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