@mjhls/mjh-framework 1.0.5 → 1.0.7

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/index.es.js CHANGED
@@ -2,10 +2,6 @@ import React__default, { useContext, useMemo, Component, useCallback, useRef, us
2
2
  import url from 'url';
3
3
  import PropTypes from 'prop-types';
4
4
  import ReactDOM from 'react-dom';
5
- import tty from 'tty';
6
- import util from 'util';
7
- import fs from 'fs';
8
- import net from 'net';
9
5
 
10
6
  function _extends() {
11
7
  _extends = Object.assign || function (target) {
@@ -11235,1901 +11231,5 @@ var Normal = function Normal(props) {
11235
11231
  );
11236
11232
  };
11237
11233
 
11238
- var getYoutubeId = createCommonjsModule(function (module, exports) {
11239
- (function (root, factory) {
11240
- {
11241
- module.exports = factory();
11242
- }
11243
- }(commonjsGlobal, function (exports) {
11244
-
11245
- return function (url$$1, opts) {
11246
- if (opts == undefined) {
11247
- opts = {fuzzy: true};
11248
- }
11249
-
11250
- if (/youtu\.?be/.test(url$$1)) {
11251
-
11252
- // Look first for known patterns
11253
- var i;
11254
- var patterns = [
11255
- /youtu\.be\/([^#\&\?]{11})/, // youtu.be/<id>
11256
- /\?v=([^#\&\?]{11})/, // ?v=<id>
11257
- /\&v=([^#\&\?]{11})/, // &v=<id>
11258
- /embed\/([^#\&\?]{11})/, // embed/<id>
11259
- /\/v\/([^#\&\?]{11})/ // /v/<id>
11260
- ];
11261
-
11262
- // If any pattern matches, return the ID
11263
- for (i = 0; i < patterns.length; ++i) {
11264
- if (patterns[i].test(url$$1)) {
11265
- return patterns[i].exec(url$$1)[1];
11266
- }
11267
- }
11268
-
11269
- if (opts.fuzzy) {
11270
- // If that fails, break it apart by certain characters and look
11271
- // for the 11 character key
11272
- var tokens = url$$1.split(/[\/\&\?=#\.\s]/g);
11273
- for (i = 0; i < tokens.length; ++i) {
11274
- if (/^[^#\&\?]{11}$/.test(tokens[i])) {
11275
- return tokens[i];
11276
- }
11277
- }
11278
- }
11279
- }
11280
-
11281
- return null;
11282
- };
11283
-
11284
- }));
11285
- });
11286
-
11287
- var isArray = Array.isArray;
11288
- var keyList = Object.keys;
11289
- var hasProp = Object.prototype.hasOwnProperty;
11290
-
11291
- var fastDeepEqual = function equal(a, b) {
11292
- if (a === b) return true;
11293
-
11294
- if (a && b && typeof a == 'object' && typeof b == 'object') {
11295
- var arrA = isArray(a)
11296
- , arrB = isArray(b)
11297
- , i
11298
- , length
11299
- , key;
11300
-
11301
- if (arrA && arrB) {
11302
- length = a.length;
11303
- if (length != b.length) return false;
11304
- for (i = length; i-- !== 0;)
11305
- if (!equal(a[i], b[i])) return false;
11306
- return true;
11307
- }
11308
-
11309
- if (arrA != arrB) return false;
11310
-
11311
- var dateA = a instanceof Date
11312
- , dateB = b instanceof Date;
11313
- if (dateA != dateB) return false;
11314
- if (dateA && dateB) return a.getTime() == b.getTime();
11315
-
11316
- var regexpA = a instanceof RegExp
11317
- , regexpB = b instanceof RegExp;
11318
- if (regexpA != regexpB) return false;
11319
- if (regexpA && regexpB) return a.toString() == b.toString();
11320
-
11321
- var keys = keyList(a);
11322
- length = keys.length;
11323
-
11324
- if (length !== keyList(b).length)
11325
- return false;
11326
-
11327
- for (i = length; i-- !== 0;)
11328
- if (!hasProp.call(b, keys[i])) return false;
11329
-
11330
- for (i = length; i-- !== 0;) {
11331
- key = keys[i];
11332
- if (!equal(a[key], b[key])) return false;
11333
- }
11334
-
11335
- return true;
11336
- }
11337
-
11338
- return a!==a && b!==b;
11339
- };
11340
-
11341
- var Sister;
11342
-
11343
- /**
11344
- * @link https://github.com/gajus/sister for the canonical source repository
11345
- * @license https://github.com/gajus/sister/blob/master/LICENSE BSD 3-Clause
11346
- */
11347
- Sister = function () {
11348
- var sister = {},
11349
- events = {};
11350
-
11351
- /**
11352
- * @name handler
11353
- * @function
11354
- * @param {Object} data Event data.
11355
- */
11356
-
11357
- /**
11358
- * @param {String} name Event name.
11359
- * @param {handler} handler
11360
- * @return {listener}
11361
- */
11362
- sister.on = function (name, handler) {
11363
- var listener = {name: name, handler: handler};
11364
- events[name] = events[name] || [];
11365
- events[name].unshift(listener);
11366
- return listener;
11367
- };
11368
-
11369
- /**
11370
- * @param {listener}
11371
- */
11372
- sister.off = function (listener) {
11373
- var index = events[listener.name].indexOf(listener);
11374
-
11375
- if (index !== -1) {
11376
- events[listener.name].splice(index, 1);
11377
- }
11378
- };
11379
-
11380
- /**
11381
- * @param {String} name Event name.
11382
- * @param {Object} data Event data.
11383
- */
11384
- sister.trigger = function (name, data) {
11385
- var listeners = events[name],
11386
- i;
11387
-
11388
- if (listeners) {
11389
- i = listeners.length;
11390
- while (i--) {
11391
- listeners[i].handler(data);
11392
- }
11393
- }
11394
- };
11395
-
11396
- return sister;
11397
- };
11398
-
11399
- var sister = Sister;
11400
-
11401
- var loadScript = function load (src, opts, cb) {
11402
- var head = document.head || document.getElementsByTagName('head')[0];
11403
- var script = document.createElement('script');
11404
-
11405
- if (typeof opts === 'function') {
11406
- cb = opts;
11407
- opts = {};
11408
- }
11409
-
11410
- opts = opts || {};
11411
- cb = cb || function() {};
11412
-
11413
- script.type = opts.type || 'text/javascript';
11414
- script.charset = opts.charset || 'utf8';
11415
- script.async = 'async' in opts ? !!opts.async : true;
11416
- script.src = src;
11417
-
11418
- if (opts.attrs) {
11419
- setAttributes$1(script, opts.attrs);
11420
- }
11421
-
11422
- if (opts.text) {
11423
- script.text = '' + opts.text;
11424
- }
11425
-
11426
- var onend = 'onload' in script ? stdOnEnd : ieOnEnd;
11427
- onend(script, cb);
11428
-
11429
- // some good legacy browsers (firefox) fail the 'in' detection above
11430
- // so as a fallback we always set onload
11431
- // old IE will ignore this and new IE will set onload
11432
- if (!script.onload) {
11433
- stdOnEnd(script, cb);
11434
- }
11435
-
11436
- head.appendChild(script);
11437
- };
11438
-
11439
- function setAttributes$1(script, attrs) {
11440
- for (var attr in attrs) {
11441
- script.setAttribute(attr, attrs[attr]);
11442
- }
11443
- }
11444
-
11445
- function stdOnEnd (script, cb) {
11446
- script.onload = function () {
11447
- this.onerror = this.onload = null;
11448
- cb(null, script);
11449
- };
11450
- script.onerror = function () {
11451
- // this.onload = null here is necessary
11452
- // because even IE9 works not like others
11453
- this.onerror = this.onload = null;
11454
- cb(new Error('Failed to load ' + this.src), script);
11455
- };
11456
- }
11457
-
11458
- function ieOnEnd (script, cb) {
11459
- script.onreadystatechange = function () {
11460
- if (this.readyState != 'complete' && this.readyState != 'loaded') return
11461
- this.onreadystatechange = null;
11462
- cb(null, script); // there is no way to catch loading errors in IE8
11463
- };
11464
- }
11465
-
11466
- var loadYouTubeIframeApi = createCommonjsModule(function (module, exports) {
11467
-
11468
- Object.defineProperty(exports, "__esModule", {
11469
- value: true
11470
- });
11471
-
11472
-
11473
-
11474
- var _loadScript2 = _interopRequireDefault(loadScript);
11475
-
11476
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11477
-
11478
- exports.default = function (emitter) {
11479
- /**
11480
- * A promise that is resolved when window.onYouTubeIframeAPIReady is called.
11481
- * The promise is resolved with a reference to window.YT object.
11482
- */
11483
- var iframeAPIReady = new Promise(function (resolve) {
11484
- if (window.YT && window.YT.Player && window.YT.Player instanceof Function) {
11485
- resolve(window.YT);
11486
-
11487
- return;
11488
- } else {
11489
- var protocol = window.location.protocol === 'http:' ? 'http:' : 'https:';
11490
-
11491
- (0, _loadScript2.default)(protocol + '//www.youtube.com/iframe_api', function (error) {
11492
- if (error) {
11493
- emitter.trigger('error', error);
11494
- }
11495
- });
11496
- }
11497
-
11498
- var previous = window.onYouTubeIframeAPIReady;
11499
-
11500
- // The API will call this function when page has finished downloading
11501
- // the JavaScript for the player API.
11502
- window.onYouTubeIframeAPIReady = function () {
11503
- if (previous) {
11504
- previous();
11505
- }
11506
-
11507
- resolve(window.YT);
11508
- };
11509
- });
11510
-
11511
- return iframeAPIReady;
11512
- };
11513
-
11514
- module.exports = exports['default'];
11515
- });
11516
-
11517
- unwrapExports(loadYouTubeIframeApi);
11518
-
11519
- /**
11520
- * Helpers.
11521
- */
11522
-
11523
- var s = 1000;
11524
- var m = s * 60;
11525
- var h = m * 60;
11526
- var d = h * 24;
11527
- var y = d * 365.25;
11528
-
11529
- /**
11530
- * Parse or format the given `val`.
11531
- *
11532
- * Options:
11533
- *
11534
- * - `long` verbose formatting [false]
11535
- *
11536
- * @param {String|Number} val
11537
- * @param {Object} [options]
11538
- * @throws {Error} throw an error if val is not a non-empty string or a number
11539
- * @return {String|Number}
11540
- * @api public
11541
- */
11542
-
11543
- var ms = function(val, options) {
11544
- options = options || {};
11545
- var type = typeof val;
11546
- if (type === 'string' && val.length > 0) {
11547
- return parse(val);
11548
- } else if (type === 'number' && isNaN(val) === false) {
11549
- return options.long ? fmtLong(val) : fmtShort(val);
11550
- }
11551
- throw new Error(
11552
- 'val is not a non-empty string or a valid number. val=' +
11553
- JSON.stringify(val)
11554
- );
11555
- };
11556
-
11557
- /**
11558
- * Parse the given `str` and return milliseconds.
11559
- *
11560
- * @param {String} str
11561
- * @return {Number}
11562
- * @api private
11563
- */
11564
-
11565
- function parse(str) {
11566
- str = String(str);
11567
- if (str.length > 100) {
11568
- return;
11569
- }
11570
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
11571
- str
11572
- );
11573
- if (!match) {
11574
- return;
11575
- }
11576
- var n = parseFloat(match[1]);
11577
- var type = (match[2] || 'ms').toLowerCase();
11578
- switch (type) {
11579
- case 'years':
11580
- case 'year':
11581
- case 'yrs':
11582
- case 'yr':
11583
- case 'y':
11584
- return n * y;
11585
- case 'days':
11586
- case 'day':
11587
- case 'd':
11588
- return n * d;
11589
- case 'hours':
11590
- case 'hour':
11591
- case 'hrs':
11592
- case 'hr':
11593
- case 'h':
11594
- return n * h;
11595
- case 'minutes':
11596
- case 'minute':
11597
- case 'mins':
11598
- case 'min':
11599
- case 'm':
11600
- return n * m;
11601
- case 'seconds':
11602
- case 'second':
11603
- case 'secs':
11604
- case 'sec':
11605
- case 's':
11606
- return n * s;
11607
- case 'milliseconds':
11608
- case 'millisecond':
11609
- case 'msecs':
11610
- case 'msec':
11611
- case 'ms':
11612
- return n;
11613
- default:
11614
- return undefined;
11615
- }
11616
- }
11617
-
11618
- /**
11619
- * Short format for `ms`.
11620
- *
11621
- * @param {Number} ms
11622
- * @return {String}
11623
- * @api private
11624
- */
11625
-
11626
- function fmtShort(ms) {
11627
- if (ms >= d) {
11628
- return Math.round(ms / d) + 'd';
11629
- }
11630
- if (ms >= h) {
11631
- return Math.round(ms / h) + 'h';
11632
- }
11633
- if (ms >= m) {
11634
- return Math.round(ms / m) + 'm';
11635
- }
11636
- if (ms >= s) {
11637
- return Math.round(ms / s) + 's';
11638
- }
11639
- return ms + 'ms';
11640
- }
11641
-
11642
- /**
11643
- * Long format for `ms`.
11644
- *
11645
- * @param {Number} ms
11646
- * @return {String}
11647
- * @api private
11648
- */
11649
-
11650
- function fmtLong(ms) {
11651
- return plural(ms, d, 'day') ||
11652
- plural(ms, h, 'hour') ||
11653
- plural(ms, m, 'minute') ||
11654
- plural(ms, s, 'second') ||
11655
- ms + ' ms';
11656
- }
11657
-
11658
- /**
11659
- * Pluralization helper.
11660
- */
11661
-
11662
- function plural(ms, n, name) {
11663
- if (ms < n) {
11664
- return;
11665
- }
11666
- if (ms < n * 1.5) {
11667
- return Math.floor(ms / n) + ' ' + name;
11668
- }
11669
- return Math.ceil(ms / n) + ' ' + name + 's';
11670
- }
11671
-
11672
- var debug = createCommonjsModule(function (module, exports) {
11673
- /**
11674
- * This is the common logic for both the Node.js and web browser
11675
- * implementations of `debug()`.
11676
- *
11677
- * Expose `debug()` as the module.
11678
- */
11679
-
11680
- exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
11681
- exports.coerce = coerce;
11682
- exports.disable = disable;
11683
- exports.enable = enable;
11684
- exports.enabled = enabled;
11685
- exports.humanize = ms;
11686
-
11687
- /**
11688
- * The currently active debug mode names, and names to skip.
11689
- */
11690
-
11691
- exports.names = [];
11692
- exports.skips = [];
11693
-
11694
- /**
11695
- * Map of special "%n" handling functions, for the debug "format" argument.
11696
- *
11697
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
11698
- */
11699
-
11700
- exports.formatters = {};
11701
-
11702
- /**
11703
- * Previous log timestamp.
11704
- */
11705
-
11706
- var prevTime;
11707
-
11708
- /**
11709
- * Select a color.
11710
- * @param {String} namespace
11711
- * @return {Number}
11712
- * @api private
11713
- */
11714
-
11715
- function selectColor(namespace) {
11716
- var hash = 0, i;
11717
-
11718
- for (i in namespace) {
11719
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
11720
- hash |= 0; // Convert to 32bit integer
11721
- }
11722
-
11723
- return exports.colors[Math.abs(hash) % exports.colors.length];
11724
- }
11725
-
11726
- /**
11727
- * Create a debugger with the given `namespace`.
11728
- *
11729
- * @param {String} namespace
11730
- * @return {Function}
11731
- * @api public
11732
- */
11733
-
11734
- function createDebug(namespace) {
11735
-
11736
- function debug() {
11737
- // disabled?
11738
- if (!debug.enabled) return;
11739
-
11740
- var self = debug;
11741
-
11742
- // set `diff` timestamp
11743
- var curr = +new Date();
11744
- var ms$$1 = curr - (prevTime || curr);
11745
- self.diff = ms$$1;
11746
- self.prev = prevTime;
11747
- self.curr = curr;
11748
- prevTime = curr;
11749
-
11750
- // turn the `arguments` into a proper Array
11751
- var args = new Array(arguments.length);
11752
- for (var i = 0; i < args.length; i++) {
11753
- args[i] = arguments[i];
11754
- }
11755
-
11756
- args[0] = exports.coerce(args[0]);
11757
-
11758
- if ('string' !== typeof args[0]) {
11759
- // anything else let's inspect with %O
11760
- args.unshift('%O');
11761
- }
11762
-
11763
- // apply any `formatters` transformations
11764
- var index = 0;
11765
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
11766
- // if we encounter an escaped % then don't increase the array index
11767
- if (match === '%%') return match;
11768
- index++;
11769
- var formatter = exports.formatters[format];
11770
- if ('function' === typeof formatter) {
11771
- var val = args[index];
11772
- match = formatter.call(self, val);
11773
-
11774
- // now we need to remove `args[index]` since it's inlined in the `format`
11775
- args.splice(index, 1);
11776
- index--;
11777
- }
11778
- return match;
11779
- });
11780
-
11781
- // apply env-specific formatting (colors, etc.)
11782
- exports.formatArgs.call(self, args);
11783
-
11784
- var logFn = debug.log || exports.log || console.log.bind(console);
11785
- logFn.apply(self, args);
11786
- }
11787
-
11788
- debug.namespace = namespace;
11789
- debug.enabled = exports.enabled(namespace);
11790
- debug.useColors = exports.useColors();
11791
- debug.color = selectColor(namespace);
11792
-
11793
- // env-specific initialization logic for debug instances
11794
- if ('function' === typeof exports.init) {
11795
- exports.init(debug);
11796
- }
11797
-
11798
- return debug;
11799
- }
11800
-
11801
- /**
11802
- * Enables a debug mode by namespaces. This can include modes
11803
- * separated by a colon and wildcards.
11804
- *
11805
- * @param {String} namespaces
11806
- * @api public
11807
- */
11808
-
11809
- function enable(namespaces) {
11810
- exports.save(namespaces);
11811
-
11812
- exports.names = [];
11813
- exports.skips = [];
11814
-
11815
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
11816
- var len = split.length;
11817
-
11818
- for (var i = 0; i < len; i++) {
11819
- if (!split[i]) continue; // ignore empty strings
11820
- namespaces = split[i].replace(/\*/g, '.*?');
11821
- if (namespaces[0] === '-') {
11822
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
11823
- } else {
11824
- exports.names.push(new RegExp('^' + namespaces + '$'));
11825
- }
11826
- }
11827
- }
11828
-
11829
- /**
11830
- * Disable debug output.
11831
- *
11832
- * @api public
11833
- */
11834
-
11835
- function disable() {
11836
- exports.enable('');
11837
- }
11838
-
11839
- /**
11840
- * Returns true if the given mode name is enabled, false otherwise.
11841
- *
11842
- * @param {String} name
11843
- * @return {Boolean}
11844
- * @api public
11845
- */
11846
-
11847
- function enabled(name) {
11848
- var i, len;
11849
- for (i = 0, len = exports.skips.length; i < len; i++) {
11850
- if (exports.skips[i].test(name)) {
11851
- return false;
11852
- }
11853
- }
11854
- for (i = 0, len = exports.names.length; i < len; i++) {
11855
- if (exports.names[i].test(name)) {
11856
- return true;
11857
- }
11858
- }
11859
- return false;
11860
- }
11861
-
11862
- /**
11863
- * Coerce `val`.
11864
- *
11865
- * @param {Mixed} val
11866
- * @return {Mixed}
11867
- * @api private
11868
- */
11869
-
11870
- function coerce(val) {
11871
- if (val instanceof Error) return val.stack || val.message;
11872
- return val;
11873
- }
11874
- });
11875
- var debug_1 = debug.coerce;
11876
- var debug_2 = debug.disable;
11877
- var debug_3 = debug.enable;
11878
- var debug_4 = debug.enabled;
11879
- var debug_5 = debug.humanize;
11880
- var debug_6 = debug.names;
11881
- var debug_7 = debug.skips;
11882
- var debug_8 = debug.formatters;
11883
-
11884
- var browser = createCommonjsModule(function (module, exports) {
11885
- /**
11886
- * This is the web browser implementation of `debug()`.
11887
- *
11888
- * Expose `debug()` as the module.
11889
- */
11890
-
11891
- exports = module.exports = debug;
11892
- exports.log = log;
11893
- exports.formatArgs = formatArgs;
11894
- exports.save = save;
11895
- exports.load = load;
11896
- exports.useColors = useColors;
11897
- exports.storage = 'undefined' != typeof chrome
11898
- && 'undefined' != typeof chrome.storage
11899
- ? chrome.storage.local
11900
- : localstorage();
11901
-
11902
- /**
11903
- * Colors.
11904
- */
11905
-
11906
- exports.colors = [
11907
- 'lightseagreen',
11908
- 'forestgreen',
11909
- 'goldenrod',
11910
- 'dodgerblue',
11911
- 'darkorchid',
11912
- 'crimson'
11913
- ];
11914
-
11915
- /**
11916
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
11917
- * and the Firebug extension (any Firefox version) are known
11918
- * to support "%c" CSS customizations.
11919
- *
11920
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
11921
- */
11922
-
11923
- function useColors() {
11924
- // NB: In an Electron preload script, document will be defined but not fully
11925
- // initialized. Since we know we're in Chrome, we'll just detect this case
11926
- // explicitly
11927
- if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
11928
- return true;
11929
- }
11930
-
11931
- // is webkit? http://stackoverflow.com/a/16459606/376773
11932
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
11933
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
11934
- // is firebug? http://stackoverflow.com/a/398120/376773
11935
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
11936
- // is firefox >= v31?
11937
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
11938
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
11939
- // double check webkit in userAgent just in case we are in a worker
11940
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
11941
- }
11942
-
11943
- /**
11944
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
11945
- */
11946
-
11947
- exports.formatters.j = function(v) {
11948
- try {
11949
- return JSON.stringify(v);
11950
- } catch (err) {
11951
- return '[UnexpectedJSONParseError]: ' + err.message;
11952
- }
11953
- };
11954
-
11955
-
11956
- /**
11957
- * Colorize log arguments if enabled.
11958
- *
11959
- * @api public
11960
- */
11961
-
11962
- function formatArgs(args) {
11963
- var useColors = this.useColors;
11964
-
11965
- args[0] = (useColors ? '%c' : '')
11966
- + this.namespace
11967
- + (useColors ? ' %c' : ' ')
11968
- + args[0]
11969
- + (useColors ? '%c ' : ' ')
11970
- + '+' + exports.humanize(this.diff);
11971
-
11972
- if (!useColors) return;
11973
-
11974
- var c = 'color: ' + this.color;
11975
- args.splice(1, 0, c, 'color: inherit');
11976
-
11977
- // the final "%c" is somewhat tricky, because there could be other
11978
- // arguments passed either before or after the %c, so we need to
11979
- // figure out the correct index to insert the CSS into
11980
- var index = 0;
11981
- var lastC = 0;
11982
- args[0].replace(/%[a-zA-Z%]/g, function(match) {
11983
- if ('%%' === match) return;
11984
- index++;
11985
- if ('%c' === match) {
11986
- // we only are interested in the *last* %c
11987
- // (the user may have provided their own)
11988
- lastC = index;
11989
- }
11990
- });
11991
-
11992
- args.splice(lastC, 0, c);
11993
- }
11994
-
11995
- /**
11996
- * Invokes `console.log()` when available.
11997
- * No-op when `console.log` is not a "function".
11998
- *
11999
- * @api public
12000
- */
12001
-
12002
- function log() {
12003
- // this hackery is required for IE8/9, where
12004
- // the `console.log` function doesn't have 'apply'
12005
- return 'object' === typeof console
12006
- && console.log
12007
- && Function.prototype.apply.call(console.log, console, arguments);
12008
- }
12009
-
12010
- /**
12011
- * Save `namespaces`.
12012
- *
12013
- * @param {String} namespaces
12014
- * @api private
12015
- */
12016
-
12017
- function save(namespaces) {
12018
- try {
12019
- if (null == namespaces) {
12020
- exports.storage.removeItem('debug');
12021
- } else {
12022
- exports.storage.debug = namespaces;
12023
- }
12024
- } catch(e) {}
12025
- }
12026
-
12027
- /**
12028
- * Load `namespaces`.
12029
- *
12030
- * @return {String} returns the previously persisted debug modes
12031
- * @api private
12032
- */
12033
-
12034
- function load() {
12035
- var r;
12036
- try {
12037
- r = exports.storage.debug;
12038
- } catch(e) {}
12039
-
12040
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
12041
- if (!r && typeof process !== 'undefined' && 'env' in process) {
12042
- r = process.env.DEBUG;
12043
- }
12044
-
12045
- return r;
12046
- }
12047
-
12048
- /**
12049
- * Enable namespaces listed in `localStorage.debug` initially.
12050
- */
12051
-
12052
- exports.enable(load());
12053
-
12054
- /**
12055
- * Localstorage attempts to return the localstorage.
12056
- *
12057
- * This is necessary because safari throws
12058
- * when a user disables cookies/localstorage
12059
- * and you attempt to access it.
12060
- *
12061
- * @return {LocalStorage}
12062
- * @api private
12063
- */
12064
-
12065
- function localstorage() {
12066
- try {
12067
- return window.localStorage;
12068
- } catch (e) {}
12069
- }
12070
- });
12071
- var browser_1 = browser.log;
12072
- var browser_2 = browser.formatArgs;
12073
- var browser_3 = browser.save;
12074
- var browser_4 = browser.load;
12075
- var browser_5 = browser.useColors;
12076
- var browser_6 = browser.storage;
12077
- var browser_7 = browser.colors;
12078
-
12079
- var node = createCommonjsModule(function (module, exports) {
12080
- /**
12081
- * Module dependencies.
12082
- */
12083
-
12084
-
12085
-
12086
-
12087
- /**
12088
- * This is the Node.js implementation of `debug()`.
12089
- *
12090
- * Expose `debug()` as the module.
12091
- */
12092
-
12093
- exports = module.exports = debug;
12094
- exports.init = init;
12095
- exports.log = log;
12096
- exports.formatArgs = formatArgs;
12097
- exports.save = save;
12098
- exports.load = load;
12099
- exports.useColors = useColors;
12100
-
12101
- /**
12102
- * Colors.
12103
- */
12104
-
12105
- exports.colors = [6, 2, 3, 4, 5, 1];
12106
-
12107
- /**
12108
- * Build up the default `inspectOpts` object from the environment variables.
12109
- *
12110
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
12111
- */
12112
-
12113
- exports.inspectOpts = Object.keys(process.env).filter(function (key) {
12114
- return /^debug_/i.test(key);
12115
- }).reduce(function (obj, key) {
12116
- // camel-case
12117
- var prop = key
12118
- .substring(6)
12119
- .toLowerCase()
12120
- .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
12121
-
12122
- // coerce string value into JS value
12123
- var val = process.env[key];
12124
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
12125
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
12126
- else if (val === 'null') val = null;
12127
- else val = Number(val);
12128
-
12129
- obj[prop] = val;
12130
- return obj;
12131
- }, {});
12132
-
12133
- /**
12134
- * The file descriptor to write the `debug()` calls to.
12135
- * Set the `DEBUG_FD` env variable to override with another value. i.e.:
12136
- *
12137
- * $ DEBUG_FD=3 node script.js 3>debug.log
12138
- */
12139
-
12140
- var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
12141
-
12142
- if (1 !== fd && 2 !== fd) {
12143
- util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
12144
- }
12145
-
12146
- var stream = 1 === fd ? process.stdout :
12147
- 2 === fd ? process.stderr :
12148
- createWritableStdioStream(fd);
12149
-
12150
- /**
12151
- * Is stdout a TTY? Colored output is enabled when `true`.
12152
- */
12153
-
12154
- function useColors() {
12155
- return 'colors' in exports.inspectOpts
12156
- ? Boolean(exports.inspectOpts.colors)
12157
- : tty.isatty(fd);
12158
- }
12159
-
12160
- /**
12161
- * Map %o to `util.inspect()`, all on a single line.
12162
- */
12163
-
12164
- exports.formatters.o = function(v) {
12165
- this.inspectOpts.colors = this.useColors;
12166
- return util.inspect(v, this.inspectOpts)
12167
- .split('\n').map(function(str) {
12168
- return str.trim()
12169
- }).join(' ');
12170
- };
12171
-
12172
- /**
12173
- * Map %o to `util.inspect()`, allowing multiple lines if needed.
12174
- */
12175
-
12176
- exports.formatters.O = function(v) {
12177
- this.inspectOpts.colors = this.useColors;
12178
- return util.inspect(v, this.inspectOpts);
12179
- };
12180
-
12181
- /**
12182
- * Adds ANSI color escape codes if enabled.
12183
- *
12184
- * @api public
12185
- */
12186
-
12187
- function formatArgs(args) {
12188
- var name = this.namespace;
12189
- var useColors = this.useColors;
12190
-
12191
- if (useColors) {
12192
- var c = this.color;
12193
- var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
12194
-
12195
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
12196
- args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
12197
- } else {
12198
- args[0] = new Date().toUTCString()
12199
- + ' ' + name + ' ' + args[0];
12200
- }
12201
- }
12202
-
12203
- /**
12204
- * Invokes `util.format()` with the specified arguments and writes to `stream`.
12205
- */
12206
-
12207
- function log() {
12208
- return stream.write(util.format.apply(util, arguments) + '\n');
12209
- }
12210
-
12211
- /**
12212
- * Save `namespaces`.
12213
- *
12214
- * @param {String} namespaces
12215
- * @api private
12216
- */
12217
-
12218
- function save(namespaces) {
12219
- if (null == namespaces) {
12220
- // If you set a process.env field to null or undefined, it gets cast to the
12221
- // string 'null' or 'undefined'. Just delete instead.
12222
- delete process.env.DEBUG;
12223
- } else {
12224
- process.env.DEBUG = namespaces;
12225
- }
12226
- }
12227
-
12228
- /**
12229
- * Load `namespaces`.
12230
- *
12231
- * @return {String} returns the previously persisted debug modes
12232
- * @api private
12233
- */
12234
-
12235
- function load() {
12236
- return process.env.DEBUG;
12237
- }
12238
-
12239
- /**
12240
- * Copied from `node/src/node.js`.
12241
- *
12242
- * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
12243
- * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
12244
- */
12245
-
12246
- function createWritableStdioStream (fd) {
12247
- var stream;
12248
- var tty_wrap = process.binding('tty_wrap');
12249
-
12250
- // Note stream._type is used for test-module-load-list.js
12251
-
12252
- switch (tty_wrap.guessHandleType(fd)) {
12253
- case 'TTY':
12254
- stream = new tty.WriteStream(fd);
12255
- stream._type = 'tty';
12256
-
12257
- // Hack to have stream not keep the event loop alive.
12258
- // See https://github.com/joyent/node/issues/1726
12259
- if (stream._handle && stream._handle.unref) {
12260
- stream._handle.unref();
12261
- }
12262
- break;
12263
-
12264
- case 'FILE':
12265
- var fs$$1 = fs;
12266
- stream = new fs$$1.SyncWriteStream(fd, { autoClose: false });
12267
- stream._type = 'fs';
12268
- break;
12269
-
12270
- case 'PIPE':
12271
- case 'TCP':
12272
- var net$$1 = net;
12273
- stream = new net$$1.Socket({
12274
- fd: fd,
12275
- readable: false,
12276
- writable: true
12277
- });
12278
-
12279
- // FIXME Should probably have an option in net.Socket to create a
12280
- // stream from an existing fd which is writable only. But for now
12281
- // we'll just add this hack and set the `readable` member to false.
12282
- // Test: ./node test/fixtures/echo.js < /etc/passwd
12283
- stream.readable = false;
12284
- stream.read = null;
12285
- stream._type = 'pipe';
12286
-
12287
- // FIXME Hack to have stream not keep the event loop alive.
12288
- // See https://github.com/joyent/node/issues/1726
12289
- if (stream._handle && stream._handle.unref) {
12290
- stream._handle.unref();
12291
- }
12292
- break;
12293
-
12294
- default:
12295
- // Probably an error on in uv_guess_handle()
12296
- throw new Error('Implement me. Unknown stream file type!');
12297
- }
12298
-
12299
- // For supporting legacy API we put the FD here.
12300
- stream.fd = fd;
12301
-
12302
- stream._isStdio = true;
12303
-
12304
- return stream;
12305
- }
12306
-
12307
- /**
12308
- * Init logic for `debug` instances.
12309
- *
12310
- * Create a new `inspectOpts` object in case `useColors` is set
12311
- * differently for a particular `debug` instance.
12312
- */
12313
-
12314
- function init (debug$$1) {
12315
- debug$$1.inspectOpts = {};
12316
-
12317
- var keys = Object.keys(exports.inspectOpts);
12318
- for (var i = 0; i < keys.length; i++) {
12319
- debug$$1.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
12320
- }
12321
- }
12322
-
12323
- /**
12324
- * Enable namespaces listed in `process.env.DEBUG` initially.
12325
- */
12326
-
12327
- exports.enable(load());
12328
- });
12329
- var node_1 = node.init;
12330
- var node_2 = node.log;
12331
- var node_3 = node.formatArgs;
12332
- var node_4 = node.save;
12333
- var node_5 = node.load;
12334
- var node_6 = node.useColors;
12335
- var node_7 = node.colors;
12336
- var node_8 = node.inspectOpts;
12337
-
12338
- var src$1 = createCommonjsModule(function (module) {
12339
- /**
12340
- * Detect Electron renderer process, which is node, but we should
12341
- * treat as a browser.
12342
- */
12343
-
12344
- if (typeof process !== 'undefined' && process.type === 'renderer') {
12345
- module.exports = browser;
12346
- } else {
12347
- module.exports = node;
12348
- }
12349
- });
12350
-
12351
- var functionNames = createCommonjsModule(function (module, exports) {
12352
-
12353
- Object.defineProperty(exports, "__esModule", {
12354
- value: true
12355
- });
12356
-
12357
-
12358
- /**
12359
- * @see https://developers.google.com/youtube/iframe_api_reference#Functions
12360
- */
12361
- exports.default = ['cueVideoById', 'loadVideoById', 'cueVideoByUrl', 'loadVideoByUrl', 'playVideo', 'pauseVideo', 'stopVideo', 'getVideoLoadedFraction', 'cuePlaylist', 'loadPlaylist', 'nextVideo', 'previousVideo', 'playVideoAt', 'setShuffle', 'setLoop', 'getPlaylist', 'getPlaylistIndex', 'setOption', 'mute', 'unMute', 'isMuted', 'setVolume', 'getVolume', 'seekTo', 'getPlayerState', 'getPlaybackRate', 'setPlaybackRate', 'getAvailablePlaybackRates', 'getPlaybackQuality', 'setPlaybackQuality', 'getAvailableQualityLevels', 'getCurrentTime', 'getDuration', 'removeEventListener', 'getVideoUrl', 'getVideoEmbedCode', 'getOptions', 'getOption', 'addEventListener', 'destroy', 'setSize', 'getIframe'];
12362
- module.exports = exports['default'];
12363
- });
12364
-
12365
- unwrapExports(functionNames);
12366
-
12367
- var eventNames = createCommonjsModule(function (module, exports) {
12368
-
12369
- Object.defineProperty(exports, "__esModule", {
12370
- value: true
12371
- });
12372
-
12373
-
12374
- /**
12375
- * @see https://developers.google.com/youtube/iframe_api_reference#Events
12376
- * `volumeChange` is not officially supported but seems to work
12377
- * it emits an object: `{volume: 82.6923076923077, muted: false}`
12378
- */
12379
- exports.default = ['ready', 'stateChange', 'playbackQualityChange', 'playbackRateChange', 'error', 'apiChange', 'volumeChange'];
12380
- module.exports = exports['default'];
12381
- });
12382
-
12383
- unwrapExports(eventNames);
12384
-
12385
- var PlayerStates = createCommonjsModule(function (module, exports) {
12386
-
12387
- Object.defineProperty(exports, "__esModule", {
12388
- value: true
12389
- });
12390
- exports.default = {
12391
- BUFFERING: 3,
12392
- ENDED: 0,
12393
- PAUSED: 2,
12394
- PLAYING: 1,
12395
- UNSTARTED: -1,
12396
- VIDEO_CUED: 5
12397
- };
12398
- module.exports = exports["default"];
12399
- });
12400
-
12401
- unwrapExports(PlayerStates);
12402
-
12403
- var FunctionStateMap = createCommonjsModule(function (module, exports) {
12404
-
12405
- Object.defineProperty(exports, "__esModule", {
12406
- value: true
12407
- });
12408
-
12409
-
12410
-
12411
- var _PlayerStates2 = _interopRequireDefault(PlayerStates);
12412
-
12413
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12414
-
12415
- exports.default = {
12416
- pauseVideo: {
12417
- acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PAUSED],
12418
- stateChangeRequired: false
12419
- },
12420
- playVideo: {
12421
- acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING],
12422
- stateChangeRequired: false
12423
- },
12424
- seekTo: {
12425
- acceptableStates: [_PlayerStates2.default.ENDED, _PlayerStates2.default.PLAYING, _PlayerStates2.default.PAUSED],
12426
- stateChangeRequired: true,
12427
-
12428
- // TRICKY: `seekTo` may not cause a state change if no buffering is
12429
- // required.
12430
- timeout: 3000
12431
- }
12432
- };
12433
- module.exports = exports['default'];
12434
- });
12435
-
12436
- unwrapExports(FunctionStateMap);
12437
-
12438
- var YouTubePlayer_1 = createCommonjsModule(function (module, exports) {
12439
-
12440
- Object.defineProperty(exports, "__esModule", {
12441
- value: true
12442
- });
12443
-
12444
-
12445
-
12446
- var _debug2 = _interopRequireDefault(src$1);
12447
-
12448
-
12449
-
12450
- var _functionNames2 = _interopRequireDefault(functionNames);
12451
-
12452
-
12453
-
12454
- var _eventNames2 = _interopRequireDefault(eventNames);
12455
-
12456
-
12457
-
12458
- var _FunctionStateMap2 = _interopRequireDefault(FunctionStateMap);
12459
-
12460
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12461
-
12462
- /* eslint-disable promise/prefer-await-to-then */
12463
-
12464
- var debug = (0, _debug2.default)('youtube-player');
12465
-
12466
- var YouTubePlayer = {};
12467
-
12468
- /**
12469
- * Construct an object that defines an event handler for all of the YouTube
12470
- * player events. Proxy captured events through an event emitter.
12471
- *
12472
- * @todo Capture event parameters.
12473
- * @see https://developers.google.com/youtube/iframe_api_reference#Events
12474
- */
12475
- YouTubePlayer.proxyEvents = function (emitter) {
12476
- var events = {};
12477
-
12478
- var _loop = function _loop(eventName) {
12479
- var onEventName = 'on' + eventName.slice(0, 1).toUpperCase() + eventName.slice(1);
12480
-
12481
- events[onEventName] = function (event) {
12482
- debug('event "%s"', onEventName, event);
12483
-
12484
- emitter.trigger(eventName, event);
12485
- };
12486
- };
12487
-
12488
- var _iteratorNormalCompletion = true;
12489
- var _didIteratorError = false;
12490
- var _iteratorError = undefined;
12491
-
12492
- try {
12493
- for (var _iterator = _eventNames2.default[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12494
- var eventName = _step.value;
12495
-
12496
- _loop(eventName);
12497
- }
12498
- } catch (err) {
12499
- _didIteratorError = true;
12500
- _iteratorError = err;
12501
- } finally {
12502
- try {
12503
- if (!_iteratorNormalCompletion && _iterator.return) {
12504
- _iterator.return();
12505
- }
12506
- } finally {
12507
- if (_didIteratorError) {
12508
- throw _iteratorError;
12509
- }
12510
- }
12511
- }
12512
-
12513
- return events;
12514
- };
12515
-
12516
- /**
12517
- * Delays player API method execution until player state is ready.
12518
- *
12519
- * @todo Proxy all of the methods using Object.keys.
12520
- * @todo See TRICKY below.
12521
- * @param playerAPIReady Promise that resolves when player is ready.
12522
- * @param strictState A flag designating whether or not to wait for
12523
- * an acceptable state when calling supported functions.
12524
- * @returns {Object}
12525
- */
12526
- YouTubePlayer.promisifyPlayer = function (playerAPIReady) {
12527
- var strictState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
12528
-
12529
- var functions = {};
12530
-
12531
- var _loop2 = function _loop2(functionName) {
12532
- if (strictState && _FunctionStateMap2.default[functionName]) {
12533
- functions[functionName] = function () {
12534
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
12535
- args[_key] = arguments[_key];
12536
- }
12537
-
12538
- return playerAPIReady.then(function (player) {
12539
- var stateInfo = _FunctionStateMap2.default[functionName];
12540
- var playerState = player.getPlayerState();
12541
-
12542
- // eslint-disable-next-line no-warning-comments
12543
- // TODO: Just spread the args into the function once Babel is fixed:
12544
- // https://github.com/babel/babel/issues/4270
12545
- //
12546
- // eslint-disable-next-line prefer-spread
12547
- var value = player[functionName].apply(player, args);
12548
-
12549
- // TRICKY: For functions like `seekTo`, a change in state must be
12550
- // triggered given that the resulting state could match the initial
12551
- // state.
12552
- if (stateInfo.stateChangeRequired ||
12553
-
12554
- // eslint-disable-next-line no-extra-parens
12555
- Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerState) === -1) {
12556
- return new Promise(function (resolve) {
12557
- var onPlayerStateChange = function onPlayerStateChange() {
12558
- var playerStateAfterChange = player.getPlayerState();
12559
-
12560
- var timeout = void 0;
12561
-
12562
- if (typeof stateInfo.timeout === 'number') {
12563
- timeout = setTimeout(function () {
12564
- player.removeEventListener('onStateChange', onPlayerStateChange);
12565
-
12566
- resolve();
12567
- }, stateInfo.timeout);
12568
- }
12569
-
12570
- if (Array.isArray(stateInfo.acceptableStates) && stateInfo.acceptableStates.indexOf(playerStateAfterChange) !== -1) {
12571
- player.removeEventListener('onStateChange', onPlayerStateChange);
12572
-
12573
- clearTimeout(timeout);
12574
-
12575
- resolve();
12576
- }
12577
- };
12578
-
12579
- player.addEventListener('onStateChange', onPlayerStateChange);
12580
- }).then(function () {
12581
- return value;
12582
- });
12583
- }
12584
-
12585
- return value;
12586
- });
12587
- };
12588
- } else {
12589
- functions[functionName] = function () {
12590
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
12591
- args[_key2] = arguments[_key2];
12592
- }
12593
-
12594
- return playerAPIReady.then(function (player) {
12595
- // eslint-disable-next-line no-warning-comments
12596
- // TODO: Just spread the args into the function once Babel is fixed:
12597
- // https://github.com/babel/babel/issues/4270
12598
- //
12599
- // eslint-disable-next-line prefer-spread
12600
- return player[functionName].apply(player, args);
12601
- });
12602
- };
12603
- }
12604
- };
12605
-
12606
- var _iteratorNormalCompletion2 = true;
12607
- var _didIteratorError2 = false;
12608
- var _iteratorError2 = undefined;
12609
-
12610
- try {
12611
- for (var _iterator2 = _functionNames2.default[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
12612
- var functionName = _step2.value;
12613
-
12614
- _loop2(functionName);
12615
- }
12616
- } catch (err) {
12617
- _didIteratorError2 = true;
12618
- _iteratorError2 = err;
12619
- } finally {
12620
- try {
12621
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
12622
- _iterator2.return();
12623
- }
12624
- } finally {
12625
- if (_didIteratorError2) {
12626
- throw _iteratorError2;
12627
- }
12628
- }
12629
- }
12630
-
12631
- return functions;
12632
- };
12633
-
12634
- exports.default = YouTubePlayer;
12635
- module.exports = exports['default'];
12636
- });
12637
-
12638
- unwrapExports(YouTubePlayer_1);
12639
-
12640
- var dist = createCommonjsModule(function (module, exports) {
12641
-
12642
- Object.defineProperty(exports, "__esModule", {
12643
- value: true
12644
- });
12645
-
12646
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
12647
-
12648
-
12649
-
12650
- var _sister2 = _interopRequireDefault(sister);
12651
-
12652
-
12653
-
12654
- var _loadYouTubeIframeApi2 = _interopRequireDefault(loadYouTubeIframeApi);
12655
-
12656
-
12657
-
12658
- var _YouTubePlayer2 = _interopRequireDefault(YouTubePlayer_1);
12659
-
12660
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12661
-
12662
- /**
12663
- * @typedef YT.Player
12664
- * @see https://developers.google.com/youtube/iframe_api_reference
12665
- * */
12666
-
12667
- /**
12668
- * @see https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
12669
- */
12670
- var youtubeIframeAPI = void 0;
12671
-
12672
- /**
12673
- * A factory function used to produce an instance of YT.Player and queue function calls and proxy events of the resulting object.
12674
- *
12675
- * @param maybeElementId Either An existing YT.Player instance,
12676
- * the DOM element or the id of the HTML element where the API will insert an <iframe>.
12677
- * @param options See `options` (Ignored when using an existing YT.Player instance).
12678
- * @param strictState A flag designating whether or not to wait for
12679
- * an acceptable state when calling supported functions. Default: `false`.
12680
- * See `FunctionStateMap.js` for supported functions and acceptable states.
12681
- */
12682
-
12683
- exports.default = function (maybeElementId) {
12684
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12685
- var strictState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
12686
-
12687
- var emitter = (0, _sister2.default)();
12688
-
12689
- if (!youtubeIframeAPI) {
12690
- youtubeIframeAPI = (0, _loadYouTubeIframeApi2.default)(emitter);
12691
- }
12692
-
12693
- if (options.events) {
12694
- throw new Error('Event handlers cannot be overwritten.');
12695
- }
12696
-
12697
- if (typeof maybeElementId === 'string' && !document.getElementById(maybeElementId)) {
12698
- throw new Error('Element "' + maybeElementId + '" does not exist.');
12699
- }
12700
-
12701
- options.events = _YouTubePlayer2.default.proxyEvents(emitter);
12702
-
12703
- var playerAPIReady = new Promise(function (resolve) {
12704
- if ((typeof maybeElementId === 'undefined' ? 'undefined' : _typeof(maybeElementId)) === 'object' && maybeElementId.playVideo instanceof Function) {
12705
- var player = maybeElementId;
12706
-
12707
- resolve(player);
12708
- } else {
12709
- // asume maybeElementId can be rendered inside
12710
- // eslint-disable-next-line promise/catch-or-return
12711
- youtubeIframeAPI.then(function (YT) {
12712
- // eslint-disable-line promise/prefer-await-to-then
12713
- var player = new YT.Player(maybeElementId, options);
12714
-
12715
- emitter.on('ready', function () {
12716
- resolve(player);
12717
- });
12718
-
12719
- return null;
12720
- });
12721
- }
12722
- });
12723
-
12724
- var playerApi = _YouTubePlayer2.default.promisifyPlayer(playerAPIReady, strictState);
12725
-
12726
- playerApi.on = emitter.on;
12727
- playerApi.off = emitter.off;
12728
-
12729
- return playerApi;
12730
- };
12731
-
12732
- module.exports = exports['default'];
12733
- });
12734
-
12735
- var youTubePlayer = unwrapExports(dist);
12736
-
12737
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
12738
-
12739
- var _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
12740
-
12741
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12742
-
12743
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
12744
-
12745
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
12746
-
12747
- /**
12748
- * Check whether a `props` change should result in the video being updated.
12749
- *
12750
- * @param {Object} prevProps
12751
- * @param {Object} props
12752
- */
12753
- function shouldUpdateVideo(prevProps, props) {
12754
- // A changing video should always trigger an update
12755
- if (prevProps.videoId !== props.videoId) {
12756
- return true;
12757
- }
12758
-
12759
- // Otherwise, a change in the start/end time playerVars also requires a player
12760
- // update.
12761
- var prevVars = prevProps.opts.playerVars || {};
12762
- var vars = props.opts.playerVars || {};
12763
-
12764
- return prevVars.start !== vars.start || prevVars.end !== vars.end;
12765
- }
12766
-
12767
- /**
12768
- * Neutralise API options that only require a video update, leaving only options
12769
- * that require a player reset. The results can then be compared to see if a
12770
- * player reset is necessary.
12771
- *
12772
- * @param {Object} opts
12773
- */
12774
- function filterResetOptions(opts) {
12775
- return _extends$3({}, opts, {
12776
- playerVars: _extends$3({}, opts.playerVars, {
12777
- autoplay: 0,
12778
- start: 0,
12779
- end: 0
12780
- })
12781
- });
12782
- }
12783
-
12784
- /**
12785
- * Check whether a `props` change should result in the player being reset.
12786
- * The player is reset when the `props.opts` change, except if the only change
12787
- * is in the `start` and `end` playerVars, because a video update can deal with
12788
- * those.
12789
- *
12790
- * @param {Object} prevProps
12791
- * @param {Object} props
12792
- */
12793
- function shouldResetPlayer(prevProps, props) {
12794
- return !fastDeepEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts));
12795
- }
12796
-
12797
- /**
12798
- * Check whether a props change should result in an id or className update.
12799
- *
12800
- * @param {Object} prevProps
12801
- * @param {Object} props
12802
- */
12803
- function shouldUpdatePlayer(prevProps, props) {
12804
- return prevProps.id !== props.id || prevProps.className !== props.className;
12805
- }
12806
-
12807
- var YouTube = function (_React$Component) {
12808
- _inherits(YouTube, _React$Component);
12809
-
12810
- function YouTube(props) {
12811
- _classCallCheck(this, YouTube);
12812
-
12813
- var _this = _possibleConstructorReturn(this, (YouTube.__proto__ || Object.getPrototypeOf(YouTube)).call(this, props));
12814
-
12815
- _this.onPlayerReady = function (event) {
12816
- return _this.props.onReady(event);
12817
- };
12818
-
12819
- _this.onPlayerError = function (event) {
12820
- return _this.props.onError(event);
12821
- };
12822
-
12823
- _this.onPlayerStateChange = function (event) {
12824
- _this.props.onStateChange(event);
12825
- switch (event.data) {
12826
-
12827
- case YouTube.PlayerState.ENDED:
12828
- _this.props.onEnd(event);
12829
- break;
12830
-
12831
- case YouTube.PlayerState.PLAYING:
12832
- _this.props.onPlay(event);
12833
- break;
12834
-
12835
- case YouTube.PlayerState.PAUSED:
12836
- _this.props.onPause(event);
12837
- break;
12838
-
12839
- default:
12840
- }
12841
- };
12842
-
12843
- _this.onPlayerPlaybackRateChange = function (event) {
12844
- return _this.props.onPlaybackRateChange(event);
12845
- };
12846
-
12847
- _this.onPlayerPlaybackQualityChange = function (event) {
12848
- return _this.props.onPlaybackQualityChange(event);
12849
- };
12850
-
12851
- _this.createPlayer = function () {
12852
- // do not attempt to create a player server-side, it won't work
12853
- if (typeof document === 'undefined') return;
12854
- // create player
12855
- var playerOpts = _extends$3({}, _this.props.opts, {
12856
- // preload the `videoId` video if one is already given
12857
- videoId: _this.props.videoId
12858
- });
12859
- _this.internalPlayer = youTubePlayer(_this.container, playerOpts);
12860
- // attach event handlers
12861
- _this.internalPlayer.on('ready', _this.onPlayerReady);
12862
- _this.internalPlayer.on('error', _this.onPlayerError);
12863
- _this.internalPlayer.on('stateChange', _this.onPlayerStateChange);
12864
- _this.internalPlayer.on('playbackRateChange', _this.onPlayerPlaybackRateChange);
12865
- _this.internalPlayer.on('playbackQualityChange', _this.onPlayerPlaybackQualityChange);
12866
- };
12867
-
12868
- _this.resetPlayer = function () {
12869
- return _this.internalPlayer.destroy().then(_this.createPlayer);
12870
- };
12871
-
12872
- _this.updatePlayer = function () {
12873
- _this.internalPlayer.getIframe().then(function (iframe) {
12874
- if (_this.props.id) iframe.setAttribute('id', _this.props.id);else iframe.removeAttribute('id');
12875
- if (_this.props.className) iframe.setAttribute('class', _this.props.className);else iframe.removeAttribute('class');
12876
- });
12877
- };
12878
-
12879
- _this.updateVideo = function () {
12880
- if (typeof _this.props.videoId === 'undefined' || _this.props.videoId === null) {
12881
- _this.internalPlayer.stopVideo();
12882
- return;
12883
- }
12884
-
12885
- // set queueing options
12886
- var autoplay = false;
12887
- var opts = {
12888
- videoId: _this.props.videoId
12889
- };
12890
- if ('playerVars' in _this.props.opts) {
12891
- autoplay = _this.props.opts.playerVars.autoplay === 1;
12892
- if ('start' in _this.props.opts.playerVars) {
12893
- opts.startSeconds = _this.props.opts.playerVars.start;
12894
- }
12895
- if ('end' in _this.props.opts.playerVars) {
12896
- opts.endSeconds = _this.props.opts.playerVars.end;
12897
- }
12898
- }
12899
-
12900
- // if autoplay is enabled loadVideoById
12901
- if (autoplay) {
12902
- _this.internalPlayer.loadVideoById(opts);
12903
- return;
12904
- }
12905
- // default behaviour just cues the video
12906
- _this.internalPlayer.cueVideoById(opts);
12907
- };
12908
-
12909
- _this.refContainer = function (container) {
12910
- _this.container = container;
12911
- };
12912
-
12913
- _this.container = null;
12914
- _this.internalPlayer = null;
12915
- return _this;
12916
- }
12917
-
12918
- /**
12919
- * Expose PlayerState constants for convenience. These constants can also be
12920
- * accessed through the global YT object after the YouTube IFrame API is instantiated.
12921
- * https://developers.google.com/youtube/iframe_api_reference#onStateChange
12922
- */
12923
-
12924
-
12925
- _createClass(YouTube, [{
12926
- key: 'componentDidMount',
12927
- value: function componentDidMount() {
12928
- this.createPlayer();
12929
- }
12930
- }, {
12931
- key: 'componentDidUpdate',
12932
- value: function componentDidUpdate(prevProps) {
12933
- if (shouldUpdatePlayer(prevProps, this.props)) {
12934
- this.updatePlayer();
12935
- }
12936
-
12937
- if (shouldResetPlayer(prevProps, this.props)) {
12938
- this.resetPlayer();
12939
- }
12940
-
12941
- if (shouldUpdateVideo(prevProps, this.props)) {
12942
- this.updateVideo();
12943
- }
12944
- }
12945
- }, {
12946
- key: 'componentWillUnmount',
12947
- value: function componentWillUnmount() {
12948
- /**
12949
- * Note: The `youtube-player` package that is used promisifies all Youtube
12950
- * Player API calls, which introduces a delay of a tick before it actually
12951
- * gets destroyed. Since React attempts to remove the element instantly
12952
- * this method isn't quick enough to reset the container element.
12953
- */
12954
- this.internalPlayer.destroy();
12955
- }
12956
-
12957
- /**
12958
- * https://developers.google.com/youtube/iframe_api_reference#onReady
12959
- *
12960
- * @param {Object} event
12961
- * @param {Object} target - player object
12962
- */
12963
-
12964
-
12965
- /**
12966
- * https://developers.google.com/youtube/iframe_api_reference#onError
12967
- *
12968
- * @param {Object} event
12969
- * @param {Integer} data - error type
12970
- * @param {Object} target - player object
12971
- */
12972
-
12973
-
12974
- /**
12975
- * https://developers.google.com/youtube/iframe_api_reference#onStateChange
12976
- *
12977
- * @param {Object} event
12978
- * @param {Integer} data - status change type
12979
- * @param {Object} target - actual YT player
12980
- */
12981
-
12982
-
12983
- /**
12984
- * https://developers.google.com/youtube/iframe_api_reference#onPlaybackRateChange
12985
- *
12986
- * @param {Object} event
12987
- * @param {Float} data - playback rate
12988
- * @param {Object} target - actual YT player
12989
- */
12990
-
12991
-
12992
- /**
12993
- * https://developers.google.com/youtube/iframe_api_reference#onPlaybackQualityChange
12994
- *
12995
- * @param {Object} event
12996
- * @param {String} data - playback quality
12997
- * @param {Object} target - actual YT player
12998
- */
12999
-
13000
-
13001
- /**
13002
- * Initialize the Youtube Player API on the container and attach event handlers
13003
- */
13004
-
13005
-
13006
- /**
13007
- * Shorthand for destroying and then re-creating the Youtube Player
13008
- */
13009
-
13010
-
13011
- /**
13012
- * Method to update the id and class of the Youtube Player iframe.
13013
- * React should update this automatically but since the Youtube Player API
13014
- * replaced the DIV that is mounted by React we need to do this manually.
13015
- */
13016
-
13017
-
13018
- /**
13019
- * Call Youtube Player API methods to update the currently playing video.
13020
- * Depeding on the `opts.playerVars.autoplay` this function uses one of two
13021
- * Youtube Player API methods to update the video.
13022
- */
13023
-
13024
- }, {
13025
- key: 'render',
13026
- value: function render() {
13027
- return React__default.createElement(
13028
- 'div',
13029
- { className: this.props.containerClassName },
13030
- React__default.createElement('div', { id: this.props.id, className: this.props.className, ref: this.refContainer })
13031
- );
13032
- }
13033
- }]);
13034
-
13035
- return YouTube;
13036
- }(React__default.Component);
13037
-
13038
- YouTube.propTypes = {
13039
- videoId: PropTypes.string,
13040
-
13041
- // custom ID for player element
13042
- id: PropTypes.string,
13043
-
13044
- // custom class name for player element
13045
- className: PropTypes.string,
13046
- // custom class name for player container element
13047
- containerClassName: PropTypes.string,
13048
-
13049
- // https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
13050
- opts: PropTypes.objectOf(PropTypes.any),
13051
-
13052
- // event subscriptions
13053
- onReady: PropTypes.func,
13054
- onError: PropTypes.func,
13055
- onPlay: PropTypes.func,
13056
- onPause: PropTypes.func,
13057
- onEnd: PropTypes.func,
13058
- onStateChange: PropTypes.func,
13059
- onPlaybackRateChange: PropTypes.func,
13060
- onPlaybackQualityChange: PropTypes.func
13061
- };
13062
- YouTube.defaultProps = {
13063
- id: null,
13064
- className: null,
13065
- opts: {},
13066
- containerClassName: '',
13067
- onReady: function onReady() {},
13068
- onError: function onError() {},
13069
- onPlay: function onPlay() {},
13070
- onPause: function onPause() {},
13071
- onEnd: function onEnd() {},
13072
- onStateChange: function onStateChange() {},
13073
- onPlaybackRateChange: function onPlaybackRateChange() {},
13074
- onPlaybackQualityChange: function onPlaybackQualityChange() {}
13075
- };
13076
- YouTube.PlayerState = {
13077
- UNSTARTED: -1,
13078
- ENDED: 0,
13079
- PLAYING: 1,
13080
- PAUSED: 2,
13081
- BUFFERING: 3,
13082
- CUED: 5
13083
- };
13084
-
13085
- var Youtube = function Youtube(props) {
13086
- var youtubeThumbnail = require('youtube-thumbnail');
13087
- var thumbnail1 = youtubeThumbnail('https://www.youtube.com/watch?v=5AlrMieL_Gg');
13088
- var thumbnail2 = youtubeThumbnail('https://www.youtube.com/watch?v=72RUDa7HvpE');
13089
- var thumbnail3 = youtubeThumbnail('https://www.youtube.com/watch?v=GpaPNBptW2E');
13090
- var thumbnail4 = youtubeThumbnail('https://www.youtube.com/watch?v=R7WO9YuXXs4');
13091
-
13092
- var url$$1 = props.url;
13093
-
13094
- var id = getYoutubeId(url$$1);
13095
-
13096
- return React__default.createElement(
13097
- 'div',
13098
- null,
13099
- React__default.createElement(YouTube, { videoId: id, className: 'youtube' }),
13100
- React__default.createElement(
13101
- 'div',
13102
- {
13103
- style: {
13104
- display: 'flex',
13105
- flexDirection: 'row',
13106
- justifyContent: 'flex-start',
13107
- width: '100%',
13108
- overflow: 'hidden'
13109
- } },
13110
- React__default.createElement(
13111
- 'div',
13112
- { style: { flex: '1 0 25%' } },
13113
- React__default.createElement('img', { src: thumbnail1.high.url, style: { width: '100%', border: '1px solid white' } })
13114
- ),
13115
- React__default.createElement(
13116
- 'div',
13117
- { style: { flex: '1 0 25%' } },
13118
- React__default.createElement('img', { src: thumbnail2.high.url, style: { width: '100%', border: '1px solid white' } })
13119
- ),
13120
- React__default.createElement(
13121
- 'div',
13122
- { style: { flex: '1 0 25%' } },
13123
- React__default.createElement('img', { src: thumbnail3.high.url, style: { width: '100%', border: '1px solid white' } })
13124
- ),
13125
- React__default.createElement(
13126
- 'div',
13127
- { style: { flex: '1 0 25%' } },
13128
- React__default.createElement('img', { src: thumbnail4.high.url, style: { width: '100%', border: '1px solid white' } })
13129
- )
13130
- )
13131
- );
13132
- };
13133
-
13134
- export { Content as DeckContent, Queue as DeckQueue, Column2, Column3, Header, LeftNav, Magazine as NavMagazine, Native as NavNative, Normal as NavNormal, Youtube as YoutubePlayer };
11234
+ export { Content as DeckContent, Queue as DeckQueue, Column2, Column3, Header, LeftNav, Magazine as NavMagazine, Native as NavNative, Normal as NavNormal };
13135
11235
  //# sourceMappingURL=index.es.js.map