@micromag/element-audio 0.3.832 → 0.4.4
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/assets/css/styles.css +3 -3
- package/es/index.d.ts +23 -0
- package/es/index.js +43 -113
- package/es/styles.css +3 -0
- package/package.json +16 -15
package/assets/css/styles.css
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.
|
|
2
|
-
.
|
|
3
|
-
.
|
|
1
|
+
.container{height:100%;position:relative;width:100%}.container .seekButton{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;height:100%;left:0;padding:0;position:absolute;top:0;-ms-touch-action:none;touch-action:none;width:100%}
|
|
2
|
+
.container .wave{height:150px}.container .wave.withAutoHeight{height:100%}
|
|
3
|
+
.container{height:100px;position:relative;-ms-touch-action:pan-y;touch-action:pan-y}.container .button,.container .canvasBackground,.container .canvasProgress{height:100%;left:0;position:absolute;top:0;width:100%}.container .button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;position:relative}
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Color } from '@micromag/core';
|
|
3
|
+
|
|
4
|
+
declare const _default: any;
|
|
5
|
+
|
|
6
|
+
interface AudioWaveProps {
|
|
7
|
+
currentTime?: number | null;
|
|
8
|
+
duration?: number | null;
|
|
9
|
+
playing?: boolean;
|
|
10
|
+
sampleWidth?: number;
|
|
11
|
+
sampleMargin?: number;
|
|
12
|
+
minSampleHeight?: number;
|
|
13
|
+
backgroundColor?: Color;
|
|
14
|
+
progressColor?: Color | null;
|
|
15
|
+
audioLevels?: number[] | null;
|
|
16
|
+
className?: string | null;
|
|
17
|
+
onSeek?: ((...args: unknown[]) => void) | null;
|
|
18
|
+
onResume?: ((...args: unknown[]) => void) | null;
|
|
19
|
+
onReady?: ((...args: unknown[]) => void) | null;
|
|
20
|
+
}
|
|
21
|
+
declare function AudioWave({ currentTime, duration, playing, sampleWidth, sampleMargin, minSampleHeight, backgroundColor, progressColor, audioLevels, className, onSeek, onResume, onReady, }: AudioWaveProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
export { AudioWave, _default as default };
|
package/es/index.js
CHANGED
|
@@ -3,9 +3,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import isFunction from 'lodash/isFunction';
|
|
5
5
|
import isNumber from 'lodash/isNumber';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
6
|
import React, { useState, useMemo, useCallback, useRef, useEffect } from 'react';
|
|
8
|
-
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
9
7
|
import { useDimensionObserver, useMediaCurrentTime, useMediaReady, useMediaDuration, useMediaLoad, useProgressSteps, useDevicePixelRatio } from '@micromag/core/hooks';
|
|
10
8
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
11
9
|
import { useGesture } from '@use-gesture/react';
|
|
@@ -14,33 +12,21 @@ import { useSpring } from '@react-spring/core';
|
|
|
14
12
|
import { animated } from '@react-spring/web';
|
|
15
13
|
import { getContrastingColor } from '@micromag/core/utils';
|
|
16
14
|
|
|
17
|
-
var styles$2 = {"container":"
|
|
15
|
+
var styles$2 = {"container":"container","seekButton":"seekButton"};
|
|
18
16
|
|
|
19
|
-
var propTypes$2 = {
|
|
20
|
-
progress: PropTypes.number,
|
|
21
|
-
duration: PropTypes.number,
|
|
22
|
-
playing: PropTypes.bool,
|
|
23
|
-
seek: PropTypes.func,
|
|
24
|
-
play: PropTypes.func,
|
|
25
|
-
// onReady: PropTypes.func,
|
|
26
|
-
className: PropTypes.string
|
|
27
|
-
};
|
|
28
|
-
var defaultProps$1 = {
|
|
29
|
-
progress: 0,
|
|
30
|
-
duration: 0,
|
|
31
|
-
playing: false,
|
|
32
|
-
seek: null,
|
|
33
|
-
play: null,
|
|
34
|
-
// onReady: null,
|
|
35
|
-
className: null
|
|
36
|
-
};
|
|
37
17
|
function AudioBars(_ref) {
|
|
38
|
-
var progress = _ref.progress,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
18
|
+
var _ref$progress = _ref.progress,
|
|
19
|
+
progress = _ref$progress === void 0 ? 0 : _ref$progress,
|
|
20
|
+
_ref$playing = _ref.playing,
|
|
21
|
+
playing = _ref$playing === void 0 ? false : _ref$playing,
|
|
22
|
+
_ref$duration = _ref.duration,
|
|
23
|
+
duration = _ref$duration === void 0 ? 0 : _ref$duration,
|
|
24
|
+
_ref$seek = _ref.seek,
|
|
25
|
+
seek = _ref$seek === void 0 ? null : _ref$seek,
|
|
26
|
+
_ref$play = _ref.play,
|
|
27
|
+
play = _ref$play === void 0 ? null : _ref$play,
|
|
28
|
+
_ref$className = _ref.className,
|
|
29
|
+
className = _ref$className === void 0 ? null : _ref$className;
|
|
44
30
|
var intl = useIntl();
|
|
45
31
|
var _useDimensionObserver = useDimensionObserver(),
|
|
46
32
|
elRef = _useDimensionObserver.ref,
|
|
@@ -172,46 +158,10 @@ function AudioBars(_ref) {
|
|
|
172
158
|
})
|
|
173
159
|
})));
|
|
174
160
|
}
|
|
175
|
-
AudioBars.propTypes = propTypes$2;
|
|
176
|
-
AudioBars.defaultProps = defaultProps$1;
|
|
177
161
|
|
|
178
|
-
var styles$1 = {"container":"
|
|
162
|
+
var styles$1 = {"container":"container","wave":"wave","withAutoHeight":"withAutoHeight"};
|
|
179
163
|
|
|
180
|
-
|
|
181
|
-
media: PropTypes$1.audioMedia,
|
|
182
|
-
mediaRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
183
|
-
current: PropTypes.any
|
|
184
|
-
})]),
|
|
185
|
-
muted: PropTypes.bool,
|
|
186
|
-
autoPlay: PropTypes.bool,
|
|
187
|
-
paused: PropTypes.bool,
|
|
188
|
-
loop: PropTypes.bool,
|
|
189
|
-
preload: PropTypes.oneOf(['auto', 'none', 'metadata']),
|
|
190
|
-
shouldLoad: PropTypes.bool,
|
|
191
|
-
waveFake: PropTypes.bool,
|
|
192
|
-
// waveProps: PropTypes.shape({
|
|
193
|
-
// sampleWidth: PropTypes.number,
|
|
194
|
-
// sampleMargin: PropTypes.number,
|
|
195
|
-
// minSampleHeight: PropTypes.number,
|
|
196
|
-
// }),
|
|
197
|
-
withWave: PropTypes.bool,
|
|
198
|
-
autoWaveHeight: PropTypes.bool,
|
|
199
|
-
// reduceBufferFactor: PropTypes.number,
|
|
200
|
-
updateInterval: PropTypes.number,
|
|
201
|
-
withoutSeek: PropTypes.bool,
|
|
202
|
-
className: PropTypes.string,
|
|
203
|
-
onReady: PropTypes.func,
|
|
204
|
-
onPlay: PropTypes.func,
|
|
205
|
-
onPause: PropTypes.func,
|
|
206
|
-
onEnded: PropTypes.func,
|
|
207
|
-
onSeeked: PropTypes.func,
|
|
208
|
-
onTimeUpdate: PropTypes.func,
|
|
209
|
-
onProgressStep: PropTypes.func,
|
|
210
|
-
onDurationChange: PropTypes.func,
|
|
211
|
-
onVolumeChange: PropTypes.func,
|
|
212
|
-
onPlayError: PropTypes.func
|
|
213
|
-
};
|
|
214
|
-
var Audio = function Audio(_ref) {
|
|
164
|
+
function Audio(_ref) {
|
|
215
165
|
var _ref$media = _ref.media,
|
|
216
166
|
media = _ref$media === void 0 ? null : _ref$media,
|
|
217
167
|
_ref$mediaRef = _ref.mediaRef,
|
|
@@ -401,60 +351,42 @@ var Audio = function Audio(_ref) {
|
|
|
401
351
|
seek: !withoutSeek ? onWaveSeek : null,
|
|
402
352
|
play: onWavePlay
|
|
403
353
|
}) : null);
|
|
404
|
-
}
|
|
405
|
-
Audio.propTypes = propTypes$1;
|
|
354
|
+
}
|
|
406
355
|
var Audio_default = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
407
356
|
return /*#__PURE__*/React.createElement(Audio, Object.assign({
|
|
408
357
|
mediaRef: ref
|
|
409
358
|
}, props));
|
|
410
359
|
});
|
|
411
360
|
|
|
412
|
-
var styles = {"container":"
|
|
361
|
+
var styles = {"container":"container","canvasBackground":"canvasBackground","canvasProgress":"canvasProgress"};
|
|
413
362
|
|
|
414
|
-
var propTypes = {
|
|
415
|
-
currentTime: PropTypes.number,
|
|
416
|
-
duration: PropTypes.number,
|
|
417
|
-
playing: PropTypes.bool,
|
|
418
|
-
sampleWidth: PropTypes.number,
|
|
419
|
-
sampleMargin: PropTypes.number,
|
|
420
|
-
minSampleHeight: PropTypes.number,
|
|
421
|
-
backgroundColor: PropTypes$1.color,
|
|
422
|
-
progressColor: PropTypes$1.color,
|
|
423
|
-
audioLevels: PropTypes.arrayOf(PropTypes.number),
|
|
424
|
-
className: PropTypes.string,
|
|
425
|
-
onSeek: PropTypes.func,
|
|
426
|
-
onResume: PropTypes.func,
|
|
427
|
-
onReady: PropTypes.func
|
|
428
|
-
};
|
|
429
|
-
var defaultProps = {
|
|
430
|
-
currentTime: null,
|
|
431
|
-
duration: null,
|
|
432
|
-
playing: false,
|
|
433
|
-
sampleWidth: 3,
|
|
434
|
-
sampleMargin: 1,
|
|
435
|
-
minSampleHeight: 2,
|
|
436
|
-
backgroundColor: 'white',
|
|
437
|
-
progressColor: null,
|
|
438
|
-
audioLevels: null,
|
|
439
|
-
className: null,
|
|
440
|
-
onSeek: null,
|
|
441
|
-
onResume: null,
|
|
442
|
-
onReady: null
|
|
443
|
-
};
|
|
444
363
|
function AudioWave(_ref) {
|
|
445
|
-
var currentTime = _ref.currentTime,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
364
|
+
var _ref$currentTime = _ref.currentTime,
|
|
365
|
+
currentTime = _ref$currentTime === void 0 ? null : _ref$currentTime,
|
|
366
|
+
_ref$duration = _ref.duration,
|
|
367
|
+
duration = _ref$duration === void 0 ? null : _ref$duration,
|
|
368
|
+
_ref$playing = _ref.playing,
|
|
369
|
+
playing = _ref$playing === void 0 ? false : _ref$playing,
|
|
370
|
+
_ref$sampleWidth = _ref.sampleWidth,
|
|
371
|
+
sampleWidth = _ref$sampleWidth === void 0 ? 3 : _ref$sampleWidth,
|
|
372
|
+
_ref$sampleMargin = _ref.sampleMargin,
|
|
373
|
+
sampleMargin = _ref$sampleMargin === void 0 ? 1 : _ref$sampleMargin,
|
|
374
|
+
_ref$minSampleHeight = _ref.minSampleHeight,
|
|
375
|
+
minSampleHeight = _ref$minSampleHeight === void 0 ? 2 : _ref$minSampleHeight,
|
|
376
|
+
_ref$backgroundColor = _ref.backgroundColor,
|
|
377
|
+
backgroundColor = _ref$backgroundColor === void 0 ? 'white' : _ref$backgroundColor,
|
|
378
|
+
_ref$progressColor = _ref.progressColor,
|
|
379
|
+
progressColor = _ref$progressColor === void 0 ? null : _ref$progressColor,
|
|
380
|
+
_ref$audioLevels = _ref.audioLevels,
|
|
381
|
+
audioLevels = _ref$audioLevels === void 0 ? null : _ref$audioLevels,
|
|
382
|
+
_ref$className = _ref.className,
|
|
383
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
384
|
+
_ref$onSeek = _ref.onSeek,
|
|
385
|
+
onSeek = _ref$onSeek === void 0 ? null : _ref$onSeek,
|
|
386
|
+
_ref$onResume = _ref.onResume,
|
|
387
|
+
onResume = _ref$onResume === void 0 ? null : _ref$onResume,
|
|
388
|
+
_ref$onReady = _ref.onReady,
|
|
389
|
+
onReady = _ref$onReady === void 0 ? null : _ref$onReady;
|
|
458
390
|
var canvasBackgroundRef = useRef(null);
|
|
459
391
|
var canvasProgressRef = useRef(null);
|
|
460
392
|
var mainColor = useMemo(function () {
|
|
@@ -630,7 +562,5 @@ function AudioWave(_ref) {
|
|
|
630
562
|
}
|
|
631
563
|
}));
|
|
632
564
|
}
|
|
633
|
-
AudioWave.propTypes = propTypes;
|
|
634
|
-
AudioWave.defaultProps = defaultProps;
|
|
635
565
|
|
|
636
566
|
export { AudioWave, Audio_default as default };
|
package/es/styles.css
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
.container{height:100%;position:relative;width:100%}.container .seekButton{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;height:100%;left:0;padding:0;position:absolute;top:0;-ms-touch-action:none;touch-action:none;width:100%}
|
|
2
|
+
.container .wave{height:150px}.container .wave.withAutoHeight{height:100%}
|
|
3
|
+
.container{height:100px;position:relative;-ms-touch-action:pan-y;touch-action:pan-y}.container .button,.container .canvasBackground,.container .canvasProgress{height:100%;left:0;position:absolute;top:0;width:100%}.container .button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-block;font-family:inherit;padding:0;position:relative}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-audio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"type": "module",
|
|
34
34
|
"module": "es/index.js",
|
|
35
|
+
"types": "es/index.d.ts",
|
|
35
36
|
"exports": {
|
|
36
37
|
".": {
|
|
37
|
-
"import": "./es/index.js"
|
|
38
|
+
"import": "./es/index.js",
|
|
39
|
+
"types": "./es/index.d.ts"
|
|
38
40
|
},
|
|
39
41
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
40
42
|
"./assets/css/styles.css": "./assets/css/styles.css"
|
|
@@ -47,32 +49,31 @@
|
|
|
47
49
|
"scripts": {
|
|
48
50
|
"clean": "rm -rf es && rm -rf lib && rm -rf assets",
|
|
49
51
|
"prepublishOnly": "npm run build",
|
|
50
|
-
"build": "../../scripts/prepare-package.sh"
|
|
52
|
+
"build": "../../scripts/prepare-package.sh --types"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"react": "^
|
|
54
|
-
"react-dom": "^
|
|
55
|
+
"react": "^19.2.0",
|
|
56
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
|
-
"react": "^
|
|
58
|
-
"react-dom": "^
|
|
59
|
+
"react": "^19.2.0",
|
|
60
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
59
61
|
},
|
|
60
62
|
"dependencies": {
|
|
61
63
|
"@babel/runtime": "^7.13.10",
|
|
62
|
-
"@micromag/core": "^0.
|
|
63
|
-
"@micromag/element-closed-captions": "^0.
|
|
64
|
-
"@react-spring/core": "^
|
|
65
|
-
"@react-spring/web": "^
|
|
64
|
+
"@micromag/core": "^0.4.4",
|
|
65
|
+
"@micromag/element-closed-captions": "^0.4.4",
|
|
66
|
+
"@react-spring/core": "^10.0.3",
|
|
67
|
+
"@react-spring/web": "^10.0.3",
|
|
66
68
|
"@use-gesture/react": "^10.3.0",
|
|
67
69
|
"classnames": "^2.2.6",
|
|
68
|
-
"lodash": "^4.17.
|
|
69
|
-
"
|
|
70
|
-
"react-intl": "^6.6.4",
|
|
70
|
+
"lodash": "^4.17.23",
|
|
71
|
+
"react-intl": "^8.1.3",
|
|
71
72
|
"uuid": "^9.0.0"
|
|
72
73
|
},
|
|
73
74
|
"publishConfig": {
|
|
74
75
|
"access": "public",
|
|
75
76
|
"registry": "https://registry.npmjs.org/"
|
|
76
77
|
},
|
|
77
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "04b8519c3a3ddace5a21497e22faa11865d57f6d"
|
|
78
79
|
}
|