@everymatrix/casino-challenge-details 0.6.10 → 0.6.12
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/dist/casino-challenge-details/casino-challenge-details-9465f599.js +7 -0
- package/dist/casino-challenge-details/casino-challenge-details.esm.js +1 -1
- package/dist/casino-challenge-details/casino-challenge-details_4.entry.js +1 -1
- package/dist/casino-challenge-details/index-30adf0cb.js +2 -0
- package/dist/casino-challenge-details/index.esm.js +1 -1
- package/dist/cjs/{casino-challenge-details-ffaca965.js → casino-challenge-details-774d82cd.js} +1069 -4
- package/dist/cjs/casino-challenge-details.cjs.js +2 -2
- package/dist/cjs/casino-challenge-details_4.cjs.entry.js +4 -4
- package/dist/cjs/{index-1b30d7ac.js → index-2a30d71d.js} +2 -69
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/casino-challenge-details/casino-challenge-details.js +23 -13
- package/dist/collection/components/components/casino-challenge-progress-bar.js +2 -2
- package/dist/esm/{casino-challenge-details-004dcf62.js → casino-challenge-details-9465f599.js} +1069 -4
- package/dist/esm/casino-challenge-details.js +3 -3
- package/dist/esm/casino-challenge-details_4.entry.js +5 -5
- package/dist/esm/{index-662208df.js → index-30adf0cb.js} +2 -69
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/casino-challenge-details/casino-challenge-details.d.ts +4 -0
- package/package.json +1 -1
- package/dist/casino-challenge-details/casino-challenge-details-004dcf62.js +0 -1
- package/dist/casino-challenge-details/index-662208df.js +0 -2
package/dist/esm/{casino-challenge-details-004dcf62.js → casino-challenge-details-9465f599.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h } from './index-
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './index-30adf0cb.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @name setClientStyling
|
|
@@ -309,6 +309,1054 @@ const titleIconSvg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53
|
|
|
309
309
|
|
|
310
310
|
const notificationSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNCAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzgzOF8zMTApIj4KPHBhdGggZD0iTTcuNTAwNDYgMTIuOTk5OUM4LjQwNTk1IDEyLjk5OTkgOS4xNjM0MSAxMi4zNTQ0IDkuMzM3MzUgMTEuNUg1LjY2MzU3QzUuODM3NiAxMi4zNTQ0IDYuNTk1MDYgMTIuOTk5OSA3LjUwMDQ2IDEyLjk5OTlaIiBmaWxsPSJ1cmwoI3BhaW50MF9saW5lYXJfODM4XzMxMCkiLz4KPHBhdGggZD0iTTExLjAwNTggNi45OTkxN0MxMS4wMDM3IDYuOTk5MTcgMTEuMDAxNyA2Ljk5OTYzIDEwLjk5OTcgNi45OTk2M0M5LjA3MDM2IDYuOTk5NjMgNy40OTk5NyA1LjQyOTcgNy40OTk5NyAzLjQ5OTlDNy40OTk5NyAyLjk2OTM5IDcuNjIyIDIuNDY3ODkgNy44MzQ0OCAyLjAxNjk0QzcuNzI0NDQgMi4wMDY1IDcuNjEyOTMgMiA3LjQ5OTk3IDJDNS41NjcxMyAyIDQuMDAwMjIgMy41NjY4MiA0LjAwMDIyIDUuNDk5NzNWNi44OTM2MkM0LjAwMDIyIDcuODgzMDUgMy41NjY3NCA4LjgxNzAxIDIuODA2MjYgOS40NTk5NEMyLjU1Mjc3IDkuNjc2NDUgMi40NDAyNiAxMC4wMjE0IDIuNTMxMjUgMTAuMzU3OUMyLjYzNzI3IDEwLjc0OTQgMy4wMjQyMyAxMC45OTk0IDMuNDMwMjUgMTAuOTk5NEgxMS41NjcyQzExLjk5MzIgMTAuOTk5NCAxMi4zOTQ3IDEwLjcyMzQgMTIuNDgxMSAxMC4zMDU5QzEyLjU0ODEgOS45ODI5NCAxMi40MzMyIDkuNjYwNDMgMTIuMTgyNyA5LjQ0OTk2QzExLjQ1NTcgOC44NDA1NCAxMS4wMzUyIDcuOTQ1MDMgMTEuMDA1OCA2Ljk5OTE3WiIgZmlsbD0idXJsKCNwYWludDFfbGluZWFyXzgzOF8zMTApIi8+CjxwYXRoIGQ9Ik0xMy41MDA2IDMuNDk5ODZDMTMuNTAwNiA0Ljg4MDQ3IDEyLjM4MTUgNS45OTk2MyAxMS4wMDA4IDUuOTk5NjNDOS42MjAxNCA1Ljk5OTYzIDguNTAwOTggNC44ODA0NyA4LjUwMDk4IDMuNDk5ODZDOC41MDA5OCAyLjExOTI1IDkuNjIwMTQgMSAxMS4wMDA4IDFDMTIuMzgxNSAxIDEzLjUwMDYgMi4xMTkyNSAxMy41MDA2IDMuNDk5ODZaIiBmaWxsPSIjRDY0MjFFIi8+CjwvZz4KPGRlZnM+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl84MzhfMzEwIiB4MT0iNy41MDA0NiIgeTE9IjExLjUiIHgyPSI3LjUwMDQ2IiB5Mj0iMTIuOTk5OSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjRUE5MDE4Ii8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iI0UwQTg0RSIvPgo8L2xpbmVhckdyYWRpZW50Pgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MV9saW5lYXJfODM4XzMxMCIgeDE9IjcuNDk5OTciIHkxPSIyIiB4Mj0iNy40OTk5NyIgeTI9IjEwLjk5OTQiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0VBOTAxOCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNFMEE4NEUiLz4KPC9saW5lYXJHcmFkaWVudD4KPGNsaXBQYXRoIGlkPSJjbGlwMF84MzhfMzEwIj4KPHJlY3Qgd2lkdGg9IjEzIiBoZWlnaHQ9IjE2IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC41KSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=';
|
|
311
311
|
|
|
312
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
313
|
+
|
|
314
|
+
var eventsource = {exports: {}};
|
|
315
|
+
|
|
316
|
+
/** @license
|
|
317
|
+
* eventsource.js
|
|
318
|
+
* Available under MIT License (MIT)
|
|
319
|
+
* https://github.com/Yaffle/EventSource/
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
(function (module, exports) {
|
|
323
|
+
/*jslint indent: 2, vars: true, plusplus: true */
|
|
324
|
+
/*global setTimeout, clearTimeout */
|
|
325
|
+
|
|
326
|
+
(function (global) {
|
|
327
|
+
|
|
328
|
+
var setTimeout = global.setTimeout;
|
|
329
|
+
var clearTimeout = global.clearTimeout;
|
|
330
|
+
var XMLHttpRequest = global.XMLHttpRequest;
|
|
331
|
+
var XDomainRequest = global.XDomainRequest;
|
|
332
|
+
var ActiveXObject = global.ActiveXObject;
|
|
333
|
+
var NativeEventSource = global.EventSource;
|
|
334
|
+
|
|
335
|
+
var document = global.document;
|
|
336
|
+
var Promise = global.Promise;
|
|
337
|
+
var fetch = global.fetch;
|
|
338
|
+
var Response = global.Response;
|
|
339
|
+
var TextDecoder = global.TextDecoder;
|
|
340
|
+
var TextEncoder = global.TextEncoder;
|
|
341
|
+
var AbortController = global.AbortController;
|
|
342
|
+
|
|
343
|
+
if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
|
|
344
|
+
document.readyState = "loading";
|
|
345
|
+
window.addEventListener("load", function (event) {
|
|
346
|
+
document.readyState = "complete";
|
|
347
|
+
}, false);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
|
|
351
|
+
XMLHttpRequest = function () {
|
|
352
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (Object.create == undefined) {
|
|
357
|
+
Object.create = function (C) {
|
|
358
|
+
function F(){}
|
|
359
|
+
F.prototype = C;
|
|
360
|
+
return new F();
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (!Date.now) {
|
|
365
|
+
Date.now = function now() {
|
|
366
|
+
return new Date().getTime();
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// see #118 (Promise#finally with polyfilled Promise)
|
|
371
|
+
// see #123 (data URLs crash Edge)
|
|
372
|
+
// see #125 (CSP violations)
|
|
373
|
+
// see pull/#138
|
|
374
|
+
// => No way to polyfill Promise#finally
|
|
375
|
+
|
|
376
|
+
if (AbortController == undefined) {
|
|
377
|
+
var originalFetch2 = fetch;
|
|
378
|
+
fetch = function (url, options) {
|
|
379
|
+
var signal = options.signal;
|
|
380
|
+
return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
|
|
381
|
+
var reader = response.body.getReader();
|
|
382
|
+
signal._reader = reader;
|
|
383
|
+
if (signal._aborted) {
|
|
384
|
+
signal._reader.cancel();
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
status: response.status,
|
|
388
|
+
statusText: response.statusText,
|
|
389
|
+
headers: response.headers,
|
|
390
|
+
body: {
|
|
391
|
+
getReader: function () {
|
|
392
|
+
return reader;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
AbortController = function () {
|
|
399
|
+
this.signal = {
|
|
400
|
+
_reader: null,
|
|
401
|
+
_aborted: false
|
|
402
|
+
};
|
|
403
|
+
this.abort = function () {
|
|
404
|
+
if (this.signal._reader != null) {
|
|
405
|
+
this.signal._reader.cancel();
|
|
406
|
+
}
|
|
407
|
+
this.signal._aborted = true;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function TextDecoderPolyfill() {
|
|
413
|
+
this.bitsNeeded = 0;
|
|
414
|
+
this.codePoint = 0;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
TextDecoderPolyfill.prototype.decode = function (octets) {
|
|
418
|
+
function valid(codePoint, shift, octetsCount) {
|
|
419
|
+
if (octetsCount === 1) {
|
|
420
|
+
return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
|
|
421
|
+
}
|
|
422
|
+
if (octetsCount === 2) {
|
|
423
|
+
return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
|
|
424
|
+
}
|
|
425
|
+
if (octetsCount === 3) {
|
|
426
|
+
return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
|
|
427
|
+
}
|
|
428
|
+
throw new Error();
|
|
429
|
+
}
|
|
430
|
+
function octetsCount(bitsNeeded, codePoint) {
|
|
431
|
+
if (bitsNeeded === 6 * 1) {
|
|
432
|
+
return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
|
|
433
|
+
}
|
|
434
|
+
if (bitsNeeded === 6 * 2) {
|
|
435
|
+
return codePoint > 15 ? 3 : 2;
|
|
436
|
+
}
|
|
437
|
+
if (bitsNeeded === 6 * 3) {
|
|
438
|
+
return 3;
|
|
439
|
+
}
|
|
440
|
+
throw new Error();
|
|
441
|
+
}
|
|
442
|
+
var REPLACER = 0xFFFD;
|
|
443
|
+
var string = "";
|
|
444
|
+
var bitsNeeded = this.bitsNeeded;
|
|
445
|
+
var codePoint = this.codePoint;
|
|
446
|
+
for (var i = 0; i < octets.length; i += 1) {
|
|
447
|
+
var octet = octets[i];
|
|
448
|
+
if (bitsNeeded !== 0) {
|
|
449
|
+
if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
|
|
450
|
+
bitsNeeded = 0;
|
|
451
|
+
codePoint = REPLACER;
|
|
452
|
+
string += String.fromCharCode(codePoint);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (bitsNeeded === 0) {
|
|
456
|
+
if (octet >= 0 && octet <= 127) {
|
|
457
|
+
bitsNeeded = 0;
|
|
458
|
+
codePoint = octet;
|
|
459
|
+
} else if (octet >= 192 && octet <= 223) {
|
|
460
|
+
bitsNeeded = 6 * 1;
|
|
461
|
+
codePoint = octet & 31;
|
|
462
|
+
} else if (octet >= 224 && octet <= 239) {
|
|
463
|
+
bitsNeeded = 6 * 2;
|
|
464
|
+
codePoint = octet & 15;
|
|
465
|
+
} else if (octet >= 240 && octet <= 247) {
|
|
466
|
+
bitsNeeded = 6 * 3;
|
|
467
|
+
codePoint = octet & 7;
|
|
468
|
+
} else {
|
|
469
|
+
bitsNeeded = 0;
|
|
470
|
+
codePoint = REPLACER;
|
|
471
|
+
}
|
|
472
|
+
if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
|
|
473
|
+
bitsNeeded = 0;
|
|
474
|
+
codePoint = REPLACER;
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
bitsNeeded -= 6;
|
|
478
|
+
codePoint = codePoint << 6 | octet & 63;
|
|
479
|
+
}
|
|
480
|
+
if (bitsNeeded === 0) {
|
|
481
|
+
if (codePoint <= 0xFFFF) {
|
|
482
|
+
string += String.fromCharCode(codePoint);
|
|
483
|
+
} else {
|
|
484
|
+
string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
|
|
485
|
+
string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
this.bitsNeeded = bitsNeeded;
|
|
490
|
+
this.codePoint = codePoint;
|
|
491
|
+
return string;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// Firefox < 38 throws an error with stream option
|
|
495
|
+
var supportsStreamOption = function () {
|
|
496
|
+
try {
|
|
497
|
+
return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
|
|
498
|
+
} catch (error) {
|
|
499
|
+
console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
|
|
500
|
+
}
|
|
501
|
+
return false;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// IE, Edge
|
|
505
|
+
if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
|
|
506
|
+
TextDecoder = TextDecoderPolyfill;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
var k = function () {
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
function XHRWrapper(xhr) {
|
|
513
|
+
this.withCredentials = false;
|
|
514
|
+
this.readyState = 0;
|
|
515
|
+
this.status = 0;
|
|
516
|
+
this.statusText = "";
|
|
517
|
+
this.responseText = "";
|
|
518
|
+
this.onprogress = k;
|
|
519
|
+
this.onload = k;
|
|
520
|
+
this.onerror = k;
|
|
521
|
+
this.onreadystatechange = k;
|
|
522
|
+
this._contentType = "";
|
|
523
|
+
this._xhr = xhr;
|
|
524
|
+
this._sendTimeout = 0;
|
|
525
|
+
this._abort = k;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
XHRWrapper.prototype.open = function (method, url) {
|
|
529
|
+
this._abort(true);
|
|
530
|
+
|
|
531
|
+
var that = this;
|
|
532
|
+
var xhr = this._xhr;
|
|
533
|
+
var state = 1;
|
|
534
|
+
var timeout = 0;
|
|
535
|
+
|
|
536
|
+
this._abort = function (silent) {
|
|
537
|
+
if (that._sendTimeout !== 0) {
|
|
538
|
+
clearTimeout(that._sendTimeout);
|
|
539
|
+
that._sendTimeout = 0;
|
|
540
|
+
}
|
|
541
|
+
if (state === 1 || state === 2 || state === 3) {
|
|
542
|
+
state = 4;
|
|
543
|
+
xhr.onload = k;
|
|
544
|
+
xhr.onerror = k;
|
|
545
|
+
xhr.onabort = k;
|
|
546
|
+
xhr.onprogress = k;
|
|
547
|
+
xhr.onreadystatechange = k;
|
|
548
|
+
// IE 8 - 9: XDomainRequest#abort() does not fire any event
|
|
549
|
+
// Opera < 10: XMLHttpRequest#abort() does not fire any event
|
|
550
|
+
xhr.abort();
|
|
551
|
+
if (timeout !== 0) {
|
|
552
|
+
clearTimeout(timeout);
|
|
553
|
+
timeout = 0;
|
|
554
|
+
}
|
|
555
|
+
if (!silent) {
|
|
556
|
+
that.readyState = 4;
|
|
557
|
+
that.onabort(null);
|
|
558
|
+
that.onreadystatechange();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
state = 0;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
var onStart = function () {
|
|
565
|
+
if (state === 1) {
|
|
566
|
+
//state = 2;
|
|
567
|
+
var status = 0;
|
|
568
|
+
var statusText = "";
|
|
569
|
+
var contentType = undefined;
|
|
570
|
+
if (!("contentType" in xhr)) {
|
|
571
|
+
try {
|
|
572
|
+
status = xhr.status;
|
|
573
|
+
statusText = xhr.statusText;
|
|
574
|
+
contentType = xhr.getResponseHeader("Content-Type");
|
|
575
|
+
} catch (error) {
|
|
576
|
+
// IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
|
|
577
|
+
// Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
|
|
578
|
+
// https://bugs.webkit.org/show_bug.cgi?id=29121
|
|
579
|
+
status = 0;
|
|
580
|
+
statusText = "";
|
|
581
|
+
contentType = undefined;
|
|
582
|
+
// Firefox < 14, Chrome ?, Safari ?
|
|
583
|
+
// https://bugs.webkit.org/show_bug.cgi?id=29658
|
|
584
|
+
// https://bugs.webkit.org/show_bug.cgi?id=77854
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
status = 200;
|
|
588
|
+
statusText = "OK";
|
|
589
|
+
contentType = xhr.contentType;
|
|
590
|
+
}
|
|
591
|
+
if (status !== 0) {
|
|
592
|
+
state = 2;
|
|
593
|
+
that.readyState = 2;
|
|
594
|
+
that.status = status;
|
|
595
|
+
that.statusText = statusText;
|
|
596
|
+
that._contentType = contentType;
|
|
597
|
+
that.onreadystatechange();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
var onProgress = function () {
|
|
602
|
+
onStart();
|
|
603
|
+
if (state === 2 || state === 3) {
|
|
604
|
+
state = 3;
|
|
605
|
+
var responseText = "";
|
|
606
|
+
try {
|
|
607
|
+
responseText = xhr.responseText;
|
|
608
|
+
} catch (error) {
|
|
609
|
+
// IE 8 - 9 with XMLHttpRequest
|
|
610
|
+
}
|
|
611
|
+
that.readyState = 3;
|
|
612
|
+
that.responseText = responseText;
|
|
613
|
+
that.onprogress();
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
var onFinish = function (type, event) {
|
|
617
|
+
if (event == null || event.preventDefault == null) {
|
|
618
|
+
event = {
|
|
619
|
+
preventDefault: k
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
// Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
|
|
623
|
+
// IE 8 fires "onload" without "onprogress"
|
|
624
|
+
onProgress();
|
|
625
|
+
if (state === 1 || state === 2 || state === 3) {
|
|
626
|
+
state = 4;
|
|
627
|
+
if (timeout !== 0) {
|
|
628
|
+
clearTimeout(timeout);
|
|
629
|
+
timeout = 0;
|
|
630
|
+
}
|
|
631
|
+
that.readyState = 4;
|
|
632
|
+
if (type === "load") {
|
|
633
|
+
that.onload(event);
|
|
634
|
+
} else if (type === "error") {
|
|
635
|
+
that.onerror(event);
|
|
636
|
+
} else if (type === "abort") {
|
|
637
|
+
that.onabort(event);
|
|
638
|
+
} else {
|
|
639
|
+
throw new TypeError();
|
|
640
|
+
}
|
|
641
|
+
that.onreadystatechange();
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
var onReadyStateChange = function (event) {
|
|
645
|
+
if (xhr != undefined) { // Opera 12
|
|
646
|
+
if (xhr.readyState === 4) {
|
|
647
|
+
if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
|
|
648
|
+
onFinish(xhr.responseText === "" ? "error" : "load", event);
|
|
649
|
+
}
|
|
650
|
+
} else if (xhr.readyState === 3) {
|
|
651
|
+
if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
|
|
652
|
+
// and in Firefox 3.6
|
|
653
|
+
onProgress();
|
|
654
|
+
}
|
|
655
|
+
} else if (xhr.readyState === 2) {
|
|
656
|
+
onStart();
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
var onTimeout = function () {
|
|
661
|
+
timeout = setTimeout(function () {
|
|
662
|
+
onTimeout();
|
|
663
|
+
}, 500);
|
|
664
|
+
if (xhr.readyState === 3) {
|
|
665
|
+
onProgress();
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
// XDomainRequest#abort removes onprogress, onerror, onload
|
|
670
|
+
if ("onload" in xhr) {
|
|
671
|
+
xhr.onload = function (event) {
|
|
672
|
+
onFinish("load", event);
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
if ("onerror" in xhr) {
|
|
676
|
+
xhr.onerror = function (event) {
|
|
677
|
+
onFinish("error", event);
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
// improper fix to match Firefox behaviour, but it is better than just ignore abort
|
|
681
|
+
// see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
|
|
682
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=880200
|
|
683
|
+
// https://code.google.com/p/chromium/issues/detail?id=153570
|
|
684
|
+
// IE 8 fires "onload" without "onprogress
|
|
685
|
+
if ("onabort" in xhr) {
|
|
686
|
+
xhr.onabort = function (event) {
|
|
687
|
+
onFinish("abort", event);
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if ("onprogress" in xhr) {
|
|
692
|
+
xhr.onprogress = onProgress;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// IE 8 - 9 (XMLHTTPRequest)
|
|
696
|
+
// Opera < 12
|
|
697
|
+
// Firefox < 3.5
|
|
698
|
+
// Firefox 3.5 - 3.6 - ? < 9.0
|
|
699
|
+
// onprogress is not fired sometimes or delayed
|
|
700
|
+
// see also #64 (significant lag in IE 11)
|
|
701
|
+
if ("onreadystatechange" in xhr) {
|
|
702
|
+
xhr.onreadystatechange = function (event) {
|
|
703
|
+
onReadyStateChange(event);
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
|
|
708
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
|
|
709
|
+
}
|
|
710
|
+
xhr.open(method, url, true);
|
|
711
|
+
|
|
712
|
+
if ("readyState" in xhr) {
|
|
713
|
+
// workaround for Opera 12 issue with "progress" events
|
|
714
|
+
// #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
|
|
715
|
+
timeout = setTimeout(function () {
|
|
716
|
+
onTimeout();
|
|
717
|
+
}, 0);
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
XHRWrapper.prototype.abort = function () {
|
|
721
|
+
this._abort(false);
|
|
722
|
+
};
|
|
723
|
+
XHRWrapper.prototype.getResponseHeader = function (name) {
|
|
724
|
+
return this._contentType;
|
|
725
|
+
};
|
|
726
|
+
XHRWrapper.prototype.setRequestHeader = function (name, value) {
|
|
727
|
+
var xhr = this._xhr;
|
|
728
|
+
if ("setRequestHeader" in xhr) {
|
|
729
|
+
xhr.setRequestHeader(name, value);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
XHRWrapper.prototype.getAllResponseHeaders = function () {
|
|
733
|
+
// XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
|
|
734
|
+
return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
|
|
735
|
+
};
|
|
736
|
+
XHRWrapper.prototype.send = function () {
|
|
737
|
+
// loading indicator in Safari < ? (6), Chrome < 14, Firefox
|
|
738
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=736723
|
|
739
|
+
if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
|
|
740
|
+
document != undefined &&
|
|
741
|
+
document.readyState != undefined &&
|
|
742
|
+
document.readyState !== "complete") {
|
|
743
|
+
var that = this;
|
|
744
|
+
that._sendTimeout = setTimeout(function () {
|
|
745
|
+
that._sendTimeout = 0;
|
|
746
|
+
that.send();
|
|
747
|
+
}, 4);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
var xhr = this._xhr;
|
|
752
|
+
// withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
|
|
753
|
+
if ("withCredentials" in xhr) {
|
|
754
|
+
xhr.withCredentials = this.withCredentials;
|
|
755
|
+
}
|
|
756
|
+
try {
|
|
757
|
+
// xhr.send(); throws "Not enough arguments" in Firefox 3.0
|
|
758
|
+
xhr.send(undefined);
|
|
759
|
+
} catch (error1) {
|
|
760
|
+
// Safari 5.1.7, Opera 12
|
|
761
|
+
throw error1;
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
function toLowerCase(name) {
|
|
766
|
+
return name.replace(/[A-Z]/g, function (c) {
|
|
767
|
+
return String.fromCharCode(c.charCodeAt(0) + 0x20);
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function HeadersPolyfill(all) {
|
|
772
|
+
// Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
|
|
773
|
+
var map = Object.create(null);
|
|
774
|
+
var array = all.split("\r\n");
|
|
775
|
+
for (var i = 0; i < array.length; i += 1) {
|
|
776
|
+
var line = array[i];
|
|
777
|
+
var parts = line.split(": ");
|
|
778
|
+
var name = parts.shift();
|
|
779
|
+
var value = parts.join(": ");
|
|
780
|
+
map[toLowerCase(name)] = value;
|
|
781
|
+
}
|
|
782
|
+
this._map = map;
|
|
783
|
+
}
|
|
784
|
+
HeadersPolyfill.prototype.get = function (name) {
|
|
785
|
+
return this._map[toLowerCase(name)];
|
|
786
|
+
};
|
|
787
|
+
|
|
788
|
+
if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
|
|
789
|
+
XMLHttpRequest.HEADERS_RECEIVED = 2;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
function XHRTransport() {
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
796
|
+
xhr.open("GET", url);
|
|
797
|
+
var offset = 0;
|
|
798
|
+
xhr.onprogress = function () {
|
|
799
|
+
var responseText = xhr.responseText;
|
|
800
|
+
var chunk = responseText.slice(offset);
|
|
801
|
+
offset += chunk.length;
|
|
802
|
+
onProgressCallback(chunk);
|
|
803
|
+
};
|
|
804
|
+
xhr.onerror = function (event) {
|
|
805
|
+
event.preventDefault();
|
|
806
|
+
onFinishCallback(new Error("NetworkError"));
|
|
807
|
+
};
|
|
808
|
+
xhr.onload = function () {
|
|
809
|
+
onFinishCallback(null);
|
|
810
|
+
};
|
|
811
|
+
xhr.onabort = function () {
|
|
812
|
+
onFinishCallback(null);
|
|
813
|
+
};
|
|
814
|
+
xhr.onreadystatechange = function () {
|
|
815
|
+
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
816
|
+
var status = xhr.status;
|
|
817
|
+
var statusText = xhr.statusText;
|
|
818
|
+
var contentType = xhr.getResponseHeader("Content-Type");
|
|
819
|
+
var headers = xhr.getAllResponseHeaders();
|
|
820
|
+
onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
xhr.withCredentials = withCredentials;
|
|
824
|
+
for (var name in headers) {
|
|
825
|
+
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
826
|
+
xhr.setRequestHeader(name, headers[name]);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
xhr.send();
|
|
830
|
+
return xhr;
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
function HeadersWrapper(headers) {
|
|
834
|
+
this._headers = headers;
|
|
835
|
+
}
|
|
836
|
+
HeadersWrapper.prototype.get = function (name) {
|
|
837
|
+
return this._headers.get(name);
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
function FetchTransport() {
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
844
|
+
var reader = null;
|
|
845
|
+
var controller = new AbortController();
|
|
846
|
+
var signal = controller.signal;
|
|
847
|
+
var textDecoder = new TextDecoder();
|
|
848
|
+
fetch(url, {
|
|
849
|
+
headers: headers,
|
|
850
|
+
credentials: withCredentials ? "include" : "same-origin",
|
|
851
|
+
signal: signal,
|
|
852
|
+
cache: "no-store"
|
|
853
|
+
}).then(function (response) {
|
|
854
|
+
reader = response.body.getReader();
|
|
855
|
+
onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
|
|
856
|
+
// see https://github.com/promises-aplus/promises-spec/issues/179
|
|
857
|
+
return new Promise(function (resolve, reject) {
|
|
858
|
+
var readNextChunk = function () {
|
|
859
|
+
reader.read().then(function (result) {
|
|
860
|
+
if (result.done) {
|
|
861
|
+
//Note: bytes in textDecoder are ignored
|
|
862
|
+
resolve(undefined);
|
|
863
|
+
} else {
|
|
864
|
+
var chunk = textDecoder.decode(result.value, {stream: true});
|
|
865
|
+
onProgressCallback(chunk);
|
|
866
|
+
readNextChunk();
|
|
867
|
+
}
|
|
868
|
+
})["catch"](function (error) {
|
|
869
|
+
reject(error);
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
readNextChunk();
|
|
873
|
+
});
|
|
874
|
+
})["catch"](function (error) {
|
|
875
|
+
if (error.name === "AbortError") {
|
|
876
|
+
return undefined;
|
|
877
|
+
} else {
|
|
878
|
+
return error;
|
|
879
|
+
}
|
|
880
|
+
}).then(function (error) {
|
|
881
|
+
onFinishCallback(error);
|
|
882
|
+
});
|
|
883
|
+
return {
|
|
884
|
+
abort: function () {
|
|
885
|
+
if (reader != null) {
|
|
886
|
+
reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
|
|
887
|
+
}
|
|
888
|
+
controller.abort();
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
function EventTarget() {
|
|
894
|
+
this._listeners = Object.create(null);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function throwError(e) {
|
|
898
|
+
setTimeout(function () {
|
|
899
|
+
throw e;
|
|
900
|
+
}, 0);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
EventTarget.prototype.dispatchEvent = function (event) {
|
|
904
|
+
event.target = this;
|
|
905
|
+
var typeListeners = this._listeners[event.type];
|
|
906
|
+
if (typeListeners != undefined) {
|
|
907
|
+
var length = typeListeners.length;
|
|
908
|
+
for (var i = 0; i < length; i += 1) {
|
|
909
|
+
var listener = typeListeners[i];
|
|
910
|
+
try {
|
|
911
|
+
if (typeof listener.handleEvent === "function") {
|
|
912
|
+
listener.handleEvent(event);
|
|
913
|
+
} else {
|
|
914
|
+
listener.call(this, event);
|
|
915
|
+
}
|
|
916
|
+
} catch (e) {
|
|
917
|
+
throwError(e);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
EventTarget.prototype.addEventListener = function (type, listener) {
|
|
923
|
+
type = String(type);
|
|
924
|
+
var listeners = this._listeners;
|
|
925
|
+
var typeListeners = listeners[type];
|
|
926
|
+
if (typeListeners == undefined) {
|
|
927
|
+
typeListeners = [];
|
|
928
|
+
listeners[type] = typeListeners;
|
|
929
|
+
}
|
|
930
|
+
var found = false;
|
|
931
|
+
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
932
|
+
if (typeListeners[i] === listener) {
|
|
933
|
+
found = true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
if (!found) {
|
|
937
|
+
typeListeners.push(listener);
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
EventTarget.prototype.removeEventListener = function (type, listener) {
|
|
941
|
+
type = String(type);
|
|
942
|
+
var listeners = this._listeners;
|
|
943
|
+
var typeListeners = listeners[type];
|
|
944
|
+
if (typeListeners != undefined) {
|
|
945
|
+
var filtered = [];
|
|
946
|
+
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
947
|
+
if (typeListeners[i] !== listener) {
|
|
948
|
+
filtered.push(typeListeners[i]);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
if (filtered.length === 0) {
|
|
952
|
+
delete listeners[type];
|
|
953
|
+
} else {
|
|
954
|
+
listeners[type] = filtered;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
function Event(type) {
|
|
960
|
+
this.type = type;
|
|
961
|
+
this.target = undefined;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function MessageEvent(type, options) {
|
|
965
|
+
Event.call(this, type);
|
|
966
|
+
this.data = options.data;
|
|
967
|
+
this.lastEventId = options.lastEventId;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
MessageEvent.prototype = Object.create(Event.prototype);
|
|
971
|
+
|
|
972
|
+
function ConnectionEvent(type, options) {
|
|
973
|
+
Event.call(this, type);
|
|
974
|
+
this.status = options.status;
|
|
975
|
+
this.statusText = options.statusText;
|
|
976
|
+
this.headers = options.headers;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
ConnectionEvent.prototype = Object.create(Event.prototype);
|
|
980
|
+
|
|
981
|
+
function ErrorEvent(type, options) {
|
|
982
|
+
Event.call(this, type);
|
|
983
|
+
this.error = options.error;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
ErrorEvent.prototype = Object.create(Event.prototype);
|
|
987
|
+
|
|
988
|
+
var WAITING = -1;
|
|
989
|
+
var CONNECTING = 0;
|
|
990
|
+
var OPEN = 1;
|
|
991
|
+
var CLOSED = 2;
|
|
992
|
+
|
|
993
|
+
var AFTER_CR = -1;
|
|
994
|
+
var FIELD_START = 0;
|
|
995
|
+
var FIELD = 1;
|
|
996
|
+
var VALUE_START = 2;
|
|
997
|
+
var VALUE = 3;
|
|
998
|
+
|
|
999
|
+
var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
|
|
1000
|
+
|
|
1001
|
+
var MINIMUM_DURATION = 1000;
|
|
1002
|
+
var MAXIMUM_DURATION = 18000000;
|
|
1003
|
+
|
|
1004
|
+
var parseDuration = function (value, def) {
|
|
1005
|
+
var n = value == null ? def : parseInt(value, 10);
|
|
1006
|
+
if (n !== n) {
|
|
1007
|
+
n = def;
|
|
1008
|
+
}
|
|
1009
|
+
return clampDuration(n);
|
|
1010
|
+
};
|
|
1011
|
+
var clampDuration = function (n) {
|
|
1012
|
+
return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
var fire = function (that, f, event) {
|
|
1016
|
+
try {
|
|
1017
|
+
if (typeof f === "function") {
|
|
1018
|
+
f.call(that, event);
|
|
1019
|
+
}
|
|
1020
|
+
} catch (e) {
|
|
1021
|
+
throwError(e);
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
function EventSourcePolyfill(url, options) {
|
|
1026
|
+
EventTarget.call(this);
|
|
1027
|
+
options = options || {};
|
|
1028
|
+
|
|
1029
|
+
this.onopen = undefined;
|
|
1030
|
+
this.onmessage = undefined;
|
|
1031
|
+
this.onerror = undefined;
|
|
1032
|
+
|
|
1033
|
+
this.url = undefined;
|
|
1034
|
+
this.readyState = undefined;
|
|
1035
|
+
this.withCredentials = undefined;
|
|
1036
|
+
this.headers = undefined;
|
|
1037
|
+
|
|
1038
|
+
this._close = undefined;
|
|
1039
|
+
|
|
1040
|
+
start(this, url, options);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
function getBestXHRTransport() {
|
|
1044
|
+
return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
|
|
1045
|
+
? new XMLHttpRequest()
|
|
1046
|
+
: new XDomainRequest();
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
|
|
1050
|
+
|
|
1051
|
+
function start(es, url, options) {
|
|
1052
|
+
url = String(url);
|
|
1053
|
+
var withCredentials = Boolean(options.withCredentials);
|
|
1054
|
+
var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
|
|
1055
|
+
|
|
1056
|
+
var initialRetry = clampDuration(1000);
|
|
1057
|
+
var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
|
|
1058
|
+
|
|
1059
|
+
var lastEventId = "";
|
|
1060
|
+
var retry = initialRetry;
|
|
1061
|
+
var wasActivity = false;
|
|
1062
|
+
var textLength = 0;
|
|
1063
|
+
var headers = options.headers || {};
|
|
1064
|
+
var TransportOption = options.Transport;
|
|
1065
|
+
var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
|
|
1066
|
+
var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
|
|
1067
|
+
var abortController = undefined;
|
|
1068
|
+
var timeout = 0;
|
|
1069
|
+
var currentState = WAITING;
|
|
1070
|
+
var dataBuffer = "";
|
|
1071
|
+
var lastEventIdBuffer = "";
|
|
1072
|
+
var eventTypeBuffer = "";
|
|
1073
|
+
|
|
1074
|
+
var textBuffer = "";
|
|
1075
|
+
var state = FIELD_START;
|
|
1076
|
+
var fieldStart = 0;
|
|
1077
|
+
var valueStart = 0;
|
|
1078
|
+
|
|
1079
|
+
var onStart = function (status, statusText, contentType, headers) {
|
|
1080
|
+
if (currentState === CONNECTING) {
|
|
1081
|
+
if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
|
|
1082
|
+
currentState = OPEN;
|
|
1083
|
+
wasActivity = Date.now();
|
|
1084
|
+
retry = initialRetry;
|
|
1085
|
+
es.readyState = OPEN;
|
|
1086
|
+
var event = new ConnectionEvent("open", {
|
|
1087
|
+
status: status,
|
|
1088
|
+
statusText: statusText,
|
|
1089
|
+
headers: headers
|
|
1090
|
+
});
|
|
1091
|
+
es.dispatchEvent(event);
|
|
1092
|
+
fire(es, es.onopen, event);
|
|
1093
|
+
} else {
|
|
1094
|
+
var message = "";
|
|
1095
|
+
if (status !== 200) {
|
|
1096
|
+
if (statusText) {
|
|
1097
|
+
statusText = statusText.replace(/\s+/g, " ");
|
|
1098
|
+
}
|
|
1099
|
+
message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
|
|
1100
|
+
} else {
|
|
1101
|
+
message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
|
|
1102
|
+
}
|
|
1103
|
+
close();
|
|
1104
|
+
var event = new ConnectionEvent("error", {
|
|
1105
|
+
status: status,
|
|
1106
|
+
statusText: statusText,
|
|
1107
|
+
headers: headers
|
|
1108
|
+
});
|
|
1109
|
+
es.dispatchEvent(event);
|
|
1110
|
+
fire(es, es.onerror, event);
|
|
1111
|
+
console.error(message);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
var onProgress = function (textChunk) {
|
|
1117
|
+
if (currentState === OPEN) {
|
|
1118
|
+
var n = -1;
|
|
1119
|
+
for (var i = 0; i < textChunk.length; i += 1) {
|
|
1120
|
+
var c = textChunk.charCodeAt(i);
|
|
1121
|
+
if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
|
|
1122
|
+
n = i;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
|
|
1126
|
+
textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
|
|
1127
|
+
if (textChunk !== "") {
|
|
1128
|
+
wasActivity = Date.now();
|
|
1129
|
+
textLength += textChunk.length;
|
|
1130
|
+
}
|
|
1131
|
+
for (var position = 0; position < chunk.length; position += 1) {
|
|
1132
|
+
var c = chunk.charCodeAt(position);
|
|
1133
|
+
if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
|
|
1134
|
+
state = FIELD_START;
|
|
1135
|
+
} else {
|
|
1136
|
+
if (state === AFTER_CR) {
|
|
1137
|
+
state = FIELD_START;
|
|
1138
|
+
}
|
|
1139
|
+
if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
|
|
1140
|
+
if (state !== FIELD_START) {
|
|
1141
|
+
if (state === FIELD) {
|
|
1142
|
+
valueStart = position + 1;
|
|
1143
|
+
}
|
|
1144
|
+
var field = chunk.slice(fieldStart, valueStart - 1);
|
|
1145
|
+
var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
|
|
1146
|
+
if (field === "data") {
|
|
1147
|
+
dataBuffer += "\n";
|
|
1148
|
+
dataBuffer += value;
|
|
1149
|
+
} else if (field === "id") {
|
|
1150
|
+
lastEventIdBuffer = value;
|
|
1151
|
+
} else if (field === "event") {
|
|
1152
|
+
eventTypeBuffer = value;
|
|
1153
|
+
} else if (field === "retry") {
|
|
1154
|
+
initialRetry = parseDuration(value, initialRetry);
|
|
1155
|
+
retry = initialRetry;
|
|
1156
|
+
} else if (field === "heartbeatTimeout") {
|
|
1157
|
+
heartbeatTimeout = parseDuration(value, heartbeatTimeout);
|
|
1158
|
+
if (timeout !== 0) {
|
|
1159
|
+
clearTimeout(timeout);
|
|
1160
|
+
timeout = setTimeout(function () {
|
|
1161
|
+
onTimeout();
|
|
1162
|
+
}, heartbeatTimeout);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (state === FIELD_START) {
|
|
1167
|
+
if (dataBuffer !== "") {
|
|
1168
|
+
lastEventId = lastEventIdBuffer;
|
|
1169
|
+
if (eventTypeBuffer === "") {
|
|
1170
|
+
eventTypeBuffer = "message";
|
|
1171
|
+
}
|
|
1172
|
+
var event = new MessageEvent(eventTypeBuffer, {
|
|
1173
|
+
data: dataBuffer.slice(1),
|
|
1174
|
+
lastEventId: lastEventIdBuffer
|
|
1175
|
+
});
|
|
1176
|
+
es.dispatchEvent(event);
|
|
1177
|
+
if (eventTypeBuffer === "open") {
|
|
1178
|
+
fire(es, es.onopen, event);
|
|
1179
|
+
} else if (eventTypeBuffer === "message") {
|
|
1180
|
+
fire(es, es.onmessage, event);
|
|
1181
|
+
} else if (eventTypeBuffer === "error") {
|
|
1182
|
+
fire(es, es.onerror, event);
|
|
1183
|
+
}
|
|
1184
|
+
if (currentState === CLOSED) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
dataBuffer = "";
|
|
1189
|
+
eventTypeBuffer = "";
|
|
1190
|
+
}
|
|
1191
|
+
state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
|
|
1192
|
+
} else {
|
|
1193
|
+
if (state === FIELD_START) {
|
|
1194
|
+
fieldStart = position;
|
|
1195
|
+
state = FIELD;
|
|
1196
|
+
}
|
|
1197
|
+
if (state === FIELD) {
|
|
1198
|
+
if (c === ":".charCodeAt(0)) {
|
|
1199
|
+
valueStart = position + 1;
|
|
1200
|
+
state = VALUE_START;
|
|
1201
|
+
}
|
|
1202
|
+
} else if (state === VALUE_START) {
|
|
1203
|
+
state = VALUE;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
var onFinish = function (error) {
|
|
1212
|
+
if (currentState === OPEN || currentState === CONNECTING) {
|
|
1213
|
+
currentState = WAITING;
|
|
1214
|
+
if (timeout !== 0) {
|
|
1215
|
+
clearTimeout(timeout);
|
|
1216
|
+
timeout = 0;
|
|
1217
|
+
}
|
|
1218
|
+
timeout = setTimeout(function () {
|
|
1219
|
+
onTimeout();
|
|
1220
|
+
}, retry);
|
|
1221
|
+
retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
|
|
1222
|
+
|
|
1223
|
+
es.readyState = CONNECTING;
|
|
1224
|
+
var event = new ErrorEvent("error", {error: error});
|
|
1225
|
+
es.dispatchEvent(event);
|
|
1226
|
+
fire(es, es.onerror, event);
|
|
1227
|
+
if (error != undefined) {
|
|
1228
|
+
console.error(error);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
var close = function () {
|
|
1234
|
+
currentState = CLOSED;
|
|
1235
|
+
if (abortController != undefined) {
|
|
1236
|
+
abortController.abort();
|
|
1237
|
+
abortController = undefined;
|
|
1238
|
+
}
|
|
1239
|
+
if (timeout !== 0) {
|
|
1240
|
+
clearTimeout(timeout);
|
|
1241
|
+
timeout = 0;
|
|
1242
|
+
}
|
|
1243
|
+
es.readyState = CLOSED;
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
var onTimeout = function () {
|
|
1247
|
+
timeout = 0;
|
|
1248
|
+
|
|
1249
|
+
if (currentState !== WAITING) {
|
|
1250
|
+
if (!wasActivity && abortController != undefined) {
|
|
1251
|
+
onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
|
|
1252
|
+
if (abortController != undefined) {
|
|
1253
|
+
abortController.abort();
|
|
1254
|
+
abortController = undefined;
|
|
1255
|
+
}
|
|
1256
|
+
} else {
|
|
1257
|
+
var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
|
|
1258
|
+
wasActivity = false;
|
|
1259
|
+
timeout = setTimeout(function () {
|
|
1260
|
+
onTimeout();
|
|
1261
|
+
}, nextHeartbeat);
|
|
1262
|
+
}
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
wasActivity = false;
|
|
1267
|
+
textLength = 0;
|
|
1268
|
+
timeout = setTimeout(function () {
|
|
1269
|
+
onTimeout();
|
|
1270
|
+
}, heartbeatTimeout);
|
|
1271
|
+
|
|
1272
|
+
currentState = CONNECTING;
|
|
1273
|
+
dataBuffer = "";
|
|
1274
|
+
eventTypeBuffer = "";
|
|
1275
|
+
lastEventIdBuffer = lastEventId;
|
|
1276
|
+
textBuffer = "";
|
|
1277
|
+
fieldStart = 0;
|
|
1278
|
+
valueStart = 0;
|
|
1279
|
+
state = FIELD_START;
|
|
1280
|
+
|
|
1281
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=428916
|
|
1282
|
+
// Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
|
|
1283
|
+
var requestURL = url;
|
|
1284
|
+
if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
|
|
1285
|
+
if (lastEventId !== "") {
|
|
1286
|
+
// Remove the lastEventId parameter if it's already part of the request URL.
|
|
1287
|
+
var i = url.indexOf("?");
|
|
1288
|
+
requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
|
|
1289
|
+
return paramName === lastEventIdQueryParameterName ? '' : p;
|
|
1290
|
+
});
|
|
1291
|
+
// Append the current lastEventId to the request URL.
|
|
1292
|
+
requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
var withCredentials = es.withCredentials;
|
|
1296
|
+
var requestHeaders = {};
|
|
1297
|
+
requestHeaders["Accept"] = "text/event-stream";
|
|
1298
|
+
var headers = es.headers;
|
|
1299
|
+
if (headers != undefined) {
|
|
1300
|
+
for (var name in headers) {
|
|
1301
|
+
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
1302
|
+
requestHeaders[name] = headers[name];
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
try {
|
|
1307
|
+
abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
close();
|
|
1310
|
+
throw error;
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
es.url = url;
|
|
1315
|
+
es.readyState = CONNECTING;
|
|
1316
|
+
es.withCredentials = withCredentials;
|
|
1317
|
+
es.headers = headers;
|
|
1318
|
+
es._close = close;
|
|
1319
|
+
|
|
1320
|
+
onTimeout();
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
|
|
1324
|
+
EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
|
|
1325
|
+
EventSourcePolyfill.prototype.OPEN = OPEN;
|
|
1326
|
+
EventSourcePolyfill.prototype.CLOSED = CLOSED;
|
|
1327
|
+
EventSourcePolyfill.prototype.close = function () {
|
|
1328
|
+
this._close();
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
EventSourcePolyfill.CONNECTING = CONNECTING;
|
|
1332
|
+
EventSourcePolyfill.OPEN = OPEN;
|
|
1333
|
+
EventSourcePolyfill.CLOSED = CLOSED;
|
|
1334
|
+
EventSourcePolyfill.prototype.withCredentials = undefined;
|
|
1335
|
+
|
|
1336
|
+
var R = NativeEventSource;
|
|
1337
|
+
if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
|
|
1338
|
+
// Why replace a native EventSource ?
|
|
1339
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=444328
|
|
1340
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=831392
|
|
1341
|
+
// https://code.google.com/p/chromium/issues/detail?id=260144
|
|
1342
|
+
// https://code.google.com/p/chromium/issues/detail?id=225654
|
|
1343
|
+
// ...
|
|
1344
|
+
R = EventSourcePolyfill;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
(function (factory) {
|
|
1348
|
+
{
|
|
1349
|
+
var v = factory(exports);
|
|
1350
|
+
if (v !== undefined) module.exports = v;
|
|
1351
|
+
}
|
|
1352
|
+
})(function (exports) {
|
|
1353
|
+
exports.EventSourcePolyfill = EventSourcePolyfill;
|
|
1354
|
+
exports.NativeEventSource = NativeEventSource;
|
|
1355
|
+
exports.EventSource = R;
|
|
1356
|
+
});
|
|
1357
|
+
}(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : commonjsGlobal) : globalThis));
|
|
1358
|
+
}(eventsource, eventsource.exports));
|
|
1359
|
+
|
|
312
1360
|
var EChallengeLevelTargetType;
|
|
313
1361
|
(function (EChallengeLevelTargetType) {
|
|
314
1362
|
EChallengeLevelTargetType[EChallengeLevelTargetType["Accumulative"] = 0] = "Accumulative";
|
|
@@ -538,6 +1586,21 @@ const CasinoChallengeDetails = class {
|
|
|
538
1586
|
this.challenge = undefined;
|
|
539
1587
|
this.loading = false;
|
|
540
1588
|
this.isChallengePaused = false;
|
|
1589
|
+
this.sseConnection = undefined;
|
|
1590
|
+
}
|
|
1591
|
+
connectGameToLiveLobby() {
|
|
1592
|
+
if (EventSource && !this.sseConnection) {
|
|
1593
|
+
const updateUrl = `${this.endpoint}/v1/encoder/challenges/*/update`;
|
|
1594
|
+
this.sseConnection = new eventsource.exports.EventSourcePolyfill(updateUrl);
|
|
1595
|
+
this.sseConnection.addEventListener('message', this.handleEvent);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
disconnectGameFromLiveLobby() {
|
|
1599
|
+
if (this.sseConnection) {
|
|
1600
|
+
this.sseConnection.removeEventListener('message');
|
|
1601
|
+
this.sseConnection.close();
|
|
1602
|
+
this.sseConnection = undefined;
|
|
1603
|
+
}
|
|
541
1604
|
}
|
|
542
1605
|
handleEvent(e) {
|
|
543
1606
|
const { data } = e === null || e === void 0 ? void 0 : e.data;
|
|
@@ -660,6 +1723,7 @@ const CasinoChallengeDetails = class {
|
|
|
660
1723
|
if (this.translationUrl) {
|
|
661
1724
|
resolveTranslationUrl(this.translationUrl);
|
|
662
1725
|
}
|
|
1726
|
+
this.connectGameToLiveLobby();
|
|
663
1727
|
this.updateTime();
|
|
664
1728
|
}
|
|
665
1729
|
componentDidLoad() {
|
|
@@ -683,6 +1747,7 @@ const CasinoChallengeDetails = class {
|
|
|
683
1747
|
this.stylingSubscription.unsubscribe();
|
|
684
1748
|
}
|
|
685
1749
|
clearInterval(this.timerId);
|
|
1750
|
+
this.disconnectGameFromLiveLobby();
|
|
686
1751
|
window.removeEventListener('resize', this.checkIsMobile);
|
|
687
1752
|
}
|
|
688
1753
|
getReward(level) {
|
|
@@ -780,7 +1845,7 @@ const CasinoChallengeDetails = class {
|
|
|
780
1845
|
getLevelStatus(level, active) {
|
|
781
1846
|
if (this.isUserAuthorized) {
|
|
782
1847
|
if (level.ProgressStatus === EChallengeProgressLevelStatus.InProgress && !active)
|
|
783
|
-
return (h("div", { class: "level__status" }, h("span", null, level.ProgressPercentage, "%"), h("img", { src: lockSvg, alt: "lock-icon", title: "lock-icon" })));
|
|
1848
|
+
return (h("div", { class: "level__status" }, h("span", null, Math.floor(level.ProgressPercentage), "%"), h("img", { src: lockSvg, alt: "lock-icon", title: "lock-icon" })));
|
|
784
1849
|
else if (level.ProgressStatus === EChallengeProgressLevelStatus.Closed || !active)
|
|
785
1850
|
return (h("div", { class: "level__status" }, h("img", { src: lockSvg, alt: "lock-icon", title: "lock-icon" })));
|
|
786
1851
|
else if (level.ProgressStatus === EChallengeProgressLevelStatus.Fillup)
|
|
@@ -788,7 +1853,7 @@ const CasinoChallengeDetails = class {
|
|
|
788
1853
|
else if (level.ProgressStatus === EChallengeProgressLevelStatus.Completed)
|
|
789
1854
|
return h("span", { class: "completed" }, translate('completed', this.language));
|
|
790
1855
|
else if (level.ProgressStatus === EChallengeProgressLevelStatus.InProgress)
|
|
791
|
-
return h("span", { class: "level__status in-progress" }, level.ProgressPercentage, "%");
|
|
1856
|
+
return h("span", { class: "level__status in-progress" }, Math.floor(level.ProgressPercentage), "%");
|
|
792
1857
|
}
|
|
793
1858
|
return null;
|
|
794
1859
|
}
|
|
@@ -912,7 +1977,7 @@ const CasinoChallengeDetails = class {
|
|
|
912
1977
|
return (((_a = this.challenge) === null || _a === void 0 ? void 0 : _a.Status) === 4 && (h("div", { class: "notification" }, h("img", { class: "notification__icon", src: infoCircleSvg }), h("span", { class: "notification__message" }, translate('expiredNotification', this.language)))));
|
|
913
1978
|
}
|
|
914
1979
|
render() {
|
|
915
|
-
return (h("div", { key: '
|
|
1980
|
+
return (h("div", { key: '5500fa3f776e2357796ad51523f96c389ccdb810', ref: (el) => (this.stylingContainer = el), class: "container" }, this.pageHeader, this.loading ? (h("div", { class: "lds-dual-ring" })) : (h("div", null, h("button", { class: "back-button", onClick: this.goBack }, h("img", { class: "back-button__icon", src: backArrowSvg }), this.getBackButtonText()), this.forfeitedNofitication, this.completedNotification, this.expiredNotification, h("div", { class: "details" }, this.cardGeneralInfo, h("div", { class: "details__tabs-container" }, this.challengeTabs, this.activeTabIndex === 0 && this.levelsTab, this.activeTabIndex === 1 && this.gamesTab, this.activeTabIndex === 2 && this.rulesTab), this.footer)))));
|
|
916
1981
|
}
|
|
917
1982
|
static get watchers() { return {
|
|
918
1983
|
"clientStyling": ["handleClientStylingChange"],
|