apm-react-audio-player 1.0.24 → 1.0.25

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.
Files changed (2) hide show
  1. package/dist/index.js +92 -103
  2. package/package.json +16 -10
package/dist/index.js CHANGED
@@ -1,75 +1,64 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
3
  var React = require('react');
8
- var React__default = _interopDefault(React);
9
4
 
10
- function _iterableToArrayLimit(arr, i) {
11
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
12
- if (null != _i) {
13
- var _s,
14
- _e,
15
- _x,
16
- _r,
17
- _arr = [],
18
- _n = !0,
19
- _d = !1;
5
+ function _arrayLikeToArray(r, a) {
6
+ (null == a || a > r.length) && (a = r.length);
7
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
+ return n;
9
+ }
10
+ function _arrayWithHoles(r) {
11
+ if (Array.isArray(r)) return r;
12
+ }
13
+ function _extends() {
14
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
15
+ for (var e = 1; e < arguments.length; e++) {
16
+ var t = arguments[e];
17
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
18
+ }
19
+ return n;
20
+ }, _extends.apply(null, arguments);
21
+ }
22
+ function _iterableToArrayLimit(r, l) {
23
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
24
+ if (null != t) {
25
+ var e,
26
+ n,
27
+ i,
28
+ u,
29
+ a = [],
30
+ f = !0,
31
+ o = !1;
20
32
  try {
21
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
22
- if (Object(_i) !== _i) return;
23
- _n = !1;
24
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
25
- } catch (err) {
26
- _d = !0, _e = err;
33
+ if (i = (t = t.call(r)).next, 0 === l) {
34
+ if (Object(t) !== t) return;
35
+ f = !1;
36
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
37
+ } catch (r) {
38
+ o = !0, n = r;
27
39
  } finally {
28
40
  try {
29
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
41
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
30
42
  } finally {
31
- if (_d) throw _e;
43
+ if (o) throw n;
32
44
  }
33
45
  }
34
- return _arr;
46
+ return a;
35
47
  }
36
48
  }
37
- function _extends() {
38
- _extends = Object.assign ? Object.assign.bind() : function (target) {
39
- for (var i = 1; i < arguments.length; i++) {
40
- var source = arguments[i];
41
- for (var key in source) {
42
- if (Object.prototype.hasOwnProperty.call(source, key)) {
43
- target[key] = source[key];
44
- }
45
- }
46
- }
47
- return target;
48
- };
49
- return _extends.apply(this, arguments);
50
- }
51
- function _slicedToArray(arr, i) {
52
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
53
- }
54
- function _arrayWithHoles(arr) {
55
- if (Array.isArray(arr)) return arr;
56
- }
57
- function _unsupportedIterableToArray(o, minLen) {
58
- if (!o) return;
59
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
60
- var n = Object.prototype.toString.call(o).slice(8, -1);
61
- if (n === "Object" && o.constructor) n = o.constructor.name;
62
- if (n === "Map" || n === "Set") return Array.from(o);
63
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
64
- }
65
- function _arrayLikeToArray(arr, len) {
66
- if (len == null || len > arr.length) len = arr.length;
67
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
68
- return arr2;
69
- }
70
49
  function _nonIterableRest() {
71
50
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
72
51
  }
52
+ function _slicedToArray(r, e) {
53
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
54
+ }
55
+ function _unsupportedIterableToArray(r, a) {
56
+ if (r) {
57
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
58
+ var t = {}.toString.call(r).slice(8, -1);
59
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
60
+ }
61
+ }
73
62
 
74
63
  var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtrl) {
75
64
  var _useState = React.useState(false),
@@ -111,7 +100,7 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
111
100
  var updateCurrentTime = function updateCurrentTime() {
112
101
  setCurrentTime(progressBarRef.current.value);
113
102
  };
114
- var whilePlaying = function whilePlaying() {
103
+ var _whilePlaying = function whilePlaying() {
115
104
  var _audioRef$current2;
116
105
  if (!(audioRef !== null && audioRef !== void 0 && (_audioRef$current2 = audioRef.current) !== null && _audioRef$current2 !== void 0 && _audioRef$current2.currentSrc.includes('stream'))) {
117
106
  // isStream isn't correct here
@@ -127,7 +116,7 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
127
116
  setIsFinishedPlaying(true);
128
117
  return;
129
118
  }
130
- animationRef.current = window.requestAnimationFrame(whilePlaying);
119
+ animationRef.current = window.requestAnimationFrame(_whilePlaying);
131
120
  };
132
121
  var pause = function pause() {
133
122
  setIsPlaying(false);
@@ -147,7 +136,7 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
147
136
  audioRef.current.play();
148
137
  if (!audioRef.current.currentSrc.includes('stream')) {
149
138
  // isStream isn't correctly set here
150
- animationRef.current = window.requestAnimationFrame(whilePlaying);
139
+ animationRef.current = window.requestAnimationFrame(_whilePlaying);
151
140
  }
152
141
  };
153
142
  var toggleMute = function toggleMute() {
@@ -229,7 +218,7 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
229
218
  };
230
219
 
231
220
  var Play = function Play() {
232
- return /*#__PURE__*/React__default.createElement("svg", {
221
+ return /*#__PURE__*/React.createElement("svg", {
233
222
  stroke: "currentColor",
234
223
  fill: "currentColor",
235
224
  strokeWidth: "0",
@@ -240,17 +229,17 @@ var Play = function Play() {
240
229
  xmlns: "http://www.w3.org/2000/svg",
241
230
  role: "img",
242
231
  "aria-labelledby": "play playButton"
243
- }, /*#__PURE__*/React__default.createElement("title", {
232
+ }, /*#__PURE__*/React.createElement("title", {
244
233
  id: "play"
245
- }, "Play"), /*#__PURE__*/React__default.createElement("desc", {
234
+ }, "Play"), /*#__PURE__*/React.createElement("desc", {
246
235
  id: "playButton"
247
- }, "Play Button"), /*#__PURE__*/React__default.createElement("path", {
236
+ }, "Play Button"), /*#__PURE__*/React.createElement("path", {
248
237
  d: "M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"
249
238
  }));
250
239
  };
251
240
 
252
241
  var Pause = function Pause() {
253
- return /*#__PURE__*/React__default.createElement("svg", {
242
+ return /*#__PURE__*/React.createElement("svg", {
254
243
  stroke: "currentColor",
255
244
  fill: "currentColor",
256
245
  strokeWidth: "0",
@@ -260,11 +249,11 @@ var Pause = function Pause() {
260
249
  xmlns: "http://www.w3.org/2000/svg",
261
250
  role: "img",
262
251
  "aria-labelledby": "pause pauseButton"
263
- }, /*#__PURE__*/React__default.createElement("title", {
252
+ }, /*#__PURE__*/React.createElement("title", {
264
253
  id: "pause"
265
- }, "Pause"), /*#__PURE__*/React__default.createElement("desc", {
254
+ }, "Pause"), /*#__PURE__*/React.createElement("desc", {
266
255
  id: "pauseButton"
267
- }, "Pause Button"), /*#__PURE__*/React__default.createElement("path", {
256
+ }, "Pause Button"), /*#__PURE__*/React.createElement("path", {
268
257
  d: "M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z"
269
258
  }));
270
259
  };
@@ -299,36 +288,36 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
299
288
  prefix = props.prefix;
300
289
  var audioDuration = duration && !isNaN(duration) && calculateTime(duration);
301
290
  var formatDuration = duration && !isNaN(duration) && audioDuration && formatCalculateTime(audioDuration);
302
- return audioSrc && /*#__PURE__*/React__default.createElement("div", {
291
+ return audioSrc && /*#__PURE__*/React.createElement("div", {
303
292
  className: "audioPlayer",
304
293
  style: customStyles && customStyles.audioPlayer
305
- }, /*#__PURE__*/React__default.createElement("audio", {
294
+ }, /*#__PURE__*/React.createElement("audio", {
306
295
  ref: audioPlayerRef,
307
296
  src: audioSrc,
308
297
  preload: "none",
309
298
  onLoadedMetadata: onLoadedMetadata,
310
299
  muted: isMuted
311
- }), /*#__PURE__*/React__default.createElement("div", {
300
+ }), /*#__PURE__*/React.createElement("div", {
312
301
  className: "player-layout"
313
- }, volumeCtrl && /*#__PURE__*/React__default.createElement("div", {
302
+ }, volumeCtrl && /*#__PURE__*/React.createElement("div", {
314
303
  className: "player-controls-secondary-outer"
315
- }, /*#__PURE__*/React__default.createElement("div", {
304
+ }, /*#__PURE__*/React.createElement("div", {
316
305
  className: "player-volume-control"
317
- }, /*#__PURE__*/React__default.createElement("div", {
306
+ }, /*#__PURE__*/React.createElement("div", {
318
307
  className: "player-volume-icon"
319
- }, /*#__PURE__*/React__default.createElement("button", {
308
+ }, /*#__PURE__*/React.createElement("button", {
320
309
  onClick: toggleMute,
321
310
  "aria-label": isMuted === true ? 'Muted' : 'Not Muted',
322
311
  title: isMuted === true ? 'Muted' : 'Not Muted'
323
- }, !isMuted ? /*#__PURE__*/React__default.createElement("img", {
312
+ }, !isMuted ? /*#__PURE__*/React.createElement("img", {
324
313
  src: "/img/icon-volume-low.svg",
325
314
  alt: "Volume Button"
326
- }) : /*#__PURE__*/React__default.createElement("img", {
315
+ }) : /*#__PURE__*/React.createElement("img", {
327
316
  src: "/img/icon-volume-mute.svg",
328
317
  alt: "Volume Mute Button"
329
- }))), /*#__PURE__*/React__default.createElement("div", {
318
+ }))), /*#__PURE__*/React.createElement("div", {
330
319
  className: "player-timeline player-controls-secondary"
331
- }, /*#__PURE__*/React__default.createElement("input", {
320
+ }, /*#__PURE__*/React.createElement("input", {
332
321
  id: "player-volume",
333
322
  type: "range",
334
323
  className: "player-volume-progress",
@@ -339,39 +328,39 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
339
328
  onChange: function onChange(e) {
340
329
  return volumeControl(e);
341
330
  }
342
- })), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("img", {
331
+ })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
343
332
  src: "/img/icon-volume-high.svg",
344
333
  alt: "Volume Button"
345
- }))), /*#__PURE__*/React__default.createElement("div", {
334
+ }))), /*#__PURE__*/React.createElement("div", {
346
335
  className: "player-volume-label"
347
- }, "Volume")), /*#__PURE__*/React__default.createElement("div", {
336
+ }, "Volume")), /*#__PURE__*/React.createElement("div", {
348
337
  className: "player-controls"
349
- }, !isLive && /*#__PURE__*/React__default.createElement("div", {
338
+ }, !isLive && /*#__PURE__*/React.createElement("div", {
350
339
  className: "player-backward-forward-controls"
351
- }, /*#__PURE__*/React__default.createElement("button", {
340
+ }, /*#__PURE__*/React.createElement("button", {
352
341
  onClick: rewindControl
353
- }, /*#__PURE__*/React__default.createElement("img", {
342
+ }, /*#__PURE__*/React.createElement("img", {
354
343
  src: "/img/icon-rewind-15.svg",
355
344
  alt: "Backward 15 seconds"
356
- }))), /*#__PURE__*/React__default.createElement("div", {
345
+ }))), /*#__PURE__*/React.createElement("div", {
357
346
  className: "".concat(isPlaying ? 'is-playing' : '', " player-btn-play-pause-outer")
358
- }, /*#__PURE__*/React__default.createElement("button", {
347
+ }, /*#__PURE__*/React.createElement("button", {
359
348
  onClick: togglePlaying,
360
349
  className: playBtnClass,
361
350
  style: customStyles && customStyles.playPause,
362
351
  id: "playbutton"
363
- }, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null))), !isLive && /*#__PURE__*/React__default.createElement("div", {
352
+ }, isPlaying ? /*#__PURE__*/React.createElement(Pause, null) : /*#__PURE__*/React.createElement(Play, null))), !isLive && /*#__PURE__*/React.createElement("div", {
364
353
  className: "player-backward-forward-controls"
365
- }, /*#__PURE__*/React__default.createElement("button", {
354
+ }, /*#__PURE__*/React.createElement("button", {
366
355
  onClick: forwardControl
367
- }, /*#__PURE__*/React__default.createElement("img", {
356
+ }, /*#__PURE__*/React.createElement("img", {
368
357
  src: "/img/icon-forward-15.svg",
369
358
  alt: "Forward 15 seconds"
370
- })))), !isLive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
359
+ })))), !isLive && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
371
360
  className: "player-timeline"
372
- }, /*#__PURE__*/React__default.createElement("div", {
361
+ }, /*#__PURE__*/React.createElement("div", {
373
362
  className: "player-timeline-progress-outer"
374
- }, /*#__PURE__*/React__default.createElement("input", {
363
+ }, /*#__PURE__*/React.createElement("input", {
375
364
  type: "range",
376
365
  className: "player-timeline-progress",
377
366
  defaultValue: "0",
@@ -379,24 +368,24 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
379
368
  onChange: changePlayerCurrentTime,
380
369
  "aria-label": "Audio progress",
381
370
  max: duration
382
- })), /*#__PURE__*/React__default.createElement("div", {
371
+ })), /*#__PURE__*/React.createElement("div", {
383
372
  className: "player-times"
384
- }, /*#__PURE__*/React__default.createElement("div", {
373
+ }, /*#__PURE__*/React.createElement("div", {
385
374
  className: "player-currentTime"
386
- }, calculateTime(currentTime)), /*#__PURE__*/React__default.createElement("div", {
375
+ }, calculateTime(currentTime)), /*#__PURE__*/React.createElement("div", {
387
376
  className: "player-duration",
388
377
  style: customStyles && customStyles.duration
389
- }, duration && !isNaN(duration) && calculateTime(duration))))), /*#__PURE__*/React__default.createElement("div", {
378
+ }, duration && !isNaN(duration) && calculateTime(duration))))), /*#__PURE__*/React.createElement("div", {
390
379
  className: "player-content"
391
- }, customHtml && customHtml, /*#__PURE__*/React__default.createElement("div", {
380
+ }, customHtml && customHtml, /*#__PURE__*/React.createElement("div", {
392
381
  className: "player-audio-type type-sm"
393
- }, isLive ? /*#__PURE__*/React__default.createElement("div", {
382
+ }, isLive ? /*#__PURE__*/React.createElement("div", {
394
383
  className: "player-live-label"
395
- }, prefix ? prefix : 'On Air') : /*#__PURE__*/React__default.createElement("div", {
384
+ }, prefix ? prefix : 'On Air') : /*#__PURE__*/React.createElement("div", {
396
385
  className: "player-label"
397
- }, "listen", /*#__PURE__*/React__default.createElement("div", {
386
+ }, "listen", /*#__PURE__*/React.createElement("div", {
398
387
  className: "player-label-duration"
399
- }, "[".concat(formatDuration, "]"))), /*#__PURE__*/React__default.createElement("div", {
388
+ }, "[".concat(formatDuration, "]"))), /*#__PURE__*/React.createElement("div", {
400
389
  className: "player-title"
401
390
  }, title || '', " ", subtitle && "by ".concat(subtitle), ' ')))));
402
391
  };
@@ -424,7 +413,7 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
424
413
  formatCalculateTime = _useAudioPlayer.formatCalculateTime,
425
414
  rewindControl = _useAudioPlayer.rewindControl,
426
415
  forwardControl = _useAudioPlayer.forwardControl;
427
- return /*#__PURE__*/React__default.createElement(ReactAudioPlayerInner, _extends({}, props, {
416
+ return /*#__PURE__*/React.createElement(ReactAudioPlayerInner, _extends({}, props, {
428
417
  audioPlayerRef: audioPlayerRef,
429
418
  progressBarRef: progressBarRef,
430
419
  isPlaying: isPlaying,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apm-react-audio-player",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "author": "Jason Phan <jphan@mpr.org>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -12,10 +12,10 @@
12
12
  "module": "dist/index.modern.js",
13
13
  "source": "src/index.js",
14
14
  "engines": {
15
- "node": ">=10"
15
+ "node": ">=20"
16
16
  },
17
17
  "scripts": {
18
- "build": "rollup -c",
18
+ "build": "rollup -c rollup.config.mjs",
19
19
  "dev": "rollup -c -w",
20
20
  "test": "jest --watch",
21
21
  "test:ci": "jest",
@@ -25,11 +25,14 @@
25
25
  "prettier:fix": "prettier --check '**/**.js' --write",
26
26
  "clean": "rm -rf node_modules dist package-lock.json yarn.lock"
27
27
  },
28
+ "assert": {
29
+ "type": "json"
30
+ },
28
31
  "peerDependencies": {
29
32
  "react": "^16.0.0"
30
33
  },
31
34
  "dependencies": {
32
- "rollup": "^1.17.0",
35
+ "rollup": "^4.29.1",
33
36
  "rollup-plugin-babel": "^4.3.3"
34
37
  },
35
38
  "devDependencies": {
@@ -50,14 +53,17 @@
50
53
  "eslint-plugin-promise": "^4.2.1",
51
54
  "eslint-plugin-react": "^7.17.0",
52
55
  "eslint-plugin-standard": "^4.0.1",
53
- "prettier": "^2.0.4",
54
- "react": "^16.13.1",
55
- "react-dom": "^16.13.1",
56
- "react-scripts": "^3.4.1",
57
- "rollup-plugin-json": "^4.0.0",
58
56
  "jest": "^24.8.0",
59
57
  "jest-environment-jsdom-fourteen": "^0.1.0",
60
- "jest-prop-type-error": "^1.1.0"
58
+ "jest-prop-type-error": "^1.1.0",
59
+ "prettier": "^2.0.4",
60
+ "react": "^18",
61
+ "react-dom": "^18",
62
+ "rollup-plugin-json": "^4.0.0"
63
+ },
64
+ "resolutions": {
65
+ "braces": ">=3.0.3",
66
+ "react-scripts": "^5.0.1"
61
67
  },
62
68
  "files": [
63
69
  "dist"