@swirly/parser-rxjs 0.18.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/bundle.js +2842 -0
- package/package.json +9 -9
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.js +0 -1777
- package/dist/cjs/index.js.map +0 -1
package/dist/cjs/index.js
DELETED
|
@@ -1,1777 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
/******************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise */
|
|
20
|
-
|
|
21
|
-
var extendStatics = function(d, b) {
|
|
22
|
-
extendStatics = Object.setPrototypeOf ||
|
|
23
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
24
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
25
|
-
return extendStatics(d, b);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function __extends(d, b) {
|
|
29
|
-
if (typeof b !== "function" && b !== null)
|
|
30
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function __values(o) {
|
|
37
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
38
|
-
if (m) return m.call(o);
|
|
39
|
-
if (o && typeof o.length === "number") return {
|
|
40
|
-
next: function () {
|
|
41
|
-
if (o && i >= o.length) o = void 0;
|
|
42
|
-
return { value: o && o[i++], done: !o };
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function __read(o, n) {
|
|
49
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
-
if (!m) return o;
|
|
51
|
-
var i = m.call(o), r, ar = [], e;
|
|
52
|
-
try {
|
|
53
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
-
}
|
|
55
|
-
catch (error) { e = { error: error }; }
|
|
56
|
-
finally {
|
|
57
|
-
try {
|
|
58
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e) throw e.error; }
|
|
61
|
-
}
|
|
62
|
-
return ar;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function __spreadArray(to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function isFunction(value) {
|
|
76
|
-
return typeof value === 'function';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function createErrorClass(createImpl) {
|
|
80
|
-
var _super = function (instance) {
|
|
81
|
-
Error.call(instance);
|
|
82
|
-
instance.stack = new Error().stack;
|
|
83
|
-
};
|
|
84
|
-
var ctorFunc = createImpl(_super);
|
|
85
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
86
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
87
|
-
return ctorFunc;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
91
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
92
|
-
_super(this);
|
|
93
|
-
this.message = errors
|
|
94
|
-
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
95
|
-
: '';
|
|
96
|
-
this.name = 'UnsubscriptionError';
|
|
97
|
-
this.errors = errors;
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
function arrRemove(arr, item) {
|
|
102
|
-
if (arr) {
|
|
103
|
-
var index = arr.indexOf(item);
|
|
104
|
-
0 <= index && arr.splice(index, 1);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var Subscription = (function () {
|
|
109
|
-
function Subscription(initialTeardown) {
|
|
110
|
-
this.initialTeardown = initialTeardown;
|
|
111
|
-
this.closed = false;
|
|
112
|
-
this._parentage = null;
|
|
113
|
-
this._finalizers = null;
|
|
114
|
-
}
|
|
115
|
-
Subscription.prototype.unsubscribe = function () {
|
|
116
|
-
var e_1, _a, e_2, _b;
|
|
117
|
-
var errors;
|
|
118
|
-
if (!this.closed) {
|
|
119
|
-
this.closed = true;
|
|
120
|
-
var _parentage = this._parentage;
|
|
121
|
-
if (_parentage) {
|
|
122
|
-
this._parentage = null;
|
|
123
|
-
if (Array.isArray(_parentage)) {
|
|
124
|
-
try {
|
|
125
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
126
|
-
var parent_1 = _parentage_1_1.value;
|
|
127
|
-
parent_1.remove(this);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
131
|
-
finally {
|
|
132
|
-
try {
|
|
133
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
134
|
-
}
|
|
135
|
-
finally { if (e_1) throw e_1.error; }
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
_parentage.remove(this);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
var initialFinalizer = this.initialTeardown;
|
|
143
|
-
if (isFunction(initialFinalizer)) {
|
|
144
|
-
try {
|
|
145
|
-
initialFinalizer();
|
|
146
|
-
}
|
|
147
|
-
catch (e) {
|
|
148
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
var _finalizers = this._finalizers;
|
|
152
|
-
if (_finalizers) {
|
|
153
|
-
this._finalizers = null;
|
|
154
|
-
try {
|
|
155
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
156
|
-
var finalizer = _finalizers_1_1.value;
|
|
157
|
-
try {
|
|
158
|
-
execFinalizer(finalizer);
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
162
|
-
if (err instanceof UnsubscriptionError) {
|
|
163
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
errors.push(err);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
172
|
-
finally {
|
|
173
|
-
try {
|
|
174
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
175
|
-
}
|
|
176
|
-
finally { if (e_2) throw e_2.error; }
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (errors) {
|
|
180
|
-
throw new UnsubscriptionError(errors);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
Subscription.prototype.add = function (teardown) {
|
|
185
|
-
var _a;
|
|
186
|
-
if (teardown && teardown !== this) {
|
|
187
|
-
if (this.closed) {
|
|
188
|
-
execFinalizer(teardown);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
if (teardown instanceof Subscription) {
|
|
192
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
teardown._addParent(this);
|
|
196
|
-
}
|
|
197
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
202
|
-
var _parentage = this._parentage;
|
|
203
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
204
|
-
};
|
|
205
|
-
Subscription.prototype._addParent = function (parent) {
|
|
206
|
-
var _parentage = this._parentage;
|
|
207
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
208
|
-
};
|
|
209
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
210
|
-
var _parentage = this._parentage;
|
|
211
|
-
if (_parentage === parent) {
|
|
212
|
-
this._parentage = null;
|
|
213
|
-
}
|
|
214
|
-
else if (Array.isArray(_parentage)) {
|
|
215
|
-
arrRemove(_parentage, parent);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
Subscription.prototype.remove = function (teardown) {
|
|
219
|
-
var _finalizers = this._finalizers;
|
|
220
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
221
|
-
if (teardown instanceof Subscription) {
|
|
222
|
-
teardown._removeParent(this);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
Subscription.EMPTY = (function () {
|
|
226
|
-
var empty = new Subscription();
|
|
227
|
-
empty.closed = true;
|
|
228
|
-
return empty;
|
|
229
|
-
})();
|
|
230
|
-
return Subscription;
|
|
231
|
-
}());
|
|
232
|
-
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
233
|
-
function isSubscription(value) {
|
|
234
|
-
return (value instanceof Subscription ||
|
|
235
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
236
|
-
}
|
|
237
|
-
function execFinalizer(finalizer) {
|
|
238
|
-
if (isFunction(finalizer)) {
|
|
239
|
-
finalizer();
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
finalizer.unsubscribe();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
var config = {
|
|
247
|
-
onUnhandledError: null,
|
|
248
|
-
onStoppedNotification: null,
|
|
249
|
-
Promise: undefined,
|
|
250
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
251
|
-
useDeprecatedNextContext: false,
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
var timeoutProvider = {
|
|
255
|
-
setTimeout: function (handler, timeout) {
|
|
256
|
-
var args = [];
|
|
257
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
258
|
-
args[_i - 2] = arguments[_i];
|
|
259
|
-
}
|
|
260
|
-
var delegate = timeoutProvider.delegate;
|
|
261
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
262
|
-
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
263
|
-
}
|
|
264
|
-
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
265
|
-
},
|
|
266
|
-
clearTimeout: function (handle) {
|
|
267
|
-
var delegate = timeoutProvider.delegate;
|
|
268
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
269
|
-
},
|
|
270
|
-
delegate: undefined,
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
function reportUnhandledError(err) {
|
|
274
|
-
timeoutProvider.setTimeout(function () {
|
|
275
|
-
{
|
|
276
|
-
throw err;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function noop() { }
|
|
282
|
-
|
|
283
|
-
var COMPLETE_NOTIFICATION = (function () { return createNotification('C', undefined, undefined); })();
|
|
284
|
-
function errorNotification(error) {
|
|
285
|
-
return createNotification('E', undefined, error);
|
|
286
|
-
}
|
|
287
|
-
function nextNotification(value) {
|
|
288
|
-
return createNotification('N', value, undefined);
|
|
289
|
-
}
|
|
290
|
-
function createNotification(kind, value, error) {
|
|
291
|
-
return {
|
|
292
|
-
kind: kind,
|
|
293
|
-
value: value,
|
|
294
|
-
error: error,
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
var context = null;
|
|
299
|
-
function errorContext(cb) {
|
|
300
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
301
|
-
var isRoot = !context;
|
|
302
|
-
if (isRoot) {
|
|
303
|
-
context = { errorThrown: false, error: null };
|
|
304
|
-
}
|
|
305
|
-
cb();
|
|
306
|
-
if (isRoot) {
|
|
307
|
-
var _a = context, errorThrown = _a.errorThrown, error = _a.error;
|
|
308
|
-
context = null;
|
|
309
|
-
if (errorThrown) {
|
|
310
|
-
throw error;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
cb();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
var Subscriber = (function (_super) {
|
|
320
|
-
__extends(Subscriber, _super);
|
|
321
|
-
function Subscriber(destination) {
|
|
322
|
-
var _this = _super.call(this) || this;
|
|
323
|
-
_this.isStopped = false;
|
|
324
|
-
if (destination) {
|
|
325
|
-
_this.destination = destination;
|
|
326
|
-
if (isSubscription(destination)) {
|
|
327
|
-
destination.add(_this);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
_this.destination = EMPTY_OBSERVER;
|
|
332
|
-
}
|
|
333
|
-
return _this;
|
|
334
|
-
}
|
|
335
|
-
Subscriber.create = function (next, error, complete) {
|
|
336
|
-
return new SafeSubscriber(next, error, complete);
|
|
337
|
-
};
|
|
338
|
-
Subscriber.prototype.next = function (value) {
|
|
339
|
-
if (this.isStopped) ;
|
|
340
|
-
else {
|
|
341
|
-
this._next(value);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
Subscriber.prototype.error = function (err) {
|
|
345
|
-
if (this.isStopped) ;
|
|
346
|
-
else {
|
|
347
|
-
this.isStopped = true;
|
|
348
|
-
this._error(err);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
Subscriber.prototype.complete = function () {
|
|
352
|
-
if (this.isStopped) ;
|
|
353
|
-
else {
|
|
354
|
-
this.isStopped = true;
|
|
355
|
-
this._complete();
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
359
|
-
if (!this.closed) {
|
|
360
|
-
this.isStopped = true;
|
|
361
|
-
_super.prototype.unsubscribe.call(this);
|
|
362
|
-
this.destination = null;
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
Subscriber.prototype._next = function (value) {
|
|
366
|
-
this.destination.next(value);
|
|
367
|
-
};
|
|
368
|
-
Subscriber.prototype._error = function (err) {
|
|
369
|
-
try {
|
|
370
|
-
this.destination.error(err);
|
|
371
|
-
}
|
|
372
|
-
finally {
|
|
373
|
-
this.unsubscribe();
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
Subscriber.prototype._complete = function () {
|
|
377
|
-
try {
|
|
378
|
-
this.destination.complete();
|
|
379
|
-
}
|
|
380
|
-
finally {
|
|
381
|
-
this.unsubscribe();
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
return Subscriber;
|
|
385
|
-
}(Subscription));
|
|
386
|
-
var _bind = Function.prototype.bind;
|
|
387
|
-
function bind(fn, thisArg) {
|
|
388
|
-
return _bind.call(fn, thisArg);
|
|
389
|
-
}
|
|
390
|
-
var ConsumerObserver = (function () {
|
|
391
|
-
function ConsumerObserver(partialObserver) {
|
|
392
|
-
this.partialObserver = partialObserver;
|
|
393
|
-
}
|
|
394
|
-
ConsumerObserver.prototype.next = function (value) {
|
|
395
|
-
var partialObserver = this.partialObserver;
|
|
396
|
-
if (partialObserver.next) {
|
|
397
|
-
try {
|
|
398
|
-
partialObserver.next(value);
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
handleUnhandledError(error);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
406
|
-
var partialObserver = this.partialObserver;
|
|
407
|
-
if (partialObserver.error) {
|
|
408
|
-
try {
|
|
409
|
-
partialObserver.error(err);
|
|
410
|
-
}
|
|
411
|
-
catch (error) {
|
|
412
|
-
handleUnhandledError(error);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
handleUnhandledError(err);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
ConsumerObserver.prototype.complete = function () {
|
|
420
|
-
var partialObserver = this.partialObserver;
|
|
421
|
-
if (partialObserver.complete) {
|
|
422
|
-
try {
|
|
423
|
-
partialObserver.complete();
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
handleUnhandledError(error);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
return ConsumerObserver;
|
|
431
|
-
}());
|
|
432
|
-
var SafeSubscriber = (function (_super) {
|
|
433
|
-
__extends(SafeSubscriber, _super);
|
|
434
|
-
function SafeSubscriber(observerOrNext, error, complete) {
|
|
435
|
-
var _this = _super.call(this) || this;
|
|
436
|
-
var partialObserver;
|
|
437
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
438
|
-
partialObserver = {
|
|
439
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
|
|
440
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
441
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
var context_1;
|
|
446
|
-
if (_this && config.useDeprecatedNextContext) {
|
|
447
|
-
context_1 = Object.create(observerOrNext);
|
|
448
|
-
context_1.unsubscribe = function () { return _this.unsubscribe(); };
|
|
449
|
-
partialObserver = {
|
|
450
|
-
next: observerOrNext.next && bind(observerOrNext.next, context_1),
|
|
451
|
-
error: observerOrNext.error && bind(observerOrNext.error, context_1),
|
|
452
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
partialObserver = observerOrNext;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
460
|
-
return _this;
|
|
461
|
-
}
|
|
462
|
-
return SafeSubscriber;
|
|
463
|
-
}(Subscriber));
|
|
464
|
-
function handleUnhandledError(error) {
|
|
465
|
-
{
|
|
466
|
-
reportUnhandledError(error);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
function defaultErrorHandler(err) {
|
|
470
|
-
throw err;
|
|
471
|
-
}
|
|
472
|
-
var EMPTY_OBSERVER = {
|
|
473
|
-
closed: true,
|
|
474
|
-
next: noop,
|
|
475
|
-
error: defaultErrorHandler,
|
|
476
|
-
complete: noop,
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
480
|
-
|
|
481
|
-
function identity(x) {
|
|
482
|
-
return x;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
function pipeFromArray(fns) {
|
|
486
|
-
if (fns.length === 0) {
|
|
487
|
-
return identity;
|
|
488
|
-
}
|
|
489
|
-
if (fns.length === 1) {
|
|
490
|
-
return fns[0];
|
|
491
|
-
}
|
|
492
|
-
return function piped(input) {
|
|
493
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
var Observable = (function () {
|
|
498
|
-
function Observable(subscribe) {
|
|
499
|
-
if (subscribe) {
|
|
500
|
-
this._subscribe = subscribe;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
Observable.prototype.lift = function (operator) {
|
|
504
|
-
var observable = new Observable();
|
|
505
|
-
observable.source = this;
|
|
506
|
-
observable.operator = operator;
|
|
507
|
-
return observable;
|
|
508
|
-
};
|
|
509
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
510
|
-
var _this = this;
|
|
511
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
512
|
-
errorContext(function () {
|
|
513
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
514
|
-
subscriber.add(operator
|
|
515
|
-
?
|
|
516
|
-
operator.call(subscriber, source)
|
|
517
|
-
: source
|
|
518
|
-
?
|
|
519
|
-
_this._subscribe(subscriber)
|
|
520
|
-
:
|
|
521
|
-
_this._trySubscribe(subscriber));
|
|
522
|
-
});
|
|
523
|
-
return subscriber;
|
|
524
|
-
};
|
|
525
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
526
|
-
try {
|
|
527
|
-
return this._subscribe(sink);
|
|
528
|
-
}
|
|
529
|
-
catch (err) {
|
|
530
|
-
sink.error(err);
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
534
|
-
var _this = this;
|
|
535
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
536
|
-
return new promiseCtor(function (resolve, reject) {
|
|
537
|
-
var subscriber = new SafeSubscriber({
|
|
538
|
-
next: function (value) {
|
|
539
|
-
try {
|
|
540
|
-
next(value);
|
|
541
|
-
}
|
|
542
|
-
catch (err) {
|
|
543
|
-
reject(err);
|
|
544
|
-
subscriber.unsubscribe();
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
error: reject,
|
|
548
|
-
complete: resolve,
|
|
549
|
-
});
|
|
550
|
-
_this.subscribe(subscriber);
|
|
551
|
-
});
|
|
552
|
-
};
|
|
553
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
554
|
-
var _a;
|
|
555
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
556
|
-
};
|
|
557
|
-
Observable.prototype[observable] = function () {
|
|
558
|
-
return this;
|
|
559
|
-
};
|
|
560
|
-
Observable.prototype.pipe = function () {
|
|
561
|
-
var operations = [];
|
|
562
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
563
|
-
operations[_i] = arguments[_i];
|
|
564
|
-
}
|
|
565
|
-
return pipeFromArray(operations)(this);
|
|
566
|
-
};
|
|
567
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
568
|
-
var _this = this;
|
|
569
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
570
|
-
return new promiseCtor(function (resolve, reject) {
|
|
571
|
-
var value;
|
|
572
|
-
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
573
|
-
});
|
|
574
|
-
};
|
|
575
|
-
Observable.create = function (subscribe) {
|
|
576
|
-
return new Observable(subscribe);
|
|
577
|
-
};
|
|
578
|
-
return Observable;
|
|
579
|
-
}());
|
|
580
|
-
function getPromiseCtor(promiseCtor) {
|
|
581
|
-
var _a;
|
|
582
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
583
|
-
}
|
|
584
|
-
function isObserver(value) {
|
|
585
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
586
|
-
}
|
|
587
|
-
function isSubscriber(value) {
|
|
588
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
var SubscriptionLog = (function () {
|
|
592
|
-
function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
|
|
593
|
-
if (unsubscribedFrame === void 0) { unsubscribedFrame = Infinity; }
|
|
594
|
-
this.subscribedFrame = subscribedFrame;
|
|
595
|
-
this.unsubscribedFrame = unsubscribedFrame;
|
|
596
|
-
}
|
|
597
|
-
return SubscriptionLog;
|
|
598
|
-
}());
|
|
599
|
-
|
|
600
|
-
var SubscriptionLoggable = (function () {
|
|
601
|
-
function SubscriptionLoggable() {
|
|
602
|
-
this.subscriptions = [];
|
|
603
|
-
}
|
|
604
|
-
SubscriptionLoggable.prototype.logSubscribedFrame = function () {
|
|
605
|
-
this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
|
|
606
|
-
return this.subscriptions.length - 1;
|
|
607
|
-
};
|
|
608
|
-
SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
|
|
609
|
-
var subscriptionLogs = this.subscriptions;
|
|
610
|
-
var oldSubscriptionLog = subscriptionLogs[index];
|
|
611
|
-
subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
|
|
612
|
-
};
|
|
613
|
-
return SubscriptionLoggable;
|
|
614
|
-
}());
|
|
615
|
-
|
|
616
|
-
function applyMixins(derivedCtor, baseCtors) {
|
|
617
|
-
for (var i = 0, len = baseCtors.length; i < len; i++) {
|
|
618
|
-
var baseCtor = baseCtors[i];
|
|
619
|
-
var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
|
|
620
|
-
for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
|
|
621
|
-
var name_1 = propertyKeys[j];
|
|
622
|
-
derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
var NotificationKind;
|
|
628
|
-
(function (NotificationKind) {
|
|
629
|
-
NotificationKind["NEXT"] = "N";
|
|
630
|
-
NotificationKind["ERROR"] = "E";
|
|
631
|
-
NotificationKind["COMPLETE"] = "C";
|
|
632
|
-
})(NotificationKind || (NotificationKind = {}));
|
|
633
|
-
function observeNotification(notification, observer) {
|
|
634
|
-
var _a, _b, _c;
|
|
635
|
-
var _d = notification, kind = _d.kind, value = _d.value, error = _d.error;
|
|
636
|
-
if (typeof kind !== 'string') {
|
|
637
|
-
throw new TypeError('Invalid notification, missing "kind"');
|
|
638
|
-
}
|
|
639
|
-
kind === 'N' ? (_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, value) : kind === 'E' ? (_b = observer.error) === null || _b === void 0 ? void 0 : _b.call(observer, error) : (_c = observer.complete) === null || _c === void 0 ? void 0 : _c.call(observer);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
var ColdObservable = (function (_super) {
|
|
643
|
-
__extends(ColdObservable, _super);
|
|
644
|
-
function ColdObservable(messages, scheduler) {
|
|
645
|
-
var _this = _super.call(this, function (subscriber) {
|
|
646
|
-
var observable = this;
|
|
647
|
-
var index = observable.logSubscribedFrame();
|
|
648
|
-
var subscription = new Subscription();
|
|
649
|
-
subscription.add(new Subscription(function () {
|
|
650
|
-
observable.logUnsubscribedFrame(index);
|
|
651
|
-
}));
|
|
652
|
-
observable.scheduleMessages(subscriber);
|
|
653
|
-
return subscription;
|
|
654
|
-
}) || this;
|
|
655
|
-
_this.messages = messages;
|
|
656
|
-
_this.subscriptions = [];
|
|
657
|
-
_this.scheduler = scheduler;
|
|
658
|
-
return _this;
|
|
659
|
-
}
|
|
660
|
-
ColdObservable.prototype.scheduleMessages = function (subscriber) {
|
|
661
|
-
var messagesLength = this.messages.length;
|
|
662
|
-
for (var i = 0; i < messagesLength; i++) {
|
|
663
|
-
var message = this.messages[i];
|
|
664
|
-
subscriber.add(this.scheduler.schedule(function (state) {
|
|
665
|
-
var _a = state, notification = _a.message.notification, destination = _a.subscriber;
|
|
666
|
-
observeNotification(notification, destination);
|
|
667
|
-
}, message.frame, { message: message, subscriber: subscriber }));
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
return ColdObservable;
|
|
671
|
-
}(Observable));
|
|
672
|
-
applyMixins(ColdObservable, [SubscriptionLoggable]);
|
|
673
|
-
|
|
674
|
-
var ObjectUnsubscribedError = createErrorClass(function (_super) {
|
|
675
|
-
return function ObjectUnsubscribedErrorImpl() {
|
|
676
|
-
_super(this);
|
|
677
|
-
this.name = 'ObjectUnsubscribedError';
|
|
678
|
-
this.message = 'object unsubscribed';
|
|
679
|
-
};
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
var Subject = (function (_super) {
|
|
683
|
-
__extends(Subject, _super);
|
|
684
|
-
function Subject() {
|
|
685
|
-
var _this = _super.call(this) || this;
|
|
686
|
-
_this.closed = false;
|
|
687
|
-
_this.currentObservers = null;
|
|
688
|
-
_this.observers = [];
|
|
689
|
-
_this.isStopped = false;
|
|
690
|
-
_this.hasError = false;
|
|
691
|
-
_this.thrownError = null;
|
|
692
|
-
return _this;
|
|
693
|
-
}
|
|
694
|
-
Subject.prototype.lift = function (operator) {
|
|
695
|
-
var subject = new AnonymousSubject(this, this);
|
|
696
|
-
subject.operator = operator;
|
|
697
|
-
return subject;
|
|
698
|
-
};
|
|
699
|
-
Subject.prototype._throwIfClosed = function () {
|
|
700
|
-
if (this.closed) {
|
|
701
|
-
throw new ObjectUnsubscribedError();
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
Subject.prototype.next = function (value) {
|
|
705
|
-
var _this = this;
|
|
706
|
-
errorContext(function () {
|
|
707
|
-
var e_1, _a;
|
|
708
|
-
_this._throwIfClosed();
|
|
709
|
-
if (!_this.isStopped) {
|
|
710
|
-
if (!_this.currentObservers) {
|
|
711
|
-
_this.currentObservers = Array.from(_this.observers);
|
|
712
|
-
}
|
|
713
|
-
try {
|
|
714
|
-
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
715
|
-
var observer = _c.value;
|
|
716
|
-
observer.next(value);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
720
|
-
finally {
|
|
721
|
-
try {
|
|
722
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
723
|
-
}
|
|
724
|
-
finally { if (e_1) throw e_1.error; }
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
};
|
|
729
|
-
Subject.prototype.error = function (err) {
|
|
730
|
-
var _this = this;
|
|
731
|
-
errorContext(function () {
|
|
732
|
-
_this._throwIfClosed();
|
|
733
|
-
if (!_this.isStopped) {
|
|
734
|
-
_this.hasError = _this.isStopped = true;
|
|
735
|
-
_this.thrownError = err;
|
|
736
|
-
var observers = _this.observers;
|
|
737
|
-
while (observers.length) {
|
|
738
|
-
observers.shift().error(err);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
};
|
|
743
|
-
Subject.prototype.complete = function () {
|
|
744
|
-
var _this = this;
|
|
745
|
-
errorContext(function () {
|
|
746
|
-
_this._throwIfClosed();
|
|
747
|
-
if (!_this.isStopped) {
|
|
748
|
-
_this.isStopped = true;
|
|
749
|
-
var observers = _this.observers;
|
|
750
|
-
while (observers.length) {
|
|
751
|
-
observers.shift().complete();
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
};
|
|
756
|
-
Subject.prototype.unsubscribe = function () {
|
|
757
|
-
this.isStopped = this.closed = true;
|
|
758
|
-
this.observers = this.currentObservers = null;
|
|
759
|
-
};
|
|
760
|
-
Object.defineProperty(Subject.prototype, "observed", {
|
|
761
|
-
get: function () {
|
|
762
|
-
var _a;
|
|
763
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
764
|
-
},
|
|
765
|
-
enumerable: false,
|
|
766
|
-
configurable: true
|
|
767
|
-
});
|
|
768
|
-
Subject.prototype._trySubscribe = function (subscriber) {
|
|
769
|
-
this._throwIfClosed();
|
|
770
|
-
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
771
|
-
};
|
|
772
|
-
Subject.prototype._subscribe = function (subscriber) {
|
|
773
|
-
this._throwIfClosed();
|
|
774
|
-
this._checkFinalizedStatuses(subscriber);
|
|
775
|
-
return this._innerSubscribe(subscriber);
|
|
776
|
-
};
|
|
777
|
-
Subject.prototype._innerSubscribe = function (subscriber) {
|
|
778
|
-
var _this = this;
|
|
779
|
-
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
780
|
-
if (hasError || isStopped) {
|
|
781
|
-
return EMPTY_SUBSCRIPTION;
|
|
782
|
-
}
|
|
783
|
-
this.currentObservers = null;
|
|
784
|
-
observers.push(subscriber);
|
|
785
|
-
return new Subscription(function () {
|
|
786
|
-
_this.currentObservers = null;
|
|
787
|
-
arrRemove(observers, subscriber);
|
|
788
|
-
});
|
|
789
|
-
};
|
|
790
|
-
Subject.prototype._checkFinalizedStatuses = function (subscriber) {
|
|
791
|
-
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
792
|
-
if (hasError) {
|
|
793
|
-
subscriber.error(thrownError);
|
|
794
|
-
}
|
|
795
|
-
else if (isStopped) {
|
|
796
|
-
subscriber.complete();
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
Subject.prototype.asObservable = function () {
|
|
800
|
-
var observable = new Observable();
|
|
801
|
-
observable.source = this;
|
|
802
|
-
return observable;
|
|
803
|
-
};
|
|
804
|
-
Subject.create = function (destination, source) {
|
|
805
|
-
return new AnonymousSubject(destination, source);
|
|
806
|
-
};
|
|
807
|
-
return Subject;
|
|
808
|
-
}(Observable));
|
|
809
|
-
var AnonymousSubject = (function (_super) {
|
|
810
|
-
__extends(AnonymousSubject, _super);
|
|
811
|
-
function AnonymousSubject(destination, source) {
|
|
812
|
-
var _this = _super.call(this) || this;
|
|
813
|
-
_this.destination = destination;
|
|
814
|
-
_this.source = source;
|
|
815
|
-
return _this;
|
|
816
|
-
}
|
|
817
|
-
AnonymousSubject.prototype.next = function (value) {
|
|
818
|
-
var _a, _b;
|
|
819
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
820
|
-
};
|
|
821
|
-
AnonymousSubject.prototype.error = function (err) {
|
|
822
|
-
var _a, _b;
|
|
823
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
824
|
-
};
|
|
825
|
-
AnonymousSubject.prototype.complete = function () {
|
|
826
|
-
var _a, _b;
|
|
827
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
828
|
-
};
|
|
829
|
-
AnonymousSubject.prototype._subscribe = function (subscriber) {
|
|
830
|
-
var _a, _b;
|
|
831
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
832
|
-
};
|
|
833
|
-
return AnonymousSubject;
|
|
834
|
-
}(Subject));
|
|
835
|
-
|
|
836
|
-
var HotObservable = (function (_super) {
|
|
837
|
-
__extends(HotObservable, _super);
|
|
838
|
-
function HotObservable(messages, scheduler) {
|
|
839
|
-
var _this = _super.call(this) || this;
|
|
840
|
-
_this.messages = messages;
|
|
841
|
-
_this.subscriptions = [];
|
|
842
|
-
_this.scheduler = scheduler;
|
|
843
|
-
return _this;
|
|
844
|
-
}
|
|
845
|
-
HotObservable.prototype._subscribe = function (subscriber) {
|
|
846
|
-
var subject = this;
|
|
847
|
-
var index = subject.logSubscribedFrame();
|
|
848
|
-
var subscription = new Subscription();
|
|
849
|
-
subscription.add(new Subscription(function () {
|
|
850
|
-
subject.logUnsubscribedFrame(index);
|
|
851
|
-
}));
|
|
852
|
-
subscription.add(_super.prototype._subscribe.call(this, subscriber));
|
|
853
|
-
return subscription;
|
|
854
|
-
};
|
|
855
|
-
HotObservable.prototype.setup = function () {
|
|
856
|
-
var subject = this;
|
|
857
|
-
var messagesLength = subject.messages.length;
|
|
858
|
-
var _loop_1 = function (i) {
|
|
859
|
-
(function () {
|
|
860
|
-
var _a = subject.messages[i], notification = _a.notification, frame = _a.frame;
|
|
861
|
-
subject.scheduler.schedule(function () {
|
|
862
|
-
observeNotification(notification, subject);
|
|
863
|
-
}, frame);
|
|
864
|
-
})();
|
|
865
|
-
};
|
|
866
|
-
for (var i = 0; i < messagesLength; i++) {
|
|
867
|
-
_loop_1(i);
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
return HotObservable;
|
|
871
|
-
}(Subject));
|
|
872
|
-
applyMixins(HotObservable, [SubscriptionLoggable]);
|
|
873
|
-
|
|
874
|
-
var Action = (function (_super) {
|
|
875
|
-
__extends(Action, _super);
|
|
876
|
-
function Action(scheduler, work) {
|
|
877
|
-
return _super.call(this) || this;
|
|
878
|
-
}
|
|
879
|
-
Action.prototype.schedule = function (state, delay) {
|
|
880
|
-
if (delay === void 0) { delay = 0; }
|
|
881
|
-
return this;
|
|
882
|
-
};
|
|
883
|
-
return Action;
|
|
884
|
-
}(Subscription));
|
|
885
|
-
|
|
886
|
-
var intervalProvider = {
|
|
887
|
-
setInterval: function (handler, timeout) {
|
|
888
|
-
var args = [];
|
|
889
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
890
|
-
args[_i - 2] = arguments[_i];
|
|
891
|
-
}
|
|
892
|
-
var delegate = intervalProvider.delegate;
|
|
893
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
894
|
-
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
895
|
-
}
|
|
896
|
-
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
897
|
-
},
|
|
898
|
-
clearInterval: function (handle) {
|
|
899
|
-
var delegate = intervalProvider.delegate;
|
|
900
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle);
|
|
901
|
-
},
|
|
902
|
-
delegate: undefined,
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
var AsyncAction = (function (_super) {
|
|
906
|
-
__extends(AsyncAction, _super);
|
|
907
|
-
function AsyncAction(scheduler, work) {
|
|
908
|
-
var _this = _super.call(this, scheduler, work) || this;
|
|
909
|
-
_this.scheduler = scheduler;
|
|
910
|
-
_this.work = work;
|
|
911
|
-
_this.pending = false;
|
|
912
|
-
return _this;
|
|
913
|
-
}
|
|
914
|
-
AsyncAction.prototype.schedule = function (state, delay) {
|
|
915
|
-
if (delay === void 0) { delay = 0; }
|
|
916
|
-
if (this.closed) {
|
|
917
|
-
return this;
|
|
918
|
-
}
|
|
919
|
-
this.state = state;
|
|
920
|
-
var id = this.id;
|
|
921
|
-
var scheduler = this.scheduler;
|
|
922
|
-
if (id != null) {
|
|
923
|
-
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
924
|
-
}
|
|
925
|
-
this.pending = true;
|
|
926
|
-
this.delay = delay;
|
|
927
|
-
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
|
|
928
|
-
return this;
|
|
929
|
-
};
|
|
930
|
-
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
931
|
-
if (delay === void 0) { delay = 0; }
|
|
932
|
-
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
933
|
-
};
|
|
934
|
-
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
935
|
-
if (delay === void 0) { delay = 0; }
|
|
936
|
-
if (delay != null && this.delay === delay && this.pending === false) {
|
|
937
|
-
return id;
|
|
938
|
-
}
|
|
939
|
-
intervalProvider.clearInterval(id);
|
|
940
|
-
return undefined;
|
|
941
|
-
};
|
|
942
|
-
AsyncAction.prototype.execute = function (state, delay) {
|
|
943
|
-
if (this.closed) {
|
|
944
|
-
return new Error('executing a cancelled action');
|
|
945
|
-
}
|
|
946
|
-
this.pending = false;
|
|
947
|
-
var error = this._execute(state, delay);
|
|
948
|
-
if (error) {
|
|
949
|
-
return error;
|
|
950
|
-
}
|
|
951
|
-
else if (this.pending === false && this.id != null) {
|
|
952
|
-
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
AsyncAction.prototype._execute = function (state, _delay) {
|
|
956
|
-
var errored = false;
|
|
957
|
-
var errorValue;
|
|
958
|
-
try {
|
|
959
|
-
this.work(state);
|
|
960
|
-
}
|
|
961
|
-
catch (e) {
|
|
962
|
-
errored = true;
|
|
963
|
-
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
964
|
-
}
|
|
965
|
-
if (errored) {
|
|
966
|
-
this.unsubscribe();
|
|
967
|
-
return errorValue;
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
AsyncAction.prototype.unsubscribe = function () {
|
|
971
|
-
if (!this.closed) {
|
|
972
|
-
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
973
|
-
var actions = scheduler.actions;
|
|
974
|
-
this.work = this.state = this.scheduler = null;
|
|
975
|
-
this.pending = false;
|
|
976
|
-
arrRemove(actions, this);
|
|
977
|
-
if (id != null) {
|
|
978
|
-
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
979
|
-
}
|
|
980
|
-
this.delay = null;
|
|
981
|
-
_super.prototype.unsubscribe.call(this);
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
return AsyncAction;
|
|
985
|
-
}(Action));
|
|
986
|
-
|
|
987
|
-
var dateTimestampProvider = {
|
|
988
|
-
now: function () {
|
|
989
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
990
|
-
},
|
|
991
|
-
delegate: undefined,
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
var Scheduler = (function () {
|
|
995
|
-
function Scheduler(schedulerActionCtor, now) {
|
|
996
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
997
|
-
this.schedulerActionCtor = schedulerActionCtor;
|
|
998
|
-
this.now = now;
|
|
999
|
-
}
|
|
1000
|
-
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1001
|
-
if (delay === void 0) { delay = 0; }
|
|
1002
|
-
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1003
|
-
};
|
|
1004
|
-
Scheduler.now = dateTimestampProvider.now;
|
|
1005
|
-
return Scheduler;
|
|
1006
|
-
}());
|
|
1007
|
-
|
|
1008
|
-
var AsyncScheduler = (function (_super) {
|
|
1009
|
-
__extends(AsyncScheduler, _super);
|
|
1010
|
-
function AsyncScheduler(SchedulerAction, now) {
|
|
1011
|
-
if (now === void 0) { now = Scheduler.now; }
|
|
1012
|
-
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1013
|
-
_this.actions = [];
|
|
1014
|
-
_this._active = false;
|
|
1015
|
-
_this._scheduled = undefined;
|
|
1016
|
-
return _this;
|
|
1017
|
-
}
|
|
1018
|
-
AsyncScheduler.prototype.flush = function (action) {
|
|
1019
|
-
var actions = this.actions;
|
|
1020
|
-
if (this._active) {
|
|
1021
|
-
actions.push(action);
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
var error;
|
|
1025
|
-
this._active = true;
|
|
1026
|
-
do {
|
|
1027
|
-
if ((error = action.execute(action.state, action.delay))) {
|
|
1028
|
-
break;
|
|
1029
|
-
}
|
|
1030
|
-
} while ((action = actions.shift()));
|
|
1031
|
-
this._active = false;
|
|
1032
|
-
if (error) {
|
|
1033
|
-
while ((action = actions.shift())) {
|
|
1034
|
-
action.unsubscribe();
|
|
1035
|
-
}
|
|
1036
|
-
throw error;
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
return AsyncScheduler;
|
|
1040
|
-
}(Scheduler));
|
|
1041
|
-
|
|
1042
|
-
var VirtualTimeScheduler = (function (_super) {
|
|
1043
|
-
__extends(VirtualTimeScheduler, _super);
|
|
1044
|
-
function VirtualTimeScheduler(schedulerActionCtor, maxFrames) {
|
|
1045
|
-
if (schedulerActionCtor === void 0) { schedulerActionCtor = VirtualAction; }
|
|
1046
|
-
if (maxFrames === void 0) { maxFrames = Infinity; }
|
|
1047
|
-
var _this = _super.call(this, schedulerActionCtor, function () { return _this.frame; }) || this;
|
|
1048
|
-
_this.maxFrames = maxFrames;
|
|
1049
|
-
_this.frame = 0;
|
|
1050
|
-
_this.index = -1;
|
|
1051
|
-
return _this;
|
|
1052
|
-
}
|
|
1053
|
-
VirtualTimeScheduler.prototype.flush = function () {
|
|
1054
|
-
var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
|
|
1055
|
-
var error;
|
|
1056
|
-
var action;
|
|
1057
|
-
while ((action = actions[0]) && action.delay <= maxFrames) {
|
|
1058
|
-
actions.shift();
|
|
1059
|
-
this.frame = action.delay;
|
|
1060
|
-
if ((error = action.execute(action.state, action.delay))) {
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
if (error) {
|
|
1065
|
-
while ((action = actions.shift())) {
|
|
1066
|
-
action.unsubscribe();
|
|
1067
|
-
}
|
|
1068
|
-
throw error;
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
VirtualTimeScheduler.frameTimeFactor = 10;
|
|
1072
|
-
return VirtualTimeScheduler;
|
|
1073
|
-
}(AsyncScheduler));
|
|
1074
|
-
var VirtualAction = (function (_super) {
|
|
1075
|
-
__extends(VirtualAction, _super);
|
|
1076
|
-
function VirtualAction(scheduler, work, index) {
|
|
1077
|
-
if (index === void 0) { index = (scheduler.index += 1); }
|
|
1078
|
-
var _this = _super.call(this, scheduler, work) || this;
|
|
1079
|
-
_this.scheduler = scheduler;
|
|
1080
|
-
_this.work = work;
|
|
1081
|
-
_this.index = index;
|
|
1082
|
-
_this.active = true;
|
|
1083
|
-
_this.index = scheduler.index = index;
|
|
1084
|
-
return _this;
|
|
1085
|
-
}
|
|
1086
|
-
VirtualAction.prototype.schedule = function (state, delay) {
|
|
1087
|
-
if (delay === void 0) { delay = 0; }
|
|
1088
|
-
if (Number.isFinite(delay)) {
|
|
1089
|
-
if (!this.id) {
|
|
1090
|
-
return _super.prototype.schedule.call(this, state, delay);
|
|
1091
|
-
}
|
|
1092
|
-
this.active = false;
|
|
1093
|
-
var action = new VirtualAction(this.scheduler, this.work);
|
|
1094
|
-
this.add(action);
|
|
1095
|
-
return action.schedule(state, delay);
|
|
1096
|
-
}
|
|
1097
|
-
else {
|
|
1098
|
-
return Subscription.EMPTY;
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
|
|
1102
|
-
if (delay === void 0) { delay = 0; }
|
|
1103
|
-
this.delay = scheduler.frame + delay;
|
|
1104
|
-
var actions = scheduler.actions;
|
|
1105
|
-
actions.push(this);
|
|
1106
|
-
actions.sort(VirtualAction.sortActions);
|
|
1107
|
-
return true;
|
|
1108
|
-
};
|
|
1109
|
-
VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
|
|
1110
|
-
if (delay === void 0) { delay = 0; }
|
|
1111
|
-
return undefined;
|
|
1112
|
-
};
|
|
1113
|
-
VirtualAction.prototype._execute = function (state, delay) {
|
|
1114
|
-
if (this.active === true) {
|
|
1115
|
-
return _super.prototype._execute.call(this, state, delay);
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
VirtualAction.sortActions = function (a, b) {
|
|
1119
|
-
if (a.delay === b.delay) {
|
|
1120
|
-
if (a.index === b.index) {
|
|
1121
|
-
return 0;
|
|
1122
|
-
}
|
|
1123
|
-
else if (a.index > b.index) {
|
|
1124
|
-
return 1;
|
|
1125
|
-
}
|
|
1126
|
-
else {
|
|
1127
|
-
return -1;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
else if (a.delay > b.delay) {
|
|
1131
|
-
return 1;
|
|
1132
|
-
}
|
|
1133
|
-
else {
|
|
1134
|
-
return -1;
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
return VirtualAction;
|
|
1138
|
-
}(AsyncAction));
|
|
1139
|
-
|
|
1140
|
-
var performanceTimestampProvider = {
|
|
1141
|
-
now: function () {
|
|
1142
|
-
return (performanceTimestampProvider.delegate || performance).now();
|
|
1143
|
-
},
|
|
1144
|
-
delegate: undefined,
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
var animationFrameProvider = {
|
|
1148
|
-
schedule: function (callback) {
|
|
1149
|
-
var request = requestAnimationFrame;
|
|
1150
|
-
var cancel = cancelAnimationFrame;
|
|
1151
|
-
var delegate = animationFrameProvider.delegate;
|
|
1152
|
-
if (delegate) {
|
|
1153
|
-
request = delegate.requestAnimationFrame;
|
|
1154
|
-
cancel = delegate.cancelAnimationFrame;
|
|
1155
|
-
}
|
|
1156
|
-
var handle = request(function (timestamp) {
|
|
1157
|
-
cancel = undefined;
|
|
1158
|
-
callback(timestamp);
|
|
1159
|
-
});
|
|
1160
|
-
return new Subscription(function () { return cancel === null || cancel === void 0 ? void 0 : cancel(handle); });
|
|
1161
|
-
},
|
|
1162
|
-
requestAnimationFrame: function () {
|
|
1163
|
-
var args = [];
|
|
1164
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1165
|
-
args[_i] = arguments[_i];
|
|
1166
|
-
}
|
|
1167
|
-
var delegate = animationFrameProvider.delegate;
|
|
1168
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame).apply(void 0, __spreadArray([], __read(args)));
|
|
1169
|
-
},
|
|
1170
|
-
cancelAnimationFrame: function () {
|
|
1171
|
-
var args = [];
|
|
1172
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1173
|
-
args[_i] = arguments[_i];
|
|
1174
|
-
}
|
|
1175
|
-
var delegate = animationFrameProvider.delegate;
|
|
1176
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame).apply(void 0, __spreadArray([], __read(args)));
|
|
1177
|
-
},
|
|
1178
|
-
delegate: undefined,
|
|
1179
|
-
};
|
|
1180
|
-
|
|
1181
|
-
var nextHandle = 1;
|
|
1182
|
-
var resolved;
|
|
1183
|
-
var activeHandles = {};
|
|
1184
|
-
function findAndClearHandle(handle) {
|
|
1185
|
-
if (handle in activeHandles) {
|
|
1186
|
-
delete activeHandles[handle];
|
|
1187
|
-
return true;
|
|
1188
|
-
}
|
|
1189
|
-
return false;
|
|
1190
|
-
}
|
|
1191
|
-
var Immediate = {
|
|
1192
|
-
setImmediate: function (cb) {
|
|
1193
|
-
var handle = nextHandle++;
|
|
1194
|
-
activeHandles[handle] = true;
|
|
1195
|
-
if (!resolved) {
|
|
1196
|
-
resolved = Promise.resolve();
|
|
1197
|
-
}
|
|
1198
|
-
resolved.then(function () { return findAndClearHandle(handle) && cb(); });
|
|
1199
|
-
return handle;
|
|
1200
|
-
},
|
|
1201
|
-
clearImmediate: function (handle) {
|
|
1202
|
-
findAndClearHandle(handle);
|
|
1203
|
-
},
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
var setImmediate = Immediate.setImmediate, clearImmediate = Immediate.clearImmediate;
|
|
1207
|
-
var immediateProvider = {
|
|
1208
|
-
setImmediate: function () {
|
|
1209
|
-
var args = [];
|
|
1210
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1211
|
-
args[_i] = arguments[_i];
|
|
1212
|
-
}
|
|
1213
|
-
var delegate = immediateProvider.delegate;
|
|
1214
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setImmediate) || setImmediate).apply(void 0, __spreadArray([], __read(args)));
|
|
1215
|
-
},
|
|
1216
|
-
clearImmediate: function (handle) {
|
|
1217
|
-
var delegate = immediateProvider.delegate;
|
|
1218
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearImmediate) || clearImmediate)(handle);
|
|
1219
|
-
},
|
|
1220
|
-
delegate: undefined,
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
var defaultMaxFrame = 750;
|
|
1224
|
-
var TestScheduler = (function (_super) {
|
|
1225
|
-
__extends(TestScheduler, _super);
|
|
1226
|
-
function TestScheduler(assertDeepEqual) {
|
|
1227
|
-
var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
|
|
1228
|
-
_this.assertDeepEqual = assertDeepEqual;
|
|
1229
|
-
_this.hotObservables = [];
|
|
1230
|
-
_this.coldObservables = [];
|
|
1231
|
-
_this.flushTests = [];
|
|
1232
|
-
_this.runMode = false;
|
|
1233
|
-
return _this;
|
|
1234
|
-
}
|
|
1235
|
-
TestScheduler.prototype.createTime = function (marbles) {
|
|
1236
|
-
var indexOf = this.runMode ? marbles.trim().indexOf('|') : marbles.indexOf('|');
|
|
1237
|
-
if (indexOf === -1) {
|
|
1238
|
-
throw new Error('marble diagram for time should have a completion marker "|"');
|
|
1239
|
-
}
|
|
1240
|
-
return indexOf * TestScheduler.frameTimeFactor;
|
|
1241
|
-
};
|
|
1242
|
-
TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
|
|
1243
|
-
if (marbles.indexOf('^') !== -1) {
|
|
1244
|
-
throw new Error('cold observable cannot have subscription offset "^"');
|
|
1245
|
-
}
|
|
1246
|
-
if (marbles.indexOf('!') !== -1) {
|
|
1247
|
-
throw new Error('cold observable cannot have unsubscription marker "!"');
|
|
1248
|
-
}
|
|
1249
|
-
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
|
|
1250
|
-
var cold = new ColdObservable(messages, this);
|
|
1251
|
-
this.coldObservables.push(cold);
|
|
1252
|
-
return cold;
|
|
1253
|
-
};
|
|
1254
|
-
TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
|
|
1255
|
-
if (marbles.indexOf('!') !== -1) {
|
|
1256
|
-
throw new Error('hot observable cannot have unsubscription marker "!"');
|
|
1257
|
-
}
|
|
1258
|
-
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
|
|
1259
|
-
var subject = new HotObservable(messages, this);
|
|
1260
|
-
this.hotObservables.push(subject);
|
|
1261
|
-
return subject;
|
|
1262
|
-
};
|
|
1263
|
-
TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
|
|
1264
|
-
var _this = this;
|
|
1265
|
-
var messages = [];
|
|
1266
|
-
observable.subscribe({
|
|
1267
|
-
next: function (value) {
|
|
1268
|
-
messages.push({ frame: _this.frame - outerFrame, notification: nextNotification(value) });
|
|
1269
|
-
},
|
|
1270
|
-
error: function (error) {
|
|
1271
|
-
messages.push({ frame: _this.frame - outerFrame, notification: errorNotification(error) });
|
|
1272
|
-
},
|
|
1273
|
-
complete: function () {
|
|
1274
|
-
messages.push({ frame: _this.frame - outerFrame, notification: COMPLETE_NOTIFICATION });
|
|
1275
|
-
},
|
|
1276
|
-
});
|
|
1277
|
-
return messages;
|
|
1278
|
-
};
|
|
1279
|
-
TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
|
|
1280
|
-
var _this = this;
|
|
1281
|
-
if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
|
|
1282
|
-
var actual = [];
|
|
1283
|
-
var flushTest = { actual: actual, ready: false };
|
|
1284
|
-
var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
|
|
1285
|
-
var subscriptionFrame = subscriptionParsed.subscribedFrame === Infinity ? 0 : subscriptionParsed.subscribedFrame;
|
|
1286
|
-
var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
|
|
1287
|
-
var subscription;
|
|
1288
|
-
this.schedule(function () {
|
|
1289
|
-
subscription = observable.subscribe({
|
|
1290
|
-
next: function (x) {
|
|
1291
|
-
var value = x instanceof Observable ? _this.materializeInnerObservable(x, _this.frame) : x;
|
|
1292
|
-
actual.push({ frame: _this.frame, notification: nextNotification(value) });
|
|
1293
|
-
},
|
|
1294
|
-
error: function (error) {
|
|
1295
|
-
actual.push({ frame: _this.frame, notification: errorNotification(error) });
|
|
1296
|
-
},
|
|
1297
|
-
complete: function () {
|
|
1298
|
-
actual.push({ frame: _this.frame, notification: COMPLETE_NOTIFICATION });
|
|
1299
|
-
},
|
|
1300
|
-
});
|
|
1301
|
-
}, subscriptionFrame);
|
|
1302
|
-
if (unsubscriptionFrame !== Infinity) {
|
|
1303
|
-
this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
|
|
1304
|
-
}
|
|
1305
|
-
this.flushTests.push(flushTest);
|
|
1306
|
-
var runMode = this.runMode;
|
|
1307
|
-
return {
|
|
1308
|
-
toBe: function (marbles, values, errorValue) {
|
|
1309
|
-
flushTest.ready = true;
|
|
1310
|
-
flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
|
|
1311
|
-
},
|
|
1312
|
-
toEqual: function (other) {
|
|
1313
|
-
flushTest.ready = true;
|
|
1314
|
-
flushTest.expected = [];
|
|
1315
|
-
_this.schedule(function () {
|
|
1316
|
-
subscription = other.subscribe({
|
|
1317
|
-
next: function (x) {
|
|
1318
|
-
var value = x instanceof Observable ? _this.materializeInnerObservable(x, _this.frame) : x;
|
|
1319
|
-
flushTest.expected.push({ frame: _this.frame, notification: nextNotification(value) });
|
|
1320
|
-
},
|
|
1321
|
-
error: function (error) {
|
|
1322
|
-
flushTest.expected.push({ frame: _this.frame, notification: errorNotification(error) });
|
|
1323
|
-
},
|
|
1324
|
-
complete: function () {
|
|
1325
|
-
flushTest.expected.push({ frame: _this.frame, notification: COMPLETE_NOTIFICATION });
|
|
1326
|
-
},
|
|
1327
|
-
});
|
|
1328
|
-
}, subscriptionFrame);
|
|
1329
|
-
},
|
|
1330
|
-
};
|
|
1331
|
-
};
|
|
1332
|
-
TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
|
|
1333
|
-
var flushTest = { actual: actualSubscriptionLogs, ready: false };
|
|
1334
|
-
this.flushTests.push(flushTest);
|
|
1335
|
-
var runMode = this.runMode;
|
|
1336
|
-
return {
|
|
1337
|
-
toBe: function (marblesOrMarblesArray) {
|
|
1338
|
-
var marblesArray = typeof marblesOrMarblesArray === 'string' ? [marblesOrMarblesArray] : marblesOrMarblesArray;
|
|
1339
|
-
flushTest.ready = true;
|
|
1340
|
-
flushTest.expected = marblesArray
|
|
1341
|
-
.map(function (marbles) { return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode); })
|
|
1342
|
-
.filter(function (marbles) { return marbles.subscribedFrame !== Infinity; });
|
|
1343
|
-
},
|
|
1344
|
-
};
|
|
1345
|
-
};
|
|
1346
|
-
TestScheduler.prototype.flush = function () {
|
|
1347
|
-
var _this = this;
|
|
1348
|
-
var hotObservables = this.hotObservables;
|
|
1349
|
-
while (hotObservables.length > 0) {
|
|
1350
|
-
hotObservables.shift().setup();
|
|
1351
|
-
}
|
|
1352
|
-
_super.prototype.flush.call(this);
|
|
1353
|
-
this.flushTests = this.flushTests.filter(function (test) {
|
|
1354
|
-
if (test.ready) {
|
|
1355
|
-
_this.assertDeepEqual(test.actual, test.expected);
|
|
1356
|
-
return false;
|
|
1357
|
-
}
|
|
1358
|
-
return true;
|
|
1359
|
-
});
|
|
1360
|
-
};
|
|
1361
|
-
TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
|
|
1362
|
-
var _this = this;
|
|
1363
|
-
if (runMode === void 0) { runMode = false; }
|
|
1364
|
-
if (typeof marbles !== 'string') {
|
|
1365
|
-
return new SubscriptionLog(Infinity);
|
|
1366
|
-
}
|
|
1367
|
-
var characters = __spreadArray([], __read(marbles));
|
|
1368
|
-
var len = characters.length;
|
|
1369
|
-
var groupStart = -1;
|
|
1370
|
-
var subscriptionFrame = Infinity;
|
|
1371
|
-
var unsubscriptionFrame = Infinity;
|
|
1372
|
-
var frame = 0;
|
|
1373
|
-
var _loop_1 = function (i) {
|
|
1374
|
-
var nextFrame = frame;
|
|
1375
|
-
var advanceFrameBy = function (count) {
|
|
1376
|
-
nextFrame += count * _this.frameTimeFactor;
|
|
1377
|
-
};
|
|
1378
|
-
var c = characters[i];
|
|
1379
|
-
switch (c) {
|
|
1380
|
-
case ' ':
|
|
1381
|
-
if (!runMode) {
|
|
1382
|
-
advanceFrameBy(1);
|
|
1383
|
-
}
|
|
1384
|
-
break;
|
|
1385
|
-
case '-':
|
|
1386
|
-
advanceFrameBy(1);
|
|
1387
|
-
break;
|
|
1388
|
-
case '(':
|
|
1389
|
-
groupStart = frame;
|
|
1390
|
-
advanceFrameBy(1);
|
|
1391
|
-
break;
|
|
1392
|
-
case ')':
|
|
1393
|
-
groupStart = -1;
|
|
1394
|
-
advanceFrameBy(1);
|
|
1395
|
-
break;
|
|
1396
|
-
case '^':
|
|
1397
|
-
if (subscriptionFrame !== Infinity) {
|
|
1398
|
-
throw new Error("found a second subscription point '^' in a " + 'subscription marble diagram. There can only be one.');
|
|
1399
|
-
}
|
|
1400
|
-
subscriptionFrame = groupStart > -1 ? groupStart : frame;
|
|
1401
|
-
advanceFrameBy(1);
|
|
1402
|
-
break;
|
|
1403
|
-
case '!':
|
|
1404
|
-
if (unsubscriptionFrame !== Infinity) {
|
|
1405
|
-
throw new Error("found a second unsubscription point '!' in a " + 'subscription marble diagram. There can only be one.');
|
|
1406
|
-
}
|
|
1407
|
-
unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
|
|
1408
|
-
break;
|
|
1409
|
-
default:
|
|
1410
|
-
if (runMode && c.match(/^[0-9]$/)) {
|
|
1411
|
-
if (i === 0 || characters[i - 1] === ' ') {
|
|
1412
|
-
var buffer = characters.slice(i).join('');
|
|
1413
|
-
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
|
|
1414
|
-
if (match) {
|
|
1415
|
-
i += match[0].length - 1;
|
|
1416
|
-
var duration = parseFloat(match[1]);
|
|
1417
|
-
var unit = match[2];
|
|
1418
|
-
var durationInMs = void 0;
|
|
1419
|
-
switch (unit) {
|
|
1420
|
-
case 'ms':
|
|
1421
|
-
durationInMs = duration;
|
|
1422
|
-
break;
|
|
1423
|
-
case 's':
|
|
1424
|
-
durationInMs = duration * 1000;
|
|
1425
|
-
break;
|
|
1426
|
-
case 'm':
|
|
1427
|
-
durationInMs = duration * 1000 * 60;
|
|
1428
|
-
break;
|
|
1429
|
-
}
|
|
1430
|
-
advanceFrameBy(durationInMs / this_1.frameTimeFactor);
|
|
1431
|
-
break;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
throw new Error("there can only be '^' and '!' markers in a " + "subscription marble diagram. Found instead '" + c + "'.");
|
|
1436
|
-
}
|
|
1437
|
-
frame = nextFrame;
|
|
1438
|
-
out_i_1 = i;
|
|
1439
|
-
};
|
|
1440
|
-
var this_1 = this, out_i_1;
|
|
1441
|
-
for (var i = 0; i < len; i++) {
|
|
1442
|
-
_loop_1(i);
|
|
1443
|
-
i = out_i_1;
|
|
1444
|
-
}
|
|
1445
|
-
if (unsubscriptionFrame < 0) {
|
|
1446
|
-
return new SubscriptionLog(subscriptionFrame);
|
|
1447
|
-
}
|
|
1448
|
-
else {
|
|
1449
|
-
return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
|
-
TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
|
|
1453
|
-
var _this = this;
|
|
1454
|
-
if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
|
|
1455
|
-
if (runMode === void 0) { runMode = false; }
|
|
1456
|
-
if (marbles.indexOf('!') !== -1) {
|
|
1457
|
-
throw new Error('conventional marble diagrams cannot have the ' + 'unsubscription marker "!"');
|
|
1458
|
-
}
|
|
1459
|
-
var characters = __spreadArray([], __read(marbles));
|
|
1460
|
-
var len = characters.length;
|
|
1461
|
-
var testMessages = [];
|
|
1462
|
-
var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
|
|
1463
|
-
var frame = subIndex === -1 ? 0 : subIndex * -this.frameTimeFactor;
|
|
1464
|
-
var getValue = typeof values !== 'object'
|
|
1465
|
-
? function (x) { return x; }
|
|
1466
|
-
: function (x) {
|
|
1467
|
-
if (materializeInnerObservables && values[x] instanceof ColdObservable) {
|
|
1468
|
-
return values[x].messages;
|
|
1469
|
-
}
|
|
1470
|
-
return values[x];
|
|
1471
|
-
};
|
|
1472
|
-
var groupStart = -1;
|
|
1473
|
-
var _loop_2 = function (i) {
|
|
1474
|
-
var nextFrame = frame;
|
|
1475
|
-
var advanceFrameBy = function (count) {
|
|
1476
|
-
nextFrame += count * _this.frameTimeFactor;
|
|
1477
|
-
};
|
|
1478
|
-
var notification = void 0;
|
|
1479
|
-
var c = characters[i];
|
|
1480
|
-
switch (c) {
|
|
1481
|
-
case ' ':
|
|
1482
|
-
if (!runMode) {
|
|
1483
|
-
advanceFrameBy(1);
|
|
1484
|
-
}
|
|
1485
|
-
break;
|
|
1486
|
-
case '-':
|
|
1487
|
-
advanceFrameBy(1);
|
|
1488
|
-
break;
|
|
1489
|
-
case '(':
|
|
1490
|
-
groupStart = frame;
|
|
1491
|
-
advanceFrameBy(1);
|
|
1492
|
-
break;
|
|
1493
|
-
case ')':
|
|
1494
|
-
groupStart = -1;
|
|
1495
|
-
advanceFrameBy(1);
|
|
1496
|
-
break;
|
|
1497
|
-
case '|':
|
|
1498
|
-
notification = COMPLETE_NOTIFICATION;
|
|
1499
|
-
advanceFrameBy(1);
|
|
1500
|
-
break;
|
|
1501
|
-
case '^':
|
|
1502
|
-
advanceFrameBy(1);
|
|
1503
|
-
break;
|
|
1504
|
-
case '#':
|
|
1505
|
-
notification = errorNotification(errorValue || 'error');
|
|
1506
|
-
advanceFrameBy(1);
|
|
1507
|
-
break;
|
|
1508
|
-
default:
|
|
1509
|
-
if (runMode && c.match(/^[0-9]$/)) {
|
|
1510
|
-
if (i === 0 || characters[i - 1] === ' ') {
|
|
1511
|
-
var buffer = characters.slice(i).join('');
|
|
1512
|
-
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
|
|
1513
|
-
if (match) {
|
|
1514
|
-
i += match[0].length - 1;
|
|
1515
|
-
var duration = parseFloat(match[1]);
|
|
1516
|
-
var unit = match[2];
|
|
1517
|
-
var durationInMs = void 0;
|
|
1518
|
-
switch (unit) {
|
|
1519
|
-
case 'ms':
|
|
1520
|
-
durationInMs = duration;
|
|
1521
|
-
break;
|
|
1522
|
-
case 's':
|
|
1523
|
-
durationInMs = duration * 1000;
|
|
1524
|
-
break;
|
|
1525
|
-
case 'm':
|
|
1526
|
-
durationInMs = duration * 1000 * 60;
|
|
1527
|
-
break;
|
|
1528
|
-
}
|
|
1529
|
-
advanceFrameBy(durationInMs / this_2.frameTimeFactor);
|
|
1530
|
-
break;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
notification = nextNotification(getValue(c));
|
|
1535
|
-
advanceFrameBy(1);
|
|
1536
|
-
break;
|
|
1537
|
-
}
|
|
1538
|
-
if (notification) {
|
|
1539
|
-
testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
|
|
1540
|
-
}
|
|
1541
|
-
frame = nextFrame;
|
|
1542
|
-
out_i_2 = i;
|
|
1543
|
-
};
|
|
1544
|
-
var this_2 = this, out_i_2;
|
|
1545
|
-
for (var i = 0; i < len; i++) {
|
|
1546
|
-
_loop_2(i);
|
|
1547
|
-
i = out_i_2;
|
|
1548
|
-
}
|
|
1549
|
-
return testMessages;
|
|
1550
|
-
};
|
|
1551
|
-
TestScheduler.prototype.createAnimator = function () {
|
|
1552
|
-
var _this = this;
|
|
1553
|
-
if (!this.runMode) {
|
|
1554
|
-
throw new Error('animate() must only be used in run mode');
|
|
1555
|
-
}
|
|
1556
|
-
var lastHandle = 0;
|
|
1557
|
-
var map;
|
|
1558
|
-
var delegate = {
|
|
1559
|
-
requestAnimationFrame: function (callback) {
|
|
1560
|
-
if (!map) {
|
|
1561
|
-
throw new Error('animate() was not called within run()');
|
|
1562
|
-
}
|
|
1563
|
-
var handle = ++lastHandle;
|
|
1564
|
-
map.set(handle, callback);
|
|
1565
|
-
return handle;
|
|
1566
|
-
},
|
|
1567
|
-
cancelAnimationFrame: function (handle) {
|
|
1568
|
-
if (!map) {
|
|
1569
|
-
throw new Error('animate() was not called within run()');
|
|
1570
|
-
}
|
|
1571
|
-
map.delete(handle);
|
|
1572
|
-
},
|
|
1573
|
-
};
|
|
1574
|
-
var animate = function (marbles) {
|
|
1575
|
-
var e_1, _a;
|
|
1576
|
-
if (map) {
|
|
1577
|
-
throw new Error('animate() must not be called more than once within run()');
|
|
1578
|
-
}
|
|
1579
|
-
if (/[|#]/.test(marbles)) {
|
|
1580
|
-
throw new Error('animate() must not complete or error');
|
|
1581
|
-
}
|
|
1582
|
-
map = new Map();
|
|
1583
|
-
var messages = TestScheduler.parseMarbles(marbles, undefined, undefined, undefined, true);
|
|
1584
|
-
try {
|
|
1585
|
-
for (var messages_1 = __values(messages), messages_1_1 = messages_1.next(); !messages_1_1.done; messages_1_1 = messages_1.next()) {
|
|
1586
|
-
var message = messages_1_1.value;
|
|
1587
|
-
_this.schedule(function () {
|
|
1588
|
-
var e_2, _a;
|
|
1589
|
-
var now = _this.now();
|
|
1590
|
-
var callbacks = Array.from(map.values());
|
|
1591
|
-
map.clear();
|
|
1592
|
-
try {
|
|
1593
|
-
for (var callbacks_1 = (e_2 = void 0, __values(callbacks)), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) {
|
|
1594
|
-
var callback = callbacks_1_1.value;
|
|
1595
|
-
callback(now);
|
|
1596
|
-
}
|
|
1597
|
-
}
|
|
1598
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1599
|
-
finally {
|
|
1600
|
-
try {
|
|
1601
|
-
if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1);
|
|
1602
|
-
}
|
|
1603
|
-
finally { if (e_2) throw e_2.error; }
|
|
1604
|
-
}
|
|
1605
|
-
}, message.frame);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1609
|
-
finally {
|
|
1610
|
-
try {
|
|
1611
|
-
if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) _a.call(messages_1);
|
|
1612
|
-
}
|
|
1613
|
-
finally { if (e_1) throw e_1.error; }
|
|
1614
|
-
}
|
|
1615
|
-
};
|
|
1616
|
-
return { animate: animate, delegate: delegate };
|
|
1617
|
-
};
|
|
1618
|
-
TestScheduler.prototype.createDelegates = function () {
|
|
1619
|
-
var _this = this;
|
|
1620
|
-
var lastHandle = 0;
|
|
1621
|
-
var scheduleLookup = new Map();
|
|
1622
|
-
var run = function () {
|
|
1623
|
-
var now = _this.now();
|
|
1624
|
-
var scheduledRecords = Array.from(scheduleLookup.values());
|
|
1625
|
-
var scheduledRecordsDue = scheduledRecords.filter(function (_a) {
|
|
1626
|
-
var due = _a.due;
|
|
1627
|
-
return due <= now;
|
|
1628
|
-
});
|
|
1629
|
-
var dueImmediates = scheduledRecordsDue.filter(function (_a) {
|
|
1630
|
-
var type = _a.type;
|
|
1631
|
-
return type === 'immediate';
|
|
1632
|
-
});
|
|
1633
|
-
if (dueImmediates.length > 0) {
|
|
1634
|
-
var _a = dueImmediates[0], handle = _a.handle, handler = _a.handler;
|
|
1635
|
-
scheduleLookup.delete(handle);
|
|
1636
|
-
handler();
|
|
1637
|
-
return;
|
|
1638
|
-
}
|
|
1639
|
-
var dueIntervals = scheduledRecordsDue.filter(function (_a) {
|
|
1640
|
-
var type = _a.type;
|
|
1641
|
-
return type === 'interval';
|
|
1642
|
-
});
|
|
1643
|
-
if (dueIntervals.length > 0) {
|
|
1644
|
-
var firstDueInterval = dueIntervals[0];
|
|
1645
|
-
var duration = firstDueInterval.duration, handler = firstDueInterval.handler;
|
|
1646
|
-
firstDueInterval.due = now + duration;
|
|
1647
|
-
firstDueInterval.subscription = _this.schedule(run, duration);
|
|
1648
|
-
handler();
|
|
1649
|
-
return;
|
|
1650
|
-
}
|
|
1651
|
-
var dueTimeouts = scheduledRecordsDue.filter(function (_a) {
|
|
1652
|
-
var type = _a.type;
|
|
1653
|
-
return type === 'timeout';
|
|
1654
|
-
});
|
|
1655
|
-
if (dueTimeouts.length > 0) {
|
|
1656
|
-
var _b = dueTimeouts[0], handle = _b.handle, handler = _b.handler;
|
|
1657
|
-
scheduleLookup.delete(handle);
|
|
1658
|
-
handler();
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
throw new Error('Expected a due immediate or interval');
|
|
1662
|
-
};
|
|
1663
|
-
var immediate = {
|
|
1664
|
-
setImmediate: function (handler) {
|
|
1665
|
-
var handle = ++lastHandle;
|
|
1666
|
-
scheduleLookup.set(handle, {
|
|
1667
|
-
due: _this.now(),
|
|
1668
|
-
duration: 0,
|
|
1669
|
-
handle: handle,
|
|
1670
|
-
handler: handler,
|
|
1671
|
-
subscription: _this.schedule(run, 0),
|
|
1672
|
-
type: 'immediate',
|
|
1673
|
-
});
|
|
1674
|
-
return handle;
|
|
1675
|
-
},
|
|
1676
|
-
clearImmediate: function (handle) {
|
|
1677
|
-
var value = scheduleLookup.get(handle);
|
|
1678
|
-
if (value) {
|
|
1679
|
-
value.subscription.unsubscribe();
|
|
1680
|
-
scheduleLookup.delete(handle);
|
|
1681
|
-
}
|
|
1682
|
-
},
|
|
1683
|
-
};
|
|
1684
|
-
var interval = {
|
|
1685
|
-
setInterval: function (handler, duration) {
|
|
1686
|
-
if (duration === void 0) { duration = 0; }
|
|
1687
|
-
var handle = ++lastHandle;
|
|
1688
|
-
scheduleLookup.set(handle, {
|
|
1689
|
-
due: _this.now() + duration,
|
|
1690
|
-
duration: duration,
|
|
1691
|
-
handle: handle,
|
|
1692
|
-
handler: handler,
|
|
1693
|
-
subscription: _this.schedule(run, duration),
|
|
1694
|
-
type: 'interval',
|
|
1695
|
-
});
|
|
1696
|
-
return handle;
|
|
1697
|
-
},
|
|
1698
|
-
clearInterval: function (handle) {
|
|
1699
|
-
var value = scheduleLookup.get(handle);
|
|
1700
|
-
if (value) {
|
|
1701
|
-
value.subscription.unsubscribe();
|
|
1702
|
-
scheduleLookup.delete(handle);
|
|
1703
|
-
}
|
|
1704
|
-
},
|
|
1705
|
-
};
|
|
1706
|
-
var timeout = {
|
|
1707
|
-
setTimeout: function (handler, duration) {
|
|
1708
|
-
if (duration === void 0) { duration = 0; }
|
|
1709
|
-
var handle = ++lastHandle;
|
|
1710
|
-
scheduleLookup.set(handle, {
|
|
1711
|
-
due: _this.now() + duration,
|
|
1712
|
-
duration: duration,
|
|
1713
|
-
handle: handle,
|
|
1714
|
-
handler: handler,
|
|
1715
|
-
subscription: _this.schedule(run, duration),
|
|
1716
|
-
type: 'timeout',
|
|
1717
|
-
});
|
|
1718
|
-
return handle;
|
|
1719
|
-
},
|
|
1720
|
-
clearTimeout: function (handle) {
|
|
1721
|
-
var value = scheduleLookup.get(handle);
|
|
1722
|
-
if (value) {
|
|
1723
|
-
value.subscription.unsubscribe();
|
|
1724
|
-
scheduleLookup.delete(handle);
|
|
1725
|
-
}
|
|
1726
|
-
},
|
|
1727
|
-
};
|
|
1728
|
-
return { immediate: immediate, interval: interval, timeout: timeout };
|
|
1729
|
-
};
|
|
1730
|
-
TestScheduler.prototype.run = function (callback) {
|
|
1731
|
-
var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
|
|
1732
|
-
var prevMaxFrames = this.maxFrames;
|
|
1733
|
-
TestScheduler.frameTimeFactor = 1;
|
|
1734
|
-
this.maxFrames = Infinity;
|
|
1735
|
-
this.runMode = true;
|
|
1736
|
-
var animator = this.createAnimator();
|
|
1737
|
-
var delegates = this.createDelegates();
|
|
1738
|
-
animationFrameProvider.delegate = animator.delegate;
|
|
1739
|
-
dateTimestampProvider.delegate = this;
|
|
1740
|
-
immediateProvider.delegate = delegates.immediate;
|
|
1741
|
-
intervalProvider.delegate = delegates.interval;
|
|
1742
|
-
timeoutProvider.delegate = delegates.timeout;
|
|
1743
|
-
performanceTimestampProvider.delegate = this;
|
|
1744
|
-
var helpers = {
|
|
1745
|
-
cold: this.createColdObservable.bind(this),
|
|
1746
|
-
hot: this.createHotObservable.bind(this),
|
|
1747
|
-
flush: this.flush.bind(this),
|
|
1748
|
-
time: this.createTime.bind(this),
|
|
1749
|
-
expectObservable: this.expectObservable.bind(this),
|
|
1750
|
-
expectSubscriptions: this.expectSubscriptions.bind(this),
|
|
1751
|
-
animate: animator.animate,
|
|
1752
|
-
};
|
|
1753
|
-
try {
|
|
1754
|
-
var ret = callback(helpers);
|
|
1755
|
-
this.flush();
|
|
1756
|
-
return ret;
|
|
1757
|
-
}
|
|
1758
|
-
finally {
|
|
1759
|
-
TestScheduler.frameTimeFactor = prevFrameTimeFactor;
|
|
1760
|
-
this.maxFrames = prevMaxFrames;
|
|
1761
|
-
this.runMode = false;
|
|
1762
|
-
animationFrameProvider.delegate = undefined;
|
|
1763
|
-
dateTimestampProvider.delegate = undefined;
|
|
1764
|
-
immediateProvider.delegate = undefined;
|
|
1765
|
-
intervalProvider.delegate = undefined;
|
|
1766
|
-
timeoutProvider.delegate = undefined;
|
|
1767
|
-
performanceTimestampProvider.delegate = undefined;
|
|
1768
|
-
}
|
|
1769
|
-
};
|
|
1770
|
-
TestScheduler.frameTimeFactor = 10;
|
|
1771
|
-
return TestScheduler;
|
|
1772
|
-
}(VirtualTimeScheduler));
|
|
1773
|
-
|
|
1774
|
-
const parseMarbles = TestScheduler.parseMarbles.bind(TestScheduler);
|
|
1775
|
-
|
|
1776
|
-
exports.parseMarbles = parseMarbles;
|
|
1777
|
-
//# sourceMappingURL=index.js.map
|