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