| OLD | NEW |
| (Empty) |
| 1 var async; | |
| 2 (function(exports) { | |
| 3 'use strict'; | |
| 4 dart.copyProperties(exports, { | |
| 5 get _hasDocument() { | |
| 6 return dart.equals(typeof document, 'object'); | |
| 7 } | |
| 8 }); | |
| 9 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic | |
| 10 function _invokeErrorHandler(errorHandler, error, stackTrace) { | |
| 11 if (dart.is(errorHandler, ZoneBinaryCallback)) { | |
| 12 return dart.dinvokef(errorHandler, error, stackTrace); | |
| 13 } else { | |
| 14 return dart.dinvokef(errorHandler, error); | |
| 15 } | |
| 16 } | |
| 17 // Function _registerErrorHandler: (Function, Zone) → Function | |
| 18 function _registerErrorHandler(errorHandler, zone) { | |
| 19 if (dart.is(errorHandler, ZoneBinaryCallback)) { | |
| 20 return zone.registerBinaryCallback(errorHandler); | |
| 21 } else { | |
| 22 return zone.registerUnaryCallback(dart.as(errorHandler, dart.throw_("Unimp
lemented type (dynamic) → dynamic"))); | |
| 23 } | |
| 24 } | |
| 25 class _UncaughtAsyncError extends AsyncError { | |
| 26 _UncaughtAsyncError(error, stackTrace) { | |
| 27 super.AsyncError(error, _getBestStackTrace(error, stackTrace)); | |
| 28 } | |
| 29 static _getBestStackTrace(error, stackTrace) { | |
| 30 if (stackTrace !== null) | |
| 31 return stackTrace; | |
| 32 if (dart.is(error, core.Error)) { | |
| 33 return dart.as(dart.dload(error, 'stackTrace'), core.StackTrace); | |
| 34 } | |
| 35 return null; | |
| 36 } | |
| 37 toString() { | |
| 38 let result = `Uncaught Error: ${this.error}`; | |
| 39 if (this.stackTrace !== null) { | |
| 40 result = `\nStack Trace:\n${this.stackTrace}`; | |
| 41 } | |
| 42 return result; | |
| 43 } | |
| 44 } | |
| 45 let _BroadcastStream$ = dart.generic(function(T) { | |
| 46 class _BroadcastStream extends _ControllerStream$(T) { | |
| 47 _BroadcastStream(controller) { | |
| 48 super._ControllerStream(dart.as(controller, _StreamControllerLifecycle$(
T))); | |
| 49 } | |
| 50 get isBroadcast() { | |
| 51 return true; | |
| 52 } | |
| 53 } | |
| 54 return _BroadcastStream; | |
| 55 }); | |
| 56 let _BroadcastStream = _BroadcastStream$(dynamic); | |
| 57 class _BroadcastSubscriptionLink extends dart.Object { | |
| 58 _BroadcastSubscriptionLink() { | |
| 59 this._next = null; | |
| 60 this._previous = null; | |
| 61 } | |
| 62 } | |
| 63 let _BroadcastSubscription$ = dart.generic(function(T) { | |
| 64 class _BroadcastSubscription extends _ControllerSubscription$(T) { | |
| 65 _BroadcastSubscription(controller, onData, onError, onDone, cancelOnError)
{ | |
| 66 this._eventState = dart.as(null, core.int); | |
| 67 this._next = null; | |
| 68 this._previous = null; | |
| 69 super._ControllerSubscription(dart.as(controller, _StreamControllerLifec
ycle$(T)), onData, onError, onDone, cancelOnError); | |
| 70 this._next = this._previous = this; | |
| 71 } | |
| 72 get _controller() { | |
| 73 return dart.as(super._controller, _BroadcastStreamController); | |
| 74 } | |
| 75 _expectsEvent(eventId) { | |
| 76 return (this._eventState & _STATE_EVENT_ID) === eventId; | |
| 77 } | |
| 78 _toggleEventId() { | |
| 79 this._eventState = _STATE_EVENT_ID; | |
| 80 } | |
| 81 get _isFiring() { | |
| 82 return (this._eventState & _STATE_FIRING) !== 0; | |
| 83 } | |
| 84 _setRemoveAfterFiring() { | |
| 85 dart.assert(this._isFiring); | |
| 86 this._eventState = _STATE_REMOVE_AFTER_FIRING; | |
| 87 } | |
| 88 get _removeAfterFiring() { | |
| 89 return (this._eventState & _STATE_REMOVE_AFTER_FIRING) !== 0; | |
| 90 } | |
| 91 _onPause() {} | |
| 92 _onResume() {} | |
| 93 } | |
| 94 _BroadcastSubscription._STATE_EVENT_ID = 1; | |
| 95 _BroadcastSubscription._STATE_FIRING = 2; | |
| 96 _BroadcastSubscription._STATE_REMOVE_AFTER_FIRING = 4; | |
| 97 return _BroadcastSubscription; | |
| 98 }); | |
| 99 let _BroadcastSubscription = _BroadcastSubscription$(dynamic); | |
| 100 let _BroadcastStreamController$ = dart.generic(function(T) { | |
| 101 class _BroadcastStreamController extends dart.Object { | |
| 102 _BroadcastStreamController(_onListen, _onCancel) { | |
| 103 this._onListen = _onListen; | |
| 104 this._onCancel = _onCancel; | |
| 105 this._state = _STATE_INITIAL; | |
| 106 this._next = null; | |
| 107 this._previous = null; | |
| 108 this._addStreamState = null; | |
| 109 this._doneFuture = null; | |
| 110 this._next = this._previous = this; | |
| 111 } | |
| 112 get stream() { | |
| 113 return new _BroadcastStream(this); | |
| 114 } | |
| 115 get sink() { | |
| 116 return new _StreamSinkWrapper(this); | |
| 117 } | |
| 118 get isClosed() { | |
| 119 return (this._state & _STATE_CLOSED) !== 0; | |
| 120 } | |
| 121 get isPaused() { | |
| 122 return false; | |
| 123 } | |
| 124 get hasListener() { | |
| 125 return !dart.notNull(this._isEmpty); | |
| 126 } | |
| 127 get _hasOneListener() { | |
| 128 dart.assert(!dart.notNull(this._isEmpty)); | |
| 129 return core.identical(this._next._next, this); | |
| 130 } | |
| 131 get _isFiring() { | |
| 132 return (this._state & _STATE_FIRING) !== 0; | |
| 133 } | |
| 134 get _isAddingStream() { | |
| 135 return (this._state & _STATE_ADDSTREAM) !== 0; | |
| 136 } | |
| 137 get _mayAddEvent() { | |
| 138 return this._state < _STATE_CLOSED; | |
| 139 } | |
| 140 _ensureDoneFuture() { | |
| 141 if (this._doneFuture !== null) | |
| 142 return this._doneFuture; | |
| 143 return this._doneFuture = new _Future(); | |
| 144 } | |
| 145 get _isEmpty() { | |
| 146 return core.identical(this._next, this); | |
| 147 } | |
| 148 _addListener(subscription) { | |
| 149 dart.assert(core.identical(subscription._next, subscription)); | |
| 150 subscription._previous = this._previous; | |
| 151 subscription._next = this; | |
| 152 this._previous._next = subscription; | |
| 153 this._previous = subscription; | |
| 154 subscription._eventState = this._state & _STATE_EVENT_ID; | |
| 155 } | |
| 156 _removeListener(subscription) { | |
| 157 dart.assert(core.identical(subscription._controller, this)); | |
| 158 dart.assert(!dart.notNull(core.identical(subscription._next, subscriptio
n))); | |
| 159 let previous = subscription._previous; | |
| 160 let next = subscription._next; | |
| 161 previous._next = next; | |
| 162 next._previous = previous; | |
| 163 subscription._next = subscription._previous = subscription; | |
| 164 } | |
| 165 _subscribe(onData, onError, onDone, cancelOnError) { | |
| 166 if (this.isClosed) { | |
| 167 if (onDone === null) | |
| 168 onDone = _nullDoneHandler; | |
| 169 return new _DoneStreamSubscription(onDone); | |
| 170 } | |
| 171 let subscription = new _BroadcastSubscription(this, onData, onError, onD
one, cancelOnError); | |
| 172 this._addListener(dart.as(subscription, _BroadcastSubscription$(T))); | |
| 173 if (core.identical(this._next, this._previous)) { | |
| 174 _runGuarded(this._onListen); | |
| 175 } | |
| 176 return dart.as(subscription, StreamSubscription$(T)); | |
| 177 } | |
| 178 _recordCancel(subscription) { | |
| 179 if (core.identical(subscription._next, subscription)) | |
| 180 return null; | |
| 181 dart.assert(!dart.notNull(core.identical(subscription._next, subscriptio
n))); | |
| 182 if (subscription._isFiring) { | |
| 183 subscription._setRemoveAfterFiring(); | |
| 184 } else { | |
| 185 dart.assert(!dart.notNull(core.identical(subscription._next, subscript
ion))); | |
| 186 this._removeListener(subscription); | |
| 187 if (dart.notNull(!dart.notNull(this._isFiring)) && dart.notNull(this._
isEmpty)) { | |
| 188 this._callOnCancel(); | |
| 189 } | |
| 190 } | |
| 191 return null; | |
| 192 } | |
| 193 _recordPause(subscription) {} | |
| 194 _recordResume(subscription) {} | |
| 195 _addEventError() { | |
| 196 if (this.isClosed) { | |
| 197 return new core.StateError("Cannot add new events after calling close"
); | |
| 198 } | |
| 199 dart.assert(this._isAddingStream); | |
| 200 return new core.StateError("Cannot add new events while doing an addStre
am"); | |
| 201 } | |
| 202 add(data) { | |
| 203 if (!dart.notNull(this._mayAddEvent)) | |
| 204 throw this._addEventError(); | |
| 205 this._sendData(data); | |
| 206 } | |
| 207 addError(error, stackTrace) { | |
| 208 if (stackTrace === void 0) | |
| 209 stackTrace = null; | |
| 210 error = _nonNullError(error); | |
| 211 if (!dart.notNull(this._mayAddEvent)) | |
| 212 throw this._addEventError(); | |
| 213 let replacement = Zone.current.errorCallback(error, stackTrace); | |
| 214 if (replacement !== null) { | |
| 215 error = _nonNullError(replacement.error); | |
| 216 stackTrace = replacement.stackTrace; | |
| 217 } | |
| 218 this._sendError(error, stackTrace); | |
| 219 } | |
| 220 close() { | |
| 221 if (this.isClosed) { | |
| 222 dart.assert(this._doneFuture !== null); | |
| 223 return this._doneFuture; | |
| 224 } | |
| 225 if (!dart.notNull(this._mayAddEvent)) | |
| 226 throw this._addEventError(); | |
| 227 this._state = _STATE_CLOSED; | |
| 228 let doneFuture = this._ensureDoneFuture(); | |
| 229 this._sendDone(); | |
| 230 return doneFuture; | |
| 231 } | |
| 232 get done() { | |
| 233 return this._ensureDoneFuture(); | |
| 234 } | |
| 235 addStream(stream, opt$) { | |
| 236 let cancelOnError = opt$.cancelOnError === void 0 ? true : opt$.cancelOn
Error; | |
| 237 if (!dart.notNull(this._mayAddEvent)) | |
| 238 throw this._addEventError(); | |
| 239 this._state = _STATE_ADDSTREAM; | |
| 240 this._addStreamState = dart.as(new _AddStreamState(this, stream, cancelO
nError), _AddStreamState$(T)); | |
| 241 return this._addStreamState.addStreamFuture; | |
| 242 } | |
| 243 _add(data) { | |
| 244 this._sendData(data); | |
| 245 } | |
| 246 _addError(error, stackTrace) { | |
| 247 this._sendError(error, stackTrace); | |
| 248 } | |
| 249 _close() { | |
| 250 dart.assert(this._isAddingStream); | |
| 251 let addState = this._addStreamState; | |
| 252 this._addStreamState = null; | |
| 253 this._state = ~_STATE_ADDSTREAM; | |
| 254 addState.complete(); | |
| 255 } | |
| 256 _forEachListener(action) { | |
| 257 if (this._isFiring) { | |
| 258 throw new core.StateError("Cannot fire new event. Controller is alread
y firing an event"); | |
| 259 } | |
| 260 if (this._isEmpty) | |
| 261 return; | |
| 262 let id = this._state & _STATE_EVENT_ID; | |
| 263 this._state = _STATE_EVENT_ID | _STATE_FIRING; | |
| 264 let link = this._next; | |
| 265 while (!dart.notNull(core.identical(link, this))) { | |
| 266 let subscription = dart.as(link, _BroadcastSubscription$(T)); | |
| 267 if (subscription._expectsEvent(id)) { | |
| 268 subscription._eventState = _BroadcastSubscription._STATE_FIRING; | |
| 269 action(subscription); | |
| 270 subscription._toggleEventId(); | |
| 271 link = subscription._next; | |
| 272 if (subscription._removeAfterFiring) { | |
| 273 this._removeListener(subscription); | |
| 274 } | |
| 275 subscription._eventState = ~_BroadcastSubscription._STATE_FIRING; | |
| 276 } else { | |
| 277 link = subscription._next; | |
| 278 } | |
| 279 } | |
| 280 this._state = ~_STATE_FIRING; | |
| 281 if (this._isEmpty) { | |
| 282 this._callOnCancel(); | |
| 283 } | |
| 284 } | |
| 285 _callOnCancel() { | |
| 286 dart.assert(this._isEmpty); | |
| 287 if (dart.notNull(this.isClosed) && dart.notNull(this._doneFuture._mayCom
plete)) { | |
| 288 this._doneFuture._asyncComplete(null); | |
| 289 } | |
| 290 _runGuarded(this._onCancel); | |
| 291 } | |
| 292 } | |
| 293 _BroadcastStreamController._STATE_INITIAL = 0; | |
| 294 _BroadcastStreamController._STATE_EVENT_ID = 1; | |
| 295 _BroadcastStreamController._STATE_FIRING = 2; | |
| 296 _BroadcastStreamController._STATE_CLOSED = 4; | |
| 297 _BroadcastStreamController._STATE_ADDSTREAM = 8; | |
| 298 return _BroadcastStreamController; | |
| 299 }); | |
| 300 let _BroadcastStreamController = _BroadcastStreamController$(dynamic); | |
| 301 let _SyncBroadcastStreamController$ = dart.generic(function(T) { | |
| 302 class _SyncBroadcastStreamController extends _BroadcastStreamController$(T)
{ | |
| 303 _SyncBroadcastStreamController(onListen, onCancel) { | |
| 304 super._BroadcastStreamController(onListen, onCancel); | |
| 305 } | |
| 306 _sendData(data) { | |
| 307 if (this._isEmpty) | |
| 308 return; | |
| 309 if (this._hasOneListener) { | |
| 310 this._state = _BroadcastStreamController._STATE_FIRING; | |
| 311 let subscription = dart.as(this._next, _BroadcastSubscription); | |
| 312 subscription._add(data); | |
| 313 this._state = ~_BroadcastStreamController._STATE_FIRING; | |
| 314 if (this._isEmpty) { | |
| 315 this._callOnCancel(); | |
| 316 } | |
| 317 return; | |
| 318 } | |
| 319 this._forEachListener(((subscription) => { | |
| 320 subscription._add(data); | |
| 321 }).bind(this)); | |
| 322 } | |
| 323 _sendError(error, stackTrace) { | |
| 324 if (this._isEmpty) | |
| 325 return; | |
| 326 this._forEachListener(((subscription) => { | |
| 327 subscription._addError(error, stackTrace); | |
| 328 }).bind(this)); | |
| 329 } | |
| 330 _sendDone() { | |
| 331 if (!dart.notNull(this._isEmpty)) { | |
| 332 this._forEachListener(dart.as(((subscription) => { | |
| 333 subscription._close(); | |
| 334 }).bind(this), dart.throw_("Unimplemented type (_BufferingStreamSubscr
iption<T>) → void"))); | |
| 335 } else { | |
| 336 dart.assert(this._doneFuture !== null); | |
| 337 dart.assert(this._doneFuture._mayComplete); | |
| 338 this._doneFuture._asyncComplete(null); | |
| 339 } | |
| 340 } | |
| 341 } | |
| 342 return _SyncBroadcastStreamController; | |
| 343 }); | |
| 344 let _SyncBroadcastStreamController = _SyncBroadcastStreamController$(dynamic); | |
| 345 let _AsyncBroadcastStreamController$ = dart.generic(function(T) { | |
| 346 class _AsyncBroadcastStreamController extends _BroadcastStreamController$(T)
{ | |
| 347 _AsyncBroadcastStreamController(onListen, onCancel) { | |
| 348 super._BroadcastStreamController(onListen, onCancel); | |
| 349 } | |
| 350 _sendData(data) { | |
| 351 for (let link = this._next; !dart.notNull(core.identical(link, this)); l
ink = link._next) { | |
| 352 let subscription = dart.as(link, _BroadcastSubscription$(T)); | |
| 353 subscription._addPending(new _DelayedData(data)); | |
| 354 } | |
| 355 } | |
| 356 _sendError(error, stackTrace) { | |
| 357 for (let link = this._next; !dart.notNull(core.identical(link, this)); l
ink = link._next) { | |
| 358 let subscription = dart.as(link, _BroadcastSubscription$(T)); | |
| 359 subscription._addPending(new _DelayedError(error, stackTrace)); | |
| 360 } | |
| 361 } | |
| 362 _sendDone() { | |
| 363 if (!dart.notNull(this._isEmpty)) { | |
| 364 for (let link = this._next; !dart.notNull(core.identical(link, this));
link = link._next) { | |
| 365 let subscription = dart.as(link, _BroadcastSubscription$(T)); | |
| 366 subscription._addPending(new _DelayedDone()); | |
| 367 } | |
| 368 } else { | |
| 369 dart.assert(this._doneFuture !== null); | |
| 370 dart.assert(this._doneFuture._mayComplete); | |
| 371 this._doneFuture._asyncComplete(null); | |
| 372 } | |
| 373 } | |
| 374 } | |
| 375 return _AsyncBroadcastStreamController; | |
| 376 }); | |
| 377 let _AsyncBroadcastStreamController = _AsyncBroadcastStreamController$(dynamic
); | |
| 378 let _AsBroadcastStreamController$ = dart.generic(function(T) { | |
| 379 class _AsBroadcastStreamController extends _SyncBroadcastStreamController$(T
) { | |
| 380 _AsBroadcastStreamController(onListen, onCancel) { | |
| 381 this._pending = null; | |
| 382 super._SyncBroadcastStreamController(onListen, onCancel); | |
| 383 } | |
| 384 get _hasPending() { | |
| 385 return dart.notNull(this._pending !== null) && dart.notNull(!dart.notNul
l(this._pending.isEmpty)); | |
| 386 } | |
| 387 _addPendingEvent(event) { | |
| 388 if (this._pending === null) { | |
| 389 this._pending = new _StreamImplEvents(); | |
| 390 } | |
| 391 this._pending.add(event); | |
| 392 } | |
| 393 add(data) { | |
| 394 if (dart.notNull(!dart.notNull(this.isClosed)) && dart.notNull(this._isF
iring)) { | |
| 395 this._addPendingEvent(new _DelayedData(data)); | |
| 396 return; | |
| 397 } | |
| 398 super.add(data); | |
| 399 while (this._hasPending) { | |
| 400 this._pending.handleNext(this); | |
| 401 } | |
| 402 } | |
| 403 addError(error, stackTrace) { | |
| 404 if (stackTrace === void 0) | |
| 405 stackTrace = null; | |
| 406 if (dart.notNull(!dart.notNull(this.isClosed)) && dart.notNull(this._isF
iring)) { | |
| 407 this._addPendingEvent(new _DelayedError(error, stackTrace)); | |
| 408 return; | |
| 409 } | |
| 410 if (!dart.notNull(this._mayAddEvent)) | |
| 411 throw this._addEventError(); | |
| 412 this._sendError(error, stackTrace); | |
| 413 while (this._hasPending) { | |
| 414 this._pending.handleNext(this); | |
| 415 } | |
| 416 } | |
| 417 close() { | |
| 418 if (dart.notNull(!dart.notNull(this.isClosed)) && dart.notNull(this._isF
iring)) { | |
| 419 this._addPendingEvent(new _DelayedDone()); | |
| 420 this._state = _BroadcastStreamController._STATE_CLOSED; | |
| 421 return super.done; | |
| 422 } | |
| 423 let result = super.close(); | |
| 424 dart.assert(!dart.notNull(this._hasPending)); | |
| 425 return result; | |
| 426 } | |
| 427 _callOnCancel() { | |
| 428 if (this._hasPending) { | |
| 429 this._pending.clear(); | |
| 430 this._pending = null; | |
| 431 } | |
| 432 super._callOnCancel(); | |
| 433 } | |
| 434 } | |
| 435 return _AsBroadcastStreamController; | |
| 436 }); | |
| 437 let _AsBroadcastStreamController = _AsBroadcastStreamController$(dynamic); | |
| 438 let _DoneSubscription$ = dart.generic(function(T) { | |
| 439 class _DoneSubscription extends dart.Object { | |
| 440 _DoneSubscription() { | |
| 441 this._pauseCount = 0; | |
| 442 } | |
| 443 onData(handleData) {} | |
| 444 onError(handleError) {} | |
| 445 onDone(handleDone) {} | |
| 446 pause(resumeSignal) { | |
| 447 if (resumeSignal === void 0) | |
| 448 resumeSignal = null; | |
| 449 if (resumeSignal !== null) | |
| 450 resumeSignal.then(this._resume); | |
| 451 this._pauseCount++; | |
| 452 } | |
| 453 resume() { | |
| 454 this._resume(null); | |
| 455 } | |
| 456 _resume(_) { | |
| 457 if (this._pauseCount > 0) | |
| 458 this._pauseCount--; | |
| 459 } | |
| 460 cancel() { | |
| 461 return new _Future.immediate(null); | |
| 462 } | |
| 463 get isPaused() { | |
| 464 return this._pauseCount > 0; | |
| 465 } | |
| 466 asFuture(value) { | |
| 467 if (value === void 0) | |
| 468 value = null; | |
| 469 return new _Future(); | |
| 470 } | |
| 471 } | |
| 472 return _DoneSubscription; | |
| 473 }); | |
| 474 let _DoneSubscription = _DoneSubscription$(dynamic); | |
| 475 class DeferredLibrary extends dart.Object { | |
| 476 DeferredLibrary(libraryName, opt$) { | |
| 477 let uri = opt$.uri === void 0 ? null : opt$.uri; | |
| 478 this.libraryName = libraryName; | |
| 479 this.uri = uri; | |
| 480 } | |
| 481 load() { | |
| 482 throw 'DeferredLibrary not supported. ' + 'please use the `import "lib.dar
t" deferred as lib` syntax.'; | |
| 483 } | |
| 484 } | |
| 485 class DeferredLoadException extends dart.Object { | |
| 486 DeferredLoadException(_s) { | |
| 487 this._s = _s; | |
| 488 } | |
| 489 toString() { | |
| 490 return `DeferredLoadException: '${this._s}'`; | |
| 491 } | |
| 492 } | |
| 493 let Future$ = dart.generic(function(T) { | |
| 494 class Future extends dart.Object { | |
| 495 Future(computation) { | |
| 496 let result = new _Future(); | |
| 497 Timer.run((() => { | |
| 498 try { | |
| 499 result._complete(computation()); | |
| 500 } catch (e) { | |
| 501 let s = dart.stackTrace(e); | |
| 502 _completeWithErrorCallback(result, e, s); | |
| 503 } | |
| 504 | |
| 505 }).bind(this)); | |
| 506 return dart.as(result, Future$(T)); | |
| 507 } | |
| 508 Future$microtask(computation) { | |
| 509 let result = new _Future(); | |
| 510 scheduleMicrotask((() => { | |
| 511 try { | |
| 512 result._complete(computation()); | |
| 513 } catch (e) { | |
| 514 let s = dart.stackTrace(e); | |
| 515 _completeWithErrorCallback(result, e, s); | |
| 516 } | |
| 517 | |
| 518 }).bind(this)); | |
| 519 return dart.as(result, Future$(T)); | |
| 520 } | |
| 521 Future$sync(computation) { | |
| 522 try { | |
| 523 let result = computation(); | |
| 524 return new Future.value(result); | |
| 525 } catch (error) { | |
| 526 let stackTrace = dart.stackTrace(error); | |
| 527 return new Future.error(error, stackTrace); | |
| 528 } | |
| 529 | |
| 530 } | |
| 531 Future$value(value) { | |
| 532 if (value === void 0) | |
| 533 value = null; | |
| 534 return new _Future.immediate(value); | |
| 535 } | |
| 536 Future$error(error, stackTrace) { | |
| 537 if (stackTrace === void 0) | |
| 538 stackTrace = null; | |
| 539 error = _nonNullError(error); | |
| 540 if (!dart.notNull(core.identical(Zone.current, _ROOT_ZONE))) { | |
| 541 let replacement = Zone.current.errorCallback(error, stackTrace); | |
| 542 if (replacement !== null) { | |
| 543 error = _nonNullError(replacement.error); | |
| 544 stackTrace = replacement.stackTrace; | |
| 545 } | |
| 546 } | |
| 547 return new _Future.immediateError(error, stackTrace); | |
| 548 } | |
| 549 Future$delayed(duration, computation) { | |
| 550 if (computation === void 0) | |
| 551 computation = null; | |
| 552 let result = new _Future(); | |
| 553 new Timer(duration, (() => { | |
| 554 try { | |
| 555 result._complete(computation === null ? null : computation()); | |
| 556 } catch (e) { | |
| 557 let s = dart.stackTrace(e); | |
| 558 _completeWithErrorCallback(result, e, s); | |
| 559 } | |
| 560 | |
| 561 }).bind(this)); | |
| 562 return dart.as(result, Future$(T)); | |
| 563 } | |
| 564 static wait(futures, opt$) { | |
| 565 let eagerError = opt$.eagerError === void 0 ? false : opt$.eagerError; | |
| 566 let cleanUp = opt$.cleanUp === void 0 ? null : opt$.cleanUp; | |
| 567 let result = new _Future(); | |
| 568 let values = null; | |
| 569 let remaining = 0; | |
| 570 let error = null; | |
| 571 let stackTrace = null; | |
| 572 // Function handleError: (dynamic, dynamic) → void | |
| 573 function handleError(theError, theStackTrace) { | |
| 574 remaining--; | |
| 575 if (values !== null) { | |
| 576 if (cleanUp !== null) { | |
| 577 for (let value of values) { | |
| 578 if (value !== null) { | |
| 579 new Future.sync(() => { | |
| 580 cleanUp(value); | |
| 581 }); | |
| 582 } | |
| 583 } | |
| 584 } | |
| 585 values = null; | |
| 586 if (dart.notNull(remaining === 0) || dart.notNull(eagerError)) { | |
| 587 result._completeError(theError, dart.as(theStackTrace, core.StackT
race)); | |
| 588 } else { | |
| 589 error = theError; | |
| 590 stackTrace = dart.as(theStackTrace, core.StackTrace); | |
| 591 } | |
| 592 } else if (dart.notNull(remaining === 0) && dart.notNull(!dart.notNull
(eagerError))) { | |
| 593 result._completeError(error, stackTrace); | |
| 594 } | |
| 595 } | |
| 596 for (let future of futures) { | |
| 597 let pos = remaining++; | |
| 598 future.then(dart.as(((value) => { | |
| 599 remaining--; | |
| 600 if (values !== null) { | |
| 601 values.set(pos, value); | |
| 602 if (remaining === 0) { | |
| 603 result._completeWithValue(values); | |
| 604 } | |
| 605 } else { | |
| 606 if (dart.notNull(cleanUp !== null) && dart.notNull(value !== null)
) { | |
| 607 new Future.sync(() => { | |
| 608 cleanUp(value); | |
| 609 }); | |
| 610 } | |
| 611 if (dart.notNull(remaining === 0) && dart.notNull(!dart.notNull(ea
gerError))) { | |
| 612 result._completeError(error, stackTrace); | |
| 613 } | |
| 614 } | |
| 615 }).bind(this), dart.throw_("Unimplemented type (dynamic) → dynamic")),
{onError: handleError}); | |
| 616 } | |
| 617 if (remaining === 0) { | |
| 618 return dart.as(new Future.value(/* Unimplemented const */new List.from
([])), Future$(core.List)); | |
| 619 } | |
| 620 values = new core.List(remaining); | |
| 621 return result; | |
| 622 } | |
| 623 static forEach(input, f) { | |
| 624 let iterator = input.iterator; | |
| 625 return doWhile((() => { | |
| 626 if (!dart.notNull(iterator.moveNext())) | |
| 627 return false; | |
| 628 return new Future.sync((() => f(iterator.current)).bind(this)).then((_
) => true); | |
| 629 }).bind(this)); | |
| 630 } | |
| 631 static doWhile(f) { | |
| 632 let doneSignal = new _Future(); | |
| 633 let nextIteration = null; | |
| 634 nextIteration = Zone.current.bindUnaryCallback(dart.as(((keepGoing) => { | |
| 635 if (keepGoing) { | |
| 636 new Future.sync(f).then(dart.as(nextIteration, dart.throw_("Unimplem
ented type (dynamic) → dynamic")), {onError: doneSignal._completeError}); | |
| 637 } else { | |
| 638 doneSignal._complete(null); | |
| 639 } | |
| 640 }).bind(this), dart.throw_("Unimplemented type (dynamic) → dynamic")), {
runGuarded: true}); | |
| 641 dart.dinvokef(nextIteration, true); | |
| 642 return doneSignal; | |
| 643 } | |
| 644 } | |
| 645 dart.defineNamedConstructor(Future, 'microtask'); | |
| 646 dart.defineNamedConstructor(Future, 'sync'); | |
| 647 dart.defineNamedConstructor(Future, 'value'); | |
| 648 dart.defineNamedConstructor(Future, 'error'); | |
| 649 dart.defineNamedConstructor(Future, 'delayed'); | |
| 650 dart.defineLazyProperties(Future, { | |
| 651 get _nullFuture() { | |
| 652 return dart.as(new Future.value(null), _Future); | |
| 653 } | |
| 654 }); | |
| 655 return Future; | |
| 656 }); | |
| 657 let Future = Future$(dynamic); | |
| 658 class TimeoutException extends dart.Object { | |
| 659 TimeoutException(message, duration) { | |
| 660 if (duration === void 0) | |
| 661 duration = null; | |
| 662 this.message = message; | |
| 663 this.duration = duration; | |
| 664 } | |
| 665 toString() { | |
| 666 let result = "TimeoutException"; | |
| 667 if (this.duration !== null) | |
| 668 result = `TimeoutException after ${this.duration}`; | |
| 669 if (this.message !== null) | |
| 670 result = `${result}: ${this.message}`; | |
| 671 return result; | |
| 672 } | |
| 673 } | |
| 674 let Completer$ = dart.generic(function(T) { | |
| 675 class Completer extends dart.Object { | |
| 676 Completer() { | |
| 677 return new _AsyncCompleter(); | |
| 678 } | |
| 679 Completer$sync() { | |
| 680 return new _SyncCompleter(); | |
| 681 } | |
| 682 } | |
| 683 dart.defineNamedConstructor(Completer, 'sync'); | |
| 684 return Completer; | |
| 685 }); | |
| 686 let Completer = Completer$(dynamic); | |
| 687 // Function _completeWithErrorCallback: (_Future<dynamic>, dynamic, dynamic) →
void | |
| 688 function _completeWithErrorCallback(result, error, stackTrace) { | |
| 689 let replacement = Zone.current.errorCallback(error, dart.as(stackTrace, core
.StackTrace)); | |
| 690 if (replacement !== null) { | |
| 691 error = _nonNullError(replacement.error); | |
| 692 stackTrace = replacement.stackTrace; | |
| 693 } | |
| 694 result._completeError(error, dart.as(stackTrace, core.StackTrace)); | |
| 695 } | |
| 696 // Function _nonNullError: (Object) → Object | |
| 697 function _nonNullError(error) { | |
| 698 return error !== null ? error : new core.NullThrownError(); | |
| 699 } | |
| 700 let _Completer$ = dart.generic(function(T) { | |
| 701 class _Completer extends dart.Object { | |
| 702 _Completer() { | |
| 703 this.future = new _Future(); | |
| 704 } | |
| 705 completeError(error, stackTrace) { | |
| 706 if (stackTrace === void 0) | |
| 707 stackTrace = null; | |
| 708 error = _nonNullError(error); | |
| 709 if (!dart.notNull(this.future._mayComplete)) | |
| 710 throw new core.StateError("Future already completed"); | |
| 711 let replacement = Zone.current.errorCallback(error, stackTrace); | |
| 712 if (replacement !== null) { | |
| 713 error = _nonNullError(replacement.error); | |
| 714 stackTrace = replacement.stackTrace; | |
| 715 } | |
| 716 this._completeError(error, stackTrace); | |
| 717 } | |
| 718 get isCompleted() { | |
| 719 return !dart.notNull(this.future._mayComplete); | |
| 720 } | |
| 721 } | |
| 722 return _Completer; | |
| 723 }); | |
| 724 let _Completer = _Completer$(dynamic); | |
| 725 let _AsyncCompleter$ = dart.generic(function(T) { | |
| 726 class _AsyncCompleter extends _Completer$(T) { | |
| 727 complete(value) { | |
| 728 if (value === void 0) | |
| 729 value = null; | |
| 730 if (!dart.notNull(this.future._mayComplete)) | |
| 731 throw new core.StateError("Future already completed"); | |
| 732 this.future._asyncComplete(value); | |
| 733 } | |
| 734 _completeError(error, stackTrace) { | |
| 735 this.future._asyncCompleteError(error, stackTrace); | |
| 736 } | |
| 737 } | |
| 738 return _AsyncCompleter; | |
| 739 }); | |
| 740 let _AsyncCompleter = _AsyncCompleter$(dynamic); | |
| 741 let _SyncCompleter$ = dart.generic(function(T) { | |
| 742 class _SyncCompleter extends _Completer$(T) { | |
| 743 complete(value) { | |
| 744 if (value === void 0) | |
| 745 value = null; | |
| 746 if (!dart.notNull(this.future._mayComplete)) | |
| 747 throw new core.StateError("Future already completed"); | |
| 748 this.future._complete(value); | |
| 749 } | |
| 750 _completeError(error, stackTrace) { | |
| 751 this.future._completeError(error, stackTrace); | |
| 752 } | |
| 753 } | |
| 754 return _SyncCompleter; | |
| 755 }); | |
| 756 let _SyncCompleter = _SyncCompleter$(dynamic); | |
| 757 class _FutureListener extends dart.Object { | |
| 758 _FutureListener$then(result, onValue, errorCallback) { | |
| 759 this.result = result; | |
| 760 this.callback = onValue; | |
| 761 this.errorCallback = errorCallback; | |
| 762 this.state = errorCallback === null ? STATE_THEN : STATE_THEN_ONERROR; | |
| 763 this._nextListener = null; | |
| 764 } | |
| 765 _FutureListener$catchError(result, errorCallback, test) { | |
| 766 this.result = result; | |
| 767 this.errorCallback = errorCallback; | |
| 768 this.callback = test; | |
| 769 this.state = test === null ? STATE_CATCHERROR : STATE_CATCHERROR_TEST; | |
| 770 this._nextListener = null; | |
| 771 } | |
| 772 _FutureListener$whenComplete(result, onComplete) { | |
| 773 this.result = result; | |
| 774 this.callback = onComplete; | |
| 775 this.errorCallback = null; | |
| 776 this.state = STATE_WHENCOMPLETE; | |
| 777 this._nextListener = null; | |
| 778 } | |
| 779 _FutureListener$chain(result) { | |
| 780 this.result = result; | |
| 781 this.callback = null; | |
| 782 this.errorCallback = null; | |
| 783 this.state = STATE_CHAIN; | |
| 784 this._nextListener = null; | |
| 785 } | |
| 786 get _zone() { | |
| 787 return this.result._zone; | |
| 788 } | |
| 789 get handlesValue() { | |
| 790 return (this.state & MASK_VALUE) !== 0; | |
| 791 } | |
| 792 get handlesError() { | |
| 793 return (this.state & MASK_ERROR) !== 0; | |
| 794 } | |
| 795 get hasErrorTest() { | |
| 796 return this.state === STATE_CATCHERROR_TEST; | |
| 797 } | |
| 798 get handlesComplete() { | |
| 799 return this.state === STATE_WHENCOMPLETE; | |
| 800 } | |
| 801 get _onValue() { | |
| 802 dart.assert(this.handlesValue); | |
| 803 return dart.as(this.callback, _FutureOnValue); | |
| 804 } | |
| 805 get _onError() { | |
| 806 return this.errorCallback; | |
| 807 } | |
| 808 get _errorTest() { | |
| 809 dart.assert(this.hasErrorTest); | |
| 810 return dart.as(this.callback, _FutureErrorTest); | |
| 811 } | |
| 812 get _whenCompleteAction() { | |
| 813 dart.assert(this.handlesComplete); | |
| 814 return dart.as(this.callback, _FutureAction); | |
| 815 } | |
| 816 } | |
| 817 dart.defineNamedConstructor(_FutureListener, 'then'); | |
| 818 dart.defineNamedConstructor(_FutureListener, 'catchError'); | |
| 819 dart.defineNamedConstructor(_FutureListener, 'whenComplete'); | |
| 820 dart.defineNamedConstructor(_FutureListener, 'chain'); | |
| 821 _FutureListener.MASK_VALUE = 1; | |
| 822 _FutureListener.MASK_ERROR = 2; | |
| 823 _FutureListener.MASK_TEST_ERROR = 4; | |
| 824 _FutureListener.MASK_WHENCOMPLETE = 8; | |
| 825 _FutureListener.STATE_CHAIN = 0; | |
| 826 _FutureListener.STATE_THEN = MASK_VALUE; | |
| 827 _FutureListener.STATE_THEN_ONERROR = MASK_VALUE | MASK_ERROR; | |
| 828 _FutureListener.STATE_CATCHERROR = MASK_ERROR; | |
| 829 _FutureListener.STATE_CATCHERROR_TEST = MASK_ERROR | MASK_TEST_ERROR; | |
| 830 _FutureListener.STATE_WHENCOMPLETE = MASK_WHENCOMPLETE; | |
| 831 let _Future$ = dart.generic(function(T) { | |
| 832 class _Future extends dart.Object { | |
| 833 _Future() { | |
| 834 this._zone = Zone.current; | |
| 835 this._state = _INCOMPLETE; | |
| 836 this._resultOrListeners = null; | |
| 837 } | |
| 838 _Future$immediate(value) { | |
| 839 this._zone = Zone.current; | |
| 840 this._state = _INCOMPLETE; | |
| 841 this._resultOrListeners = null; | |
| 842 this._asyncComplete(value); | |
| 843 } | |
| 844 _Future$immediateError(error, stackTrace) { | |
| 845 if (stackTrace === void 0) | |
| 846 stackTrace = null; | |
| 847 this._zone = Zone.current; | |
| 848 this._state = _INCOMPLETE; | |
| 849 this._resultOrListeners = null; | |
| 850 this._asyncCompleteError(error, stackTrace); | |
| 851 } | |
| 852 get _mayComplete() { | |
| 853 return this._state === _INCOMPLETE; | |
| 854 } | |
| 855 get _isChained() { | |
| 856 return this._state === _CHAINED; | |
| 857 } | |
| 858 get _isComplete() { | |
| 859 return this._state >= _VALUE; | |
| 860 } | |
| 861 get _hasValue() { | |
| 862 return this._state === _VALUE; | |
| 863 } | |
| 864 get _hasError() { | |
| 865 return this._state === _ERROR; | |
| 866 } | |
| 867 set _isChained(value) { | |
| 868 if (value) { | |
| 869 dart.assert(!dart.notNull(this._isComplete)); | |
| 870 this._state = _CHAINED; | |
| 871 } else { | |
| 872 dart.assert(this._isChained); | |
| 873 this._state = _INCOMPLETE; | |
| 874 } | |
| 875 } | |
| 876 then(f, opt$) { | |
| 877 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 878 let result = new _Future(); | |
| 879 if (!dart.notNull(core.identical(result._zone, _ROOT_ZONE))) { | |
| 880 f = result._zone.registerUnaryCallback(dart.as(f, dart.throw_("Unimple
mented type (dynamic) → dynamic"))); | |
| 881 if (onError !== null) { | |
| 882 onError = _registerErrorHandler(onError, result._zone); | |
| 883 } | |
| 884 } | |
| 885 this._addListener(new _FutureListener.then(result, dart.as(f, _FutureOnV
alue), onError)); | |
| 886 return result; | |
| 887 } | |
| 888 catchError(onError, opt$) { | |
| 889 let test = opt$.test === void 0 ? null : opt$.test; | |
| 890 let result = new _Future(); | |
| 891 if (!dart.notNull(core.identical(result._zone, _ROOT_ZONE))) { | |
| 892 onError = _registerErrorHandler(onError, result._zone); | |
| 893 if (test !== null) | |
| 894 test = dart.as(result._zone.registerUnaryCallback(test), dart.throw_
("Unimplemented type (dynamic) → bool")); | |
| 895 } | |
| 896 this._addListener(new _FutureListener.catchError(result, onError, test))
; | |
| 897 return result; | |
| 898 } | |
| 899 whenComplete(action) { | |
| 900 let result = new _Future(); | |
| 901 if (!dart.notNull(core.identical(result._zone, _ROOT_ZONE))) { | |
| 902 action = result._zone.registerCallback(action); | |
| 903 } | |
| 904 this._addListener(new _FutureListener.whenComplete(result, action)); | |
| 905 return dart.as(result, Future$(T)); | |
| 906 } | |
| 907 asStream() { | |
| 908 return dart.as(new Stream.fromFuture(this), Stream$(T)); | |
| 909 } | |
| 910 _markPendingCompletion() { | |
| 911 if (!dart.notNull(this._mayComplete)) | |
| 912 throw new core.StateError("Future already completed"); | |
| 913 this._state = _PENDING_COMPLETE; | |
| 914 } | |
| 915 get _value() { | |
| 916 dart.assert(dart.notNull(this._isComplete) && dart.notNull(this._hasValu
e)); | |
| 917 return dart.as(this._resultOrListeners, T); | |
| 918 } | |
| 919 get _error() { | |
| 920 dart.assert(dart.notNull(this._isComplete) && dart.notNull(this._hasErro
r)); | |
| 921 return dart.as(this._resultOrListeners, AsyncError); | |
| 922 } | |
| 923 _setValue(value) { | |
| 924 dart.assert(!dart.notNull(this._isComplete)); | |
| 925 this._state = _VALUE; | |
| 926 this._resultOrListeners = value; | |
| 927 } | |
| 928 _setErrorObject(error) { | |
| 929 dart.assert(!dart.notNull(this._isComplete)); | |
| 930 this._state = _ERROR; | |
| 931 this._resultOrListeners = error; | |
| 932 } | |
| 933 _setError(error, stackTrace) { | |
| 934 this._setErrorObject(new AsyncError(error, stackTrace)); | |
| 935 } | |
| 936 _addListener(listener) { | |
| 937 dart.assert(listener._nextListener === null); | |
| 938 if (this._isComplete) { | |
| 939 this._zone.scheduleMicrotask((() => { | |
| 940 _propagateToListeners(this, listener); | |
| 941 }).bind(this)); | |
| 942 } else { | |
| 943 listener._nextListener = dart.as(this._resultOrListeners, _FutureListe
ner); | |
| 944 this._resultOrListeners = listener; | |
| 945 } | |
| 946 } | |
| 947 _removeListeners() { | |
| 948 dart.assert(!dart.notNull(this._isComplete)); | |
| 949 let current = dart.as(this._resultOrListeners, _FutureListener); | |
| 950 this._resultOrListeners = null; | |
| 951 let prev = null; | |
| 952 while (current !== null) { | |
| 953 let next = current._nextListener; | |
| 954 current._nextListener = prev; | |
| 955 prev = current; | |
| 956 current = next; | |
| 957 } | |
| 958 return prev; | |
| 959 } | |
| 960 static _chainForeignFuture(source, target) { | |
| 961 dart.assert(!dart.notNull(target._isComplete)); | |
| 962 dart.assert(!dart.is(source, _Future)); | |
| 963 target._isChained = true; | |
| 964 source.then(((value) => { | |
| 965 dart.assert(target._isChained); | |
| 966 target._completeWithValue(value); | |
| 967 }).bind(this), {onError: ((error, stackTrace) => { | |
| 968 if (stackTrace === void 0) | |
| 969 stackTrace = null; | |
| 970 dart.assert(target._isChained); | |
| 971 target._completeError(error, dart.as(stackTrace, core.StackTrace)); | |
| 972 }).bind(this)}); | |
| 973 } | |
| 974 static _chainCoreFuture(source, target) { | |
| 975 dart.assert(!dart.notNull(target._isComplete)); | |
| 976 dart.assert(dart.is(source, _Future)); | |
| 977 target._isChained = true; | |
| 978 let listener = new _FutureListener.chain(target); | |
| 979 if (source._isComplete) { | |
| 980 _propagateToListeners(source, listener); | |
| 981 } else { | |
| 982 source._addListener(listener); | |
| 983 } | |
| 984 } | |
| 985 _complete(value) { | |
| 986 dart.assert(!dart.notNull(this._isComplete)); | |
| 987 if (dart.is(value, Future)) { | |
| 988 if (dart.is(value, _Future)) { | |
| 989 _chainCoreFuture(dart.as(value, _Future), this); | |
| 990 } else { | |
| 991 _chainForeignFuture(dart.as(value, Future), this); | |
| 992 } | |
| 993 } else { | |
| 994 let listeners = this._removeListeners(); | |
| 995 this._setValue(dart.as(value, T)); | |
| 996 _propagateToListeners(this, listeners); | |
| 997 } | |
| 998 } | |
| 999 _completeWithValue(value) { | |
| 1000 dart.assert(!dart.notNull(this._isComplete)); | |
| 1001 dart.assert(!dart.is(value, Future)); | |
| 1002 let listeners = this._removeListeners(); | |
| 1003 this._setValue(dart.as(value, T)); | |
| 1004 _propagateToListeners(this, listeners); | |
| 1005 } | |
| 1006 _completeError(error, stackTrace) { | |
| 1007 if (stackTrace === void 0) | |
| 1008 stackTrace = null; | |
| 1009 dart.assert(!dart.notNull(this._isComplete)); | |
| 1010 let listeners = this._removeListeners(); | |
| 1011 this._setError(error, stackTrace); | |
| 1012 _propagateToListeners(this, listeners); | |
| 1013 } | |
| 1014 _asyncComplete(value) { | |
| 1015 dart.assert(!dart.notNull(this._isComplete)); | |
| 1016 if (value === null) { | |
| 1017 } else if (dart.is(value, Future)) { | |
| 1018 let typedFuture = dart.as(value, Future$(T)); | |
| 1019 if (dart.is(typedFuture, _Future)) { | |
| 1020 let coreFuture = dart.as(typedFuture, _Future$(T)); | |
| 1021 if (dart.notNull(coreFuture._isComplete) && dart.notNull(coreFuture.
_hasError)) { | |
| 1022 this._markPendingCompletion(); | |
| 1023 this._zone.scheduleMicrotask((() => { | |
| 1024 _chainCoreFuture(coreFuture, this); | |
| 1025 }).bind(this)); | |
| 1026 } else { | |
| 1027 _chainCoreFuture(coreFuture, this); | |
| 1028 } | |
| 1029 } else { | |
| 1030 _chainForeignFuture(typedFuture, this); | |
| 1031 } | |
| 1032 return; | |
| 1033 } else { | |
| 1034 let typedValue = dart.as(value, T); | |
| 1035 } | |
| 1036 this._markPendingCompletion(); | |
| 1037 this._zone.scheduleMicrotask((() => { | |
| 1038 this._completeWithValue(value); | |
| 1039 }).bind(this)); | |
| 1040 } | |
| 1041 _asyncCompleteError(error, stackTrace) { | |
| 1042 dart.assert(!dart.notNull(this._isComplete)); | |
| 1043 this._markPendingCompletion(); | |
| 1044 this._zone.scheduleMicrotask((() => { | |
| 1045 this._completeError(error, stackTrace); | |
| 1046 }).bind(this)); | |
| 1047 } | |
| 1048 static _propagateToListeners(source, listeners) { | |
| 1049 while (true) { | |
| 1050 dart.assert(source._isComplete); | |
| 1051 let hasError = source._hasError; | |
| 1052 if (listeners === null) { | |
| 1053 if (hasError) { | |
| 1054 let asyncError = source._error; | |
| 1055 source._zone.handleUncaughtError(asyncError.error, asyncError.stac
kTrace); | |
| 1056 } | |
| 1057 return; | |
| 1058 } | |
| 1059 while (listeners._nextListener !== null) { | |
| 1060 let listener = listeners; | |
| 1061 listeners = listener._nextListener; | |
| 1062 listener._nextListener = null; | |
| 1063 _propagateToListeners(source, listener); | |
| 1064 } | |
| 1065 let listener = listeners; | |
| 1066 let listenerHasValue = true; | |
| 1067 let sourceValue = hasError ? null : source._value; | |
| 1068 let listenerValueOrError = sourceValue; | |
| 1069 let isPropagationAborted = false; | |
| 1070 if (dart.notNull(hasError) || dart.notNull(dart.notNull(listener.handl
esValue) || dart.notNull(listener.handlesComplete))) { | |
| 1071 let zone = listener._zone; | |
| 1072 if (dart.notNull(hasError) && dart.notNull(!dart.notNull(source._zon
e.inSameErrorZone(zone)))) { | |
| 1073 let asyncError = source._error; | |
| 1074 source._zone.handleUncaughtError(asyncError.error, asyncError.stac
kTrace); | |
| 1075 return; | |
| 1076 } | |
| 1077 let oldZone = null; | |
| 1078 if (!dart.notNull(core.identical(Zone.current, zone))) { | |
| 1079 oldZone = Zone._enter(zone); | |
| 1080 } | |
| 1081 // Function handleValueCallback: () → bool | |
| 1082 function handleValueCallback() { | |
| 1083 try { | |
| 1084 listenerValueOrError = zone.runUnary(listener._onValue, sourceVa
lue); | |
| 1085 return true; | |
| 1086 } catch (e) { | |
| 1087 let s = dart.stackTrace(e); | |
| 1088 listenerValueOrError = new AsyncError(e, s); | |
| 1089 return false; | |
| 1090 } | |
| 1091 | |
| 1092 } | |
| 1093 // Function handleError: () → void | |
| 1094 function handleError() { | |
| 1095 let asyncError = source._error; | |
| 1096 let matchesTest = true; | |
| 1097 if (listener.hasErrorTest) { | |
| 1098 let test = listener._errorTest; | |
| 1099 try { | |
| 1100 matchesTest = dart.as(zone.runUnary(test, asyncError.error), c
ore.bool); | |
| 1101 } catch (e) { | |
| 1102 let s = dart.stackTrace(e); | |
| 1103 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); | |
| 1104 listenerHasValue = false; | |
| 1105 return; | |
| 1106 } | |
| 1107 | |
| 1108 } | |
| 1109 let errorCallback = listener._onError; | |
| 1110 if (dart.notNull(matchesTest) && dart.notNull(errorCallback !== nu
ll)) { | |
| 1111 try { | |
| 1112 if (dart.is(errorCallback, ZoneBinaryCallback)) { | |
| 1113 listenerValueOrError = zone.runBinary(errorCallback, asyncEr
ror.error, asyncError.stackTrace); | |
| 1114 } else { | |
| 1115 listenerValueOrError = zone.runUnary(dart.as(errorCallback,
dart.throw_("Unimplemented type (dynamic) → dynamic")), asyncError.error); | |
| 1116 } | |
| 1117 } catch (e) { | |
| 1118 let s = dart.stackTrace(e); | |
| 1119 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); | |
| 1120 listenerHasValue = false; | |
| 1121 return; | |
| 1122 } | |
| 1123 | |
| 1124 listenerHasValue = true; | |
| 1125 } else { | |
| 1126 listenerValueOrError = asyncError; | |
| 1127 listenerHasValue = false; | |
| 1128 } | |
| 1129 } | |
| 1130 // Function handleWhenCompleteCallback: () → void | |
| 1131 function handleWhenCompleteCallback() { | |
| 1132 let completeResult = null; | |
| 1133 try { | |
| 1134 completeResult = zone.run(listener._whenCompleteAction); | |
| 1135 } catch (e) { | |
| 1136 let s = dart.stackTrace(e); | |
| 1137 if (dart.notNull(hasError) && dart.notNull(core.identical(source
._error.error, e))) { | |
| 1138 listenerValueOrError = source._error; | |
| 1139 } else { | |
| 1140 listenerValueOrError = new AsyncError(e, s); | |
| 1141 } | |
| 1142 listenerHasValue = false; | |
| 1143 return; | |
| 1144 } | |
| 1145 | |
| 1146 if (dart.is(completeResult, Future)) { | |
| 1147 let result = listener.result; | |
| 1148 result._isChained = true; | |
| 1149 isPropagationAborted = true; | |
| 1150 dart.dinvoke(completeResult, 'then', (ignored) => { | |
| 1151 _propagateToListeners(source, new _FutureListener.chain(result
)); | |
| 1152 }, { | |
| 1153 onError: (error, stackTrace) => { | |
| 1154 if (stackTrace === void 0) | |
| 1155 stackTrace = null; | |
| 1156 if (!dart.is(completeResult, _Future)) { | |
| 1157 completeResult = new _Future(); | |
| 1158 dart.dinvoke(completeResult, '_setError', error, stackTrac
e); | |
| 1159 } | |
| 1160 _propagateToListeners(dart.as(completeResult, _Future), new
_FutureListener.chain(result)); | |
| 1161 } | |
| 1162 }); | |
| 1163 } | |
| 1164 } | |
| 1165 if (!dart.notNull(hasError)) { | |
| 1166 if (listener.handlesValue) { | |
| 1167 listenerHasValue = handleValueCallback(); | |
| 1168 } | |
| 1169 } else { | |
| 1170 handleError(); | |
| 1171 } | |
| 1172 if (listener.handlesComplete) { | |
| 1173 handleWhenCompleteCallback(); | |
| 1174 } | |
| 1175 if (oldZone !== null) | |
| 1176 Zone._leave(oldZone); | |
| 1177 if (isPropagationAborted) | |
| 1178 return; | |
| 1179 if (dart.notNull(dart.notNull(listenerHasValue) && dart.notNull(!dar
t.notNull(core.identical(sourceValue, listenerValueOrError)))) && dart.notNull(d
art.is(listenerValueOrError, Future))) { | |
| 1180 let chainSource = dart.as(listenerValueOrError, Future); | |
| 1181 let result = listener.result; | |
| 1182 if (dart.is(chainSource, _Future)) { | |
| 1183 if (chainSource._isComplete) { | |
| 1184 result._isChained = true; | |
| 1185 source = chainSource; | |
| 1186 listeners = new _FutureListener.chain(result); | |
| 1187 continue; | |
| 1188 } else { | |
| 1189 _chainCoreFuture(chainSource, result); | |
| 1190 } | |
| 1191 } else { | |
| 1192 _chainForeignFuture(chainSource, result); | |
| 1193 } | |
| 1194 return; | |
| 1195 } | |
| 1196 } | |
| 1197 let result = listener.result; | |
| 1198 listeners = result._removeListeners(); | |
| 1199 if (listenerHasValue) { | |
| 1200 result._setValue(listenerValueOrError); | |
| 1201 } else { | |
| 1202 let asyncError = dart.as(listenerValueOrError, AsyncError); | |
| 1203 result._setErrorObject(asyncError); | |
| 1204 } | |
| 1205 source = result; | |
| 1206 } | |
| 1207 } | |
| 1208 timeout(timeLimit, opt$) { | |
| 1209 let onTimeout = opt$.onTimeout === void 0 ? null : opt$.onTimeout; | |
| 1210 if (this._isComplete) | |
| 1211 return new _Future.immediate(this); | |
| 1212 let result = new _Future(); | |
| 1213 let timer = null; | |
| 1214 if (onTimeout === null) { | |
| 1215 timer = new Timer(timeLimit, (() => { | |
| 1216 result._completeError(new TimeoutException("Future not completed", t
imeLimit)); | |
| 1217 }).bind(this)); | |
| 1218 } else { | |
| 1219 let zone = Zone.current; | |
| 1220 onTimeout = zone.registerCallback(onTimeout); | |
| 1221 timer = new Timer(timeLimit, (() => { | |
| 1222 try { | |
| 1223 result._complete(zone.run(onTimeout)); | |
| 1224 } catch (e) { | |
| 1225 let s = dart.stackTrace(e); | |
| 1226 result._completeError(e, s); | |
| 1227 } | |
| 1228 | |
| 1229 }).bind(this)); | |
| 1230 } | |
| 1231 this.then(((v) => { | |
| 1232 if (timer.isActive) { | |
| 1233 timer.cancel(); | |
| 1234 result._completeWithValue(v); | |
| 1235 } | |
| 1236 }).bind(this), {onError: ((e, s) => { | |
| 1237 if (timer.isActive) { | |
| 1238 timer.cancel(); | |
| 1239 result._completeError(e, dart.as(s, core.StackTrace)); | |
| 1240 } | |
| 1241 }).bind(this)}); | |
| 1242 return result; | |
| 1243 } | |
| 1244 } | |
| 1245 dart.defineNamedConstructor(_Future, 'immediate'); | |
| 1246 dart.defineNamedConstructor(_Future, 'immediateError'); | |
| 1247 _Future._INCOMPLETE = 0; | |
| 1248 _Future._PENDING_COMPLETE = 1; | |
| 1249 _Future._CHAINED = 2; | |
| 1250 _Future._VALUE = 4; | |
| 1251 _Future._ERROR = 8; | |
| 1252 return _Future; | |
| 1253 }); | |
| 1254 let _Future = _Future$(dynamic); | |
| 1255 class _AsyncCallbackEntry extends dart.Object { | |
| 1256 _AsyncCallbackEntry(callback) { | |
| 1257 this.callback = callback; | |
| 1258 this.next = null; | |
| 1259 } | |
| 1260 } | |
| 1261 exports._nextCallback = null; | |
| 1262 exports._lastCallback = null; | |
| 1263 exports._lastPriorityCallback = null; | |
| 1264 exports._isInCallbackLoop = false; | |
| 1265 // Function _asyncRunCallbackLoop: () → void | |
| 1266 function _asyncRunCallbackLoop() { | |
| 1267 while (exports._nextCallback !== null) { | |
| 1268 exports._lastPriorityCallback = null; | |
| 1269 let entry = exports._nextCallback; | |
| 1270 exports._nextCallback = entry.next; | |
| 1271 if (exports._nextCallback === null) | |
| 1272 exports._lastCallback = null; | |
| 1273 entry.callback(); | |
| 1274 } | |
| 1275 } | |
| 1276 // Function _asyncRunCallback: () → void | |
| 1277 function _asyncRunCallback() { | |
| 1278 exports._isInCallbackLoop = true; | |
| 1279 try { | |
| 1280 _asyncRunCallbackLoop(); | |
| 1281 } finally { | |
| 1282 exports._lastPriorityCallback = null; | |
| 1283 exports._isInCallbackLoop = false; | |
| 1284 if (exports._nextCallback !== null) | |
| 1285 _AsyncRun._scheduleImmediate(_asyncRunCallback); | |
| 1286 } | |
| 1287 } | |
| 1288 // Function _scheduleAsyncCallback: (dynamic) → void | |
| 1289 function _scheduleAsyncCallback(callback) { | |
| 1290 if (exports._nextCallback === null) { | |
| 1291 exports._nextCallback = exports._lastCallback = new _AsyncCallbackEntry(da
rt.as(callback, _AsyncCallback)); | |
| 1292 if (!dart.notNull(exports._isInCallbackLoop)) { | |
| 1293 _AsyncRun._scheduleImmediate(_asyncRunCallback); | |
| 1294 } | |
| 1295 } else { | |
| 1296 let newEntry = new _AsyncCallbackEntry(dart.as(callback, _AsyncCallback)); | |
| 1297 exports._lastCallback.next = newEntry; | |
| 1298 exports._lastCallback = newEntry; | |
| 1299 } | |
| 1300 } | |
| 1301 // Function _schedulePriorityAsyncCallback: (dynamic) → void | |
| 1302 function _schedulePriorityAsyncCallback(callback) { | |
| 1303 let entry = new _AsyncCallbackEntry(dart.as(callback, _AsyncCallback)); | |
| 1304 if (exports._nextCallback === null) { | |
| 1305 _scheduleAsyncCallback(callback); | |
| 1306 exports._lastPriorityCallback = exports._lastCallback; | |
| 1307 } else if (exports._lastPriorityCallback === null) { | |
| 1308 entry.next = exports._nextCallback; | |
| 1309 exports._nextCallback = exports._lastPriorityCallback = entry; | |
| 1310 } else { | |
| 1311 entry.next = exports._lastPriorityCallback.next; | |
| 1312 exports._lastPriorityCallback.next = entry; | |
| 1313 exports._lastPriorityCallback = entry; | |
| 1314 if (entry.next === null) { | |
| 1315 exports._lastCallback = entry; | |
| 1316 } | |
| 1317 } | |
| 1318 } | |
| 1319 // Function scheduleMicrotask: (() → void) → void | |
| 1320 function scheduleMicrotask(callback) { | |
| 1321 if (core.identical(_ROOT_ZONE, Zone.current)) { | |
| 1322 _rootScheduleMicrotask(null, null, dart.as(_ROOT_ZONE, Zone), callback); | |
| 1323 return; | |
| 1324 } | |
| 1325 Zone.current.scheduleMicrotask(Zone.current.bindCallback(callback, {runGuard
ed: true})); | |
| 1326 } | |
| 1327 class _AsyncRun extends dart.Object { | |
| 1328 static _scheduleImmediate(callback) { | |
| 1329 dart.dinvokef(scheduleImmediateClosure, callback); | |
| 1330 } | |
| 1331 static _initializeScheduleImmediate() { | |
| 1332 _js_helper.requiresPreamble(); | |
| 1333 if (self.scheduleImmediate !== null) { | |
| 1334 return _scheduleImmediateJsOverride; | |
| 1335 } | |
| 1336 if (dart.notNull(self.MutationObserver !== null) && dart.notNull(self.docu
ment !== null)) { | |
| 1337 let div = self.document.createElement("div"); | |
| 1338 let span = self.document.createElement("span"); | |
| 1339 let storedCallback = null; | |
| 1340 // Function internalCallback: (dynamic) → dynamic | |
| 1341 function internalCallback(_) { | |
| 1342 _isolate_helper.leaveJsAsync(); | |
| 1343 let f = storedCallback; | |
| 1344 storedCallback = null; | |
| 1345 dart.dinvokef(f); | |
| 1346 } | |
| 1347 ; | |
| 1348 let observer = new self.MutationObserver(_js_helper.convertDartClosureTo
JS(internalCallback, 1)); | |
| 1349 observer.observe(div, {childList: true}); | |
| 1350 return (callback) => { | |
| 1351 dart.assert(storedCallback === null); | |
| 1352 _isolate_helper.enterJsAsync(); | |
| 1353 storedCallback = callback; | |
| 1354 div.firstChild ? div.removeChild(span) : div.appendChild(span); | |
| 1355 }; | |
| 1356 } else if (self.setImmediate !== null) { | |
| 1357 return _scheduleImmediateWithSetImmediate; | |
| 1358 } | |
| 1359 return _scheduleImmediateWithTimer; | |
| 1360 } | |
| 1361 static _scheduleImmediateJsOverride(callback) { | |
| 1362 // Function internalCallback: () → dynamic | |
| 1363 function internalCallback() { | |
| 1364 _isolate_helper.leaveJsAsync(); | |
| 1365 callback(); | |
| 1366 } | |
| 1367 ; | |
| 1368 _isolate_helper.enterJsAsync(); | |
| 1369 self.scheduleImmediate(_js_helper.convertDartClosureToJS(internalCallback,
0)); | |
| 1370 } | |
| 1371 static _scheduleImmediateWithSetImmediate(callback) { | |
| 1372 // Function internalCallback: () → dynamic | |
| 1373 function internalCallback() { | |
| 1374 _isolate_helper.leaveJsAsync(); | |
| 1375 callback(); | |
| 1376 } | |
| 1377 ; | |
| 1378 _isolate_helper.enterJsAsync(); | |
| 1379 self.setImmediate(_js_helper.convertDartClosureToJS(internalCallback, 0)); | |
| 1380 } | |
| 1381 static _scheduleImmediateWithTimer(callback) { | |
| 1382 Timer._createTimer(core.Duration.ZERO, callback); | |
| 1383 } | |
| 1384 } | |
| 1385 dart.defineLazyProperties(_AsyncRun, { | |
| 1386 get scheduleImmediateClosure() { | |
| 1387 return _initializeScheduleImmediate(); | |
| 1388 } | |
| 1389 }); | |
| 1390 let Stream$ = dart.generic(function(T) { | |
| 1391 class Stream extends dart.Object { | |
| 1392 Stream() { | |
| 1393 } | |
| 1394 Stream$fromFuture(future) { | |
| 1395 let controller = dart.as(new StreamController({sync: true}), _StreamCont
roller$(T)); | |
| 1396 future.then(((value) => { | |
| 1397 controller._add(dart.as(value, T)); | |
| 1398 controller._closeUnchecked(); | |
| 1399 }).bind(this), {onError: ((error, stackTrace) => { | |
| 1400 controller._addError(error, dart.as(stackTrace, core.StackTrace)); | |
| 1401 controller._closeUnchecked(); | |
| 1402 }).bind(this)}); | |
| 1403 return controller.stream; | |
| 1404 } | |
| 1405 Stream$fromIterable(data) { | |
| 1406 return new _GeneratedStreamImpl(() => new _IterablePendingEvents(data)); | |
| 1407 } | |
| 1408 Stream$periodic(period, computation) { | |
| 1409 if (computation === void 0) | |
| 1410 computation = null; | |
| 1411 if (computation === null) | |
| 1412 computation = dart.as((i) => null, dart.throw_("Unimplemented type (in
t) → T")); | |
| 1413 let timer = null; | |
| 1414 let computationCount = 0; | |
| 1415 let controller = null; | |
| 1416 let watch = new core.Stopwatch(); | |
| 1417 // Function sendEvent: () → void | |
| 1418 function sendEvent() { | |
| 1419 watch.reset(); | |
| 1420 let data = computation(computationCount++); | |
| 1421 controller.add(data); | |
| 1422 } | |
| 1423 // Function startPeriodicTimer: () → void | |
| 1424 function startPeriodicTimer() { | |
| 1425 dart.assert(timer === null); | |
| 1426 timer = new Timer.periodic(period, (timer) => { | |
| 1427 sendEvent(); | |
| 1428 }); | |
| 1429 } | |
| 1430 controller = new StreamController({sync: true, onListen: (() => { | |
| 1431 watch.start(); | |
| 1432 startPeriodicTimer(); | |
| 1433 }).bind(this), onPause: (() => { | |
| 1434 timer.cancel(); | |
| 1435 timer = null; | |
| 1436 watch.stop(); | |
| 1437 }).bind(this), onResume: (() => { | |
| 1438 dart.assert(timer === null); | |
| 1439 let elapsed = watch.elapsed; | |
| 1440 watch.start(); | |
| 1441 timer = new Timer(period['-'](elapsed), () => { | |
| 1442 timer = null; | |
| 1443 startPeriodicTimer(); | |
| 1444 sendEvent(); | |
| 1445 }); | |
| 1446 }).bind(this), onCancel: (() => { | |
| 1447 if (timer !== null) | |
| 1448 timer.cancel(); | |
| 1449 timer = null; | |
| 1450 }).bind(this)}); | |
| 1451 return controller.stream; | |
| 1452 } | |
| 1453 Stream$eventTransformed(source, mapSink) { | |
| 1454 return dart.as(new _BoundSinkStream(source, dart.as(mapSink, _SinkMapper
)), Stream$(T)); | |
| 1455 } | |
| 1456 get isBroadcast() { | |
| 1457 return false; | |
| 1458 } | |
| 1459 asBroadcastStream(opt$) { | |
| 1460 let onListen = opt$.onListen === void 0 ? null : opt$.onListen; | |
| 1461 let onCancel = opt$.onCancel === void 0 ? null : opt$.onCancel; | |
| 1462 return new _AsBroadcastStream(this, dart.as(onListen, dart.throw_("Unimp
lemented type (StreamSubscription<dynamic>) → void")), dart.as(onCancel, dart.th
row_("Unimplemented type (StreamSubscription<dynamic>) → void"))); | |
| 1463 } | |
| 1464 where(test) { | |
| 1465 return new _WhereStream(this, test); | |
| 1466 } | |
| 1467 map(convert) { | |
| 1468 return new _MapStream(this, convert); | |
| 1469 } | |
| 1470 asyncMap(convert) { | |
| 1471 let controller = null; | |
| 1472 let subscription = null; | |
| 1473 // Function onListen: () → void | |
| 1474 function onListen() { | |
| 1475 let add = controller.add; | |
| 1476 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da
rt.notNull(dart.is(controller, _BroadcastStreamController))); | |
| 1477 let eventSink = controller; | |
| 1478 let addError = eventSink._addError; | |
| 1479 subscription = this.listen(((event) => { | |
| 1480 let newValue = null; | |
| 1481 try { | |
| 1482 newValue = convert(event); | |
| 1483 } catch (e) { | |
| 1484 let s = dart.stackTrace(e); | |
| 1485 controller.addError(e, s); | |
| 1486 return; | |
| 1487 } | |
| 1488 | |
| 1489 if (dart.is(newValue, Future)) { | |
| 1490 subscription.pause(); | |
| 1491 dart.dinvoke(dart.dinvoke(newValue, 'then', add, {onError: addErro
r}), 'whenComplete', subscription.resume); | |
| 1492 } else { | |
| 1493 controller.add(newValue); | |
| 1494 } | |
| 1495 }).bind(this), {onError: dart.as(addError, core.Function), onDone: con
troller.close}); | |
| 1496 } | |
| 1497 if (this.isBroadcast) { | |
| 1498 controller = new StreamController.broadcast({onListen: onListen, onCan
cel: (() => { | |
| 1499 subscription.cancel(); | |
| 1500 }).bind(this), sync: true}); | |
| 1501 } else { | |
| 1502 controller = new StreamController({onListen: onListen, onPause: (() =>
{ | |
| 1503 subscription.pause(); | |
| 1504 }).bind(this), onResume: (() => { | |
| 1505 subscription.resume(); | |
| 1506 }).bind(this), onCancel: (() => { | |
| 1507 subscription.cancel(); | |
| 1508 }).bind(this), sync: true}); | |
| 1509 } | |
| 1510 return controller.stream; | |
| 1511 } | |
| 1512 asyncExpand(convert) { | |
| 1513 let controller = null; | |
| 1514 let subscription = null; | |
| 1515 // Function onListen: () → void | |
| 1516 function onListen() { | |
| 1517 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da
rt.notNull(dart.is(controller, _BroadcastStreamController))); | |
| 1518 let eventSink = controller; | |
| 1519 subscription = this.listen(((event) => { | |
| 1520 let newStream = null; | |
| 1521 try { | |
| 1522 newStream = convert(event); | |
| 1523 } catch (e) { | |
| 1524 let s = dart.stackTrace(e); | |
| 1525 controller.addError(e, s); | |
| 1526 return; | |
| 1527 } | |
| 1528 | |
| 1529 if (newStream !== null) { | |
| 1530 subscription.pause(); | |
| 1531 controller.addStream(newStream).whenComplete(subscription.resume); | |
| 1532 } | |
| 1533 }).bind(this), {onError: dart.as(eventSink._addError, core.Function),
onDone: controller.close}); | |
| 1534 } | |
| 1535 if (this.isBroadcast) { | |
| 1536 controller = new StreamController.broadcast({onListen: onListen, onCan
cel: (() => { | |
| 1537 subscription.cancel(); | |
| 1538 }).bind(this), sync: true}); | |
| 1539 } else { | |
| 1540 controller = new StreamController({onListen: onListen, onPause: (() =>
{ | |
| 1541 subscription.pause(); | |
| 1542 }).bind(this), onResume: (() => { | |
| 1543 subscription.resume(); | |
| 1544 }).bind(this), onCancel: (() => { | |
| 1545 subscription.cancel(); | |
| 1546 }).bind(this), sync: true}); | |
| 1547 } | |
| 1548 return controller.stream; | |
| 1549 } | |
| 1550 handleError(onError, opt$) { | |
| 1551 let test = opt$.test === void 0 ? null : opt$.test; | |
| 1552 return new _HandleErrorStream(this, onError, test); | |
| 1553 } | |
| 1554 expand(convert) { | |
| 1555 return new _ExpandStream(this, convert); | |
| 1556 } | |
| 1557 pipe(streamConsumer) { | |
| 1558 return streamConsumer.addStream(this).then(((_) => streamConsumer.close(
)).bind(this)); | |
| 1559 } | |
| 1560 transform(streamTransformer) { | |
| 1561 return streamTransformer.bind(this); | |
| 1562 } | |
| 1563 reduce(combine) { | |
| 1564 let result = new _Future(); | |
| 1565 let seenFirst = false; | |
| 1566 let value = null; | |
| 1567 let subscription = null; | |
| 1568 subscription = this.listen((element) => { | |
| 1569 if (seenFirst) { | |
| 1570 _runUserCode(() => combine(value, element), dart.as((newValue) => { | |
| 1571 value = newValue; | |
| 1572 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_
cancelAndErrorClosure(subscription, result), dart.throw_("Unimplemented type (dy
namic, StackTrace) → dynamic"))); | |
| 1573 } else { | |
| 1574 value = element; | |
| 1575 seenFirst = true; | |
| 1576 } | |
| 1577 }, {onError: result._completeError, onDone: (() => { | |
| 1578 if (!dart.notNull(seenFirst)) { | |
| 1579 try { | |
| 1580 throw _internal.IterableElementError.noElement(); | |
| 1581 } catch (e) { | |
| 1582 let s = dart.stackTrace(e); | |
| 1583 _completeWithErrorCallback(result, e, s); | |
| 1584 } | |
| 1585 | |
| 1586 } else { | |
| 1587 result._complete(value); | |
| 1588 } | |
| 1589 }).bind(this), cancelOnError: true}); | |
| 1590 return result; | |
| 1591 } | |
| 1592 fold(initialValue, combine) { | |
| 1593 let result = new _Future(); | |
| 1594 let value = initialValue; | |
| 1595 let subscription = null; | |
| 1596 subscription = this.listen((element) => { | |
| 1597 _runUserCode(() => combine(value, element), (newValue) => { | |
| 1598 value = newValue; | |
| 1599 }, dart.as(_cancelAndErrorClosure(subscription, result), dart.throw_("
Unimplemented type (dynamic, StackTrace) → dynamic"))); | |
| 1600 }, {onError: ((e, st) => { | |
| 1601 result._completeError(e, dart.as(st, core.StackTrace)); | |
| 1602 }).bind(this), onDone: (() => { | |
| 1603 result._complete(value); | |
| 1604 }).bind(this), cancelOnError: true}); | |
| 1605 return result; | |
| 1606 } | |
| 1607 join(separator) { | |
| 1608 if (separator === void 0) | |
| 1609 separator = ""; | |
| 1610 let result = new _Future(); | |
| 1611 let buffer = new core.StringBuffer(); | |
| 1612 let subscription = null; | |
| 1613 let first = true; | |
| 1614 subscription = this.listen(((element) => { | |
| 1615 if (!dart.notNull(first)) { | |
| 1616 buffer.write(separator); | |
| 1617 } | |
| 1618 first = false; | |
| 1619 try { | |
| 1620 buffer.write(element); | |
| 1621 } catch (e) { | |
| 1622 let s = dart.stackTrace(e); | |
| 1623 _cancelAndErrorWithReplacement(subscription, result, e, s); | |
| 1624 } | |
| 1625 | |
| 1626 }).bind(this), {onError: ((e) => { | |
| 1627 result._completeError(e); | |
| 1628 }).bind(this), onDone: (() => { | |
| 1629 result._complete(buffer.toString()); | |
| 1630 }).bind(this), cancelOnError: true}); | |
| 1631 return result; | |
| 1632 } | |
| 1633 contains(needle) { | |
| 1634 let future = new _Future(); | |
| 1635 let subscription = null; | |
| 1636 subscription = this.listen((element) => { | |
| 1637 _runUserCode(() => dart.equals(element, needle), dart.as((isMatch) =>
{ | |
| 1638 if (isMatch) { | |
| 1639 _cancelAndValue(subscription, future, true); | |
| 1640 } | |
| 1641 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1642 }, {onError: future._completeError, onDone: (() => { | |
| 1643 future._complete(false); | |
| 1644 }).bind(this), cancelOnError: true}); | |
| 1645 return future; | |
| 1646 } | |
| 1647 forEach(action) { | |
| 1648 let future = new _Future(); | |
| 1649 let subscription = null; | |
| 1650 subscription = this.listen((element) => { | |
| 1651 _runUserCode(() => action(element), (_) => { | |
| 1652 }, dart.as(_cancelAndErrorClosure(subscription, future), dart.throw_("
Unimplemented type (dynamic, StackTrace) → dynamic"))); | |
| 1653 }, {onError: future._completeError, onDone: (() => { | |
| 1654 future._complete(null); | |
| 1655 }).bind(this), cancelOnError: true}); | |
| 1656 return future; | |
| 1657 } | |
| 1658 every(test) { | |
| 1659 let future = new _Future(); | |
| 1660 let subscription = null; | |
| 1661 subscription = this.listen((element) => { | |
| 1662 _runUserCode(() => test(element), dart.as((isMatch) => { | |
| 1663 if (!dart.notNull(isMatch)) { | |
| 1664 _cancelAndValue(subscription, future, false); | |
| 1665 } | |
| 1666 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1667 }, {onError: future._completeError, onDone: (() => { | |
| 1668 future._complete(true); | |
| 1669 }).bind(this), cancelOnError: true}); | |
| 1670 return future; | |
| 1671 } | |
| 1672 any(test) { | |
| 1673 let future = new _Future(); | |
| 1674 let subscription = null; | |
| 1675 subscription = this.listen((element) => { | |
| 1676 _runUserCode(() => test(element), dart.as((isMatch) => { | |
| 1677 if (isMatch) { | |
| 1678 _cancelAndValue(subscription, future, true); | |
| 1679 } | |
| 1680 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1681 }, {onError: future._completeError, onDone: (() => { | |
| 1682 future._complete(false); | |
| 1683 }).bind(this), cancelOnError: true}); | |
| 1684 return future; | |
| 1685 } | |
| 1686 get length() { | |
| 1687 let future = new _Future(); | |
| 1688 let count = 0; | |
| 1689 this.listen((_) => { | |
| 1690 count++; | |
| 1691 }, {onError: future._completeError, onDone: (() => { | |
| 1692 future._complete(count); | |
| 1693 }).bind(this), cancelOnError: true}); | |
| 1694 return future; | |
| 1695 } | |
| 1696 get isEmpty() { | |
| 1697 let future = new _Future(); | |
| 1698 let subscription = null; | |
| 1699 subscription = this.listen((_) => { | |
| 1700 _cancelAndValue(subscription, future, false); | |
| 1701 }, {onError: future._completeError, onDone: (() => { | |
| 1702 future._complete(true); | |
| 1703 }).bind(this), cancelOnError: true}); | |
| 1704 return future; | |
| 1705 } | |
| 1706 toList() { | |
| 1707 let result = new List.from([]); | |
| 1708 let future = new _Future(); | |
| 1709 this.listen(((data) => { | |
| 1710 result.add(data); | |
| 1711 }).bind(this), {onError: future._completeError, onDone: (() => { | |
| 1712 future._complete(result); | |
| 1713 }).bind(this), cancelOnError: true}); | |
| 1714 return future; | |
| 1715 } | |
| 1716 toSet() { | |
| 1717 let result = new core.Set(); | |
| 1718 let future = new _Future(); | |
| 1719 this.listen(((data) => { | |
| 1720 result.add(data); | |
| 1721 }).bind(this), {onError: future._completeError, onDone: (() => { | |
| 1722 future._complete(result); | |
| 1723 }).bind(this), cancelOnError: true}); | |
| 1724 return future; | |
| 1725 } | |
| 1726 drain(futureValue) { | |
| 1727 if (futureValue === void 0) | |
| 1728 futureValue = null; | |
| 1729 return this.listen(null, {cancelOnError: true}).asFuture(futureValue); | |
| 1730 } | |
| 1731 take(count) { | |
| 1732 return dart.as(new _TakeStream(this, count), Stream$(T)); | |
| 1733 } | |
| 1734 takeWhile(test) { | |
| 1735 return dart.as(new _TakeWhileStream(this, dart.as(test, dart.throw_("Uni
mplemented type (dynamic) → bool"))), Stream$(T)); | |
| 1736 } | |
| 1737 skip(count) { | |
| 1738 return dart.as(new _SkipStream(this, count), Stream$(T)); | |
| 1739 } | |
| 1740 skipWhile(test) { | |
| 1741 return dart.as(new _SkipWhileStream(this, dart.as(test, dart.throw_("Uni
mplemented type (dynamic) → bool"))), Stream$(T)); | |
| 1742 } | |
| 1743 distinct(equals) { | |
| 1744 if (equals === void 0) | |
| 1745 equals = null; | |
| 1746 return dart.as(new _DistinctStream(this, dart.as(equals, dart.throw_("Un
implemented type (dynamic, dynamic) → bool"))), Stream$(T)); | |
| 1747 } | |
| 1748 get first() { | |
| 1749 let future = new _Future(); | |
| 1750 let subscription = null; | |
| 1751 subscription = this.listen((value) => { | |
| 1752 _cancelAndValue(subscription, future, value); | |
| 1753 }, { | |
| 1754 onError: future._completeError, | |
| 1755 onDone: () => { | |
| 1756 try { | |
| 1757 throw _internal.IterableElementError.noElement(); | |
| 1758 } catch (e) { | |
| 1759 let s = dart.stackTrace(e); | |
| 1760 _completeWithErrorCallback(future, e, s); | |
| 1761 } | |
| 1762 | |
| 1763 }, | |
| 1764 cancelOnError: true | |
| 1765 }); | |
| 1766 return future; | |
| 1767 } | |
| 1768 get last() { | |
| 1769 let future = new _Future(); | |
| 1770 let result = dart.as(null, T); | |
| 1771 let foundResult = false; | |
| 1772 let subscription = null; | |
| 1773 subscription = this.listen((value) => { | |
| 1774 foundResult = true; | |
| 1775 result = value; | |
| 1776 }, {onError: future._completeError, onDone: (() => { | |
| 1777 if (foundResult) { | |
| 1778 future._complete(result); | |
| 1779 return; | |
| 1780 } | |
| 1781 try { | |
| 1782 throw _internal.IterableElementError.noElement(); | |
| 1783 } catch (e) { | |
| 1784 let s = dart.stackTrace(e); | |
| 1785 _completeWithErrorCallback(future, e, s); | |
| 1786 } | |
| 1787 | |
| 1788 }).bind(this), cancelOnError: true}); | |
| 1789 return future; | |
| 1790 } | |
| 1791 get single() { | |
| 1792 let future = new _Future(); | |
| 1793 let result = dart.as(null, T); | |
| 1794 let foundResult = false; | |
| 1795 let subscription = null; | |
| 1796 subscription = this.listen((value) => { | |
| 1797 if (foundResult) { | |
| 1798 try { | |
| 1799 throw _internal.IterableElementError.tooMany(); | |
| 1800 } catch (e) { | |
| 1801 let s = dart.stackTrace(e); | |
| 1802 _cancelAndErrorWithReplacement(subscription, future, e, s); | |
| 1803 } | |
| 1804 | |
| 1805 return; | |
| 1806 } | |
| 1807 foundResult = true; | |
| 1808 result = value; | |
| 1809 }, {onError: future._completeError, onDone: (() => { | |
| 1810 if (foundResult) { | |
| 1811 future._complete(result); | |
| 1812 return; | |
| 1813 } | |
| 1814 try { | |
| 1815 throw _internal.IterableElementError.noElement(); | |
| 1816 } catch (e) { | |
| 1817 let s = dart.stackTrace(e); | |
| 1818 _completeWithErrorCallback(future, e, s); | |
| 1819 } | |
| 1820 | |
| 1821 }).bind(this), cancelOnError: true}); | |
| 1822 return future; | |
| 1823 } | |
| 1824 firstWhere(test, opt$) { | |
| 1825 let defaultValue = opt$.defaultValue === void 0 ? null : opt$.defaultVal
ue; | |
| 1826 let future = new _Future(); | |
| 1827 let subscription = null; | |
| 1828 subscription = this.listen((value) => { | |
| 1829 _runUserCode(() => test(value), dart.as((isMatch) => { | |
| 1830 if (isMatch) { | |
| 1831 _cancelAndValue(subscription, future, value); | |
| 1832 } | |
| 1833 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1834 }, {onError: future._completeError, onDone: (() => { | |
| 1835 if (defaultValue !== null) { | |
| 1836 _runUserCode(defaultValue, future._complete, future._completeError
); | |
| 1837 return; | |
| 1838 } | |
| 1839 try { | |
| 1840 throw _internal.IterableElementError.noElement(); | |
| 1841 } catch (e) { | |
| 1842 let s = dart.stackTrace(e); | |
| 1843 _completeWithErrorCallback(future, e, s); | |
| 1844 } | |
| 1845 | |
| 1846 }).bind(this), cancelOnError: true}); | |
| 1847 return future; | |
| 1848 } | |
| 1849 lastWhere(test, opt$) { | |
| 1850 let defaultValue = opt$.defaultValue === void 0 ? null : opt$.defaultVal
ue; | |
| 1851 let future = new _Future(); | |
| 1852 let result = dart.as(null, T); | |
| 1853 let foundResult = false; | |
| 1854 let subscription = null; | |
| 1855 subscription = this.listen((value) => { | |
| 1856 _runUserCode(() => true === test(value), dart.as((isMatch) => { | |
| 1857 if (isMatch) { | |
| 1858 foundResult = true; | |
| 1859 result = value; | |
| 1860 } | |
| 1861 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1862 }, {onError: future._completeError, onDone: (() => { | |
| 1863 if (foundResult) { | |
| 1864 future._complete(result); | |
| 1865 return; | |
| 1866 } | |
| 1867 if (defaultValue !== null) { | |
| 1868 _runUserCode(defaultValue, future._complete, future._completeError
); | |
| 1869 return; | |
| 1870 } | |
| 1871 try { | |
| 1872 throw _internal.IterableElementError.noElement(); | |
| 1873 } catch (e) { | |
| 1874 let s = dart.stackTrace(e); | |
| 1875 _completeWithErrorCallback(future, e, s); | |
| 1876 } | |
| 1877 | |
| 1878 }).bind(this), cancelOnError: true}); | |
| 1879 return future; | |
| 1880 } | |
| 1881 singleWhere(test) { | |
| 1882 let future = new _Future(); | |
| 1883 let result = dart.as(null, T); | |
| 1884 let foundResult = false; | |
| 1885 let subscription = null; | |
| 1886 subscription = this.listen((value) => { | |
| 1887 _runUserCode(() => true === test(value), dart.as((isMatch) => { | |
| 1888 if (isMatch) { | |
| 1889 if (foundResult) { | |
| 1890 try { | |
| 1891 throw _internal.IterableElementError.tooMany(); | |
| 1892 } catch (e) { | |
| 1893 let s = dart.stackTrace(e); | |
| 1894 _cancelAndErrorWithReplacement(subscription, future, e, s); | |
| 1895 } | |
| 1896 | |
| 1897 return; | |
| 1898 } | |
| 1899 foundResult = true; | |
| 1900 result = value; | |
| 1901 } | |
| 1902 }, dart.throw_("Unimplemented type (dynamic) → dynamic")), dart.as(_ca
ncelAndErrorClosure(subscription, future), dart.throw_("Unimplemented type (dyna
mic, StackTrace) → dynamic"))); | |
| 1903 }, {onError: future._completeError, onDone: (() => { | |
| 1904 if (foundResult) { | |
| 1905 future._complete(result); | |
| 1906 return; | |
| 1907 } | |
| 1908 try { | |
| 1909 throw _internal.IterableElementError.noElement(); | |
| 1910 } catch (e) { | |
| 1911 let s = dart.stackTrace(e); | |
| 1912 _completeWithErrorCallback(future, e, s); | |
| 1913 } | |
| 1914 | |
| 1915 }).bind(this), cancelOnError: true}); | |
| 1916 return future; | |
| 1917 } | |
| 1918 elementAt(index) { | |
| 1919 if (dart.notNull(!(typeof index == number)) || dart.notNull(index < 0)) | |
| 1920 throw new core.ArgumentError(index); | |
| 1921 let future = new _Future(); | |
| 1922 let subscription = null; | |
| 1923 let elementIndex = 0; | |
| 1924 subscription = this.listen((value) => { | |
| 1925 if (index === elementIndex) { | |
| 1926 _cancelAndValue(subscription, future, value); | |
| 1927 return; | |
| 1928 } | |
| 1929 elementIndex = 1; | |
| 1930 }, {onError: future._completeError, onDone: (() => { | |
| 1931 future._completeError(new core.RangeError.index(index, this, "index"
, null, elementIndex)); | |
| 1932 }).bind(this), cancelOnError: true}); | |
| 1933 return future; | |
| 1934 } | |
| 1935 timeout(timeLimit, opt$) { | |
| 1936 let onTimeout = opt$.onTimeout === void 0 ? null : opt$.onTimeout; | |
| 1937 let controller = null; | |
| 1938 let subscription = null; | |
| 1939 let timer = null; | |
| 1940 let zone = null; | |
| 1941 let timeout = null; | |
| 1942 // Function onData: (T) → void | |
| 1943 function onData(event) { | |
| 1944 timer.cancel(); | |
| 1945 controller.add(event); | |
| 1946 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.throw_("Unim
plemented type () → void"))); | |
| 1947 } | |
| 1948 // Function onError: (dynamic, StackTrace) → void | |
| 1949 function onError(error, stackTrace) { | |
| 1950 timer.cancel(); | |
| 1951 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da
rt.notNull(dart.is(controller, _BroadcastStreamController))); | |
| 1952 let eventSink = controller; | |
| 1953 dart.dinvoke(eventSink, '_addError', error, stackTrace); | |
| 1954 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.throw_("Unim
plemented type () → void"))); | |
| 1955 } | |
| 1956 // Function onDone: () → void | |
| 1957 function onDone() { | |
| 1958 timer.cancel(); | |
| 1959 controller.close(); | |
| 1960 } | |
| 1961 // Function onListen: () → void | |
| 1962 function onListen() { | |
| 1963 zone = Zone.current; | |
| 1964 if (onTimeout === null) { | |
| 1965 timeout = (() => { | |
| 1966 controller.addError(new TimeoutException("No stream event", timeLi
mit), null); | |
| 1967 }).bind(this); | |
| 1968 } else { | |
| 1969 onTimeout = zone.registerUnaryCallback(dart.as(onTimeout, dart.throw
_("Unimplemented type (dynamic) → dynamic"))); | |
| 1970 let wrapper = new _ControllerEventSinkWrapper(null); | |
| 1971 timeout = (() => { | |
| 1972 wrapper._sink = controller; | |
| 1973 zone.runUnaryGuarded(dart.as(onTimeout, dart.throw_("Unimplemented
type (dynamic) → dynamic")), wrapper); | |
| 1974 wrapper._sink = null; | |
| 1975 }).bind(this); | |
| 1976 } | |
| 1977 subscription = this.listen(onData, {onError: onError, onDone: onDone})
; | |
| 1978 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.throw_("Unim
plemented type () → void"))); | |
| 1979 } | |
| 1980 // Function onCancel: () → Future<dynamic> | |
| 1981 function onCancel() { | |
| 1982 timer.cancel(); | |
| 1983 let result = subscription.cancel(); | |
| 1984 subscription = null; | |
| 1985 return result; | |
| 1986 } | |
| 1987 controller = this.isBroadcast ? new _SyncBroadcastStreamController(onLis
ten, onCancel) : new _SyncStreamController(onListen, (() => { | |
| 1988 timer.cancel(); | |
| 1989 subscription.pause(); | |
| 1990 }).bind(this), (() => { | |
| 1991 subscription.resume(); | |
| 1992 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.throw_("Unim
plemented type () → void"))); | |
| 1993 }).bind(this), onCancel); | |
| 1994 return controller.stream; | |
| 1995 } | |
| 1996 } | |
| 1997 dart.defineNamedConstructor(Stream, 'fromFuture'); | |
| 1998 dart.defineNamedConstructor(Stream, 'fromIterable'); | |
| 1999 dart.defineNamedConstructor(Stream, 'periodic'); | |
| 2000 dart.defineNamedConstructor(Stream, 'eventTransformed'); | |
| 2001 return Stream; | |
| 2002 }); | |
| 2003 let Stream = Stream$(dynamic); | |
| 2004 let StreamSubscription$ = dart.generic(function(T) { | |
| 2005 class StreamSubscription extends dart.Object { | |
| 2006 } | |
| 2007 return StreamSubscription; | |
| 2008 }); | |
| 2009 let StreamSubscription = StreamSubscription$(dynamic); | |
| 2010 let EventSink$ = dart.generic(function(T) { | |
| 2011 class EventSink extends dart.Object { | |
| 2012 } | |
| 2013 return EventSink; | |
| 2014 }); | |
| 2015 let EventSink = EventSink$(dynamic); | |
| 2016 let StreamView$ = dart.generic(function(T) { | |
| 2017 class StreamView extends Stream$(T) { | |
| 2018 StreamView(_stream) { | |
| 2019 this._stream = _stream; | |
| 2020 super.Stream(); | |
| 2021 } | |
| 2022 get isBroadcast() { | |
| 2023 return this._stream.isBroadcast; | |
| 2024 } | |
| 2025 asBroadcastStream(opt$) { | |
| 2026 let onListen = opt$.onListen === void 0 ? null : opt$.onListen; | |
| 2027 let onCancel = opt$.onCancel === void 0 ? null : opt$.onCancel; | |
| 2028 return this._stream.asBroadcastStream({onListen: onListen, onCancel: onC
ancel}); | |
| 2029 } | |
| 2030 listen(onData, opt$) { | |
| 2031 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 2032 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 2033 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 2034 return this._stream.listen(onData, {onError: onError, onDone: onDone, ca
ncelOnError: cancelOnError}); | |
| 2035 } | |
| 2036 } | |
| 2037 return StreamView; | |
| 2038 }); | |
| 2039 let StreamView = StreamView$(dynamic); | |
| 2040 let StreamConsumer$ = dart.generic(function(S) { | |
| 2041 class StreamConsumer extends dart.Object { | |
| 2042 } | |
| 2043 return StreamConsumer; | |
| 2044 }); | |
| 2045 let StreamConsumer = StreamConsumer$(dynamic); | |
| 2046 let StreamSink$ = dart.generic(function(S) { | |
| 2047 class StreamSink extends dart.Object { | |
| 2048 } | |
| 2049 return StreamSink; | |
| 2050 }); | |
| 2051 let StreamSink = StreamSink$(dynamic); | |
| 2052 let StreamTransformer$ = dart.generic(function(S, T) { | |
| 2053 class StreamTransformer extends dart.Object { | |
| 2054 StreamTransformer(transformer) { | |
| 2055 return new _StreamSubscriptionTransformer(transformer); | |
| 2056 } | |
| 2057 StreamTransformer$fromHandlers(opt$) { | |
| 2058 return new _StreamHandlerTransformer(opt$); | |
| 2059 } | |
| 2060 } | |
| 2061 dart.defineNamedConstructor(StreamTransformer, 'fromHandlers'); | |
| 2062 return StreamTransformer; | |
| 2063 }); | |
| 2064 let StreamTransformer = StreamTransformer$(dynamic, dynamic); | |
| 2065 let StreamIterator$ = dart.generic(function(T) { | |
| 2066 class StreamIterator extends dart.Object { | |
| 2067 StreamIterator(stream) { | |
| 2068 return new _StreamIteratorImpl(stream); | |
| 2069 } | |
| 2070 } | |
| 2071 return StreamIterator; | |
| 2072 }); | |
| 2073 let StreamIterator = StreamIterator$(dynamic); | |
| 2074 let _ControllerEventSinkWrapper$ = dart.generic(function(T) { | |
| 2075 class _ControllerEventSinkWrapper extends dart.Object { | |
| 2076 _ControllerEventSinkWrapper(_sink) { | |
| 2077 this._sink = _sink; | |
| 2078 } | |
| 2079 add(data) { | |
| 2080 this._sink.add(data); | |
| 2081 } | |
| 2082 addError(error, stackTrace) { | |
| 2083 if (stackTrace === void 0) | |
| 2084 stackTrace = null; | |
| 2085 this._sink.addError(error, stackTrace); | |
| 2086 } | |
| 2087 close() { | |
| 2088 this._sink.close(); | |
| 2089 } | |
| 2090 } | |
| 2091 return _ControllerEventSinkWrapper; | |
| 2092 }); | |
| 2093 let _ControllerEventSinkWrapper = _ControllerEventSinkWrapper$(dynamic); | |
| 2094 let StreamController$ = dart.generic(function(T) { | |
| 2095 class StreamController extends dart.Object { | |
| 2096 StreamController(opt$) { | |
| 2097 let onListen = opt$.onListen === void 0 ? null : opt$.onListen; | |
| 2098 let onPause = opt$.onPause === void 0 ? null : opt$.onPause; | |
| 2099 let onResume = opt$.onResume === void 0 ? null : opt$.onResume; | |
| 2100 let onCancel = opt$.onCancel === void 0 ? null : opt$.onCancel; | |
| 2101 let sync = opt$.sync === void 0 ? false : opt$.sync; | |
| 2102 if (dart.notNull(dart.notNull(dart.notNull(onListen === null) && dart.no
tNull(onPause === null)) && dart.notNull(onResume === null)) && dart.notNull(onC
ancel === null)) { | |
| 2103 return dart.as(sync ? new _NoCallbackSyncStreamController() : new _NoC
allbackAsyncStreamController(), StreamController$(T)); | |
| 2104 } | |
| 2105 return sync ? new _SyncStreamController(onListen, onPause, onResume, onC
ancel) : new _AsyncStreamController(onListen, onPause, onResume, onCancel); | |
| 2106 } | |
| 2107 StreamController$broadcast(opt$) { | |
| 2108 let onListen = opt$.onListen === void 0 ? null : opt$.onListen; | |
| 2109 let onCancel = opt$.onCancel === void 0 ? null : opt$.onCancel; | |
| 2110 let sync = opt$.sync === void 0 ? false : opt$.sync; | |
| 2111 return sync ? new _SyncBroadcastStreamController(onListen, onCancel) : n
ew _AsyncBroadcastStreamController(onListen, onCancel); | |
| 2112 } | |
| 2113 } | |
| 2114 dart.defineNamedConstructor(StreamController, 'broadcast'); | |
| 2115 return StreamController; | |
| 2116 }); | |
| 2117 let StreamController = StreamController$(dynamic); | |
| 2118 let _StreamControllerLifecycle$ = dart.generic(function(T) { | |
| 2119 class _StreamControllerLifecycle extends dart.Object { | |
| 2120 _recordPause(subscription) {} | |
| 2121 _recordResume(subscription) {} | |
| 2122 _recordCancel(subscription) { | |
| 2123 return null; | |
| 2124 } | |
| 2125 } | |
| 2126 return _StreamControllerLifecycle; | |
| 2127 }); | |
| 2128 let _StreamControllerLifecycle = _StreamControllerLifecycle$(dynamic); | |
| 2129 let _StreamController$ = dart.generic(function(T) { | |
| 2130 class _StreamController extends dart.Object { | |
| 2131 _StreamController() { | |
| 2132 this._varData = null; | |
| 2133 this._state = _STATE_INITIAL; | |
| 2134 this._doneFuture = null; | |
| 2135 } | |
| 2136 get stream() { | |
| 2137 return dart.as(new _ControllerStream(this), Stream$(T)); | |
| 2138 } | |
| 2139 get sink() { | |
| 2140 return new _StreamSinkWrapper(this); | |
| 2141 } | |
| 2142 get _isCanceled() { | |
| 2143 return (this._state & _STATE_CANCELED) !== 0; | |
| 2144 } | |
| 2145 get hasListener() { | |
| 2146 return (this._state & _STATE_SUBSCRIBED) !== 0; | |
| 2147 } | |
| 2148 get _isInitialState() { | |
| 2149 return (this._state & _STATE_SUBSCRIPTION_MASK) === _STATE_INITIAL; | |
| 2150 } | |
| 2151 get isClosed() { | |
| 2152 return (this._state & _STATE_CLOSED) !== 0; | |
| 2153 } | |
| 2154 get isPaused() { | |
| 2155 return this.hasListener ? this._subscription._isInputPaused : !dart.notN
ull(this._isCanceled); | |
| 2156 } | |
| 2157 get _isAddingStream() { | |
| 2158 return (this._state & _STATE_ADDSTREAM) !== 0; | |
| 2159 } | |
| 2160 get _mayAddEvent() { | |
| 2161 return this._state < _STATE_CLOSED; | |
| 2162 } | |
| 2163 get _pendingEvents() { | |
| 2164 dart.assert(this._isInitialState); | |
| 2165 if (!dart.notNull(this._isAddingStream)) { | |
| 2166 return dart.as(this._varData, _PendingEvents); | |
| 2167 } | |
| 2168 let state = dart.as(this._varData, _StreamControllerAddStreamState); | |
| 2169 return dart.as(state.varData, _PendingEvents); | |
| 2170 } | |
| 2171 _ensurePendingEvents() { | |
| 2172 dart.assert(this._isInitialState); | |
| 2173 if (!dart.notNull(this._isAddingStream)) { | |
| 2174 if (this._varData === null) | |
| 2175 this._varData = new _StreamImplEvents(); | |
| 2176 return dart.as(this._varData, _StreamImplEvents); | |
| 2177 } | |
| 2178 let state = dart.as(this._varData, _StreamControllerAddStreamState); | |
| 2179 if (state.varData === null) | |
| 2180 state.varData = new _StreamImplEvents(); | |
| 2181 return dart.as(state.varData, _StreamImplEvents); | |
| 2182 } | |
| 2183 get _subscription() { | |
| 2184 dart.assert(this.hasListener); | |
| 2185 if (this._isAddingStream) { | |
| 2186 let addState = dart.as(this._varData, _StreamControllerAddStreamState)
; | |
| 2187 return dart.as(addState.varData, _ControllerSubscription); | |
| 2188 } | |
| 2189 return dart.as(this._varData, _ControllerSubscription); | |
| 2190 } | |
| 2191 _badEventState() { | |
| 2192 if (this.isClosed) { | |
| 2193 return new core.StateError("Cannot add event after closing"); | |
| 2194 } | |
| 2195 dart.assert(this._isAddingStream); | |
| 2196 return new core.StateError("Cannot add event while adding a stream"); | |
| 2197 } | |
| 2198 addStream(source, opt$) { | |
| 2199 let cancelOnError = opt$.cancelOnError === void 0 ? true : opt$.cancelOn
Error; | |
| 2200 if (!dart.notNull(this._mayAddEvent)) | |
| 2201 throw this._badEventState(); | |
| 2202 if (this._isCanceled) | |
| 2203 return new _Future.immediate(null); | |
| 2204 let addState = new _StreamControllerAddStreamState(this, this._varData,
source, cancelOnError); | |
| 2205 this._varData = addState; | |
| 2206 this._state = _STATE_ADDSTREAM; | |
| 2207 return addState.addStreamFuture; | |
| 2208 } | |
| 2209 get done() { | |
| 2210 return this._ensureDoneFuture(); | |
| 2211 } | |
| 2212 _ensureDoneFuture() { | |
| 2213 if (this._doneFuture === null) { | |
| 2214 this._doneFuture = this._isCanceled ? Future._nullFuture : new _Future
(); | |
| 2215 } | |
| 2216 return this._doneFuture; | |
| 2217 } | |
| 2218 add(value) { | |
| 2219 if (!dart.notNull(this._mayAddEvent)) | |
| 2220 throw this._badEventState(); | |
| 2221 this._add(value); | |
| 2222 } | |
| 2223 addError(error, stackTrace) { | |
| 2224 if (stackTrace === void 0) | |
| 2225 stackTrace = null; | |
| 2226 error = _nonNullError(error); | |
| 2227 if (!dart.notNull(this._mayAddEvent)) | |
| 2228 throw this._badEventState(); | |
| 2229 let replacement = Zone.current.errorCallback(error, stackTrace); | |
| 2230 if (replacement !== null) { | |
| 2231 error = _nonNullError(replacement.error); | |
| 2232 stackTrace = replacement.stackTrace; | |
| 2233 } | |
| 2234 this._addError(error, stackTrace); | |
| 2235 } | |
| 2236 close() { | |
| 2237 if (this.isClosed) { | |
| 2238 return this._ensureDoneFuture(); | |
| 2239 } | |
| 2240 if (!dart.notNull(this._mayAddEvent)) | |
| 2241 throw this._badEventState(); | |
| 2242 this._closeUnchecked(); | |
| 2243 return this._ensureDoneFuture(); | |
| 2244 } | |
| 2245 _closeUnchecked() { | |
| 2246 this._state = _STATE_CLOSED; | |
| 2247 if (this.hasListener) { | |
| 2248 this._sendDone(); | |
| 2249 } else if (this._isInitialState) { | |
| 2250 this._ensurePendingEvents().add(new _DelayedDone()); | |
| 2251 } | |
| 2252 } | |
| 2253 _add(value) { | |
| 2254 if (this.hasListener) { | |
| 2255 this._sendData(value); | |
| 2256 } else if (this._isInitialState) { | |
| 2257 this._ensurePendingEvents().add(new _DelayedData(value)); | |
| 2258 } | |
| 2259 } | |
| 2260 _addError(error, stackTrace) { | |
| 2261 if (this.hasListener) { | |
| 2262 this._sendError(error, stackTrace); | |
| 2263 } else if (this._isInitialState) { | |
| 2264 this._ensurePendingEvents().add(new _DelayedError(error, stackTrace)); | |
| 2265 } | |
| 2266 } | |
| 2267 _close() { | |
| 2268 dart.assert(this._isAddingStream); | |
| 2269 let addState = dart.as(this._varData, _StreamControllerAddStreamState); | |
| 2270 this._varData = addState.varData; | |
| 2271 this._state = ~_STATE_ADDSTREAM; | |
| 2272 addState.complete(); | |
| 2273 } | |
| 2274 _subscribe(onData, onError, onDone, cancelOnError) { | |
| 2275 if (!dart.notNull(this._isInitialState)) { | |
| 2276 throw new core.StateError("Stream has already been listened to."); | |
| 2277 } | |
| 2278 let subscription = new _ControllerSubscription(this, dart.as(onData, dar
t.throw_("Unimplemented type (dynamic) → void")), onError, onDone, cancelOnError
); | |
| 2279 let pendingEvents = this._pendingEvents; | |
| 2280 this._state = _STATE_SUBSCRIBED; | |
| 2281 if (this._isAddingStream) { | |
| 2282 let addState = dart.as(this._varData, _StreamControllerAddStreamState)
; | |
| 2283 addState.varData = subscription; | |
| 2284 addState.resume(); | |
| 2285 } else { | |
| 2286 this._varData = subscription; | |
| 2287 } | |
| 2288 subscription._setPendingEvents(pendingEvents); | |
| 2289 subscription._guardCallback((() => { | |
| 2290 _runGuarded(this._onListen); | |
| 2291 }).bind(this)); | |
| 2292 return dart.as(subscription, StreamSubscription$(T)); | |
| 2293 } | |
| 2294 _recordCancel(subscription) { | |
| 2295 let result = null; | |
| 2296 if (this._isAddingStream) { | |
| 2297 let addState = dart.as(this._varData, _StreamControllerAddStreamState)
; | |
| 2298 result = addState.cancel(); | |
| 2299 } | |
| 2300 this._varData = null; | |
| 2301 this._state = this._state & ~(_STATE_SUBSCRIBED | _STATE_ADDSTREAM) | _S
TATE_CANCELED; | |
| 2302 if (this._onCancel !== null) { | |
| 2303 if (result === null) { | |
| 2304 try { | |
| 2305 result = dart.as(this._onCancel(), Future); | |
| 2306 } catch (e) { | |
| 2307 let s = dart.stackTrace(e); | |
| 2308 result = ((_) => { | |
| 2309 _._asyncCompleteError(e, s); | |
| 2310 return _; | |
| 2311 }).bind(this)(new _Future()); | |
| 2312 } | |
| 2313 | |
| 2314 } else { | |
| 2315 result = result.whenComplete(this._onCancel); | |
| 2316 } | |
| 2317 } | |
| 2318 // Function complete: () → void | |
| 2319 function complete() { | |
| 2320 if (dart.notNull(this._doneFuture !== null) && dart.notNull(this._done
Future._mayComplete)) { | |
| 2321 this._doneFuture._asyncComplete(null); | |
| 2322 } | |
| 2323 } | |
| 2324 if (result !== null) { | |
| 2325 result = result.whenComplete(complete); | |
| 2326 } else { | |
| 2327 complete(); | |
| 2328 } | |
| 2329 return result; | |
| 2330 } | |
| 2331 _recordPause(subscription) { | |
| 2332 if (this._isAddingStream) { | |
| 2333 let addState = dart.as(this._varData, _StreamControllerAddStreamState)
; | |
| 2334 addState.pause(); | |
| 2335 } | |
| 2336 _runGuarded(this._onPause); | |
| 2337 } | |
| 2338 _recordResume(subscription) { | |
| 2339 if (this._isAddingStream) { | |
| 2340 let addState = dart.as(this._varData, _StreamControllerAddStreamState)
; | |
| 2341 addState.resume(); | |
| 2342 } | |
| 2343 _runGuarded(this._onResume); | |
| 2344 } | |
| 2345 } | |
| 2346 _StreamController._STATE_INITIAL = 0; | |
| 2347 _StreamController._STATE_SUBSCRIBED = 1; | |
| 2348 _StreamController._STATE_CANCELED = 2; | |
| 2349 _StreamController._STATE_SUBSCRIPTION_MASK = 3; | |
| 2350 _StreamController._STATE_CLOSED = 4; | |
| 2351 _StreamController._STATE_ADDSTREAM = 8; | |
| 2352 return _StreamController; | |
| 2353 }); | |
| 2354 let _StreamController = _StreamController$(dynamic); | |
| 2355 let _SyncStreamControllerDispatch$ = dart.generic(function(T) { | |
| 2356 class _SyncStreamControllerDispatch extends dart.Object { | |
| 2357 _sendData(data) { | |
| 2358 this._subscription._add(data); | |
| 2359 } | |
| 2360 _sendError(error, stackTrace) { | |
| 2361 this._subscription._addError(error, stackTrace); | |
| 2362 } | |
| 2363 _sendDone() { | |
| 2364 this._subscription._close(); | |
| 2365 } | |
| 2366 } | |
| 2367 return _SyncStreamControllerDispatch; | |
| 2368 }); | |
| 2369 let _SyncStreamControllerDispatch = _SyncStreamControllerDispatch$(dynamic); | |
| 2370 let _AsyncStreamControllerDispatch$ = dart.generic(function(T) { | |
| 2371 class _AsyncStreamControllerDispatch extends dart.Object { | |
| 2372 _sendData(data) { | |
| 2373 this._subscription._addPending(new _DelayedData(data)); | |
| 2374 } | |
| 2375 _sendError(error, stackTrace) { | |
| 2376 this._subscription._addPending(new _DelayedError(error, stackTrace)); | |
| 2377 } | |
| 2378 _sendDone() { | |
| 2379 this._subscription._addPending(new _DelayedDone()); | |
| 2380 } | |
| 2381 } | |
| 2382 return _AsyncStreamControllerDispatch; | |
| 2383 }); | |
| 2384 let _AsyncStreamControllerDispatch = _AsyncStreamControllerDispatch$(dynamic); | |
| 2385 let _AsyncStreamController$ = dart.generic(function(T) { | |
| 2386 class _AsyncStreamController extends dart.mixin(_StreamController$(T), _Asyn
cStreamControllerDispatch$(T)) { | |
| 2387 _AsyncStreamController(_onListen, _onPause, _onResume, _onCancel) { | |
| 2388 this._onListen = _onListen; | |
| 2389 this._onPause = _onPause; | |
| 2390 this._onResume = _onResume; | |
| 2391 this._onCancel = _onCancel; | |
| 2392 super._StreamController(); | |
| 2393 } | |
| 2394 } | |
| 2395 return _AsyncStreamController; | |
| 2396 }); | |
| 2397 let _AsyncStreamController = _AsyncStreamController$(dynamic); | |
| 2398 let _SyncStreamController$ = dart.generic(function(T) { | |
| 2399 class _SyncStreamController extends dart.mixin(_StreamController$(T), _SyncS
treamControllerDispatch$(T)) { | |
| 2400 _SyncStreamController(_onListen, _onPause, _onResume, _onCancel) { | |
| 2401 this._onListen = _onListen; | |
| 2402 this._onPause = _onPause; | |
| 2403 this._onResume = _onResume; | |
| 2404 this._onCancel = _onCancel; | |
| 2405 super._StreamController(); | |
| 2406 } | |
| 2407 } | |
| 2408 return _SyncStreamController; | |
| 2409 }); | |
| 2410 let _SyncStreamController = _SyncStreamController$(dynamic); | |
| 2411 class _NoCallbacks extends dart.Object { | |
| 2412 get _onListen() { | |
| 2413 return null; | |
| 2414 } | |
| 2415 get _onPause() { | |
| 2416 return null; | |
| 2417 } | |
| 2418 get _onResume() { | |
| 2419 return null; | |
| 2420 } | |
| 2421 get _onCancel() { | |
| 2422 return null; | |
| 2423 } | |
| 2424 } | |
| 2425 class _NoCallbackAsyncStreamController extends dart.mixin(_AsyncStreamControll
erDispatch, _NoCallbacks) { | |
| 2426 } | |
| 2427 class _NoCallbackSyncStreamController extends dart.mixin(_SyncStreamController
Dispatch, _NoCallbacks) { | |
| 2428 } | |
| 2429 // Function _runGuarded: (() → dynamic) → Future<dynamic> | |
| 2430 function _runGuarded(notificationHandler) { | |
| 2431 if (notificationHandler === null) | |
| 2432 return null; | |
| 2433 try { | |
| 2434 let result = notificationHandler(); | |
| 2435 if (dart.is(result, Future)) | |
| 2436 return dart.as(result, Future); | |
| 2437 return null; | |
| 2438 } catch (e) { | |
| 2439 let s = dart.stackTrace(e); | |
| 2440 Zone.current.handleUncaughtError(e, s); | |
| 2441 } | |
| 2442 | |
| 2443 } | |
| 2444 let _ControllerStream$ = dart.generic(function(T) { | |
| 2445 class _ControllerStream extends _StreamImpl$(T) { | |
| 2446 _ControllerStream(_controller) { | |
| 2447 this._controller = _controller; | |
| 2448 super._StreamImpl(); | |
| 2449 } | |
| 2450 _createSubscription(onData, onError, onDone, cancelOnError) { | |
| 2451 return this._controller._subscribe(onData, onError, onDone, cancelOnErro
r); | |
| 2452 } | |
| 2453 get hashCode() { | |
| 2454 return this._controller.hashCode ^ 892482866; | |
| 2455 } | |
| 2456 ['=='](other) { | |
| 2457 if (core.identical(this, other)) | |
| 2458 return true; | |
| 2459 if (!dart.is(other, _ControllerStream)) | |
| 2460 return false; | |
| 2461 let otherStream = dart.as(other, _ControllerStream); | |
| 2462 return core.identical(otherStream._controller, this._controller); | |
| 2463 } | |
| 2464 } | |
| 2465 return _ControllerStream; | |
| 2466 }); | |
| 2467 let _ControllerStream = _ControllerStream$(dynamic); | |
| 2468 let _ControllerSubscription$ = dart.generic(function(T) { | |
| 2469 class _ControllerSubscription extends _BufferingStreamSubscription$(T) { | |
| 2470 _ControllerSubscription(_controller, onData, onError, onDone, cancelOnErro
r) { | |
| 2471 this._controller = _controller; | |
| 2472 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro
r); | |
| 2473 } | |
| 2474 _onCancel() { | |
| 2475 return this._controller._recordCancel(this); | |
| 2476 } | |
| 2477 _onPause() { | |
| 2478 this._controller._recordPause(this); | |
| 2479 } | |
| 2480 _onResume() { | |
| 2481 this._controller._recordResume(this); | |
| 2482 } | |
| 2483 } | |
| 2484 return _ControllerSubscription; | |
| 2485 }); | |
| 2486 let _ControllerSubscription = _ControllerSubscription$(dynamic); | |
| 2487 let _StreamSinkWrapper$ = dart.generic(function(T) { | |
| 2488 class _StreamSinkWrapper extends dart.Object { | |
| 2489 _StreamSinkWrapper(_target) { | |
| 2490 this._target = _target; | |
| 2491 } | |
| 2492 add(data) { | |
| 2493 this._target.add(data); | |
| 2494 } | |
| 2495 addError(error, stackTrace) { | |
| 2496 if (stackTrace === void 0) | |
| 2497 stackTrace = null; | |
| 2498 this._target.addError(error, stackTrace); | |
| 2499 } | |
| 2500 close() { | |
| 2501 return this._target.close(); | |
| 2502 } | |
| 2503 addStream(source, opt$) { | |
| 2504 let cancelOnError = opt$.cancelOnError === void 0 ? true : opt$.cancelOn
Error; | |
| 2505 return this._target.addStream(source, {cancelOnError: cancelOnError}); | |
| 2506 } | |
| 2507 get done() { | |
| 2508 return this._target.done; | |
| 2509 } | |
| 2510 } | |
| 2511 return _StreamSinkWrapper; | |
| 2512 }); | |
| 2513 let _StreamSinkWrapper = _StreamSinkWrapper$(dynamic); | |
| 2514 let _AddStreamState$ = dart.generic(function(T) { | |
| 2515 class _AddStreamState extends dart.Object { | |
| 2516 _AddStreamState(controller, source, cancelOnError) { | |
| 2517 this.addStreamFuture = new _Future(); | |
| 2518 this.addSubscription = source.listen(dart.as(controller._add, dart.throw
_("Unimplemented type (dynamic) → void")), {onError: dart.as(cancelOnError ? mak
eErrorHandler(controller) : controller._addError, core.Function), onDone: contro
ller._close, cancelOnError: cancelOnError}); | |
| 2519 } | |
| 2520 static makeErrorHandler(controller) { | |
| 2521 return ((e, s) => { | |
| 2522 controller._addError(e, s); | |
| 2523 controller._close(); | |
| 2524 }).bind(this); | |
| 2525 } | |
| 2526 pause() { | |
| 2527 this.addSubscription.pause(); | |
| 2528 } | |
| 2529 resume() { | |
| 2530 this.addSubscription.resume(); | |
| 2531 } | |
| 2532 cancel() { | |
| 2533 let cancel = this.addSubscription.cancel(); | |
| 2534 if (cancel === null) { | |
| 2535 this.addStreamFuture._asyncComplete(null); | |
| 2536 return null; | |
| 2537 } | |
| 2538 return cancel.whenComplete((() => { | |
| 2539 this.addStreamFuture._asyncComplete(null); | |
| 2540 }).bind(this)); | |
| 2541 } | |
| 2542 complete() { | |
| 2543 this.addStreamFuture._asyncComplete(null); | |
| 2544 } | |
| 2545 } | |
| 2546 return _AddStreamState; | |
| 2547 }); | |
| 2548 let _AddStreamState = _AddStreamState$(dynamic); | |
| 2549 let _StreamControllerAddStreamState$ = dart.generic(function(T) { | |
| 2550 class _StreamControllerAddStreamState extends _AddStreamState$(T) { | |
| 2551 _StreamControllerAddStreamState(controller, varData, source, cancelOnError
) { | |
| 2552 this.varData = varData; | |
| 2553 super._AddStreamState(dart.as(controller, _EventSink$(T)), source, cance
lOnError); | |
| 2554 if (controller.isPaused) { | |
| 2555 this.addSubscription.pause(); | |
| 2556 } | |
| 2557 } | |
| 2558 } | |
| 2559 return _StreamControllerAddStreamState; | |
| 2560 }); | |
| 2561 let _StreamControllerAddStreamState = _StreamControllerAddStreamState$(dynamic
); | |
| 2562 let _EventSink$ = dart.generic(function(T) { | |
| 2563 class _EventSink extends dart.Object { | |
| 2564 } | |
| 2565 return _EventSink; | |
| 2566 }); | |
| 2567 let _EventSink = _EventSink$(dynamic); | |
| 2568 let _EventDispatch$ = dart.generic(function(T) { | |
| 2569 class _EventDispatch extends dart.Object { | |
| 2570 } | |
| 2571 return _EventDispatch; | |
| 2572 }); | |
| 2573 let _EventDispatch = _EventDispatch$(dynamic); | |
| 2574 let _BufferingStreamSubscription$ = dart.generic(function(T) { | |
| 2575 class _BufferingStreamSubscription extends dart.Object { | |
| 2576 _BufferingStreamSubscription(onData, onError, onDone, cancelOnError) { | |
| 2577 this._zone = Zone.current; | |
| 2578 this._state = cancelOnError ? _STATE_CANCEL_ON_ERROR : 0; | |
| 2579 this._onData = null; | |
| 2580 this._onError = null; | |
| 2581 this._onDone = null; | |
| 2582 this._cancelFuture = null; | |
| 2583 this._pending = null; | |
| 2584 this.onData(onData); | |
| 2585 this.onError(onError); | |
| 2586 this.onDone(onDone); | |
| 2587 } | |
| 2588 _setPendingEvents(pendingEvents) { | |
| 2589 dart.assert(this._pending === null); | |
| 2590 if (pendingEvents === null) | |
| 2591 return; | |
| 2592 this._pending = pendingEvents; | |
| 2593 if (!dart.notNull(pendingEvents.isEmpty)) { | |
| 2594 this._state = _STATE_HAS_PENDING; | |
| 2595 this._pending.schedule(this); | |
| 2596 } | |
| 2597 } | |
| 2598 _extractPending() { | |
| 2599 dart.assert(this._isCanceled); | |
| 2600 let events = this._pending; | |
| 2601 this._pending = null; | |
| 2602 return events; | |
| 2603 } | |
| 2604 onData(handleData) { | |
| 2605 if (handleData === null) | |
| 2606 handleData = _nullDataHandler; | |
| 2607 this._onData = this._zone.registerUnaryCallback(dart.as(handleData, dart
.throw_("Unimplemented type (dynamic) → dynamic"))); | |
| 2608 } | |
| 2609 onError(handleError) { | |
| 2610 if (handleError === null) | |
| 2611 handleError = _nullErrorHandler; | |
| 2612 this._onError = _registerErrorHandler(handleError, this._zone); | |
| 2613 } | |
| 2614 onDone(handleDone) { | |
| 2615 if (handleDone === null) | |
| 2616 handleDone = _nullDoneHandler; | |
| 2617 this._onDone = this._zone.registerCallback(handleDone); | |
| 2618 } | |
| 2619 pause(resumeSignal) { | |
| 2620 if (resumeSignal === void 0) | |
| 2621 resumeSignal = null; | |
| 2622 if (this._isCanceled) | |
| 2623 return; | |
| 2624 let wasPaused = this._isPaused; | |
| 2625 let wasInputPaused = this._isInputPaused; | |
| 2626 this._state = this._state + _STATE_PAUSE_COUNT | _STATE_INPUT_PAUSED; | |
| 2627 if (resumeSignal !== null) | |
| 2628 resumeSignal.whenComplete(this.resume); | |
| 2629 if (dart.notNull(!dart.notNull(wasPaused)) && dart.notNull(this._pending
!== null)) | |
| 2630 this._pending.cancelSchedule(); | |
| 2631 if (dart.notNull(!dart.notNull(wasInputPaused)) && dart.notNull(!dart.no
tNull(this._inCallback))) | |
| 2632 this._guardCallback(this._onPause); | |
| 2633 } | |
| 2634 resume() { | |
| 2635 if (this._isCanceled) | |
| 2636 return; | |
| 2637 if (this._isPaused) { | |
| 2638 this._decrementPauseCount(); | |
| 2639 if (!dart.notNull(this._isPaused)) { | |
| 2640 if (dart.notNull(this._hasPending) && dart.notNull(!dart.notNull(thi
s._pending.isEmpty))) { | |
| 2641 this._pending.schedule(this); | |
| 2642 } else { | |
| 2643 dart.assert(this._mayResumeInput); | |
| 2644 this._state = ~_STATE_INPUT_PAUSED; | |
| 2645 if (!dart.notNull(this._inCallback)) | |
| 2646 this._guardCallback(this._onResume); | |
| 2647 } | |
| 2648 } | |
| 2649 } | |
| 2650 } | |
| 2651 cancel() { | |
| 2652 this._state = ~_STATE_WAIT_FOR_CANCEL; | |
| 2653 if (this._isCanceled) | |
| 2654 return this._cancelFuture; | |
| 2655 this._cancel(); | |
| 2656 return this._cancelFuture; | |
| 2657 } | |
| 2658 asFuture(futureValue) { | |
| 2659 if (futureValue === void 0) | |
| 2660 futureValue = null; | |
| 2661 let result = new _Future(); | |
| 2662 this._onDone = (() => { | |
| 2663 result._complete(futureValue); | |
| 2664 }).bind(this); | |
| 2665 this._onError = ((error, stackTrace) => { | |
| 2666 this.cancel(); | |
| 2667 result._completeError(error, dart.as(stackTrace, core.StackTrace)); | |
| 2668 }).bind(this); | |
| 2669 return result; | |
| 2670 } | |
| 2671 get _isInputPaused() { | |
| 2672 return (this._state & _STATE_INPUT_PAUSED) !== 0; | |
| 2673 } | |
| 2674 get _isClosed() { | |
| 2675 return (this._state & _STATE_CLOSED) !== 0; | |
| 2676 } | |
| 2677 get _isCanceled() { | |
| 2678 return (this._state & _STATE_CANCELED) !== 0; | |
| 2679 } | |
| 2680 get _waitsForCancel() { | |
| 2681 return (this._state & _STATE_WAIT_FOR_CANCEL) !== 0; | |
| 2682 } | |
| 2683 get _inCallback() { | |
| 2684 return (this._state & _STATE_IN_CALLBACK) !== 0; | |
| 2685 } | |
| 2686 get _hasPending() { | |
| 2687 return (this._state & _STATE_HAS_PENDING) !== 0; | |
| 2688 } | |
| 2689 get _isPaused() { | |
| 2690 return this._state >= _STATE_PAUSE_COUNT; | |
| 2691 } | |
| 2692 get _canFire() { | |
| 2693 return this._state < _STATE_IN_CALLBACK; | |
| 2694 } | |
| 2695 get _mayResumeInput() { | |
| 2696 return dart.notNull(!dart.notNull(this._isPaused)) && dart.notNull(dart.
notNull(this._pending === null) || dart.notNull(this._pending.isEmpty)); | |
| 2697 } | |
| 2698 get _cancelOnError() { | |
| 2699 return (this._state & _STATE_CANCEL_ON_ERROR) !== 0; | |
| 2700 } | |
| 2701 get isPaused() { | |
| 2702 return this._isPaused; | |
| 2703 } | |
| 2704 _cancel() { | |
| 2705 this._state = _STATE_CANCELED; | |
| 2706 if (this._hasPending) { | |
| 2707 this._pending.cancelSchedule(); | |
| 2708 } | |
| 2709 if (!dart.notNull(this._inCallback)) | |
| 2710 this._pending = null; | |
| 2711 this._cancelFuture = this._onCancel(); | |
| 2712 } | |
| 2713 _incrementPauseCount() { | |
| 2714 this._state = this._state + _STATE_PAUSE_COUNT | _STATE_INPUT_PAUSED; | |
| 2715 } | |
| 2716 _decrementPauseCount() { | |
| 2717 dart.assert(this._isPaused); | |
| 2718 this._state = _STATE_PAUSE_COUNT; | |
| 2719 } | |
| 2720 _add(data) { | |
| 2721 dart.assert(!dart.notNull(this._isClosed)); | |
| 2722 if (this._isCanceled) | |
| 2723 return; | |
| 2724 if (this._canFire) { | |
| 2725 this._sendData(data); | |
| 2726 } else { | |
| 2727 this._addPending(new _DelayedData(data)); | |
| 2728 } | |
| 2729 } | |
| 2730 _addError(error, stackTrace) { | |
| 2731 if (this._isCanceled) | |
| 2732 return; | |
| 2733 if (this._canFire) { | |
| 2734 this._sendError(error, stackTrace); | |
| 2735 } else { | |
| 2736 this._addPending(new _DelayedError(error, stackTrace)); | |
| 2737 } | |
| 2738 } | |
| 2739 _close() { | |
| 2740 dart.assert(!dart.notNull(this._isClosed)); | |
| 2741 if (this._isCanceled) | |
| 2742 return; | |
| 2743 this._state = _STATE_CLOSED; | |
| 2744 if (this._canFire) { | |
| 2745 this._sendDone(); | |
| 2746 } else { | |
| 2747 this._addPending(new _DelayedDone()); | |
| 2748 } | |
| 2749 } | |
| 2750 _onPause() { | |
| 2751 dart.assert(this._isInputPaused); | |
| 2752 } | |
| 2753 _onResume() { | |
| 2754 dart.assert(!dart.notNull(this._isInputPaused)); | |
| 2755 } | |
| 2756 _onCancel() { | |
| 2757 dart.assert(this._isCanceled); | |
| 2758 return null; | |
| 2759 } | |
| 2760 _addPending(event) { | |
| 2761 let pending = dart.as(this._pending, _StreamImplEvents); | |
| 2762 if (this._pending === null) | |
| 2763 pending = this._pending = new _StreamImplEvents(); | |
| 2764 pending.add(event); | |
| 2765 if (!dart.notNull(this._hasPending)) { | |
| 2766 this._state = _STATE_HAS_PENDING; | |
| 2767 if (!dart.notNull(this._isPaused)) { | |
| 2768 this._pending.schedule(this); | |
| 2769 } | |
| 2770 } | |
| 2771 } | |
| 2772 _sendData(data) { | |
| 2773 dart.assert(!dart.notNull(this._isCanceled)); | |
| 2774 dart.assert(!dart.notNull(this._isPaused)); | |
| 2775 dart.assert(!dart.notNull(this._inCallback)); | |
| 2776 let wasInputPaused = this._isInputPaused; | |
| 2777 this._state = _STATE_IN_CALLBACK; | |
| 2778 this._zone.runUnaryGuarded(dart.as(this._onData, dart.throw_("Unimplemen
ted type (dynamic) → dynamic")), data); | |
| 2779 this._state = ~_STATE_IN_CALLBACK; | |
| 2780 this._checkState(wasInputPaused); | |
| 2781 } | |
| 2782 _sendError(error, stackTrace) { | |
| 2783 dart.assert(!dart.notNull(this._isCanceled)); | |
| 2784 dart.assert(!dart.notNull(this._isPaused)); | |
| 2785 dart.assert(!dart.notNull(this._inCallback)); | |
| 2786 let wasInputPaused = this._isInputPaused; | |
| 2787 // Function sendError: () → void | |
| 2788 function sendError() { | |
| 2789 if (dart.notNull(this._isCanceled) && dart.notNull(!dart.notNull(this.
_waitsForCancel))) | |
| 2790 return; | |
| 2791 this._state = _STATE_IN_CALLBACK; | |
| 2792 if (dart.is(this._onError, ZoneBinaryCallback)) { | |
| 2793 this._zone.runBinaryGuarded(dart.as(this._onError, dart.throw_("Unim
plemented type (dynamic, dynamic) → dynamic")), error, stackTrace); | |
| 2794 } else { | |
| 2795 this._zone.runUnaryGuarded(dart.as(this._onError, dart.throw_("Unimp
lemented type (dynamic) → dynamic")), error); | |
| 2796 } | |
| 2797 this._state = ~_STATE_IN_CALLBACK; | |
| 2798 } | |
| 2799 if (this._cancelOnError) { | |
| 2800 this._state = _STATE_WAIT_FOR_CANCEL; | |
| 2801 this._cancel(); | |
| 2802 if (dart.is(this._cancelFuture, Future)) { | |
| 2803 this._cancelFuture.whenComplete(sendError); | |
| 2804 } else { | |
| 2805 sendError(); | |
| 2806 } | |
| 2807 } else { | |
| 2808 sendError(); | |
| 2809 this._checkState(wasInputPaused); | |
| 2810 } | |
| 2811 } | |
| 2812 _sendDone() { | |
| 2813 dart.assert(!dart.notNull(this._isCanceled)); | |
| 2814 dart.assert(!dart.notNull(this._isPaused)); | |
| 2815 dart.assert(!dart.notNull(this._inCallback)); | |
| 2816 // Function sendDone: () → void | |
| 2817 function sendDone() { | |
| 2818 if (!dart.notNull(this._waitsForCancel)) | |
| 2819 return; | |
| 2820 this._state = _STATE_CANCELED | _STATE_CLOSED | _STATE_IN_CALLBACK; | |
| 2821 this._zone.runGuarded(this._onDone); | |
| 2822 this._state = ~_STATE_IN_CALLBACK; | |
| 2823 } | |
| 2824 this._cancel(); | |
| 2825 this._state = _STATE_WAIT_FOR_CANCEL; | |
| 2826 if (dart.is(this._cancelFuture, Future)) { | |
| 2827 this._cancelFuture.whenComplete(sendDone); | |
| 2828 } else { | |
| 2829 sendDone(); | |
| 2830 } | |
| 2831 } | |
| 2832 _guardCallback(callback) { | |
| 2833 dart.assert(!dart.notNull(this._inCallback)); | |
| 2834 let wasInputPaused = this._isInputPaused; | |
| 2835 this._state = _STATE_IN_CALLBACK; | |
| 2836 dart.dinvokef(callback); | |
| 2837 this._state = ~_STATE_IN_CALLBACK; | |
| 2838 this._checkState(wasInputPaused); | |
| 2839 } | |
| 2840 _checkState(wasInputPaused) { | |
| 2841 dart.assert(!dart.notNull(this._inCallback)); | |
| 2842 if (dart.notNull(this._hasPending) && dart.notNull(this._pending.isEmpty
)) { | |
| 2843 this._state = ~_STATE_HAS_PENDING; | |
| 2844 if (dart.notNull(this._isInputPaused) && dart.notNull(this._mayResumeI
nput)) { | |
| 2845 this._state = ~_STATE_INPUT_PAUSED; | |
| 2846 } | |
| 2847 } | |
| 2848 while (true) { | |
| 2849 if (this._isCanceled) { | |
| 2850 this._pending = null; | |
| 2851 return; | |
| 2852 } | |
| 2853 let isInputPaused = this._isInputPaused; | |
| 2854 if (wasInputPaused === isInputPaused) | |
| 2855 break; | |
| 2856 this._state = _STATE_IN_CALLBACK; | |
| 2857 if (isInputPaused) { | |
| 2858 this._onPause(); | |
| 2859 } else { | |
| 2860 this._onResume(); | |
| 2861 } | |
| 2862 this._state = ~_STATE_IN_CALLBACK; | |
| 2863 wasInputPaused = isInputPaused; | |
| 2864 } | |
| 2865 if (dart.notNull(this._hasPending) && dart.notNull(!dart.notNull(this._i
sPaused))) { | |
| 2866 this._pending.schedule(this); | |
| 2867 } | |
| 2868 } | |
| 2869 } | |
| 2870 _BufferingStreamSubscription._STATE_CANCEL_ON_ERROR = 1; | |
| 2871 _BufferingStreamSubscription._STATE_CLOSED = 2; | |
| 2872 _BufferingStreamSubscription._STATE_INPUT_PAUSED = 4; | |
| 2873 _BufferingStreamSubscription._STATE_CANCELED = 8; | |
| 2874 _BufferingStreamSubscription._STATE_WAIT_FOR_CANCEL = 16; | |
| 2875 _BufferingStreamSubscription._STATE_IN_CALLBACK = 32; | |
| 2876 _BufferingStreamSubscription._STATE_HAS_PENDING = 64; | |
| 2877 _BufferingStreamSubscription._STATE_PAUSE_COUNT = 128; | |
| 2878 _BufferingStreamSubscription._STATE_PAUSE_COUNT_SHIFT = 7; | |
| 2879 return _BufferingStreamSubscription; | |
| 2880 }); | |
| 2881 let _BufferingStreamSubscription = _BufferingStreamSubscription$(dynamic); | |
| 2882 let _StreamImpl$ = dart.generic(function(T) { | |
| 2883 class _StreamImpl extends Stream$(T) { | |
| 2884 listen(onData, opt$) { | |
| 2885 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 2886 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 2887 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 2888 cancelOnError = core.identical(true, cancelOnError); | |
| 2889 let subscription = this._createSubscription(onData, onError, onDone, can
celOnError); | |
| 2890 this._onListen(subscription); | |
| 2891 return dart.as(subscription, StreamSubscription$(T)); | |
| 2892 } | |
| 2893 _createSubscription(onData, onError, onDone, cancelOnError) { | |
| 2894 return new _BufferingStreamSubscription(onData, onError, onDone, cancelO
nError); | |
| 2895 } | |
| 2896 _onListen(subscription) {} | |
| 2897 } | |
| 2898 return _StreamImpl; | |
| 2899 }); | |
| 2900 let _StreamImpl = _StreamImpl$(dynamic); | |
| 2901 let _GeneratedStreamImpl$ = dart.generic(function(T) { | |
| 2902 class _GeneratedStreamImpl extends _StreamImpl$(T) { | |
| 2903 _GeneratedStreamImpl(_pending) { | |
| 2904 this._pending = _pending; | |
| 2905 this._isUsed = false; | |
| 2906 super._StreamImpl(); | |
| 2907 } | |
| 2908 _createSubscription(onData, onError, onDone, cancelOnError) { | |
| 2909 if (this._isUsed) | |
| 2910 throw new core.StateError("Stream has already been listened to."); | |
| 2911 this._isUsed = true; | |
| 2912 return ((_) => { | |
| 2913 _._setPendingEvents(this._pending()); | |
| 2914 return _; | |
| 2915 }).bind(this)(new _BufferingStreamSubscription(dart.as(onData, dart.thro
w_("Unimplemented type (dynamic) → void")), onError, onDone, cancelOnError)); | |
| 2916 } | |
| 2917 } | |
| 2918 return _GeneratedStreamImpl; | |
| 2919 }); | |
| 2920 let _GeneratedStreamImpl = _GeneratedStreamImpl$(dynamic); | |
| 2921 let _IterablePendingEvents$ = dart.generic(function(T) { | |
| 2922 class _IterablePendingEvents extends _PendingEvents { | |
| 2923 _IterablePendingEvents(data) { | |
| 2924 this._iterator = data.iterator; | |
| 2925 super._PendingEvents(); | |
| 2926 } | |
| 2927 get isEmpty() { | |
| 2928 return this._iterator === null; | |
| 2929 } | |
| 2930 handleNext(dispatch) { | |
| 2931 if (this._iterator === null) { | |
| 2932 throw new core.StateError("No events pending."); | |
| 2933 } | |
| 2934 let isDone = null; | |
| 2935 try { | |
| 2936 isDone = !dart.notNull(this._iterator.moveNext()); | |
| 2937 } catch (e) { | |
| 2938 let s = dart.stackTrace(e); | |
| 2939 this._iterator = null; | |
| 2940 dispatch._sendError(e, s); | |
| 2941 return; | |
| 2942 } | |
| 2943 | |
| 2944 if (!dart.notNull(isDone)) { | |
| 2945 dispatch._sendData(this._iterator.current); | |
| 2946 } else { | |
| 2947 this._iterator = null; | |
| 2948 dispatch._sendDone(); | |
| 2949 } | |
| 2950 } | |
| 2951 clear() { | |
| 2952 if (this.isScheduled) | |
| 2953 this.cancelSchedule(); | |
| 2954 this._iterator = null; | |
| 2955 } | |
| 2956 } | |
| 2957 return _IterablePendingEvents; | |
| 2958 }); | |
| 2959 let _IterablePendingEvents = _IterablePendingEvents$(dynamic); | |
| 2960 // Function _nullDataHandler: (dynamic) → void | |
| 2961 function _nullDataHandler(value) { | |
| 2962 } | |
| 2963 // Function _nullErrorHandler: (dynamic, [StackTrace]) → void | |
| 2964 function _nullErrorHandler(error, stackTrace) { | |
| 2965 if (stackTrace === void 0) | |
| 2966 stackTrace = null; | |
| 2967 Zone.current.handleUncaughtError(error, stackTrace); | |
| 2968 } | |
| 2969 // Function _nullDoneHandler: () → void | |
| 2970 function _nullDoneHandler() { | |
| 2971 } | |
| 2972 class _DelayedEvent extends dart.Object { | |
| 2973 _DelayedEvent() { | |
| 2974 this.next = null; | |
| 2975 } | |
| 2976 } | |
| 2977 let _DelayedData$ = dart.generic(function(T) { | |
| 2978 class _DelayedData extends _DelayedEvent { | |
| 2979 _DelayedData(value) { | |
| 2980 this.value = value; | |
| 2981 super._DelayedEvent(); | |
| 2982 } | |
| 2983 perform(dispatch) { | |
| 2984 dispatch._sendData(this.value); | |
| 2985 } | |
| 2986 } | |
| 2987 return _DelayedData; | |
| 2988 }); | |
| 2989 let _DelayedData = _DelayedData$(dynamic); | |
| 2990 class _DelayedError extends _DelayedEvent { | |
| 2991 _DelayedError(error, stackTrace) { | |
| 2992 this.error = error; | |
| 2993 this.stackTrace = stackTrace; | |
| 2994 super._DelayedEvent(); | |
| 2995 } | |
| 2996 perform(dispatch) { | |
| 2997 dispatch._sendError(this.error, this.stackTrace); | |
| 2998 } | |
| 2999 } | |
| 3000 class _DelayedDone extends dart.Object { | |
| 3001 _DelayedDone() { | |
| 3002 } | |
| 3003 perform(dispatch) { | |
| 3004 dispatch._sendDone(); | |
| 3005 } | |
| 3006 get next() { | |
| 3007 return null; | |
| 3008 } | |
| 3009 set next(_) { | |
| 3010 throw new core.StateError("No events after a done."); | |
| 3011 } | |
| 3012 } | |
| 3013 class _PendingEvents extends dart.Object { | |
| 3014 _PendingEvents() { | |
| 3015 this._state = _STATE_UNSCHEDULED; | |
| 3016 } | |
| 3017 get isScheduled() { | |
| 3018 return this._state === _STATE_SCHEDULED; | |
| 3019 } | |
| 3020 get _eventScheduled() { | |
| 3021 return this._state >= _STATE_SCHEDULED; | |
| 3022 } | |
| 3023 schedule(dispatch) { | |
| 3024 if (this.isScheduled) | |
| 3025 return; | |
| 3026 dart.assert(!dart.notNull(this.isEmpty)); | |
| 3027 if (this._eventScheduled) { | |
| 3028 dart.assert(this._state === _STATE_CANCELED); | |
| 3029 this._state = _STATE_SCHEDULED; | |
| 3030 return; | |
| 3031 } | |
| 3032 scheduleMicrotask((() => { | |
| 3033 let oldState = this._state; | |
| 3034 this._state = _STATE_UNSCHEDULED; | |
| 3035 if (oldState === _STATE_CANCELED) | |
| 3036 return; | |
| 3037 this.handleNext(dispatch); | |
| 3038 }).bind(this)); | |
| 3039 this._state = _STATE_SCHEDULED; | |
| 3040 } | |
| 3041 cancelSchedule() { | |
| 3042 if (this.isScheduled) | |
| 3043 this._state = _STATE_CANCELED; | |
| 3044 } | |
| 3045 } | |
| 3046 _PendingEvents._STATE_UNSCHEDULED = 0; | |
| 3047 _PendingEvents._STATE_SCHEDULED = 1; | |
| 3048 _PendingEvents._STATE_CANCELED = 3; | |
| 3049 class _StreamImplEvents extends _PendingEvents { | |
| 3050 _StreamImplEvents() { | |
| 3051 this.firstPendingEvent = null; | |
| 3052 this.lastPendingEvent = null; | |
| 3053 super._PendingEvents(); | |
| 3054 } | |
| 3055 get isEmpty() { | |
| 3056 return this.lastPendingEvent === null; | |
| 3057 } | |
| 3058 add(event) { | |
| 3059 if (this.lastPendingEvent === null) { | |
| 3060 this.firstPendingEvent = this.lastPendingEvent = event; | |
| 3061 } else { | |
| 3062 this.lastPendingEvent = this.lastPendingEvent.next = event; | |
| 3063 } | |
| 3064 } | |
| 3065 handleNext(dispatch) { | |
| 3066 dart.assert(!dart.notNull(this.isScheduled)); | |
| 3067 let event = this.firstPendingEvent; | |
| 3068 this.firstPendingEvent = event.next; | |
| 3069 if (this.firstPendingEvent === null) { | |
| 3070 this.lastPendingEvent = null; | |
| 3071 } | |
| 3072 event.perform(dispatch); | |
| 3073 } | |
| 3074 clear() { | |
| 3075 if (this.isScheduled) | |
| 3076 this.cancelSchedule(); | |
| 3077 this.firstPendingEvent = this.lastPendingEvent = null; | |
| 3078 } | |
| 3079 } | |
| 3080 class _BroadcastLinkedList extends dart.Object { | |
| 3081 _BroadcastLinkedList() { | |
| 3082 this._next = null; | |
| 3083 this._previous = null; | |
| 3084 } | |
| 3085 _unlink() { | |
| 3086 this._previous._next = this._next; | |
| 3087 this._next._previous = this._previous; | |
| 3088 this._next = this._previous = this; | |
| 3089 } | |
| 3090 _insertBefore(newNext) { | |
| 3091 let newPrevious = newNext._previous; | |
| 3092 newPrevious._next = this; | |
| 3093 newNext._previous = this._previous; | |
| 3094 this._previous._next = newNext; | |
| 3095 this._previous = newPrevious; | |
| 3096 } | |
| 3097 } | |
| 3098 let _DoneStreamSubscription$ = dart.generic(function(T) { | |
| 3099 class _DoneStreamSubscription extends dart.Object { | |
| 3100 _DoneStreamSubscription(_onDone) { | |
| 3101 this._onDone = _onDone; | |
| 3102 this._zone = Zone.current; | |
| 3103 this._state = 0; | |
| 3104 this._schedule(); | |
| 3105 } | |
| 3106 get _isSent() { | |
| 3107 return (this._state & _DONE_SENT) !== 0; | |
| 3108 } | |
| 3109 get _isScheduled() { | |
| 3110 return (this._state & _SCHEDULED) !== 0; | |
| 3111 } | |
| 3112 get isPaused() { | |
| 3113 return this._state >= _PAUSED; | |
| 3114 } | |
| 3115 _schedule() { | |
| 3116 if (this._isScheduled) | |
| 3117 return; | |
| 3118 this._zone.scheduleMicrotask(this._sendDone); | |
| 3119 this._state = _SCHEDULED; | |
| 3120 } | |
| 3121 onData(handleData) {} | |
| 3122 onError(handleError) {} | |
| 3123 onDone(handleDone) { | |
| 3124 this._onDone = handleDone; | |
| 3125 } | |
| 3126 pause(resumeSignal) { | |
| 3127 if (resumeSignal === void 0) | |
| 3128 resumeSignal = null; | |
| 3129 this._state = _PAUSED; | |
| 3130 if (resumeSignal !== null) | |
| 3131 resumeSignal.whenComplete(this.resume); | |
| 3132 } | |
| 3133 resume() { | |
| 3134 if (this.isPaused) { | |
| 3135 this._state = _PAUSED; | |
| 3136 if (dart.notNull(!dart.notNull(this.isPaused)) && dart.notNull(!dart.n
otNull(this._isSent))) { | |
| 3137 this._schedule(); | |
| 3138 } | |
| 3139 } | |
| 3140 } | |
| 3141 cancel() { | |
| 3142 return null; | |
| 3143 } | |
| 3144 asFuture(futureValue) { | |
| 3145 if (futureValue === void 0) | |
| 3146 futureValue = null; | |
| 3147 let result = new _Future(); | |
| 3148 this._onDone = (() => { | |
| 3149 result._completeWithValue(null); | |
| 3150 }).bind(this); | |
| 3151 return result; | |
| 3152 } | |
| 3153 _sendDone() { | |
| 3154 this._state = ~_SCHEDULED; | |
| 3155 if (this.isPaused) | |
| 3156 return; | |
| 3157 this._state = _DONE_SENT; | |
| 3158 if (this._onDone !== null) | |
| 3159 this._zone.runGuarded(this._onDone); | |
| 3160 } | |
| 3161 } | |
| 3162 _DoneStreamSubscription._DONE_SENT = 1; | |
| 3163 _DoneStreamSubscription._SCHEDULED = 2; | |
| 3164 _DoneStreamSubscription._PAUSED = 4; | |
| 3165 return _DoneStreamSubscription; | |
| 3166 }); | |
| 3167 let _DoneStreamSubscription = _DoneStreamSubscription$(dynamic); | |
| 3168 let _AsBroadcastStream$ = dart.generic(function(T) { | |
| 3169 class _AsBroadcastStream extends Stream$(T) { | |
| 3170 _AsBroadcastStream(_source, onListenHandler, onCancelHandler) { | |
| 3171 this._source = _source; | |
| 3172 this._onListenHandler = Zone.current.registerUnaryCallback(dart.as(onLis
tenHandler, dart.throw_("Unimplemented type (dynamic) → dynamic"))); | |
| 3173 this._onCancelHandler = Zone.current.registerUnaryCallback(dart.as(onCan
celHandler, dart.throw_("Unimplemented type (dynamic) → dynamic"))); | |
| 3174 this._zone = Zone.current; | |
| 3175 this._controller = null; | |
| 3176 this._subscription = null; | |
| 3177 super.Stream(); | |
| 3178 this._controller = new _AsBroadcastStreamController(this._onListen, this
._onCancel); | |
| 3179 } | |
| 3180 get isBroadcast() { | |
| 3181 return true; | |
| 3182 } | |
| 3183 listen(onData, opt$) { | |
| 3184 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 3185 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 3186 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 3187 if (dart.notNull(this._controller === null) || dart.notNull(this._contro
ller.isClosed)) { | |
| 3188 return new _DoneStreamSubscription(onDone); | |
| 3189 } | |
| 3190 if (this._subscription === null) { | |
| 3191 this._subscription = this._source.listen(this._controller.add, {onErro
r: this._controller.addError, onDone: this._controller.close}); | |
| 3192 } | |
| 3193 cancelOnError = core.identical(true, cancelOnError); | |
| 3194 return this._controller._subscribe(onData, onError, onDone, cancelOnErro
r); | |
| 3195 } | |
| 3196 _onCancel() { | |
| 3197 let shutdown = dart.notNull(this._controller === null) || dart.notNull(t
his._controller.isClosed); | |
| 3198 if (this._onCancelHandler !== null) { | |
| 3199 this._zone.runUnary(dart.as(this._onCancelHandler, dart.throw_("Unimpl
emented type (dynamic) → dynamic")), new _BroadcastSubscriptionWrapper(this)); | |
| 3200 } | |
| 3201 if (shutdown) { | |
| 3202 if (this._subscription !== null) { | |
| 3203 this._subscription.cancel(); | |
| 3204 this._subscription = null; | |
| 3205 } | |
| 3206 } | |
| 3207 } | |
| 3208 _onListen() { | |
| 3209 if (this._onListenHandler !== null) { | |
| 3210 this._zone.runUnary(dart.as(this._onListenHandler, dart.throw_("Unimpl
emented type (dynamic) → dynamic")), new _BroadcastSubscriptionWrapper(this)); | |
| 3211 } | |
| 3212 } | |
| 3213 _cancelSubscription() { | |
| 3214 if (this._subscription === null) | |
| 3215 return; | |
| 3216 let subscription = this._subscription; | |
| 3217 this._subscription = null; | |
| 3218 this._controller = null; | |
| 3219 subscription.cancel(); | |
| 3220 } | |
| 3221 _pauseSubscription(resumeSignal) { | |
| 3222 if (this._subscription === null) | |
| 3223 return; | |
| 3224 this._subscription.pause(resumeSignal); | |
| 3225 } | |
| 3226 _resumeSubscription() { | |
| 3227 if (this._subscription === null) | |
| 3228 return; | |
| 3229 this._subscription.resume(); | |
| 3230 } | |
| 3231 get _isSubscriptionPaused() { | |
| 3232 if (this._subscription === null) | |
| 3233 return false; | |
| 3234 return this._subscription.isPaused; | |
| 3235 } | |
| 3236 } | |
| 3237 return _AsBroadcastStream; | |
| 3238 }); | |
| 3239 let _AsBroadcastStream = _AsBroadcastStream$(dynamic); | |
| 3240 let _BroadcastSubscriptionWrapper$ = dart.generic(function(T) { | |
| 3241 class _BroadcastSubscriptionWrapper extends dart.Object { | |
| 3242 _BroadcastSubscriptionWrapper(_stream) { | |
| 3243 this._stream = _stream; | |
| 3244 } | |
| 3245 onData(handleData) { | |
| 3246 throw new core.UnsupportedError("Cannot change handlers of asBroadcastSt
ream source subscription."); | |
| 3247 } | |
| 3248 onError(handleError) { | |
| 3249 throw new core.UnsupportedError("Cannot change handlers of asBroadcastSt
ream source subscription."); | |
| 3250 } | |
| 3251 onDone(handleDone) { | |
| 3252 throw new core.UnsupportedError("Cannot change handlers of asBroadcastSt
ream source subscription."); | |
| 3253 } | |
| 3254 pause(resumeSignal) { | |
| 3255 if (resumeSignal === void 0) | |
| 3256 resumeSignal = null; | |
| 3257 this._stream._pauseSubscription(resumeSignal); | |
| 3258 } | |
| 3259 resume() { | |
| 3260 this._stream._resumeSubscription(); | |
| 3261 } | |
| 3262 cancel() { | |
| 3263 this._stream._cancelSubscription(); | |
| 3264 return null; | |
| 3265 } | |
| 3266 get isPaused() { | |
| 3267 return this._stream._isSubscriptionPaused; | |
| 3268 } | |
| 3269 asFuture(futureValue) { | |
| 3270 if (futureValue === void 0) | |
| 3271 futureValue = null; | |
| 3272 throw new core.UnsupportedError("Cannot change handlers of asBroadcastSt
ream source subscription."); | |
| 3273 } | |
| 3274 } | |
| 3275 return _BroadcastSubscriptionWrapper; | |
| 3276 }); | |
| 3277 let _BroadcastSubscriptionWrapper = _BroadcastSubscriptionWrapper$(dynamic); | |
| 3278 let _StreamIteratorImpl$ = dart.generic(function(T) { | |
| 3279 class _StreamIteratorImpl extends dart.Object { | |
| 3280 _StreamIteratorImpl(stream) { | |
| 3281 this._subscription = null; | |
| 3282 this._current = dart.as(null, T); | |
| 3283 this._futureOrPrefetch = null; | |
| 3284 this._state = _STATE_FOUND; | |
| 3285 this._subscription = stream.listen(this._onData, {onError: this._onError
, onDone: this._onDone, cancelOnError: true}); | |
| 3286 } | |
| 3287 get current() { | |
| 3288 return this._current; | |
| 3289 } | |
| 3290 moveNext() { | |
| 3291 if (this._state === _STATE_DONE) { | |
| 3292 return new _Future.immediate(false); | |
| 3293 } | |
| 3294 if (this._state === _STATE_MOVING) { | |
| 3295 throw new core.StateError("Already waiting for next."); | |
| 3296 } | |
| 3297 if (this._state === _STATE_FOUND) { | |
| 3298 this._state = _STATE_MOVING; | |
| 3299 this._current = dart.as(null, T); | |
| 3300 this._futureOrPrefetch = new _Future(); | |
| 3301 return dart.as(this._futureOrPrefetch, Future$(core.bool)); | |
| 3302 } else { | |
| 3303 dart.assert(this._state >= _STATE_EXTRA_DATA); | |
| 3304 switch (this._state) { | |
| 3305 case _STATE_EXTRA_DATA: | |
| 3306 this._state = _STATE_FOUND; | |
| 3307 this._current = dart.as(this._futureOrPrefetch, T); | |
| 3308 this._futureOrPrefetch = null; | |
| 3309 this._subscription.resume(); | |
| 3310 return new _Future.immediate(true); | |
| 3311 case _STATE_EXTRA_ERROR: | |
| 3312 let prefetch = dart.as(this._futureOrPrefetch, AsyncError); | |
| 3313 this._clear(); | |
| 3314 return new _Future.immediateError(prefetch.error, prefetch.stackTr
ace); | |
| 3315 case _STATE_EXTRA_DONE: | |
| 3316 this._clear(); | |
| 3317 return new _Future.immediate(false); | |
| 3318 } | |
| 3319 } | |
| 3320 } | |
| 3321 _clear() { | |
| 3322 this._subscription = null; | |
| 3323 this._futureOrPrefetch = null; | |
| 3324 this._current = dart.as(null, T); | |
| 3325 this._state = _STATE_DONE; | |
| 3326 } | |
| 3327 cancel() { | |
| 3328 let subscription = this._subscription; | |
| 3329 if (this._state === _STATE_MOVING) { | |
| 3330 let hasNext = dart.as(this._futureOrPrefetch, _Future$(core.bool)); | |
| 3331 this._clear(); | |
| 3332 hasNext._complete(false); | |
| 3333 } else { | |
| 3334 this._clear(); | |
| 3335 } | |
| 3336 return subscription.cancel(); | |
| 3337 } | |
| 3338 _onData(data) { | |
| 3339 if (this._state === _STATE_MOVING) { | |
| 3340 this._current = data; | |
| 3341 let hasNext = dart.as(this._futureOrPrefetch, _Future$(core.bool)); | |
| 3342 this._futureOrPrefetch = null; | |
| 3343 this._state = _STATE_FOUND; | |
| 3344 hasNext._complete(true); | |
| 3345 return; | |
| 3346 } | |
| 3347 this._subscription.pause(); | |
| 3348 dart.assert(this._futureOrPrefetch === null); | |
| 3349 this._futureOrPrefetch = data; | |
| 3350 this._state = _STATE_EXTRA_DATA; | |
| 3351 } | |
| 3352 _onError(error, stackTrace) { | |
| 3353 if (stackTrace === void 0) | |
| 3354 stackTrace = null; | |
| 3355 if (this._state === _STATE_MOVING) { | |
| 3356 let hasNext = dart.as(this._futureOrPrefetch, _Future$(core.bool)); | |
| 3357 this._clear(); | |
| 3358 hasNext._completeError(error, stackTrace); | |
| 3359 return; | |
| 3360 } | |
| 3361 this._subscription.pause(); | |
| 3362 dart.assert(this._futureOrPrefetch === null); | |
| 3363 this._futureOrPrefetch = new AsyncError(error, stackTrace); | |
| 3364 this._state = _STATE_EXTRA_ERROR; | |
| 3365 } | |
| 3366 _onDone() { | |
| 3367 if (this._state === _STATE_MOVING) { | |
| 3368 let hasNext = dart.as(this._futureOrPrefetch, _Future$(core.bool)); | |
| 3369 this._clear(); | |
| 3370 hasNext._complete(false); | |
| 3371 return; | |
| 3372 } | |
| 3373 this._subscription.pause(); | |
| 3374 this._futureOrPrefetch = null; | |
| 3375 this._state = _STATE_EXTRA_DONE; | |
| 3376 } | |
| 3377 } | |
| 3378 _StreamIteratorImpl._STATE_FOUND = 0; | |
| 3379 _StreamIteratorImpl._STATE_DONE = 1; | |
| 3380 _StreamIteratorImpl._STATE_MOVING = 2; | |
| 3381 _StreamIteratorImpl._STATE_EXTRA_DATA = 3; | |
| 3382 _StreamIteratorImpl._STATE_EXTRA_ERROR = 4; | |
| 3383 _StreamIteratorImpl._STATE_EXTRA_DONE = 5; | |
| 3384 return _StreamIteratorImpl; | |
| 3385 }); | |
| 3386 let _StreamIteratorImpl = _StreamIteratorImpl$(dynamic); | |
| 3387 // Function _runUserCode: (() → dynamic, (dynamic) → dynamic, (dynamic, StackT
race) → dynamic) → dynamic | |
| 3388 function _runUserCode(userCode, onSuccess, onError) { | |
| 3389 try { | |
| 3390 onSuccess(userCode()); | |
| 3391 } catch (e) { | |
| 3392 let s = dart.stackTrace(e); | |
| 3393 let replacement = Zone.current.errorCallback(e, s); | |
| 3394 if (replacement === null) { | |
| 3395 onError(e, s); | |
| 3396 } else { | |
| 3397 let error = _nonNullError(replacement.error); | |
| 3398 let stackTrace = replacement.stackTrace; | |
| 3399 onError(error, stackTrace); | |
| 3400 } | |
| 3401 } | |
| 3402 | |
| 3403 } | |
| 3404 // Function _cancelAndError: (StreamSubscription<dynamic>, _Future<dynamic>, d
ynamic, StackTrace) → void | |
| 3405 function _cancelAndError(subscription, future, error, stackTrace) { | |
| 3406 let cancelFuture = subscription.cancel(); | |
| 3407 if (dart.is(cancelFuture, Future)) { | |
| 3408 cancelFuture.whenComplete(() => future._completeError(error, stackTrace)); | |
| 3409 } else { | |
| 3410 future._completeError(error, stackTrace); | |
| 3411 } | |
| 3412 } | |
| 3413 // Function _cancelAndErrorWithReplacement: (StreamSubscription<dynamic>, _Fut
ure<dynamic>, dynamic, StackTrace) → void | |
| 3414 function _cancelAndErrorWithReplacement(subscription, future, error, stackTrac
e) { | |
| 3415 let replacement = Zone.current.errorCallback(error, stackTrace); | |
| 3416 if (replacement !== null) { | |
| 3417 error = _nonNullError(replacement.error); | |
| 3418 stackTrace = replacement.stackTrace; | |
| 3419 } | |
| 3420 _cancelAndError(subscription, future, error, stackTrace); | |
| 3421 } | |
| 3422 // Function _cancelAndErrorClosure: (StreamSubscription<dynamic>, _Future<dyna
mic>) → dynamic | |
| 3423 function _cancelAndErrorClosure(subscription, future) { | |
| 3424 return (error, stackTrace) => _cancelAndError(subscription, future, error, s
tackTrace); | |
| 3425 } | |
| 3426 // Function _cancelAndValue: (StreamSubscription<dynamic>, _Future<dynamic>, d
ynamic) → void | |
| 3427 function _cancelAndValue(subscription, future, value) { | |
| 3428 let cancelFuture = subscription.cancel(); | |
| 3429 if (dart.is(cancelFuture, Future)) { | |
| 3430 cancelFuture.whenComplete(() => future._complete(value)); | |
| 3431 } else { | |
| 3432 future._complete(value); | |
| 3433 } | |
| 3434 } | |
| 3435 let _ForwardingStream$ = dart.generic(function(S, T) { | |
| 3436 class _ForwardingStream extends Stream$(T) { | |
| 3437 _ForwardingStream(_source) { | |
| 3438 this._source = _source; | |
| 3439 super.Stream(); | |
| 3440 } | |
| 3441 get isBroadcast() { | |
| 3442 return this._source.isBroadcast; | |
| 3443 } | |
| 3444 listen(onData, opt$) { | |
| 3445 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 3446 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 3447 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 3448 cancelOnError = core.identical(true, cancelOnError); | |
| 3449 return this._createSubscription(onData, onError, onDone, cancelOnError); | |
| 3450 } | |
| 3451 _createSubscription(onData, onError, onDone, cancelOnError) { | |
| 3452 return new _ForwardingStreamSubscription(this, onData, onError, onDone,
cancelOnError); | |
| 3453 } | |
| 3454 _handleData(data, sink) { | |
| 3455 let outputData = data; | |
| 3456 sink._add(outputData); | |
| 3457 } | |
| 3458 _handleError(error, stackTrace, sink) { | |
| 3459 sink._addError(error, stackTrace); | |
| 3460 } | |
| 3461 _handleDone(sink) { | |
| 3462 sink._close(); | |
| 3463 } | |
| 3464 } | |
| 3465 return _ForwardingStream; | |
| 3466 }); | |
| 3467 let _ForwardingStream = _ForwardingStream$(dynamic, dynamic); | |
| 3468 let _ForwardingStreamSubscription$ = dart.generic(function(S, T) { | |
| 3469 class _ForwardingStreamSubscription extends _BufferingStreamSubscription$(T)
{ | |
| 3470 _ForwardingStreamSubscription(_stream, onData, onError, onDone, cancelOnEr
ror) { | |
| 3471 this._stream = _stream; | |
| 3472 this._subscription = null; | |
| 3473 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro
r); | |
| 3474 this._subscription = this._stream._source.listen(this._handleData, {onEr
ror: this._handleError, onDone: this._handleDone}); | |
| 3475 } | |
| 3476 _add(data) { | |
| 3477 if (this._isClosed) | |
| 3478 return; | |
| 3479 super._add(data); | |
| 3480 } | |
| 3481 _addError(error, stackTrace) { | |
| 3482 if (this._isClosed) | |
| 3483 return; | |
| 3484 super._addError(error, stackTrace); | |
| 3485 } | |
| 3486 _onPause() { | |
| 3487 if (this._subscription === null) | |
| 3488 return; | |
| 3489 this._subscription.pause(); | |
| 3490 } | |
| 3491 _onResume() { | |
| 3492 if (this._subscription === null) | |
| 3493 return; | |
| 3494 this._subscription.resume(); | |
| 3495 } | |
| 3496 _onCancel() { | |
| 3497 if (this._subscription !== null) { | |
| 3498 let subscription = this._subscription; | |
| 3499 this._subscription = null; | |
| 3500 subscription.cancel(); | |
| 3501 } | |
| 3502 return null; | |
| 3503 } | |
| 3504 _handleData(data) { | |
| 3505 this._stream._handleData(data, this); | |
| 3506 } | |
| 3507 _handleError(error, stackTrace) { | |
| 3508 this._stream._handleError(error, stackTrace, this); | |
| 3509 } | |
| 3510 _handleDone() { | |
| 3511 this._stream._handleDone(this); | |
| 3512 } | |
| 3513 } | |
| 3514 return _ForwardingStreamSubscription; | |
| 3515 }); | |
| 3516 let _ForwardingStreamSubscription = _ForwardingStreamSubscription$(dynamic, dy
namic); | |
| 3517 // Function _addErrorWithReplacement: (_EventSink<dynamic>, dynamic, dynamic)
→ void | |
| 3518 function _addErrorWithReplacement(sink, error, stackTrace) { | |
| 3519 let replacement = Zone.current.errorCallback(error, dart.as(stackTrace, core
.StackTrace)); | |
| 3520 if (replacement !== null) { | |
| 3521 error = _nonNullError(replacement.error); | |
| 3522 stackTrace = replacement.stackTrace; | |
| 3523 } | |
| 3524 sink._addError(error, dart.as(stackTrace, core.StackTrace)); | |
| 3525 } | |
| 3526 let _WhereStream$ = dart.generic(function(T) { | |
| 3527 class _WhereStream extends _ForwardingStream$(T, T) { | |
| 3528 _WhereStream(source, test) { | |
| 3529 this._test = test; | |
| 3530 super._ForwardingStream(source); | |
| 3531 } | |
| 3532 _handleData(inputEvent, sink) { | |
| 3533 let satisfies = null; | |
| 3534 try { | |
| 3535 satisfies = this._test(inputEvent); | |
| 3536 } catch (e) { | |
| 3537 let s = dart.stackTrace(e); | |
| 3538 _addErrorWithReplacement(sink, e, s); | |
| 3539 return; | |
| 3540 } | |
| 3541 | |
| 3542 if (satisfies) { | |
| 3543 sink._add(inputEvent); | |
| 3544 } | |
| 3545 } | |
| 3546 } | |
| 3547 return _WhereStream; | |
| 3548 }); | |
| 3549 let _WhereStream = _WhereStream$(dynamic); | |
| 3550 let _MapStream$ = dart.generic(function(S, T) { | |
| 3551 class _MapStream extends _ForwardingStream$(S, T) { | |
| 3552 _MapStream(source, transform) { | |
| 3553 this._transform = dart.as(transform, _Transformation); | |
| 3554 super._ForwardingStream(source); | |
| 3555 } | |
| 3556 _handleData(inputEvent, sink) { | |
| 3557 let outputEvent = null; | |
| 3558 try { | |
| 3559 outputEvent = dart.as(this._transform(inputEvent), T); | |
| 3560 } catch (e) { | |
| 3561 let s = dart.stackTrace(e); | |
| 3562 _addErrorWithReplacement(sink, e, s); | |
| 3563 return; | |
| 3564 } | |
| 3565 | |
| 3566 sink._add(outputEvent); | |
| 3567 } | |
| 3568 } | |
| 3569 return _MapStream; | |
| 3570 }); | |
| 3571 let _MapStream = _MapStream$(dynamic, dynamic); | |
| 3572 let _ExpandStream$ = dart.generic(function(S, T) { | |
| 3573 class _ExpandStream extends _ForwardingStream$(S, T) { | |
| 3574 _ExpandStream(source, expand) { | |
| 3575 this._expand = expand; | |
| 3576 super._ForwardingStream(source); | |
| 3577 } | |
| 3578 _handleData(inputEvent, sink) { | |
| 3579 try { | |
| 3580 for (let value of this._expand(inputEvent)) { | |
| 3581 sink._add(value); | |
| 3582 } | |
| 3583 } catch (e) { | |
| 3584 let s = dart.stackTrace(e); | |
| 3585 _addErrorWithReplacement(sink, e, s); | |
| 3586 } | |
| 3587 | |
| 3588 } | |
| 3589 } | |
| 3590 return _ExpandStream; | |
| 3591 }); | |
| 3592 let _ExpandStream = _ExpandStream$(dynamic, dynamic); | |
| 3593 let _HandleErrorStream$ = dart.generic(function(T) { | |
| 3594 class _HandleErrorStream extends _ForwardingStream$(T, T) { | |
| 3595 _HandleErrorStream(source, onError, test) { | |
| 3596 this._transform = onError; | |
| 3597 this._test = test; | |
| 3598 super._ForwardingStream(source); | |
| 3599 } | |
| 3600 _handleError(error, stackTrace, sink) { | |
| 3601 let matches = true; | |
| 3602 if (this._test !== null) { | |
| 3603 try { | |
| 3604 matches = this._test(error); | |
| 3605 } catch (e) { | |
| 3606 let s = dart.stackTrace(e); | |
| 3607 _addErrorWithReplacement(sink, e, s); | |
| 3608 return; | |
| 3609 } | |
| 3610 | |
| 3611 } | |
| 3612 if (matches) { | |
| 3613 try { | |
| 3614 _invokeErrorHandler(this._transform, error, stackTrace); | |
| 3615 } catch (e) { | |
| 3616 let s = dart.stackTrace(e); | |
| 3617 if (core.identical(e, error)) { | |
| 3618 sink._addError(error, stackTrace); | |
| 3619 } else { | |
| 3620 _addErrorWithReplacement(sink, e, s); | |
| 3621 } | |
| 3622 return; | |
| 3623 } | |
| 3624 | |
| 3625 } else { | |
| 3626 sink._addError(error, stackTrace); | |
| 3627 } | |
| 3628 } | |
| 3629 } | |
| 3630 return _HandleErrorStream; | |
| 3631 }); | |
| 3632 let _HandleErrorStream = _HandleErrorStream$(dynamic); | |
| 3633 let _TakeStream$ = dart.generic(function(T) { | |
| 3634 class _TakeStream extends _ForwardingStream$(T, T) { | |
| 3635 _TakeStream(source, count) { | |
| 3636 this._remaining = count; | |
| 3637 super._ForwardingStream(source); | |
| 3638 if (!(typeof count == number)) | |
| 3639 throw new core.ArgumentError(count); | |
| 3640 } | |
| 3641 _handleData(inputEvent, sink) { | |
| 3642 if (this._remaining > 0) { | |
| 3643 sink._add(inputEvent); | |
| 3644 this._remaining = 1; | |
| 3645 if (this._remaining === 0) { | |
| 3646 sink._close(); | |
| 3647 } | |
| 3648 } | |
| 3649 } | |
| 3650 } | |
| 3651 return _TakeStream; | |
| 3652 }); | |
| 3653 let _TakeStream = _TakeStream$(dynamic); | |
| 3654 let _TakeWhileStream$ = dart.generic(function(T) { | |
| 3655 class _TakeWhileStream extends _ForwardingStream$(T, T) { | |
| 3656 _TakeWhileStream(source, test) { | |
| 3657 this._test = test; | |
| 3658 super._ForwardingStream(source); | |
| 3659 } | |
| 3660 _handleData(inputEvent, sink) { | |
| 3661 let satisfies = null; | |
| 3662 try { | |
| 3663 satisfies = this._test(inputEvent); | |
| 3664 } catch (e) { | |
| 3665 let s = dart.stackTrace(e); | |
| 3666 _addErrorWithReplacement(sink, e, s); | |
| 3667 sink._close(); | |
| 3668 return; | |
| 3669 } | |
| 3670 | |
| 3671 if (satisfies) { | |
| 3672 sink._add(inputEvent); | |
| 3673 } else { | |
| 3674 sink._close(); | |
| 3675 } | |
| 3676 } | |
| 3677 } | |
| 3678 return _TakeWhileStream; | |
| 3679 }); | |
| 3680 let _TakeWhileStream = _TakeWhileStream$(dynamic); | |
| 3681 let _SkipStream$ = dart.generic(function(T) { | |
| 3682 class _SkipStream extends _ForwardingStream$(T, T) { | |
| 3683 _SkipStream(source, count) { | |
| 3684 this._remaining = count; | |
| 3685 super._ForwardingStream(source); | |
| 3686 if (dart.notNull(!(typeof count == number)) || dart.notNull(count < 0)) | |
| 3687 throw new core.ArgumentError(count); | |
| 3688 } | |
| 3689 _handleData(inputEvent, sink) { | |
| 3690 if (this._remaining > 0) { | |
| 3691 this._remaining--; | |
| 3692 return; | |
| 3693 } | |
| 3694 sink._add(inputEvent); | |
| 3695 } | |
| 3696 } | |
| 3697 return _SkipStream; | |
| 3698 }); | |
| 3699 let _SkipStream = _SkipStream$(dynamic); | |
| 3700 let _SkipWhileStream$ = dart.generic(function(T) { | |
| 3701 class _SkipWhileStream extends _ForwardingStream$(T, T) { | |
| 3702 _SkipWhileStream(source, test) { | |
| 3703 this._test = test; | |
| 3704 this._hasFailed = false; | |
| 3705 super._ForwardingStream(source); | |
| 3706 } | |
| 3707 _handleData(inputEvent, sink) { | |
| 3708 if (this._hasFailed) { | |
| 3709 sink._add(inputEvent); | |
| 3710 return; | |
| 3711 } | |
| 3712 let satisfies = null; | |
| 3713 try { | |
| 3714 satisfies = this._test(inputEvent); | |
| 3715 } catch (e) { | |
| 3716 let s = dart.stackTrace(e); | |
| 3717 _addErrorWithReplacement(sink, e, s); | |
| 3718 this._hasFailed = true; | |
| 3719 return; | |
| 3720 } | |
| 3721 | |
| 3722 if (!dart.notNull(satisfies)) { | |
| 3723 this._hasFailed = true; | |
| 3724 sink._add(inputEvent); | |
| 3725 } | |
| 3726 } | |
| 3727 } | |
| 3728 return _SkipWhileStream; | |
| 3729 }); | |
| 3730 let _SkipWhileStream = _SkipWhileStream$(dynamic); | |
| 3731 let _DistinctStream$ = dart.generic(function(T) { | |
| 3732 class _DistinctStream extends _ForwardingStream$(T, T) { | |
| 3733 _DistinctStream(source, equals) { | |
| 3734 this._previous = _SENTINEL; | |
| 3735 this._equals = equals; | |
| 3736 super._ForwardingStream(source); | |
| 3737 } | |
| 3738 _handleData(inputEvent, sink) { | |
| 3739 if (core.identical(this._previous, _SENTINEL)) { | |
| 3740 this._previous = inputEvent; | |
| 3741 return sink._add(inputEvent); | |
| 3742 } else { | |
| 3743 let isEqual = null; | |
| 3744 try { | |
| 3745 if (this._equals === null) { | |
| 3746 isEqual = dart.equals(this._previous, inputEvent); | |
| 3747 } else { | |
| 3748 isEqual = this._equals(dart.as(this._previous, T), inputEvent); | |
| 3749 } | |
| 3750 } catch (e) { | |
| 3751 let s = dart.stackTrace(e); | |
| 3752 _addErrorWithReplacement(sink, e, s); | |
| 3753 return null; | |
| 3754 } | |
| 3755 | |
| 3756 if (!dart.notNull(isEqual)) { | |
| 3757 sink._add(inputEvent); | |
| 3758 this._previous = inputEvent; | |
| 3759 } | |
| 3760 } | |
| 3761 } | |
| 3762 } | |
| 3763 dart.defineLazyProperties(_DistinctStream, { | |
| 3764 get _SENTINEL() { | |
| 3765 return new core.Object(); | |
| 3766 }, | |
| 3767 set _SENTINEL() {} | |
| 3768 }); | |
| 3769 return _DistinctStream; | |
| 3770 }); | |
| 3771 let _DistinctStream = _DistinctStream$(dynamic); | |
| 3772 let _EventSinkWrapper$ = dart.generic(function(T) { | |
| 3773 class _EventSinkWrapper extends dart.Object { | |
| 3774 _EventSinkWrapper(_sink) { | |
| 3775 this._sink = _sink; | |
| 3776 } | |
| 3777 add(data) { | |
| 3778 this._sink._add(data); | |
| 3779 } | |
| 3780 addError(error, stackTrace) { | |
| 3781 if (stackTrace === void 0) | |
| 3782 stackTrace = null; | |
| 3783 this._sink._addError(error, stackTrace); | |
| 3784 } | |
| 3785 close() { | |
| 3786 this._sink._close(); | |
| 3787 } | |
| 3788 } | |
| 3789 return _EventSinkWrapper; | |
| 3790 }); | |
| 3791 let _EventSinkWrapper = _EventSinkWrapper$(dynamic); | |
| 3792 let _SinkTransformerStreamSubscription$ = dart.generic(function(S, T) { | |
| 3793 class _SinkTransformerStreamSubscription extends _BufferingStreamSubscriptio
n$(T) { | |
| 3794 _SinkTransformerStreamSubscription(source, mapper, onData, onError, onDone
, cancelOnError) { | |
| 3795 this._transformerSink = null; | |
| 3796 this._subscription = null; | |
| 3797 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro
r); | |
| 3798 let eventSink = new _EventSinkWrapper(this); | |
| 3799 this._transformerSink = mapper(eventSink); | |
| 3800 this._subscription = source.listen(this._handleData, {onError: this._han
dleError, onDone: this._handleDone}); | |
| 3801 } | |
| 3802 get _isSubscribed() { | |
| 3803 return this._subscription !== null; | |
| 3804 } | |
| 3805 _add(data) { | |
| 3806 if (this._isClosed) { | |
| 3807 throw new core.StateError("Stream is already closed"); | |
| 3808 } | |
| 3809 super._add(data); | |
| 3810 } | |
| 3811 _addError(error, stackTrace) { | |
| 3812 if (this._isClosed) { | |
| 3813 throw new core.StateError("Stream is already closed"); | |
| 3814 } | |
| 3815 super._addError(error, stackTrace); | |
| 3816 } | |
| 3817 _close() { | |
| 3818 if (this._isClosed) { | |
| 3819 throw new core.StateError("Stream is already closed"); | |
| 3820 } | |
| 3821 super._close(); | |
| 3822 } | |
| 3823 _onPause() { | |
| 3824 if (this._isSubscribed) | |
| 3825 this._subscription.pause(); | |
| 3826 } | |
| 3827 _onResume() { | |
| 3828 if (this._isSubscribed) | |
| 3829 this._subscription.resume(); | |
| 3830 } | |
| 3831 _onCancel() { | |
| 3832 if (this._isSubscribed) { | |
| 3833 let subscription = this._subscription; | |
| 3834 this._subscription = null; | |
| 3835 subscription.cancel(); | |
| 3836 } | |
| 3837 return null; | |
| 3838 } | |
| 3839 _handleData(data) { | |
| 3840 try { | |
| 3841 this._transformerSink.add(data); | |
| 3842 } catch (e) { | |
| 3843 let s = dart.stackTrace(e); | |
| 3844 this._addError(e, s); | |
| 3845 } | |
| 3846 | |
| 3847 } | |
| 3848 _handleError(error, stackTrace) { | |
| 3849 if (stackTrace === void 0) | |
| 3850 stackTrace = null; | |
| 3851 try { | |
| 3852 this._transformerSink.addError(error, dart.as(stackTrace, core.StackTr
ace)); | |
| 3853 } catch (e) { | |
| 3854 let s = dart.stackTrace(e); | |
| 3855 if (core.identical(e, error)) { | |
| 3856 this._addError(error, dart.as(stackTrace, core.StackTrace)); | |
| 3857 } else { | |
| 3858 this._addError(e, s); | |
| 3859 } | |
| 3860 } | |
| 3861 | |
| 3862 } | |
| 3863 _handleDone() { | |
| 3864 try { | |
| 3865 this._subscription = null; | |
| 3866 this._transformerSink.close(); | |
| 3867 } catch (e) { | |
| 3868 let s = dart.stackTrace(e); | |
| 3869 this._addError(e, s); | |
| 3870 } | |
| 3871 | |
| 3872 } | |
| 3873 } | |
| 3874 return _SinkTransformerStreamSubscription; | |
| 3875 }); | |
| 3876 let _SinkTransformerStreamSubscription = _SinkTransformerStreamSubscription$(d
ynamic, dynamic); | |
| 3877 let _StreamSinkTransformer$ = dart.generic(function(S, T) { | |
| 3878 class _StreamSinkTransformer extends dart.Object { | |
| 3879 _StreamSinkTransformer(_sinkMapper) { | |
| 3880 this._sinkMapper = _sinkMapper; | |
| 3881 } | |
| 3882 bind(stream) { | |
| 3883 return new _BoundSinkStream(stream, this._sinkMapper); | |
| 3884 } | |
| 3885 } | |
| 3886 return _StreamSinkTransformer; | |
| 3887 }); | |
| 3888 let _StreamSinkTransformer = _StreamSinkTransformer$(dynamic, dynamic); | |
| 3889 let _BoundSinkStream$ = dart.generic(function(S, T) { | |
| 3890 class _BoundSinkStream extends Stream$(T) { | |
| 3891 get isBroadcast() { | |
| 3892 return this._stream.isBroadcast; | |
| 3893 } | |
| 3894 _BoundSinkStream(_stream, _sinkMapper) { | |
| 3895 this._stream = _stream; | |
| 3896 this._sinkMapper = _sinkMapper; | |
| 3897 super.Stream(); | |
| 3898 } | |
| 3899 listen(onData, opt$) { | |
| 3900 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 3901 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 3902 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 3903 cancelOnError = core.identical(true, cancelOnError); | |
| 3904 let subscription = dart.as(new _SinkTransformerStreamSubscription(this._
stream, dart.as(this._sinkMapper, _SinkMapper), dart.as(onData, dart.throw_("Uni
mplemented type (dynamic) → void")), onError, onDone, cancelOnError), StreamSubs
cription$(T)); | |
| 3905 return subscription; | |
| 3906 } | |
| 3907 } | |
| 3908 return _BoundSinkStream; | |
| 3909 }); | |
| 3910 let _BoundSinkStream = _BoundSinkStream$(dynamic, dynamic); | |
| 3911 let _HandlerEventSink$ = dart.generic(function(S, T) { | |
| 3912 class _HandlerEventSink extends dart.Object { | |
| 3913 _HandlerEventSink(_handleData, _handleError, _handleDone, _sink) { | |
| 3914 this._handleData = _handleData; | |
| 3915 this._handleError = _handleError; | |
| 3916 this._handleDone = _handleDone; | |
| 3917 this._sink = _sink; | |
| 3918 } | |
| 3919 add(data) { | |
| 3920 return this._handleData(data, this._sink); | |
| 3921 } | |
| 3922 addError(error, stackTrace) { | |
| 3923 if (stackTrace === void 0) | |
| 3924 stackTrace = null; | |
| 3925 return this._handleError(error, stackTrace, this._sink); | |
| 3926 } | |
| 3927 close() { | |
| 3928 return this._handleDone(this._sink); | |
| 3929 } | |
| 3930 } | |
| 3931 return _HandlerEventSink; | |
| 3932 }); | |
| 3933 let _HandlerEventSink = _HandlerEventSink$(dynamic, dynamic); | |
| 3934 let _StreamHandlerTransformer$ = dart.generic(function(S, T) { | |
| 3935 class _StreamHandlerTransformer extends _StreamSinkTransformer$(S, T) { | |
| 3936 _StreamHandlerTransformer(opt$) { | |
| 3937 let handleData = opt$.handleData === void 0 ? null : opt$.handleData; | |
| 3938 let handleError = opt$.handleError === void 0 ? null : opt$.handleError; | |
| 3939 let handleDone = opt$.handleDone === void 0 ? null : opt$.handleDone; | |
| 3940 super._StreamSinkTransformer(dart.as((outputSink) => { | |
| 3941 if (handleData === null) | |
| 3942 handleData = _defaultHandleData; | |
| 3943 if (handleError === null) | |
| 3944 handleError = _defaultHandleError; | |
| 3945 if (handleDone === null) | |
| 3946 handleDone = _defaultHandleDone; | |
| 3947 return new _HandlerEventSink(handleData, handleError, handleDone, outp
utSink); | |
| 3948 }, _SinkMapper)); | |
| 3949 } | |
| 3950 bind(stream) { | |
| 3951 return super.bind(stream); | |
| 3952 } | |
| 3953 static _defaultHandleData(data, sink) { | |
| 3954 sink.add(data); | |
| 3955 } | |
| 3956 static _defaultHandleError(error, stackTrace, sink) { | |
| 3957 sink.addError(error); | |
| 3958 } | |
| 3959 static _defaultHandleDone(sink) { | |
| 3960 sink.close(); | |
| 3961 } | |
| 3962 } | |
| 3963 return _StreamHandlerTransformer; | |
| 3964 }); | |
| 3965 let _StreamHandlerTransformer = _StreamHandlerTransformer$(dynamic, dynamic); | |
| 3966 let _StreamSubscriptionTransformer$ = dart.generic(function(S, T) { | |
| 3967 class _StreamSubscriptionTransformer extends dart.Object { | |
| 3968 _StreamSubscriptionTransformer(_transformer) { | |
| 3969 this._transformer = _transformer; | |
| 3970 } | |
| 3971 bind(stream) { | |
| 3972 return new _BoundSubscriptionStream(stream, this._transformer); | |
| 3973 } | |
| 3974 } | |
| 3975 return _StreamSubscriptionTransformer; | |
| 3976 }); | |
| 3977 let _StreamSubscriptionTransformer = _StreamSubscriptionTransformer$(dynamic,
dynamic); | |
| 3978 let _BoundSubscriptionStream$ = dart.generic(function(S, T) { | |
| 3979 class _BoundSubscriptionStream extends Stream$(T) { | |
| 3980 _BoundSubscriptionStream(_stream, _transformer) { | |
| 3981 this._stream = _stream; | |
| 3982 this._transformer = _transformer; | |
| 3983 super.Stream(); | |
| 3984 } | |
| 3985 listen(onData, opt$) { | |
| 3986 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 3987 let onDone = opt$.onDone === void 0 ? null : opt$.onDone; | |
| 3988 let cancelOnError = opt$.cancelOnError === void 0 ? null : opt$.cancelOn
Error; | |
| 3989 cancelOnError = core.identical(true, cancelOnError); | |
| 3990 let result = this._transformer(this._stream, cancelOnError); | |
| 3991 result.onData(onData); | |
| 3992 result.onError(onError); | |
| 3993 result.onDone(onDone); | |
| 3994 return result; | |
| 3995 } | |
| 3996 } | |
| 3997 return _BoundSubscriptionStream; | |
| 3998 }); | |
| 3999 let _BoundSubscriptionStream = _BoundSubscriptionStream$(dynamic, dynamic); | |
| 4000 class Timer extends dart.Object { | |
| 4001 Timer(duration, callback) { | |
| 4002 if (dart.equals(Zone.current, Zone.ROOT)) { | |
| 4003 return Zone.current.createTimer(duration, callback); | |
| 4004 } | |
| 4005 return Zone.current.createTimer(duration, Zone.current.bindCallback(callba
ck, {runGuarded: true})); | |
| 4006 } | |
| 4007 Timer$periodic(duration, callback) { | |
| 4008 if (dart.equals(Zone.current, Zone.ROOT)) { | |
| 4009 return Zone.current.createPeriodicTimer(duration, callback); | |
| 4010 } | |
| 4011 return Zone.current.createPeriodicTimer(duration, Zone.current.bindUnaryCa
llback(dart.as(callback, dart.throw_("Unimplemented type (dynamic) → dynamic")),
{runGuarded: true})); | |
| 4012 } | |
| 4013 static run(callback) { | |
| 4014 new Timer(core.Duration.ZERO, callback); | |
| 4015 } | |
| 4016 static _createTimer(duration, callback) { | |
| 4017 let milliseconds = duration.inMilliseconds; | |
| 4018 if (milliseconds < 0) | |
| 4019 milliseconds = 0; | |
| 4020 return new _isolate_helper.TimerImpl(milliseconds, callback); | |
| 4021 } | |
| 4022 static _createPeriodicTimer(duration, callback) { | |
| 4023 let milliseconds = duration.inMilliseconds; | |
| 4024 if (milliseconds < 0) | |
| 4025 milliseconds = 0; | |
| 4026 return new _isolate_helper.TimerImpl.periodic(milliseconds, callback); | |
| 4027 } | |
| 4028 } | |
| 4029 dart.defineNamedConstructor(Timer, 'periodic'); | |
| 4030 class AsyncError extends dart.Object { | |
| 4031 AsyncError(error, stackTrace) { | |
| 4032 this.error = error; | |
| 4033 this.stackTrace = stackTrace; | |
| 4034 } | |
| 4035 toString() { | |
| 4036 return dart.as(dart.dinvoke(this.error, 'toString'), core.String); | |
| 4037 } | |
| 4038 } | |
| 4039 class _ZoneFunction extends dart.Object { | |
| 4040 _ZoneFunction(zone, function) { | |
| 4041 this.zone = zone; | |
| 4042 this["function"] = function; | |
| 4043 } | |
| 4044 } | |
| 4045 class ZoneSpecification extends dart.Object { | |
| 4046 ZoneSpecification(opt$) { | |
| 4047 return new _ZoneSpecification(opt$); | |
| 4048 } | |
| 4049 ZoneSpecification$from(other, opt$) { | |
| 4050 let handleUncaughtError = opt$.handleUncaughtError === void 0 ? null : opt
$.handleUncaughtError; | |
| 4051 let run = opt$.run === void 0 ? null : opt$.run; | |
| 4052 let runUnary = opt$.runUnary === void 0 ? null : opt$.runUnary; | |
| 4053 let runBinary = opt$.runBinary === void 0 ? null : opt$.runBinary; | |
| 4054 let registerCallback = opt$.registerCallback === void 0 ? null : opt$.regi
sterCallback; | |
| 4055 let registerUnaryCallback = opt$.registerUnaryCallback === void 0 ? null :
opt$.registerUnaryCallback; | |
| 4056 let registerBinaryCallback = opt$.registerBinaryCallback === void 0 ? null
: opt$.registerBinaryCallback; | |
| 4057 let errorCallback = opt$.errorCallback === void 0 ? null : opt$.errorCallb
ack; | |
| 4058 let scheduleMicrotask = opt$.scheduleMicrotask === void 0 ? null : opt$.sc
heduleMicrotask; | |
| 4059 let createTimer = opt$.createTimer === void 0 ? null : opt$.createTimer; | |
| 4060 let createPeriodicTimer = opt$.createPeriodicTimer === void 0 ? null : opt
$.createPeriodicTimer; | |
| 4061 let print = opt$.print === void 0 ? null : opt$.print; | |
| 4062 let fork = opt$.fork === void 0 ? null : opt$.fork; | |
| 4063 return new ZoneSpecification({handleUncaughtError: dart.as(handleUncaughtE
rror !== null ? handleUncaughtError : other.handleUncaughtError, dart.throw_("Un
implemented type (Zone, ZoneDelegate, Zone, dynamic, StackTrace) → dynamic")), r
un: dart.as(run !== null ? run : other.run, dart.throw_("Unimplemented type (Zon
e, ZoneDelegate, Zone, () → dynamic) → dynamic")), runUnary: dart.as(runUnary !=
= null ? runUnary : other.runUnary, dart.throw_("Unimplemented type (Zone, ZoneD
elegate, Zone, (dynamic) → dynamic, dynamic) → dynamic")), runBinary: dart.as(ru
nBinary !== null ? runBinary : other.runBinary, dart.throw_("Unimplemented type
(Zone, ZoneDelegate, Zone, (dynamic, dynamic) → dynamic, dynamic, dynamic) → dyn
amic")), registerCallback: dart.as(registerCallback !== null ? registerCallback
: other.registerCallback, dart.throw_("Unimplemented type (Zone, ZoneDelegate, Z
one, () → dynamic) → ZoneCallback")), registerUnaryCallback: dart.as(registerUna
ryCallback !== null ? registerUnaryCallback : other.registerUnaryCallback, dart.
throw_("Unimplemented type (Zone, ZoneDelegate, Zone, (dynamic) → dynamic) → Zon
eUnaryCallback")), registerBinaryCallback: dart.as(registerBinaryCallback !== nu
ll ? registerBinaryCallback : other.registerBinaryCallback, dart.throw_("Unimple
mented type (Zone, ZoneDelegate, Zone, (dynamic, dynamic) → dynamic) → ZoneBinar
yCallback")), errorCallback: dart.as(errorCallback !== null ? errorCallback : ot
her.errorCallback, dart.throw_("Unimplemented type (Zone, ZoneDelegate, Zone, Ob
ject, StackTrace) → AsyncError")), scheduleMicrotask: dart.as(scheduleMicrotask
!== null ? scheduleMicrotask : other.scheduleMicrotask, dart.throw_("Unimplement
ed type (Zone, ZoneDelegate, Zone, () → dynamic) → void")), createTimer: dart.as
(createTimer !== null ? createTimer : other.createTimer, dart.throw_("Unimplemen
ted type (Zone, ZoneDelegate, Zone, Duration, () → void) → Timer")), createPerio
dicTimer: dart.as(createPeriodicTimer !== null ? createPeriodicTimer : other.cre
atePeriodicTimer, dart.throw_("Unimplemented type (Zone, ZoneDelegate, Zone, Dur
ation, (Timer) → void) → Timer")), print: dart.as(print !== null ? print : other
.print, dart.throw_("Unimplemented type (Zone, ZoneDelegate, Zone, String) → voi
d")), fork: dart.as(fork !== null ? fork : other.fork, dart.throw_("Unimplemente
d type (Zone, ZoneDelegate, Zone, ZoneSpecification, Map<dynamic, dynamic>) → Zo
ne"))}); | |
| 4064 } | |
| 4065 } | |
| 4066 dart.defineNamedConstructor(ZoneSpecification, 'from'); | |
| 4067 class _ZoneSpecification extends dart.Object { | |
| 4068 _ZoneSpecification(opt$) { | |
| 4069 let handleUncaughtError = opt$.handleUncaughtError === void 0 ? null : opt
$.handleUncaughtError; | |
| 4070 let run = opt$.run === void 0 ? null : opt$.run; | |
| 4071 let runUnary = opt$.runUnary === void 0 ? null : opt$.runUnary; | |
| 4072 let runBinary = opt$.runBinary === void 0 ? null : opt$.runBinary; | |
| 4073 let registerCallback = opt$.registerCallback === void 0 ? null : opt$.regi
sterCallback; | |
| 4074 let registerUnaryCallback = opt$.registerUnaryCallback === void 0 ? null :
opt$.registerUnaryCallback; | |
| 4075 let registerBinaryCallback = opt$.registerBinaryCallback === void 0 ? null
: opt$.registerBinaryCallback; | |
| 4076 let errorCallback = opt$.errorCallback === void 0 ? null : opt$.errorCallb
ack; | |
| 4077 let scheduleMicrotask = opt$.scheduleMicrotask === void 0 ? null : opt$.sc
heduleMicrotask; | |
| 4078 let createTimer = opt$.createTimer === void 0 ? null : opt$.createTimer; | |
| 4079 let createPeriodicTimer = opt$.createPeriodicTimer === void 0 ? null : opt
$.createPeriodicTimer; | |
| 4080 let print = opt$.print === void 0 ? null : opt$.print; | |
| 4081 let fork = opt$.fork === void 0 ? null : opt$.fork; | |
| 4082 this.handleUncaughtError = handleUncaughtError; | |
| 4083 this.run = run; | |
| 4084 this.runUnary = runUnary; | |
| 4085 this.runBinary = runBinary; | |
| 4086 this.registerCallback = registerCallback; | |
| 4087 this.registerUnaryCallback = registerUnaryCallback; | |
| 4088 this.registerBinaryCallback = registerBinaryCallback; | |
| 4089 this.errorCallback = errorCallback; | |
| 4090 this.scheduleMicrotask = scheduleMicrotask; | |
| 4091 this.createTimer = createTimer; | |
| 4092 this.createPeriodicTimer = createPeriodicTimer; | |
| 4093 this.print = print; | |
| 4094 this.fork = fork; | |
| 4095 } | |
| 4096 } | |
| 4097 class ZoneDelegate extends dart.Object { | |
| 4098 } | |
| 4099 class Zone extends dart.Object { | |
| 4100 Zone$_() { | |
| 4101 } | |
| 4102 static get current() { | |
| 4103 return _current; | |
| 4104 } | |
| 4105 static _enter(zone) { | |
| 4106 dart.assert(zone !== null); | |
| 4107 dart.assert(!dart.notNull(core.identical(zone, _current))); | |
| 4108 let previous = _current; | |
| 4109 _current = zone; | |
| 4110 return previous; | |
| 4111 } | |
| 4112 static _leave(previous) { | |
| 4113 dart.assert(previous !== null); | |
| 4114 Zone._current = previous; | |
| 4115 } | |
| 4116 } | |
| 4117 dart.defineNamedConstructor(Zone, '_'); | |
| 4118 Zone.ROOT = dart.as(_ROOT_ZONE, Zone); | |
| 4119 Zone._current = dart.as(_ROOT_ZONE, Zone); | |
| 4120 // Function _parentDelegate: (_Zone) → ZoneDelegate | |
| 4121 function _parentDelegate(zone) { | |
| 4122 if (zone.parent === null) | |
| 4123 return null; | |
| 4124 return zone.parent._delegate; | |
| 4125 } | |
| 4126 class _ZoneDelegate extends dart.Object { | |
| 4127 _ZoneDelegate(_delegationTarget) { | |
| 4128 this._delegationTarget = _delegationTarget; | |
| 4129 } | |
| 4130 handleUncaughtError(zone, error, stackTrace) { | |
| 4131 let implementation = this._delegationTarget._handleUncaughtError; | |
| 4132 let implZone = implementation.zone; | |
| 4133 return dart.dinvokef(implementation["function"], implZone, _parentDelegate
(implZone), zone, error, stackTrace); | |
| 4134 } | |
| 4135 run(zone, f) { | |
| 4136 let implementation = this._delegationTarget._run; | |
| 4137 let implZone = implementation.zone; | |
| 4138 return dart.dinvokef(implementation["function"], implZone, _parentDelegate
(implZone), zone, f); | |
| 4139 } | |
| 4140 runUnary(zone, f, arg) { | |
| 4141 let implementation = this._delegationTarget._runUnary; | |
| 4142 let implZone = implementation.zone; | |
| 4143 return dart.dinvokef(implementation["function"], implZone, _parentDelegate
(implZone), zone, f, arg); | |
| 4144 } | |
| 4145 runBinary(zone, f, arg1, arg2) { | |
| 4146 let implementation = this._delegationTarget._runBinary; | |
| 4147 let implZone = implementation.zone; | |
| 4148 return dart.dinvokef(implementation["function"], implZone, _parentDelegate
(implZone), zone, f, arg1, arg2); | |
| 4149 } | |
| 4150 registerCallback(zone, f) { | |
| 4151 let implementation = this._delegationTarget._registerCallback; | |
| 4152 let implZone = implementation.zone; | |
| 4153 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, f), ZoneCallback); | |
| 4154 } | |
| 4155 registerUnaryCallback(zone, f) { | |
| 4156 let implementation = this._delegationTarget._registerUnaryCallback; | |
| 4157 let implZone = implementation.zone; | |
| 4158 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, f), ZoneUnaryCallback); | |
| 4159 } | |
| 4160 registerBinaryCallback(zone, f) { | |
| 4161 let implementation = this._delegationTarget._registerBinaryCallback; | |
| 4162 let implZone = implementation.zone; | |
| 4163 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, f), ZoneBinaryCallback); | |
| 4164 } | |
| 4165 errorCallback(zone, error, stackTrace) { | |
| 4166 let implementation = this._delegationTarget._errorCallback; | |
| 4167 let implZone = implementation.zone; | |
| 4168 if (core.identical(implZone, _ROOT_ZONE)) | |
| 4169 return null; | |
| 4170 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, error, stackTrace), AsyncError); | |
| 4171 } | |
| 4172 scheduleMicrotask(zone, f) { | |
| 4173 let implementation = this._delegationTarget._scheduleMicrotask; | |
| 4174 let implZone = implementation.zone; | |
| 4175 dart.dinvokef(implementation["function"], implZone, _parentDelegate(implZo
ne), zone, f); | |
| 4176 } | |
| 4177 createTimer(zone, duration, f) { | |
| 4178 let implementation = this._delegationTarget._createTimer; | |
| 4179 let implZone = implementation.zone; | |
| 4180 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, duration, f), Timer); | |
| 4181 } | |
| 4182 createPeriodicTimer(zone, period, f) { | |
| 4183 let implementation = this._delegationTarget._createPeriodicTimer; | |
| 4184 let implZone = implementation.zone; | |
| 4185 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, period, f), Timer); | |
| 4186 } | |
| 4187 print(zone, line) { | |
| 4188 let implementation = this._delegationTarget._print; | |
| 4189 let implZone = implementation.zone; | |
| 4190 dart.dinvokef(implementation["function"], implZone, _parentDelegate(implZo
ne), zone, line); | |
| 4191 } | |
| 4192 fork(zone, specification, zoneValues) { | |
| 4193 let implementation = this._delegationTarget._fork; | |
| 4194 let implZone = implementation.zone; | |
| 4195 return dart.as(dart.dinvokef(implementation["function"], implZone, _parent
Delegate(implZone), zone, specification, zoneValues), Zone); | |
| 4196 } | |
| 4197 } | |
| 4198 class _Zone extends dart.Object { | |
| 4199 _Zone() { | |
| 4200 } | |
| 4201 inSameErrorZone(otherZone) { | |
| 4202 return dart.notNull(core.identical(this, otherZone)) || dart.notNull(core.
identical(this.errorZone, otherZone.errorZone)); | |
| 4203 } | |
| 4204 } | |
| 4205 class _CustomZone extends _Zone { | |
| 4206 get _delegate() { | |
| 4207 if (this._delegateCache !== null) | |
| 4208 return this._delegateCache; | |
| 4209 this._delegateCache = new _ZoneDelegate(this); | |
| 4210 return this._delegateCache; | |
| 4211 } | |
| 4212 _CustomZone(parent, specification, _map) { | |
| 4213 this.parent = parent; | |
| 4214 this._map = _map; | |
| 4215 this._runUnary = null; | |
| 4216 this._run = null; | |
| 4217 this._runBinary = null; | |
| 4218 this._registerCallback = null; | |
| 4219 this._registerUnaryCallback = null; | |
| 4220 this._registerBinaryCallback = null; | |
| 4221 this._errorCallback = null; | |
| 4222 this._scheduleMicrotask = null; | |
| 4223 this._createTimer = null; | |
| 4224 this._createPeriodicTimer = null; | |
| 4225 this._print = null; | |
| 4226 this._fork = null; | |
| 4227 this._handleUncaughtError = null; | |
| 4228 this._delegateCache = null; | |
| 4229 super._Zone(); | |
| 4230 this._run = specification.run !== null ? new _ZoneFunction(this, specifica
tion.run) : this.parent._run; | |
| 4231 this._runUnary = specification.runUnary !== null ? new _ZoneFunction(this,
specification.runUnary) : this.parent._runUnary; | |
| 4232 this._runBinary = specification.runBinary !== null ? new _ZoneFunction(thi
s, specification.runBinary) : this.parent._runBinary; | |
| 4233 this._registerCallback = specification.registerCallback !== null ? new _Zo
neFunction(this, specification.registerCallback) : this.parent._registerCallback
; | |
| 4234 this._registerUnaryCallback = specification.registerUnaryCallback !== null
? new _ZoneFunction(this, specification.registerUnaryCallback) : this.parent._r
egisterUnaryCallback; | |
| 4235 this._registerBinaryCallback = specification.registerBinaryCallback !== nu
ll ? new _ZoneFunction(this, specification.registerBinaryCallback) : this.parent
._registerBinaryCallback; | |
| 4236 this._errorCallback = specification.errorCallback !== null ? new _ZoneFunc
tion(this, specification.errorCallback) : this.parent._errorCallback; | |
| 4237 this._scheduleMicrotask = specification.scheduleMicrotask !== null ? new _
ZoneFunction(this, specification.scheduleMicrotask) : this.parent._scheduleMicro
task; | |
| 4238 this._createTimer = specification.createTimer !== null ? new _ZoneFunction
(this, specification.createTimer) : this.parent._createTimer; | |
| 4239 this._createPeriodicTimer = specification.createPeriodicTimer !== null ? n
ew _ZoneFunction(this, specification.createPeriodicTimer) : this.parent._createP
eriodicTimer; | |
| 4240 this._print = specification.print !== null ? new _ZoneFunction(this, speci
fication.print) : this.parent._print; | |
| 4241 this._fork = specification.fork !== null ? new _ZoneFunction(this, specifi
cation.fork) : this.parent._fork; | |
| 4242 this._handleUncaughtError = specification.handleUncaughtError !== null ? n
ew _ZoneFunction(this, specification.handleUncaughtError) : this.parent._handleU
ncaughtError; | |
| 4243 } | |
| 4244 get errorZone() { | |
| 4245 return this._handleUncaughtError.zone; | |
| 4246 } | |
| 4247 runGuarded(f) { | |
| 4248 try { | |
| 4249 return this.run(f); | |
| 4250 } catch (e) { | |
| 4251 let s = dart.stackTrace(e); | |
| 4252 return this.handleUncaughtError(e, s); | |
| 4253 } | |
| 4254 | |
| 4255 } | |
| 4256 runUnaryGuarded(f, arg) { | |
| 4257 try { | |
| 4258 return this.runUnary(f, arg); | |
| 4259 } catch (e) { | |
| 4260 let s = dart.stackTrace(e); | |
| 4261 return this.handleUncaughtError(e, s); | |
| 4262 } | |
| 4263 | |
| 4264 } | |
| 4265 runBinaryGuarded(f, arg1, arg2) { | |
| 4266 try { | |
| 4267 return this.runBinary(f, arg1, arg2); | |
| 4268 } catch (e) { | |
| 4269 let s = dart.stackTrace(e); | |
| 4270 return this.handleUncaughtError(e, s); | |
| 4271 } | |
| 4272 | |
| 4273 } | |
| 4274 bindCallback(f, opt$) { | |
| 4275 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4276 let registered = this.registerCallback(f); | |
| 4277 if (runGuarded) { | |
| 4278 return (() => this.runGuarded(registered)).bind(this); | |
| 4279 } else { | |
| 4280 return (() => this.run(registered)).bind(this); | |
| 4281 } | |
| 4282 } | |
| 4283 bindUnaryCallback(f, opt$) { | |
| 4284 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4285 let registered = this.registerUnaryCallback(f); | |
| 4286 if (runGuarded) { | |
| 4287 return ((arg) => this.runUnaryGuarded(registered, arg)).bind(this); | |
| 4288 } else { | |
| 4289 return ((arg) => this.runUnary(registered, arg)).bind(this); | |
| 4290 } | |
| 4291 } | |
| 4292 bindBinaryCallback(f, opt$) { | |
| 4293 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4294 let registered = this.registerBinaryCallback(f); | |
| 4295 if (runGuarded) { | |
| 4296 return ((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2)).b
ind(this); | |
| 4297 } else { | |
| 4298 return ((arg1, arg2) => this.runBinary(registered, arg1, arg2)).bind(thi
s); | |
| 4299 } | |
| 4300 } | |
| 4301 get(key) { | |
| 4302 let result = this._map.get(key); | |
| 4303 if (dart.notNull(result !== null) || dart.notNull(this._map.containsKey(ke
y))) | |
| 4304 return result; | |
| 4305 if (this.parent !== null) { | |
| 4306 let value = this.parent.get(key); | |
| 4307 if (value !== null) { | |
| 4308 this._map.set(key, value); | |
| 4309 } | |
| 4310 return value; | |
| 4311 } | |
| 4312 dart.assert(dart.equals(this, _ROOT_ZONE)); | |
| 4313 return null; | |
| 4314 } | |
| 4315 handleUncaughtError(error, stackTrace) { | |
| 4316 let implementation = this._handleUncaughtError; | |
| 4317 dart.assert(implementation !== null); | |
| 4318 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4319 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, error, stackTrace); | |
| 4320 } | |
| 4321 fork(opt$) { | |
| 4322 let specification = opt$.specification === void 0 ? null : opt$.specificat
ion; | |
| 4323 let zoneValues = opt$.zoneValues === void 0 ? null : opt$.zoneValues; | |
| 4324 let implementation = this._fork; | |
| 4325 dart.assert(implementation !== null); | |
| 4326 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4327 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, specification, zoneValues), Zone); | |
| 4328 } | |
| 4329 run(f) { | |
| 4330 let implementation = this._run; | |
| 4331 dart.assert(implementation !== null); | |
| 4332 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4333 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, f); | |
| 4334 } | |
| 4335 runUnary(f, arg) { | |
| 4336 let implementation = this._runUnary; | |
| 4337 dart.assert(implementation !== null); | |
| 4338 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4339 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, f, arg); | |
| 4340 } | |
| 4341 runBinary(f, arg1, arg2) { | |
| 4342 let implementation = this._runBinary; | |
| 4343 dart.assert(implementation !== null); | |
| 4344 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4345 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, f, arg1, arg2); | |
| 4346 } | |
| 4347 registerCallback(f) { | |
| 4348 let implementation = this._registerCallback; | |
| 4349 dart.assert(implementation !== null); | |
| 4350 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4351 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, f), ZoneCallback); | |
| 4352 } | |
| 4353 registerUnaryCallback(f) { | |
| 4354 let implementation = this._registerUnaryCallback; | |
| 4355 dart.assert(implementation !== null); | |
| 4356 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4357 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, f), ZoneUnaryCallback); | |
| 4358 } | |
| 4359 registerBinaryCallback(f) { | |
| 4360 let implementation = this._registerBinaryCallback; | |
| 4361 dart.assert(implementation !== null); | |
| 4362 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4363 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, f), ZoneBinaryCallback); | |
| 4364 } | |
| 4365 errorCallback(error, stackTrace) { | |
| 4366 let implementation = this._errorCallback; | |
| 4367 dart.assert(implementation !== null); | |
| 4368 let implementationZone = implementation.zone; | |
| 4369 if (core.identical(implementationZone, _ROOT_ZONE)) | |
| 4370 return null; | |
| 4371 let parentDelegate = _parentDelegate(dart.as(implementationZone, _Zone)); | |
| 4372 return dart.as(dart.dinvokef(implementation["function"], implementationZon
e, parentDelegate, this, error, stackTrace), AsyncError); | |
| 4373 } | |
| 4374 scheduleMicrotask(f) { | |
| 4375 let implementation = this._scheduleMicrotask; | |
| 4376 dart.assert(implementation !== null); | |
| 4377 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4378 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, f); | |
| 4379 } | |
| 4380 createTimer(duration, f) { | |
| 4381 let implementation = this._createTimer; | |
| 4382 dart.assert(implementation !== null); | |
| 4383 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4384 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, duration, f), Timer); | |
| 4385 } | |
| 4386 createPeriodicTimer(duration, f) { | |
| 4387 let implementation = this._createPeriodicTimer; | |
| 4388 dart.assert(implementation !== null); | |
| 4389 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4390 return dart.as(dart.dinvokef(implementation["function"], implementation.zo
ne, parentDelegate, this, duration, f), Timer); | |
| 4391 } | |
| 4392 print(line) { | |
| 4393 let implementation = this._print; | |
| 4394 dart.assert(implementation !== null); | |
| 4395 let parentDelegate = _parentDelegate(implementation.zone); | |
| 4396 return dart.dinvokef(implementation["function"], implementation.zone, pare
ntDelegate, this, line); | |
| 4397 } | |
| 4398 } | |
| 4399 // Function _rootHandleUncaughtError: (Zone, ZoneDelegate, Zone, dynamic, Stac
kTrace) → void | |
| 4400 function _rootHandleUncaughtError(self, parent, zone, error, stackTrace) { | |
| 4401 _schedulePriorityAsyncCallback(() => { | |
| 4402 throw new _UncaughtAsyncError(error, stackTrace); | |
| 4403 }); | |
| 4404 } | |
| 4405 // Function _rootRun: (Zone, ZoneDelegate, Zone, () → dynamic) → dynamic | |
| 4406 function _rootRun(self, parent, zone, f) { | |
| 4407 if (dart.equals(Zone._current, zone)) | |
| 4408 return f(); | |
| 4409 let old = Zone._enter(zone); | |
| 4410 try { | |
| 4411 return f(); | |
| 4412 } finally { | |
| 4413 Zone._leave(old); | |
| 4414 } | |
| 4415 } | |
| 4416 // Function _rootRunUnary: (Zone, ZoneDelegate, Zone, (dynamic) → dynamic, dyn
amic) → dynamic | |
| 4417 function _rootRunUnary(self, parent, zone, f, arg) { | |
| 4418 if (dart.equals(Zone._current, zone)) | |
| 4419 return f(arg); | |
| 4420 let old = Zone._enter(zone); | |
| 4421 try { | |
| 4422 return f(arg); | |
| 4423 } finally { | |
| 4424 Zone._leave(old); | |
| 4425 } | |
| 4426 } | |
| 4427 // Function _rootRunBinary: (Zone, ZoneDelegate, Zone, (dynamic, dynamic) → dy
namic, dynamic, dynamic) → dynamic | |
| 4428 function _rootRunBinary(self, parent, zone, f, arg1, arg2) { | |
| 4429 if (dart.equals(Zone._current, zone)) | |
| 4430 return f(arg1, arg2); | |
| 4431 let old = Zone._enter(zone); | |
| 4432 try { | |
| 4433 return f(arg1, arg2); | |
| 4434 } finally { | |
| 4435 Zone._leave(old); | |
| 4436 } | |
| 4437 } | |
| 4438 // Function _rootRegisterCallback: (Zone, ZoneDelegate, Zone, () → dynamic) →
ZoneCallback | |
| 4439 function _rootRegisterCallback(self, parent, zone, f) { | |
| 4440 return f; | |
| 4441 } | |
| 4442 // Function _rootRegisterUnaryCallback: (Zone, ZoneDelegate, Zone, (dynamic) →
dynamic) → ZoneUnaryCallback | |
| 4443 function _rootRegisterUnaryCallback(self, parent, zone, f) { | |
| 4444 return f; | |
| 4445 } | |
| 4446 // Function _rootRegisterBinaryCallback: (Zone, ZoneDelegate, Zone, (dynamic,
dynamic) → dynamic) → ZoneBinaryCallback | |
| 4447 function _rootRegisterBinaryCallback(self, parent, zone, f) { | |
| 4448 return f; | |
| 4449 } | |
| 4450 // Function _rootErrorCallback: (Zone, ZoneDelegate, Zone, Object, StackTrace)
→ AsyncError | |
| 4451 function _rootErrorCallback(self, parent, zone, error, stackTrace) { | |
| 4452 return null; | |
| 4453 } | |
| 4454 // Function _rootScheduleMicrotask: (Zone, ZoneDelegate, Zone, () → dynamic) →
void | |
| 4455 function _rootScheduleMicrotask(self, parent, zone, f) { | |
| 4456 if (!dart.notNull(core.identical(_ROOT_ZONE, zone))) { | |
| 4457 let hasErrorHandler = dart.throw_("Unimplemented PrefixExpression: !_ROOT_
ZONE.inSameErrorZone(zone)"); | |
| 4458 f = zone.bindCallback(f, {runGuarded: hasErrorHandler}); | |
| 4459 } | |
| 4460 _scheduleAsyncCallback(f); | |
| 4461 } | |
| 4462 // Function _rootCreateTimer: (Zone, ZoneDelegate, Zone, Duration, () → void)
→ Timer | |
| 4463 function _rootCreateTimer(self, parent, zone, duration, callback) { | |
| 4464 if (!dart.notNull(core.identical(_ROOT_ZONE, zone))) { | |
| 4465 callback = zone.bindCallback(callback); | |
| 4466 } | |
| 4467 return Timer._createTimer(duration, callback); | |
| 4468 } | |
| 4469 // Function _rootCreatePeriodicTimer: (Zone, ZoneDelegate, Zone, Duration, (Ti
mer) → void) → Timer | |
| 4470 function _rootCreatePeriodicTimer(self, parent, zone, duration, callback) { | |
| 4471 if (!dart.notNull(core.identical(_ROOT_ZONE, zone))) { | |
| 4472 callback = zone.bindUnaryCallback(dart.as(callback, dart.throw_("Unimpleme
nted type (dynamic) → dynamic"))); | |
| 4473 } | |
| 4474 return Timer._createPeriodicTimer(duration, callback); | |
| 4475 } | |
| 4476 // Function _rootPrint: (Zone, ZoneDelegate, Zone, String) → void | |
| 4477 function _rootPrint(self, parent, zone, line) { | |
| 4478 _internal.printToConsole(line); | |
| 4479 } | |
| 4480 // Function _printToZone: (String) → void | |
| 4481 function _printToZone(line) { | |
| 4482 Zone.current.print(line); | |
| 4483 } | |
| 4484 // Function _rootFork: (Zone, ZoneDelegate, Zone, ZoneSpecification, Map<dynam
ic, dynamic>) → Zone | |
| 4485 function _rootFork(self, parent, zone, specification, zoneValues) { | |
| 4486 _internal.printToZone = _printToZone; | |
| 4487 if (specification === null) { | |
| 4488 specification = new ZoneSpecification(); | |
| 4489 } else if (!dart.is(specification, _ZoneSpecification)) { | |
| 4490 throw new core.ArgumentError("ZoneSpecifications must be instantiated" + "
with the provided constructor."); | |
| 4491 } | |
| 4492 let valueMap = null; | |
| 4493 if (zoneValues === null) { | |
| 4494 if (dart.is(zone, _Zone)) { | |
| 4495 valueMap = zone._map; | |
| 4496 } else { | |
| 4497 valueMap = new collection.HashMap(); | |
| 4498 } | |
| 4499 } else { | |
| 4500 valueMap = new collection.HashMap.from(zoneValues); | |
| 4501 } | |
| 4502 return new _CustomZone(dart.as(zone, _Zone), specification, valueMap); | |
| 4503 } | |
| 4504 class _RootZoneSpecification extends dart.Object { | |
| 4505 get handleUncaughtError() { | |
| 4506 return _rootHandleUncaughtError; | |
| 4507 } | |
| 4508 get run() { | |
| 4509 return _rootRun; | |
| 4510 } | |
| 4511 get runUnary() { | |
| 4512 return _rootRunUnary; | |
| 4513 } | |
| 4514 get runBinary() { | |
| 4515 return _rootRunBinary; | |
| 4516 } | |
| 4517 get registerCallback() { | |
| 4518 return _rootRegisterCallback; | |
| 4519 } | |
| 4520 get registerUnaryCallback() { | |
| 4521 return _rootRegisterUnaryCallback; | |
| 4522 } | |
| 4523 get registerBinaryCallback() { | |
| 4524 return _rootRegisterBinaryCallback; | |
| 4525 } | |
| 4526 get errorCallback() { | |
| 4527 return _rootErrorCallback; | |
| 4528 } | |
| 4529 get scheduleMicrotask() { | |
| 4530 return _rootScheduleMicrotask; | |
| 4531 } | |
| 4532 get createTimer() { | |
| 4533 return _rootCreateTimer; | |
| 4534 } | |
| 4535 get createPeriodicTimer() { | |
| 4536 return _rootCreatePeriodicTimer; | |
| 4537 } | |
| 4538 get print() { | |
| 4539 return _rootPrint; | |
| 4540 } | |
| 4541 get fork() { | |
| 4542 return _rootFork; | |
| 4543 } | |
| 4544 } | |
| 4545 class _RootZone extends _Zone { | |
| 4546 _RootZone() { | |
| 4547 super._Zone(); | |
| 4548 } | |
| 4549 get _run() { | |
| 4550 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRun); | |
| 4551 } | |
| 4552 get _runUnary() { | |
| 4553 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRunUnary); | |
| 4554 } | |
| 4555 get _runBinary() { | |
| 4556 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRunBinary); | |
| 4557 } | |
| 4558 get _registerCallback() { | |
| 4559 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRegisterCallback
); | |
| 4560 } | |
| 4561 get _registerUnaryCallback() { | |
| 4562 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRegisterUnaryCal
lback); | |
| 4563 } | |
| 4564 get _registerBinaryCallback() { | |
| 4565 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootRegisterBinaryCa
llback); | |
| 4566 } | |
| 4567 get _errorCallback() { | |
| 4568 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootErrorCallback); | |
| 4569 } | |
| 4570 get _scheduleMicrotask() { | |
| 4571 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootScheduleMicrotas
k); | |
| 4572 } | |
| 4573 get _createTimer() { | |
| 4574 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootCreateTimer); | |
| 4575 } | |
| 4576 get _createPeriodicTimer() { | |
| 4577 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootCreatePeriodicTi
mer); | |
| 4578 } | |
| 4579 get _print() { | |
| 4580 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootPrint); | |
| 4581 } | |
| 4582 get _fork() { | |
| 4583 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootFork); | |
| 4584 } | |
| 4585 get _handleUncaughtError() { | |
| 4586 return new _ZoneFunction(dart.as(_ROOT_ZONE, _Zone), _rootHandleUncaughtEr
ror); | |
| 4587 } | |
| 4588 get parent() { | |
| 4589 return null; | |
| 4590 } | |
| 4591 get _map() { | |
| 4592 return _rootMap; | |
| 4593 } | |
| 4594 get _delegate() { | |
| 4595 if (_rootDelegate !== null) | |
| 4596 return _rootDelegate; | |
| 4597 return _rootDelegate = new _ZoneDelegate(this); | |
| 4598 } | |
| 4599 get errorZone() { | |
| 4600 return this; | |
| 4601 } | |
| 4602 runGuarded(f) { | |
| 4603 try { | |
| 4604 if (core.identical(_ROOT_ZONE, Zone._current)) { | |
| 4605 return f(); | |
| 4606 } | |
| 4607 return _rootRun(null, null, this, f); | |
| 4608 } catch (e) { | |
| 4609 let s = dart.stackTrace(e); | |
| 4610 return this.handleUncaughtError(e, s); | |
| 4611 } | |
| 4612 | |
| 4613 } | |
| 4614 runUnaryGuarded(f, arg) { | |
| 4615 try { | |
| 4616 if (core.identical(_ROOT_ZONE, Zone._current)) { | |
| 4617 return f(arg); | |
| 4618 } | |
| 4619 return _rootRunUnary(null, null, this, f, arg); | |
| 4620 } catch (e) { | |
| 4621 let s = dart.stackTrace(e); | |
| 4622 return this.handleUncaughtError(e, s); | |
| 4623 } | |
| 4624 | |
| 4625 } | |
| 4626 runBinaryGuarded(f, arg1, arg2) { | |
| 4627 try { | |
| 4628 if (core.identical(_ROOT_ZONE, Zone._current)) { | |
| 4629 return f(arg1, arg2); | |
| 4630 } | |
| 4631 return _rootRunBinary(null, null, this, f, arg1, arg2); | |
| 4632 } catch (e) { | |
| 4633 let s = dart.stackTrace(e); | |
| 4634 return this.handleUncaughtError(e, s); | |
| 4635 } | |
| 4636 | |
| 4637 } | |
| 4638 bindCallback(f, opt$) { | |
| 4639 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4640 if (runGuarded) { | |
| 4641 return (() => this.runGuarded(f)).bind(this); | |
| 4642 } else { | |
| 4643 return (() => this.run(f)).bind(this); | |
| 4644 } | |
| 4645 } | |
| 4646 bindUnaryCallback(f, opt$) { | |
| 4647 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4648 if (runGuarded) { | |
| 4649 return ((arg) => this.runUnaryGuarded(f, arg)).bind(this); | |
| 4650 } else { | |
| 4651 return ((arg) => this.runUnary(f, arg)).bind(this); | |
| 4652 } | |
| 4653 } | |
| 4654 bindBinaryCallback(f, opt$) { | |
| 4655 let runGuarded = opt$.runGuarded === void 0 ? true : opt$.runGuarded; | |
| 4656 if (runGuarded) { | |
| 4657 return ((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2)).bind(this)
; | |
| 4658 } else { | |
| 4659 return ((arg1, arg2) => this.runBinary(f, arg1, arg2)).bind(this); | |
| 4660 } | |
| 4661 } | |
| 4662 get(key) { | |
| 4663 return null; | |
| 4664 } | |
| 4665 handleUncaughtError(error, stackTrace) { | |
| 4666 return _rootHandleUncaughtError(null, null, this, error, stackTrace); | |
| 4667 } | |
| 4668 fork(opt$) { | |
| 4669 let specification = opt$.specification === void 0 ? null : opt$.specificat
ion; | |
| 4670 let zoneValues = opt$.zoneValues === void 0 ? null : opt$.zoneValues; | |
| 4671 return _rootFork(null, null, this, specification, zoneValues); | |
| 4672 } | |
| 4673 run(f) { | |
| 4674 if (core.identical(Zone._current, _ROOT_ZONE)) | |
| 4675 return f(); | |
| 4676 return _rootRun(null, null, this, f); | |
| 4677 } | |
| 4678 runUnary(f, arg) { | |
| 4679 if (core.identical(Zone._current, _ROOT_ZONE)) | |
| 4680 return f(arg); | |
| 4681 return _rootRunUnary(null, null, this, f, arg); | |
| 4682 } | |
| 4683 runBinary(f, arg1, arg2) { | |
| 4684 if (core.identical(Zone._current, _ROOT_ZONE)) | |
| 4685 return f(arg1, arg2); | |
| 4686 return _rootRunBinary(null, null, this, f, arg1, arg2); | |
| 4687 } | |
| 4688 registerCallback(f) { | |
| 4689 return f; | |
| 4690 } | |
| 4691 registerUnaryCallback(f) { | |
| 4692 return f; | |
| 4693 } | |
| 4694 registerBinaryCallback(f) { | |
| 4695 return f; | |
| 4696 } | |
| 4697 errorCallback(error, stackTrace) { | |
| 4698 return null; | |
| 4699 } | |
| 4700 scheduleMicrotask(f) { | |
| 4701 _rootScheduleMicrotask(null, null, this, f); | |
| 4702 } | |
| 4703 createTimer(duration, f) { | |
| 4704 return Timer._createTimer(duration, f); | |
| 4705 } | |
| 4706 createPeriodicTimer(duration, f) { | |
| 4707 return Timer._createPeriodicTimer(duration, f); | |
| 4708 } | |
| 4709 print(line) { | |
| 4710 _internal.printToConsole(line); | |
| 4711 } | |
| 4712 } | |
| 4713 _RootZone._rootDelegate = null; | |
| 4714 dart.defineLazyProperties(_RootZone, { | |
| 4715 get _rootMap() { | |
| 4716 return new collection.HashMap(); | |
| 4717 }, | |
| 4718 set _rootMap() {} | |
| 4719 }); | |
| 4720 let _ROOT_ZONE = new _RootZone(); | |
| 4721 // Function runZoned: (() → dynamic, {zoneValues: Map<dynamic, dynamic>, zoneS
pecification: ZoneSpecification, onError: Function}) → dynamic | |
| 4722 function runZoned(body, opt$) { | |
| 4723 let zoneValues = opt$.zoneValues === void 0 ? null : opt$.zoneValues; | |
| 4724 let zoneSpecification = opt$.zoneSpecification === void 0 ? null : opt$.zone
Specification; | |
| 4725 let onError = opt$.onError === void 0 ? null : opt$.onError; | |
| 4726 let errorHandler = null; | |
| 4727 if (onError !== null) { | |
| 4728 errorHandler = (self, parent, zone, error, stackTrace) => { | |
| 4729 try { | |
| 4730 if (dart.is(onError, ZoneBinaryCallback)) { | |
| 4731 return self.parent.runBinary(onError, error, stackTrace); | |
| 4732 } | |
| 4733 return self.parent.runUnary(dart.as(onError, dart.throw_("Unimplemente
d type (dynamic) → dynamic")), error); | |
| 4734 } catch (e) { | |
| 4735 let s = dart.stackTrace(e); | |
| 4736 if (core.identical(e, error)) { | |
| 4737 return parent.handleUncaughtError(zone, error, stackTrace); | |
| 4738 } else { | |
| 4739 return parent.handleUncaughtError(zone, e, s); | |
| 4740 } | |
| 4741 } | |
| 4742 | |
| 4743 }; | |
| 4744 } | |
| 4745 if (zoneSpecification === null) { | |
| 4746 zoneSpecification = new ZoneSpecification({handleUncaughtError: errorHandl
er}); | |
| 4747 } else if (errorHandler !== null) { | |
| 4748 zoneSpecification = new ZoneSpecification.from(zoneSpecification, {handleU
ncaughtError: errorHandler}); | |
| 4749 } | |
| 4750 let zone = Zone.current.fork({specification: zoneSpecification, zoneValues:
zoneValues}); | |
| 4751 if (onError !== null) { | |
| 4752 return zone.runGuarded(body); | |
| 4753 } else { | |
| 4754 return zone.run(body); | |
| 4755 } | |
| 4756 } | |
| 4757 // Exports: | |
| 4758 exports.DeferredLibrary = DeferredLibrary; | |
| 4759 exports.DeferredLoadException = DeferredLoadException; | |
| 4760 exports.Future = Future; | |
| 4761 exports.Future$ = Future$; | |
| 4762 exports.TimeoutException = TimeoutException; | |
| 4763 exports.Completer = Completer; | |
| 4764 exports.Completer$ = Completer$; | |
| 4765 exports.scheduleMicrotask = scheduleMicrotask; | |
| 4766 exports.Stream = Stream; | |
| 4767 exports.Stream$ = Stream$; | |
| 4768 exports.StreamSubscription = StreamSubscription; | |
| 4769 exports.StreamSubscription$ = StreamSubscription$; | |
| 4770 exports.EventSink = EventSink; | |
| 4771 exports.EventSink$ = EventSink$; | |
| 4772 exports.StreamView = StreamView; | |
| 4773 exports.StreamView$ = StreamView$; | |
| 4774 exports.StreamConsumer = StreamConsumer; | |
| 4775 exports.StreamConsumer$ = StreamConsumer$; | |
| 4776 exports.StreamSink = StreamSink; | |
| 4777 exports.StreamSink$ = StreamSink$; | |
| 4778 exports.StreamTransformer = StreamTransformer; | |
| 4779 exports.StreamTransformer$ = StreamTransformer$; | |
| 4780 exports.StreamIterator = StreamIterator; | |
| 4781 exports.StreamIterator$ = StreamIterator$; | |
| 4782 exports.StreamController = StreamController; | |
| 4783 exports.StreamController$ = StreamController$; | |
| 4784 exports.Timer = Timer; | |
| 4785 exports.AsyncError = AsyncError; | |
| 4786 exports.ZoneSpecification = ZoneSpecification; | |
| 4787 exports.ZoneDelegate = ZoneDelegate; | |
| 4788 exports.Zone = Zone; | |
| 4789 exports.runZoned = runZoned; | |
| 4790 })(async || (async = {})); | |
| OLD | NEW |