Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: lib/runtime/dart/async.js

Issue 1879373004: Implement modular compilation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/_runtime.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('dart/async', null, /* Imports */[
2 'dart/_runtime',
3 'dart/core',
4 'dart/_internal',
5 'dart/collection'
6 ], /* Lazy imports */[
7 'dart/_isolate_helper'
8 ], function(exports, dart, core, _internal, collection, _isolate_helper) {
9 'use strict';
10 let dartx = dart.dartx;
11 function _invokeErrorHandler(errorHandler, error, stackTrace) {
12 if (dart.is(errorHandler, ZoneBinaryCallback)) {
13 return dart.dcall(errorHandler, error, stackTrace);
14 } else {
15 return dart.dcall(errorHandler, error);
16 }
17 }
18 dart.fn(_invokeErrorHandler, dart.dynamic, [core.Function, core.Object, core.S tackTrace]);
19 function _registerErrorHandler(errorHandler, zone) {
20 if (dart.is(errorHandler, ZoneBinaryCallback)) {
21 return zone.registerBinaryCallback(errorHandler);
22 } else {
23 return zone.registerUnaryCallback(dart.as(errorHandler, dart.functionType( dart.dynamic, [dart.dynamic])));
24 }
25 }
26 dart.fn(_registerErrorHandler, () => dart.definiteFunctionType(core.Function, [core.Function, Zone]));
27 class AsyncError extends core.Object {
28 AsyncError(error, stackTrace) {
29 this.error = error;
30 this.stackTrace = stackTrace;
31 }
32 toString() {
33 return dart.toString(this.error);
34 }
35 }
36 AsyncError[dart.implements] = () => [core.Error];
37 dart.setSignature(AsyncError, {
38 constructors: () => ({AsyncError: [AsyncError, [dart.dynamic, core.StackTrac e]]})
39 });
40 class _UncaughtAsyncError extends AsyncError {
41 _UncaughtAsyncError(error, stackTrace) {
42 super.AsyncError(error, _UncaughtAsyncError._getBestStackTrace(error, stac kTrace));
43 }
44 static _getBestStackTrace(error, stackTrace) {
45 if (stackTrace != null) return stackTrace;
46 if (dart.is(error, core.Error)) {
47 return error.stackTrace;
48 }
49 return null;
50 }
51 toString() {
52 let result = `Uncaught Error: ${this.error}`;
53 if (this.stackTrace != null) {
54 result = result + `\nStack Trace:\n${this.stackTrace}`;
55 }
56 return result;
57 }
58 }
59 dart.setSignature(_UncaughtAsyncError, {
60 constructors: () => ({_UncaughtAsyncError: [_UncaughtAsyncError, [dart.dynam ic, core.StackTrace]]}),
61 statics: () => ({_getBestStackTrace: [core.StackTrace, [dart.dynamic, core.S tackTrace]]}),
62 names: ['_getBestStackTrace']
63 });
64 const _controller = Symbol('_controller');
65 const _subscribe = Symbol('_subscribe');
66 const _createSubscription = Symbol('_createSubscription');
67 const _onListen = Symbol('_onListen');
68 const _add = Symbol('_add');
69 const _closeUnchecked = Symbol('_closeUnchecked');
70 const _addError = Symbol('_addError');
71 const _completeError = Symbol('_completeError');
72 const _complete = Symbol('_complete');
73 const _sink = Symbol('_sink');
74 const Stream$ = dart.generic(function(T) {
75 class Stream extends core.Object {
76 Stream() {
77 }
78 static fromFuture(future) {
79 let controller = dart.as(StreamController$(T).new({sync: true}), _Stream Controller$(T));
80 future.then(dart.fn(value => {
81 dart.as(value, T);
82 controller[_add](value);
83 controller[_closeUnchecked]();
84 }, dart.dynamic, [T]), {onError: dart.fn((error, stackTrace) => {
85 controller[_addError](error, dart.as(stackTrace, core.StackTrace));
86 controller[_closeUnchecked]();
87 })});
88 return controller.stream;
89 }
90 static fromIterable(data) {
91 return new (_GeneratedStreamImpl$(T))(dart.fn(() => new (_IterablePendin gEvents$(T))(data), _IterablePendingEvents$(T), []));
92 }
93 static periodic(period, computation) {
94 if (computation === void 0) computation = null;
95 if (computation == null) computation = dart.fn(i => null, T, [core.int]) ;
96 let timer = null;
97 let computationCount = 0;
98 let controller = null;
99 let watch = new core.Stopwatch();
100 function sendEvent() {
101 watch.reset();
102 let data = computation(computationCount++);
103 controller.add(data);
104 }
105 dart.fn(sendEvent, dart.void, []);
106 function startPeriodicTimer() {
107 dart.assert(timer == null);
108 timer = Timer.periodic(period, dart.fn(timer => {
109 sendEvent();
110 }, dart.void, [Timer]));
111 }
112 dart.fn(startPeriodicTimer, dart.void, []);
113 controller = StreamController$(T).new({sync: true, onListen: dart.fn(() => {
114 watch.start();
115 startPeriodicTimer();
116 }, dart.void, []), onPause: dart.fn(() => {
117 timer.cancel();
118 timer = null;
119 watch.stop();
120 }, dart.void, []), onResume: dart.fn(() => {
121 dart.assert(timer == null);
122 let elapsed = watch.elapsed;
123 watch.start();
124 timer = Timer.new(period['-'](elapsed), dart.fn(() => {
125 timer = null;
126 startPeriodicTimer();
127 sendEvent();
128 }, dart.void, []));
129 }, dart.void, []), onCancel: dart.fn(() => {
130 if (timer != null) timer.cancel();
131 timer = null;
132 })});
133 return controller.stream;
134 }
135 static eventTransformed(source, mapSink) {
136 return new (_BoundSinkStream$(dart.dynamic, T))(source, mapSink);
137 }
138 get isBroadcast() {
139 return false;
140 }
141 asBroadcastStream(opts) {
142 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
143 dart.as(onListen, dart.functionType(dart.void, [StreamSubscription$(T)]) );
144 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
145 dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription$(T)]) );
146 return new (_AsBroadcastStream$(T))(this, dart.as(onListen, dart.functio nType(dart.void, [StreamSubscription])), dart.as(onCancel, dart.functionType(dar t.void, [StreamSubscription])));
147 }
148 where(test) {
149 dart.as(test, dart.functionType(core.bool, [T]));
150 return new (_WhereStream$(T))(this, test);
151 }
152 map(convert) {
153 dart.as(convert, dart.functionType(dart.dynamic, [T]));
154 return new (_MapStream$(T, dart.dynamic))(this, convert);
155 }
156 asyncMap(convert) {
157 dart.as(convert, dart.functionType(dart.dynamic, [T]));
158 let controller = null;
159 let subscription = null;
160 const onListen = (function() {
161 let add = dart.bind(controller, 'add');
162 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
163 let eventSink = dart.as(controller, _EventSink$(T));
164 let addError = dart.bind(eventSink, _addError);
165 subscription = this.listen(dart.fn(event => {
166 dart.as(event, T);
167 let newValue = null;
168 try {
169 newValue = convert(event);
170 } catch (e) {
171 let s = dart.stackTrace(e);
172 controller.addError(e, s);
173 return;
174 }
175
176 if (dart.is(newValue, Future)) {
177 subscription.pause();
178 newValue.then(add, {onError: addError}).whenComplete(dart.bind(sub scription, 'resume'));
179 } else {
180 controller.add(newValue);
181 }
182 }, dart.void, [T]), {onError: addError, onDone: dart.bind(controller, 'close')});
183 }).bind(this);
184 dart.fn(onListen, dart.void, []);
185 if (dart.notNull(this.isBroadcast)) {
186 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
187 subscription.cancel();
188 }, dart.void, []), sync: true});
189 } else {
190 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => {
191 subscription.pause();
192 }, dart.void, []), onResume: dart.fn(() => {
193 subscription.resume();
194 }, dart.void, []), onCancel: dart.fn(() => {
195 subscription.cancel();
196 }), sync: true});
197 }
198 return controller.stream;
199 }
200 asyncExpand(convert) {
201 dart.as(convert, dart.functionType(Stream$(), [T]));
202 let controller = null;
203 let subscription = null;
204 const onListen = (function() {
205 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
206 let eventSink = dart.as(controller, _EventSink$(T));
207 subscription = this.listen(dart.fn(event => {
208 dart.as(event, T);
209 let newStream = null;
210 try {
211 newStream = convert(event);
212 } catch (e) {
213 let s = dart.stackTrace(e);
214 controller.addError(e, s);
215 return;
216 }
217
218 if (newStream != null) {
219 subscription.pause();
220 controller.addStream(newStream).whenComplete(dart.bind(subscriptio n, 'resume'));
221 }
222 }, dart.void, [T]), {onError: dart.bind(eventSink, _addError), onDone: dart.bind(controller, 'close')});
223 }).bind(this);
224 dart.fn(onListen, dart.void, []);
225 if (dart.notNull(this.isBroadcast)) {
226 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
227 subscription.cancel();
228 }, dart.void, []), sync: true});
229 } else {
230 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => {
231 subscription.pause();
232 }, dart.void, []), onResume: dart.fn(() => {
233 subscription.resume();
234 }, dart.void, []), onCancel: dart.fn(() => {
235 subscription.cancel();
236 }), sync: true});
237 }
238 return controller.stream;
239 }
240 handleError(onError, opts) {
241 let test = opts && 'test' in opts ? opts.test : null;
242 dart.as(test, dart.functionType(core.bool, [dart.dynamic]));
243 return new (_HandleErrorStream$(T))(this, onError, test);
244 }
245 expand(convert) {
246 dart.as(convert, dart.functionType(core.Iterable, [T]));
247 return new (_ExpandStream$(T, dart.dynamic))(this, convert);
248 }
249 pipe(streamConsumer) {
250 dart.as(streamConsumer, StreamConsumer$(T));
251 return streamConsumer.addStream(this).then(dart.fn(_ => streamConsumer.c lose(), Future, [dart.dynamic]));
252 }
253 transform(streamTransformer) {
254 dart.as(streamTransformer, StreamTransformer$(T, dart.dynamic));
255 return streamTransformer.bind(this);
256 }
257 reduce(combine) {
258 dart.as(combine, dart.functionType(T, [T, T]));
259 let result = new (_Future$(T))();
260 let seenFirst = false;
261 let value = null;
262 let subscription = null;
263 subscription = this.listen(dart.fn(element => {
264 dart.as(element, T);
265 if (seenFirst) {
266 _runUserCode(dart.fn(() => combine(value, element), T, []), dart.fn( newValue => {
267 dart.as(newValue, T);
268 value = newValue;
269 }, dart.dynamic, [T]), dart.as(_cancelAndErrorClosure(subscription, result), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])));
270 } else {
271 value = element;
272 seenFirst = true;
273 }
274 }, dart.void, [T]), {onError: dart.bind(result, _completeError), onDone: dart.fn(() => {
275 if (!seenFirst) {
276 try {
277 dart.throw(_internal.IterableElementError.noElement());
278 } catch (e) {
279 let s = dart.stackTrace(e);
280 _completeWithErrorCallback(result, e, s);
281 }
282
283 } else {
284 result[_complete](value);
285 }
286 }, dart.void, []), cancelOnError: true});
287 return result;
288 }
289 fold(initialValue, combine) {
290 dart.as(combine, dart.functionType(dart.dynamic, [dart.dynamic, T]));
291 let result = new _Future();
292 let value = initialValue;
293 let subscription = null;
294 subscription = this.listen(dart.fn(element => {
295 dart.as(element, T);
296 _runUserCode(dart.fn(() => combine(value, element), dart.dynamic, []), dart.fn(newValue => {
297 value = dart.as(newValue, dart.dynamic);
298 }), dart.as(_cancelAndErrorClosure(subscription, result), dart.functio nType(dart.dynamic, [dart.dynamic, core.StackTrace])));
299 }, dart.void, [T]), {onError: dart.fn((e, st) => {
300 result[_completeError](e, dart.as(st, core.StackTrace));
301 }), onDone: dart.fn(() => {
302 result[_complete](value);
303 }, dart.void, []), cancelOnError: true});
304 return result;
305 }
306 join(separator) {
307 if (separator === void 0) separator = "";
308 let result = new (_Future$(core.String))();
309 let buffer = new core.StringBuffer();
310 let subscription = null;
311 let first = true;
312 subscription = this.listen(dart.fn(element => {
313 dart.as(element, T);
314 if (!first) {
315 buffer.write(separator);
316 }
317 first = false;
318 try {
319 buffer.write(element);
320 } catch (e) {
321 let s = dart.stackTrace(e);
322 _cancelAndErrorWithReplacement(subscription, result, e, s);
323 }
324
325 }, dart.void, [T]), {onError: dart.fn(e => {
326 result[_completeError](e);
327 }), onDone: dart.fn(() => {
328 result[_complete](buffer.toString());
329 }, dart.void, []), cancelOnError: true});
330 return result;
331 }
332 contains(needle) {
333 let future = new (_Future$(core.bool))();
334 let subscription = null;
335 subscription = this.listen(dart.fn(element => {
336 dart.as(element, T);
337 _runUserCode(dart.fn(() => dart.equals(element, needle), core.bool, [] ), dart.fn(isMatch => {
338 if (dart.notNull(isMatch)) {
339 _cancelAndValue(subscription, future, true);
340 }
341 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
342 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
343 future[_complete](false);
344 }, dart.void, []), cancelOnError: true});
345 return future;
346 }
347 forEach(action) {
348 dart.as(action, dart.functionType(dart.void, [T]));
349 let future = new _Future();
350 let subscription = null;
351 subscription = this.listen(dart.fn(element => {
352 dart.as(element, T);
353 _runUserCode(dart.fn(() => action(element), dart.void, []), dart.fn(_ => {
354 }), dart.as(_cancelAndErrorClosure(subscription, future), dart.functio nType(dart.dynamic, [dart.dynamic, core.StackTrace])));
355 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
356 future[_complete](null);
357 }, dart.void, []), cancelOnError: true});
358 return future;
359 }
360 every(test) {
361 dart.as(test, dart.functionType(core.bool, [T]));
362 let future = new (_Future$(core.bool))();
363 let subscription = null;
364 subscription = this.listen(dart.fn(element => {
365 dart.as(element, T);
366 _runUserCode(dart.fn(() => test(element), core.bool, []), dart.fn(isMa tch => {
367 if (!dart.notNull(isMatch)) {
368 _cancelAndValue(subscription, future, false);
369 }
370 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
371 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
372 future[_complete](true);
373 }, dart.void, []), cancelOnError: true});
374 return future;
375 }
376 any(test) {
377 dart.as(test, dart.functionType(core.bool, [T]));
378 let future = new (_Future$(core.bool))();
379 let subscription = null;
380 subscription = this.listen(dart.fn(element => {
381 dart.as(element, T);
382 _runUserCode(dart.fn(() => test(element), core.bool, []), dart.fn(isMa tch => {
383 if (dart.notNull(isMatch)) {
384 _cancelAndValue(subscription, future, true);
385 }
386 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
387 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
388 future[_complete](false);
389 }, dart.void, []), cancelOnError: true});
390 return future;
391 }
392 get length() {
393 let future = new (_Future$(core.int))();
394 let count = 0;
395 this.listen(dart.fn(_ => {
396 dart.as(_, T);
397 count++;
398 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
399 future[_complete](count);
400 }, dart.void, []), cancelOnError: true});
401 return future;
402 }
403 get isEmpty() {
404 let future = new (_Future$(core.bool))();
405 let subscription = null;
406 subscription = this.listen(dart.fn(_ => {
407 dart.as(_, T);
408 _cancelAndValue(subscription, future, false);
409 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
410 future[_complete](true);
411 }, dart.void, []), cancelOnError: true});
412 return future;
413 }
414 toList() {
415 let result = dart.list([], T);
416 let future = new (_Future$(core.List$(T)))();
417 this.listen(dart.fn(data => {
418 dart.as(data, T);
419 result[dartx.add](data);
420 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
421 future[_complete](result);
422 }, dart.void, []), cancelOnError: true});
423 return future;
424 }
425 toSet() {
426 let result = core.Set$(T).new();
427 let future = new (_Future$(core.Set$(T)))();
428 this.listen(dart.fn(data => {
429 dart.as(data, T);
430 result.add(data);
431 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
432 future[_complete](result);
433 }, dart.void, []), cancelOnError: true});
434 return future;
435 }
436 drain(futureValue) {
437 if (futureValue === void 0) futureValue = null;
438 return this.listen(null, {cancelOnError: true}).asFuture(futureValue);
439 }
440 take(count) {
441 return new (_TakeStream$(T))(this, count);
442 }
443 takeWhile(test) {
444 dart.as(test, dart.functionType(core.bool, [T]));
445 return new (_TakeWhileStream$(T))(this, test);
446 }
447 skip(count) {
448 return new (_SkipStream$(T))(this, count);
449 }
450 skipWhile(test) {
451 dart.as(test, dart.functionType(core.bool, [T]));
452 return new (_SkipWhileStream$(T))(this, test);
453 }
454 distinct(equals) {
455 if (equals === void 0) equals = null;
456 dart.as(equals, dart.functionType(core.bool, [T, T]));
457 return new (_DistinctStream$(T))(this, equals);
458 }
459 get first() {
460 let future = new (_Future$(T))();
461 let subscription = null;
462 subscription = this.listen(dart.fn(value => {
463 dart.as(value, T);
464 _cancelAndValue(subscription, future, value);
465 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
466 try {
467 dart.throw(_internal.IterableElementError.noElement());
468 } catch (e) {
469 let s = dart.stackTrace(e);
470 _completeWithErrorCallback(future, e, s);
471 }
472
473 }, dart.void, []), cancelOnError: true});
474 return future;
475 }
476 get last() {
477 let future = new (_Future$(T))();
478 let result = null;
479 let foundResult = false;
480 let subscription = null;
481 subscription = this.listen(dart.fn(value => {
482 dart.as(value, T);
483 foundResult = true;
484 result = value;
485 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
486 if (foundResult) {
487 future[_complete](result);
488 return;
489 }
490 try {
491 dart.throw(_internal.IterableElementError.noElement());
492 } catch (e) {
493 let s = dart.stackTrace(e);
494 _completeWithErrorCallback(future, e, s);
495 }
496
497 }, dart.void, []), cancelOnError: true});
498 return future;
499 }
500 get single() {
501 let future = new (_Future$(T))();
502 let result = null;
503 let foundResult = false;
504 let subscription = null;
505 subscription = this.listen(dart.fn(value => {
506 dart.as(value, T);
507 if (foundResult) {
508 try {
509 dart.throw(_internal.IterableElementError.tooMany());
510 } catch (e) {
511 let s = dart.stackTrace(e);
512 _cancelAndErrorWithReplacement(subscription, future, e, s);
513 }
514
515 return;
516 }
517 foundResult = true;
518 result = value;
519 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
520 if (foundResult) {
521 future[_complete](result);
522 return;
523 }
524 try {
525 dart.throw(_internal.IterableElementError.noElement());
526 } catch (e) {
527 let s = dart.stackTrace(e);
528 _completeWithErrorCallback(future, e, s);
529 }
530
531 }, dart.void, []), cancelOnError: true});
532 return future;
533 }
534 firstWhere(test, opts) {
535 dart.as(test, dart.functionType(core.bool, [T]));
536 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null;
537 dart.as(defaultValue, dart.functionType(core.Object, []));
538 let future = new _Future();
539 let subscription = null;
540 subscription = this.listen(dart.fn(value => {
541 dart.as(value, T);
542 _runUserCode(dart.fn(() => test(value), core.bool, []), dart.fn(isMatc h => {
543 if (dart.notNull(isMatch)) {
544 _cancelAndValue(subscription, future, value);
545 }
546 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
547 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
548 if (defaultValue != null) {
549 _runUserCode(defaultValue, dart.bind(future, _complete), dart.bind (future, _completeError));
550 return;
551 }
552 try {
553 dart.throw(_internal.IterableElementError.noElement());
554 } catch (e) {
555 let s = dart.stackTrace(e);
556 _completeWithErrorCallback(future, e, s);
557 }
558
559 }, dart.void, []), cancelOnError: true});
560 return future;
561 }
562 lastWhere(test, opts) {
563 dart.as(test, dart.functionType(core.bool, [T]));
564 let defaultValue = opts && 'defaultValue' in opts ? opts.defaultValue : null;
565 dart.as(defaultValue, dart.functionType(core.Object, []));
566 let future = new _Future();
567 let result = null;
568 let foundResult = false;
569 let subscription = null;
570 subscription = this.listen(dart.fn(value => {
571 dart.as(value, T);
572 _runUserCode(dart.fn(() => true == test(value), core.bool, []), dart.f n(isMatch => {
573 if (dart.notNull(isMatch)) {
574 foundResult = true;
575 result = value;
576 }
577 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
578 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
579 if (foundResult) {
580 future[_complete](result);
581 return;
582 }
583 if (defaultValue != null) {
584 _runUserCode(defaultValue, dart.bind(future, _complete), dart.bind (future, _completeError));
585 return;
586 }
587 try {
588 dart.throw(_internal.IterableElementError.noElement());
589 } catch (e) {
590 let s = dart.stackTrace(e);
591 _completeWithErrorCallback(future, e, s);
592 }
593
594 }, dart.void, []), cancelOnError: true});
595 return future;
596 }
597 singleWhere(test) {
598 dart.as(test, dart.functionType(core.bool, [T]));
599 let future = new (_Future$(T))();
600 let result = null;
601 let foundResult = false;
602 let subscription = null;
603 subscription = this.listen(dart.fn(value => {
604 dart.as(value, T);
605 _runUserCode(dart.fn(() => true == test(value), core.bool, []), dart.f n(isMatch => {
606 if (dart.notNull(isMatch)) {
607 if (foundResult) {
608 try {
609 dart.throw(_internal.IterableElementError.tooMany());
610 } catch (e) {
611 let s = dart.stackTrace(e);
612 _cancelAndErrorWithReplacement(subscription, future, e, s);
613 }
614
615 return;
616 }
617 foundResult = true;
618 result = value;
619 }
620 }, dart.dynamic, [core.bool]), dart.as(_cancelAndErrorClosure(subscrip tion, future), dart.functionType(dart.dynamic, [dart.dynamic, core.StackTrace])) );
621 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
622 if (foundResult) {
623 future[_complete](result);
624 return;
625 }
626 try {
627 dart.throw(_internal.IterableElementError.noElement());
628 } catch (e) {
629 let s = dart.stackTrace(e);
630 _completeWithErrorCallback(future, e, s);
631 }
632
633 }, dart.void, []), cancelOnError: true});
634 return future;
635 }
636 elementAt(index) {
637 if (!(typeof index == 'number') || dart.notNull(index) < 0) dart.throw(n ew core.ArgumentError(index));
638 let future = new (_Future$(T))();
639 let subscription = null;
640 let elementIndex = 0;
641 subscription = this.listen(dart.fn(value => {
642 dart.as(value, T);
643 if (index == elementIndex) {
644 _cancelAndValue(subscription, future, value);
645 return;
646 }
647 elementIndex = elementIndex + 1;
648 }, dart.void, [T]), {onError: dart.bind(future, _completeError), onDone: dart.fn(() => {
649 future[_completeError](core.RangeError.index(index, this, "index", n ull, elementIndex));
650 }, dart.void, []), cancelOnError: true});
651 return future;
652 }
653 timeout(timeLimit, opts) {
654 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
655 dart.as(onTimeout, dart.functionType(dart.void, [EventSink]));
656 let controller = null;
657 let subscription = null;
658 let timer = null;
659 let zone = null;
660 let timeout2 = null;
661 function onData(event) {
662 dart.as(event, T);
663 timer.cancel();
664 controller.add(event);
665 timer = zone.createTimer(timeLimit, dart.as(timeout2, dart.functionTyp e(dart.void, [])));
666 }
667 dart.fn(onData, dart.void, [T]);
668 function onError(error, stackTrace) {
669 timer.cancel();
670 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
671 let eventSink = dart.as(controller, _EventSink$(T));
672 eventSink[_addError](error, stackTrace);
673 timer = zone.createTimer(timeLimit, dart.as(timeout2, dart.functionTyp e(dart.void, [])));
674 }
675 dart.fn(onError, dart.void, [dart.dynamic, core.StackTrace]);
676 function onDone() {
677 timer.cancel();
678 controller.close();
679 }
680 dart.fn(onDone, dart.void, []);
681 const onListen = (function() {
682 zone = Zone.current;
683 if (onTimeout == null) {
684 timeout2 = dart.fn(() => {
685 controller.addError(new TimeoutException("No stream event", timeLi mit), null);
686 });
687 } else {
688 onTimeout = dart.as(zone.registerUnaryCallback(onTimeout), dart.func tionType(dart.void, [EventSink]));
689 let wrapper = new _ControllerEventSinkWrapper(null);
690 timeout2 = dart.fn(() => {
691 wrapper[_sink] = controller;
692 zone.runUnaryGuarded(onTimeout, wrapper);
693 wrapper[_sink] = null;
694 });
695 }
696 subscription = this.listen(onData, {onError: onError, onDone: onDone}) ;
697 timer = zone.createTimer(timeLimit, dart.as(timeout2, dart.functionTyp e(dart.void, [])));
698 }).bind(this);
699 dart.fn(onListen, dart.void, []);
700 function onCancel() {
701 timer.cancel();
702 let result = subscription.cancel();
703 subscription = null;
704 return result;
705 }
706 dart.fn(onCancel, Future, []);
707 controller = dart.notNull(this.isBroadcast) ? new _SyncBroadcastStreamCo ntroller(onListen, onCancel) : new _SyncStreamController(onListen, dart.fn(() => {
708 timer.cancel();
709 subscription.pause();
710 }, dart.void, []), dart.fn(() => {
711 subscription.resume();
712 timer = zone.createTimer(timeLimit, dart.as(timeout2, dart.functionTyp e(dart.void, [])));
713 }, dart.void, []), onCancel);
714 return controller.stream;
715 }
716 }
717 dart.setSignature(Stream, {
718 constructors: () => ({
719 Stream: [Stream$(T), []],
720 fromFuture: [Stream$(T), [Future$(T)]],
721 fromIterable: [Stream$(T), [core.Iterable$(T)]],
722 periodic: [Stream$(T), [core.Duration], [dart.functionType(T, [core.int] )]],
723 eventTransformed: [Stream$(T), [Stream$(), dart.functionType(EventSink, [EventSink$(T)])]]
724 }),
725 methods: () => ({
726 asBroadcastStream: [Stream$(T), [], {onListen: dart.functionType(dart.vo id, [StreamSubscription$(T)]), onCancel: dart.functionType(dart.void, [StreamSub scription$(T)])}],
727 where: [Stream$(T), [dart.functionType(core.bool, [T])]],
728 map: [Stream$(), [dart.functionType(dart.dynamic, [T])]],
729 asyncMap: [Stream$(), [dart.functionType(dart.dynamic, [T])]],
730 asyncExpand: [Stream$(), [dart.functionType(Stream$(), [T])]],
731 handleError: [Stream$(T), [core.Function], {test: dart.functionType(core .bool, [dart.dynamic])}],
732 expand: [Stream$(), [dart.functionType(core.Iterable, [T])]],
733 pipe: [Future, [StreamConsumer$(T)]],
734 transform: [Stream$(), [StreamTransformer$(T, dart.dynamic)]],
735 reduce: [Future$(T), [dart.functionType(T, [T, T])]],
736 fold: [Future, [dart.dynamic, dart.functionType(dart.dynamic, [dart.dyna mic, T])]],
737 join: [Future$(core.String), [], [core.String]],
738 contains: [Future$(core.bool), [core.Object]],
739 forEach: [Future, [dart.functionType(dart.void, [T])]],
740 every: [Future$(core.bool), [dart.functionType(core.bool, [T])]],
741 any: [Future$(core.bool), [dart.functionType(core.bool, [T])]],
742 toList: [Future$(core.List$(T)), []],
743 toSet: [Future$(core.Set$(T)), []],
744 drain: [Future, [], [dart.dynamic]],
745 take: [Stream$(T), [core.int]],
746 takeWhile: [Stream$(T), [dart.functionType(core.bool, [T])]],
747 skip: [Stream$(T), [core.int]],
748 skipWhile: [Stream$(T), [dart.functionType(core.bool, [T])]],
749 distinct: [Stream$(T), [], [dart.functionType(core.bool, [T, T])]],
750 firstWhere: [Future, [dart.functionType(core.bool, [T])], {defaultValue: dart.functionType(core.Object, [])}],
751 lastWhere: [Future, [dart.functionType(core.bool, [T])], {defaultValue: dart.functionType(core.Object, [])}],
752 singleWhere: [Future$(T), [dart.functionType(core.bool, [T])]],
753 elementAt: [Future$(T), [core.int]],
754 timeout: [Stream$(), [core.Duration], {onTimeout: dart.functionType(dart .void, [EventSink])}]
755 })
756 });
757 return Stream;
758 });
759 let Stream = Stream$();
760 const _StreamImpl$ = dart.generic(function(T) {
761 class _StreamImpl extends Stream$(T) {
762 _StreamImpl() {
763 super.Stream();
764 }
765 listen(onData, opts) {
766 dart.as(onData, dart.functionType(dart.void, [T]));
767 let onError = opts && 'onError' in opts ? opts.onError : null;
768 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
769 dart.as(onDone, dart.functionType(dart.void, []));
770 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
771 cancelOnError = core.identical(true, cancelOnError);
772 let subscription = this[_createSubscription](onData, onError, onDone, ca ncelOnError);
773 this[_onListen](subscription);
774 return dart.as(subscription, StreamSubscription$(T));
775 }
776 [_createSubscription](onData, onError, onDone, cancelOnError) {
777 dart.as(onData, dart.functionType(dart.void, [T]));
778 dart.as(onDone, dart.functionType(dart.void, []));
779 return new (_BufferingStreamSubscription$(T))(onData, onError, onDone, c ancelOnError);
780 }
781 [_onListen](subscription) {}
782 }
783 dart.setSignature(_StreamImpl, {
784 methods: () => ({
785 listen: [StreamSubscription$(T), [dart.functionType(dart.void, [T])], {o nError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}],
786 [_createSubscription]: [StreamSubscription$(T), [dart.functionType(dart. void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]],
787 [_onListen]: [dart.void, [StreamSubscription]]
788 })
789 });
790 return _StreamImpl;
791 });
792 let _StreamImpl = _StreamImpl$();
793 const _ControllerStream$ = dart.generic(function(T) {
794 class _ControllerStream extends _StreamImpl$(T) {
795 _ControllerStream(controller) {
796 this[_controller] = controller;
797 }
798 [_createSubscription](onData, onError, onDone, cancelOnError) {
799 dart.as(onData, dart.functionType(dart.void, [T]));
800 dart.as(onDone, dart.functionType(dart.void, []));
801 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror);
802 }
803 get hashCode() {
804 return dart.notNull(dart.hashCode(this[_controller])) ^ 892482866;
805 }
806 ['=='](other) {
807 if (core.identical(this, other)) return true;
808 if (!dart.is(other, _ControllerStream$())) return false;
809 let otherStream = dart.as(other, _ControllerStream$());
810 return core.identical(otherStream[_controller], this[_controller]);
811 }
812 }
813 dart.setSignature(_ControllerStream, {
814 constructors: () => ({_ControllerStream: [_ControllerStream$(T), [_StreamC ontrollerLifecycle$(T)]]}),
815 methods: () => ({
816 [_createSubscription]: [StreamSubscription$(T), [dart.functionType(dart. void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]],
817 '==': [core.bool, [core.Object]]
818 })
819 });
820 return _ControllerStream;
821 });
822 let _ControllerStream = _ControllerStream$();
823 const _BroadcastStream$ = dart.generic(function(T) {
824 class _BroadcastStream extends _ControllerStream$(T) {
825 _BroadcastStream(controller) {
826 super._ControllerStream(dart.as(controller, _StreamControllerLifecycle$( T)));
827 }
828 get isBroadcast() {
829 return true;
830 }
831 }
832 dart.setSignature(_BroadcastStream, {
833 constructors: () => ({_BroadcastStream: [_BroadcastStream$(T), [_StreamCon trollerLifecycle]]})
834 });
835 return _BroadcastStream;
836 });
837 let _BroadcastStream = _BroadcastStream$();
838 const _next = Symbol('_next');
839 const _previous = Symbol('_previous');
840 class _BroadcastSubscriptionLink extends core.Object {
841 _BroadcastSubscriptionLink() {
842 this[_next] = null;
843 this[_previous] = null;
844 }
845 }
846 const _eventState = Symbol('_eventState');
847 const _expectsEvent = Symbol('_expectsEvent');
848 const _toggleEventId = Symbol('_toggleEventId');
849 const _isFiring = Symbol('_isFiring');
850 const _setRemoveAfterFiring = Symbol('_setRemoveAfterFiring');
851 const _removeAfterFiring = Symbol('_removeAfterFiring');
852 const _onPause = Symbol('_onPause');
853 const _onResume = Symbol('_onResume');
854 const _recordCancel = Symbol('_recordCancel');
855 const _onCancel = Symbol('_onCancel');
856 const _recordPause = Symbol('_recordPause');
857 const _recordResume = Symbol('_recordResume');
858 const _zone = Symbol('_zone');
859 const _state = Symbol('_state');
860 const _onData = Symbol('_onData');
861 const _onError = Symbol('_onError');
862 const _onDone = Symbol('_onDone');
863 const _cancelFuture = Symbol('_cancelFuture');
864 const _pending = Symbol('_pending');
865 const _setPendingEvents = Symbol('_setPendingEvents');
866 const _isCanceled = Symbol('_isCanceled');
867 const _extractPending = Symbol('_extractPending');
868 const _isPaused = Symbol('_isPaused');
869 const _isInputPaused = Symbol('_isInputPaused');
870 const _inCallback = Symbol('_inCallback');
871 const _guardCallback = Symbol('_guardCallback');
872 const _decrementPauseCount = Symbol('_decrementPauseCount');
873 const _hasPending = Symbol('_hasPending');
874 const _mayResumeInput = Symbol('_mayResumeInput');
875 const _cancel = Symbol('_cancel');
876 const _isClosed = Symbol('_isClosed');
877 const _waitsForCancel = Symbol('_waitsForCancel');
878 const _canFire = Symbol('_canFire');
879 const _cancelOnError = Symbol('_cancelOnError');
880 const _incrementPauseCount = Symbol('_incrementPauseCount');
881 const _sendData = Symbol('_sendData');
882 const _addPending = Symbol('_addPending');
883 const _sendError = Symbol('_sendError');
884 const _sendDone = Symbol('_sendDone');
885 const _close = Symbol('_close');
886 const _checkState = Symbol('_checkState');
887 const _BufferingStreamSubscription$ = dart.generic(function(T) {
888 class _BufferingStreamSubscription extends core.Object {
889 _BufferingStreamSubscription(onData, onError, onDone, cancelOnError) {
890 this[_zone] = Zone.current;
891 this[_state] = dart.notNull(cancelOnError) ? _BufferingStreamSubscriptio n$()._STATE_CANCEL_ON_ERROR : 0;
892 this[_onData] = null;
893 this[_onError] = null;
894 this[_onDone] = null;
895 this[_cancelFuture] = null;
896 this[_pending] = null;
897 this.onData(onData);
898 this.onError(onError);
899 this.onDone(onDone);
900 }
901 [_setPendingEvents](pendingEvents) {
902 dart.assert(this[_pending] == null);
903 if (pendingEvents == null) return;
904 this[_pending] = pendingEvents;
905 if (!dart.notNull(pendingEvents.isEmpty)) {
906 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_HAS_PENDING);
907 this[_pending].schedule(this);
908 }
909 }
910 [_extractPending]() {
911 dart.assert(this[_isCanceled]);
912 let events = this[_pending];
913 this[_pending] = null;
914 return events;
915 }
916 onData(handleData) {
917 dart.as(handleData, dart.functionType(dart.void, [T]));
918 if (handleData == null) handleData = _nullDataHandler;
919 this[_onData] = dart.as(this[_zone].registerUnaryCallback(handleData), _ DataHandler$(T));
920 }
921 onError(handleError) {
922 if (handleError == null) handleError = _nullErrorHandler;
923 this[_onError] = _registerErrorHandler(handleError, this[_zone]);
924 }
925 onDone(handleDone) {
926 dart.as(handleDone, dart.functionType(dart.void, []));
927 if (handleDone == null) handleDone = _nullDoneHandler;
928 this[_onDone] = this[_zone].registerCallback(handleDone);
929 }
930 pause(resumeSignal) {
931 if (resumeSignal === void 0) resumeSignal = null;
932 if (dart.notNull(this[_isCanceled])) return;
933 let wasPaused = this[_isPaused];
934 let wasInputPaused = this[_isInputPaused];
935 this[_state] = dart.notNull(this[_state]) + dart.notNull(_BufferingStrea mSubscription$()._STATE_PAUSE_COUNT) | dart.notNull(_BufferingStreamSubscription $()._STATE_INPUT_PAUSED);
936 if (resumeSignal != null) resumeSignal.whenComplete(dart.bind(this, 'res ume'));
937 if (!dart.notNull(wasPaused) && this[_pending] != null) this[_pending].c ancelSchedule();
938 if (!dart.notNull(wasInputPaused) && !dart.notNull(this[_inCallback])) t his[_guardCallback](dart.bind(this, _onPause));
939 }
940 resume() {
941 if (dart.notNull(this[_isCanceled])) return;
942 if (dart.notNull(this[_isPaused])) {
943 this[_decrementPauseCount]();
944 if (!dart.notNull(this[_isPaused])) {
945 if (dart.notNull(this[_hasPending]) && !dart.notNull(this[_pending]. isEmpty)) {
946 this[_pending].schedule(this);
947 } else {
948 dart.assert(this[_mayResumeInput]);
949 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_Bufferi ngStreamSubscription$()._STATE_INPUT_PAUSED);
950 if (!dart.notNull(this[_inCallback])) this[_guardCallback](dart.bi nd(this, _onResume));
951 }
952 }
953 }
954 }
955 cancel() {
956 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription$()._STATE_WAIT_FOR_CANCEL);
957 if (dart.notNull(this[_isCanceled])) return this[_cancelFuture];
958 this[_cancel]();
959 return this[_cancelFuture];
960 }
961 asFuture(futureValue) {
962 if (futureValue === void 0) futureValue = null;
963 let result = new (_Future$(T))();
964 this[_onDone] = dart.fn(() => {
965 result[_complete](futureValue);
966 }, dart.void, []);
967 this[_onError] = dart.fn((error, stackTrace) => {
968 this.cancel();
969 result[_completeError](error, dart.as(stackTrace, core.StackTrace));
970 });
971 return result;
972 }
973 get [_isInputPaused]() {
974 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_INPUT_PAUSED)) != 0;
975 }
976 get [_isClosed]() {
977 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CLOSED)) != 0;
978 }
979 get [_isCanceled]() {
980 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CANCELED)) != 0;
981 }
982 get [_waitsForCancel]() {
983 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_WAIT_FOR_CANCEL)) != 0;
984 }
985 get [_inCallback]() {
986 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_IN_CALLBACK)) != 0;
987 }
988 get [_hasPending]() {
989 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_HAS_PENDING)) != 0;
990 }
991 get [_isPaused]() {
992 return dart.notNull(this[_state]) >= dart.notNull(_BufferingStreamSubscr iption$()._STATE_PAUSE_COUNT);
993 }
994 get [_canFire]() {
995 return dart.notNull(this[_state]) < dart.notNull(_BufferingStreamSubscri ption$()._STATE_IN_CALLBACK);
996 }
997 get [_mayResumeInput]() {
998 return !dart.notNull(this[_isPaused]) && (this[_pending] == null || dart .notNull(this[_pending].isEmpty));
999 }
1000 get [_cancelOnError]() {
1001 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CANCEL_ON_ERROR)) != 0;
1002 }
1003 get isPaused() {
1004 return this[_isPaused];
1005 }
1006 [_cancel]() {
1007 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_CANCELED);
1008 if (dart.notNull(this[_hasPending])) {
1009 this[_pending].cancelSchedule();
1010 }
1011 if (!dart.notNull(this[_inCallback])) this[_pending] = null;
1012 this[_cancelFuture] = this[_onCancel]();
1013 }
1014 [_incrementPauseCount]() {
1015 this[_state] = dart.notNull(this[_state]) + dart.notNull(_BufferingStrea mSubscription$()._STATE_PAUSE_COUNT) | dart.notNull(_BufferingStreamSubscription $()._STATE_INPUT_PAUSED);
1016 }
1017 [_decrementPauseCount]() {
1018 dart.assert(this[_isPaused]);
1019 this[_state] = dart.notNull(this[_state]) - dart.notNull(_BufferingStrea mSubscription$()._STATE_PAUSE_COUNT);
1020 }
1021 [_add](data) {
1022 dart.as(data, T);
1023 dart.assert(!dart.notNull(this[_isClosed]));
1024 if (dart.notNull(this[_isCanceled])) return;
1025 if (dart.notNull(this[_canFire])) {
1026 this[_sendData](data);
1027 } else {
1028 this[_addPending](new _DelayedData(data));
1029 }
1030 }
1031 [_addError](error, stackTrace) {
1032 if (dart.notNull(this[_isCanceled])) return;
1033 if (dart.notNull(this[_canFire])) {
1034 this[_sendError](error, stackTrace);
1035 } else {
1036 this[_addPending](new _DelayedError(error, stackTrace));
1037 }
1038 }
1039 [_close]() {
1040 dart.assert(!dart.notNull(this[_isClosed]));
1041 if (dart.notNull(this[_isCanceled])) return;
1042 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_CLOSED);
1043 if (dart.notNull(this[_canFire])) {
1044 this[_sendDone]();
1045 } else {
1046 this[_addPending](dart.const(new _DelayedDone()));
1047 }
1048 }
1049 [_onPause]() {
1050 dart.assert(this[_isInputPaused]);
1051 }
1052 [_onResume]() {
1053 dart.assert(!dart.notNull(this[_isInputPaused]));
1054 }
1055 [_onCancel]() {
1056 dart.assert(this[_isCanceled]);
1057 return null;
1058 }
1059 [_addPending](event) {
1060 let pending = dart.as(this[_pending], _StreamImplEvents);
1061 if (this[_pending] == null) pending = this[_pending] = new _StreamImplEv ents();
1062 pending.add(event);
1063 if (!dart.notNull(this[_hasPending])) {
1064 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_HAS_PENDING);
1065 if (!dart.notNull(this[_isPaused])) {
1066 this[_pending].schedule(this);
1067 }
1068 }
1069 }
1070 [_sendData](data) {
1071 dart.as(data, T);
1072 dart.assert(!dart.notNull(this[_isCanceled]));
1073 dart.assert(!dart.notNull(this[_isPaused]));
1074 dart.assert(!dart.notNull(this[_inCallback]));
1075 let wasInputPaused = this[_isInputPaused];
1076 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_IN_CALLBACK);
1077 this[_zone].runUnaryGuarded(this[_onData], data);
1078 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription$()._STATE_IN_CALLBACK);
1079 this[_checkState](wasInputPaused);
1080 }
1081 [_sendError](error, stackTrace) {
1082 dart.assert(!dart.notNull(this[_isCanceled]));
1083 dart.assert(!dart.notNull(this[_isPaused]));
1084 dart.assert(!dart.notNull(this[_inCallback]));
1085 let wasInputPaused = this[_isInputPaused];
1086 const sendError = (function() {
1087 if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCan cel])) return;
1088 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_IN_CALLBACK);
1089 if (dart.is(this[_onError], ZoneBinaryCallback)) {
1090 this[_zone].runBinaryGuarded(dart.as(this[_onError], dart.functionTy pe(dart.dynamic, [dart.dynamic, dart.dynamic])), error, stackTrace);
1091 } else {
1092 this[_zone].runUnaryGuarded(dart.as(this[_onError], dart.functionTyp e(dart.dynamic, [dart.dynamic])), error);
1093 }
1094 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK);
1095 }).bind(this);
1096 dart.fn(sendError, dart.void, []);
1097 if (dart.notNull(this[_cancelOnError])) {
1098 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_WAIT_FOR_CANCEL);
1099 this[_cancel]();
1100 if (dart.is(this[_cancelFuture], Future)) {
1101 this[_cancelFuture].whenComplete(sendError);
1102 } else {
1103 sendError();
1104 }
1105 } else {
1106 sendError();
1107 this[_checkState](wasInputPaused);
1108 }
1109 }
1110 [_sendDone]() {
1111 dart.assert(!dart.notNull(this[_isCanceled]));
1112 dart.assert(!dart.notNull(this[_isPaused]));
1113 dart.assert(!dart.notNull(this[_inCallback]));
1114 const sendDone = (function() {
1115 if (!dart.notNull(this[_waitsForCancel])) return;
1116 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription$ ()._STATE_CLOSED) | dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLB ACK);
1117 this[_zone].runGuarded(this[_onDone]);
1118 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK);
1119 }).bind(this);
1120 dart.fn(sendDone, dart.void, []);
1121 this[_cancel]();
1122 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_WAIT_FOR_CANCEL);
1123 if (dart.is(this[_cancelFuture], Future)) {
1124 this[_cancelFuture].whenComplete(sendDone);
1125 } else {
1126 sendDone();
1127 }
1128 }
1129 [_guardCallback](callback) {
1130 dart.assert(!dart.notNull(this[_inCallback]));
1131 let wasInputPaused = this[_isInputPaused];
1132 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_IN_CALLBACK);
1133 dart.dcall(callback);
1134 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription$()._STATE_IN_CALLBACK);
1135 this[_checkState](wasInputPaused);
1136 }
1137 [_checkState](wasInputPaused) {
1138 dart.assert(!dart.notNull(this[_inCallback]));
1139 if (dart.notNull(this[_hasPending]) && dart.notNull(this[_pending].isEmp ty)) {
1140 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_HAS_PENDING);
1141 if (dart.notNull(this[_isInputPaused]) && dart.notNull(this[_mayResume Input])) {
1142 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_Buffering StreamSubscription$()._STATE_INPUT_PAUSED);
1143 }
1144 }
1145 while (true) {
1146 if (dart.notNull(this[_isCanceled])) {
1147 this[_pending] = null;
1148 return;
1149 }
1150 let isInputPaused = this[_isInputPaused];
1151 if (wasInputPaused == isInputPaused) break;
1152 this[_state] = dart.notNull(this[_state]) ^ dart.notNull(_BufferingStr eamSubscription$()._STATE_IN_CALLBACK);
1153 if (dart.notNull(isInputPaused)) {
1154 this[_onPause]();
1155 } else {
1156 this[_onResume]();
1157 }
1158 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK);
1159 wasInputPaused = isInputPaused;
1160 }
1161 if (dart.notNull(this[_hasPending]) && !dart.notNull(this[_isPaused])) {
1162 this[_pending].schedule(this);
1163 }
1164 }
1165 }
1166 _BufferingStreamSubscription[dart.implements] = () => [StreamSubscription$(T ), _EventSink$(T), _EventDispatch$(T)];
1167 dart.setSignature(_BufferingStreamSubscription, {
1168 constructors: () => ({_BufferingStreamSubscription: [_BufferingStreamSubsc ription$(T), [dart.functionType(dart.void, [T]), core.Function, dart.functionTyp e(dart.void, []), core.bool]]}),
1169 methods: () => ({
1170 [_setPendingEvents]: [dart.void, [_PendingEvents]],
1171 [_extractPending]: [_PendingEvents, []],
1172 onData: [dart.void, [dart.functionType(dart.void, [T])]],
1173 onError: [dart.void, [core.Function]],
1174 onDone: [dart.void, [dart.functionType(dart.void, [])]],
1175 pause: [dart.void, [], [Future]],
1176 resume: [dart.void, []],
1177 cancel: [Future, []],
1178 asFuture: [Future, [], [dart.dynamic]],
1179 [_cancel]: [dart.void, []],
1180 [_incrementPauseCount]: [dart.void, []],
1181 [_decrementPauseCount]: [dart.void, []],
1182 [_add]: [dart.void, [T]],
1183 [_addError]: [dart.void, [core.Object, core.StackTrace]],
1184 [_close]: [dart.void, []],
1185 [_onPause]: [dart.void, []],
1186 [_onResume]: [dart.void, []],
1187 [_onCancel]: [Future, []],
1188 [_addPending]: [dart.void, [_DelayedEvent]],
1189 [_sendData]: [dart.void, [T]],
1190 [_sendError]: [dart.void, [core.Object, core.StackTrace]],
1191 [_sendDone]: [dart.void, []],
1192 [_guardCallback]: [dart.void, [dart.dynamic]],
1193 [_checkState]: [dart.void, [core.bool]]
1194 })
1195 });
1196 _BufferingStreamSubscription._STATE_CANCEL_ON_ERROR = 1;
1197 _BufferingStreamSubscription._STATE_CLOSED = 2;
1198 _BufferingStreamSubscription._STATE_INPUT_PAUSED = 4;
1199 _BufferingStreamSubscription._STATE_CANCELED = 8;
1200 _BufferingStreamSubscription._STATE_WAIT_FOR_CANCEL = 16;
1201 _BufferingStreamSubscription._STATE_IN_CALLBACK = 32;
1202 _BufferingStreamSubscription._STATE_HAS_PENDING = 64;
1203 _BufferingStreamSubscription._STATE_PAUSE_COUNT = 128;
1204 _BufferingStreamSubscription._STATE_PAUSE_COUNT_SHIFT = 7;
1205 return _BufferingStreamSubscription;
1206 });
1207 let _BufferingStreamSubscription = _BufferingStreamSubscription$();
1208 const _ControllerSubscription$ = dart.generic(function(T) {
1209 class _ControllerSubscription extends _BufferingStreamSubscription$(T) {
1210 _ControllerSubscription(controller, onData, onError, onDone, cancelOnError ) {
1211 this[_controller] = controller;
1212 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r);
1213 }
1214 [_onCancel]() {
1215 return this[_controller][_recordCancel](this);
1216 }
1217 [_onPause]() {
1218 this[_controller][_recordPause](this);
1219 }
1220 [_onResume]() {
1221 this[_controller][_recordResume](this);
1222 }
1223 }
1224 dart.setSignature(_ControllerSubscription, {
1225 constructors: () => ({_ControllerSubscription: [_ControllerSubscription$(T ), [_StreamControllerLifecycle$(T), dart.functionType(dart.void, [T]), core.Func tion, dart.functionType(dart.void, []), core.bool]]})
1226 });
1227 return _ControllerSubscription;
1228 });
1229 let _ControllerSubscription = _ControllerSubscription$();
1230 const _BroadcastSubscription$ = dart.generic(function(T) {
1231 class _BroadcastSubscription extends _ControllerSubscription$(T) {
1232 _BroadcastSubscription(controller, onData, onError, onDone, cancelOnError) {
1233 this[_eventState] = null;
1234 this[_next] = null;
1235 this[_previous] = null;
1236 super._ControllerSubscription(dart.as(controller, _StreamControllerLifec ycle$(T)), onData, onError, onDone, cancelOnError);
1237 this[_next] = this[_previous] = this;
1238 }
1239 [_expectsEvent](eventId) {
1240 return (dart.notNull(this[_eventState]) & dart.notNull(_BroadcastSubscri ption$()._STATE_EVENT_ID)) == eventId;
1241 }
1242 [_toggleEventId]() {
1243 this[_eventState] = dart.notNull(this[_eventState]) ^ dart.notNull(_Broa dcastSubscription$()._STATE_EVENT_ID);
1244 }
1245 get [_isFiring]() {
1246 return (dart.notNull(this[_eventState]) & dart.notNull(_BroadcastSubscri ption$()._STATE_FIRING)) != 0;
1247 }
1248 [_setRemoveAfterFiring]() {
1249 dart.assert(this[_isFiring]);
1250 this[_eventState] = dart.notNull(this[_eventState]) | dart.notNull(_Broa dcastSubscription$()._STATE_REMOVE_AFTER_FIRING);
1251 }
1252 get [_removeAfterFiring]() {
1253 return (dart.notNull(this[_eventState]) & dart.notNull(_BroadcastSubscri ption$()._STATE_REMOVE_AFTER_FIRING)) != 0;
1254 }
1255 [_onPause]() {}
1256 [_onResume]() {}
1257 }
1258 _BroadcastSubscription[dart.implements] = () => [_BroadcastSubscriptionLink] ;
1259 dart.setSignature(_BroadcastSubscription, {
1260 constructors: () => ({_BroadcastSubscription: [_BroadcastSubscription$(T), [_StreamControllerLifecycle, dart.functionType(dart.void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]]}),
1261 methods: () => ({
1262 [_expectsEvent]: [core.bool, [core.int]],
1263 [_toggleEventId]: [dart.void, []],
1264 [_setRemoveAfterFiring]: [dart.void, []]
1265 })
1266 });
1267 _BroadcastSubscription._STATE_EVENT_ID = 1;
1268 _BroadcastSubscription._STATE_FIRING = 2;
1269 _BroadcastSubscription._STATE_REMOVE_AFTER_FIRING = 4;
1270 return _BroadcastSubscription;
1271 });
1272 let _BroadcastSubscription = _BroadcastSubscription$();
1273 const _addStreamState = Symbol('_addStreamState');
1274 const _doneFuture = Symbol('_doneFuture');
1275 const _isEmpty = Symbol('_isEmpty');
1276 const _hasOneListener = Symbol('_hasOneListener');
1277 const _isAddingStream = Symbol('_isAddingStream');
1278 const _mayAddEvent = Symbol('_mayAddEvent');
1279 const _ensureDoneFuture = Symbol('_ensureDoneFuture');
1280 const _addListener = Symbol('_addListener');
1281 const _removeListener = Symbol('_removeListener');
1282 const _callOnCancel = Symbol('_callOnCancel');
1283 const _addEventError = Symbol('_addEventError');
1284 const _forEachListener = Symbol('_forEachListener');
1285 const _mayComplete = Symbol('_mayComplete');
1286 const _asyncComplete = Symbol('_asyncComplete');
1287 const _BroadcastStreamController$ = dart.generic(function(T) {
1288 class _BroadcastStreamController extends core.Object {
1289 _BroadcastStreamController(onListen, onCancel) {
1290 this[_onListen] = onListen;
1291 this[_onCancel] = onCancel;
1292 this[_state] = _BroadcastStreamController$()._STATE_INITIAL;
1293 this[_next] = null;
1294 this[_previous] = null;
1295 this[_addStreamState] = null;
1296 this[_doneFuture] = null;
1297 this[_next] = this[_previous] = this;
1298 }
1299 get stream() {
1300 return new (_BroadcastStream$(T))(this);
1301 }
1302 get sink() {
1303 return new (_StreamSinkWrapper$(T))(this);
1304 }
1305 get isClosed() {
1306 return (dart.notNull(this[_state]) & dart.notNull(_BroadcastStreamContro ller$()._STATE_CLOSED)) != 0;
1307 }
1308 get isPaused() {
1309 return false;
1310 }
1311 get hasListener() {
1312 return !dart.notNull(this[_isEmpty]);
1313 }
1314 get [_hasOneListener]() {
1315 dart.assert(!dart.notNull(this[_isEmpty]));
1316 return core.identical(this[_next][_next], this);
1317 }
1318 get [_isFiring]() {
1319 return (dart.notNull(this[_state]) & dart.notNull(_BroadcastStreamContro ller$()._STATE_FIRING)) != 0;
1320 }
1321 get [_isAddingStream]() {
1322 return (dart.notNull(this[_state]) & dart.notNull(_BroadcastStreamContro ller$()._STATE_ADDSTREAM)) != 0;
1323 }
1324 get [_mayAddEvent]() {
1325 return dart.notNull(this[_state]) < dart.notNull(_BroadcastStreamControl ler$()._STATE_CLOSED);
1326 }
1327 [_ensureDoneFuture]() {
1328 if (this[_doneFuture] != null) return this[_doneFuture];
1329 return this[_doneFuture] = new _Future();
1330 }
1331 get [_isEmpty]() {
1332 return core.identical(this[_next], this);
1333 }
1334 [_addListener](subscription) {
1335 dart.as(subscription, _BroadcastSubscription$(T));
1336 dart.assert(core.identical(subscription[_next], subscription));
1337 subscription[_previous] = this[_previous];
1338 subscription[_next] = this;
1339 this[_previous][_next] = subscription;
1340 this[_previous] = subscription;
1341 subscription[_eventState] = dart.notNull(this[_state]) & dart.notNull(_B roadcastStreamController$()._STATE_EVENT_ID);
1342 }
1343 [_removeListener](subscription) {
1344 dart.as(subscription, _BroadcastSubscription$(T));
1345 dart.assert(core.identical(subscription[_controller], this));
1346 dart.assert(!core.identical(subscription[_next], subscription));
1347 let previous = subscription[_previous];
1348 let next = subscription[_next];
1349 previous[_next] = next;
1350 next[_previous] = previous;
1351 subscription[_next] = subscription[_previous] = subscription;
1352 }
1353 [_subscribe](onData, onError, onDone, cancelOnError) {
1354 dart.as(onData, dart.functionType(dart.void, [T]));
1355 dart.as(onDone, dart.functionType(dart.void, []));
1356 if (dart.notNull(this.isClosed)) {
1357 if (onDone == null) onDone = _nullDoneHandler;
1358 return new (_DoneStreamSubscription$(T))(onDone);
1359 }
1360 let subscription = new (_BroadcastSubscription$(T))(this, onData, onErro r, onDone, cancelOnError);
1361 this[_addListener](dart.as(subscription, _BroadcastSubscription$(T)));
1362 if (core.identical(this[_next], this[_previous])) {
1363 _runGuarded(this[_onListen]);
1364 }
1365 return dart.as(subscription, StreamSubscription$(T));
1366 }
1367 [_recordCancel](sub) {
1368 dart.as(sub, StreamSubscription$(T));
1369 let subscription = dart.as(sub, _BroadcastSubscription$(T));
1370 if (core.identical(subscription[_next], subscription)) return null;
1371 dart.assert(!core.identical(subscription[_next], subscription));
1372 if (dart.notNull(subscription[_isFiring])) {
1373 subscription[_setRemoveAfterFiring]();
1374 } else {
1375 dart.assert(!core.identical(subscription[_next], subscription));
1376 this[_removeListener](subscription);
1377 if (!dart.notNull(this[_isFiring]) && dart.notNull(this[_isEmpty])) {
1378 this[_callOnCancel]();
1379 }
1380 }
1381 return null;
1382 }
1383 [_recordPause](subscription) {
1384 dart.as(subscription, StreamSubscription$(T));
1385 }
1386 [_recordResume](subscription) {
1387 dart.as(subscription, StreamSubscription$(T));
1388 }
1389 [_addEventError]() {
1390 if (dart.notNull(this.isClosed)) {
1391 return new core.StateError("Cannot add new events after calling close" );
1392 }
1393 dart.assert(this[_isAddingStream]);
1394 return new core.StateError("Cannot add new events while doing an addStre am");
1395 }
1396 add(data) {
1397 dart.as(data, T);
1398 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_addEventError]() );
1399 this[_sendData](data);
1400 }
1401 addError(error, stackTrace) {
1402 if (stackTrace === void 0) stackTrace = null;
1403 error = _nonNullError(error);
1404 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_addEventError]() );
1405 let replacement = Zone.current.errorCallback(error, stackTrace);
1406 if (replacement != null) {
1407 error = _nonNullError(replacement.error);
1408 stackTrace = replacement.stackTrace;
1409 }
1410 this[_sendError](error, stackTrace);
1411 }
1412 close() {
1413 if (dart.notNull(this.isClosed)) {
1414 dart.assert(this[_doneFuture] != null);
1415 return this[_doneFuture];
1416 }
1417 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_addEventError]() );
1418 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController$()._STATE_CLOSED);
1419 let doneFuture = this[_ensureDoneFuture]();
1420 this[_sendDone]();
1421 return doneFuture;
1422 }
1423 get done() {
1424 return this[_ensureDoneFuture]();
1425 }
1426 addStream(stream, opts) {
1427 dart.as(stream, Stream$(T));
1428 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
1429 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_addEventError]() );
1430 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStrea mController$()._STATE_ADDSTREAM);
1431 this[_addStreamState] = new (_AddStreamState$(T))(this, stream, cancelOn Error);
1432 return this[_addStreamState].addStreamFuture;
1433 }
1434 [_add](data) {
1435 dart.as(data, T);
1436 this[_sendData](data);
1437 }
1438 [_addError](error, stackTrace) {
1439 this[_sendError](error, stackTrace);
1440 }
1441 [_close]() {
1442 dart.assert(this[_isAddingStream]);
1443 let addState = this[_addStreamState];
1444 this[_addStreamState] = null;
1445 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStre amController$()._STATE_ADDSTREAM);
1446 addState.complete();
1447 }
1448 [_forEachListener](action) {
1449 dart.as(action, dart.functionType(dart.void, [_BufferingStreamSubscripti on$(T)]));
1450 if (dart.notNull(this[_isFiring])) {
1451 dart.throw(new core.StateError("Cannot fire new event. Controller is a lready firing an event"));
1452 }
1453 if (dart.notNull(this[_isEmpty])) return;
1454 let id = dart.notNull(this[_state]) & dart.notNull(_BroadcastStreamContr oller$()._STATE_EVENT_ID);
1455 this[_state] = dart.notNull(this[_state]) ^ (dart.notNull(_BroadcastStre amController$()._STATE_EVENT_ID) | dart.notNull(_BroadcastStreamController$()._S TATE_FIRING));
1456 let link = this[_next];
1457 while (!core.identical(link, this)) {
1458 let subscription = dart.as(link, _BroadcastSubscription$(T));
1459 if (dart.notNull(subscription[_expectsEvent](id))) {
1460 subscription[_eventState] = dart.notNull(subscription[_eventState]) | dart.notNull(_BroadcastSubscription._STATE_FIRING);
1461 action(subscription);
1462 subscription[_toggleEventId]();
1463 link = subscription[_next];
1464 if (dart.notNull(subscription[_removeAfterFiring])) {
1465 this[_removeListener](subscription);
1466 }
1467 subscription[_eventState] = dart.notNull(subscription[_eventState]) & ~dart.notNull(_BroadcastSubscription._STATE_FIRING);
1468 } else {
1469 link = subscription[_next];
1470 }
1471 }
1472 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastStre amController$()._STATE_FIRING);
1473 if (dart.notNull(this[_isEmpty])) {
1474 this[_callOnCancel]();
1475 }
1476 }
1477 [_callOnCancel]() {
1478 dart.assert(this[_isEmpty]);
1479 if (dart.notNull(this.isClosed) && dart.notNull(this[_doneFuture][_mayCo mplete])) {
1480 this[_doneFuture][_asyncComplete](null);
1481 }
1482 _runGuarded(this[_onCancel]);
1483 }
1484 }
1485 _BroadcastStreamController[dart.implements] = () => [StreamController$(T), _ StreamControllerLifecycle$(T), _BroadcastSubscriptionLink, _EventSink$(T), _Even tDispatch$(T)];
1486 dart.setSignature(_BroadcastStreamController, {
1487 constructors: () => ({_BroadcastStreamController: [_BroadcastStreamControl ler$(T), [_NotificationHandler, _NotificationHandler]]}),
1488 methods: () => ({
1489 [_ensureDoneFuture]: [_Future, []],
1490 [_addListener]: [dart.void, [_BroadcastSubscription$(T)]],
1491 [_removeListener]: [dart.void, [_BroadcastSubscription$(T)]],
1492 [_subscribe]: [StreamSubscription$(T), [dart.functionType(dart.void, [T] ), core.Function, dart.functionType(dart.void, []), core.bool]],
1493 [_recordCancel]: [Future, [StreamSubscription$(T)]],
1494 [_recordPause]: [dart.void, [StreamSubscription$(T)]],
1495 [_recordResume]: [dart.void, [StreamSubscription$(T)]],
1496 [_addEventError]: [core.Error, []],
1497 add: [dart.void, [T]],
1498 addError: [dart.void, [core.Object], [core.StackTrace]],
1499 close: [Future, []],
1500 addStream: [Future, [Stream$(T)], {cancelOnError: core.bool}],
1501 [_add]: [dart.void, [T]],
1502 [_addError]: [dart.void, [core.Object, core.StackTrace]],
1503 [_close]: [dart.void, []],
1504 [_forEachListener]: [dart.void, [dart.functionType(dart.void, [_Bufferin gStreamSubscription$(T)])]],
1505 [_callOnCancel]: [dart.void, []]
1506 })
1507 });
1508 _BroadcastStreamController._STATE_INITIAL = 0;
1509 _BroadcastStreamController._STATE_EVENT_ID = 1;
1510 _BroadcastStreamController._STATE_FIRING = 2;
1511 _BroadcastStreamController._STATE_CLOSED = 4;
1512 _BroadcastStreamController._STATE_ADDSTREAM = 8;
1513 return _BroadcastStreamController;
1514 });
1515 let _BroadcastStreamController = _BroadcastStreamController$();
1516 const _SyncBroadcastStreamController$ = dart.generic(function(T) {
1517 class _SyncBroadcastStreamController extends _BroadcastStreamController$(T) {
1518 _SyncBroadcastStreamController(onListen, onCancel) {
1519 super._BroadcastStreamController(onListen, onCancel);
1520 }
1521 [_sendData](data) {
1522 dart.as(data, T);
1523 if (dart.notNull(this[_isEmpty])) return;
1524 if (dart.notNull(this[_hasOneListener])) {
1525 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStr eamController._STATE_FIRING);
1526 let subscription = dart.as(this[_next], _BroadcastSubscription);
1527 subscription[_add](data);
1528 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BroadcastSt reamController._STATE_FIRING);
1529 if (dart.notNull(this[_isEmpty])) {
1530 this[_callOnCancel]();
1531 }
1532 return;
1533 }
1534 this[_forEachListener](dart.fn(subscription => {
1535 dart.as(subscription, _BufferingStreamSubscription$(T));
1536 subscription[_add](data);
1537 }, dart.void, [_BufferingStreamSubscription$(T)]));
1538 }
1539 [_sendError](error, stackTrace) {
1540 if (dart.notNull(this[_isEmpty])) return;
1541 this[_forEachListener](dart.fn(subscription => {
1542 dart.as(subscription, _BufferingStreamSubscription$(T));
1543 subscription[_addError](error, stackTrace);
1544 }, dart.void, [_BufferingStreamSubscription$(T)]));
1545 }
1546 [_sendDone]() {
1547 if (!dart.notNull(this[_isEmpty])) {
1548 this[_forEachListener](dart.fn(subscription => {
1549 dart.as(subscription, _BroadcastSubscription$(T));
1550 subscription[_close]();
1551 }, dart.void, [_BroadcastSubscription$(T)]));
1552 } else {
1553 dart.assert(this[_doneFuture] != null);
1554 dart.assert(this[_doneFuture][_mayComplete]);
1555 this[_doneFuture][_asyncComplete](null);
1556 }
1557 }
1558 }
1559 dart.setSignature(_SyncBroadcastStreamController, {
1560 constructors: () => ({_SyncBroadcastStreamController: [_SyncBroadcastStrea mController$(T), [dart.functionType(dart.void, []), dart.functionType(dart.void, [])]]}),
1561 methods: () => ({
1562 [_sendData]: [dart.void, [T]],
1563 [_sendError]: [dart.void, [core.Object, core.StackTrace]],
1564 [_sendDone]: [dart.void, []]
1565 })
1566 });
1567 return _SyncBroadcastStreamController;
1568 });
1569 let _SyncBroadcastStreamController = _SyncBroadcastStreamController$();
1570 const _AsyncBroadcastStreamController$ = dart.generic(function(T) {
1571 class _AsyncBroadcastStreamController extends _BroadcastStreamController$(T) {
1572 _AsyncBroadcastStreamController(onListen, onCancel) {
1573 super._BroadcastStreamController(onListen, onCancel);
1574 }
1575 [_sendData](data) {
1576 dart.as(data, T);
1577 for (let link = this[_next]; !core.identical(link, this); link = link[_n ext]) {
1578 let subscription = dart.as(link, _BroadcastSubscription$(T));
1579 subscription[_addPending](new _DelayedData(data));
1580 }
1581 }
1582 [_sendError](error, stackTrace) {
1583 for (let link = this[_next]; !core.identical(link, this); link = link[_n ext]) {
1584 let subscription = dart.as(link, _BroadcastSubscription$(T));
1585 subscription[_addPending](new _DelayedError(error, stackTrace));
1586 }
1587 }
1588 [_sendDone]() {
1589 if (!dart.notNull(this[_isEmpty])) {
1590 for (let link = this[_next]; !core.identical(link, this); link = link[ _next]) {
1591 let subscription = dart.as(link, _BroadcastSubscription$(T));
1592 subscription[_addPending](dart.const(new _DelayedDone()));
1593 }
1594 } else {
1595 dart.assert(this[_doneFuture] != null);
1596 dart.assert(this[_doneFuture][_mayComplete]);
1597 this[_doneFuture][_asyncComplete](null);
1598 }
1599 }
1600 }
1601 dart.setSignature(_AsyncBroadcastStreamController, {
1602 constructors: () => ({_AsyncBroadcastStreamController: [_AsyncBroadcastStr eamController$(T), [dart.functionType(dart.void, []), dart.functionType(dart.voi d, [])]]}),
1603 methods: () => ({
1604 [_sendData]: [dart.void, [T]],
1605 [_sendError]: [dart.void, [core.Object, core.StackTrace]],
1606 [_sendDone]: [dart.void, []]
1607 })
1608 });
1609 return _AsyncBroadcastStreamController;
1610 });
1611 let _AsyncBroadcastStreamController = _AsyncBroadcastStreamController$();
1612 const _addPendingEvent = Symbol('_addPendingEvent');
1613 const _AsBroadcastStreamController$ = dart.generic(function(T) {
1614 class _AsBroadcastStreamController extends _SyncBroadcastStreamController$(T ) {
1615 _AsBroadcastStreamController(onListen, onCancel) {
1616 this[_pending] = null;
1617 super._SyncBroadcastStreamController(onListen, onCancel);
1618 }
1619 get [_hasPending]() {
1620 return this[_pending] != null && !dart.notNull(this[_pending].isEmpty);
1621 }
1622 [_addPendingEvent](event) {
1623 if (this[_pending] == null) {
1624 this[_pending] = new _StreamImplEvents();
1625 }
1626 this[_pending].add(event);
1627 }
1628 add(data) {
1629 dart.as(data, T);
1630 if (!dart.notNull(this.isClosed) && dart.notNull(this[_isFiring])) {
1631 this[_addPendingEvent](new (_DelayedData$(T))(data));
1632 return;
1633 }
1634 super.add(data);
1635 while (dart.notNull(this[_hasPending])) {
1636 this[_pending].handleNext(this);
1637 }
1638 }
1639 addError(error, stackTrace) {
1640 if (stackTrace === void 0) stackTrace = null;
1641 if (!dart.notNull(this.isClosed) && dart.notNull(this[_isFiring])) {
1642 this[_addPendingEvent](new _DelayedError(error, stackTrace));
1643 return;
1644 }
1645 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_addEventError]() );
1646 this[_sendError](error, stackTrace);
1647 while (dart.notNull(this[_hasPending])) {
1648 this[_pending].handleNext(this);
1649 }
1650 }
1651 close() {
1652 if (!dart.notNull(this.isClosed) && dart.notNull(this[_isFiring])) {
1653 this[_addPendingEvent](dart.const(new _DelayedDone()));
1654 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BroadcastStr eamController._STATE_CLOSED);
1655 return super.done;
1656 }
1657 let result = super.close();
1658 dart.assert(!dart.notNull(this[_hasPending]));
1659 return result;
1660 }
1661 [_callOnCancel]() {
1662 if (dart.notNull(this[_hasPending])) {
1663 this[_pending].clear();
1664 this[_pending] = null;
1665 }
1666 super[_callOnCancel]();
1667 }
1668 }
1669 _AsBroadcastStreamController[dart.implements] = () => [_EventDispatch$(T)];
1670 dart.setSignature(_AsBroadcastStreamController, {
1671 constructors: () => ({_AsBroadcastStreamController: [_AsBroadcastStreamCon troller$(T), [dart.functionType(dart.void, []), dart.functionType(dart.void, []) ]]}),
1672 methods: () => ({
1673 [_addPendingEvent]: [dart.void, [_DelayedEvent]],
1674 add: [dart.void, [T]]
1675 })
1676 });
1677 return _AsBroadcastStreamController;
1678 });
1679 let _AsBroadcastStreamController = _AsBroadcastStreamController$();
1680 const _pauseCount = Symbol('_pauseCount');
1681 const _resume = Symbol('_resume');
1682 const _DoneSubscription$ = dart.generic(function(T) {
1683 class _DoneSubscription extends core.Object {
1684 _DoneSubscription() {
1685 this[_pauseCount] = 0;
1686 }
1687 onData(handleData) {
1688 dart.as(handleData, dart.functionType(dart.void, [T]));
1689 }
1690 onError(handleError) {}
1691 onDone(handleDone) {
1692 dart.as(handleDone, dart.functionType(dart.void, []));
1693 }
1694 pause(resumeSignal) {
1695 if (resumeSignal === void 0) resumeSignal = null;
1696 if (resumeSignal != null) resumeSignal.then(dart.bind(this, _resume));
1697 this[_pauseCount] = dart.notNull(this[_pauseCount]) + 1;
1698 }
1699 resume() {
1700 this[_resume](null);
1701 }
1702 [_resume](_) {
1703 if (dart.notNull(this[_pauseCount]) > 0) {
1704 this[_pauseCount] = dart.notNull(this[_pauseCount]) - 1;
1705 }
1706 }
1707 cancel() {
1708 return new _Future.immediate(null);
1709 }
1710 get isPaused() {
1711 return dart.notNull(this[_pauseCount]) > 0;
1712 }
1713 asFuture(value) {
1714 if (value === void 0) value = null;
1715 return new _Future();
1716 }
1717 }
1718 _DoneSubscription[dart.implements] = () => [StreamSubscription$(T)];
1719 dart.setSignature(_DoneSubscription, {
1720 methods: () => ({
1721 onData: [dart.void, [dart.functionType(dart.void, [T])]],
1722 onError: [dart.void, [core.Function]],
1723 onDone: [dart.void, [dart.functionType(dart.void, [])]],
1724 pause: [dart.void, [], [Future]],
1725 resume: [dart.void, []],
1726 [_resume]: [dart.void, [dart.dynamic]],
1727 cancel: [Future, []],
1728 asFuture: [Future, [], [core.Object]]
1729 })
1730 });
1731 return _DoneSubscription;
1732 });
1733 let _DoneSubscription = _DoneSubscription$();
1734 class DeferredLibrary extends core.Object {
1735 DeferredLibrary(libraryName, opts) {
1736 let uri = opts && 'uri' in opts ? opts.uri : null;
1737 this.libraryName = libraryName;
1738 this.uri = uri;
1739 }
1740 load() {
1741 dart.throw('DeferredLibrary not supported. ' + 'please use the `import "li b.dart" deferred as lib` syntax.');
1742 }
1743 }
1744 dart.setSignature(DeferredLibrary, {
1745 constructors: () => ({DeferredLibrary: [DeferredLibrary, [core.String], {uri : core.String}]}),
1746 methods: () => ({load: [Future$(core.Null), []]})
1747 });
1748 DeferredLibrary[dart.metadata] = () => [dart.const(new core.Deprecated("Dart s dk v. 1.8"))];
1749 const _s = Symbol('_s');
1750 class DeferredLoadException extends core.Object {
1751 DeferredLoadException(s) {
1752 this[_s] = s;
1753 }
1754 toString() {
1755 return `DeferredLoadException: '${this[_s]}'`;
1756 }
1757 }
1758 DeferredLoadException[dart.implements] = () => [core.Exception];
1759 dart.setSignature(DeferredLoadException, {
1760 constructors: () => ({DeferredLoadException: [DeferredLoadException, [core.S tring]]})
1761 });
1762 const _completeWithValue = Symbol('_completeWithValue');
1763 const Future$ = dart.generic(function(T) {
1764 class Future extends core.Object {
1765 static new(computation) {
1766 let result = new (_Future$(T))();
1767 Timer.run(dart.fn(() => {
1768 try {
1769 result[_complete](computation());
1770 } catch (e) {
1771 let s = dart.stackTrace(e);
1772 _completeWithErrorCallback(result, e, s);
1773 }
1774
1775 }, dart.void, []));
1776 return dart.as(result, Future$(T));
1777 }
1778 static microtask(computation) {
1779 let result = new (_Future$(T))();
1780 scheduleMicrotask(dart.fn(() => {
1781 try {
1782 result[_complete](computation());
1783 } catch (e) {
1784 let s = dart.stackTrace(e);
1785 _completeWithErrorCallback(result, e, s);
1786 }
1787
1788 }, dart.void, []));
1789 return dart.as(result, Future$(T));
1790 }
1791 static sync(computation) {
1792 try {
1793 let result = computation();
1794 return Future$(T).value(result);
1795 } catch (error) {
1796 let stackTrace = dart.stackTrace(error);
1797 return Future$(T).error(error, stackTrace);
1798 }
1799
1800 }
1801 static value(value) {
1802 if (value === void 0) value = null;
1803 return new (_Future$(T)).immediate(value);
1804 }
1805 static error(error, stackTrace) {
1806 if (stackTrace === void 0) stackTrace = null;
1807 error = _nonNullError(error);
1808 if (!core.identical(Zone.current, _ROOT_ZONE)) {
1809 let replacement = Zone.current.errorCallback(error, stackTrace);
1810 if (replacement != null) {
1811 error = _nonNullError(replacement.error);
1812 stackTrace = replacement.stackTrace;
1813 }
1814 }
1815 return new (_Future$(T)).immediateError(error, stackTrace);
1816 }
1817 static delayed(duration, computation) {
1818 if (computation === void 0) computation = null;
1819 let result = new (_Future$(T))();
1820 Timer.new(duration, dart.fn(() => {
1821 try {
1822 result[_complete](computation == null ? null : computation());
1823 } catch (e) {
1824 let s = dart.stackTrace(e);
1825 _completeWithErrorCallback(result, e, s);
1826 }
1827
1828 }, dart.void, []));
1829 return dart.as(result, Future$(T));
1830 }
1831 static wait(futures, opts) {
1832 let eagerError = opts && 'eagerError' in opts ? opts.eagerError : false;
1833 let cleanUp = opts && 'cleanUp' in opts ? opts.cleanUp : null;
1834 let result = new (_Future$(core.List))();
1835 let values = null;
1836 let remaining = 0;
1837 let error = null;
1838 let stackTrace = null;
1839 function handleError(theError, theStackTrace) {
1840 remaining--;
1841 if (values != null) {
1842 if (cleanUp != null) {
1843 for (let value2 of values) {
1844 if (value2 != null) {
1845 Future$().sync(dart.fn(() => {
1846 cleanUp(value2);
1847 }));
1848 }
1849 }
1850 }
1851 values = null;
1852 if (remaining == 0 || dart.notNull(eagerError)) {
1853 result[_completeError](theError, dart.as(theStackTrace, core.Stack Trace));
1854 } else {
1855 error = theError;
1856 stackTrace = dart.as(theStackTrace, core.StackTrace);
1857 }
1858 } else if (remaining == 0 && !dart.notNull(eagerError)) {
1859 result[_completeError](error, stackTrace);
1860 }
1861 }
1862 dart.fn(handleError, dart.void, [dart.dynamic, dart.dynamic]);
1863 for (let future of futures) {
1864 let pos = remaining++;
1865 future.then(dart.fn(value => {
1866 remaining--;
1867 if (values != null) {
1868 values[dartx.set](pos, dart.as(value, dart.dynamic));
1869 if (remaining == 0) {
1870 result[_completeWithValue](values);
1871 }
1872 } else {
1873 if (cleanUp != null && value != null) {
1874 Future$().sync(dart.fn(() => {
1875 cleanUp(dart.as(value, dart.dynamic));
1876 }));
1877 }
1878 if (remaining == 0 && !dart.notNull(eagerError)) {
1879 result[_completeError](error, stackTrace);
1880 }
1881 }
1882 }, dart.dynamic, [core.Object]), {onError: handleError});
1883 }
1884 if (remaining == 0) {
1885 return Future$(core.List).value(dart.const([]));
1886 }
1887 values = core.List.new(remaining);
1888 return result;
1889 }
1890 static forEach(input, f) {
1891 let iterator = input[dartx.iterator];
1892 return Future$().doWhile(dart.fn(() => {
1893 if (!dart.notNull(iterator.moveNext())) return false;
1894 return Future$().sync(dart.fn(() => dart.dcall(f, iterator.current))). then(dart.fn(_ => true, core.bool, [dart.dynamic]));
1895 }, core.Object, []));
1896 }
1897 static doWhile(f) {
1898 let doneSignal = new _Future();
1899 let nextIteration = null;
1900 nextIteration = Zone.current.bindUnaryCallback(dart.fn(keepGoing => {
1901 if (dart.notNull(keepGoing)) {
1902 Future$().sync(f).then(dart.as(nextIteration, dart.functionType(dart .dynamic, [dart.dynamic])), {onError: dart.bind(doneSignal, _completeError)});
1903 } else {
1904 doneSignal[_complete](null);
1905 }
1906 }, dart.dynamic, [core.bool]), {runGuarded: true});
1907 dart.dcall(nextIteration, true);
1908 return doneSignal;
1909 }
1910 }
1911 dart.setSignature(Future, {
1912 constructors: () => ({
1913 new: [Future$(T), [dart.functionType(dart.dynamic, [])]],
1914 microtask: [Future$(T), [dart.functionType(dart.dynamic, [])]],
1915 sync: [Future$(T), [dart.functionType(dart.dynamic, [])]],
1916 value: [Future$(T), [], [dart.dynamic]],
1917 error: [Future$(T), [core.Object], [core.StackTrace]],
1918 delayed: [Future$(T), [core.Duration], [dart.functionType(T, [])]]
1919 }),
1920 statics: () => ({
1921 wait: [Future$(core.List), [core.Iterable$(Future$())], {eagerError: cor e.bool, cleanUp: dart.functionType(dart.void, [dart.dynamic])}],
1922 forEach: [Future$(), [core.Iterable, dart.functionType(dart.dynamic, [da rt.dynamic])]],
1923 doWhile: [Future$(), [dart.functionType(dart.dynamic, [])]]
1924 }),
1925 names: ['wait', 'forEach', 'doWhile']
1926 });
1927 dart.defineLazyProperties(Future, {
1928 get _nullFuture() {
1929 return new _Future.immediate(null);
1930 }
1931 });
1932 return Future;
1933 });
1934 let Future = Future$();
1935 class TimeoutException extends core.Object {
1936 TimeoutException(message, duration) {
1937 if (duration === void 0) duration = null;
1938 this.message = message;
1939 this.duration = duration;
1940 }
1941 toString() {
1942 let result = "TimeoutException";
1943 if (this.duration != null) result = `TimeoutException after ${this.duratio n}`;
1944 if (this.message != null) result = `${result}: ${this.message}`;
1945 return result;
1946 }
1947 }
1948 TimeoutException[dart.implements] = () => [core.Exception];
1949 dart.setSignature(TimeoutException, {
1950 constructors: () => ({TimeoutException: [TimeoutException, [core.String], [c ore.Duration]]})
1951 });
1952 const Completer$ = dart.generic(function(T) {
1953 class Completer extends core.Object {
1954 static new() {
1955 return new (_AsyncCompleter$(T))();
1956 }
1957 static sync() {
1958 return new (_SyncCompleter$(T))();
1959 }
1960 }
1961 dart.setSignature(Completer, {
1962 constructors: () => ({
1963 new: [Completer$(T), []],
1964 sync: [Completer$(T), []]
1965 })
1966 });
1967 return Completer;
1968 });
1969 let Completer = Completer$();
1970 function _completeWithErrorCallback(result, error, stackTrace) {
1971 let replacement = Zone.current.errorCallback(error, dart.as(stackTrace, core .StackTrace));
1972 if (replacement != null) {
1973 error = _nonNullError(replacement.error);
1974 stackTrace = replacement.stackTrace;
1975 }
1976 result[_completeError](error, dart.as(stackTrace, core.StackTrace));
1977 }
1978 dart.fn(_completeWithErrorCallback, () => dart.definiteFunctionType(dart.void, [_Future, dart.dynamic, dart.dynamic]));
1979 function _nonNullError(error) {
1980 return error != null ? error : new core.NullThrownError();
1981 }
1982 dart.fn(_nonNullError, core.Object, [core.Object]);
1983 const _FutureOnValue$ = dart.generic(function(T) {
1984 const _FutureOnValue = dart.typedef('_FutureOnValue', () => dart.functionTyp e(dart.dynamic, [T]));
1985 return _FutureOnValue;
1986 });
1987 let _FutureOnValue = _FutureOnValue$();
1988 const _FutureErrorTest = dart.typedef('_FutureErrorTest', () => dart.functionT ype(core.bool, [dart.dynamic]));
1989 const _FutureAction = dart.typedef('_FutureAction', () => dart.functionType(da rt.dynamic, []));
1990 const _Completer$ = dart.generic(function(T) {
1991 class _Completer extends core.Object {
1992 _Completer() {
1993 this.future = new (_Future$(T))();
1994 }
1995 completeError(error, stackTrace) {
1996 if (stackTrace === void 0) stackTrace = null;
1997 error = _nonNullError(error);
1998 if (!dart.notNull(this.future[_mayComplete])) dart.throw(new core.StateE rror("Future already completed"));
1999 let replacement = Zone.current.errorCallback(error, stackTrace);
2000 if (replacement != null) {
2001 error = _nonNullError(replacement.error);
2002 stackTrace = replacement.stackTrace;
2003 }
2004 this[_completeError](error, stackTrace);
2005 }
2006 get isCompleted() {
2007 return !dart.notNull(this.future[_mayComplete]);
2008 }
2009 }
2010 _Completer[dart.implements] = () => [Completer$(T)];
2011 dart.setSignature(_Completer, {
2012 methods: () => ({completeError: [dart.void, [core.Object], [core.StackTrac e]]})
2013 });
2014 return _Completer;
2015 });
2016 let _Completer = _Completer$();
2017 const _asyncCompleteError = Symbol('_asyncCompleteError');
2018 const _AsyncCompleter$ = dart.generic(function(T) {
2019 class _AsyncCompleter extends _Completer$(T) {
2020 _AsyncCompleter() {
2021 super._Completer();
2022 }
2023 complete(value) {
2024 if (value === void 0) value = null;
2025 if (!dart.notNull(this.future[_mayComplete])) dart.throw(new core.StateE rror("Future already completed"));
2026 this.future[_asyncComplete](value);
2027 }
2028 [_completeError](error, stackTrace) {
2029 this.future[_asyncCompleteError](error, stackTrace);
2030 }
2031 }
2032 dart.setSignature(_AsyncCompleter, {
2033 methods: () => ({
2034 complete: [dart.void, [], [dart.dynamic]],
2035 [_completeError]: [dart.void, [core.Object, core.StackTrace]]
2036 })
2037 });
2038 return _AsyncCompleter;
2039 });
2040 let _AsyncCompleter = _AsyncCompleter$();
2041 const _SyncCompleter$ = dart.generic(function(T) {
2042 class _SyncCompleter extends _Completer$(T) {
2043 _SyncCompleter() {
2044 super._Completer();
2045 }
2046 complete(value) {
2047 if (value === void 0) value = null;
2048 if (!dart.notNull(this.future[_mayComplete])) dart.throw(new core.StateE rror("Future already completed"));
2049 this.future[_complete](value);
2050 }
2051 [_completeError](error, stackTrace) {
2052 this.future[_completeError](error, stackTrace);
2053 }
2054 }
2055 dart.setSignature(_SyncCompleter, {
2056 methods: () => ({
2057 complete: [dart.void, [], [dart.dynamic]],
2058 [_completeError]: [dart.void, [core.Object, core.StackTrace]]
2059 })
2060 });
2061 return _SyncCompleter;
2062 });
2063 let _SyncCompleter = _SyncCompleter$();
2064 const _nextListener = Symbol('_nextListener');
2065 const _onValue = Symbol('_onValue');
2066 const _errorTest = Symbol('_errorTest');
2067 const _whenCompleteAction = Symbol('_whenCompleteAction');
2068 class _FutureListener extends core.Object {
2069 then(result, onValue, errorCallback) {
2070 this.result = result;
2071 this.callback = onValue;
2072 this.errorCallback = errorCallback;
2073 this.state = errorCallback == null ? _FutureListener.STATE_THEN : _FutureL istener.STATE_THEN_ONERROR;
2074 this[_nextListener] = null;
2075 }
2076 catchError(result, errorCallback, test) {
2077 this.result = result;
2078 this.errorCallback = errorCallback;
2079 this.callback = test;
2080 this.state = test == null ? _FutureListener.STATE_CATCHERROR : _FutureList ener.STATE_CATCHERROR_TEST;
2081 this[_nextListener] = null;
2082 }
2083 whenComplete(result, onComplete) {
2084 this.result = result;
2085 this.callback = onComplete;
2086 this.errorCallback = null;
2087 this.state = _FutureListener.STATE_WHENCOMPLETE;
2088 this[_nextListener] = null;
2089 }
2090 chain(result) {
2091 this.result = result;
2092 this.callback = null;
2093 this.errorCallback = null;
2094 this.state = _FutureListener.STATE_CHAIN;
2095 this[_nextListener] = null;
2096 }
2097 get [_zone]() {
2098 return this.result[_zone];
2099 }
2100 get handlesValue() {
2101 return (dart.notNull(this.state) & dart.notNull(_FutureListener.MASK_VALUE )) != 0;
2102 }
2103 get handlesError() {
2104 return (dart.notNull(this.state) & dart.notNull(_FutureListener.MASK_ERROR )) != 0;
2105 }
2106 get hasErrorTest() {
2107 return this.state == _FutureListener.STATE_CATCHERROR_TEST;
2108 }
2109 get handlesComplete() {
2110 return this.state == _FutureListener.STATE_WHENCOMPLETE;
2111 }
2112 get [_onValue]() {
2113 dart.assert(this.handlesValue);
2114 return dart.as(this.callback, _FutureOnValue);
2115 }
2116 get [_onError]() {
2117 return this.errorCallback;
2118 }
2119 get [_errorTest]() {
2120 dart.assert(this.hasErrorTest);
2121 return dart.as(this.callback, _FutureErrorTest);
2122 }
2123 get [_whenCompleteAction]() {
2124 dart.assert(this.handlesComplete);
2125 return dart.as(this.callback, _FutureAction);
2126 }
2127 }
2128 dart.defineNamedConstructor(_FutureListener, 'then');
2129 dart.defineNamedConstructor(_FutureListener, 'catchError');
2130 dart.defineNamedConstructor(_FutureListener, 'whenComplete');
2131 dart.defineNamedConstructor(_FutureListener, 'chain');
2132 dart.setSignature(_FutureListener, {
2133 constructors: () => ({
2134 then: [_FutureListener, [_Future, _FutureOnValue, core.Function]],
2135 catchError: [_FutureListener, [_Future, core.Function, _FutureErrorTest]],
2136 whenComplete: [_FutureListener, [_Future, _FutureAction]],
2137 chain: [_FutureListener, [_Future]]
2138 })
2139 });
2140 _FutureListener.MASK_VALUE = 1;
2141 _FutureListener.MASK_ERROR = 2;
2142 _FutureListener.MASK_TEST_ERROR = 4;
2143 _FutureListener.MASK_WHENCOMPLETE = 8;
2144 _FutureListener.STATE_CHAIN = 0;
2145 dart.defineLazyProperties(_FutureListener, {
2146 get STATE_THEN() {
2147 return _FutureListener.MASK_VALUE;
2148 },
2149 get STATE_THEN_ONERROR() {
2150 return dart.notNull(_FutureListener.MASK_VALUE) | dart.notNull(_FutureList ener.MASK_ERROR);
2151 },
2152 get STATE_CATCHERROR() {
2153 return _FutureListener.MASK_ERROR;
2154 },
2155 get STATE_CATCHERROR_TEST() {
2156 return dart.notNull(_FutureListener.MASK_ERROR) | dart.notNull(_FutureList ener.MASK_TEST_ERROR);
2157 },
2158 get STATE_WHENCOMPLETE() {
2159 return _FutureListener.MASK_WHENCOMPLETE;
2160 }
2161 });
2162 const _resultOrListeners = Symbol('_resultOrListeners');
2163 const _isChained = Symbol('_isChained');
2164 const _isComplete = Symbol('_isComplete');
2165 const _hasValue = Symbol('_hasValue');
2166 const _hasError = Symbol('_hasError');
2167 const _markPendingCompletion = Symbol('_markPendingCompletion');
2168 const _value = Symbol('_value');
2169 const _error = Symbol('_error');
2170 const _setValue = Symbol('_setValue');
2171 const _setErrorObject = Symbol('_setErrorObject');
2172 const _setError = Symbol('_setError');
2173 const _removeListeners = Symbol('_removeListeners');
2174 const _Future$ = dart.generic(function(T) {
2175 class _Future extends core.Object {
2176 _Future() {
2177 this[_zone] = Zone.current;
2178 this[_state] = _Future$()._INCOMPLETE;
2179 this[_resultOrListeners] = null;
2180 }
2181 immediate(value) {
2182 this[_zone] = Zone.current;
2183 this[_state] = _Future$()._INCOMPLETE;
2184 this[_resultOrListeners] = null;
2185 this[_asyncComplete](value);
2186 }
2187 immediateError(error, stackTrace) {
2188 if (stackTrace === void 0) stackTrace = null;
2189 this[_zone] = Zone.current;
2190 this[_state] = _Future$()._INCOMPLETE;
2191 this[_resultOrListeners] = null;
2192 this[_asyncCompleteError](error, stackTrace);
2193 }
2194 get [_mayComplete]() {
2195 return this[_state] == _Future$()._INCOMPLETE;
2196 }
2197 get [_isChained]() {
2198 return this[_state] == _Future$()._CHAINED;
2199 }
2200 get [_isComplete]() {
2201 return dart.notNull(this[_state]) >= dart.notNull(_Future$()._VALUE);
2202 }
2203 get [_hasValue]() {
2204 return this[_state] == _Future$()._VALUE;
2205 }
2206 get [_hasError]() {
2207 return this[_state] == _Future$()._ERROR;
2208 }
2209 set [_isChained](value) {
2210 if (dart.notNull(value)) {
2211 dart.assert(!dart.notNull(this[_isComplete]));
2212 this[_state] = _Future$()._CHAINED;
2213 } else {
2214 dart.assert(this[_isChained]);
2215 this[_state] = _Future$()._INCOMPLETE;
2216 }
2217 }
2218 then(f, opts) {
2219 dart.as(f, dart.functionType(dart.dynamic, [T]));
2220 let onError = opts && 'onError' in opts ? opts.onError : null;
2221 let result = new (_Future$())();
2222 if (!core.identical(result[_zone], _ROOT_ZONE)) {
2223 f = dart.as(result[_zone].registerUnaryCallback(f), dart.functionType( dart.dynamic, [T]));
2224 if (onError != null) {
2225 onError = _registerErrorHandler(onError, result[_zone]);
2226 }
2227 }
2228 this[_addListener](new _FutureListener.then(result, f, onError));
2229 return result;
2230 }
2231 catchError(onError, opts) {
2232 let test = opts && 'test' in opts ? opts.test : null;
2233 dart.as(test, dart.functionType(core.bool, [dart.dynamic]));
2234 let result = new (_Future$())();
2235 if (!core.identical(result[_zone], _ROOT_ZONE)) {
2236 onError = _registerErrorHandler(onError, result[_zone]);
2237 if (test != null) test = dart.as(result[_zone].registerUnaryCallback(t est), dart.functionType(core.bool, [dart.dynamic]));
2238 }
2239 this[_addListener](new _FutureListener.catchError(result, onError, test) );
2240 return result;
2241 }
2242 whenComplete(action) {
2243 dart.as(action, dart.functionType(dart.dynamic, []));
2244 let result = new (_Future$(T))();
2245 if (!core.identical(result[_zone], _ROOT_ZONE)) {
2246 action = result[_zone].registerCallback(action);
2247 }
2248 this[_addListener](new _FutureListener.whenComplete(result, action));
2249 return dart.as(result, Future$(T));
2250 }
2251 asStream() {
2252 return Stream$(T).fromFuture(this);
2253 }
2254 [_markPendingCompletion]() {
2255 if (!dart.notNull(this[_mayComplete])) dart.throw(new core.StateError("F uture already completed"));
2256 this[_state] = _Future$()._PENDING_COMPLETE;
2257 }
2258 get [_value]() {
2259 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasVal ue]));
2260 return dart.as(this[_resultOrListeners], T);
2261 }
2262 get [_error]() {
2263 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasErr or]));
2264 return dart.as(this[_resultOrListeners], AsyncError);
2265 }
2266 [_setValue](value) {
2267 dart.as(value, T);
2268 dart.assert(!dart.notNull(this[_isComplete]));
2269 this[_state] = _Future$()._VALUE;
2270 this[_resultOrListeners] = value;
2271 }
2272 [_setErrorObject](error) {
2273 dart.assert(!dart.notNull(this[_isComplete]));
2274 this[_state] = _Future$()._ERROR;
2275 this[_resultOrListeners] = error;
2276 }
2277 [_setError](error, stackTrace) {
2278 this[_setErrorObject](new AsyncError(error, stackTrace));
2279 }
2280 [_addListener](listener) {
2281 dart.assert(listener[_nextListener] == null);
2282 if (dart.notNull(this[_isComplete])) {
2283 this[_zone].scheduleMicrotask(dart.fn(() => {
2284 _Future$()._propagateToListeners(this, listener);
2285 }, dart.void, []));
2286 } else {
2287 listener[_nextListener] = dart.as(this[_resultOrListeners], _FutureLis tener);
2288 this[_resultOrListeners] = listener;
2289 }
2290 }
2291 [_removeListeners]() {
2292 dart.assert(!dart.notNull(this[_isComplete]));
2293 let current = dart.as(this[_resultOrListeners], _FutureListener);
2294 this[_resultOrListeners] = null;
2295 let prev = null;
2296 while (current != null) {
2297 let next = current[_nextListener];
2298 current[_nextListener] = prev;
2299 prev = current;
2300 current = next;
2301 }
2302 return prev;
2303 }
2304 static _chainForeignFuture(source, target) {
2305 dart.assert(!dart.notNull(target[_isComplete]));
2306 dart.assert(!dart.is(source, _Future$()));
2307 target[_isChained] = true;
2308 source.then(dart.fn(value => {
2309 dart.assert(target[_isChained]);
2310 target[_completeWithValue](value);
2311 }), {onError: dart.fn((error, stackTrace) => {
2312 if (stackTrace === void 0) stackTrace = null;
2313 dart.assert(target[_isChained]);
2314 target[_completeError](error, dart.as(stackTrace, core.StackTrace));
2315 }, dart.dynamic, [dart.dynamic], [dart.dynamic])});
2316 }
2317 static _chainCoreFuture(source, target) {
2318 dart.assert(!dart.notNull(target[_isComplete]));
2319 dart.assert(dart.is(source, _Future$()));
2320 target[_isChained] = true;
2321 let listener = new _FutureListener.chain(target);
2322 if (dart.notNull(source[_isComplete])) {
2323 _Future$()._propagateToListeners(source, listener);
2324 } else {
2325 source[_addListener](listener);
2326 }
2327 }
2328 [_complete](value) {
2329 dart.assert(!dart.notNull(this[_isComplete]));
2330 if (dart.is(value, Future)) {
2331 if (dart.is(value, _Future$())) {
2332 _Future$()._chainCoreFuture(value, this);
2333 } else {
2334 _Future$()._chainForeignFuture(value, this);
2335 }
2336 } else {
2337 let listeners = this[_removeListeners]();
2338 this[_setValue](dart.as(value, T));
2339 _Future$()._propagateToListeners(this, listeners);
2340 }
2341 }
2342 [_completeWithValue](value) {
2343 dart.assert(!dart.notNull(this[_isComplete]));
2344 dart.assert(!dart.is(value, Future));
2345 let listeners = this[_removeListeners]();
2346 this[_setValue](dart.as(value, T));
2347 _Future$()._propagateToListeners(this, listeners);
2348 }
2349 [_completeError](error, stackTrace) {
2350 if (stackTrace === void 0) stackTrace = null;
2351 dart.assert(!dart.notNull(this[_isComplete]));
2352 let listeners = this[_removeListeners]();
2353 this[_setError](error, stackTrace);
2354 _Future$()._propagateToListeners(this, listeners);
2355 }
2356 [_asyncComplete](value) {
2357 dart.assert(!dart.notNull(this[_isComplete]));
2358 if (value == null) {
2359 } else if (dart.is(value, Future)) {
2360 let typedFuture = dart.as(value, Future$(T));
2361 if (dart.is(typedFuture, _Future$())) {
2362 let coreFuture = dart.as(typedFuture, _Future$(T));
2363 if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture [_hasError])) {
2364 this[_markPendingCompletion]();
2365 this[_zone].scheduleMicrotask(dart.fn(() => {
2366 _Future$()._chainCoreFuture(coreFuture, this);
2367 }, dart.void, []));
2368 } else {
2369 _Future$()._chainCoreFuture(coreFuture, this);
2370 }
2371 } else {
2372 _Future$()._chainForeignFuture(typedFuture, this);
2373 }
2374 return;
2375 } else {
2376 let typedValue = dart.as(value, T);
2377 }
2378 this[_markPendingCompletion]();
2379 this[_zone].scheduleMicrotask(dart.fn(() => {
2380 this[_completeWithValue](value);
2381 }, dart.void, []));
2382 }
2383 [_asyncCompleteError](error, stackTrace) {
2384 dart.assert(!dart.notNull(this[_isComplete]));
2385 this[_markPendingCompletion]();
2386 this[_zone].scheduleMicrotask(dart.fn(() => {
2387 this[_completeError](error, stackTrace);
2388 }, dart.void, []));
2389 }
2390 static _propagateToListeners(source, listeners) {
2391 while (true) {
2392 dart.assert(source[_isComplete]);
2393 let hasError = source[_hasError];
2394 if (listeners == null) {
2395 if (dart.notNull(hasError)) {
2396 let asyncError = source[_error];
2397 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta ckTrace);
2398 }
2399 return;
2400 }
2401 while (listeners[_nextListener] != null) {
2402 let listener = listeners;
2403 listeners = listener[_nextListener];
2404 listener[_nextListener] = null;
2405 _Future$()._propagateToListeners(source, listener);
2406 }
2407 let listener = listeners;
2408 let listenerHasValue = true;
2409 let sourceValue = dart.notNull(hasError) ? null : source[_value];
2410 let listenerValueOrError = sourceValue;
2411 let isPropagationAborted = false;
2412 if (dart.notNull(hasError) || dart.notNull(listener.handlesValue) || d art.notNull(listener.handlesComplete)) {
2413 let zone = listener[_zone];
2414 if (dart.notNull(hasError) && !dart.notNull(source[_zone].inSameErro rZone(zone))) {
2415 let asyncError = source[_error];
2416 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta ckTrace);
2417 return;
2418 }
2419 let oldZone = null;
2420 if (!core.identical(Zone.current, zone)) {
2421 oldZone = Zone._enter(zone);
2422 }
2423 function handleValueCallback() {
2424 try {
2425 listenerValueOrError = zone.runUnary(listener[_onValue], sourceV alue);
2426 return true;
2427 } catch (e) {
2428 let s = dart.stackTrace(e);
2429 listenerValueOrError = new AsyncError(e, s);
2430 return false;
2431 }
2432
2433 }
2434 dart.fn(handleValueCallback, core.bool, []);
2435 function handleError() {
2436 let asyncError = source[_error];
2437 let matchesTest = true;
2438 if (dart.notNull(listener.hasErrorTest)) {
2439 let test = listener[_errorTest];
2440 try {
2441 matchesTest = dart.as(zone.runUnary(test, asyncError.error), c ore.bool);
2442 } catch (e) {
2443 let s = dart.stackTrace(e);
2444 listenerValueOrError = core.identical(asyncError.error, e) ? a syncError : new AsyncError(e, s);
2445 listenerHasValue = false;
2446 return;
2447 }
2448
2449 }
2450 let errorCallback = listener[_onError];
2451 if (dart.notNull(matchesTest) && errorCallback != null) {
2452 try {
2453 if (dart.is(errorCallback, ZoneBinaryCallback)) {
2454 listenerValueOrError = zone.runBinary(errorCallback, asyncEr ror.error, asyncError.stackTrace);
2455 } else {
2456 listenerValueOrError = zone.runUnary(dart.as(errorCallback, dart.functionType(dart.dynamic, [dart.dynamic])), asyncError.error);
2457 }
2458 } catch (e) {
2459 let s = dart.stackTrace(e);
2460 listenerValueOrError = core.identical(asyncError.error, e) ? a syncError : new AsyncError(e, s);
2461 listenerHasValue = false;
2462 return;
2463 }
2464
2465 listenerHasValue = true;
2466 } else {
2467 listenerValueOrError = asyncError;
2468 listenerHasValue = false;
2469 }
2470 }
2471 dart.fn(handleError, dart.void, []);
2472 function handleWhenCompleteCallback() {
2473 let completeResult = null;
2474 try {
2475 completeResult = zone.run(listener[_whenCompleteAction]);
2476 } catch (e) {
2477 let s = dart.stackTrace(e);
2478 if (dart.notNull(hasError) && core.identical(source[_error].erro r, e)) {
2479 listenerValueOrError = source[_error];
2480 } else {
2481 listenerValueOrError = new AsyncError(e, s);
2482 }
2483 listenerHasValue = false;
2484 return;
2485 }
2486
2487 if (dart.is(completeResult, Future)) {
2488 let result = listener.result;
2489 result[_isChained] = true;
2490 isPropagationAborted = true;
2491 dart.dsend(completeResult, 'then', dart.fn(ignored => {
2492 _Future$()._propagateToListeners(source, new _FutureListener.c hain(result));
2493 }), {onError: dart.fn((error, stackTrace) => {
2494 if (stackTrace === void 0) stackTrace = null;
2495 if (!dart.is(completeResult, _Future$())) {
2496 completeResult = new (_Future$())();
2497 dart.dsend(completeResult, _setError, error, stackTrace);
2498 }
2499 _Future$()._propagateToListeners(dart.as(completeResult, _Fu ture$()), new _FutureListener.chain(result));
2500 }, dart.dynamic, [dart.dynamic], [dart.dynamic])});
2501 }
2502 }
2503 dart.fn(handleWhenCompleteCallback, dart.void, []);
2504 if (!dart.notNull(hasError)) {
2505 if (dart.notNull(listener.handlesValue)) {
2506 listenerHasValue = handleValueCallback();
2507 }
2508 } else {
2509 handleError();
2510 }
2511 if (dart.notNull(listener.handlesComplete)) {
2512 handleWhenCompleteCallback();
2513 }
2514 if (oldZone != null) Zone._leave(oldZone);
2515 if (isPropagationAborted) return;
2516 if (dart.notNull(listenerHasValue) && !core.identical(sourceValue, l istenerValueOrError) && dart.is(listenerValueOrError, Future)) {
2517 let chainSource = dart.as(listenerValueOrError, Future);
2518 let result = listener.result;
2519 if (dart.is(chainSource, _Future$())) {
2520 if (dart.notNull(chainSource[_isComplete])) {
2521 result[_isChained] = true;
2522 source = chainSource;
2523 listeners = new _FutureListener.chain(result);
2524 continue;
2525 } else {
2526 _Future$()._chainCoreFuture(chainSource, result);
2527 }
2528 } else {
2529 _Future$()._chainForeignFuture(chainSource, result);
2530 }
2531 return;
2532 }
2533 }
2534 let result = listener.result;
2535 listeners = result[_removeListeners]();
2536 if (dart.notNull(listenerHasValue)) {
2537 result[_setValue](listenerValueOrError);
2538 } else {
2539 let asyncError = dart.as(listenerValueOrError, AsyncError);
2540 result[_setErrorObject](asyncError);
2541 }
2542 source = result;
2543 }
2544 }
2545 timeout(timeLimit, opts) {
2546 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
2547 dart.as(onTimeout, dart.functionType(dart.dynamic, []));
2548 if (dart.notNull(this[_isComplete])) return new (_Future$()).immediate(t his);
2549 let result = new (_Future$())();
2550 let timer = null;
2551 if (onTimeout == null) {
2552 timer = Timer.new(timeLimit, dart.fn(() => {
2553 result[_completeError](new TimeoutException("Future not completed", timeLimit));
2554 }, dart.void, []));
2555 } else {
2556 let zone = Zone.current;
2557 onTimeout = zone.registerCallback(onTimeout);
2558 timer = Timer.new(timeLimit, dart.fn(() => {
2559 try {
2560 result[_complete](zone.run(onTimeout));
2561 } catch (e) {
2562 let s = dart.stackTrace(e);
2563 result[_completeError](e, s);
2564 }
2565
2566 }, dart.void, []));
2567 }
2568 this.then(dart.fn(v => {
2569 dart.as(v, T);
2570 if (dart.notNull(timer.isActive)) {
2571 timer.cancel();
2572 result[_completeWithValue](v);
2573 }
2574 }, dart.dynamic, [T]), {onError: dart.fn((e, s) => {
2575 if (dart.notNull(timer.isActive)) {
2576 timer.cancel();
2577 result[_completeError](e, dart.as(s, core.StackTrace));
2578 }
2579 })});
2580 return result;
2581 }
2582 }
2583 _Future[dart.implements] = () => [Future$(T)];
2584 dart.defineNamedConstructor(_Future, 'immediate');
2585 dart.defineNamedConstructor(_Future, 'immediateError');
2586 dart.setSignature(_Future, {
2587 constructors: () => ({
2588 _Future: [_Future$(T), []],
2589 immediate: [_Future$(T), [dart.dynamic]],
2590 immediateError: [_Future$(T), [dart.dynamic], [core.StackTrace]]
2591 }),
2592 methods: () => ({
2593 then: [Future, [dart.functionType(dart.dynamic, [T])], {onError: core.Fu nction}],
2594 catchError: [Future, [core.Function], {test: dart.functionType(core.bool , [dart.dynamic])}],
2595 whenComplete: [Future$(T), [dart.functionType(dart.dynamic, [])]],
2596 asStream: [Stream$(T), []],
2597 [_markPendingCompletion]: [dart.void, []],
2598 [_setValue]: [dart.void, [T]],
2599 [_setErrorObject]: [dart.void, [AsyncError]],
2600 [_setError]: [dart.void, [core.Object, core.StackTrace]],
2601 [_addListener]: [dart.void, [_FutureListener]],
2602 [_removeListeners]: [_FutureListener, []],
2603 [_complete]: [dart.void, [dart.dynamic]],
2604 [_completeWithValue]: [dart.void, [dart.dynamic]],
2605 [_completeError]: [dart.void, [dart.dynamic], [core.StackTrace]],
2606 [_asyncComplete]: [dart.void, [dart.dynamic]],
2607 [_asyncCompleteError]: [dart.void, [dart.dynamic, core.StackTrace]],
2608 timeout: [Future, [core.Duration], {onTimeout: dart.functionType(dart.dy namic, [])}]
2609 }),
2610 statics: () => ({
2611 _chainForeignFuture: [dart.void, [Future, _Future$()]],
2612 _chainCoreFuture: [dart.void, [_Future$(), _Future$()]],
2613 _propagateToListeners: [dart.void, [_Future$(), _FutureListener]]
2614 }),
2615 names: ['_chainForeignFuture', '_chainCoreFuture', '_propagateToListeners' ]
2616 });
2617 _Future._INCOMPLETE = 0;
2618 _Future._PENDING_COMPLETE = 1;
2619 _Future._CHAINED = 2;
2620 _Future._VALUE = 4;
2621 _Future._ERROR = 8;
2622 return _Future;
2623 });
2624 let _Future = _Future$();
2625 const _AsyncCallback = dart.typedef('_AsyncCallback', () => dart.functionType( dart.void, []));
2626 class _AsyncCallbackEntry extends core.Object {
2627 _AsyncCallbackEntry(callback) {
2628 this.callback = callback;
2629 this.next = null;
2630 }
2631 }
2632 dart.setSignature(_AsyncCallbackEntry, {
2633 constructors: () => ({_AsyncCallbackEntry: [_AsyncCallbackEntry, [_AsyncCall back]]})
2634 });
2635 exports._nextCallback = null;
2636 exports._lastCallback = null;
2637 exports._lastPriorityCallback = null;
2638 exports._isInCallbackLoop = false;
2639 function _asyncRunCallbackLoop() {
2640 while (exports._nextCallback != null) {
2641 exports._lastPriorityCallback = null;
2642 let entry = exports._nextCallback;
2643 exports._nextCallback = entry.next;
2644 if (exports._nextCallback == null) exports._lastCallback = null;
2645 entry.callback();
2646 }
2647 }
2648 dart.fn(_asyncRunCallbackLoop, dart.void, []);
2649 function _asyncRunCallback() {
2650 exports._isInCallbackLoop = true;
2651 try {
2652 _asyncRunCallbackLoop();
2653 } finally {
2654 exports._lastPriorityCallback = null;
2655 exports._isInCallbackLoop = false;
2656 if (exports._nextCallback != null) _AsyncRun._scheduleImmediate(_asyncRunC allback);
2657 }
2658 }
2659 dart.fn(_asyncRunCallback, dart.void, []);
2660 function _scheduleAsyncCallback(callback) {
2661 if (exports._nextCallback == null) {
2662 exports._nextCallback = exports._lastCallback = new _AsyncCallbackEntry(da rt.as(callback, _AsyncCallback));
2663 if (!dart.notNull(exports._isInCallbackLoop)) {
2664 _AsyncRun._scheduleImmediate(_asyncRunCallback);
2665 }
2666 } else {
2667 let newEntry = new _AsyncCallbackEntry(dart.as(callback, _AsyncCallback));
2668 exports._lastCallback.next = newEntry;
2669 exports._lastCallback = newEntry;
2670 }
2671 }
2672 dart.fn(_scheduleAsyncCallback, dart.void, [dart.dynamic]);
2673 function _schedulePriorityAsyncCallback(callback) {
2674 let entry = new _AsyncCallbackEntry(dart.as(callback, _AsyncCallback));
2675 if (exports._nextCallback == null) {
2676 _scheduleAsyncCallback(callback);
2677 exports._lastPriorityCallback = exports._lastCallback;
2678 } else if (exports._lastPriorityCallback == null) {
2679 entry.next = exports._nextCallback;
2680 exports._nextCallback = exports._lastPriorityCallback = entry;
2681 } else {
2682 entry.next = exports._lastPriorityCallback.next;
2683 exports._lastPriorityCallback.next = entry;
2684 exports._lastPriorityCallback = entry;
2685 if (entry.next == null) {
2686 exports._lastCallback = entry;
2687 }
2688 }
2689 }
2690 dart.fn(_schedulePriorityAsyncCallback, dart.void, [dart.dynamic]);
2691 function scheduleMicrotask(callback) {
2692 if (core.identical(_ROOT_ZONE, Zone.current)) {
2693 _rootScheduleMicrotask(null, null, _ROOT_ZONE, callback);
2694 return;
2695 }
2696 Zone.current.scheduleMicrotask(Zone.current.bindCallback(callback, {runGuard ed: true}));
2697 }
2698 dart.fn(scheduleMicrotask, dart.void, [dart.functionType(dart.void, [])]);
2699 class _AsyncRun extends core.Object {
2700 static _scheduleImmediate(callback) {
2701 dart.dcall(_AsyncRun.scheduleImmediateClosure, callback);
2702 }
2703 static _initializeScheduleImmediate() {
2704 if (self.scheduleImmediate != null) {
2705 return _AsyncRun._scheduleImmediateJsOverride;
2706 }
2707 if (self.MutationObserver != null && self.document != null) {
2708 let div = self.document.createElement("div");
2709 let span = self.document.createElement("span");
2710 let storedCallback = null;
2711 function internalCallback(_) {
2712 _isolate_helper.leaveJsAsync();
2713 let f = storedCallback;
2714 storedCallback = null;
2715 dart.dcall(f);
2716 }
2717 dart.fn(internalCallback);
2718 ;
2719 let observer = new self.MutationObserver(internalCallback);
2720 observer.observe(div, {childList: true});
2721 return dart.fn(callback => {
2722 dart.assert(storedCallback == null);
2723 _isolate_helper.enterJsAsync();
2724 storedCallback = callback;
2725 div.firstChild ? div.removeChild(span) : div.appendChild(span);
2726 }, dart.dynamic, [dart.functionType(dart.void, [])]);
2727 } else if (self.setImmediate != null) {
2728 return _AsyncRun._scheduleImmediateWithSetImmediate;
2729 }
2730 return _AsyncRun._scheduleImmediateWithTimer;
2731 }
2732 static _scheduleImmediateJsOverride(callback) {
2733 function internalCallback() {
2734 _isolate_helper.leaveJsAsync();
2735 callback();
2736 }
2737 dart.fn(internalCallback);
2738 ;
2739 _isolate_helper.enterJsAsync();
2740 self.scheduleImmediate(internalCallback);
2741 }
2742 static _scheduleImmediateWithSetImmediate(callback) {
2743 function internalCallback() {
2744 _isolate_helper.leaveJsAsync();
2745 callback();
2746 }
2747 dart.fn(internalCallback);
2748 ;
2749 _isolate_helper.enterJsAsync();
2750 self.setImmediate(internalCallback);
2751 }
2752 static _scheduleImmediateWithTimer(callback) {
2753 Timer._createTimer(core.Duration.ZERO, callback);
2754 }
2755 }
2756 dart.setSignature(_AsyncRun, {
2757 statics: () => ({
2758 _scheduleImmediate: [dart.void, [dart.functionType(dart.void, [])]],
2759 _initializeScheduleImmediate: [core.Function, []],
2760 _scheduleImmediateJsOverride: [dart.void, [dart.functionType(dart.void, [] )]],
2761 _scheduleImmediateWithSetImmediate: [dart.void, [dart.functionType(dart.vo id, [])]],
2762 _scheduleImmediateWithTimer: [dart.void, [dart.functionType(dart.void, []) ]]
2763 }),
2764 names: ['_scheduleImmediate', '_initializeScheduleImmediate', '_scheduleImme diateJsOverride', '_scheduleImmediateWithSetImmediate', '_scheduleImmediateWithT imer']
2765 });
2766 dart.defineLazyProperties(_AsyncRun, {
2767 get scheduleImmediateClosure() {
2768 return _AsyncRun._initializeScheduleImmediate();
2769 }
2770 });
2771 const StreamSubscription$ = dart.generic(function(T) {
2772 class StreamSubscription extends core.Object {}
2773 return StreamSubscription;
2774 });
2775 let StreamSubscription = StreamSubscription$();
2776 const EventSink$ = dart.generic(function(T) {
2777 class EventSink extends core.Object {}
2778 EventSink[dart.implements] = () => [core.Sink$(T)];
2779 return EventSink;
2780 });
2781 let EventSink = EventSink$();
2782 const _stream = Symbol('_stream');
2783 const StreamView$ = dart.generic(function(T) {
2784 class StreamView extends Stream$(T) {
2785 StreamView(stream) {
2786 this[_stream] = stream;
2787 super.Stream();
2788 }
2789 get isBroadcast() {
2790 return this[_stream].isBroadcast;
2791 }
2792 asBroadcastStream(opts) {
2793 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2794 dart.as(onListen, dart.functionType(dart.void, [StreamSubscription$(T)]) );
2795 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2796 dart.as(onCancel, dart.functionType(dart.void, [StreamSubscription$(T)]) );
2797 return this[_stream].asBroadcastStream({onListen: onListen, onCancel: on Cancel});
2798 }
2799 listen(onData, opts) {
2800 dart.as(onData, dart.functionType(dart.void, [T]));
2801 let onError = opts && 'onError' in opts ? opts.onError : null;
2802 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
2803 dart.as(onDone, dart.functionType(dart.void, []));
2804 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
2805 return this[_stream].listen(onData, {onError: onError, onDone: onDone, c ancelOnError: cancelOnError});
2806 }
2807 }
2808 dart.setSignature(StreamView, {
2809 constructors: () => ({StreamView: [StreamView$(T), [Stream$(T)]]}),
2810 methods: () => ({
2811 asBroadcastStream: [Stream$(T), [], {onListen: dart.functionType(dart.vo id, [StreamSubscription$(T)]), onCancel: dart.functionType(dart.void, [StreamSub scription$(T)])}],
2812 listen: [StreamSubscription$(T), [dart.functionType(dart.void, [T])], {o nError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}]
2813 })
2814 });
2815 return StreamView;
2816 });
2817 let StreamView = StreamView$();
2818 const StreamConsumer$ = dart.generic(function(S) {
2819 class StreamConsumer extends core.Object {}
2820 return StreamConsumer;
2821 });
2822 let StreamConsumer = StreamConsumer$();
2823 const StreamSink$ = dart.generic(function(S) {
2824 class StreamSink extends core.Object {}
2825 StreamSink[dart.implements] = () => [StreamConsumer$(S), EventSink$(S)];
2826 return StreamSink;
2827 });
2828 let StreamSink = StreamSink$();
2829 const StreamTransformer$ = dart.generic(function(S, T) {
2830 class StreamTransformer extends core.Object {
2831 static new(transformer) {
2832 return new (_StreamSubscriptionTransformer$(S, T))(transformer);
2833 }
2834 static fromHandlers(opts) {
2835 return new (_StreamHandlerTransformer$(S, T))(opts);
2836 }
2837 }
2838 dart.setSignature(StreamTransformer, {
2839 constructors: () => ({
2840 new: [StreamTransformer$(S, T), [dart.functionType(StreamSubscription$(T ), [Stream$(S), core.bool])]],
2841 fromHandlers: [StreamTransformer$(S, T), [], {handleData: dart.functionT ype(dart.void, [S, EventSink$(T)]), handleError: dart.functionType(dart.void, [c ore.Object, core.StackTrace, EventSink$(T)]), handleDone: dart.functionType(dart .void, [EventSink$(T)])}]
2842 })
2843 });
2844 return StreamTransformer;
2845 });
2846 let StreamTransformer = StreamTransformer$();
2847 const StreamIterator$ = dart.generic(function(T) {
2848 class StreamIterator extends core.Object {
2849 static new(stream) {
2850 return new (_StreamIteratorImpl$(T))(stream);
2851 }
2852 }
2853 dart.setSignature(StreamIterator, {
2854 constructors: () => ({new: [StreamIterator$(T), [Stream$(T)]]})
2855 });
2856 return StreamIterator;
2857 });
2858 let StreamIterator = StreamIterator$();
2859 const _ControllerEventSinkWrapper$ = dart.generic(function(T) {
2860 class _ControllerEventSinkWrapper extends core.Object {
2861 _ControllerEventSinkWrapper(sink) {
2862 this[_sink] = sink;
2863 }
2864 add(data) {
2865 dart.as(data, T);
2866 this[_sink].add(data);
2867 }
2868 addError(error, stackTrace) {
2869 if (stackTrace === void 0) stackTrace = null;
2870 this[_sink].addError(error, stackTrace);
2871 }
2872 close() {
2873 this[_sink].close();
2874 }
2875 }
2876 _ControllerEventSinkWrapper[dart.implements] = () => [EventSink$(T)];
2877 dart.setSignature(_ControllerEventSinkWrapper, {
2878 constructors: () => ({_ControllerEventSinkWrapper: [_ControllerEventSinkWr apper$(T), [EventSink]]}),
2879 methods: () => ({
2880 add: [dart.void, [T]],
2881 addError: [dart.void, [dart.dynamic], [core.StackTrace]],
2882 close: [dart.void, []]
2883 })
2884 });
2885 return _ControllerEventSinkWrapper;
2886 });
2887 let _ControllerEventSinkWrapper = _ControllerEventSinkWrapper$();
2888 const StreamController$ = dart.generic(function(T) {
2889 class StreamController extends core.Object {
2890 static new(opts) {
2891 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2892 let onPause = opts && 'onPause' in opts ? opts.onPause : null;
2893 let onResume = opts && 'onResume' in opts ? opts.onResume : null;
2894 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2895 let sync = opts && 'sync' in opts ? opts.sync : false;
2896 if (onListen == null && onPause == null && onResume == null && onCancel == null) {
2897 return dart.notNull(sync) ? new (_NoCallbackSyncStreamController$(T))( ) : new (_NoCallbackAsyncStreamController$(T))();
2898 }
2899 return dart.notNull(sync) ? new (_SyncStreamController$(T))(onListen, on Pause, onResume, onCancel) : new (_AsyncStreamController$(T))(onListen, onPause, onResume, onCancel);
2900 }
2901 static broadcast(opts) {
2902 let onListen = opts && 'onListen' in opts ? opts.onListen : null;
2903 let onCancel = opts && 'onCancel' in opts ? opts.onCancel : null;
2904 let sync = opts && 'sync' in opts ? opts.sync : false;
2905 return dart.notNull(sync) ? new (_SyncBroadcastStreamController$(T))(onL isten, onCancel) : new (_AsyncBroadcastStreamController$(T))(onListen, onCancel) ;
2906 }
2907 }
2908 StreamController[dart.implements] = () => [StreamSink$(T)];
2909 dart.setSignature(StreamController, {
2910 constructors: () => ({
2911 new: [StreamController$(T), [], {onListen: dart.functionType(dart.void, []), onPause: dart.functionType(dart.void, []), onResume: dart.functionType(dart .void, []), onCancel: dart.functionType(dart.dynamic, []), sync: core.bool}],
2912 broadcast: [StreamController$(T), [], {onListen: dart.functionType(dart. void, []), onCancel: dart.functionType(dart.void, []), sync: core.bool}]
2913 })
2914 });
2915 return StreamController;
2916 });
2917 let StreamController = StreamController$();
2918 const _StreamControllerLifecycle$ = dart.generic(function(T) {
2919 class _StreamControllerLifecycle extends core.Object {
2920 [_recordPause](subscription) {
2921 dart.as(subscription, StreamSubscription$(T));
2922 }
2923 [_recordResume](subscription) {
2924 dart.as(subscription, StreamSubscription$(T));
2925 }
2926 [_recordCancel](subscription) {
2927 dart.as(subscription, StreamSubscription$(T));
2928 return null;
2929 }
2930 }
2931 dart.setSignature(_StreamControllerLifecycle, {
2932 methods: () => ({
2933 [_recordPause]: [dart.void, [StreamSubscription$(T)]],
2934 [_recordResume]: [dart.void, [StreamSubscription$(T)]],
2935 [_recordCancel]: [Future, [StreamSubscription$(T)]]
2936 })
2937 });
2938 return _StreamControllerLifecycle;
2939 });
2940 let _StreamControllerLifecycle = _StreamControllerLifecycle$();
2941 const _varData = Symbol('_varData');
2942 const _isInitialState = Symbol('_isInitialState');
2943 const _subscription = Symbol('_subscription');
2944 const _pendingEvents = Symbol('_pendingEvents');
2945 const _ensurePendingEvents = Symbol('_ensurePendingEvents');
2946 const _badEventState = Symbol('_badEventState');
2947 const _StreamController$ = dart.generic(function(T) {
2948 class _StreamController extends core.Object {
2949 _StreamController() {
2950 this[_varData] = null;
2951 this[_state] = _StreamController$()._STATE_INITIAL;
2952 this[_doneFuture] = null;
2953 }
2954 get stream() {
2955 return new (_ControllerStream$(T))(this);
2956 }
2957 get sink() {
2958 return new (_StreamSinkWrapper$(T))(this);
2959 }
2960 get [_isCanceled]() {
2961 return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._ STATE_CANCELED)) != 0;
2962 }
2963 get hasListener() {
2964 return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._ STATE_SUBSCRIBED)) != 0;
2965 }
2966 get [_isInitialState]() {
2967 return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._ STATE_SUBSCRIPTION_MASK)) == _StreamController$()._STATE_INITIAL;
2968 }
2969 get isClosed() {
2970 return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._ STATE_CLOSED)) != 0;
2971 }
2972 get isPaused() {
2973 return dart.notNull(this.hasListener) ? this[_subscription][_isInputPaus ed] : !dart.notNull(this[_isCanceled]);
2974 }
2975 get [_isAddingStream]() {
2976 return (dart.notNull(this[_state]) & dart.notNull(_StreamController$()._ STATE_ADDSTREAM)) != 0;
2977 }
2978 get [_mayAddEvent]() {
2979 return dart.notNull(this[_state]) < dart.notNull(_StreamController$()._S TATE_CLOSED);
2980 }
2981 get [_pendingEvents]() {
2982 dart.assert(this[_isInitialState]);
2983 if (!dart.notNull(this[_isAddingStream])) {
2984 return dart.as(this[_varData], _PendingEvents);
2985 }
2986 let state = dart.as(this[_varData], _StreamControllerAddStreamState);
2987 return dart.as(state.varData, _PendingEvents);
2988 }
2989 [_ensurePendingEvents]() {
2990 dart.assert(this[_isInitialState]);
2991 if (!dart.notNull(this[_isAddingStream])) {
2992 if (this[_varData] == null) this[_varData] = new _StreamImplEvents();
2993 return dart.as(this[_varData], _StreamImplEvents);
2994 }
2995 let state = dart.as(this[_varData], _StreamControllerAddStreamState);
2996 if (state.varData == null) state.varData = new _StreamImplEvents();
2997 return dart.as(state.varData, _StreamImplEvents);
2998 }
2999 get [_subscription]() {
3000 dart.assert(this.hasListener);
3001 if (dart.notNull(this[_isAddingStream])) {
3002 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3003 return dart.as(addState.varData, _ControllerSubscription);
3004 }
3005 return dart.as(this[_varData], _ControllerSubscription);
3006 }
3007 [_badEventState]() {
3008 if (dart.notNull(this.isClosed)) {
3009 return new core.StateError("Cannot add event after closing");
3010 }
3011 dart.assert(this[_isAddingStream]);
3012 return new core.StateError("Cannot add event while adding a stream");
3013 }
3014 addStream(source, opts) {
3015 dart.as(source, Stream$(T));
3016 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
3017 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_badEventState]() );
3018 if (dart.notNull(this[_isCanceled])) return new _Future.immediate(null);
3019 let addState = new _StreamControllerAddStreamState(this, this[_varData], source, cancelOnError);
3020 this[_varData] = addState;
3021 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er$()._STATE_ADDSTREAM);
3022 return addState.addStreamFuture;
3023 }
3024 get done() {
3025 return this[_ensureDoneFuture]();
3026 }
3027 [_ensureDoneFuture]() {
3028 if (this[_doneFuture] == null) {
3029 this[_doneFuture] = dart.notNull(this[_isCanceled]) ? Future._nullFutu re : new _Future();
3030 }
3031 return this[_doneFuture];
3032 }
3033 add(value) {
3034 dart.as(value, T);
3035 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_badEventState]() );
3036 this[_add](value);
3037 }
3038 addError(error, stackTrace) {
3039 if (stackTrace === void 0) stackTrace = null;
3040 error = _nonNullError(error);
3041 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_badEventState]() );
3042 let replacement = Zone.current.errorCallback(error, stackTrace);
3043 if (replacement != null) {
3044 error = _nonNullError(replacement.error);
3045 stackTrace = replacement.stackTrace;
3046 }
3047 this[_addError](error, stackTrace);
3048 }
3049 close() {
3050 if (dart.notNull(this.isClosed)) {
3051 return this[_ensureDoneFuture]();
3052 }
3053 if (!dart.notNull(this[_mayAddEvent])) dart.throw(this[_badEventState]() );
3054 this[_closeUnchecked]();
3055 return this[_ensureDoneFuture]();
3056 }
3057 [_closeUnchecked]() {
3058 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er$()._STATE_CLOSED);
3059 if (dart.notNull(this.hasListener)) {
3060 this[_sendDone]();
3061 } else if (dart.notNull(this[_isInitialState])) {
3062 this[_ensurePendingEvents]().add(dart.const(new _DelayedDone()));
3063 }
3064 }
3065 [_add](value) {
3066 dart.as(value, T);
3067 if (dart.notNull(this.hasListener)) {
3068 this[_sendData](value);
3069 } else if (dart.notNull(this[_isInitialState])) {
3070 this[_ensurePendingEvents]().add(new (_DelayedData$(T))(value));
3071 }
3072 }
3073 [_addError](error, stackTrace) {
3074 if (dart.notNull(this.hasListener)) {
3075 this[_sendError](error, stackTrace);
3076 } else if (dart.notNull(this[_isInitialState])) {
3077 this[_ensurePendingEvents]().add(new _DelayedError(error, stackTrace)) ;
3078 }
3079 }
3080 [_close]() {
3081 dart.assert(this[_isAddingStream]);
3082 let addState = dart.as(this[_varData], _StreamControllerAddStreamState);
3083 this[_varData] = addState.varData;
3084 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_StreamControl ler$()._STATE_ADDSTREAM);
3085 addState.complete();
3086 }
3087 [_subscribe](onData, onError, onDone, cancelOnError) {
3088 dart.as(onData, dart.functionType(dart.void, [T]));
3089 dart.as(onDone, dart.functionType(dart.void, []));
3090 if (!dart.notNull(this[_isInitialState])) {
3091 dart.throw(new core.StateError("Stream has already been listened to.") );
3092 }
3093 let subscription = new _ControllerSubscription(this, onData, onError, on Done, cancelOnError);
3094 let pendingEvents = this[_pendingEvents];
3095 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er$()._STATE_SUBSCRIBED);
3096 if (dart.notNull(this[_isAddingStream])) {
3097 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3098 addState.varData = subscription;
3099 addState.resume();
3100 } else {
3101 this[_varData] = subscription;
3102 }
3103 subscription[_setPendingEvents](pendingEvents);
3104 subscription[_guardCallback](dart.fn(() => {
3105 _runGuarded(this[_onListen]);
3106 }));
3107 return dart.as(subscription, StreamSubscription$(T));
3108 }
3109 [_recordCancel](subscription) {
3110 dart.as(subscription, StreamSubscription$(T));
3111 let result = null;
3112 if (dart.notNull(this[_isAddingStream])) {
3113 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3114 result = addState.cancel();
3115 }
3116 this[_varData] = null;
3117 this[_state] = dart.notNull(this[_state]) & ~(dart.notNull(_StreamContro ller$()._STATE_SUBSCRIBED) | dart.notNull(_StreamController$()._STATE_ADDSTREAM) ) | dart.notNull(_StreamController$()._STATE_CANCELED);
3118 if (this[_onCancel] != null) {
3119 if (result == null) {
3120 try {
3121 result = dart.as(this[_onCancel](), Future);
3122 } catch (e) {
3123 let s = dart.stackTrace(e);
3124 result = new _Future();
3125 result[_asyncCompleteError](e, s);
3126 }
3127
3128 } else {
3129 result = result.whenComplete(this[_onCancel]);
3130 }
3131 }
3132 const complete = (function() {
3133 if (this[_doneFuture] != null && dart.notNull(this[_doneFuture][_mayCo mplete])) {
3134 this[_doneFuture][_asyncComplete](null);
3135 }
3136 }).bind(this);
3137 dart.fn(complete, dart.void, []);
3138 if (result != null) {
3139 result = result.whenComplete(complete);
3140 } else {
3141 complete();
3142 }
3143 return result;
3144 }
3145 [_recordPause](subscription) {
3146 dart.as(subscription, StreamSubscription$(T));
3147 if (dart.notNull(this[_isAddingStream])) {
3148 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3149 addState.pause();
3150 }
3151 _runGuarded(this[_onPause]);
3152 }
3153 [_recordResume](subscription) {
3154 dart.as(subscription, StreamSubscription$(T));
3155 if (dart.notNull(this[_isAddingStream])) {
3156 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3157 addState.resume();
3158 }
3159 _runGuarded(this[_onResume]);
3160 }
3161 }
3162 _StreamController[dart.implements] = () => [StreamController$(T), _StreamCon trollerLifecycle$(T), _EventSink$(T), _EventDispatch$(T)];
3163 dart.setSignature(_StreamController, {
3164 constructors: () => ({_StreamController: [_StreamController$(T), []]}),
3165 methods: () => ({
3166 [_ensurePendingEvents]: [_StreamImplEvents, []],
3167 [_badEventState]: [core.Error, []],
3168 addStream: [Future, [Stream$(T)], {cancelOnError: core.bool}],
3169 [_ensureDoneFuture]: [Future, []],
3170 add: [dart.void, [T]],
3171 addError: [dart.void, [core.Object], [core.StackTrace]],
3172 close: [Future, []],
3173 [_closeUnchecked]: [dart.void, []],
3174 [_add]: [dart.void, [T]],
3175 [_addError]: [dart.void, [core.Object, core.StackTrace]],
3176 [_close]: [dart.void, []],
3177 [_subscribe]: [StreamSubscription$(T), [dart.functionType(dart.void, [T] ), core.Function, dart.functionType(dart.void, []), core.bool]],
3178 [_recordCancel]: [Future, [StreamSubscription$(T)]],
3179 [_recordPause]: [dart.void, [StreamSubscription$(T)]],
3180 [_recordResume]: [dart.void, [StreamSubscription$(T)]]
3181 })
3182 });
3183 _StreamController._STATE_INITIAL = 0;
3184 _StreamController._STATE_SUBSCRIBED = 1;
3185 _StreamController._STATE_CANCELED = 2;
3186 _StreamController._STATE_SUBSCRIPTION_MASK = 3;
3187 _StreamController._STATE_CLOSED = 4;
3188 _StreamController._STATE_ADDSTREAM = 8;
3189 return _StreamController;
3190 });
3191 let _StreamController = _StreamController$();
3192 const _SyncStreamControllerDispatch$ = dart.generic(function(T) {
3193 class _SyncStreamControllerDispatch extends core.Object {
3194 [_sendData](data) {
3195 dart.as(data, T);
3196 this[_subscription][_add](data);
3197 }
3198 [_sendError](error, stackTrace) {
3199 this[_subscription][_addError](error, stackTrace);
3200 }
3201 [_sendDone]() {
3202 this[_subscription][_close]();
3203 }
3204 }
3205 _SyncStreamControllerDispatch[dart.implements] = () => [_StreamController$(T )];
3206 dart.setSignature(_SyncStreamControllerDispatch, {
3207 methods: () => ({
3208 [_sendData]: [dart.void, [T]],
3209 [_sendError]: [dart.void, [core.Object, core.StackTrace]],
3210 [_sendDone]: [dart.void, []]
3211 })
3212 });
3213 return _SyncStreamControllerDispatch;
3214 });
3215 let _SyncStreamControllerDispatch = _SyncStreamControllerDispatch$();
3216 const _AsyncStreamControllerDispatch$ = dart.generic(function(T) {
3217 class _AsyncStreamControllerDispatch extends core.Object {
3218 [_sendData](data) {
3219 dart.as(data, T);
3220 this[_subscription][_addPending](new _DelayedData(data));
3221 }
3222 [_sendError](error, stackTrace) {
3223 this[_subscription][_addPending](new _DelayedError(error, stackTrace));
3224 }
3225 [_sendDone]() {
3226 this[_subscription][_addPending](dart.const(new _DelayedDone()));
3227 }
3228 }
3229 _AsyncStreamControllerDispatch[dart.implements] = () => [_StreamController$( T)];
3230 dart.setSignature(_AsyncStreamControllerDispatch, {
3231 methods: () => ({
3232 [_sendData]: [dart.void, [T]],
3233 [_sendError]: [dart.void, [core.Object, core.StackTrace]],
3234 [_sendDone]: [dart.void, []]
3235 })
3236 });
3237 return _AsyncStreamControllerDispatch;
3238 });
3239 let _AsyncStreamControllerDispatch = _AsyncStreamControllerDispatch$();
3240 const _AsyncStreamController$ = dart.generic(function(T) {
3241 class _AsyncStreamController extends dart.mixin(_StreamController$(T), _Asyn cStreamControllerDispatch$(T)) {
3242 _AsyncStreamController(onListen, onPause, onResume, onCancel) {
3243 this[_onListen] = onListen;
3244 this[_onPause] = onPause;
3245 this[_onResume] = onResume;
3246 this[_onCancel] = onCancel;
3247 super._StreamController();
3248 }
3249 }
3250 dart.setSignature(_AsyncStreamController, {
3251 constructors: () => ({_AsyncStreamController: [_AsyncStreamController$(T), [dart.functionType(dart.void, []), dart.functionType(dart.void, []), dart.funct ionType(dart.void, []), dart.functionType(dart.dynamic, [])]]})
3252 });
3253 return _AsyncStreamController;
3254 });
3255 let _AsyncStreamController = _AsyncStreamController$();
3256 const _SyncStreamController$ = dart.generic(function(T) {
3257 class _SyncStreamController extends dart.mixin(_StreamController$(T), _SyncS treamControllerDispatch$(T)) {
3258 _SyncStreamController(onListen, onPause, onResume, onCancel) {
3259 this[_onListen] = onListen;
3260 this[_onPause] = onPause;
3261 this[_onResume] = onResume;
3262 this[_onCancel] = onCancel;
3263 super._StreamController();
3264 }
3265 }
3266 dart.setSignature(_SyncStreamController, {
3267 constructors: () => ({_SyncStreamController: [_SyncStreamController$(T), [ dart.functionType(dart.void, []), dart.functionType(dart.void, []), dart.functio nType(dart.void, []), dart.functionType(dart.dynamic, [])]]})
3268 });
3269 return _SyncStreamController;
3270 });
3271 let _SyncStreamController = _SyncStreamController$();
3272 class _NoCallbacks extends core.Object {
3273 get [_onListen]() {
3274 return null;
3275 }
3276 get [_onPause]() {
3277 return null;
3278 }
3279 get [_onResume]() {
3280 return null;
3281 }
3282 get [_onCancel]() {
3283 return null;
3284 }
3285 }
3286 const _NoCallbackAsyncStreamController$ = dart.generic(function(T) {
3287 class _NoCallbackAsyncStreamController extends dart.mixin(_StreamController$ (T), _AsyncStreamControllerDispatch$(T), _NoCallbacks) {
3288 _NoCallbackAsyncStreamController() {
3289 super._StreamController(...arguments);
3290 }
3291 }
3292 return _NoCallbackAsyncStreamController;
3293 });
3294 let _NoCallbackAsyncStreamController = _NoCallbackAsyncStreamController$();
3295 const _NoCallbackSyncStreamController$ = dart.generic(function(T) {
3296 class _NoCallbackSyncStreamController extends dart.mixin(_StreamController$( T), _SyncStreamControllerDispatch$(T), _NoCallbacks) {
3297 _NoCallbackSyncStreamController() {
3298 super._StreamController(...arguments);
3299 }
3300 }
3301 return _NoCallbackSyncStreamController;
3302 });
3303 let _NoCallbackSyncStreamController = _NoCallbackSyncStreamController$();
3304 const _NotificationHandler = dart.typedef('_NotificationHandler', () => dart.f unctionType(dart.dynamic, []));
3305 function _runGuarded(notificationHandler) {
3306 if (notificationHandler == null) return null;
3307 try {
3308 let result = notificationHandler();
3309 if (dart.is(result, Future)) return result;
3310 return null;
3311 } catch (e) {
3312 let s = dart.stackTrace(e);
3313 Zone.current.handleUncaughtError(e, s);
3314 }
3315
3316 }
3317 dart.fn(_runGuarded, Future, [_NotificationHandler]);
3318 const _target = Symbol('_target');
3319 const _StreamSinkWrapper$ = dart.generic(function(T) {
3320 class _StreamSinkWrapper extends core.Object {
3321 _StreamSinkWrapper(target) {
3322 this[_target] = target;
3323 }
3324 add(data) {
3325 dart.as(data, T);
3326 this[_target].add(data);
3327 }
3328 addError(error, stackTrace) {
3329 if (stackTrace === void 0) stackTrace = null;
3330 this[_target].addError(error, stackTrace);
3331 }
3332 close() {
3333 return this[_target].close();
3334 }
3335 addStream(source, opts) {
3336 dart.as(source, Stream$(T));
3337 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : true;
3338 return this[_target].addStream(source, {cancelOnError: cancelOnError});
3339 }
3340 get done() {
3341 return this[_target].done;
3342 }
3343 }
3344 _StreamSinkWrapper[dart.implements] = () => [StreamSink$(T)];
3345 dart.setSignature(_StreamSinkWrapper, {
3346 constructors: () => ({_StreamSinkWrapper: [_StreamSinkWrapper$(T), [Stream Controller]]}),
3347 methods: () => ({
3348 add: [dart.void, [T]],
3349 addError: [dart.void, [core.Object], [core.StackTrace]],
3350 close: [Future, []],
3351 addStream: [Future, [Stream$(T)], {cancelOnError: core.bool}]
3352 })
3353 });
3354 return _StreamSinkWrapper;
3355 });
3356 let _StreamSinkWrapper = _StreamSinkWrapper$();
3357 const _AddStreamState$ = dart.generic(function(T) {
3358 class _AddStreamState extends core.Object {
3359 _AddStreamState(controller, source, cancelOnError) {
3360 this.addStreamFuture = new _Future();
3361 this.addSubscription = source.listen(dart.bind(controller, _add), {onErr or: dart.as(dart.notNull(cancelOnError) ? _AddStreamState$().makeErrorHandler(co ntroller) : dart.bind(controller, _addError), core.Function), onDone: dart.bind( controller, _close), cancelOnError: cancelOnError});
3362 }
3363 static makeErrorHandler(controller) {
3364 return dart.fn((e, s) => {
3365 controller[_addError](e, s);
3366 controller[_close]();
3367 }, dart.dynamic, [dart.dynamic, core.StackTrace]);
3368 }
3369 pause() {
3370 this.addSubscription.pause();
3371 }
3372 resume() {
3373 this.addSubscription.resume();
3374 }
3375 cancel() {
3376 let cancel2 = this.addSubscription.cancel();
3377 if (cancel2 == null) {
3378 this.addStreamFuture[_asyncComplete](null);
3379 return null;
3380 }
3381 return cancel2.whenComplete(dart.fn(() => {
3382 this.addStreamFuture[_asyncComplete](null);
3383 }));
3384 }
3385 complete() {
3386 this.addStreamFuture[_asyncComplete](null);
3387 }
3388 }
3389 dart.setSignature(_AddStreamState, {
3390 constructors: () => ({_AddStreamState: [_AddStreamState$(T), [_EventSink$( T), Stream, core.bool]]}),
3391 methods: () => ({
3392 pause: [dart.void, []],
3393 resume: [dart.void, []],
3394 cancel: [Future, []],
3395 complete: [dart.void, []]
3396 }),
3397 statics: () => ({makeErrorHandler: [dart.dynamic, [_EventSink]]}),
3398 names: ['makeErrorHandler']
3399 });
3400 return _AddStreamState;
3401 });
3402 let _AddStreamState = _AddStreamState$();
3403 const _StreamControllerAddStreamState$ = dart.generic(function(T) {
3404 class _StreamControllerAddStreamState extends _AddStreamState$(T) {
3405 _StreamControllerAddStreamState(controller, varData, source, cancelOnError ) {
3406 this.varData = varData;
3407 super._AddStreamState(dart.as(controller, _EventSink$(T)), source, cance lOnError);
3408 if (dart.notNull(controller.isPaused)) {
3409 this.addSubscription.pause();
3410 }
3411 }
3412 }
3413 dart.setSignature(_StreamControllerAddStreamState, {
3414 constructors: () => ({_StreamControllerAddStreamState: [_StreamControllerA ddStreamState$(T), [_StreamController, dart.dynamic, Stream, core.bool]]})
3415 });
3416 return _StreamControllerAddStreamState;
3417 });
3418 let _StreamControllerAddStreamState = _StreamControllerAddStreamState$();
3419 const _EventSink$ = dart.generic(function(T) {
3420 class _EventSink extends core.Object {}
3421 return _EventSink;
3422 });
3423 let _EventSink = _EventSink$();
3424 const _EventDispatch$ = dart.generic(function(T) {
3425 class _EventDispatch extends core.Object {}
3426 return _EventDispatch;
3427 });
3428 let _EventDispatch = _EventDispatch$();
3429 const _EventGenerator = dart.typedef('_EventGenerator', () => dart.functionTyp e(_PendingEvents, []));
3430 const _isUsed = Symbol('_isUsed');
3431 const _GeneratedStreamImpl$ = dart.generic(function(T) {
3432 class _GeneratedStreamImpl extends _StreamImpl$(T) {
3433 _GeneratedStreamImpl(pending) {
3434 this[_pending] = pending;
3435 this[_isUsed] = false;
3436 }
3437 [_createSubscription](onData, onError, onDone, cancelOnError) {
3438 dart.as(onData, dart.functionType(dart.void, [T]));
3439 dart.as(onDone, dart.functionType(dart.void, []));
3440 if (dart.notNull(this[_isUsed])) dart.throw(new core.StateError("Stream has already been listened to."));
3441 this[_isUsed] = true;
3442 let _ = new (_BufferingStreamSubscription$(T))(onData, onError, onDone, cancelOnError);
3443 _[_setPendingEvents](this[_pending]());
3444 return _;
3445 }
3446 }
3447 dart.setSignature(_GeneratedStreamImpl, {
3448 constructors: () => ({_GeneratedStreamImpl: [_GeneratedStreamImpl$(T), [_E ventGenerator]]}),
3449 methods: () => ({[_createSubscription]: [StreamSubscription$(T), [dart.fun ctionType(dart.void, [T]), core.Function, dart.functionType(dart.void, []), core .bool]]})
3450 });
3451 return _GeneratedStreamImpl;
3452 });
3453 let _GeneratedStreamImpl = _GeneratedStreamImpl$();
3454 const _iterator = Symbol('_iterator');
3455 const _eventScheduled = Symbol('_eventScheduled');
3456 class _PendingEvents extends core.Object {
3457 _PendingEvents() {
3458 this[_state] = _PendingEvents._STATE_UNSCHEDULED;
3459 }
3460 get isScheduled() {
3461 return this[_state] == _PendingEvents._STATE_SCHEDULED;
3462 }
3463 get [_eventScheduled]() {
3464 return dart.notNull(this[_state]) >= dart.notNull(_PendingEvents._STATE_SC HEDULED);
3465 }
3466 schedule(dispatch) {
3467 if (dart.notNull(this.isScheduled)) return;
3468 dart.assert(!dart.notNull(this.isEmpty));
3469 if (dart.notNull(this[_eventScheduled])) {
3470 dart.assert(this[_state] == _PendingEvents._STATE_CANCELED);
3471 this[_state] = _PendingEvents._STATE_SCHEDULED;
3472 return;
3473 }
3474 scheduleMicrotask(dart.fn(() => {
3475 let oldState = this[_state];
3476 this[_state] = _PendingEvents._STATE_UNSCHEDULED;
3477 if (oldState == _PendingEvents._STATE_CANCELED) return;
3478 this.handleNext(dispatch);
3479 }, dart.void, []));
3480 this[_state] = _PendingEvents._STATE_SCHEDULED;
3481 }
3482 cancelSchedule() {
3483 if (dart.notNull(this.isScheduled)) this[_state] = _PendingEvents._STATE_C ANCELED;
3484 }
3485 }
3486 dart.setSignature(_PendingEvents, {
3487 methods: () => ({
3488 schedule: [dart.void, [_EventDispatch]],
3489 cancelSchedule: [dart.void, []]
3490 })
3491 });
3492 _PendingEvents._STATE_UNSCHEDULED = 0;
3493 _PendingEvents._STATE_SCHEDULED = 1;
3494 _PendingEvents._STATE_CANCELED = 3;
3495 const _IterablePendingEvents$ = dart.generic(function(T) {
3496 class _IterablePendingEvents extends _PendingEvents {
3497 _IterablePendingEvents(data) {
3498 this[_iterator] = data[dartx.iterator];
3499 super._PendingEvents();
3500 }
3501 get isEmpty() {
3502 return this[_iterator] == null;
3503 }
3504 handleNext(dispatch) {
3505 if (this[_iterator] == null) {
3506 dart.throw(new core.StateError("No events pending."));
3507 }
3508 let isDone = null;
3509 try {
3510 isDone = !dart.notNull(this[_iterator].moveNext());
3511 } catch (e) {
3512 let s = dart.stackTrace(e);
3513 this[_iterator] = null;
3514 dispatch[_sendError](e, s);
3515 return;
3516 }
3517
3518 if (!dart.notNull(isDone)) {
3519 dispatch[_sendData](this[_iterator].current);
3520 } else {
3521 this[_iterator] = null;
3522 dispatch[_sendDone]();
3523 }
3524 }
3525 clear() {
3526 if (dart.notNull(this.isScheduled)) this.cancelSchedule();
3527 this[_iterator] = null;
3528 }
3529 }
3530 dart.setSignature(_IterablePendingEvents, {
3531 constructors: () => ({_IterablePendingEvents: [_IterablePendingEvents$(T), [core.Iterable$(T)]]}),
3532 methods: () => ({
3533 handleNext: [dart.void, [_EventDispatch]],
3534 clear: [dart.void, []]
3535 })
3536 });
3537 return _IterablePendingEvents;
3538 });
3539 let _IterablePendingEvents = _IterablePendingEvents$();
3540 const _DataHandler$ = dart.generic(function(T) {
3541 const _DataHandler = dart.typedef('_DataHandler', () => dart.functionType(da rt.void, [T]));
3542 return _DataHandler;
3543 });
3544 let _DataHandler = _DataHandler$();
3545 const _DoneHandler = dart.typedef('_DoneHandler', () => dart.functionType(dart .void, []));
3546 function _nullDataHandler(value) {
3547 }
3548 dart.fn(_nullDataHandler, dart.void, [dart.dynamic]);
3549 function _nullErrorHandler(error, stackTrace) {
3550 if (stackTrace === void 0) stackTrace = null;
3551 Zone.current.handleUncaughtError(error, stackTrace);
3552 }
3553 dart.fn(_nullErrorHandler, dart.void, [dart.dynamic], [core.StackTrace]);
3554 function _nullDoneHandler() {
3555 }
3556 dart.fn(_nullDoneHandler, dart.void, []);
3557 const _DelayedEvent$ = dart.generic(function(T) {
3558 class _DelayedEvent extends core.Object {
3559 _DelayedEvent() {
3560 this.next = null;
3561 }
3562 }
3563 return _DelayedEvent;
3564 });
3565 let _DelayedEvent = _DelayedEvent$();
3566 const _DelayedData$ = dart.generic(function(T) {
3567 class _DelayedData extends _DelayedEvent$(T) {
3568 _DelayedData(value) {
3569 this.value = value;
3570 super._DelayedEvent();
3571 }
3572 perform(dispatch) {
3573 dart.as(dispatch, _EventDispatch$(T));
3574 dispatch[_sendData](this.value);
3575 }
3576 }
3577 dart.setSignature(_DelayedData, {
3578 constructors: () => ({_DelayedData: [_DelayedData$(T), [T]]}),
3579 methods: () => ({perform: [dart.void, [_EventDispatch$(T)]]})
3580 });
3581 return _DelayedData;
3582 });
3583 let _DelayedData = _DelayedData$();
3584 class _DelayedError extends _DelayedEvent {
3585 _DelayedError(error, stackTrace) {
3586 this.error = error;
3587 this.stackTrace = stackTrace;
3588 super._DelayedEvent();
3589 }
3590 perform(dispatch) {
3591 dispatch[_sendError](this.error, this.stackTrace);
3592 }
3593 }
3594 dart.setSignature(_DelayedError, {
3595 constructors: () => ({_DelayedError: [_DelayedError, [dart.dynamic, core.Sta ckTrace]]}),
3596 methods: () => ({perform: [dart.void, [_EventDispatch]]})
3597 });
3598 class _DelayedDone extends core.Object {
3599 _DelayedDone() {
3600 }
3601 perform(dispatch) {
3602 dispatch[_sendDone]();
3603 }
3604 get next() {
3605 return null;
3606 }
3607 set next(_) {
3608 dart.throw(new core.StateError("No events after a done."));
3609 }
3610 }
3611 _DelayedDone[dart.implements] = () => [_DelayedEvent];
3612 dart.setSignature(_DelayedDone, {
3613 constructors: () => ({_DelayedDone: [_DelayedDone, []]}),
3614 methods: () => ({perform: [dart.void, [_EventDispatch]]})
3615 });
3616 class _StreamImplEvents extends _PendingEvents {
3617 _StreamImplEvents() {
3618 this.firstPendingEvent = null;
3619 this.lastPendingEvent = null;
3620 super._PendingEvents();
3621 }
3622 get isEmpty() {
3623 return this.lastPendingEvent == null;
3624 }
3625 add(event) {
3626 if (this.lastPendingEvent == null) {
3627 this.firstPendingEvent = this.lastPendingEvent = event;
3628 } else {
3629 this.lastPendingEvent = this.lastPendingEvent.next = event;
3630 }
3631 }
3632 handleNext(dispatch) {
3633 dart.assert(!dart.notNull(this.isScheduled));
3634 let event = this.firstPendingEvent;
3635 this.firstPendingEvent = event.next;
3636 if (this.firstPendingEvent == null) {
3637 this.lastPendingEvent = null;
3638 }
3639 event.perform(dispatch);
3640 }
3641 clear() {
3642 if (dart.notNull(this.isScheduled)) this.cancelSchedule();
3643 this.firstPendingEvent = this.lastPendingEvent = null;
3644 }
3645 }
3646 dart.setSignature(_StreamImplEvents, {
3647 methods: () => ({
3648 add: [dart.void, [_DelayedEvent]],
3649 handleNext: [dart.void, [_EventDispatch]],
3650 clear: [dart.void, []]
3651 })
3652 });
3653 const _unlink = Symbol('_unlink');
3654 const _insertBefore = Symbol('_insertBefore');
3655 class _BroadcastLinkedList extends core.Object {
3656 _BroadcastLinkedList() {
3657 this[_next] = null;
3658 this[_previous] = null;
3659 }
3660 [_unlink]() {
3661 this[_previous][_next] = this[_next];
3662 this[_next][_previous] = this[_previous];
3663 this[_next] = this[_previous] = this;
3664 }
3665 [_insertBefore](newNext) {
3666 let newPrevious = newNext[_previous];
3667 newPrevious[_next] = this;
3668 newNext[_previous] = this[_previous];
3669 this[_previous][_next] = newNext;
3670 this[_previous] = newPrevious;
3671 }
3672 }
3673 dart.setSignature(_BroadcastLinkedList, {
3674 methods: () => ({
3675 [_unlink]: [dart.void, []],
3676 [_insertBefore]: [dart.void, [_BroadcastLinkedList]]
3677 })
3678 });
3679 const _broadcastCallback = dart.typedef('_broadcastCallback', () => dart.funct ionType(dart.void, [StreamSubscription]));
3680 const _schedule = Symbol('_schedule');
3681 const _isSent = Symbol('_isSent');
3682 const _isScheduled = Symbol('_isScheduled');
3683 const _DoneStreamSubscription$ = dart.generic(function(T) {
3684 class _DoneStreamSubscription extends core.Object {
3685 _DoneStreamSubscription(onDone) {
3686 this[_onDone] = onDone;
3687 this[_zone] = Zone.current;
3688 this[_state] = 0;
3689 this[_schedule]();
3690 }
3691 get [_isSent]() {
3692 return (dart.notNull(this[_state]) & dart.notNull(_DoneStreamSubscriptio n$()._DONE_SENT)) != 0;
3693 }
3694 get [_isScheduled]() {
3695 return (dart.notNull(this[_state]) & dart.notNull(_DoneStreamSubscriptio n$()._SCHEDULED)) != 0;
3696 }
3697 get isPaused() {
3698 return dart.notNull(this[_state]) >= dart.notNull(_DoneStreamSubscriptio n$()._PAUSED);
3699 }
3700 [_schedule]() {
3701 if (dart.notNull(this[_isScheduled])) return;
3702 this[_zone].scheduleMicrotask(dart.bind(this, _sendDone));
3703 this[_state] = dart.notNull(this[_state]) | dart.notNull(_DoneStreamSubs cription$()._SCHEDULED);
3704 }
3705 onData(handleData) {
3706 dart.as(handleData, dart.functionType(dart.void, [T]));
3707 }
3708 onError(handleError) {}
3709 onDone(handleDone) {
3710 dart.as(handleDone, dart.functionType(dart.void, []));
3711 this[_onDone] = handleDone;
3712 }
3713 pause(resumeSignal) {
3714 if (resumeSignal === void 0) resumeSignal = null;
3715 this[_state] = dart.notNull(this[_state]) + dart.notNull(_DoneStreamSubs cription$()._PAUSED);
3716 if (resumeSignal != null) resumeSignal.whenComplete(dart.bind(this, 'res ume'));
3717 }
3718 resume() {
3719 if (dart.notNull(this.isPaused)) {
3720 this[_state] = dart.notNull(this[_state]) - dart.notNull(_DoneStreamSu bscription$()._PAUSED);
3721 if (!dart.notNull(this.isPaused) && !dart.notNull(this[_isSent])) {
3722 this[_schedule]();
3723 }
3724 }
3725 }
3726 cancel() {
3727 return null;
3728 }
3729 asFuture(futureValue) {
3730 if (futureValue === void 0) futureValue = null;
3731 let result = new _Future();
3732 this[_onDone] = dart.fn(() => {
3733 result[_completeWithValue](null);
3734 }, dart.void, []);
3735 return result;
3736 }
3737 [_sendDone]() {
3738 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_DoneStreamSub scription$()._SCHEDULED);
3739 if (dart.notNull(this.isPaused)) return;
3740 this[_state] = dart.notNull(this[_state]) | dart.notNull(_DoneStreamSubs cription$()._DONE_SENT);
3741 if (this[_onDone] != null) this[_zone].runGuarded(this[_onDone]);
3742 }
3743 }
3744 _DoneStreamSubscription[dart.implements] = () => [StreamSubscription$(T)];
3745 dart.setSignature(_DoneStreamSubscription, {
3746 constructors: () => ({_DoneStreamSubscription: [_DoneStreamSubscription$(T ), [_DoneHandler]]}),
3747 methods: () => ({
3748 [_schedule]: [dart.void, []],
3749 onData: [dart.void, [dart.functionType(dart.void, [T])]],
3750 onError: [dart.void, [core.Function]],
3751 onDone: [dart.void, [dart.functionType(dart.void, [])]],
3752 pause: [dart.void, [], [Future]],
3753 resume: [dart.void, []],
3754 cancel: [Future, []],
3755 asFuture: [Future, [], [dart.dynamic]],
3756 [_sendDone]: [dart.void, []]
3757 })
3758 });
3759 _DoneStreamSubscription._DONE_SENT = 1;
3760 _DoneStreamSubscription._SCHEDULED = 2;
3761 _DoneStreamSubscription._PAUSED = 4;
3762 return _DoneStreamSubscription;
3763 });
3764 let _DoneStreamSubscription = _DoneStreamSubscription$();
3765 const _source = Symbol('_source');
3766 const _onListenHandler = Symbol('_onListenHandler');
3767 const _onCancelHandler = Symbol('_onCancelHandler');
3768 const _cancelSubscription = Symbol('_cancelSubscription');
3769 const _pauseSubscription = Symbol('_pauseSubscription');
3770 const _resumeSubscription = Symbol('_resumeSubscription');
3771 const _isSubscriptionPaused = Symbol('_isSubscriptionPaused');
3772 const _AsBroadcastStream$ = dart.generic(function(T) {
3773 class _AsBroadcastStream extends Stream$(T) {
3774 _AsBroadcastStream(source, onListenHandler, onCancelHandler) {
3775 this[_source] = source;
3776 this[_onListenHandler] = dart.as(Zone.current.registerUnaryCallback(onLi stenHandler), _broadcastCallback);
3777 this[_onCancelHandler] = dart.as(Zone.current.registerUnaryCallback(onCa ncelHandler), _broadcastCallback);
3778 this[_zone] = Zone.current;
3779 this[_controller] = null;
3780 this[_subscription] = null;
3781 super.Stream();
3782 this[_controller] = new (_AsBroadcastStreamController$(T))(dart.bind(thi s, _onListen), dart.bind(this, _onCancel));
3783 }
3784 get isBroadcast() {
3785 return true;
3786 }
3787 listen(onData, opts) {
3788 dart.as(onData, dart.functionType(dart.void, [T]));
3789 let onError = opts && 'onError' in opts ? opts.onError : null;
3790 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
3791 dart.as(onDone, dart.functionType(dart.void, []));
3792 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
3793 if (this[_controller] == null || dart.notNull(this[_controller].isClosed )) {
3794 return new (_DoneStreamSubscription$(T))(onDone);
3795 }
3796 if (this[_subscription] == null) {
3797 this[_subscription] = this[_source].listen(dart.bind(this[_controller] , 'add'), {onError: dart.bind(this[_controller], 'addError'), onDone: dart.bind( this[_controller], 'close')});
3798 }
3799 cancelOnError = core.identical(true, cancelOnError);
3800 return this[_controller][_subscribe](onData, onError, onDone, cancelOnEr ror);
3801 }
3802 [_onCancel]() {
3803 let shutdown = this[_controller] == null || dart.notNull(this[_controlle r].isClosed);
3804 if (this[_onCancelHandler] != null) {
3805 this[_zone].runUnary(this[_onCancelHandler], new _BroadcastSubscriptio nWrapper(this));
3806 }
3807 if (shutdown) {
3808 if (this[_subscription] != null) {
3809 this[_subscription].cancel();
3810 this[_subscription] = null;
3811 }
3812 }
3813 }
3814 [_onListen]() {
3815 if (this[_onListenHandler] != null) {
3816 this[_zone].runUnary(this[_onListenHandler], new _BroadcastSubscriptio nWrapper(this));
3817 }
3818 }
3819 [_cancelSubscription]() {
3820 if (this[_subscription] == null) return;
3821 let subscription = this[_subscription];
3822 this[_subscription] = null;
3823 this[_controller] = null;
3824 subscription.cancel();
3825 }
3826 [_pauseSubscription](resumeSignal) {
3827 if (this[_subscription] == null) return;
3828 this[_subscription].pause(resumeSignal);
3829 }
3830 [_resumeSubscription]() {
3831 if (this[_subscription] == null) return;
3832 this[_subscription].resume();
3833 }
3834 get [_isSubscriptionPaused]() {
3835 if (this[_subscription] == null) return false;
3836 return this[_subscription].isPaused;
3837 }
3838 }
3839 dart.setSignature(_AsBroadcastStream, {
3840 constructors: () => ({_AsBroadcastStream: [_AsBroadcastStream$(T), [Stream $(T), dart.functionType(dart.void, [StreamSubscription]), dart.functionType(dart .void, [StreamSubscription])]]}),
3841 methods: () => ({
3842 listen: [StreamSubscription$(T), [dart.functionType(dart.void, [T])], {o nError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}],
3843 [_onCancel]: [dart.void, []],
3844 [_onListen]: [dart.void, []],
3845 [_cancelSubscription]: [dart.void, []],
3846 [_pauseSubscription]: [dart.void, [Future]],
3847 [_resumeSubscription]: [dart.void, []]
3848 })
3849 });
3850 return _AsBroadcastStream;
3851 });
3852 let _AsBroadcastStream = _AsBroadcastStream$();
3853 const _BroadcastSubscriptionWrapper$ = dart.generic(function(T) {
3854 class _BroadcastSubscriptionWrapper extends core.Object {
3855 _BroadcastSubscriptionWrapper(stream) {
3856 this[_stream] = stream;
3857 }
3858 onData(handleData) {
3859 dart.as(handleData, dart.functionType(dart.void, [T]));
3860 dart.throw(new core.UnsupportedError("Cannot change handlers of asBroadc astStream source subscription."));
3861 }
3862 onError(handleError) {
3863 dart.throw(new core.UnsupportedError("Cannot change handlers of asBroadc astStream source subscription."));
3864 }
3865 onDone(handleDone) {
3866 dart.as(handleDone, dart.functionType(dart.void, []));
3867 dart.throw(new core.UnsupportedError("Cannot change handlers of asBroadc astStream source subscription."));
3868 }
3869 pause(resumeSignal) {
3870 if (resumeSignal === void 0) resumeSignal = null;
3871 this[_stream][_pauseSubscription](resumeSignal);
3872 }
3873 resume() {
3874 this[_stream][_resumeSubscription]();
3875 }
3876 cancel() {
3877 this[_stream][_cancelSubscription]();
3878 return null;
3879 }
3880 get isPaused() {
3881 return this[_stream][_isSubscriptionPaused];
3882 }
3883 asFuture(futureValue) {
3884 if (futureValue === void 0) futureValue = null;
3885 dart.throw(new core.UnsupportedError("Cannot change handlers of asBroadc astStream source subscription."));
3886 }
3887 }
3888 _BroadcastSubscriptionWrapper[dart.implements] = () => [StreamSubscription$( T)];
3889 dart.setSignature(_BroadcastSubscriptionWrapper, {
3890 constructors: () => ({_BroadcastSubscriptionWrapper: [_BroadcastSubscripti onWrapper$(T), [_AsBroadcastStream]]}),
3891 methods: () => ({
3892 onData: [dart.void, [dart.functionType(dart.void, [T])]],
3893 onError: [dart.void, [core.Function]],
3894 onDone: [dart.void, [dart.functionType(dart.void, [])]],
3895 pause: [dart.void, [], [Future]],
3896 resume: [dart.void, []],
3897 cancel: [Future, []],
3898 asFuture: [Future, [], [dart.dynamic]]
3899 })
3900 });
3901 return _BroadcastSubscriptionWrapper;
3902 });
3903 let _BroadcastSubscriptionWrapper = _BroadcastSubscriptionWrapper$();
3904 const _current = Symbol('_current');
3905 const _futureOrPrefetch = Symbol('_futureOrPrefetch');
3906 const _clear = Symbol('_clear');
3907 const _StreamIteratorImpl$ = dart.generic(function(T) {
3908 class _StreamIteratorImpl extends core.Object {
3909 _StreamIteratorImpl(stream) {
3910 this[_subscription] = null;
3911 this[_current] = null;
3912 this[_futureOrPrefetch] = null;
3913 this[_state] = _StreamIteratorImpl$()._STATE_FOUND;
3914 this[_subscription] = stream.listen(dart.bind(this, _onData), {onError: dart.bind(this, _onError), onDone: dart.bind(this, _onDone), cancelOnError: true });
3915 }
3916 get current() {
3917 return this[_current];
3918 }
3919 moveNext() {
3920 if (this[_state] == _StreamIteratorImpl$()._STATE_DONE) {
3921 return new (_Future$(core.bool)).immediate(false);
3922 }
3923 if (this[_state] == _StreamIteratorImpl$()._STATE_MOVING) {
3924 dart.throw(new core.StateError("Already waiting for next."));
3925 }
3926 if (this[_state] == _StreamIteratorImpl$()._STATE_FOUND) {
3927 this[_state] = _StreamIteratorImpl$()._STATE_MOVING;
3928 this[_current] = null;
3929 this[_futureOrPrefetch] = new (_Future$(core.bool))();
3930 return dart.as(this[_futureOrPrefetch], Future$(core.bool));
3931 } else {
3932 dart.assert(dart.notNull(this[_state]) >= dart.notNull(_StreamIterator Impl$()._STATE_EXTRA_DATA));
3933 switch (this[_state]) {
3934 case _StreamIteratorImpl$()._STATE_EXTRA_DATA:
3935 {
3936 this[_state] = _StreamIteratorImpl$()._STATE_FOUND;
3937 this[_current] = dart.as(this[_futureOrPrefetch], T);
3938 this[_futureOrPrefetch] = null;
3939 this[_subscription].resume();
3940 return new (_Future$(core.bool)).immediate(true);
3941 }
3942 case _StreamIteratorImpl$()._STATE_EXTRA_ERROR:
3943 {
3944 let prefetch = dart.as(this[_futureOrPrefetch], AsyncError);
3945 this[_clear]();
3946 return new (_Future$(core.bool)).immediateError(prefetch.error, pr efetch.stackTrace);
3947 }
3948 case _StreamIteratorImpl$()._STATE_EXTRA_DONE:
3949 {
3950 this[_clear]();
3951 return new (_Future$(core.bool)).immediate(false);
3952 }
3953 }
3954 }
3955 }
3956 [_clear]() {
3957 this[_subscription] = null;
3958 this[_futureOrPrefetch] = null;
3959 this[_current] = null;
3960 this[_state] = _StreamIteratorImpl$()._STATE_DONE;
3961 }
3962 cancel() {
3963 let subscription = this[_subscription];
3964 if (subscription == null) return null;
3965 if (this[_state] == _StreamIteratorImpl$()._STATE_MOVING) {
3966 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
3967 this[_clear]();
3968 hasNext[_complete](false);
3969 } else {
3970 this[_clear]();
3971 }
3972 return subscription.cancel();
3973 }
3974 [_onData](data) {
3975 dart.as(data, T);
3976 if (this[_state] == _StreamIteratorImpl$()._STATE_MOVING) {
3977 this[_current] = data;
3978 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
3979 this[_futureOrPrefetch] = null;
3980 this[_state] = _StreamIteratorImpl$()._STATE_FOUND;
3981 hasNext[_complete](true);
3982 return;
3983 }
3984 this[_subscription].pause();
3985 dart.assert(this[_futureOrPrefetch] == null);
3986 this[_futureOrPrefetch] = data;
3987 this[_state] = _StreamIteratorImpl$()._STATE_EXTRA_DATA;
3988 }
3989 [_onError](error, stackTrace) {
3990 if (stackTrace === void 0) stackTrace = null;
3991 if (this[_state] == _StreamIteratorImpl$()._STATE_MOVING) {
3992 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
3993 this[_clear]();
3994 hasNext[_completeError](error, stackTrace);
3995 return;
3996 }
3997 this[_subscription].pause();
3998 dart.assert(this[_futureOrPrefetch] == null);
3999 this[_futureOrPrefetch] = new AsyncError(error, stackTrace);
4000 this[_state] = _StreamIteratorImpl$()._STATE_EXTRA_ERROR;
4001 }
4002 [_onDone]() {
4003 if (this[_state] == _StreamIteratorImpl$()._STATE_MOVING) {
4004 let hasNext = dart.as(this[_futureOrPrefetch], _Future$(core.bool));
4005 this[_clear]();
4006 hasNext[_complete](false);
4007 return;
4008 }
4009 this[_subscription].pause();
4010 this[_futureOrPrefetch] = null;
4011 this[_state] = _StreamIteratorImpl$()._STATE_EXTRA_DONE;
4012 }
4013 }
4014 _StreamIteratorImpl[dart.implements] = () => [StreamIterator$(T)];
4015 dart.setSignature(_StreamIteratorImpl, {
4016 constructors: () => ({_StreamIteratorImpl: [_StreamIteratorImpl$(T), [Stre am$(T)]]}),
4017 methods: () => ({
4018 moveNext: [Future$(core.bool), []],
4019 [_clear]: [dart.void, []],
4020 cancel: [Future, []],
4021 [_onData]: [dart.void, [T]],
4022 [_onError]: [dart.void, [core.Object], [core.StackTrace]],
4023 [_onDone]: [dart.void, []]
4024 })
4025 });
4026 _StreamIteratorImpl._STATE_FOUND = 0;
4027 _StreamIteratorImpl._STATE_DONE = 1;
4028 _StreamIteratorImpl._STATE_MOVING = 2;
4029 _StreamIteratorImpl._STATE_EXTRA_DATA = 3;
4030 _StreamIteratorImpl._STATE_EXTRA_ERROR = 4;
4031 _StreamIteratorImpl._STATE_EXTRA_DONE = 5;
4032 return _StreamIteratorImpl;
4033 });
4034 let _StreamIteratorImpl = _StreamIteratorImpl$();
4035 function _runUserCode(userCode, onSuccess, onError) {
4036 try {
4037 dart.dcall(onSuccess, userCode());
4038 } catch (e) {
4039 let s = dart.stackTrace(e);
4040 let replacement = Zone.current.errorCallback(e, s);
4041 if (replacement == null) {
4042 dart.dcall(onError, e, s);
4043 } else {
4044 let error = _nonNullError(replacement.error);
4045 let stackTrace = replacement.stackTrace;
4046 dart.dcall(onError, error, stackTrace);
4047 }
4048 }
4049
4050 }
4051 dart.fn(_runUserCode, dart.dynamic, [dart.functionType(dart.dynamic, []), dart .functionType(dart.dynamic, [dart.dynamic]), dart.functionType(dart.dynamic, [da rt.dynamic, core.StackTrace])]);
4052 function _cancelAndError(subscription, future, error, stackTrace) {
4053 let cancelFuture = subscription.cancel();
4054 if (dart.is(cancelFuture, Future)) {
4055 cancelFuture.whenComplete(dart.fn(() => future[_completeError](error, stac kTrace), dart.void, []));
4056 } else {
4057 future[_completeError](error, stackTrace);
4058 }
4059 }
4060 dart.fn(_cancelAndError, dart.void, [StreamSubscription, _Future, dart.dynamic , core.StackTrace]);
4061 function _cancelAndErrorWithReplacement(subscription, future, error, stackTrac e) {
4062 let replacement = Zone.current.errorCallback(error, stackTrace);
4063 if (replacement != null) {
4064 error = _nonNullError(replacement.error);
4065 stackTrace = replacement.stackTrace;
4066 }
4067 _cancelAndError(subscription, future, error, stackTrace);
4068 }
4069 dart.fn(_cancelAndErrorWithReplacement, dart.void, [StreamSubscription, _Futur e, dart.dynamic, core.StackTrace]);
4070 function _cancelAndErrorClosure(subscription, future) {
4071 return dart.fn((error, stackTrace) => _cancelAndError(subscription, future, error, stackTrace), dart.void, [dart.dynamic, core.StackTrace]);
4072 }
4073 dart.fn(_cancelAndErrorClosure, dart.dynamic, [StreamSubscription, _Future]);
4074 function _cancelAndValue(subscription, future, value) {
4075 let cancelFuture = subscription.cancel();
4076 if (dart.is(cancelFuture, Future)) {
4077 cancelFuture.whenComplete(dart.fn(() => future[_complete](value), dart.voi d, []));
4078 } else {
4079 future[_complete](value);
4080 }
4081 }
4082 dart.fn(_cancelAndValue, dart.void, [StreamSubscription, _Future, dart.dynamic ]);
4083 const _handleData = Symbol('_handleData');
4084 const _handleError = Symbol('_handleError');
4085 const _handleDone = Symbol('_handleDone');
4086 const _ForwardingStream$ = dart.generic(function(S, T) {
4087 class _ForwardingStream extends Stream$(T) {
4088 _ForwardingStream(source) {
4089 this[_source] = source;
4090 super.Stream();
4091 }
4092 get isBroadcast() {
4093 return this[_source].isBroadcast;
4094 }
4095 listen(onData, opts) {
4096 dart.as(onData, dart.functionType(dart.void, [T]));
4097 let onError = opts && 'onError' in opts ? opts.onError : null;
4098 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
4099 dart.as(onDone, dart.functionType(dart.void, []));
4100 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
4101 cancelOnError = core.identical(true, cancelOnError);
4102 return this[_createSubscription](onData, onError, onDone, cancelOnError) ;
4103 }
4104 [_createSubscription](onData, onError, onDone, cancelOnError) {
4105 dart.as(onData, dart.functionType(dart.void, [T]));
4106 dart.as(onDone, dart.functionType(dart.void, []));
4107 return new (_ForwardingStreamSubscription$(S, T))(this, onData, onError, onDone, cancelOnError);
4108 }
4109 [_handleData](data, sink) {
4110 dart.as(data, S);
4111 dart.as(sink, _EventSink$(T));
4112 let outputData = data;
4113 sink[_add](dart.as(outputData, T));
4114 }
4115 [_handleError](error, stackTrace, sink) {
4116 dart.as(sink, _EventSink$(T));
4117 sink[_addError](error, stackTrace);
4118 }
4119 [_handleDone](sink) {
4120 dart.as(sink, _EventSink$(T));
4121 sink[_close]();
4122 }
4123 }
4124 dart.setSignature(_ForwardingStream, {
4125 constructors: () => ({_ForwardingStream: [_ForwardingStream$(S, T), [Strea m$(S)]]}),
4126 methods: () => ({
4127 listen: [StreamSubscription$(T), [dart.functionType(dart.void, [T])], {o nError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}],
4128 [_createSubscription]: [StreamSubscription$(T), [dart.functionType(dart. void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]],
4129 [_handleData]: [dart.void, [S, _EventSink$(T)]],
4130 [_handleError]: [dart.void, [dart.dynamic, core.StackTrace, _EventSink$( T)]],
4131 [_handleDone]: [dart.void, [_EventSink$(T)]]
4132 })
4133 });
4134 return _ForwardingStream;
4135 });
4136 let _ForwardingStream = _ForwardingStream$();
4137 const _ForwardingStreamSubscription$ = dart.generic(function(S, T) {
4138 class _ForwardingStreamSubscription extends _BufferingStreamSubscription$(T) {
4139 _ForwardingStreamSubscription(stream, onData, onError, onDone, cancelOnErr or) {
4140 this[_stream] = stream;
4141 this[_subscription] = null;
4142 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r);
4143 this[_subscription] = this[_stream][_source].listen(dart.bind(this, _han dleData), {onError: dart.bind(this, _handleError), onDone: dart.bind(this, _hand leDone)});
4144 }
4145 [_add](data) {
4146 dart.as(data, T);
4147 if (dart.notNull(this[_isClosed])) return;
4148 super[_add](data);
4149 }
4150 [_addError](error, stackTrace) {
4151 if (dart.notNull(this[_isClosed])) return;
4152 super[_addError](error, stackTrace);
4153 }
4154 [_onPause]() {
4155 if (this[_subscription] == null) return;
4156 this[_subscription].pause();
4157 }
4158 [_onResume]() {
4159 if (this[_subscription] == null) return;
4160 this[_subscription].resume();
4161 }
4162 [_onCancel]() {
4163 if (this[_subscription] != null) {
4164 let subscription = this[_subscription];
4165 this[_subscription] = null;
4166 subscription.cancel();
4167 }
4168 return null;
4169 }
4170 [_handleData](data) {
4171 dart.as(data, S);
4172 this[_stream][_handleData](data, this);
4173 }
4174 [_handleError](error, stackTrace) {
4175 this[_stream][_handleError](error, stackTrace, this);
4176 }
4177 [_handleDone]() {
4178 this[_stream][_handleDone](this);
4179 }
4180 }
4181 dart.setSignature(_ForwardingStreamSubscription, {
4182 constructors: () => ({_ForwardingStreamSubscription: [_ForwardingStreamSub scription$(S, T), [_ForwardingStream$(S, T), dart.functionType(dart.void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]]}),
4183 methods: () => ({
4184 [_add]: [dart.void, [T]],
4185 [_handleData]: [dart.void, [S]],
4186 [_handleError]: [dart.void, [dart.dynamic, core.StackTrace]],
4187 [_handleDone]: [dart.void, []]
4188 })
4189 });
4190 return _ForwardingStreamSubscription;
4191 });
4192 let _ForwardingStreamSubscription = _ForwardingStreamSubscription$();
4193 const _Predicate$ = dart.generic(function(T) {
4194 const _Predicate = dart.typedef('_Predicate', () => dart.functionType(core.b ool, [T]));
4195 return _Predicate;
4196 });
4197 let _Predicate = _Predicate$();
4198 function _addErrorWithReplacement(sink, error, stackTrace) {
4199 let replacement = Zone.current.errorCallback(error, dart.as(stackTrace, core .StackTrace));
4200 if (replacement != null) {
4201 error = _nonNullError(replacement.error);
4202 stackTrace = replacement.stackTrace;
4203 }
4204 sink[_addError](error, dart.as(stackTrace, core.StackTrace));
4205 }
4206 dart.fn(_addErrorWithReplacement, dart.void, [_EventSink, dart.dynamic, dart.d ynamic]);
4207 const _test = Symbol('_test');
4208 const _WhereStream$ = dart.generic(function(T) {
4209 class _WhereStream extends _ForwardingStream$(T, T) {
4210 _WhereStream(source, test) {
4211 this[_test] = test;
4212 super._ForwardingStream(source);
4213 }
4214 [_handleData](inputEvent, sink) {
4215 dart.as(inputEvent, T);
4216 dart.as(sink, _EventSink$(T));
4217 let satisfies = null;
4218 try {
4219 satisfies = this[_test](inputEvent);
4220 } catch (e) {
4221 let s = dart.stackTrace(e);
4222 _addErrorWithReplacement(sink, e, s);
4223 return;
4224 }
4225
4226 if (dart.notNull(satisfies)) {
4227 sink[_add](inputEvent);
4228 }
4229 }
4230 }
4231 dart.setSignature(_WhereStream, {
4232 constructors: () => ({_WhereStream: [_WhereStream$(T), [Stream$(T), dart.f unctionType(core.bool, [T])]]}),
4233 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4234 });
4235 return _WhereStream;
4236 });
4237 let _WhereStream = _WhereStream$();
4238 const _Transformation$ = dart.generic(function(S, T) {
4239 const _Transformation = dart.typedef('_Transformation', () => dart.functionT ype(T, [S]));
4240 return _Transformation;
4241 });
4242 let _Transformation = _Transformation$();
4243 const _transform = Symbol('_transform');
4244 const _MapStream$ = dart.generic(function(S, T) {
4245 class _MapStream extends _ForwardingStream$(S, T) {
4246 _MapStream(source, transform) {
4247 this[_transform] = transform;
4248 super._ForwardingStream(source);
4249 }
4250 [_handleData](inputEvent, sink) {
4251 dart.as(inputEvent, S);
4252 dart.as(sink, _EventSink$(T));
4253 let outputEvent = null;
4254 try {
4255 outputEvent = dart.as(dart.dcall(this[_transform], inputEvent), T);
4256 } catch (e) {
4257 let s = dart.stackTrace(e);
4258 _addErrorWithReplacement(sink, e, s);
4259 return;
4260 }
4261
4262 sink[_add](outputEvent);
4263 }
4264 }
4265 dart.setSignature(_MapStream, {
4266 constructors: () => ({_MapStream: [_MapStream$(S, T), [Stream$(S), dart.fu nctionType(T, [S])]]}),
4267 methods: () => ({[_handleData]: [dart.void, [S, _EventSink$(T)]]})
4268 });
4269 return _MapStream;
4270 });
4271 let _MapStream = _MapStream$();
4272 const _expand = Symbol('_expand');
4273 const _ExpandStream$ = dart.generic(function(S, T) {
4274 class _ExpandStream extends _ForwardingStream$(S, T) {
4275 _ExpandStream(source, expand) {
4276 this[_expand] = expand;
4277 super._ForwardingStream(source);
4278 }
4279 [_handleData](inputEvent, sink) {
4280 dart.as(inputEvent, S);
4281 dart.as(sink, _EventSink$(T));
4282 try {
4283 for (let value of this[_expand](inputEvent)) {
4284 sink[_add](value);
4285 }
4286 } catch (e) {
4287 let s = dart.stackTrace(e);
4288 _addErrorWithReplacement(sink, e, s);
4289 }
4290
4291 }
4292 }
4293 dart.setSignature(_ExpandStream, {
4294 constructors: () => ({_ExpandStream: [_ExpandStream$(S, T), [Stream$(S), d art.functionType(core.Iterable$(T), [S])]]}),
4295 methods: () => ({[_handleData]: [dart.void, [S, _EventSink$(T)]]})
4296 });
4297 return _ExpandStream;
4298 });
4299 let _ExpandStream = _ExpandStream$();
4300 const _ErrorTest = dart.typedef('_ErrorTest', () => dart.functionType(core.boo l, [dart.dynamic]));
4301 const _HandleErrorStream$ = dart.generic(function(T) {
4302 class _HandleErrorStream extends _ForwardingStream$(T, T) {
4303 _HandleErrorStream(source, onError, test) {
4304 this[_transform] = onError;
4305 this[_test] = test;
4306 super._ForwardingStream(source);
4307 }
4308 [_handleError](error, stackTrace, sink) {
4309 dart.as(sink, _EventSink$(T));
4310 let matches = true;
4311 if (this[_test] != null) {
4312 try {
4313 matches = dart.dcall(this[_test], error);
4314 } catch (e) {
4315 let s = dart.stackTrace(e);
4316 _addErrorWithReplacement(sink, e, s);
4317 return;
4318 }
4319
4320 }
4321 if (dart.notNull(matches)) {
4322 try {
4323 _invokeErrorHandler(this[_transform], error, stackTrace);
4324 } catch (e) {
4325 let s = dart.stackTrace(e);
4326 if (core.identical(e, error)) {
4327 sink[_addError](error, stackTrace);
4328 } else {
4329 _addErrorWithReplacement(sink, e, s);
4330 }
4331 return;
4332 }
4333
4334 } else {
4335 sink[_addError](error, stackTrace);
4336 }
4337 }
4338 }
4339 dart.setSignature(_HandleErrorStream, {
4340 constructors: () => ({_HandleErrorStream: [_HandleErrorStream$(T), [Stream $(T), core.Function, dart.functionType(core.bool, [dart.dynamic])]]}),
4341 methods: () => ({[_handleError]: [dart.void, [core.Object, core.StackTrace , _EventSink$(T)]]})
4342 });
4343 return _HandleErrorStream;
4344 });
4345 let _HandleErrorStream = _HandleErrorStream$();
4346 const _remaining = Symbol('_remaining');
4347 const _TakeStream$ = dart.generic(function(T) {
4348 class _TakeStream extends _ForwardingStream$(T, T) {
4349 _TakeStream(source, count) {
4350 this[_remaining] = count;
4351 super._ForwardingStream(source);
4352 if (!(typeof count == 'number')) dart.throw(new core.ArgumentError(count ));
4353 }
4354 [_handleData](inputEvent, sink) {
4355 dart.as(inputEvent, T);
4356 dart.as(sink, _EventSink$(T));
4357 if (dart.notNull(this[_remaining]) > 0) {
4358 sink[_add](inputEvent);
4359 this[_remaining] = dart.notNull(this[_remaining]) - 1;
4360 if (this[_remaining] == 0) {
4361 sink[_close]();
4362 }
4363 }
4364 }
4365 }
4366 dart.setSignature(_TakeStream, {
4367 constructors: () => ({_TakeStream: [_TakeStream$(T), [Stream$(T), core.int ]]}),
4368 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4369 });
4370 return _TakeStream;
4371 });
4372 let _TakeStream = _TakeStream$();
4373 const _TakeWhileStream$ = dart.generic(function(T) {
4374 class _TakeWhileStream extends _ForwardingStream$(T, T) {
4375 _TakeWhileStream(source, test) {
4376 this[_test] = test;
4377 super._ForwardingStream(source);
4378 }
4379 [_handleData](inputEvent, sink) {
4380 dart.as(inputEvent, T);
4381 dart.as(sink, _EventSink$(T));
4382 let satisfies = null;
4383 try {
4384 satisfies = this[_test](inputEvent);
4385 } catch (e) {
4386 let s = dart.stackTrace(e);
4387 _addErrorWithReplacement(sink, e, s);
4388 sink[_close]();
4389 return;
4390 }
4391
4392 if (dart.notNull(satisfies)) {
4393 sink[_add](inputEvent);
4394 } else {
4395 sink[_close]();
4396 }
4397 }
4398 }
4399 dart.setSignature(_TakeWhileStream, {
4400 constructors: () => ({_TakeWhileStream: [_TakeWhileStream$(T), [Stream$(T) , dart.functionType(core.bool, [T])]]}),
4401 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4402 });
4403 return _TakeWhileStream;
4404 });
4405 let _TakeWhileStream = _TakeWhileStream$();
4406 const _SkipStream$ = dart.generic(function(T) {
4407 class _SkipStream extends _ForwardingStream$(T, T) {
4408 _SkipStream(source, count) {
4409 this[_remaining] = count;
4410 super._ForwardingStream(source);
4411 if (!(typeof count == 'number') || dart.notNull(count) < 0) dart.throw(n ew core.ArgumentError(count));
4412 }
4413 [_handleData](inputEvent, sink) {
4414 dart.as(inputEvent, T);
4415 dart.as(sink, _EventSink$(T));
4416 if (dart.notNull(this[_remaining]) > 0) {
4417 this[_remaining] = dart.notNull(this[_remaining]) - 1;
4418 return;
4419 }
4420 sink[_add](inputEvent);
4421 }
4422 }
4423 dart.setSignature(_SkipStream, {
4424 constructors: () => ({_SkipStream: [_SkipStream$(T), [Stream$(T), core.int ]]}),
4425 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4426 });
4427 return _SkipStream;
4428 });
4429 let _SkipStream = _SkipStream$();
4430 const _hasFailed = Symbol('_hasFailed');
4431 const _SkipWhileStream$ = dart.generic(function(T) {
4432 class _SkipWhileStream extends _ForwardingStream$(T, T) {
4433 _SkipWhileStream(source, test) {
4434 this[_test] = test;
4435 this[_hasFailed] = false;
4436 super._ForwardingStream(source);
4437 }
4438 [_handleData](inputEvent, sink) {
4439 dart.as(inputEvent, T);
4440 dart.as(sink, _EventSink$(T));
4441 if (dart.notNull(this[_hasFailed])) {
4442 sink[_add](inputEvent);
4443 return;
4444 }
4445 let satisfies = null;
4446 try {
4447 satisfies = this[_test](inputEvent);
4448 } catch (e) {
4449 let s = dart.stackTrace(e);
4450 _addErrorWithReplacement(sink, e, s);
4451 this[_hasFailed] = true;
4452 return;
4453 }
4454
4455 if (!dart.notNull(satisfies)) {
4456 this[_hasFailed] = true;
4457 sink[_add](inputEvent);
4458 }
4459 }
4460 }
4461 dart.setSignature(_SkipWhileStream, {
4462 constructors: () => ({_SkipWhileStream: [_SkipWhileStream$(T), [Stream$(T) , dart.functionType(core.bool, [T])]]}),
4463 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4464 });
4465 return _SkipWhileStream;
4466 });
4467 let _SkipWhileStream = _SkipWhileStream$();
4468 const _Equality$ = dart.generic(function(T) {
4469 const _Equality = dart.typedef('_Equality', () => dart.functionType(core.boo l, [T, T]));
4470 return _Equality;
4471 });
4472 let _Equality = _Equality$();
4473 const _equals = Symbol('_equals');
4474 const _DistinctStream$ = dart.generic(function(T) {
4475 class _DistinctStream extends _ForwardingStream$(T, T) {
4476 _DistinctStream(source, equals) {
4477 this[_previous] = _DistinctStream$()._SENTINEL;
4478 this[_equals] = equals;
4479 super._ForwardingStream(source);
4480 }
4481 [_handleData](inputEvent, sink) {
4482 dart.as(inputEvent, T);
4483 dart.as(sink, _EventSink$(T));
4484 if (core.identical(this[_previous], _DistinctStream$()._SENTINEL)) {
4485 this[_previous] = inputEvent;
4486 return sink[_add](inputEvent);
4487 } else {
4488 let isEqual = null;
4489 try {
4490 if (this[_equals] == null) {
4491 isEqual = dart.equals(this[_previous], inputEvent);
4492 } else {
4493 isEqual = this[_equals](dart.as(this[_previous], T), inputEvent);
4494 }
4495 } catch (e) {
4496 let s = dart.stackTrace(e);
4497 _addErrorWithReplacement(sink, e, s);
4498 return null;
4499 }
4500
4501 if (!dart.notNull(isEqual)) {
4502 sink[_add](inputEvent);
4503 this[_previous] = inputEvent;
4504 }
4505 }
4506 }
4507 }
4508 dart.setSignature(_DistinctStream, {
4509 constructors: () => ({_DistinctStream: [_DistinctStream$(T), [Stream$(T), dart.functionType(core.bool, [T, T])]]}),
4510 methods: () => ({[_handleData]: [dart.void, [T, _EventSink$(T)]]})
4511 });
4512 dart.defineLazyProperties(_DistinctStream, {
4513 get _SENTINEL() {
4514 return new core.Object();
4515 },
4516 set _SENTINEL(_) {}
4517 });
4518 return _DistinctStream;
4519 });
4520 let _DistinctStream = _DistinctStream$();
4521 const _EventSinkWrapper$ = dart.generic(function(T) {
4522 class _EventSinkWrapper extends core.Object {
4523 _EventSinkWrapper(sink) {
4524 this[_sink] = sink;
4525 }
4526 add(data) {
4527 dart.as(data, T);
4528 this[_sink][_add](data);
4529 }
4530 addError(error, stackTrace) {
4531 if (stackTrace === void 0) stackTrace = null;
4532 this[_sink][_addError](error, stackTrace);
4533 }
4534 close() {
4535 this[_sink][_close]();
4536 }
4537 }
4538 _EventSinkWrapper[dart.implements] = () => [EventSink$(T)];
4539 dart.setSignature(_EventSinkWrapper, {
4540 constructors: () => ({_EventSinkWrapper: [_EventSinkWrapper$(T), [_EventSi nk]]}),
4541 methods: () => ({
4542 add: [dart.void, [T]],
4543 addError: [dart.void, [dart.dynamic], [core.StackTrace]],
4544 close: [dart.void, []]
4545 })
4546 });
4547 return _EventSinkWrapper;
4548 });
4549 let _EventSinkWrapper = _EventSinkWrapper$();
4550 const _transformerSink = Symbol('_transformerSink');
4551 const _isSubscribed = Symbol('_isSubscribed');
4552 const _SinkTransformerStreamSubscription$ = dart.generic(function(S, T) {
4553 class _SinkTransformerStreamSubscription extends _BufferingStreamSubscriptio n$(T) {
4554 _SinkTransformerStreamSubscription(source, mapper, onData, onError, onDone , cancelOnError) {
4555 this[_transformerSink] = null;
4556 this[_subscription] = null;
4557 super._BufferingStreamSubscription(onData, onError, onDone, cancelOnErro r);
4558 let eventSink = new (_EventSinkWrapper$(T))(this);
4559 this[_transformerSink] = mapper(eventSink);
4560 this[_subscription] = source.listen(dart.bind(this, _handleData), {onErr or: dart.bind(this, _handleError), onDone: dart.bind(this, _handleDone)});
4561 }
4562 get [_isSubscribed]() {
4563 return this[_subscription] != null;
4564 }
4565 [_add](data) {
4566 dart.as(data, T);
4567 if (dart.notNull(this[_isClosed])) {
4568 dart.throw(new core.StateError("Stream is already closed"));
4569 }
4570 super[_add](data);
4571 }
4572 [_addError](error, stackTrace) {
4573 if (dart.notNull(this[_isClosed])) {
4574 dart.throw(new core.StateError("Stream is already closed"));
4575 }
4576 super[_addError](error, stackTrace);
4577 }
4578 [_close]() {
4579 if (dart.notNull(this[_isClosed])) {
4580 dart.throw(new core.StateError("Stream is already closed"));
4581 }
4582 super[_close]();
4583 }
4584 [_onPause]() {
4585 if (dart.notNull(this[_isSubscribed])) this[_subscription].pause();
4586 }
4587 [_onResume]() {
4588 if (dart.notNull(this[_isSubscribed])) this[_subscription].resume();
4589 }
4590 [_onCancel]() {
4591 if (dart.notNull(this[_isSubscribed])) {
4592 let subscription = this[_subscription];
4593 this[_subscription] = null;
4594 subscription.cancel();
4595 }
4596 return null;
4597 }
4598 [_handleData](data) {
4599 dart.as(data, S);
4600 try {
4601 this[_transformerSink].add(data);
4602 } catch (e) {
4603 let s = dart.stackTrace(e);
4604 this[_addError](e, s);
4605 }
4606
4607 }
4608 [_handleError](error, stackTrace) {
4609 if (stackTrace === void 0) stackTrace = null;
4610 try {
4611 this[_transformerSink].addError(error, dart.as(stackTrace, core.StackT race));
4612 } catch (e) {
4613 let s = dart.stackTrace(e);
4614 if (core.identical(e, error)) {
4615 this[_addError](error, dart.as(stackTrace, core.StackTrace));
4616 } else {
4617 this[_addError](e, s);
4618 }
4619 }
4620
4621 }
4622 [_handleDone]() {
4623 try {
4624 this[_subscription] = null;
4625 this[_transformerSink].close();
4626 } catch (e) {
4627 let s = dart.stackTrace(e);
4628 this[_addError](e, s);
4629 }
4630
4631 }
4632 }
4633 dart.setSignature(_SinkTransformerStreamSubscription, {
4634 constructors: () => ({_SinkTransformerStreamSubscription: [_SinkTransforme rStreamSubscription$(S, T), [Stream$(S), _SinkMapper$(S, T), dart.functionType(d art.void, [T]), core.Function, dart.functionType(dart.void, []), core.bool]]}),
4635 methods: () => ({
4636 [_add]: [dart.void, [T]],
4637 [_handleData]: [dart.void, [S]],
4638 [_handleError]: [dart.void, [dart.dynamic], [dart.dynamic]],
4639 [_handleDone]: [dart.void, []]
4640 })
4641 });
4642 return _SinkTransformerStreamSubscription;
4643 });
4644 let _SinkTransformerStreamSubscription = _SinkTransformerStreamSubscription$() ;
4645 const _SinkMapper$ = dart.generic(function(S, T) {
4646 const _SinkMapper = dart.typedef('_SinkMapper', () => dart.functionType(Even tSink$(S), [EventSink$(T)]));
4647 return _SinkMapper;
4648 });
4649 let _SinkMapper = _SinkMapper$();
4650 const _sinkMapper = Symbol('_sinkMapper');
4651 const _StreamSinkTransformer$ = dart.generic(function(S, T) {
4652 class _StreamSinkTransformer extends core.Object {
4653 _StreamSinkTransformer(sinkMapper) {
4654 this[_sinkMapper] = sinkMapper;
4655 }
4656 bind(stream) {
4657 dart.as(stream, Stream$(S));
4658 return new (_BoundSinkStream$(S, T))(stream, this[_sinkMapper]);
4659 }
4660 }
4661 _StreamSinkTransformer[dart.implements] = () => [StreamTransformer$(S, T)];
4662 dart.setSignature(_StreamSinkTransformer, {
4663 constructors: () => ({_StreamSinkTransformer: [_StreamSinkTransformer$(S, T), [_SinkMapper$(S, T)]]}),
4664 methods: () => ({bind: [Stream$(T), [Stream$(S)]]})
4665 });
4666 return _StreamSinkTransformer;
4667 });
4668 let _StreamSinkTransformer = _StreamSinkTransformer$();
4669 const _BoundSinkStream$ = dart.generic(function(S, T) {
4670 class _BoundSinkStream extends Stream$(T) {
4671 get isBroadcast() {
4672 return this[_stream].isBroadcast;
4673 }
4674 _BoundSinkStream(stream, sinkMapper) {
4675 this[_stream] = stream;
4676 this[_sinkMapper] = sinkMapper;
4677 super.Stream();
4678 }
4679 listen(onData, opts) {
4680 dart.as(onData, dart.functionType(dart.void, [T]));
4681 let onError = opts && 'onError' in opts ? opts.onError : null;
4682 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
4683 dart.as(onDone, dart.functionType(dart.void, []));
4684 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
4685 cancelOnError = core.identical(true, cancelOnError);
4686 let subscription = new (_SinkTransformerStreamSubscription$(dart.dynamic , T))(this[_stream], this[_sinkMapper], onData, onError, onDone, cancelOnError);
4687 return subscription;
4688 }
4689 }
4690 dart.setSignature(_BoundSinkStream, {
4691 constructors: () => ({_BoundSinkStream: [_BoundSinkStream$(S, T), [Stream$ (S), _SinkMapper$(S, T)]]}),
4692 methods: () => ({listen: [StreamSubscription$(T), [dart.functionType(dart. void, [T])], {onError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}]})
4693 });
4694 return _BoundSinkStream;
4695 });
4696 let _BoundSinkStream = _BoundSinkStream$();
4697 const _TransformDataHandler$ = dart.generic(function(S, T) {
4698 const _TransformDataHandler = dart.typedef('_TransformDataHandler', () => da rt.functionType(dart.void, [S, EventSink$(T)]));
4699 return _TransformDataHandler;
4700 });
4701 let _TransformDataHandler = _TransformDataHandler$();
4702 const _TransformErrorHandler$ = dart.generic(function(T) {
4703 const _TransformErrorHandler = dart.typedef('_TransformErrorHandler', () => dart.functionType(dart.void, [core.Object, core.StackTrace, EventSink$(T)]));
4704 return _TransformErrorHandler;
4705 });
4706 let _TransformErrorHandler = _TransformErrorHandler$();
4707 const _TransformDoneHandler$ = dart.generic(function(T) {
4708 const _TransformDoneHandler = dart.typedef('_TransformDoneHandler', () => da rt.functionType(dart.void, [EventSink$(T)]));
4709 return _TransformDoneHandler;
4710 });
4711 let _TransformDoneHandler = _TransformDoneHandler$();
4712 const _HandlerEventSink$ = dart.generic(function(S, T) {
4713 class _HandlerEventSink extends core.Object {
4714 _HandlerEventSink(handleData, handleError, handleDone, sink) {
4715 this[_handleData] = handleData;
4716 this[_handleError] = handleError;
4717 this[_handleDone] = handleDone;
4718 this[_sink] = sink;
4719 }
4720 add(data) {
4721 dart.as(data, S);
4722 return this[_handleData](data, this[_sink]);
4723 }
4724 addError(error, stackTrace) {
4725 if (stackTrace === void 0) stackTrace = null;
4726 return this[_handleError](error, stackTrace, this[_sink]);
4727 }
4728 close() {
4729 return this[_handleDone](this[_sink]);
4730 }
4731 }
4732 _HandlerEventSink[dart.implements] = () => [EventSink$(S)];
4733 dart.setSignature(_HandlerEventSink, {
4734 constructors: () => ({_HandlerEventSink: [_HandlerEventSink$(S, T), [_Tran sformDataHandler$(S, T), _TransformErrorHandler$(T), _TransformDoneHandler$(T), EventSink$(T)]]}),
4735 methods: () => ({
4736 add: [dart.void, [S]],
4737 addError: [dart.void, [core.Object], [core.StackTrace]],
4738 close: [dart.void, []]
4739 })
4740 });
4741 return _HandlerEventSink;
4742 });
4743 let _HandlerEventSink = _HandlerEventSink$();
4744 const _StreamHandlerTransformer$ = dart.generic(function(S, T) {
4745 class _StreamHandlerTransformer extends _StreamSinkTransformer$(S, T) {
4746 _StreamHandlerTransformer(opts) {
4747 let handleData = opts && 'handleData' in opts ? opts.handleData : null;
4748 let handleError = opts && 'handleError' in opts ? opts.handleError : nul l;
4749 let handleDone = opts && 'handleDone' in opts ? opts.handleDone : null;
4750 super._StreamSinkTransformer(dart.fn(outputSink => {
4751 dart.as(outputSink, EventSink$(T));
4752 if (handleData == null) handleData = _StreamHandlerTransformer$()._def aultHandleData;
4753 if (handleError == null) handleError = _StreamHandlerTransformer$()._d efaultHandleError;
4754 if (handleDone == null) handleDone = _StreamHandlerTransformer$()._def aultHandleDone;
4755 return new (_HandlerEventSink$(S, T))(handleData, handleError, handleD one, outputSink);
4756 }, EventSink$(S), [EventSink$(T)]));
4757 }
4758 bind(stream) {
4759 dart.as(stream, Stream$(S));
4760 return super.bind(stream);
4761 }
4762 static _defaultHandleData(data, sink) {
4763 sink.add(data);
4764 }
4765 static _defaultHandleError(error, stackTrace, sink) {
4766 sink.addError(error);
4767 }
4768 static _defaultHandleDone(sink) {
4769 sink.close();
4770 }
4771 }
4772 dart.setSignature(_StreamHandlerTransformer, {
4773 constructors: () => ({_StreamHandlerTransformer: [_StreamHandlerTransforme r$(S, T), [], {handleData: dart.functionType(dart.void, [S, EventSink$(T)]), han dleError: dart.functionType(dart.void, [core.Object, core.StackTrace, EventSink$ (T)]), handleDone: dart.functionType(dart.void, [EventSink$(T)])}]}),
4774 methods: () => ({bind: [Stream$(T), [Stream$(S)]]}),
4775 statics: () => ({
4776 _defaultHandleData: [dart.void, [dart.dynamic, EventSink]],
4777 _defaultHandleError: [dart.void, [dart.dynamic, core.StackTrace, EventSi nk]],
4778 _defaultHandleDone: [dart.void, [EventSink]]
4779 }),
4780 names: ['_defaultHandleData', '_defaultHandleError', '_defaultHandleDone']
4781 });
4782 return _StreamHandlerTransformer;
4783 });
4784 let _StreamHandlerTransformer = _StreamHandlerTransformer$();
4785 const _SubscriptionTransformer$ = dart.generic(function(S, T) {
4786 const _SubscriptionTransformer = dart.typedef('_SubscriptionTransformer', () => dart.functionType(StreamSubscription$(T), [Stream$(S), core.bool]));
4787 return _SubscriptionTransformer;
4788 });
4789 let _SubscriptionTransformer = _SubscriptionTransformer$();
4790 const _transformer = Symbol('_transformer');
4791 const _StreamSubscriptionTransformer$ = dart.generic(function(S, T) {
4792 class _StreamSubscriptionTransformer extends core.Object {
4793 _StreamSubscriptionTransformer(transformer) {
4794 this[_transformer] = transformer;
4795 }
4796 bind(stream) {
4797 dart.as(stream, Stream$(S));
4798 return new (_BoundSubscriptionStream$(S, T))(stream, this[_transformer]) ;
4799 }
4800 }
4801 _StreamSubscriptionTransformer[dart.implements] = () => [StreamTransformer$( S, T)];
4802 dart.setSignature(_StreamSubscriptionTransformer, {
4803 constructors: () => ({_StreamSubscriptionTransformer: [_StreamSubscription Transformer$(S, T), [_SubscriptionTransformer$(S, T)]]}),
4804 methods: () => ({bind: [Stream$(T), [Stream$(S)]]})
4805 });
4806 return _StreamSubscriptionTransformer;
4807 });
4808 let _StreamSubscriptionTransformer = _StreamSubscriptionTransformer$();
4809 const _BoundSubscriptionStream$ = dart.generic(function(S, T) {
4810 class _BoundSubscriptionStream extends Stream$(T) {
4811 _BoundSubscriptionStream(stream, transformer) {
4812 this[_stream] = stream;
4813 this[_transformer] = transformer;
4814 super.Stream();
4815 }
4816 listen(onData, opts) {
4817 dart.as(onData, dart.functionType(dart.void, [T]));
4818 let onError = opts && 'onError' in opts ? opts.onError : null;
4819 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
4820 dart.as(onDone, dart.functionType(dart.void, []));
4821 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
4822 cancelOnError = core.identical(true, cancelOnError);
4823 let result = this[_transformer](this[_stream], cancelOnError);
4824 result.onData(onData);
4825 result.onError(onError);
4826 result.onDone(onDone);
4827 return result;
4828 }
4829 }
4830 dart.setSignature(_BoundSubscriptionStream, {
4831 constructors: () => ({_BoundSubscriptionStream: [_BoundSubscriptionStream$ (S, T), [Stream$(S), _SubscriptionTransformer$(S, T)]]}),
4832 methods: () => ({listen: [StreamSubscription$(T), [dart.functionType(dart. void, [T])], {onError: core.Function, onDone: dart.functionType(dart.void, []), cancelOnError: core.bool}]})
4833 });
4834 return _BoundSubscriptionStream;
4835 });
4836 let _BoundSubscriptionStream = _BoundSubscriptionStream$();
4837 class Timer extends core.Object {
4838 static new(duration, callback) {
4839 if (dart.equals(Zone.current, Zone.ROOT)) {
4840 return Zone.current.createTimer(duration, callback);
4841 }
4842 return Zone.current.createTimer(duration, Zone.current.bindCallback(callba ck, {runGuarded: true}));
4843 }
4844 static periodic(duration, callback) {
4845 if (dart.equals(Zone.current, Zone.ROOT)) {
4846 return Zone.current.createPeriodicTimer(duration, callback);
4847 }
4848 return Zone.current.createPeriodicTimer(duration, dart.as(Zone.current.bin dUnaryCallback(callback, {runGuarded: true}), dart.functionType(dart.void, [Time r])));
4849 }
4850 static run(callback) {
4851 Timer.new(core.Duration.ZERO, callback);
4852 }
4853 static _createTimer(duration, callback) {
4854 let milliseconds = duration.inMilliseconds;
4855 if (dart.notNull(milliseconds) < 0) milliseconds = 0;
4856 return new _isolate_helper.TimerImpl(milliseconds, callback);
4857 }
4858 static _createPeriodicTimer(duration, callback) {
4859 let milliseconds = duration.inMilliseconds;
4860 if (dart.notNull(milliseconds) < 0) milliseconds = 0;
4861 return new _isolate_helper.TimerImpl.periodic(milliseconds, callback);
4862 }
4863 }
4864 dart.setSignature(Timer, {
4865 constructors: () => ({
4866 new: [Timer, [core.Duration, dart.functionType(dart.void, [])]],
4867 periodic: [Timer, [core.Duration, dart.functionType(dart.void, [Timer])]]
4868 }),
4869 statics: () => ({
4870 run: [dart.void, [dart.functionType(dart.void, [])]],
4871 _createTimer: [Timer, [core.Duration, dart.functionType(dart.void, [])]],
4872 _createPeriodicTimer: [Timer, [core.Duration, dart.functionType(dart.void, [Timer])]]
4873 }),
4874 names: ['run', '_createTimer', '_createPeriodicTimer']
4875 });
4876 const ZoneCallback = dart.typedef('ZoneCallback', () => dart.functionType(dart .dynamic, []));
4877 const ZoneUnaryCallback = dart.typedef('ZoneUnaryCallback', () => dart.functio nType(dart.dynamic, [dart.dynamic]));
4878 const ZoneBinaryCallback = dart.typedef('ZoneBinaryCallback', () => dart.funct ionType(dart.dynamic, [dart.dynamic, dart.dynamic]));
4879 const HandleUncaughtErrorHandler = dart.typedef('HandleUncaughtErrorHandler', () => dart.functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.dynamic, c ore.StackTrace]));
4880 const RunHandler = dart.typedef('RunHandler', () => dart.functionType(dart.dyn amic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [])]));
4881 const RunUnaryHandler = dart.typedef('RunUnaryHandler', () => dart.functionTyp e(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [dart .dynamic]), dart.dynamic]));
4882 const RunBinaryHandler = dart.typedef('RunBinaryHandler', () => dart.functionT ype(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [da rt.dynamic, dart.dynamic]), dart.dynamic, dart.dynamic]));
4883 const RegisterCallbackHandler = dart.typedef('RegisterCallbackHandler', () => dart.functionType(ZoneCallback, [Zone, ZoneDelegate, Zone, dart.functionType(dar t.dynamic, [])]));
4884 const RegisterUnaryCallbackHandler = dart.typedef('RegisterUnaryCallbackHandle r', () => dart.functionType(ZoneUnaryCallback, [Zone, ZoneDelegate, Zone, dart.f unctionType(dart.dynamic, [dart.dynamic])]));
4885 const RegisterBinaryCallbackHandler = dart.typedef('RegisterBinaryCallbackHand ler', () => dart.functionType(ZoneBinaryCallback, [Zone, ZoneDelegate, Zone, dar t.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])]));
4886 const ErrorCallbackHandler = dart.typedef('ErrorCallbackHandler', () => dart.f unctionType(AsyncError, [Zone, ZoneDelegate, Zone, core.Object, core.StackTrace] ));
4887 const ScheduleMicrotaskHandler = dart.typedef('ScheduleMicrotaskHandler', () = > dart.functionType(dart.void, [Zone, ZoneDelegate, Zone, dart.functionType(dart .dynamic, [])]));
4888 const CreateTimerHandler = dart.typedef('CreateTimerHandler', () => dart.funct ionType(Timer, [Zone, ZoneDelegate, Zone, core.Duration, dart.functionType(dart. void, [])]));
4889 const CreatePeriodicTimerHandler = dart.typedef('CreatePeriodicTimerHandler', () => dart.functionType(Timer, [Zone, ZoneDelegate, Zone, core.Duration, dart.fu nctionType(dart.void, [Timer])]));
4890 const PrintHandler = dart.typedef('PrintHandler', () => dart.functionType(dart .void, [Zone, ZoneDelegate, Zone, core.String]));
4891 const ForkHandler = dart.typedef('ForkHandler', () => dart.functionType(Zone, [Zone, ZoneDelegate, Zone, ZoneSpecification, core.Map]));
4892 class _ZoneFunction extends core.Object {
4893 _ZoneFunction(zone, func) {
4894 this.zone = zone;
4895 this.function = func;
4896 }
4897 }
4898 dart.setSignature(_ZoneFunction, {
4899 constructors: () => ({_ZoneFunction: [_ZoneFunction, [_Zone, core.Function]] })
4900 });
4901 class ZoneSpecification extends core.Object {
4902 static new(opts) {
4903 return new _ZoneSpecification(opts);
4904 }
4905 static from(other, opts) {
4906 let handleUncaughtError = opts && 'handleUncaughtError' in opts ? opts.han dleUncaughtError : null;
4907 let run = opts && 'run' in opts ? opts.run : null;
4908 let runUnary = opts && 'runUnary' in opts ? opts.runUnary : null;
4909 let runBinary = opts && 'runBinary' in opts ? opts.runBinary : null;
4910 let registerCallback = opts && 'registerCallback' in opts ? opts.registerC allback : null;
4911 let registerUnaryCallback = opts && 'registerUnaryCallback' in opts ? opts .registerUnaryCallback : null;
4912 let registerBinaryCallback = opts && 'registerBinaryCallback' in opts ? op ts.registerBinaryCallback : null;
4913 let errorCallback = opts && 'errorCallback' in opts ? opts.errorCallback : null;
4914 let scheduleMicrotask = opts && 'scheduleMicrotask' in opts ? opts.schedul eMicrotask : null;
4915 let createTimer = opts && 'createTimer' in opts ? opts.createTimer : null;
4916 let createPeriodicTimer = opts && 'createPeriodicTimer' in opts ? opts.cre atePeriodicTimer : null;
4917 let print = opts && 'print' in opts ? opts.print : null;
4918 let fork = opts && 'fork' in opts ? opts.fork : null;
4919 return ZoneSpecification.new({handleUncaughtError: handleUncaughtError != null ? handleUncaughtError : other.handleUncaughtError, run: run != null ? run : other.run, runUnary: runUnary != null ? runUnary : other.runUnary, runBinary: r unBinary != null ? runBinary : other.runBinary, registerCallback: registerCallba ck != null ? registerCallback : other.registerCallback, registerUnaryCallback: r egisterUnaryCallback != null ? registerUnaryCallback : other.registerUnaryCallba ck, registerBinaryCallback: registerBinaryCallback != null ? registerBinaryCallb ack : other.registerBinaryCallback, errorCallback: errorCallback != null ? error Callback : other.errorCallback, scheduleMicrotask: scheduleMicrotask != null ? s cheduleMicrotask : other.scheduleMicrotask, createTimer: createTimer != null ? c reateTimer : other.createTimer, createPeriodicTimer: createPeriodicTimer != null ? createPeriodicTimer : other.createPeriodicTimer, print: print != null ? print : other.print, fork: fork != null ? fork : other.fork});
4920 }
4921 }
4922 dart.setSignature(ZoneSpecification, {
4923 constructors: () => ({
4924 new: [ZoneSpecification, [], {handleUncaughtError: dart.functionType(dart. dynamic, [Zone, ZoneDelegate, Zone, dart.dynamic, core.StackTrace]), run: dart.f unctionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dyna mic, [])]), runUnary: dart.functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [dart.dynamic]), dart.dynamic]), runBinary: dar t.functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(dart.d ynamic, [dart.dynamic, dart.dynamic]), dart.dynamic, dart.dynamic]), registerCal lback: dart.functionType(ZoneCallback, [Zone, ZoneDelegate, Zone, dart.functionT ype(dart.dynamic, [])]), registerUnaryCallback: dart.functionType(ZoneUnaryCallb ack, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [dart.dynamic])] ), registerBinaryCallback: dart.functionType(ZoneBinaryCallback, [Zone, ZoneDele gate, Zone, dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])]), err orCallback: dart.functionType(AsyncError, [Zone, ZoneDelegate, Zone, core.Object , core.StackTrace]), scheduleMicrotask: dart.functionType(dart.void, [Zone, Zone Delegate, Zone, dart.functionType(dart.dynamic, [])]), createTimer: dart.functio nType(Timer, [Zone, ZoneDelegate, Zone, core.Duration, dart.functionType(dart.vo id, [])]), createPeriodicTimer: dart.functionType(Timer, [Zone, ZoneDelegate, Zo ne, core.Duration, dart.functionType(dart.void, [Timer])]), print: dart.function Type(dart.void, [Zone, ZoneDelegate, Zone, core.String]), fork: dart.functionTyp e(Zone, [Zone, ZoneDelegate, Zone, ZoneSpecification, core.Map])}],
4925 from: [ZoneSpecification, [ZoneSpecification], {handleUncaughtError: dart. functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.dynamic, core.StackTr ace]), run: dart.functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.func tionType(dart.dynamic, [])]), runUnary: dart.functionType(dart.dynamic, [Zone, Z oneDelegate, Zone, dart.functionType(dart.dynamic, [dart.dynamic]), dart.dynamic ]), runBinary: dart.functionType(dart.dynamic, [Zone, ZoneDelegate, Zone, dart.f unctionType(dart.dynamic, [dart.dynamic, dart.dynamic]), dart.dynamic, dart.dyna mic]), registerCallback: dart.functionType(ZoneCallback, [Zone, ZoneDelegate, Zo ne, dart.functionType(dart.dynamic, [])]), registerUnaryCallback: dart.functionT ype(ZoneUnaryCallback, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic , [dart.dynamic])]), registerBinaryCallback: dart.functionType(ZoneBinaryCallbac k, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [dart.dynamic, dar t.dynamic])]), errorCallback: dart.functionType(AsyncError, [Zone, ZoneDelegate, Zone, core.Object, core.StackTrace]), scheduleMicrotask: dart.functionType(dart .void, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [])]), createT imer: dart.functionType(Timer, [Zone, ZoneDelegate, Zone, core.Duration, dart.fu nctionType(dart.void, [])]), createPeriodicTimer: dart.functionType(Timer, [Zone , ZoneDelegate, Zone, core.Duration, dart.functionType(dart.void, [Timer])]), pr int: dart.functionType(dart.void, [Zone, ZoneDelegate, Zone, core.String]), fork : dart.functionType(Zone, [Zone, ZoneDelegate, Zone, ZoneSpecification, core.Map ])}]
4926 })
4927 });
4928 class _ZoneSpecification extends core.Object {
4929 _ZoneSpecification(opts) {
4930 let handleUncaughtError = opts && 'handleUncaughtError' in opts ? opts.han dleUncaughtError : null;
4931 let run = opts && 'run' in opts ? opts.run : null;
4932 let runUnary = opts && 'runUnary' in opts ? opts.runUnary : null;
4933 let runBinary = opts && 'runBinary' in opts ? opts.runBinary : null;
4934 let registerCallback = opts && 'registerCallback' in opts ? opts.registerC allback : null;
4935 let registerUnaryCallback = opts && 'registerUnaryCallback' in opts ? opts .registerUnaryCallback : null;
4936 let registerBinaryCallback = opts && 'registerBinaryCallback' in opts ? op ts.registerBinaryCallback : null;
4937 let errorCallback = opts && 'errorCallback' in opts ? opts.errorCallback : null;
4938 let scheduleMicrotask = opts && 'scheduleMicrotask' in opts ? opts.schedul eMicrotask : null;
4939 let createTimer = opts && 'createTimer' in opts ? opts.createTimer : null;
4940 let createPeriodicTimer = opts && 'createPeriodicTimer' in opts ? opts.cre atePeriodicTimer : null;
4941 let print = opts && 'print' in opts ? opts.print : null;
4942 let fork = opts && 'fork' in opts ? opts.fork : null;
4943 this.handleUncaughtError = handleUncaughtError;
4944 this.run = run;
4945 this.runUnary = runUnary;
4946 this.runBinary = runBinary;
4947 this.registerCallback = registerCallback;
4948 this.registerUnaryCallback = registerUnaryCallback;
4949 this.registerBinaryCallback = registerBinaryCallback;
4950 this.errorCallback = errorCallback;
4951 this.scheduleMicrotask = scheduleMicrotask;
4952 this.createTimer = createTimer;
4953 this.createPeriodicTimer = createPeriodicTimer;
4954 this.print = print;
4955 this.fork = fork;
4956 }
4957 }
4958 _ZoneSpecification[dart.implements] = () => [ZoneSpecification];
4959 dart.setSignature(_ZoneSpecification, {
4960 constructors: () => ({_ZoneSpecification: [_ZoneSpecification, [], {handleUn caughtError: HandleUncaughtErrorHandler, run: RunHandler, runUnary: RunUnaryHand ler, runBinary: RunBinaryHandler, registerCallback: RegisterCallbackHandler, reg isterUnaryCallback: RegisterUnaryCallbackHandler, registerBinaryCallback: Regist erBinaryCallbackHandler, errorCallback: ErrorCallbackHandler, scheduleMicrotask: ScheduleMicrotaskHandler, createTimer: CreateTimerHandler, createPeriodicTimer: CreatePeriodicTimerHandler, print: PrintHandler, fork: ForkHandler}]})
4961 });
4962 class ZoneDelegate extends core.Object {}
4963 class Zone extends core.Object {
4964 _() {
4965 }
4966 static get current() {
4967 return Zone._current;
4968 }
4969 static _enter(zone) {
4970 dart.assert(zone != null);
4971 dart.assert(!core.identical(zone, Zone._current));
4972 let previous = Zone._current;
4973 Zone._current = zone;
4974 return previous;
4975 }
4976 static _leave(previous) {
4977 dart.assert(previous != null);
4978 Zone._current = previous;
4979 }
4980 }
4981 dart.defineNamedConstructor(Zone, '_');
4982 dart.setSignature(Zone, {
4983 constructors: () => ({_: [Zone, []]}),
4984 statics: () => ({
4985 _enter: [Zone, [Zone]],
4986 _leave: [dart.void, [Zone]]
4987 }),
4988 names: ['_enter', '_leave']
4989 });
4990 dart.defineLazyProperties(Zone, {
4991 get ROOT() {
4992 return _ROOT_ZONE;
4993 },
4994 get _current() {
4995 return _ROOT_ZONE;
4996 },
4997 set _current(_) {}
4998 });
4999 const _delegate = Symbol('_delegate');
5000 function _parentDelegate(zone) {
5001 if (zone.parent == null) return null;
5002 return zone.parent[_delegate];
5003 }
5004 dart.fn(_parentDelegate, () => dart.definiteFunctionType(ZoneDelegate, [_Zone] ));
5005 const _delegationTarget = Symbol('_delegationTarget');
5006 const _handleUncaughtError = Symbol('_handleUncaughtError');
5007 const _run = Symbol('_run');
5008 const _runUnary = Symbol('_runUnary');
5009 const _runBinary = Symbol('_runBinary');
5010 const _registerCallback = Symbol('_registerCallback');
5011 const _registerUnaryCallback = Symbol('_registerUnaryCallback');
5012 const _registerBinaryCallback = Symbol('_registerBinaryCallback');
5013 const _errorCallback = Symbol('_errorCallback');
5014 const _scheduleMicrotask = Symbol('_scheduleMicrotask');
5015 const _createTimer = Symbol('_createTimer');
5016 const _createPeriodicTimer = Symbol('_createPeriodicTimer');
5017 const _print = Symbol('_print');
5018 const _fork = Symbol('_fork');
5019 class _ZoneDelegate extends core.Object {
5020 _ZoneDelegate(delegationTarget) {
5021 this[_delegationTarget] = delegationTarget;
5022 }
5023 handleUncaughtError(zone, error, stackTrace) {
5024 let implementation = this[_delegationTarget][_handleUncaughtError];
5025 let implZone = implementation.zone;
5026 return dart.dcall(implementation.function, implZone, _parentDelegate(implZ one), zone, error, stackTrace);
5027 }
5028 run(zone, f) {
5029 let implementation = this[_delegationTarget][_run];
5030 let implZone = implementation.zone;
5031 return dart.dcall(implementation.function, implZone, _parentDelegate(implZ one), zone, f);
5032 }
5033 runUnary(zone, f, arg) {
5034 let implementation = this[_delegationTarget][_runUnary];
5035 let implZone = implementation.zone;
5036 return dart.dcall(implementation.function, implZone, _parentDelegate(implZ one), zone, f, arg);
5037 }
5038 runBinary(zone, f, arg1, arg2) {
5039 let implementation = this[_delegationTarget][_runBinary];
5040 let implZone = implementation.zone;
5041 return dart.dcall(implementation.function, implZone, _parentDelegate(implZ one), zone, f, arg1, arg2);
5042 }
5043 registerCallback(zone, f) {
5044 let implementation = this[_delegationTarget][_registerCallback];
5045 let implZone = implementation.zone;
5046 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, f), ZoneCallback);
5047 }
5048 registerUnaryCallback(zone, f) {
5049 let implementation = this[_delegationTarget][_registerUnaryCallback];
5050 let implZone = implementation.zone;
5051 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, f), ZoneUnaryCallback);
5052 }
5053 registerBinaryCallback(zone, f) {
5054 let implementation = this[_delegationTarget][_registerBinaryCallback];
5055 let implZone = implementation.zone;
5056 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, f), ZoneBinaryCallback);
5057 }
5058 errorCallback(zone, error, stackTrace) {
5059 let implementation = this[_delegationTarget][_errorCallback];
5060 let implZone = implementation.zone;
5061 if (core.identical(implZone, _ROOT_ZONE)) return null;
5062 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, error, stackTrace), AsyncError);
5063 }
5064 scheduleMicrotask(zone, f) {
5065 let implementation = this[_delegationTarget][_scheduleMicrotask];
5066 let implZone = implementation.zone;
5067 dart.dcall(implementation.function, implZone, _parentDelegate(implZone), z one, f);
5068 }
5069 createTimer(zone, duration, f) {
5070 let implementation = this[_delegationTarget][_createTimer];
5071 let implZone = implementation.zone;
5072 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, duration, f), Timer);
5073 }
5074 createPeriodicTimer(zone, period, f) {
5075 let implementation = this[_delegationTarget][_createPeriodicTimer];
5076 let implZone = implementation.zone;
5077 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, period, f), Timer);
5078 }
5079 print(zone, line) {
5080 let implementation = this[_delegationTarget][_print];
5081 let implZone = implementation.zone;
5082 dart.dcall(implementation.function, implZone, _parentDelegate(implZone), z one, line);
5083 }
5084 fork(zone, specification, zoneValues) {
5085 let implementation = this[_delegationTarget][_fork];
5086 let implZone = implementation.zone;
5087 return dart.as(dart.dcall(implementation.function, implZone, _parentDelega te(implZone), zone, specification, zoneValues), Zone);
5088 }
5089 }
5090 _ZoneDelegate[dart.implements] = () => [ZoneDelegate];
5091 dart.setSignature(_ZoneDelegate, {
5092 constructors: () => ({_ZoneDelegate: [_ZoneDelegate, [_Zone]]}),
5093 methods: () => ({
5094 handleUncaughtError: [dart.dynamic, [Zone, dart.dynamic, core.StackTrace]] ,
5095 run: [dart.dynamic, [Zone, dart.functionType(dart.dynamic, [])]],
5096 runUnary: [dart.dynamic, [Zone, dart.functionType(dart.dynamic, [dart.dyna mic]), dart.dynamic]],
5097 runBinary: [dart.dynamic, [Zone, dart.functionType(dart.dynamic, [dart.dyn amic, dart.dynamic]), dart.dynamic, dart.dynamic]],
5098 registerCallback: [ZoneCallback, [Zone, dart.functionType(dart.dynamic, [] )]],
5099 registerUnaryCallback: [ZoneUnaryCallback, [Zone, dart.functionType(dart.d ynamic, [dart.dynamic])]],
5100 registerBinaryCallback: [ZoneBinaryCallback, [Zone, dart.functionType(dart .dynamic, [dart.dynamic, dart.dynamic])]],
5101 errorCallback: [AsyncError, [Zone, core.Object, core.StackTrace]],
5102 scheduleMicrotask: [dart.void, [Zone, dart.functionType(dart.dynamic, [])] ],
5103 createTimer: [Timer, [Zone, core.Duration, dart.functionType(dart.void, [] )]],
5104 createPeriodicTimer: [Timer, [Zone, core.Duration, dart.functionType(dart. void, [Timer])]],
5105 print: [dart.void, [Zone, core.String]],
5106 fork: [Zone, [Zone, ZoneSpecification, core.Map]]
5107 })
5108 });
5109 class _Zone extends core.Object {
5110 _Zone() {
5111 }
5112 inSameErrorZone(otherZone) {
5113 return core.identical(this, otherZone) || core.identical(this.errorZone, o therZone.errorZone);
5114 }
5115 }
5116 _Zone[dart.implements] = () => [Zone];
5117 dart.setSignature(_Zone, {
5118 constructors: () => ({_Zone: [_Zone, []]}),
5119 methods: () => ({inSameErrorZone: [core.bool, [Zone]]})
5120 });
5121 const _delegateCache = Symbol('_delegateCache');
5122 const _map = Symbol('_map');
5123 class _CustomZone extends _Zone {
5124 get [_delegate]() {
5125 if (this[_delegateCache] != null) return this[_delegateCache];
5126 this[_delegateCache] = new _ZoneDelegate(this);
5127 return this[_delegateCache];
5128 }
5129 _CustomZone(parent, specification, map) {
5130 this.parent = parent;
5131 this[_map] = map;
5132 this[_runUnary] = null;
5133 this[_run] = null;
5134 this[_runBinary] = null;
5135 this[_registerCallback] = null;
5136 this[_registerUnaryCallback] = null;
5137 this[_registerBinaryCallback] = null;
5138 this[_errorCallback] = null;
5139 this[_scheduleMicrotask] = null;
5140 this[_createTimer] = null;
5141 this[_createPeriodicTimer] = null;
5142 this[_print] = null;
5143 this[_fork] = null;
5144 this[_handleUncaughtError] = null;
5145 this[_delegateCache] = null;
5146 super._Zone();
5147 this[_run] = specification.run != null ? new _ZoneFunction(this, specifica tion.run) : this.parent[_run];
5148 this[_runUnary] = specification.runUnary != null ? new _ZoneFunction(this, specification.runUnary) : this.parent[_runUnary];
5149 this[_runBinary] = specification.runBinary != null ? new _ZoneFunction(thi s, specification.runBinary) : this.parent[_runBinary];
5150 this[_registerCallback] = specification.registerCallback != null ? new _Zo neFunction(this, specification.registerCallback) : this.parent[_registerCallback ];
5151 this[_registerUnaryCallback] = specification.registerUnaryCallback != null ? new _ZoneFunction(this, specification.registerUnaryCallback) : this.parent[_r egisterUnaryCallback];
5152 this[_registerBinaryCallback] = specification.registerBinaryCallback != nu ll ? new _ZoneFunction(this, specification.registerBinaryCallback) : this.parent [_registerBinaryCallback];
5153 this[_errorCallback] = specification.errorCallback != null ? new _ZoneFunc tion(this, specification.errorCallback) : this.parent[_errorCallback];
5154 this[_scheduleMicrotask] = specification.scheduleMicrotask != null ? new _ ZoneFunction(this, specification.scheduleMicrotask) : this.parent[_scheduleMicro task];
5155 this[_createTimer] = specification.createTimer != null ? new _ZoneFunction (this, specification.createTimer) : this.parent[_createTimer];
5156 this[_createPeriodicTimer] = specification.createPeriodicTimer != null ? n ew _ZoneFunction(this, specification.createPeriodicTimer) : this.parent[_createP eriodicTimer];
5157 this[_print] = specification.print != null ? new _ZoneFunction(this, speci fication.print) : this.parent[_print];
5158 this[_fork] = specification.fork != null ? new _ZoneFunction(this, specifi cation.fork) : this.parent[_fork];
5159 this[_handleUncaughtError] = specification.handleUncaughtError != null ? n ew _ZoneFunction(this, specification.handleUncaughtError) : this.parent[_handleU ncaughtError];
5160 }
5161 get errorZone() {
5162 return this[_handleUncaughtError].zone;
5163 }
5164 runGuarded(f) {
5165 try {
5166 return this.run(f);
5167 } catch (e) {
5168 let s = dart.stackTrace(e);
5169 return this.handleUncaughtError(e, s);
5170 }
5171
5172 }
5173 runUnaryGuarded(f, arg) {
5174 try {
5175 return this.runUnary(f, arg);
5176 } catch (e) {
5177 let s = dart.stackTrace(e);
5178 return this.handleUncaughtError(e, s);
5179 }
5180
5181 }
5182 runBinaryGuarded(f, arg1, arg2) {
5183 try {
5184 return this.runBinary(f, arg1, arg2);
5185 } catch (e) {
5186 let s = dart.stackTrace(e);
5187 return this.handleUncaughtError(e, s);
5188 }
5189
5190 }
5191 bindCallback(f, opts) {
5192 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5193 let registered = this.registerCallback(f);
5194 if (dart.notNull(runGuarded)) {
5195 return dart.fn(() => this.runGuarded(registered));
5196 } else {
5197 return dart.fn(() => this.run(registered));
5198 }
5199 }
5200 bindUnaryCallback(f, opts) {
5201 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5202 let registered = this.registerUnaryCallback(f);
5203 if (dart.notNull(runGuarded)) {
5204 return dart.fn(arg => this.runUnaryGuarded(registered, arg));
5205 } else {
5206 return dart.fn(arg => this.runUnary(registered, arg));
5207 }
5208 }
5209 bindBinaryCallback(f, opts) {
5210 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5211 let registered = this.registerBinaryCallback(f);
5212 if (dart.notNull(runGuarded)) {
5213 return dart.fn((arg1, arg2) => this.runBinaryGuarded(registered, arg1, a rg2));
5214 } else {
5215 return dart.fn((arg1, arg2) => this.runBinary(registered, arg1, arg2));
5216 }
5217 }
5218 get(key) {
5219 let result = this[_map][dartx.get](key);
5220 if (result != null || dart.notNull(this[_map][dartx.containsKey](key))) re turn result;
5221 if (this.parent != null) {
5222 let value = this.parent.get(key);
5223 if (value != null) {
5224 this[_map][dartx.set](key, value);
5225 }
5226 return value;
5227 }
5228 dart.assert(dart.equals(this, _ROOT_ZONE));
5229 return null;
5230 }
5231 handleUncaughtError(error, stackTrace) {
5232 let implementation = this[_handleUncaughtError];
5233 dart.assert(implementation != null);
5234 let parentDelegate = _parentDelegate(implementation.zone);
5235 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, error, stackTrace);
5236 }
5237 fork(opts) {
5238 let specification = opts && 'specification' in opts ? opts.specification : null;
5239 let zoneValues = opts && 'zoneValues' in opts ? opts.zoneValues : null;
5240 let implementation = this[_fork];
5241 dart.assert(implementation != null);
5242 let parentDelegate = _parentDelegate(implementation.zone);
5243 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, specification, zoneValues), Zone);
5244 }
5245 run(f) {
5246 let implementation = this[_run];
5247 dart.assert(implementation != null);
5248 let parentDelegate = _parentDelegate(implementation.zone);
5249 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, f);
5250 }
5251 runUnary(f, arg) {
5252 let implementation = this[_runUnary];
5253 dart.assert(implementation != null);
5254 let parentDelegate = _parentDelegate(implementation.zone);
5255 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, f, arg);
5256 }
5257 runBinary(f, arg1, arg2) {
5258 let implementation = this[_runBinary];
5259 dart.assert(implementation != null);
5260 let parentDelegate = _parentDelegate(implementation.zone);
5261 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, f, arg1, arg2);
5262 }
5263 registerCallback(f) {
5264 let implementation = this[_registerCallback];
5265 dart.assert(implementation != null);
5266 let parentDelegate = _parentDelegate(implementation.zone);
5267 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, f), ZoneCallback);
5268 }
5269 registerUnaryCallback(f) {
5270 let implementation = this[_registerUnaryCallback];
5271 dart.assert(implementation != null);
5272 let parentDelegate = _parentDelegate(implementation.zone);
5273 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, f), ZoneUnaryCallback);
5274 }
5275 registerBinaryCallback(f) {
5276 let implementation = this[_registerBinaryCallback];
5277 dart.assert(implementation != null);
5278 let parentDelegate = _parentDelegate(implementation.zone);
5279 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, f), ZoneBinaryCallback);
5280 }
5281 errorCallback(error, stackTrace) {
5282 let implementation = this[_errorCallback];
5283 dart.assert(implementation != null);
5284 let implementationZone = implementation.zone;
5285 if (core.identical(implementationZone, _ROOT_ZONE)) return null;
5286 let parentDelegate = _parentDelegate(dart.as(implementationZone, _Zone));
5287 return dart.as(dart.dcall(implementation.function, implementationZone, par entDelegate, this, error, stackTrace), AsyncError);
5288 }
5289 scheduleMicrotask(f) {
5290 let implementation = this[_scheduleMicrotask];
5291 dart.assert(implementation != null);
5292 let parentDelegate = _parentDelegate(implementation.zone);
5293 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, f);
5294 }
5295 createTimer(duration, f) {
5296 let implementation = this[_createTimer];
5297 dart.assert(implementation != null);
5298 let parentDelegate = _parentDelegate(implementation.zone);
5299 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, duration, f), Timer);
5300 }
5301 createPeriodicTimer(duration, f) {
5302 let implementation = this[_createPeriodicTimer];
5303 dart.assert(implementation != null);
5304 let parentDelegate = _parentDelegate(implementation.zone);
5305 return dart.as(dart.dcall(implementation.function, implementation.zone, pa rentDelegate, this, duration, f), Timer);
5306 }
5307 print(line) {
5308 let implementation = this[_print];
5309 dart.assert(implementation != null);
5310 let parentDelegate = _parentDelegate(implementation.zone);
5311 return dart.dcall(implementation.function, implementation.zone, parentDele gate, this, line);
5312 }
5313 }
5314 dart.setSignature(_CustomZone, {
5315 constructors: () => ({_CustomZone: [_CustomZone, [_Zone, ZoneSpecification, core.Map]]}),
5316 methods: () => ({
5317 runGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [])]],
5318 runUnaryGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dyn amic]), dart.dynamic]],
5319 runBinaryGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dy namic, dart.dynamic]), dart.dynamic, dart.dynamic]],
5320 bindCallback: [ZoneCallback, [dart.functionType(dart.dynamic, [])], {runGu arded: core.bool}],
5321 bindUnaryCallback: [ZoneUnaryCallback, [dart.functionType(dart.dynamic, [d art.dynamic])], {runGuarded: core.bool}],
5322 bindBinaryCallback: [ZoneBinaryCallback, [dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])], {runGuarded: core.bool}],
5323 get: [dart.dynamic, [core.Object]],
5324 handleUncaughtError: [dart.dynamic, [dart.dynamic, core.StackTrace]],
5325 fork: [Zone, [], {specification: ZoneSpecification, zoneValues: core.Map}] ,
5326 run: [dart.dynamic, [dart.functionType(dart.dynamic, [])]],
5327 runUnary: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dynamic]), dart.dynamic]],
5328 runBinary: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic]), dart.dynamic, dart.dynamic]],
5329 registerCallback: [ZoneCallback, [dart.functionType(dart.dynamic, [])]],
5330 registerUnaryCallback: [ZoneUnaryCallback, [dart.functionType(dart.dynamic , [dart.dynamic])]],
5331 registerBinaryCallback: [ZoneBinaryCallback, [dart.functionType(dart.dynam ic, [dart.dynamic, dart.dynamic])]],
5332 errorCallback: [AsyncError, [core.Object, core.StackTrace]],
5333 scheduleMicrotask: [dart.void, [dart.functionType(dart.void, [])]],
5334 createTimer: [Timer, [core.Duration, dart.functionType(dart.void, [])]],
5335 createPeriodicTimer: [Timer, [core.Duration, dart.functionType(dart.void, [Timer])]],
5336 print: [dart.void, [core.String]]
5337 })
5338 });
5339 function _rootHandleUncaughtError(self, parent, zone, error, stackTrace) {
5340 _schedulePriorityAsyncCallback(dart.fn(() => {
5341 dart.throw(new _UncaughtAsyncError(error, stackTrace));
5342 }));
5343 }
5344 dart.fn(_rootHandleUncaughtError, dart.void, [Zone, ZoneDelegate, Zone, dart.d ynamic, core.StackTrace]);
5345 function _rootRun(self, parent, zone, f) {
5346 if (dart.equals(Zone._current, zone)) return f();
5347 let old = Zone._enter(zone);
5348 try {
5349 return f();
5350 } finally {
5351 Zone._leave(old);
5352 }
5353 }
5354 dart.fn(_rootRun, dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionType(d art.dynamic, [])]);
5355 function _rootRunUnary(self, parent, zone, f, arg) {
5356 if (dart.equals(Zone._current, zone)) return dart.dcall(f, arg);
5357 let old = Zone._enter(zone);
5358 try {
5359 return dart.dcall(f, arg);
5360 } finally {
5361 Zone._leave(old);
5362 }
5363 }
5364 dart.fn(_rootRunUnary, dart.dynamic, [Zone, ZoneDelegate, Zone, dart.functionT ype(dart.dynamic, [dart.dynamic]), dart.dynamic]);
5365 function _rootRunBinary(self, parent, zone, f, arg1, arg2) {
5366 if (dart.equals(Zone._current, zone)) return dart.dcall(f, arg1, arg2);
5367 let old = Zone._enter(zone);
5368 try {
5369 return dart.dcall(f, arg1, arg2);
5370 } finally {
5371 Zone._leave(old);
5372 }
5373 }
5374 dart.fn(_rootRunBinary, dart.dynamic, [Zone, ZoneDelegate, Zone, dart.function Type(dart.dynamic, [dart.dynamic, dart.dynamic]), dart.dynamic, dart.dynamic]);
5375 function _rootRegisterCallback(self, parent, zone, f) {
5376 return f;
5377 }
5378 dart.fn(_rootRegisterCallback, ZoneCallback, [Zone, ZoneDelegate, Zone, dart.f unctionType(dart.dynamic, [])]);
5379 function _rootRegisterUnaryCallback(self, parent, zone, f) {
5380 return f;
5381 }
5382 dart.fn(_rootRegisterUnaryCallback, ZoneUnaryCallback, [Zone, ZoneDelegate, Zo ne, dart.functionType(dart.dynamic, [dart.dynamic])]);
5383 function _rootRegisterBinaryCallback(self, parent, zone, f) {
5384 return f;
5385 }
5386 dart.fn(_rootRegisterBinaryCallback, ZoneBinaryCallback, [Zone, ZoneDelegate, Zone, dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])]);
5387 function _rootErrorCallback(self, parent, zone, error, stackTrace) {
5388 return null;
5389 }
5390 dart.fn(_rootErrorCallback, AsyncError, [Zone, ZoneDelegate, Zone, core.Object , core.StackTrace]);
5391 function _rootScheduleMicrotask(self, parent, zone, f) {
5392 if (!core.identical(_ROOT_ZONE, zone)) {
5393 let hasErrorHandler = !dart.notNull(_ROOT_ZONE.inSameErrorZone(zone));
5394 f = zone.bindCallback(f, {runGuarded: hasErrorHandler});
5395 }
5396 _scheduleAsyncCallback(f);
5397 }
5398 dart.fn(_rootScheduleMicrotask, dart.void, [Zone, ZoneDelegate, Zone, dart.fun ctionType(dart.dynamic, [])]);
5399 function _rootCreateTimer(self, parent, zone, duration, callback) {
5400 if (!core.identical(_ROOT_ZONE, zone)) {
5401 callback = zone.bindCallback(callback);
5402 }
5403 return Timer._createTimer(duration, callback);
5404 }
5405 dart.fn(_rootCreateTimer, Timer, [Zone, ZoneDelegate, Zone, core.Duration, dar t.functionType(dart.void, [])]);
5406 function _rootCreatePeriodicTimer(self, parent, zone, duration, callback) {
5407 if (!core.identical(_ROOT_ZONE, zone)) {
5408 callback = dart.as(zone.bindUnaryCallback(callback), dart.functionType(dar t.void, [Timer]));
5409 }
5410 return Timer._createPeriodicTimer(duration, callback);
5411 }
5412 dart.fn(_rootCreatePeriodicTimer, Timer, [Zone, ZoneDelegate, Zone, core.Durat ion, dart.functionType(dart.void, [Timer])]);
5413 function _rootPrint(self, parent, zone, line) {
5414 _internal.printToConsole(line);
5415 }
5416 dart.fn(_rootPrint, dart.void, [Zone, ZoneDelegate, Zone, core.String]);
5417 function _printToZone(line) {
5418 Zone.current.print(line);
5419 }
5420 dart.fn(_printToZone, dart.void, [core.String]);
5421 function _rootFork(self, parent, zone, specification, zoneValues) {
5422 _internal.printToZone = _printToZone;
5423 if (specification == null) {
5424 specification = dart.const(ZoneSpecification.new());
5425 } else if (!dart.is(specification, _ZoneSpecification)) {
5426 dart.throw(new core.ArgumentError("ZoneSpecifications must be instantiated " + " with the provided constructor."));
5427 }
5428 let valueMap = null;
5429 if (zoneValues == null) {
5430 if (dart.is(zone, _Zone)) {
5431 valueMap = zone[_map];
5432 } else {
5433 valueMap = collection.HashMap.new();
5434 }
5435 } else {
5436 valueMap = collection.HashMap.from(zoneValues);
5437 }
5438 return new _CustomZone(dart.as(zone, _Zone), specification, valueMap);
5439 }
5440 dart.fn(_rootFork, Zone, [Zone, ZoneDelegate, Zone, ZoneSpecification, core.Ma p]);
5441 class _RootZoneSpecification extends core.Object {
5442 get handleUncaughtError() {
5443 return _rootHandleUncaughtError;
5444 }
5445 get run() {
5446 return _rootRun;
5447 }
5448 get runUnary() {
5449 return _rootRunUnary;
5450 }
5451 get runBinary() {
5452 return _rootRunBinary;
5453 }
5454 get registerCallback() {
5455 return _rootRegisterCallback;
5456 }
5457 get registerUnaryCallback() {
5458 return _rootRegisterUnaryCallback;
5459 }
5460 get registerBinaryCallback() {
5461 return _rootRegisterBinaryCallback;
5462 }
5463 get errorCallback() {
5464 return _rootErrorCallback;
5465 }
5466 get scheduleMicrotask() {
5467 return _rootScheduleMicrotask;
5468 }
5469 get createTimer() {
5470 return _rootCreateTimer;
5471 }
5472 get createPeriodicTimer() {
5473 return _rootCreatePeriodicTimer;
5474 }
5475 get print() {
5476 return _rootPrint;
5477 }
5478 get fork() {
5479 return _rootFork;
5480 }
5481 }
5482 _RootZoneSpecification[dart.implements] = () => [ZoneSpecification];
5483 class _RootZone extends _Zone {
5484 _RootZone() {
5485 super._Zone();
5486 }
5487 get [_run]() {
5488 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRun));
5489 }
5490 get [_runUnary]() {
5491 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRunUnary));
5492 }
5493 get [_runBinary]() {
5494 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRunBinary));
5495 }
5496 get [_registerCallback]() {
5497 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRegisterCallback));
5498 }
5499 get [_registerUnaryCallback]() {
5500 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRegisterUnaryCallback ));
5501 }
5502 get [_registerBinaryCallback]() {
5503 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootRegisterBinaryCallbac k));
5504 }
5505 get [_errorCallback]() {
5506 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootErrorCallback));
5507 }
5508 get [_scheduleMicrotask]() {
5509 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootScheduleMicrotask));
5510 }
5511 get [_createTimer]() {
5512 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootCreateTimer));
5513 }
5514 get [_createPeriodicTimer]() {
5515 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootCreatePeriodicTimer)) ;
5516 }
5517 get [_print]() {
5518 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootPrint));
5519 }
5520 get [_fork]() {
5521 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootFork));
5522 }
5523 get [_handleUncaughtError]() {
5524 return dart.const(new _ZoneFunction(_ROOT_ZONE, _rootHandleUncaughtError)) ;
5525 }
5526 get parent() {
5527 return null;
5528 }
5529 get [_map]() {
5530 return _RootZone._rootMap;
5531 }
5532 get [_delegate]() {
5533 if (_RootZone._rootDelegate != null) return _RootZone._rootDelegate;
5534 return _RootZone._rootDelegate = new _ZoneDelegate(this);
5535 }
5536 get errorZone() {
5537 return this;
5538 }
5539 runGuarded(f) {
5540 try {
5541 if (core.identical(_ROOT_ZONE, Zone._current)) {
5542 return f();
5543 }
5544 return _rootRun(null, null, this, f);
5545 } catch (e) {
5546 let s = dart.stackTrace(e);
5547 return this.handleUncaughtError(e, s);
5548 }
5549
5550 }
5551 runUnaryGuarded(f, arg) {
5552 try {
5553 if (core.identical(_ROOT_ZONE, Zone._current)) {
5554 return dart.dcall(f, arg);
5555 }
5556 return _rootRunUnary(null, null, this, f, arg);
5557 } catch (e) {
5558 let s = dart.stackTrace(e);
5559 return this.handleUncaughtError(e, s);
5560 }
5561
5562 }
5563 runBinaryGuarded(f, arg1, arg2) {
5564 try {
5565 if (core.identical(_ROOT_ZONE, Zone._current)) {
5566 return dart.dcall(f, arg1, arg2);
5567 }
5568 return _rootRunBinary(null, null, this, f, arg1, arg2);
5569 } catch (e) {
5570 let s = dart.stackTrace(e);
5571 return this.handleUncaughtError(e, s);
5572 }
5573
5574 }
5575 bindCallback(f, opts) {
5576 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5577 if (dart.notNull(runGuarded)) {
5578 return dart.fn(() => this.runGuarded(f));
5579 } else {
5580 return dart.fn(() => this.run(f));
5581 }
5582 }
5583 bindUnaryCallback(f, opts) {
5584 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5585 if (dart.notNull(runGuarded)) {
5586 return dart.fn(arg => this.runUnaryGuarded(f, arg));
5587 } else {
5588 return dart.fn(arg => this.runUnary(f, arg));
5589 }
5590 }
5591 bindBinaryCallback(f, opts) {
5592 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5593 if (dart.notNull(runGuarded)) {
5594 return dart.fn((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2));
5595 } else {
5596 return dart.fn((arg1, arg2) => this.runBinary(f, arg1, arg2));
5597 }
5598 }
5599 get(key) {
5600 return null;
5601 }
5602 handleUncaughtError(error, stackTrace) {
5603 return _rootHandleUncaughtError(null, null, this, error, stackTrace);
5604 }
5605 fork(opts) {
5606 let specification = opts && 'specification' in opts ? opts.specification : null;
5607 let zoneValues = opts && 'zoneValues' in opts ? opts.zoneValues : null;
5608 return _rootFork(null, null, this, specification, zoneValues);
5609 }
5610 run(f) {
5611 if (core.identical(Zone._current, _ROOT_ZONE)) return f();
5612 return _rootRun(null, null, this, f);
5613 }
5614 runUnary(f, arg) {
5615 if (core.identical(Zone._current, _ROOT_ZONE)) return dart.dcall(f, arg);
5616 return _rootRunUnary(null, null, this, f, arg);
5617 }
5618 runBinary(f, arg1, arg2) {
5619 if (core.identical(Zone._current, _ROOT_ZONE)) return dart.dcall(f, arg1, arg2);
5620 return _rootRunBinary(null, null, this, f, arg1, arg2);
5621 }
5622 registerCallback(f) {
5623 return f;
5624 }
5625 registerUnaryCallback(f) {
5626 return f;
5627 }
5628 registerBinaryCallback(f) {
5629 return f;
5630 }
5631 errorCallback(error, stackTrace) {
5632 return null;
5633 }
5634 scheduleMicrotask(f) {
5635 _rootScheduleMicrotask(null, null, this, f);
5636 }
5637 createTimer(duration, f) {
5638 return Timer._createTimer(duration, f);
5639 }
5640 createPeriodicTimer(duration, f) {
5641 return Timer._createPeriodicTimer(duration, f);
5642 }
5643 print(line) {
5644 _internal.printToConsole(line);
5645 }
5646 }
5647 dart.setSignature(_RootZone, {
5648 constructors: () => ({_RootZone: [_RootZone, []]}),
5649 methods: () => ({
5650 runGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [])]],
5651 runUnaryGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dyn amic]), dart.dynamic]],
5652 runBinaryGuarded: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dy namic, dart.dynamic]), dart.dynamic, dart.dynamic]],
5653 bindCallback: [ZoneCallback, [dart.functionType(dart.dynamic, [])], {runGu arded: core.bool}],
5654 bindUnaryCallback: [ZoneUnaryCallback, [dart.functionType(dart.dynamic, [d art.dynamic])], {runGuarded: core.bool}],
5655 bindBinaryCallback: [ZoneBinaryCallback, [dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic])], {runGuarded: core.bool}],
5656 get: [dart.dynamic, [core.Object]],
5657 handleUncaughtError: [dart.dynamic, [dart.dynamic, core.StackTrace]],
5658 fork: [Zone, [], {specification: ZoneSpecification, zoneValues: core.Map}] ,
5659 run: [dart.dynamic, [dart.functionType(dart.dynamic, [])]],
5660 runUnary: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dynamic]), dart.dynamic]],
5661 runBinary: [dart.dynamic, [dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic]), dart.dynamic, dart.dynamic]],
5662 registerCallback: [ZoneCallback, [dart.functionType(dart.dynamic, [])]],
5663 registerUnaryCallback: [ZoneUnaryCallback, [dart.functionType(dart.dynamic , [dart.dynamic])]],
5664 registerBinaryCallback: [ZoneBinaryCallback, [dart.functionType(dart.dynam ic, [dart.dynamic, dart.dynamic])]],
5665 errorCallback: [AsyncError, [core.Object, core.StackTrace]],
5666 scheduleMicrotask: [dart.void, [dart.functionType(dart.void, [])]],
5667 createTimer: [Timer, [core.Duration, dart.functionType(dart.void, [])]],
5668 createPeriodicTimer: [Timer, [core.Duration, dart.functionType(dart.void, [Timer])]],
5669 print: [dart.void, [core.String]]
5670 })
5671 });
5672 _RootZone._rootDelegate = null;
5673 dart.defineLazyProperties(_RootZone, {
5674 get _rootMap() {
5675 return collection.HashMap.new();
5676 },
5677 set _rootMap(_) {}
5678 });
5679 const _ROOT_ZONE = dart.const(new _RootZone());
5680 function runZoned(body, opts) {
5681 let zoneValues = opts && 'zoneValues' in opts ? opts.zoneValues : null;
5682 let zoneSpecification = opts && 'zoneSpecification' in opts ? opts.zoneSpeci fication : null;
5683 let onError = opts && 'onError' in opts ? opts.onError : null;
5684 let errorHandler = null;
5685 if (onError != null) {
5686 errorHandler = dart.fn((self, parent, zone, error, stackTrace) => {
5687 try {
5688 if (dart.is(onError, ZoneBinaryCallback)) {
5689 return self.parent.runBinary(onError, error, stackTrace);
5690 }
5691 return self.parent.runUnary(dart.as(onError, dart.functionType(dart.dy namic, [dart.dynamic])), error);
5692 } catch (e) {
5693 let s = dart.stackTrace(e);
5694 if (core.identical(e, error)) {
5695 return parent.handleUncaughtError(zone, error, stackTrace);
5696 } else {
5697 return parent.handleUncaughtError(zone, e, s);
5698 }
5699 }
5700
5701 }, dart.dynamic, [Zone, ZoneDelegate, Zone, dart.dynamic, core.StackTrace] );
5702 }
5703 if (zoneSpecification == null) {
5704 zoneSpecification = ZoneSpecification.new({handleUncaughtError: errorHandl er});
5705 } else if (errorHandler != null) {
5706 zoneSpecification = ZoneSpecification.from(zoneSpecification, {handleUncau ghtError: errorHandler});
5707 }
5708 let zone = Zone.current.fork({specification: zoneSpecification, zoneValues: zoneValues});
5709 if (onError != null) {
5710 return zone.runGuarded(body);
5711 } else {
5712 return zone.run(body);
5713 }
5714 }
5715 dart.fn(runZoned, dart.dynamic, [dart.functionType(dart.dynamic, [])], {zoneVa lues: core.Map, zoneSpecification: ZoneSpecification, onError: core.Function});
5716 dart.copyProperties(exports, {
5717 get _hasDocument() {
5718 return typeof document == 'object';
5719 }
5720 });
5721 // Exports:
5722 exports.AsyncError = AsyncError;
5723 exports.Stream$ = Stream$;
5724 exports.Stream = Stream;
5725 exports.DeferredLibrary = DeferredLibrary;
5726 exports.DeferredLoadException = DeferredLoadException;
5727 exports.Future$ = Future$;
5728 exports.Future = Future;
5729 exports.TimeoutException = TimeoutException;
5730 exports.Completer$ = Completer$;
5731 exports.Completer = Completer;
5732 exports.scheduleMicrotask = scheduleMicrotask;
5733 exports.StreamSubscription$ = StreamSubscription$;
5734 exports.StreamSubscription = StreamSubscription;
5735 exports.EventSink$ = EventSink$;
5736 exports.EventSink = EventSink;
5737 exports.StreamView$ = StreamView$;
5738 exports.StreamView = StreamView;
5739 exports.StreamConsumer$ = StreamConsumer$;
5740 exports.StreamConsumer = StreamConsumer;
5741 exports.StreamSink$ = StreamSink$;
5742 exports.StreamSink = StreamSink;
5743 exports.StreamTransformer$ = StreamTransformer$;
5744 exports.StreamTransformer = StreamTransformer;
5745 exports.StreamIterator$ = StreamIterator$;
5746 exports.StreamIterator = StreamIterator;
5747 exports.StreamController$ = StreamController$;
5748 exports.StreamController = StreamController;
5749 exports.Timer = Timer;
5750 exports.ZoneCallback = ZoneCallback;
5751 exports.ZoneUnaryCallback = ZoneUnaryCallback;
5752 exports.ZoneBinaryCallback = ZoneBinaryCallback;
5753 exports.HandleUncaughtErrorHandler = HandleUncaughtErrorHandler;
5754 exports.RunHandler = RunHandler;
5755 exports.RunUnaryHandler = RunUnaryHandler;
5756 exports.RunBinaryHandler = RunBinaryHandler;
5757 exports.RegisterCallbackHandler = RegisterCallbackHandler;
5758 exports.RegisterUnaryCallbackHandler = RegisterUnaryCallbackHandler;
5759 exports.RegisterBinaryCallbackHandler = RegisterBinaryCallbackHandler;
5760 exports.ErrorCallbackHandler = ErrorCallbackHandler;
5761 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5762 exports.CreateTimerHandler = CreateTimerHandler;
5763 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5764 exports.PrintHandler = PrintHandler;
5765 exports.ForkHandler = ForkHandler;
5766 exports.ZoneSpecification = ZoneSpecification;
5767 exports.ZoneDelegate = ZoneDelegate;
5768 exports.Zone = Zone;
5769 exports.runZoned = runZoned;
5770 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/_runtime.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698