sceyt-chat-react-uikit 1.6.5-beta.4 → 1.6.5-beta.6
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/index.js +1955 -165
- package/index.modern.js +2194 -404
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10960,7 +10960,7 @@ var CustomInput = styled__default.input(_templateObject10 || (_templateObject10
|
|
|
10960
10960
|
}, function (props) {
|
|
10961
10961
|
return props.color;
|
|
10962
10962
|
}, function (props) {
|
|
10963
|
-
return props.error ? "1px solid " + props.errorColor :
|
|
10963
|
+
return props.error ? "1px solid " + props.errorColor : 'transparent';
|
|
10964
10964
|
}, function (props) {
|
|
10965
10965
|
return props.error ? "1px solid " + colors.errorBlur : props.theme !== THEME.DARK ? "2px solid " + props.borderColor : 'none';
|
|
10966
10966
|
}, colors.gray0, function (props) {
|
|
@@ -19160,7 +19160,7 @@ var Channel = function Channel(_ref) {
|
|
|
19160
19160
|
var _useColor = useColors(),
|
|
19161
19161
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
19162
19162
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
19163
|
-
|
|
19163
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND],
|
|
19164
19164
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
19165
19165
|
surface2 = _useColor[THEME_COLORS.SURFACE_2],
|
|
19166
19166
|
errorColor = _useColor[THEME_COLORS.WARNING],
|
|
@@ -19237,7 +19237,7 @@ var Channel = function Channel(_ref) {
|
|
|
19237
19237
|
theme: theme,
|
|
19238
19238
|
selectedChannel: channel.id === activeChannel.id,
|
|
19239
19239
|
selectedChannelLeftBorder: selectedChannelLeftBorder,
|
|
19240
|
-
selectedBackgroundColor: selectedChannelBackground ||
|
|
19240
|
+
selectedBackgroundColor: selectedChannelBackground || hoverBackground,
|
|
19241
19241
|
selectedChannelPaddings: selectedChannelPaddings,
|
|
19242
19242
|
channelsPaddings: channelsPaddings,
|
|
19243
19243
|
selectedChannelBorderRadius: selectedChannelBorderRadius,
|
|
@@ -19798,7 +19798,8 @@ var UsersPopup = function UsersPopup(_ref) {
|
|
|
19798
19798
|
sectionBackground = _useColor[THEME_COLORS.SECTION_BACKGROUND],
|
|
19799
19799
|
surface1Background = _useColor[THEME_COLORS.SURFACE_1],
|
|
19800
19800
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
19801
|
-
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY]
|
|
19801
|
+
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
19802
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND];
|
|
19802
19803
|
var dispatch = reactRedux.useDispatch();
|
|
19803
19804
|
var ChatClient = getClient();
|
|
19804
19805
|
var selfUser = ChatClient.user;
|
|
@@ -20043,7 +20044,7 @@ var UsersPopup = function UsersPopup(_ref) {
|
|
|
20043
20044
|
var memberDisplayName = selfUser.id === user.id ? 'Me' : makeUsername(contactsMap[user.id], user, selfUser.id !== user.id && getFromContacts);
|
|
20044
20045
|
return /*#__PURE__*/React__default.createElement(ListRow, {
|
|
20045
20046
|
isAdd: actionType !== 'createChat',
|
|
20046
|
-
hoverBackground:
|
|
20047
|
+
hoverBackground: hoverBackground,
|
|
20047
20048
|
key: user.id,
|
|
20048
20049
|
onClick: function onClick() {
|
|
20049
20050
|
return actionType === 'createChat' && handleAddMember(user);
|
|
@@ -20818,7 +20819,7 @@ var CreateChannelButton = function CreateChannelButton(_ref) {
|
|
|
20818
20819
|
uploadPhotoIcon = _ref.uploadPhotoIcon;
|
|
20819
20820
|
var _useColor = useColors(),
|
|
20820
20821
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
20821
|
-
|
|
20822
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND],
|
|
20822
20823
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY];
|
|
20823
20824
|
var _useState = React.useState(false),
|
|
20824
20825
|
showAddMemberPopup = _useState[0],
|
|
@@ -20843,14 +20844,14 @@ var CreateChannelButton = function CreateChannelButton(_ref) {
|
|
|
20843
20844
|
theme: theme,
|
|
20844
20845
|
zIndex: '300',
|
|
20845
20846
|
trigger: /*#__PURE__*/React__default.createElement(CreateDropdownButton, {
|
|
20846
|
-
hoverBackground:
|
|
20847
|
+
hoverBackground: hoverBackground,
|
|
20847
20848
|
leftAuto: !showSearch,
|
|
20848
20849
|
iconColor: accentColor
|
|
20849
20850
|
}, createChannelIcon || /*#__PURE__*/React__default.createElement(SvgAddChat, null))
|
|
20850
20851
|
}, /*#__PURE__*/React__default.createElement(DropdownOptionsUl, null, /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
20851
20852
|
key: 1,
|
|
20852
20853
|
textColor: textPrimary,
|
|
20853
|
-
hoverBackground:
|
|
20854
|
+
hoverBackground: hoverBackground,
|
|
20854
20855
|
onClick: function onClick() {
|
|
20855
20856
|
return handleOpenCreateChannel('broadcast');
|
|
20856
20857
|
},
|
|
@@ -20858,7 +20859,7 @@ var CreateChannelButton = function CreateChannelButton(_ref) {
|
|
|
20858
20859
|
}, newChannelIcon || /*#__PURE__*/React__default.createElement(SvgCreateChannel, null), "New channel"), /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
20859
20860
|
key: 2,
|
|
20860
20861
|
textColor: textPrimary,
|
|
20861
|
-
hoverBackground:
|
|
20862
|
+
hoverBackground: hoverBackground,
|
|
20862
20863
|
onClick: function onClick() {
|
|
20863
20864
|
return handleOpenCreateChannel('group');
|
|
20864
20865
|
},
|
|
@@ -20866,7 +20867,7 @@ var CreateChannelButton = function CreateChannelButton(_ref) {
|
|
|
20866
20867
|
}, newGroupIcon || /*#__PURE__*/React__default.createElement(SvgCreateGroup, null), "New group"), /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
20867
20868
|
key: 3,
|
|
20868
20869
|
textColor: textPrimary,
|
|
20869
|
-
hoverBackground:
|
|
20870
|
+
hoverBackground: hoverBackground,
|
|
20870
20871
|
onClick: function onClick() {
|
|
20871
20872
|
return handleOpenCreateChannel('direct');
|
|
20872
20873
|
},
|
|
@@ -21940,7 +21941,8 @@ function ChatHeader(_ref) {
|
|
|
21940
21941
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
21941
21942
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
21942
21943
|
iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
|
|
21943
|
-
borderColor = _useColor[THEME_COLORS.BORDER]
|
|
21944
|
+
borderColor = _useColor[THEME_COLORS.BORDER],
|
|
21945
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND];
|
|
21944
21946
|
var dispatch = reactRedux.useDispatch();
|
|
21945
21947
|
var ChatClient = getClient();
|
|
21946
21948
|
var user = ChatClient.user;
|
|
@@ -21982,12 +21984,12 @@ function ChatHeader(_ref) {
|
|
|
21982
21984
|
onClick: handleBackToChannels
|
|
21983
21985
|
}, MobileBackButton || (/*#__PURE__*/React__default.createElement(MobileBackButtonWrapper, {
|
|
21984
21986
|
onClick: handleBackToChannels,
|
|
21985
|
-
hoverBackground:
|
|
21987
|
+
hoverBackground: hoverBackground
|
|
21986
21988
|
}, /*#__PURE__*/React__default.createElement(WrapArrowLeftIcon, {
|
|
21987
21989
|
color: iconPrimary
|
|
21988
21990
|
})))), activeChannel.isLinkedChannel && (/*#__PURE__*/React__default.createElement(BackButtonWrapper, {
|
|
21989
21991
|
onClick: handleSwitchChannel,
|
|
21990
|
-
hoverBackground:
|
|
21992
|
+
hoverBackground: hoverBackground,
|
|
21991
21993
|
order: backButtonOrder
|
|
21992
21994
|
}, /*#__PURE__*/React__default.createElement(WrapArrowLeftIcon, {
|
|
21993
21995
|
color: iconPrimary
|
|
@@ -24905,6 +24907,1805 @@ function SvgPause(props) {
|
|
|
24905
24907
|
})));
|
|
24906
24908
|
}
|
|
24907
24909
|
|
|
24910
|
+
/** A simple event emitter that can be used to listen to and emit events. */
|
|
24911
|
+
class EventEmitter {
|
|
24912
|
+
constructor() {
|
|
24913
|
+
this.listeners = {};
|
|
24914
|
+
}
|
|
24915
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
24916
|
+
on(event, listener, options) {
|
|
24917
|
+
if (!this.listeners[event]) {
|
|
24918
|
+
this.listeners[event] = new Set();
|
|
24919
|
+
}
|
|
24920
|
+
this.listeners[event].add(listener);
|
|
24921
|
+
if (options === null || options === void 0 ? void 0 : options.once) {
|
|
24922
|
+
const unsubscribeOnce = () => {
|
|
24923
|
+
this.un(event, unsubscribeOnce);
|
|
24924
|
+
this.un(event, listener);
|
|
24925
|
+
};
|
|
24926
|
+
this.on(event, unsubscribeOnce);
|
|
24927
|
+
return unsubscribeOnce;
|
|
24928
|
+
}
|
|
24929
|
+
return () => this.un(event, listener);
|
|
24930
|
+
}
|
|
24931
|
+
/** Unsubscribe from an event */
|
|
24932
|
+
un(event, listener) {
|
|
24933
|
+
var _a;
|
|
24934
|
+
(_a = this.listeners[event]) === null || _a === void 0 ? void 0 : _a.delete(listener);
|
|
24935
|
+
}
|
|
24936
|
+
/** Subscribe to an event only once */
|
|
24937
|
+
once(event, listener) {
|
|
24938
|
+
return this.on(event, listener, { once: true });
|
|
24939
|
+
}
|
|
24940
|
+
/** Clear all events */
|
|
24941
|
+
unAll() {
|
|
24942
|
+
this.listeners = {};
|
|
24943
|
+
}
|
|
24944
|
+
/** Emit an event */
|
|
24945
|
+
emit(eventName, ...args) {
|
|
24946
|
+
if (this.listeners[eventName]) {
|
|
24947
|
+
this.listeners[eventName].forEach((listener) => listener(...args));
|
|
24948
|
+
}
|
|
24949
|
+
}
|
|
24950
|
+
}
|
|
24951
|
+
|
|
24952
|
+
/** Base class for wavesurfer plugins */
|
|
24953
|
+
class BasePlugin extends EventEmitter {
|
|
24954
|
+
/** Create a plugin instance */
|
|
24955
|
+
constructor(options) {
|
|
24956
|
+
super();
|
|
24957
|
+
this.subscriptions = [];
|
|
24958
|
+
this.options = options;
|
|
24959
|
+
}
|
|
24960
|
+
/** Called after this.wavesurfer is available */
|
|
24961
|
+
onInit() {
|
|
24962
|
+
return;
|
|
24963
|
+
}
|
|
24964
|
+
/** Do not call directly, only called by WavesSurfer internally */
|
|
24965
|
+
_init(wavesurfer) {
|
|
24966
|
+
this.wavesurfer = wavesurfer;
|
|
24967
|
+
this.onInit();
|
|
24968
|
+
}
|
|
24969
|
+
/** Destroy the plugin and unsubscribe from all events */
|
|
24970
|
+
destroy() {
|
|
24971
|
+
this.emit('destroy');
|
|
24972
|
+
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
24973
|
+
}
|
|
24974
|
+
}
|
|
24975
|
+
|
|
24976
|
+
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24977
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
24978
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24979
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24980
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24981
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24982
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24983
|
+
});
|
|
24984
|
+
};
|
|
24985
|
+
/** Decode an array buffer into an audio buffer */
|
|
24986
|
+
function decode(audioData, sampleRate) {
|
|
24987
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24988
|
+
const audioCtx = new AudioContext({ sampleRate });
|
|
24989
|
+
const decode = audioCtx.decodeAudioData(audioData);
|
|
24990
|
+
return decode.finally(() => audioCtx.close());
|
|
24991
|
+
});
|
|
24992
|
+
}
|
|
24993
|
+
/** Normalize peaks to -1..1 */
|
|
24994
|
+
function normalize(channelData) {
|
|
24995
|
+
const firstChannel = channelData[0];
|
|
24996
|
+
if (firstChannel.some((n) => n > 1 || n < -1)) {
|
|
24997
|
+
const length = firstChannel.length;
|
|
24998
|
+
let max = 0;
|
|
24999
|
+
for (let i = 0; i < length; i++) {
|
|
25000
|
+
const absN = Math.abs(firstChannel[i]);
|
|
25001
|
+
if (absN > max)
|
|
25002
|
+
max = absN;
|
|
25003
|
+
}
|
|
25004
|
+
for (const channel of channelData) {
|
|
25005
|
+
for (let i = 0; i < length; i++) {
|
|
25006
|
+
channel[i] /= max;
|
|
25007
|
+
}
|
|
25008
|
+
}
|
|
25009
|
+
}
|
|
25010
|
+
return channelData;
|
|
25011
|
+
}
|
|
25012
|
+
/** Create an audio buffer from pre-decoded audio data */
|
|
25013
|
+
function createBuffer(channelData, duration) {
|
|
25014
|
+
// If a single array of numbers is passed, make it an array of arrays
|
|
25015
|
+
if (typeof channelData[0] === 'number')
|
|
25016
|
+
channelData = [channelData];
|
|
25017
|
+
// Normalize to -1..1
|
|
25018
|
+
normalize(channelData);
|
|
25019
|
+
return {
|
|
25020
|
+
duration,
|
|
25021
|
+
length: channelData[0].length,
|
|
25022
|
+
sampleRate: channelData[0].length / duration,
|
|
25023
|
+
numberOfChannels: channelData.length,
|
|
25024
|
+
getChannelData: (i) => channelData === null || channelData === void 0 ? void 0 : channelData[i],
|
|
25025
|
+
copyFromChannel: AudioBuffer.prototype.copyFromChannel,
|
|
25026
|
+
copyToChannel: AudioBuffer.prototype.copyToChannel,
|
|
25027
|
+
};
|
|
25028
|
+
}
|
|
25029
|
+
const Decoder = {
|
|
25030
|
+
decode,
|
|
25031
|
+
createBuffer,
|
|
25032
|
+
};
|
|
25033
|
+
|
|
25034
|
+
function renderNode(tagName, content) {
|
|
25035
|
+
const element = content.xmlns
|
|
25036
|
+
? document.createElementNS(content.xmlns, tagName)
|
|
25037
|
+
: document.createElement(tagName);
|
|
25038
|
+
for (const [key, value] of Object.entries(content)) {
|
|
25039
|
+
if (key === 'children') {
|
|
25040
|
+
for (const [key, value] of Object.entries(content)) {
|
|
25041
|
+
if (typeof value === 'string') {
|
|
25042
|
+
element.appendChild(document.createTextNode(value));
|
|
25043
|
+
}
|
|
25044
|
+
else {
|
|
25045
|
+
element.appendChild(renderNode(key, value));
|
|
25046
|
+
}
|
|
25047
|
+
}
|
|
25048
|
+
}
|
|
25049
|
+
else if (key === 'style') {
|
|
25050
|
+
Object.assign(element.style, value);
|
|
25051
|
+
}
|
|
25052
|
+
else if (key === 'textContent') {
|
|
25053
|
+
element.textContent = value;
|
|
25054
|
+
}
|
|
25055
|
+
else {
|
|
25056
|
+
element.setAttribute(key, value.toString());
|
|
25057
|
+
}
|
|
25058
|
+
}
|
|
25059
|
+
return element;
|
|
25060
|
+
}
|
|
25061
|
+
function createElement(tagName, content, container) {
|
|
25062
|
+
const el = renderNode(tagName, content || {});
|
|
25063
|
+
container === null || container === void 0 ? void 0 : container.appendChild(el);
|
|
25064
|
+
return el;
|
|
25065
|
+
}
|
|
25066
|
+
|
|
25067
|
+
var dom = {
|
|
25068
|
+
__proto__: null,
|
|
25069
|
+
createElement: createElement,
|
|
25070
|
+
'default': createElement
|
|
25071
|
+
};
|
|
25072
|
+
|
|
25073
|
+
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25074
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25075
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25076
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25077
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25078
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25079
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25080
|
+
});
|
|
25081
|
+
};
|
|
25082
|
+
function watchProgress(response, progressCallback) {
|
|
25083
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
25084
|
+
if (!response.body || !response.headers)
|
|
25085
|
+
return;
|
|
25086
|
+
const reader = response.body.getReader();
|
|
25087
|
+
const contentLength = Number(response.headers.get('Content-Length')) || 0;
|
|
25088
|
+
let receivedLength = 0;
|
|
25089
|
+
// Process the data
|
|
25090
|
+
const processChunk = (value) => __awaiter$1(this, void 0, void 0, function* () {
|
|
25091
|
+
// Add to the received length
|
|
25092
|
+
receivedLength += (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
25093
|
+
const percentage = Math.round((receivedLength / contentLength) * 100);
|
|
25094
|
+
progressCallback(percentage);
|
|
25095
|
+
});
|
|
25096
|
+
const read = () => __awaiter$1(this, void 0, void 0, function* () {
|
|
25097
|
+
let data;
|
|
25098
|
+
try {
|
|
25099
|
+
data = yield reader.read();
|
|
25100
|
+
}
|
|
25101
|
+
catch (_a) {
|
|
25102
|
+
// Ignore errors because we can only handle the main response
|
|
25103
|
+
return;
|
|
25104
|
+
}
|
|
25105
|
+
// Continue reading data until done
|
|
25106
|
+
if (!data.done) {
|
|
25107
|
+
processChunk(data.value);
|
|
25108
|
+
yield read();
|
|
25109
|
+
}
|
|
25110
|
+
});
|
|
25111
|
+
read();
|
|
25112
|
+
});
|
|
25113
|
+
}
|
|
25114
|
+
function fetchBlob(url, progressCallback, requestInit) {
|
|
25115
|
+
return __awaiter$1(this, void 0, void 0, function* () {
|
|
25116
|
+
// Fetch the resource
|
|
25117
|
+
const response = yield fetch(url, requestInit);
|
|
25118
|
+
if (response.status >= 400) {
|
|
25119
|
+
throw new Error(`Failed to fetch ${url}: ${response.status} (${response.statusText})`);
|
|
25120
|
+
}
|
|
25121
|
+
// Read the data to track progress
|
|
25122
|
+
watchProgress(response.clone(), progressCallback);
|
|
25123
|
+
return response.blob();
|
|
25124
|
+
});
|
|
25125
|
+
}
|
|
25126
|
+
const Fetcher = {
|
|
25127
|
+
fetchBlob,
|
|
25128
|
+
};
|
|
25129
|
+
|
|
25130
|
+
var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25131
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25132
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25133
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25134
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25135
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25136
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25137
|
+
});
|
|
25138
|
+
};
|
|
25139
|
+
class Player extends EventEmitter {
|
|
25140
|
+
constructor(options) {
|
|
25141
|
+
super();
|
|
25142
|
+
this.isExternalMedia = false;
|
|
25143
|
+
if (options.media) {
|
|
25144
|
+
this.media = options.media;
|
|
25145
|
+
this.isExternalMedia = true;
|
|
25146
|
+
}
|
|
25147
|
+
else {
|
|
25148
|
+
this.media = document.createElement('audio');
|
|
25149
|
+
}
|
|
25150
|
+
// Controls
|
|
25151
|
+
if (options.mediaControls) {
|
|
25152
|
+
this.media.controls = true;
|
|
25153
|
+
}
|
|
25154
|
+
// Autoplay
|
|
25155
|
+
if (options.autoplay) {
|
|
25156
|
+
this.media.autoplay = true;
|
|
25157
|
+
}
|
|
25158
|
+
// Speed
|
|
25159
|
+
if (options.playbackRate != null) {
|
|
25160
|
+
this.onMediaEvent('canplay', () => {
|
|
25161
|
+
if (options.playbackRate != null) {
|
|
25162
|
+
this.media.playbackRate = options.playbackRate;
|
|
25163
|
+
}
|
|
25164
|
+
}, { once: true });
|
|
25165
|
+
}
|
|
25166
|
+
}
|
|
25167
|
+
onMediaEvent(event, callback, options) {
|
|
25168
|
+
this.media.addEventListener(event, callback, options);
|
|
25169
|
+
return () => this.media.removeEventListener(event, callback, options);
|
|
25170
|
+
}
|
|
25171
|
+
getSrc() {
|
|
25172
|
+
return this.media.currentSrc || this.media.src || '';
|
|
25173
|
+
}
|
|
25174
|
+
revokeSrc() {
|
|
25175
|
+
const src = this.getSrc();
|
|
25176
|
+
if (src.startsWith('blob:')) {
|
|
25177
|
+
URL.revokeObjectURL(src);
|
|
25178
|
+
}
|
|
25179
|
+
}
|
|
25180
|
+
canPlayType(type) {
|
|
25181
|
+
return this.media.canPlayType(type) !== '';
|
|
25182
|
+
}
|
|
25183
|
+
setSrc(url, blob) {
|
|
25184
|
+
const src = this.getSrc();
|
|
25185
|
+
if (url && src === url)
|
|
25186
|
+
return;
|
|
25187
|
+
this.revokeSrc();
|
|
25188
|
+
const newSrc = blob instanceof Blob && (this.canPlayType(blob.type) || !url) ? URL.createObjectURL(blob) : url;
|
|
25189
|
+
// Reset the media element, otherwise it keeps the previous source
|
|
25190
|
+
if (src) {
|
|
25191
|
+
this.media.src = '';
|
|
25192
|
+
}
|
|
25193
|
+
try {
|
|
25194
|
+
this.media.src = newSrc;
|
|
25195
|
+
}
|
|
25196
|
+
catch (e) {
|
|
25197
|
+
this.media.src = url;
|
|
25198
|
+
}
|
|
25199
|
+
}
|
|
25200
|
+
destroy() {
|
|
25201
|
+
if (this.isExternalMedia)
|
|
25202
|
+
return;
|
|
25203
|
+
this.media.pause();
|
|
25204
|
+
this.media.remove();
|
|
25205
|
+
this.revokeSrc();
|
|
25206
|
+
this.media.src = '';
|
|
25207
|
+
// Load resets the media element to its initial state
|
|
25208
|
+
this.media.load();
|
|
25209
|
+
}
|
|
25210
|
+
setMediaElement(element) {
|
|
25211
|
+
this.media = element;
|
|
25212
|
+
}
|
|
25213
|
+
/** Start playing the audio */
|
|
25214
|
+
play() {
|
|
25215
|
+
return __awaiter$2(this, void 0, void 0, function* () {
|
|
25216
|
+
return this.media.play();
|
|
25217
|
+
});
|
|
25218
|
+
}
|
|
25219
|
+
/** Pause the audio */
|
|
25220
|
+
pause() {
|
|
25221
|
+
this.media.pause();
|
|
25222
|
+
}
|
|
25223
|
+
/** Check if the audio is playing */
|
|
25224
|
+
isPlaying() {
|
|
25225
|
+
return !this.media.paused && !this.media.ended;
|
|
25226
|
+
}
|
|
25227
|
+
/** Jump to a specific time in the audio (in seconds) */
|
|
25228
|
+
setTime(time) {
|
|
25229
|
+
this.media.currentTime = Math.max(0, Math.min(time, this.getDuration()));
|
|
25230
|
+
}
|
|
25231
|
+
/** Get the duration of the audio in seconds */
|
|
25232
|
+
getDuration() {
|
|
25233
|
+
return this.media.duration;
|
|
25234
|
+
}
|
|
25235
|
+
/** Get the current audio position in seconds */
|
|
25236
|
+
getCurrentTime() {
|
|
25237
|
+
return this.media.currentTime;
|
|
25238
|
+
}
|
|
25239
|
+
/** Get the audio volume */
|
|
25240
|
+
getVolume() {
|
|
25241
|
+
return this.media.volume;
|
|
25242
|
+
}
|
|
25243
|
+
/** Set the audio volume */
|
|
25244
|
+
setVolume(volume) {
|
|
25245
|
+
this.media.volume = volume;
|
|
25246
|
+
}
|
|
25247
|
+
/** Get the audio muted state */
|
|
25248
|
+
getMuted() {
|
|
25249
|
+
return this.media.muted;
|
|
25250
|
+
}
|
|
25251
|
+
/** Mute or unmute the audio */
|
|
25252
|
+
setMuted(muted) {
|
|
25253
|
+
this.media.muted = muted;
|
|
25254
|
+
}
|
|
25255
|
+
/** Get the playback speed */
|
|
25256
|
+
getPlaybackRate() {
|
|
25257
|
+
return this.media.playbackRate;
|
|
25258
|
+
}
|
|
25259
|
+
/** Check if the audio is seeking */
|
|
25260
|
+
isSeeking() {
|
|
25261
|
+
return this.media.seeking;
|
|
25262
|
+
}
|
|
25263
|
+
/** Set the playback speed, pass an optional false to NOT preserve the pitch */
|
|
25264
|
+
setPlaybackRate(rate, preservePitch) {
|
|
25265
|
+
// preservePitch is true by default in most browsers
|
|
25266
|
+
if (preservePitch != null) {
|
|
25267
|
+
this.media.preservesPitch = preservePitch;
|
|
25268
|
+
}
|
|
25269
|
+
this.media.playbackRate = rate;
|
|
25270
|
+
}
|
|
25271
|
+
/** Get the HTML media element */
|
|
25272
|
+
getMediaElement() {
|
|
25273
|
+
return this.media;
|
|
25274
|
+
}
|
|
25275
|
+
/** Set a sink id to change the audio output device */
|
|
25276
|
+
setSinkId(sinkId) {
|
|
25277
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId
|
|
25278
|
+
const media = this.media;
|
|
25279
|
+
return media.setSinkId(sinkId);
|
|
25280
|
+
}
|
|
25281
|
+
}
|
|
25282
|
+
|
|
25283
|
+
function makeDraggable(element, onDrag, onStart, onEnd, threshold = 3, mouseButton = 0, touchDelay = 100) {
|
|
25284
|
+
if (!element)
|
|
25285
|
+
return () => void 0;
|
|
25286
|
+
const isTouchDevice = matchMedia('(pointer: coarse)').matches;
|
|
25287
|
+
let unsubscribeDocument = () => void 0;
|
|
25288
|
+
const onPointerDown = (event) => {
|
|
25289
|
+
if (event.button !== mouseButton)
|
|
25290
|
+
return;
|
|
25291
|
+
event.preventDefault();
|
|
25292
|
+
event.stopPropagation();
|
|
25293
|
+
let startX = event.clientX;
|
|
25294
|
+
let startY = event.clientY;
|
|
25295
|
+
let isDragging = false;
|
|
25296
|
+
const touchStartTime = Date.now();
|
|
25297
|
+
const onPointerMove = (event) => {
|
|
25298
|
+
event.preventDefault();
|
|
25299
|
+
event.stopPropagation();
|
|
25300
|
+
if (isTouchDevice && Date.now() - touchStartTime < touchDelay)
|
|
25301
|
+
return;
|
|
25302
|
+
const x = event.clientX;
|
|
25303
|
+
const y = event.clientY;
|
|
25304
|
+
const dx = x - startX;
|
|
25305
|
+
const dy = y - startY;
|
|
25306
|
+
if (isDragging || Math.abs(dx) > threshold || Math.abs(dy) > threshold) {
|
|
25307
|
+
const rect = element.getBoundingClientRect();
|
|
25308
|
+
const { left, top } = rect;
|
|
25309
|
+
if (!isDragging) {
|
|
25310
|
+
onStart === null || onStart === void 0 ? void 0 : onStart(startX - left, startY - top);
|
|
25311
|
+
isDragging = true;
|
|
25312
|
+
}
|
|
25313
|
+
onDrag(dx, dy, x - left, y - top);
|
|
25314
|
+
startX = x;
|
|
25315
|
+
startY = y;
|
|
25316
|
+
}
|
|
25317
|
+
};
|
|
25318
|
+
const onPointerUp = (event) => {
|
|
25319
|
+
if (isDragging) {
|
|
25320
|
+
const x = event.clientX;
|
|
25321
|
+
const y = event.clientY;
|
|
25322
|
+
const rect = element.getBoundingClientRect();
|
|
25323
|
+
const { left, top } = rect;
|
|
25324
|
+
onEnd === null || onEnd === void 0 ? void 0 : onEnd(x - left, y - top);
|
|
25325
|
+
}
|
|
25326
|
+
unsubscribeDocument();
|
|
25327
|
+
};
|
|
25328
|
+
const onPointerLeave = (e) => {
|
|
25329
|
+
// Listen to events only on the document and not on inner elements
|
|
25330
|
+
if (!e.relatedTarget || e.relatedTarget === document.documentElement) {
|
|
25331
|
+
onPointerUp(e);
|
|
25332
|
+
}
|
|
25333
|
+
};
|
|
25334
|
+
const onClick = (event) => {
|
|
25335
|
+
if (isDragging) {
|
|
25336
|
+
event.stopPropagation();
|
|
25337
|
+
event.preventDefault();
|
|
25338
|
+
}
|
|
25339
|
+
};
|
|
25340
|
+
const onTouchMove = (event) => {
|
|
25341
|
+
if (isDragging) {
|
|
25342
|
+
event.preventDefault();
|
|
25343
|
+
}
|
|
25344
|
+
};
|
|
25345
|
+
document.addEventListener('pointermove', onPointerMove);
|
|
25346
|
+
document.addEventListener('pointerup', onPointerUp);
|
|
25347
|
+
document.addEventListener('pointerout', onPointerLeave);
|
|
25348
|
+
document.addEventListener('pointercancel', onPointerLeave);
|
|
25349
|
+
document.addEventListener('touchmove', onTouchMove, { passive: false });
|
|
25350
|
+
document.addEventListener('click', onClick, { capture: true });
|
|
25351
|
+
unsubscribeDocument = () => {
|
|
25352
|
+
document.removeEventListener('pointermove', onPointerMove);
|
|
25353
|
+
document.removeEventListener('pointerup', onPointerUp);
|
|
25354
|
+
document.removeEventListener('pointerout', onPointerLeave);
|
|
25355
|
+
document.removeEventListener('pointercancel', onPointerLeave);
|
|
25356
|
+
document.removeEventListener('touchmove', onTouchMove);
|
|
25357
|
+
setTimeout(() => {
|
|
25358
|
+
document.removeEventListener('click', onClick, { capture: true });
|
|
25359
|
+
}, 10);
|
|
25360
|
+
};
|
|
25361
|
+
};
|
|
25362
|
+
element.addEventListener('pointerdown', onPointerDown);
|
|
25363
|
+
return () => {
|
|
25364
|
+
unsubscribeDocument();
|
|
25365
|
+
element.removeEventListener('pointerdown', onPointerDown);
|
|
25366
|
+
};
|
|
25367
|
+
}
|
|
25368
|
+
|
|
25369
|
+
var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25370
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25371
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25372
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25373
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25374
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25375
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25376
|
+
});
|
|
25377
|
+
};
|
|
25378
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
25379
|
+
var t = {};
|
|
25380
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25381
|
+
t[p] = s[p];
|
|
25382
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25383
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25384
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25385
|
+
t[p[i]] = s[p[i]];
|
|
25386
|
+
}
|
|
25387
|
+
return t;
|
|
25388
|
+
};
|
|
25389
|
+
class Renderer extends EventEmitter {
|
|
25390
|
+
constructor(options, audioElement) {
|
|
25391
|
+
super();
|
|
25392
|
+
this.timeouts = [];
|
|
25393
|
+
this.isScrollable = false;
|
|
25394
|
+
this.audioData = null;
|
|
25395
|
+
this.resizeObserver = null;
|
|
25396
|
+
this.lastContainerWidth = 0;
|
|
25397
|
+
this.isDragging = false;
|
|
25398
|
+
this.subscriptions = [];
|
|
25399
|
+
this.unsubscribeOnScroll = [];
|
|
25400
|
+
this.subscriptions = [];
|
|
25401
|
+
this.options = options;
|
|
25402
|
+
const parent = this.parentFromOptionsContainer(options.container);
|
|
25403
|
+
this.parent = parent;
|
|
25404
|
+
const [div, shadow] = this.initHtml();
|
|
25405
|
+
parent.appendChild(div);
|
|
25406
|
+
this.container = div;
|
|
25407
|
+
this.scrollContainer = shadow.querySelector('.scroll');
|
|
25408
|
+
this.wrapper = shadow.querySelector('.wrapper');
|
|
25409
|
+
this.canvasWrapper = shadow.querySelector('.canvases');
|
|
25410
|
+
this.progressWrapper = shadow.querySelector('.progress');
|
|
25411
|
+
this.cursor = shadow.querySelector('.cursor');
|
|
25412
|
+
if (audioElement) {
|
|
25413
|
+
shadow.appendChild(audioElement);
|
|
25414
|
+
}
|
|
25415
|
+
this.initEvents();
|
|
25416
|
+
}
|
|
25417
|
+
parentFromOptionsContainer(container) {
|
|
25418
|
+
let parent;
|
|
25419
|
+
if (typeof container === 'string') {
|
|
25420
|
+
parent = document.querySelector(container);
|
|
25421
|
+
}
|
|
25422
|
+
else if (container instanceof HTMLElement) {
|
|
25423
|
+
parent = container;
|
|
25424
|
+
}
|
|
25425
|
+
if (!parent) {
|
|
25426
|
+
throw new Error('Container not found');
|
|
25427
|
+
}
|
|
25428
|
+
return parent;
|
|
25429
|
+
}
|
|
25430
|
+
initEvents() {
|
|
25431
|
+
const getClickPosition = (e) => {
|
|
25432
|
+
const rect = this.wrapper.getBoundingClientRect();
|
|
25433
|
+
const x = e.clientX - rect.left;
|
|
25434
|
+
const y = e.clientY - rect.top;
|
|
25435
|
+
const relativeX = x / rect.width;
|
|
25436
|
+
const relativeY = y / rect.height;
|
|
25437
|
+
return [relativeX, relativeY];
|
|
25438
|
+
};
|
|
25439
|
+
// Add a click listener
|
|
25440
|
+
this.wrapper.addEventListener('click', (e) => {
|
|
25441
|
+
const [x, y] = getClickPosition(e);
|
|
25442
|
+
this.emit('click', x, y);
|
|
25443
|
+
});
|
|
25444
|
+
// Add a double click listener
|
|
25445
|
+
this.wrapper.addEventListener('dblclick', (e) => {
|
|
25446
|
+
const [x, y] = getClickPosition(e);
|
|
25447
|
+
this.emit('dblclick', x, y);
|
|
25448
|
+
});
|
|
25449
|
+
// Drag
|
|
25450
|
+
if (this.options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
|
|
25451
|
+
this.initDrag();
|
|
25452
|
+
}
|
|
25453
|
+
// Add a scroll listener
|
|
25454
|
+
this.scrollContainer.addEventListener('scroll', () => {
|
|
25455
|
+
const { scrollLeft, scrollWidth, clientWidth } = this.scrollContainer;
|
|
25456
|
+
const startX = scrollLeft / scrollWidth;
|
|
25457
|
+
const endX = (scrollLeft + clientWidth) / scrollWidth;
|
|
25458
|
+
this.emit('scroll', startX, endX, scrollLeft, scrollLeft + clientWidth);
|
|
25459
|
+
});
|
|
25460
|
+
// Re-render the waveform on container resize
|
|
25461
|
+
if (typeof ResizeObserver === 'function') {
|
|
25462
|
+
const delay = this.createDelay(100);
|
|
25463
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
25464
|
+
delay()
|
|
25465
|
+
.then(() => this.onContainerResize())
|
|
25466
|
+
.catch(() => undefined);
|
|
25467
|
+
});
|
|
25468
|
+
this.resizeObserver.observe(this.scrollContainer);
|
|
25469
|
+
}
|
|
25470
|
+
}
|
|
25471
|
+
onContainerResize() {
|
|
25472
|
+
const width = this.parent.clientWidth;
|
|
25473
|
+
if (width === this.lastContainerWidth && this.options.height !== 'auto')
|
|
25474
|
+
return;
|
|
25475
|
+
this.lastContainerWidth = width;
|
|
25476
|
+
this.reRender();
|
|
25477
|
+
}
|
|
25478
|
+
initDrag() {
|
|
25479
|
+
this.subscriptions.push(makeDraggable(this.wrapper,
|
|
25480
|
+
// On drag
|
|
25481
|
+
(_, __, x) => {
|
|
25482
|
+
this.emit('drag', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
25483
|
+
},
|
|
25484
|
+
// On start drag
|
|
25485
|
+
(x) => {
|
|
25486
|
+
this.isDragging = true;
|
|
25487
|
+
this.emit('dragstart', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
25488
|
+
},
|
|
25489
|
+
// On end drag
|
|
25490
|
+
(x) => {
|
|
25491
|
+
this.isDragging = false;
|
|
25492
|
+
this.emit('dragend', Math.max(0, Math.min(1, x / this.wrapper.getBoundingClientRect().width)));
|
|
25493
|
+
}));
|
|
25494
|
+
}
|
|
25495
|
+
getHeight(optionsHeight, optionsSplitChannel) {
|
|
25496
|
+
var _a;
|
|
25497
|
+
const defaultHeight = 128;
|
|
25498
|
+
const numberOfChannels = ((_a = this.audioData) === null || _a === void 0 ? void 0 : _a.numberOfChannels) || 1;
|
|
25499
|
+
if (optionsHeight == null)
|
|
25500
|
+
return defaultHeight;
|
|
25501
|
+
if (!isNaN(Number(optionsHeight)))
|
|
25502
|
+
return Number(optionsHeight);
|
|
25503
|
+
if (optionsHeight === 'auto') {
|
|
25504
|
+
const height = this.parent.clientHeight || defaultHeight;
|
|
25505
|
+
if (optionsSplitChannel === null || optionsSplitChannel === void 0 ? void 0 : optionsSplitChannel.every((channel) => !channel.overlay))
|
|
25506
|
+
return height / numberOfChannels;
|
|
25507
|
+
return height;
|
|
25508
|
+
}
|
|
25509
|
+
return defaultHeight;
|
|
25510
|
+
}
|
|
25511
|
+
initHtml() {
|
|
25512
|
+
const div = document.createElement('div');
|
|
25513
|
+
const shadow = div.attachShadow({ mode: 'open' });
|
|
25514
|
+
const cspNonce = this.options.cspNonce && typeof this.options.cspNonce === 'string' ? this.options.cspNonce.replace(/"/g, '') : '';
|
|
25515
|
+
shadow.innerHTML = `
|
|
25516
|
+
<style${cspNonce ? ` nonce="${cspNonce}"` : ''}>
|
|
25517
|
+
:host {
|
|
25518
|
+
user-select: none;
|
|
25519
|
+
min-width: 1px;
|
|
25520
|
+
}
|
|
25521
|
+
:host audio {
|
|
25522
|
+
display: block;
|
|
25523
|
+
width: 100%;
|
|
25524
|
+
}
|
|
25525
|
+
:host .scroll {
|
|
25526
|
+
overflow-x: auto;
|
|
25527
|
+
overflow-y: hidden;
|
|
25528
|
+
width: 100%;
|
|
25529
|
+
position: relative;
|
|
25530
|
+
}
|
|
25531
|
+
:host .noScrollbar {
|
|
25532
|
+
scrollbar-color: transparent;
|
|
25533
|
+
scrollbar-width: none;
|
|
25534
|
+
}
|
|
25535
|
+
:host .noScrollbar::-webkit-scrollbar {
|
|
25536
|
+
display: none;
|
|
25537
|
+
-webkit-appearance: none;
|
|
25538
|
+
}
|
|
25539
|
+
:host .wrapper {
|
|
25540
|
+
position: relative;
|
|
25541
|
+
overflow: visible;
|
|
25542
|
+
z-index: 2;
|
|
25543
|
+
}
|
|
25544
|
+
:host .canvases {
|
|
25545
|
+
min-height: ${this.getHeight(this.options.height, this.options.splitChannels)}px;
|
|
25546
|
+
}
|
|
25547
|
+
:host .canvases > div {
|
|
25548
|
+
position: relative;
|
|
25549
|
+
}
|
|
25550
|
+
:host canvas {
|
|
25551
|
+
display: block;
|
|
25552
|
+
position: absolute;
|
|
25553
|
+
top: 0;
|
|
25554
|
+
image-rendering: pixelated;
|
|
25555
|
+
}
|
|
25556
|
+
:host .progress {
|
|
25557
|
+
pointer-events: none;
|
|
25558
|
+
position: absolute;
|
|
25559
|
+
z-index: 2;
|
|
25560
|
+
top: 0;
|
|
25561
|
+
left: 0;
|
|
25562
|
+
width: 0;
|
|
25563
|
+
height: 100%;
|
|
25564
|
+
overflow: hidden;
|
|
25565
|
+
}
|
|
25566
|
+
:host .progress > div {
|
|
25567
|
+
position: relative;
|
|
25568
|
+
}
|
|
25569
|
+
:host .cursor {
|
|
25570
|
+
pointer-events: none;
|
|
25571
|
+
position: absolute;
|
|
25572
|
+
z-index: 5;
|
|
25573
|
+
top: 0;
|
|
25574
|
+
left: 0;
|
|
25575
|
+
height: 100%;
|
|
25576
|
+
border-radius: 2px;
|
|
25577
|
+
}
|
|
25578
|
+
</style>
|
|
25579
|
+
|
|
25580
|
+
<div class="scroll" part="scroll">
|
|
25581
|
+
<div class="wrapper" part="wrapper">
|
|
25582
|
+
<div class="canvases" part="canvases"></div>
|
|
25583
|
+
<div class="progress" part="progress"></div>
|
|
25584
|
+
<div class="cursor" part="cursor"></div>
|
|
25585
|
+
</div>
|
|
25586
|
+
</div>
|
|
25587
|
+
`;
|
|
25588
|
+
return [div, shadow];
|
|
25589
|
+
}
|
|
25590
|
+
/** Wavesurfer itself calls this method. Do not call it manually. */
|
|
25591
|
+
setOptions(options) {
|
|
25592
|
+
if (this.options.container !== options.container) {
|
|
25593
|
+
const newParent = this.parentFromOptionsContainer(options.container);
|
|
25594
|
+
newParent.appendChild(this.container);
|
|
25595
|
+
this.parent = newParent;
|
|
25596
|
+
}
|
|
25597
|
+
if (options.dragToSeek === true || typeof this.options.dragToSeek === 'object') {
|
|
25598
|
+
this.initDrag();
|
|
25599
|
+
}
|
|
25600
|
+
this.options = options;
|
|
25601
|
+
// Re-render the waveform
|
|
25602
|
+
this.reRender();
|
|
25603
|
+
}
|
|
25604
|
+
getWrapper() {
|
|
25605
|
+
return this.wrapper;
|
|
25606
|
+
}
|
|
25607
|
+
getWidth() {
|
|
25608
|
+
return this.scrollContainer.clientWidth;
|
|
25609
|
+
}
|
|
25610
|
+
getScroll() {
|
|
25611
|
+
return this.scrollContainer.scrollLeft;
|
|
25612
|
+
}
|
|
25613
|
+
setScroll(pixels) {
|
|
25614
|
+
this.scrollContainer.scrollLeft = pixels;
|
|
25615
|
+
}
|
|
25616
|
+
setScrollPercentage(percent) {
|
|
25617
|
+
const { scrollWidth } = this.scrollContainer;
|
|
25618
|
+
const scrollStart = scrollWidth * percent;
|
|
25619
|
+
this.setScroll(scrollStart);
|
|
25620
|
+
}
|
|
25621
|
+
destroy() {
|
|
25622
|
+
var _a, _b;
|
|
25623
|
+
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
25624
|
+
this.container.remove();
|
|
25625
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
25626
|
+
(_b = this.unsubscribeOnScroll) === null || _b === void 0 ? void 0 : _b.forEach((unsubscribe) => unsubscribe());
|
|
25627
|
+
this.unsubscribeOnScroll = [];
|
|
25628
|
+
}
|
|
25629
|
+
createDelay(delayMs = 10) {
|
|
25630
|
+
let timeout;
|
|
25631
|
+
let reject;
|
|
25632
|
+
const onClear = () => {
|
|
25633
|
+
if (timeout)
|
|
25634
|
+
clearTimeout(timeout);
|
|
25635
|
+
if (reject)
|
|
25636
|
+
reject();
|
|
25637
|
+
};
|
|
25638
|
+
this.timeouts.push(onClear);
|
|
25639
|
+
return () => {
|
|
25640
|
+
return new Promise((resolveFn, rejectFn) => {
|
|
25641
|
+
onClear();
|
|
25642
|
+
reject = rejectFn;
|
|
25643
|
+
timeout = setTimeout(() => {
|
|
25644
|
+
timeout = undefined;
|
|
25645
|
+
reject = undefined;
|
|
25646
|
+
resolveFn();
|
|
25647
|
+
}, delayMs);
|
|
25648
|
+
});
|
|
25649
|
+
};
|
|
25650
|
+
}
|
|
25651
|
+
// Convert array of color values to linear gradient
|
|
25652
|
+
convertColorValues(color) {
|
|
25653
|
+
if (!Array.isArray(color))
|
|
25654
|
+
return color || '';
|
|
25655
|
+
if (color.length < 2)
|
|
25656
|
+
return color[0] || '';
|
|
25657
|
+
const canvasElement = document.createElement('canvas');
|
|
25658
|
+
const ctx = canvasElement.getContext('2d');
|
|
25659
|
+
const gradientHeight = canvasElement.height * (window.devicePixelRatio || 1);
|
|
25660
|
+
const gradient = ctx.createLinearGradient(0, 0, 0, gradientHeight);
|
|
25661
|
+
const colorStopPercentage = 1 / (color.length - 1);
|
|
25662
|
+
color.forEach((color, index) => {
|
|
25663
|
+
const offset = index * colorStopPercentage;
|
|
25664
|
+
gradient.addColorStop(offset, color);
|
|
25665
|
+
});
|
|
25666
|
+
return gradient;
|
|
25667
|
+
}
|
|
25668
|
+
getPixelRatio() {
|
|
25669
|
+
return Math.max(1, window.devicePixelRatio || 1);
|
|
25670
|
+
}
|
|
25671
|
+
renderBarWaveform(channelData, options, ctx, vScale) {
|
|
25672
|
+
const topChannel = channelData[0];
|
|
25673
|
+
const bottomChannel = channelData[1] || channelData[0];
|
|
25674
|
+
const length = topChannel.length;
|
|
25675
|
+
const { width, height } = ctx.canvas;
|
|
25676
|
+
const halfHeight = height / 2;
|
|
25677
|
+
const pixelRatio = this.getPixelRatio();
|
|
25678
|
+
const barWidth = options.barWidth ? options.barWidth * pixelRatio : 1;
|
|
25679
|
+
const barGap = options.barGap ? options.barGap * pixelRatio : options.barWidth ? barWidth / 2 : 0;
|
|
25680
|
+
const barRadius = options.barRadius || 0;
|
|
25681
|
+
const barIndexScale = width / (barWidth + barGap) / length;
|
|
25682
|
+
const rectFn = barRadius && 'roundRect' in ctx ? 'roundRect' : 'rect';
|
|
25683
|
+
ctx.beginPath();
|
|
25684
|
+
let prevX = 0;
|
|
25685
|
+
let maxTop = 0;
|
|
25686
|
+
let maxBottom = 0;
|
|
25687
|
+
for (let i = 0; i <= length; i++) {
|
|
25688
|
+
const x = Math.round(i * barIndexScale);
|
|
25689
|
+
if (x > prevX) {
|
|
25690
|
+
const topBarHeight = Math.round(maxTop * halfHeight * vScale);
|
|
25691
|
+
const bottomBarHeight = Math.round(maxBottom * halfHeight * vScale);
|
|
25692
|
+
const barHeight = topBarHeight + bottomBarHeight || 1;
|
|
25693
|
+
// Vertical alignment
|
|
25694
|
+
let y = halfHeight - topBarHeight;
|
|
25695
|
+
if (options.barAlign === 'top') {
|
|
25696
|
+
y = 0;
|
|
25697
|
+
}
|
|
25698
|
+
else if (options.barAlign === 'bottom') {
|
|
25699
|
+
y = height - barHeight;
|
|
25700
|
+
}
|
|
25701
|
+
ctx[rectFn](prevX * (barWidth + barGap), y, barWidth, barHeight, barRadius);
|
|
25702
|
+
prevX = x;
|
|
25703
|
+
maxTop = 0;
|
|
25704
|
+
maxBottom = 0;
|
|
25705
|
+
}
|
|
25706
|
+
const magnitudeTop = Math.abs(topChannel[i] || 0);
|
|
25707
|
+
const magnitudeBottom = Math.abs(bottomChannel[i] || 0);
|
|
25708
|
+
if (magnitudeTop > maxTop)
|
|
25709
|
+
maxTop = magnitudeTop;
|
|
25710
|
+
if (magnitudeBottom > maxBottom)
|
|
25711
|
+
maxBottom = magnitudeBottom;
|
|
25712
|
+
}
|
|
25713
|
+
ctx.fill();
|
|
25714
|
+
ctx.closePath();
|
|
25715
|
+
}
|
|
25716
|
+
renderLineWaveform(channelData, _options, ctx, vScale) {
|
|
25717
|
+
const drawChannel = (index) => {
|
|
25718
|
+
const channel = channelData[index] || channelData[0];
|
|
25719
|
+
const length = channel.length;
|
|
25720
|
+
const { height } = ctx.canvas;
|
|
25721
|
+
const halfHeight = height / 2;
|
|
25722
|
+
const hScale = ctx.canvas.width / length;
|
|
25723
|
+
ctx.moveTo(0, halfHeight);
|
|
25724
|
+
let prevX = 0;
|
|
25725
|
+
let max = 0;
|
|
25726
|
+
for (let i = 0; i <= length; i++) {
|
|
25727
|
+
const x = Math.round(i * hScale);
|
|
25728
|
+
if (x > prevX) {
|
|
25729
|
+
const h = Math.round(max * halfHeight * vScale) || 1;
|
|
25730
|
+
const y = halfHeight + h * (index === 0 ? -1 : 1);
|
|
25731
|
+
ctx.lineTo(prevX, y);
|
|
25732
|
+
prevX = x;
|
|
25733
|
+
max = 0;
|
|
25734
|
+
}
|
|
25735
|
+
const value = Math.abs(channel[i] || 0);
|
|
25736
|
+
if (value > max)
|
|
25737
|
+
max = value;
|
|
25738
|
+
}
|
|
25739
|
+
ctx.lineTo(prevX, halfHeight);
|
|
25740
|
+
};
|
|
25741
|
+
ctx.beginPath();
|
|
25742
|
+
drawChannel(0);
|
|
25743
|
+
drawChannel(1);
|
|
25744
|
+
ctx.fill();
|
|
25745
|
+
ctx.closePath();
|
|
25746
|
+
}
|
|
25747
|
+
renderWaveform(channelData, options, ctx) {
|
|
25748
|
+
ctx.fillStyle = this.convertColorValues(options.waveColor);
|
|
25749
|
+
// Custom rendering function
|
|
25750
|
+
if (options.renderFunction) {
|
|
25751
|
+
options.renderFunction(channelData, ctx);
|
|
25752
|
+
return;
|
|
25753
|
+
}
|
|
25754
|
+
// Vertical scaling
|
|
25755
|
+
let vScale = options.barHeight || 1;
|
|
25756
|
+
if (options.normalize) {
|
|
25757
|
+
const max = Array.from(channelData[0]).reduce((max, value) => Math.max(max, Math.abs(value)), 0);
|
|
25758
|
+
vScale = max ? 1 / max : 1;
|
|
25759
|
+
}
|
|
25760
|
+
// Render waveform as bars
|
|
25761
|
+
if (options.barWidth || options.barGap || options.barAlign) {
|
|
25762
|
+
this.renderBarWaveform(channelData, options, ctx, vScale);
|
|
25763
|
+
return;
|
|
25764
|
+
}
|
|
25765
|
+
// Render waveform as a polyline
|
|
25766
|
+
this.renderLineWaveform(channelData, options, ctx, vScale);
|
|
25767
|
+
}
|
|
25768
|
+
renderSingleCanvas(data, options, width, height, offset, canvasContainer, progressContainer) {
|
|
25769
|
+
const pixelRatio = this.getPixelRatio();
|
|
25770
|
+
const canvas = document.createElement('canvas');
|
|
25771
|
+
canvas.width = Math.round(width * pixelRatio);
|
|
25772
|
+
canvas.height = Math.round(height * pixelRatio);
|
|
25773
|
+
canvas.style.width = `${width}px`;
|
|
25774
|
+
canvas.style.height = `${height}px`;
|
|
25775
|
+
canvas.style.left = `${Math.round(offset)}px`;
|
|
25776
|
+
canvasContainer.appendChild(canvas);
|
|
25777
|
+
const ctx = canvas.getContext('2d');
|
|
25778
|
+
this.renderWaveform(data, options, ctx);
|
|
25779
|
+
// Draw a progress canvas
|
|
25780
|
+
if (canvas.width > 0 && canvas.height > 0) {
|
|
25781
|
+
const progressCanvas = canvas.cloneNode();
|
|
25782
|
+
const progressCtx = progressCanvas.getContext('2d');
|
|
25783
|
+
progressCtx.drawImage(canvas, 0, 0);
|
|
25784
|
+
// Set the composition method to draw only where the waveform is drawn
|
|
25785
|
+
progressCtx.globalCompositeOperation = 'source-in';
|
|
25786
|
+
progressCtx.fillStyle = this.convertColorValues(options.progressColor);
|
|
25787
|
+
// This rectangle acts as a mask thanks to the composition method
|
|
25788
|
+
progressCtx.fillRect(0, 0, canvas.width, canvas.height);
|
|
25789
|
+
progressContainer.appendChild(progressCanvas);
|
|
25790
|
+
}
|
|
25791
|
+
}
|
|
25792
|
+
renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer) {
|
|
25793
|
+
const pixelRatio = this.getPixelRatio();
|
|
25794
|
+
const { clientWidth } = this.scrollContainer;
|
|
25795
|
+
const totalWidth = width / pixelRatio;
|
|
25796
|
+
let singleCanvasWidth = Math.min(Renderer.MAX_CANVAS_WIDTH, clientWidth, totalWidth);
|
|
25797
|
+
let drawnIndexes = {};
|
|
25798
|
+
// Nothing to render
|
|
25799
|
+
if (singleCanvasWidth === 0)
|
|
25800
|
+
return;
|
|
25801
|
+
// Adjust width to avoid gaps between canvases when using bars
|
|
25802
|
+
if (options.barWidth || options.barGap) {
|
|
25803
|
+
const barWidth = options.barWidth || 0.5;
|
|
25804
|
+
const barGap = options.barGap || barWidth / 2;
|
|
25805
|
+
const totalBarWidth = barWidth + barGap;
|
|
25806
|
+
if (singleCanvasWidth % totalBarWidth !== 0) {
|
|
25807
|
+
singleCanvasWidth = Math.floor(singleCanvasWidth / totalBarWidth) * totalBarWidth;
|
|
25808
|
+
}
|
|
25809
|
+
}
|
|
25810
|
+
// Draw a single canvas
|
|
25811
|
+
const draw = (index) => {
|
|
25812
|
+
if (index < 0 || index >= numCanvases)
|
|
25813
|
+
return;
|
|
25814
|
+
if (drawnIndexes[index])
|
|
25815
|
+
return;
|
|
25816
|
+
drawnIndexes[index] = true;
|
|
25817
|
+
const offset = index * singleCanvasWidth;
|
|
25818
|
+
const clampedWidth = Math.min(totalWidth - offset, singleCanvasWidth);
|
|
25819
|
+
if (clampedWidth <= 0)
|
|
25820
|
+
return;
|
|
25821
|
+
const data = channelData.map((channel) => {
|
|
25822
|
+
const start = Math.floor((offset / totalWidth) * channel.length);
|
|
25823
|
+
const end = Math.floor(((offset + clampedWidth) / totalWidth) * channel.length);
|
|
25824
|
+
return channel.slice(start, end);
|
|
25825
|
+
});
|
|
25826
|
+
this.renderSingleCanvas(data, options, clampedWidth, height, offset, canvasContainer, progressContainer);
|
|
25827
|
+
};
|
|
25828
|
+
// Clear canvases to avoid too many DOM nodes
|
|
25829
|
+
const clearCanvases = () => {
|
|
25830
|
+
if (Object.keys(drawnIndexes).length > Renderer.MAX_NODES) {
|
|
25831
|
+
canvasContainer.innerHTML = '';
|
|
25832
|
+
progressContainer.innerHTML = '';
|
|
25833
|
+
drawnIndexes = {};
|
|
25834
|
+
}
|
|
25835
|
+
};
|
|
25836
|
+
// Calculate how many canvases to render
|
|
25837
|
+
const numCanvases = Math.ceil(totalWidth / singleCanvasWidth);
|
|
25838
|
+
// Render all canvases if the waveform doesn't scroll
|
|
25839
|
+
if (!this.isScrollable) {
|
|
25840
|
+
for (let i = 0; i < numCanvases; i++) {
|
|
25841
|
+
draw(i);
|
|
25842
|
+
}
|
|
25843
|
+
return;
|
|
25844
|
+
}
|
|
25845
|
+
// Lazy rendering
|
|
25846
|
+
const viewPosition = this.scrollContainer.scrollLeft / totalWidth;
|
|
25847
|
+
const startCanvas = Math.floor(viewPosition * numCanvases);
|
|
25848
|
+
// Draw the canvases in the viewport first
|
|
25849
|
+
draw(startCanvas - 1);
|
|
25850
|
+
draw(startCanvas);
|
|
25851
|
+
draw(startCanvas + 1);
|
|
25852
|
+
// Subscribe to the scroll event to draw additional canvases
|
|
25853
|
+
if (numCanvases > 1) {
|
|
25854
|
+
const unsubscribe = this.on('scroll', () => {
|
|
25855
|
+
const { scrollLeft } = this.scrollContainer;
|
|
25856
|
+
const canvasIndex = Math.floor((scrollLeft / totalWidth) * numCanvases);
|
|
25857
|
+
clearCanvases();
|
|
25858
|
+
draw(canvasIndex - 1);
|
|
25859
|
+
draw(canvasIndex);
|
|
25860
|
+
draw(canvasIndex + 1);
|
|
25861
|
+
});
|
|
25862
|
+
this.unsubscribeOnScroll.push(unsubscribe);
|
|
25863
|
+
}
|
|
25864
|
+
}
|
|
25865
|
+
renderChannel(channelData, _a, width, channelIndex) {
|
|
25866
|
+
var { overlay } = _a, options = __rest(_a, ["overlay"]);
|
|
25867
|
+
// A container for canvases
|
|
25868
|
+
const canvasContainer = document.createElement('div');
|
|
25869
|
+
const height = this.getHeight(options.height, options.splitChannels);
|
|
25870
|
+
canvasContainer.style.height = `${height}px`;
|
|
25871
|
+
if (overlay && channelIndex > 0) {
|
|
25872
|
+
canvasContainer.style.marginTop = `-${height}px`;
|
|
25873
|
+
}
|
|
25874
|
+
this.canvasWrapper.style.minHeight = `${height}px`;
|
|
25875
|
+
this.canvasWrapper.appendChild(canvasContainer);
|
|
25876
|
+
// A container for progress canvases
|
|
25877
|
+
const progressContainer = canvasContainer.cloneNode();
|
|
25878
|
+
this.progressWrapper.appendChild(progressContainer);
|
|
25879
|
+
// Render the waveform
|
|
25880
|
+
this.renderMultiCanvas(channelData, options, width, height, canvasContainer, progressContainer);
|
|
25881
|
+
}
|
|
25882
|
+
render(audioData) {
|
|
25883
|
+
return __awaiter$3(this, void 0, void 0, function* () {
|
|
25884
|
+
var _a;
|
|
25885
|
+
// Clear previous timeouts
|
|
25886
|
+
this.timeouts.forEach((clear) => clear());
|
|
25887
|
+
this.timeouts = [];
|
|
25888
|
+
// Clear the canvases
|
|
25889
|
+
this.canvasWrapper.innerHTML = '';
|
|
25890
|
+
this.progressWrapper.innerHTML = '';
|
|
25891
|
+
// Width
|
|
25892
|
+
if (this.options.width != null) {
|
|
25893
|
+
this.scrollContainer.style.width =
|
|
25894
|
+
typeof this.options.width === 'number' ? `${this.options.width}px` : this.options.width;
|
|
25895
|
+
}
|
|
25896
|
+
// Determine the width of the waveform
|
|
25897
|
+
const pixelRatio = this.getPixelRatio();
|
|
25898
|
+
const parentWidth = this.scrollContainer.clientWidth;
|
|
25899
|
+
const scrollWidth = Math.ceil(audioData.duration * (this.options.minPxPerSec || 0));
|
|
25900
|
+
// Whether the container should scroll
|
|
25901
|
+
this.isScrollable = scrollWidth > parentWidth;
|
|
25902
|
+
const useParentWidth = this.options.fillParent && !this.isScrollable;
|
|
25903
|
+
// Width of the waveform in pixels
|
|
25904
|
+
const width = (useParentWidth ? parentWidth : scrollWidth) * pixelRatio;
|
|
25905
|
+
// Set the width of the wrapper
|
|
25906
|
+
this.wrapper.style.width = useParentWidth ? '100%' : `${scrollWidth}px`;
|
|
25907
|
+
// Set additional styles
|
|
25908
|
+
this.scrollContainer.style.overflowX = this.isScrollable ? 'auto' : 'hidden';
|
|
25909
|
+
this.scrollContainer.classList.toggle('noScrollbar', !!this.options.hideScrollbar);
|
|
25910
|
+
this.cursor.style.backgroundColor = `${this.options.cursorColor || this.options.progressColor}`;
|
|
25911
|
+
this.cursor.style.width = `${this.options.cursorWidth}px`;
|
|
25912
|
+
this.audioData = audioData;
|
|
25913
|
+
this.emit('render');
|
|
25914
|
+
// Render the waveform
|
|
25915
|
+
if (this.options.splitChannels) {
|
|
25916
|
+
// Render a waveform for each channel
|
|
25917
|
+
for (let i = 0; i < audioData.numberOfChannels; i++) {
|
|
25918
|
+
const options = Object.assign(Object.assign({}, this.options), (_a = this.options.splitChannels) === null || _a === void 0 ? void 0 : _a[i]);
|
|
25919
|
+
this.renderChannel([audioData.getChannelData(i)], options, width, i);
|
|
25920
|
+
}
|
|
25921
|
+
}
|
|
25922
|
+
else {
|
|
25923
|
+
// Render a single waveform for the first two channels (left and right)
|
|
25924
|
+
const channels = [audioData.getChannelData(0)];
|
|
25925
|
+
if (audioData.numberOfChannels > 1)
|
|
25926
|
+
channels.push(audioData.getChannelData(1));
|
|
25927
|
+
this.renderChannel(channels, this.options, width, 0);
|
|
25928
|
+
}
|
|
25929
|
+
// Must be emitted asynchronously for backward compatibility
|
|
25930
|
+
Promise.resolve().then(() => this.emit('rendered'));
|
|
25931
|
+
});
|
|
25932
|
+
}
|
|
25933
|
+
reRender() {
|
|
25934
|
+
this.unsubscribeOnScroll.forEach((unsubscribe) => unsubscribe());
|
|
25935
|
+
this.unsubscribeOnScroll = [];
|
|
25936
|
+
// Return if the waveform has not been rendered yet
|
|
25937
|
+
if (!this.audioData)
|
|
25938
|
+
return;
|
|
25939
|
+
// Remember the current cursor position
|
|
25940
|
+
const { scrollWidth } = this.scrollContainer;
|
|
25941
|
+
const { right: before } = this.progressWrapper.getBoundingClientRect();
|
|
25942
|
+
// Re-render the waveform
|
|
25943
|
+
this.render(this.audioData);
|
|
25944
|
+
// Adjust the scroll position so that the cursor stays in the same place
|
|
25945
|
+
if (this.isScrollable && scrollWidth !== this.scrollContainer.scrollWidth) {
|
|
25946
|
+
const { right: after } = this.progressWrapper.getBoundingClientRect();
|
|
25947
|
+
let delta = after - before;
|
|
25948
|
+
// to limit compounding floating-point drift
|
|
25949
|
+
// we need to round to the half px furthest from 0
|
|
25950
|
+
delta *= 2;
|
|
25951
|
+
delta = delta < 0 ? Math.floor(delta) : Math.ceil(delta);
|
|
25952
|
+
delta /= 2;
|
|
25953
|
+
this.scrollContainer.scrollLeft += delta;
|
|
25954
|
+
}
|
|
25955
|
+
}
|
|
25956
|
+
zoom(minPxPerSec) {
|
|
25957
|
+
this.options.minPxPerSec = minPxPerSec;
|
|
25958
|
+
this.reRender();
|
|
25959
|
+
}
|
|
25960
|
+
scrollIntoView(progress, isPlaying = false) {
|
|
25961
|
+
const { scrollLeft, scrollWidth, clientWidth } = this.scrollContainer;
|
|
25962
|
+
const progressWidth = progress * scrollWidth;
|
|
25963
|
+
const startEdge = scrollLeft;
|
|
25964
|
+
const endEdge = scrollLeft + clientWidth;
|
|
25965
|
+
const middle = clientWidth / 2;
|
|
25966
|
+
if (this.isDragging) {
|
|
25967
|
+
// Scroll when dragging close to the edge of the viewport
|
|
25968
|
+
const minGap = 30;
|
|
25969
|
+
if (progressWidth + minGap > endEdge) {
|
|
25970
|
+
this.scrollContainer.scrollLeft += minGap;
|
|
25971
|
+
}
|
|
25972
|
+
else if (progressWidth - minGap < startEdge) {
|
|
25973
|
+
this.scrollContainer.scrollLeft -= minGap;
|
|
25974
|
+
}
|
|
25975
|
+
}
|
|
25976
|
+
else {
|
|
25977
|
+
if (progressWidth < startEdge || progressWidth > endEdge) {
|
|
25978
|
+
this.scrollContainer.scrollLeft = progressWidth - (this.options.autoCenter ? middle : 0);
|
|
25979
|
+
}
|
|
25980
|
+
// Keep the cursor centered when playing
|
|
25981
|
+
const center = progressWidth - scrollLeft - middle;
|
|
25982
|
+
if (isPlaying && this.options.autoCenter && center > 0) {
|
|
25983
|
+
this.scrollContainer.scrollLeft += Math.min(center, 10);
|
|
25984
|
+
}
|
|
25985
|
+
}
|
|
25986
|
+
// Emit the scroll event
|
|
25987
|
+
{
|
|
25988
|
+
const newScroll = this.scrollContainer.scrollLeft;
|
|
25989
|
+
const startX = newScroll / scrollWidth;
|
|
25990
|
+
const endX = (newScroll + clientWidth) / scrollWidth;
|
|
25991
|
+
this.emit('scroll', startX, endX, newScroll, newScroll + clientWidth);
|
|
25992
|
+
}
|
|
25993
|
+
}
|
|
25994
|
+
renderProgress(progress, isPlaying) {
|
|
25995
|
+
if (isNaN(progress))
|
|
25996
|
+
return;
|
|
25997
|
+
const percents = progress * 100;
|
|
25998
|
+
this.canvasWrapper.style.clipPath = `polygon(${percents}% 0, 100% 0, 100% 100%, ${percents}% 100%)`;
|
|
25999
|
+
this.progressWrapper.style.width = `${percents}%`;
|
|
26000
|
+
this.cursor.style.left = `${percents}%`;
|
|
26001
|
+
this.cursor.style.transform = `translateX(-${Math.round(percents) === 100 ? this.options.cursorWidth : 0}px)`;
|
|
26002
|
+
if (this.isScrollable && this.options.autoScroll) {
|
|
26003
|
+
this.scrollIntoView(progress, isPlaying);
|
|
26004
|
+
}
|
|
26005
|
+
}
|
|
26006
|
+
exportImage(format, quality, type) {
|
|
26007
|
+
return __awaiter$3(this, void 0, void 0, function* () {
|
|
26008
|
+
const canvases = this.canvasWrapper.querySelectorAll('canvas');
|
|
26009
|
+
if (!canvases.length) {
|
|
26010
|
+
throw new Error('No waveform data');
|
|
26011
|
+
}
|
|
26012
|
+
// Data URLs
|
|
26013
|
+
if (type === 'dataURL') {
|
|
26014
|
+
const images = Array.from(canvases).map((canvas) => canvas.toDataURL(format, quality));
|
|
26015
|
+
return Promise.resolve(images);
|
|
26016
|
+
}
|
|
26017
|
+
// Blobs
|
|
26018
|
+
return Promise.all(Array.from(canvases).map((canvas) => {
|
|
26019
|
+
return new Promise((resolve, reject) => {
|
|
26020
|
+
canvas.toBlob((blob) => {
|
|
26021
|
+
blob ? resolve(blob) : reject(new Error('Could not export image'));
|
|
26022
|
+
}, format, quality);
|
|
26023
|
+
});
|
|
26024
|
+
}));
|
|
26025
|
+
});
|
|
26026
|
+
}
|
|
26027
|
+
}
|
|
26028
|
+
Renderer.MAX_CANVAS_WIDTH = 8000;
|
|
26029
|
+
Renderer.MAX_NODES = 10;
|
|
26030
|
+
|
|
26031
|
+
class Timer extends EventEmitter {
|
|
26032
|
+
constructor() {
|
|
26033
|
+
super(...arguments);
|
|
26034
|
+
this.unsubscribe = () => undefined;
|
|
26035
|
+
}
|
|
26036
|
+
start() {
|
|
26037
|
+
this.unsubscribe = this.on('tick', () => {
|
|
26038
|
+
requestAnimationFrame(() => {
|
|
26039
|
+
this.emit('tick');
|
|
26040
|
+
});
|
|
26041
|
+
});
|
|
26042
|
+
this.emit('tick');
|
|
26043
|
+
}
|
|
26044
|
+
stop() {
|
|
26045
|
+
this.unsubscribe();
|
|
26046
|
+
}
|
|
26047
|
+
destroy() {
|
|
26048
|
+
this.unsubscribe();
|
|
26049
|
+
}
|
|
26050
|
+
}
|
|
26051
|
+
|
|
26052
|
+
var __awaiter$4 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26053
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26054
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26055
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26056
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26057
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26058
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26059
|
+
});
|
|
26060
|
+
};
|
|
26061
|
+
/**
|
|
26062
|
+
* A Web Audio buffer player emulating the behavior of an HTML5 Audio element.
|
|
26063
|
+
*/
|
|
26064
|
+
class WebAudioPlayer extends EventEmitter {
|
|
26065
|
+
constructor(audioContext = new AudioContext()) {
|
|
26066
|
+
super();
|
|
26067
|
+
this.bufferNode = null;
|
|
26068
|
+
this.playStartTime = 0;
|
|
26069
|
+
this.playedDuration = 0;
|
|
26070
|
+
this._muted = false;
|
|
26071
|
+
this._playbackRate = 1;
|
|
26072
|
+
this._duration = undefined;
|
|
26073
|
+
this.buffer = null;
|
|
26074
|
+
this.currentSrc = '';
|
|
26075
|
+
this.paused = true;
|
|
26076
|
+
this.crossOrigin = null;
|
|
26077
|
+
this.seeking = false;
|
|
26078
|
+
this.autoplay = false;
|
|
26079
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
26080
|
+
this.addEventListener = this.on;
|
|
26081
|
+
/** Unsubscribe from an event */
|
|
26082
|
+
this.removeEventListener = this.un;
|
|
26083
|
+
this.audioContext = audioContext;
|
|
26084
|
+
this.gainNode = this.audioContext.createGain();
|
|
26085
|
+
this.gainNode.connect(this.audioContext.destination);
|
|
26086
|
+
}
|
|
26087
|
+
load() {
|
|
26088
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
26089
|
+
return;
|
|
26090
|
+
});
|
|
26091
|
+
}
|
|
26092
|
+
get src() {
|
|
26093
|
+
return this.currentSrc;
|
|
26094
|
+
}
|
|
26095
|
+
set src(value) {
|
|
26096
|
+
this.currentSrc = value;
|
|
26097
|
+
this._duration = undefined;
|
|
26098
|
+
if (!value) {
|
|
26099
|
+
this.buffer = null;
|
|
26100
|
+
this.emit('emptied');
|
|
26101
|
+
return;
|
|
26102
|
+
}
|
|
26103
|
+
fetch(value)
|
|
26104
|
+
.then((response) => {
|
|
26105
|
+
if (response.status >= 400) {
|
|
26106
|
+
throw new Error(`Failed to fetch ${value}: ${response.status} (${response.statusText})`);
|
|
26107
|
+
}
|
|
26108
|
+
return response.arrayBuffer();
|
|
26109
|
+
})
|
|
26110
|
+
.then((arrayBuffer) => {
|
|
26111
|
+
if (this.currentSrc !== value)
|
|
26112
|
+
return null;
|
|
26113
|
+
return this.audioContext.decodeAudioData(arrayBuffer);
|
|
26114
|
+
})
|
|
26115
|
+
.then((audioBuffer) => {
|
|
26116
|
+
if (this.currentSrc !== value)
|
|
26117
|
+
return;
|
|
26118
|
+
this.buffer = audioBuffer;
|
|
26119
|
+
this.emit('loadedmetadata');
|
|
26120
|
+
this.emit('canplay');
|
|
26121
|
+
if (this.autoplay)
|
|
26122
|
+
this.play();
|
|
26123
|
+
});
|
|
26124
|
+
}
|
|
26125
|
+
_play() {
|
|
26126
|
+
var _a;
|
|
26127
|
+
if (!this.paused)
|
|
26128
|
+
return;
|
|
26129
|
+
this.paused = false;
|
|
26130
|
+
(_a = this.bufferNode) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
26131
|
+
this.bufferNode = this.audioContext.createBufferSource();
|
|
26132
|
+
if (this.buffer) {
|
|
26133
|
+
this.bufferNode.buffer = this.buffer;
|
|
26134
|
+
}
|
|
26135
|
+
this.bufferNode.playbackRate.value = this._playbackRate;
|
|
26136
|
+
this.bufferNode.connect(this.gainNode);
|
|
26137
|
+
let currentPos = this.playedDuration * this._playbackRate;
|
|
26138
|
+
if (currentPos >= this.duration || currentPos < 0) {
|
|
26139
|
+
currentPos = 0;
|
|
26140
|
+
this.playedDuration = 0;
|
|
26141
|
+
}
|
|
26142
|
+
this.bufferNode.start(this.audioContext.currentTime, currentPos);
|
|
26143
|
+
this.playStartTime = this.audioContext.currentTime;
|
|
26144
|
+
this.bufferNode.onended = () => {
|
|
26145
|
+
if (this.currentTime >= this.duration) {
|
|
26146
|
+
this.pause();
|
|
26147
|
+
this.emit('ended');
|
|
26148
|
+
}
|
|
26149
|
+
};
|
|
26150
|
+
}
|
|
26151
|
+
_pause() {
|
|
26152
|
+
var _a;
|
|
26153
|
+
this.paused = true;
|
|
26154
|
+
(_a = this.bufferNode) === null || _a === void 0 ? void 0 : _a.stop();
|
|
26155
|
+
this.playedDuration += this.audioContext.currentTime - this.playStartTime;
|
|
26156
|
+
}
|
|
26157
|
+
play() {
|
|
26158
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
26159
|
+
if (!this.paused)
|
|
26160
|
+
return;
|
|
26161
|
+
this._play();
|
|
26162
|
+
this.emit('play');
|
|
26163
|
+
});
|
|
26164
|
+
}
|
|
26165
|
+
pause() {
|
|
26166
|
+
if (this.paused)
|
|
26167
|
+
return;
|
|
26168
|
+
this._pause();
|
|
26169
|
+
this.emit('pause');
|
|
26170
|
+
}
|
|
26171
|
+
stopAt(timeSeconds) {
|
|
26172
|
+
const delay = timeSeconds - this.currentTime;
|
|
26173
|
+
const currentBufferNode = this.bufferNode;
|
|
26174
|
+
currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.stop(this.audioContext.currentTime + delay);
|
|
26175
|
+
currentBufferNode === null || currentBufferNode === void 0 ? void 0 : currentBufferNode.addEventListener('ended', () => {
|
|
26176
|
+
if (currentBufferNode === this.bufferNode) {
|
|
26177
|
+
this.bufferNode = null;
|
|
26178
|
+
this.pause();
|
|
26179
|
+
}
|
|
26180
|
+
}, { once: true });
|
|
26181
|
+
}
|
|
26182
|
+
setSinkId(deviceId) {
|
|
26183
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
26184
|
+
const ac = this.audioContext;
|
|
26185
|
+
return ac.setSinkId(deviceId);
|
|
26186
|
+
});
|
|
26187
|
+
}
|
|
26188
|
+
get playbackRate() {
|
|
26189
|
+
return this._playbackRate;
|
|
26190
|
+
}
|
|
26191
|
+
set playbackRate(value) {
|
|
26192
|
+
this._playbackRate = value;
|
|
26193
|
+
if (this.bufferNode) {
|
|
26194
|
+
this.bufferNode.playbackRate.value = value;
|
|
26195
|
+
}
|
|
26196
|
+
}
|
|
26197
|
+
get currentTime() {
|
|
26198
|
+
const time = this.paused
|
|
26199
|
+
? this.playedDuration
|
|
26200
|
+
: this.playedDuration + (this.audioContext.currentTime - this.playStartTime);
|
|
26201
|
+
return time * this._playbackRate;
|
|
26202
|
+
}
|
|
26203
|
+
set currentTime(value) {
|
|
26204
|
+
const wasPlaying = !this.paused;
|
|
26205
|
+
wasPlaying && this._pause();
|
|
26206
|
+
this.playedDuration = value / this._playbackRate;
|
|
26207
|
+
wasPlaying && this._play();
|
|
26208
|
+
this.emit('seeking');
|
|
26209
|
+
this.emit('timeupdate');
|
|
26210
|
+
}
|
|
26211
|
+
get duration() {
|
|
26212
|
+
var _a, _b;
|
|
26213
|
+
return (_a = this._duration) !== null && _a !== void 0 ? _a : (((_b = this.buffer) === null || _b === void 0 ? void 0 : _b.duration) || 0);
|
|
26214
|
+
}
|
|
26215
|
+
set duration(value) {
|
|
26216
|
+
this._duration = value;
|
|
26217
|
+
}
|
|
26218
|
+
get volume() {
|
|
26219
|
+
return this.gainNode.gain.value;
|
|
26220
|
+
}
|
|
26221
|
+
set volume(value) {
|
|
26222
|
+
this.gainNode.gain.value = value;
|
|
26223
|
+
this.emit('volumechange');
|
|
26224
|
+
}
|
|
26225
|
+
get muted() {
|
|
26226
|
+
return this._muted;
|
|
26227
|
+
}
|
|
26228
|
+
set muted(value) {
|
|
26229
|
+
if (this._muted === value)
|
|
26230
|
+
return;
|
|
26231
|
+
this._muted = value;
|
|
26232
|
+
if (this._muted) {
|
|
26233
|
+
this.gainNode.disconnect();
|
|
26234
|
+
}
|
|
26235
|
+
else {
|
|
26236
|
+
this.gainNode.connect(this.audioContext.destination);
|
|
26237
|
+
}
|
|
26238
|
+
}
|
|
26239
|
+
canPlayType(mimeType) {
|
|
26240
|
+
return /^(audio|video)\//.test(mimeType);
|
|
26241
|
+
}
|
|
26242
|
+
/** Get the GainNode used to play the audio. Can be used to attach filters. */
|
|
26243
|
+
getGainNode() {
|
|
26244
|
+
return this.gainNode;
|
|
26245
|
+
}
|
|
26246
|
+
/** Get decoded audio */
|
|
26247
|
+
getChannelData() {
|
|
26248
|
+
const channels = [];
|
|
26249
|
+
if (!this.buffer)
|
|
26250
|
+
return channels;
|
|
26251
|
+
const numChannels = this.buffer.numberOfChannels;
|
|
26252
|
+
for (let i = 0; i < numChannels; i++) {
|
|
26253
|
+
channels.push(this.buffer.getChannelData(i));
|
|
26254
|
+
}
|
|
26255
|
+
return channels;
|
|
26256
|
+
}
|
|
26257
|
+
}
|
|
26258
|
+
|
|
26259
|
+
var __awaiter$5 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26260
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26261
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26262
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
26263
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26264
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26265
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26266
|
+
});
|
|
26267
|
+
};
|
|
26268
|
+
const defaultOptions = {
|
|
26269
|
+
waveColor: '#999',
|
|
26270
|
+
progressColor: '#555',
|
|
26271
|
+
cursorWidth: 1,
|
|
26272
|
+
minPxPerSec: 0,
|
|
26273
|
+
fillParent: true,
|
|
26274
|
+
interact: true,
|
|
26275
|
+
dragToSeek: false,
|
|
26276
|
+
autoScroll: true,
|
|
26277
|
+
autoCenter: true,
|
|
26278
|
+
sampleRate: 8000,
|
|
26279
|
+
};
|
|
26280
|
+
class WaveSurfer extends Player {
|
|
26281
|
+
/** Create a new WaveSurfer instance */
|
|
26282
|
+
static create(options) {
|
|
26283
|
+
return new WaveSurfer(options);
|
|
26284
|
+
}
|
|
26285
|
+
/** Create a new WaveSurfer instance */
|
|
26286
|
+
constructor(options) {
|
|
26287
|
+
const media = options.media ||
|
|
26288
|
+
(options.backend === 'WebAudio' ? new WebAudioPlayer() : undefined);
|
|
26289
|
+
super({
|
|
26290
|
+
media,
|
|
26291
|
+
mediaControls: options.mediaControls,
|
|
26292
|
+
autoplay: options.autoplay,
|
|
26293
|
+
playbackRate: options.audioRate,
|
|
26294
|
+
});
|
|
26295
|
+
this.plugins = [];
|
|
26296
|
+
this.decodedData = null;
|
|
26297
|
+
this.stopAtPosition = null;
|
|
26298
|
+
this.subscriptions = [];
|
|
26299
|
+
this.mediaSubscriptions = [];
|
|
26300
|
+
this.abortController = null;
|
|
26301
|
+
this.options = Object.assign({}, defaultOptions, options);
|
|
26302
|
+
this.timer = new Timer();
|
|
26303
|
+
const audioElement = media ? undefined : this.getMediaElement();
|
|
26304
|
+
this.renderer = new Renderer(this.options, audioElement);
|
|
26305
|
+
this.initPlayerEvents();
|
|
26306
|
+
this.initRendererEvents();
|
|
26307
|
+
this.initTimerEvents();
|
|
26308
|
+
this.initPlugins();
|
|
26309
|
+
// Read the initial URL before load has been called
|
|
26310
|
+
const initialUrl = this.options.url || this.getSrc() || '';
|
|
26311
|
+
// Init and load async to allow external events to be registered
|
|
26312
|
+
Promise.resolve().then(() => {
|
|
26313
|
+
this.emit('init');
|
|
26314
|
+
// Load audio if URL or an external media with an src is passed,
|
|
26315
|
+
// of render w/o audio if pre-decoded peaks and duration are provided
|
|
26316
|
+
const { peaks, duration } = this.options;
|
|
26317
|
+
if (initialUrl || (peaks && duration)) {
|
|
26318
|
+
// Swallow async errors because they cannot be caught from a constructor call.
|
|
26319
|
+
// Subscribe to the wavesurfer's error event to handle them.
|
|
26320
|
+
this.load(initialUrl, peaks, duration).catch(() => null);
|
|
26321
|
+
}
|
|
26322
|
+
});
|
|
26323
|
+
}
|
|
26324
|
+
updateProgress(currentTime = this.getCurrentTime()) {
|
|
26325
|
+
this.renderer.renderProgress(currentTime / this.getDuration(), this.isPlaying());
|
|
26326
|
+
return currentTime;
|
|
26327
|
+
}
|
|
26328
|
+
initTimerEvents() {
|
|
26329
|
+
// The timer fires every 16ms for a smooth progress animation
|
|
26330
|
+
this.subscriptions.push(this.timer.on('tick', () => {
|
|
26331
|
+
if (!this.isSeeking()) {
|
|
26332
|
+
const currentTime = this.updateProgress();
|
|
26333
|
+
this.emit('timeupdate', currentTime);
|
|
26334
|
+
this.emit('audioprocess', currentTime);
|
|
26335
|
+
// Pause audio when it reaches the stopAtPosition
|
|
26336
|
+
if (this.stopAtPosition != null && this.isPlaying() && currentTime >= this.stopAtPosition) {
|
|
26337
|
+
this.pause();
|
|
26338
|
+
}
|
|
26339
|
+
}
|
|
26340
|
+
}));
|
|
26341
|
+
}
|
|
26342
|
+
initPlayerEvents() {
|
|
26343
|
+
if (this.isPlaying()) {
|
|
26344
|
+
this.emit('play');
|
|
26345
|
+
this.timer.start();
|
|
26346
|
+
}
|
|
26347
|
+
this.mediaSubscriptions.push(this.onMediaEvent('timeupdate', () => {
|
|
26348
|
+
const currentTime = this.updateProgress();
|
|
26349
|
+
this.emit('timeupdate', currentTime);
|
|
26350
|
+
}), this.onMediaEvent('play', () => {
|
|
26351
|
+
this.emit('play');
|
|
26352
|
+
this.timer.start();
|
|
26353
|
+
}), this.onMediaEvent('pause', () => {
|
|
26354
|
+
this.emit('pause');
|
|
26355
|
+
this.timer.stop();
|
|
26356
|
+
this.stopAtPosition = null;
|
|
26357
|
+
}), this.onMediaEvent('emptied', () => {
|
|
26358
|
+
this.timer.stop();
|
|
26359
|
+
this.stopAtPosition = null;
|
|
26360
|
+
}), this.onMediaEvent('ended', () => {
|
|
26361
|
+
this.emit('timeupdate', this.getDuration());
|
|
26362
|
+
this.emit('finish');
|
|
26363
|
+
this.stopAtPosition = null;
|
|
26364
|
+
}), this.onMediaEvent('seeking', () => {
|
|
26365
|
+
this.emit('seeking', this.getCurrentTime());
|
|
26366
|
+
}), this.onMediaEvent('error', () => {
|
|
26367
|
+
var _a;
|
|
26368
|
+
this.emit('error', ((_a = this.getMediaElement().error) !== null && _a !== void 0 ? _a : new Error('Media error')));
|
|
26369
|
+
this.stopAtPosition = null;
|
|
26370
|
+
}));
|
|
26371
|
+
}
|
|
26372
|
+
initRendererEvents() {
|
|
26373
|
+
this.subscriptions.push(
|
|
26374
|
+
// Seek on click
|
|
26375
|
+
this.renderer.on('click', (relativeX, relativeY) => {
|
|
26376
|
+
if (this.options.interact) {
|
|
26377
|
+
this.seekTo(relativeX);
|
|
26378
|
+
this.emit('interaction', relativeX * this.getDuration());
|
|
26379
|
+
this.emit('click', relativeX, relativeY);
|
|
26380
|
+
}
|
|
26381
|
+
}),
|
|
26382
|
+
// Double click
|
|
26383
|
+
this.renderer.on('dblclick', (relativeX, relativeY) => {
|
|
26384
|
+
this.emit('dblclick', relativeX, relativeY);
|
|
26385
|
+
}),
|
|
26386
|
+
// Scroll
|
|
26387
|
+
this.renderer.on('scroll', (startX, endX, scrollLeft, scrollRight) => {
|
|
26388
|
+
const duration = this.getDuration();
|
|
26389
|
+
this.emit('scroll', startX * duration, endX * duration, scrollLeft, scrollRight);
|
|
26390
|
+
}),
|
|
26391
|
+
// Redraw
|
|
26392
|
+
this.renderer.on('render', () => {
|
|
26393
|
+
this.emit('redraw');
|
|
26394
|
+
}),
|
|
26395
|
+
// RedrawComplete
|
|
26396
|
+
this.renderer.on('rendered', () => {
|
|
26397
|
+
this.emit('redrawcomplete');
|
|
26398
|
+
}),
|
|
26399
|
+
// DragStart
|
|
26400
|
+
this.renderer.on('dragstart', (relativeX) => {
|
|
26401
|
+
this.emit('dragstart', relativeX);
|
|
26402
|
+
}),
|
|
26403
|
+
// DragEnd
|
|
26404
|
+
this.renderer.on('dragend', (relativeX) => {
|
|
26405
|
+
this.emit('dragend', relativeX);
|
|
26406
|
+
}));
|
|
26407
|
+
// Drag
|
|
26408
|
+
{
|
|
26409
|
+
let debounce;
|
|
26410
|
+
this.subscriptions.push(this.renderer.on('drag', (relativeX) => {
|
|
26411
|
+
if (!this.options.interact)
|
|
26412
|
+
return;
|
|
26413
|
+
// Update the visual position
|
|
26414
|
+
this.renderer.renderProgress(relativeX);
|
|
26415
|
+
// Set the audio position with a debounce
|
|
26416
|
+
clearTimeout(debounce);
|
|
26417
|
+
let debounceTime;
|
|
26418
|
+
if (this.isPlaying()) {
|
|
26419
|
+
debounceTime = 0;
|
|
26420
|
+
}
|
|
26421
|
+
else if (this.options.dragToSeek === true) {
|
|
26422
|
+
debounceTime = 200;
|
|
26423
|
+
}
|
|
26424
|
+
else if (typeof this.options.dragToSeek === 'object' && this.options.dragToSeek !== undefined) {
|
|
26425
|
+
debounceTime = this.options.dragToSeek['debounceTime'];
|
|
26426
|
+
}
|
|
26427
|
+
debounce = setTimeout(() => {
|
|
26428
|
+
this.seekTo(relativeX);
|
|
26429
|
+
}, debounceTime);
|
|
26430
|
+
this.emit('interaction', relativeX * this.getDuration());
|
|
26431
|
+
this.emit('drag', relativeX);
|
|
26432
|
+
}));
|
|
26433
|
+
}
|
|
26434
|
+
}
|
|
26435
|
+
initPlugins() {
|
|
26436
|
+
var _a;
|
|
26437
|
+
if (!((_a = this.options.plugins) === null || _a === void 0 ? void 0 : _a.length))
|
|
26438
|
+
return;
|
|
26439
|
+
this.options.plugins.forEach((plugin) => {
|
|
26440
|
+
this.registerPlugin(plugin);
|
|
26441
|
+
});
|
|
26442
|
+
}
|
|
26443
|
+
unsubscribePlayerEvents() {
|
|
26444
|
+
this.mediaSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
26445
|
+
this.mediaSubscriptions = [];
|
|
26446
|
+
}
|
|
26447
|
+
/** Set new wavesurfer options and re-render it */
|
|
26448
|
+
setOptions(options) {
|
|
26449
|
+
this.options = Object.assign({}, this.options, options);
|
|
26450
|
+
if (options.duration && !options.peaks) {
|
|
26451
|
+
this.decodedData = Decoder.createBuffer(this.exportPeaks(), options.duration);
|
|
26452
|
+
}
|
|
26453
|
+
if (options.peaks && options.duration) {
|
|
26454
|
+
// Create new decoded data buffer from peaks and duration
|
|
26455
|
+
this.decodedData = Decoder.createBuffer(options.peaks, options.duration);
|
|
26456
|
+
}
|
|
26457
|
+
this.renderer.setOptions(this.options);
|
|
26458
|
+
if (options.audioRate) {
|
|
26459
|
+
this.setPlaybackRate(options.audioRate);
|
|
26460
|
+
}
|
|
26461
|
+
if (options.mediaControls != null) {
|
|
26462
|
+
this.getMediaElement().controls = options.mediaControls;
|
|
26463
|
+
}
|
|
26464
|
+
}
|
|
26465
|
+
/** Register a wavesurfer.js plugin */
|
|
26466
|
+
registerPlugin(plugin) {
|
|
26467
|
+
plugin._init(this);
|
|
26468
|
+
this.plugins.push(plugin);
|
|
26469
|
+
// Unregister plugin on destroy
|
|
26470
|
+
this.subscriptions.push(plugin.once('destroy', () => {
|
|
26471
|
+
this.plugins = this.plugins.filter((p) => p !== plugin);
|
|
26472
|
+
}));
|
|
26473
|
+
return plugin;
|
|
26474
|
+
}
|
|
26475
|
+
/** For plugins only: get the waveform wrapper div */
|
|
26476
|
+
getWrapper() {
|
|
26477
|
+
return this.renderer.getWrapper();
|
|
26478
|
+
}
|
|
26479
|
+
/** For plugins only: get the scroll container client width */
|
|
26480
|
+
getWidth() {
|
|
26481
|
+
return this.renderer.getWidth();
|
|
26482
|
+
}
|
|
26483
|
+
/** Get the current scroll position in pixels */
|
|
26484
|
+
getScroll() {
|
|
26485
|
+
return this.renderer.getScroll();
|
|
26486
|
+
}
|
|
26487
|
+
/** Set the current scroll position in pixels */
|
|
26488
|
+
setScroll(pixels) {
|
|
26489
|
+
return this.renderer.setScroll(pixels);
|
|
26490
|
+
}
|
|
26491
|
+
/** Move the start of the viewing window to a specific time in the audio (in seconds) */
|
|
26492
|
+
setScrollTime(time) {
|
|
26493
|
+
const percentage = time / this.getDuration();
|
|
26494
|
+
this.renderer.setScrollPercentage(percentage);
|
|
26495
|
+
}
|
|
26496
|
+
/** Get all registered plugins */
|
|
26497
|
+
getActivePlugins() {
|
|
26498
|
+
return this.plugins;
|
|
26499
|
+
}
|
|
26500
|
+
loadAudio(url, blob, channelData, duration) {
|
|
26501
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
26502
|
+
var _a;
|
|
26503
|
+
this.emit('load', url);
|
|
26504
|
+
if (!this.options.media && this.isPlaying())
|
|
26505
|
+
this.pause();
|
|
26506
|
+
this.decodedData = null;
|
|
26507
|
+
this.stopAtPosition = null;
|
|
26508
|
+
// Fetch the entire audio as a blob if pre-decoded data is not provided
|
|
26509
|
+
if (!blob && !channelData) {
|
|
26510
|
+
const fetchParams = this.options.fetchParams || {};
|
|
26511
|
+
if (window.AbortController && !fetchParams.signal) {
|
|
26512
|
+
this.abortController = new AbortController();
|
|
26513
|
+
fetchParams.signal = (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.signal;
|
|
26514
|
+
}
|
|
26515
|
+
const onProgress = (percentage) => this.emit('loading', percentage);
|
|
26516
|
+
blob = yield Fetcher.fetchBlob(url, onProgress, fetchParams);
|
|
26517
|
+
const overridenMimeType = this.options.blobMimeType;
|
|
26518
|
+
if (overridenMimeType) {
|
|
26519
|
+
blob = new Blob([blob], { type: overridenMimeType });
|
|
26520
|
+
}
|
|
26521
|
+
}
|
|
26522
|
+
// Set the mediaelement source
|
|
26523
|
+
this.setSrc(url, blob);
|
|
26524
|
+
// Wait for the audio duration
|
|
26525
|
+
const audioDuration = yield new Promise((resolve) => {
|
|
26526
|
+
const staticDuration = duration || this.getDuration();
|
|
26527
|
+
if (staticDuration) {
|
|
26528
|
+
resolve(staticDuration);
|
|
26529
|
+
}
|
|
26530
|
+
else {
|
|
26531
|
+
this.mediaSubscriptions.push(this.onMediaEvent('loadedmetadata', () => resolve(this.getDuration()), { once: true }));
|
|
26532
|
+
}
|
|
26533
|
+
});
|
|
26534
|
+
// Set the duration if the player is a WebAudioPlayer without a URL
|
|
26535
|
+
if (!url && !blob) {
|
|
26536
|
+
const media = this.getMediaElement();
|
|
26537
|
+
if (media instanceof WebAudioPlayer) {
|
|
26538
|
+
media.duration = audioDuration;
|
|
26539
|
+
}
|
|
26540
|
+
}
|
|
26541
|
+
// Decode the audio data or use user-provided peaks
|
|
26542
|
+
if (channelData) {
|
|
26543
|
+
this.decodedData = Decoder.createBuffer(channelData, audioDuration || 0);
|
|
26544
|
+
}
|
|
26545
|
+
else if (blob) {
|
|
26546
|
+
const arrayBuffer = yield blob.arrayBuffer();
|
|
26547
|
+
this.decodedData = yield Decoder.decode(arrayBuffer, this.options.sampleRate);
|
|
26548
|
+
}
|
|
26549
|
+
if (this.decodedData) {
|
|
26550
|
+
this.emit('decode', this.getDuration());
|
|
26551
|
+
this.renderer.render(this.decodedData);
|
|
26552
|
+
}
|
|
26553
|
+
this.emit('ready', this.getDuration());
|
|
26554
|
+
});
|
|
26555
|
+
}
|
|
26556
|
+
/** Load an audio file by URL, with optional pre-decoded audio data */
|
|
26557
|
+
load(url, channelData, duration) {
|
|
26558
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
26559
|
+
try {
|
|
26560
|
+
return yield this.loadAudio(url, undefined, channelData, duration);
|
|
26561
|
+
}
|
|
26562
|
+
catch (err) {
|
|
26563
|
+
this.emit('error', err);
|
|
26564
|
+
throw err;
|
|
26565
|
+
}
|
|
26566
|
+
});
|
|
26567
|
+
}
|
|
26568
|
+
/** Load an audio blob */
|
|
26569
|
+
loadBlob(blob, channelData, duration) {
|
|
26570
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
26571
|
+
try {
|
|
26572
|
+
return yield this.loadAudio('', blob, channelData, duration);
|
|
26573
|
+
}
|
|
26574
|
+
catch (err) {
|
|
26575
|
+
this.emit('error', err);
|
|
26576
|
+
throw err;
|
|
26577
|
+
}
|
|
26578
|
+
});
|
|
26579
|
+
}
|
|
26580
|
+
/** Zoom the waveform by a given pixels-per-second factor */
|
|
26581
|
+
zoom(minPxPerSec) {
|
|
26582
|
+
if (!this.decodedData) {
|
|
26583
|
+
throw new Error('No audio loaded');
|
|
26584
|
+
}
|
|
26585
|
+
this.renderer.zoom(minPxPerSec);
|
|
26586
|
+
this.emit('zoom', minPxPerSec);
|
|
26587
|
+
}
|
|
26588
|
+
/** Get the decoded audio data */
|
|
26589
|
+
getDecodedData() {
|
|
26590
|
+
return this.decodedData;
|
|
26591
|
+
}
|
|
26592
|
+
/** Get decoded peaks */
|
|
26593
|
+
exportPeaks({ channels = 2, maxLength = 8000, precision = 10000 } = {}) {
|
|
26594
|
+
if (!this.decodedData) {
|
|
26595
|
+
throw new Error('The audio has not been decoded yet');
|
|
26596
|
+
}
|
|
26597
|
+
const maxChannels = Math.min(channels, this.decodedData.numberOfChannels);
|
|
26598
|
+
const peaks = [];
|
|
26599
|
+
for (let i = 0; i < maxChannels; i++) {
|
|
26600
|
+
const channel = this.decodedData.getChannelData(i);
|
|
26601
|
+
const data = [];
|
|
26602
|
+
const sampleSize = channel.length / maxLength;
|
|
26603
|
+
for (let i = 0; i < maxLength; i++) {
|
|
26604
|
+
const sample = channel.slice(Math.floor(i * sampleSize), Math.ceil((i + 1) * sampleSize));
|
|
26605
|
+
let max = 0;
|
|
26606
|
+
for (let x = 0; x < sample.length; x++) {
|
|
26607
|
+
const n = sample[x];
|
|
26608
|
+
if (Math.abs(n) > Math.abs(max))
|
|
26609
|
+
max = n;
|
|
26610
|
+
}
|
|
26611
|
+
data.push(Math.round(max * precision) / precision);
|
|
26612
|
+
}
|
|
26613
|
+
peaks.push(data);
|
|
26614
|
+
}
|
|
26615
|
+
return peaks;
|
|
26616
|
+
}
|
|
26617
|
+
/** Get the duration of the audio in seconds */
|
|
26618
|
+
getDuration() {
|
|
26619
|
+
let duration = super.getDuration() || 0;
|
|
26620
|
+
// Fall back to the decoded data duration if the media duration is incorrect
|
|
26621
|
+
if ((duration === 0 || duration === Infinity) && this.decodedData) {
|
|
26622
|
+
duration = this.decodedData.duration;
|
|
26623
|
+
}
|
|
26624
|
+
return duration;
|
|
26625
|
+
}
|
|
26626
|
+
/** Toggle if the waveform should react to clicks */
|
|
26627
|
+
toggleInteraction(isInteractive) {
|
|
26628
|
+
this.options.interact = isInteractive;
|
|
26629
|
+
}
|
|
26630
|
+
/** Jump to a specific time in the audio (in seconds) */
|
|
26631
|
+
setTime(time) {
|
|
26632
|
+
this.stopAtPosition = null;
|
|
26633
|
+
super.setTime(time);
|
|
26634
|
+
this.updateProgress(time);
|
|
26635
|
+
this.emit('timeupdate', time);
|
|
26636
|
+
}
|
|
26637
|
+
/** Seek to a percentage of audio as [0..1] (0 = beginning, 1 = end) */
|
|
26638
|
+
seekTo(progress) {
|
|
26639
|
+
const time = this.getDuration() * progress;
|
|
26640
|
+
this.setTime(time);
|
|
26641
|
+
}
|
|
26642
|
+
/** Start playing the audio */
|
|
26643
|
+
play(start, end) {
|
|
26644
|
+
const _super = Object.create(null, {
|
|
26645
|
+
play: { get: () => super.play }
|
|
26646
|
+
});
|
|
26647
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
26648
|
+
if (start != null) {
|
|
26649
|
+
this.setTime(start);
|
|
26650
|
+
}
|
|
26651
|
+
const playResult = yield _super.play.call(this);
|
|
26652
|
+
if (end != null) {
|
|
26653
|
+
if (this.media instanceof WebAudioPlayer) {
|
|
26654
|
+
this.media.stopAt(end);
|
|
26655
|
+
}
|
|
26656
|
+
else {
|
|
26657
|
+
this.stopAtPosition = end;
|
|
26658
|
+
}
|
|
26659
|
+
}
|
|
26660
|
+
return playResult;
|
|
26661
|
+
});
|
|
26662
|
+
}
|
|
26663
|
+
/** Play or pause the audio */
|
|
26664
|
+
playPause() {
|
|
26665
|
+
return __awaiter$5(this, void 0, void 0, function* () {
|
|
26666
|
+
return this.isPlaying() ? this.pause() : this.play();
|
|
26667
|
+
});
|
|
26668
|
+
}
|
|
26669
|
+
/** Stop the audio and go to the beginning */
|
|
26670
|
+
stop() {
|
|
26671
|
+
this.pause();
|
|
26672
|
+
this.setTime(0);
|
|
26673
|
+
}
|
|
26674
|
+
/** Skip N or -N seconds from the current position */
|
|
26675
|
+
skip(seconds) {
|
|
26676
|
+
this.setTime(this.getCurrentTime() + seconds);
|
|
26677
|
+
}
|
|
26678
|
+
/** Empty the waveform */
|
|
26679
|
+
empty() {
|
|
26680
|
+
this.load('', [[0]], 0.001);
|
|
26681
|
+
}
|
|
26682
|
+
/** Set HTML media element */
|
|
26683
|
+
setMediaElement(element) {
|
|
26684
|
+
this.unsubscribePlayerEvents();
|
|
26685
|
+
super.setMediaElement(element);
|
|
26686
|
+
this.initPlayerEvents();
|
|
26687
|
+
}
|
|
26688
|
+
exportImage() {
|
|
26689
|
+
return __awaiter$5(this, arguments, void 0, function* (format = 'image/png', quality = 1, type = 'dataURL') {
|
|
26690
|
+
return this.renderer.exportImage(format, quality, type);
|
|
26691
|
+
});
|
|
26692
|
+
}
|
|
26693
|
+
/** Unmount wavesurfer */
|
|
26694
|
+
destroy() {
|
|
26695
|
+
var _a;
|
|
26696
|
+
this.emit('destroy');
|
|
26697
|
+
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
26698
|
+
this.plugins.forEach((plugin) => plugin.destroy());
|
|
26699
|
+
this.subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
26700
|
+
this.unsubscribePlayerEvents();
|
|
26701
|
+
this.timer.destroy();
|
|
26702
|
+
this.renderer.destroy();
|
|
26703
|
+
super.destroy();
|
|
26704
|
+
}
|
|
26705
|
+
}
|
|
26706
|
+
WaveSurfer.BasePlugin = BasePlugin;
|
|
26707
|
+
WaveSurfer.dom = dom;
|
|
26708
|
+
|
|
24908
26709
|
var _templateObject$t, _templateObject2$p, _templateObject3$j, _templateObject4$g, _templateObject5$e, _templateObject6$c;
|
|
24909
26710
|
var AudioPlayer = function AudioPlayer(_ref) {
|
|
24910
26711
|
var url = _ref.url,
|
|
@@ -25020,73 +26821,69 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
25020
26821
|
}
|
|
25021
26822
|
var initWaveSurfer = function initWaveSurfer() {
|
|
25022
26823
|
try {
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
|
|
25037
|
-
|
|
25038
|
-
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
if (file.metadata) {
|
|
25042
|
-
if (file.metadata.dur) {
|
|
25043
|
-
setCurrentTime(formatAudioVideoTime(file.metadata.dur));
|
|
25044
|
-
}
|
|
25045
|
-
if (file.metadata.tmb) {
|
|
25046
|
-
var maxVal = Math.max.apply(Math, file.metadata.tmb);
|
|
25047
|
-
var dec = maxVal / 100;
|
|
25048
|
-
peaks = file.metadata.tmb.map(function (peak) {
|
|
25049
|
-
return peak / dec / 100;
|
|
25050
|
-
});
|
|
25051
|
-
}
|
|
26824
|
+
try {
|
|
26825
|
+
wavesurfer.current = WaveSurfer.create({
|
|
26826
|
+
container: wavesurferContainer.current,
|
|
26827
|
+
waveColor: textSecondary,
|
|
26828
|
+
progressColor: accentColor,
|
|
26829
|
+
audioRate: audioRate,
|
|
26830
|
+
barWidth: 1,
|
|
26831
|
+
barHeight: 1,
|
|
26832
|
+
hideScrollbar: true,
|
|
26833
|
+
barRadius: 1.5,
|
|
26834
|
+
cursorWidth: 0,
|
|
26835
|
+
barGap: 2,
|
|
26836
|
+
height: 20
|
|
26837
|
+
});
|
|
26838
|
+
var peaks;
|
|
26839
|
+
if (file.metadata) {
|
|
26840
|
+
if (file.metadata.dur) {
|
|
26841
|
+
setCurrentTime(formatAudioVideoTime(file.metadata.dur));
|
|
25052
26842
|
}
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
var
|
|
25056
|
-
|
|
25057
|
-
|
|
25058
|
-
|
|
25059
|
-
|
|
25060
|
-
|
|
25061
|
-
|
|
25062
|
-
|
|
25063
|
-
|
|
25064
|
-
|
|
25065
|
-
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
|
|
25069
|
-
|
|
25070
|
-
|
|
25071
|
-
wavesurfer.current.
|
|
25072
|
-
|
|
25073
|
-
|
|
25074
|
-
|
|
25075
|
-
|
|
25076
|
-
|
|
25077
|
-
|
|
25078
|
-
|
|
25079
|
-
|
|
25080
|
-
|
|
25081
|
-
|
|
25082
|
-
|
|
25083
|
-
setIsRendered(true);
|
|
26843
|
+
if (file.metadata.tmb) {
|
|
26844
|
+
var maxVal = Math.max.apply(Math, file.metadata.tmb);
|
|
26845
|
+
var dec = maxVal / 100;
|
|
26846
|
+
peaks = file.metadata.tmb.map(function (peak) {
|
|
26847
|
+
return peak / dec / 100;
|
|
26848
|
+
});
|
|
26849
|
+
}
|
|
26850
|
+
}
|
|
26851
|
+
wavesurfer.current.load(url, peaks);
|
|
26852
|
+
wavesurfer.current.on('ready', function () {
|
|
26853
|
+
var audioDuration = wavesurfer.current.getDuration();
|
|
26854
|
+
setCurrentTime(formatAudioVideoTime(audioDuration));
|
|
26855
|
+
wavesurfer.current.drawBuffer = function (d) {
|
|
26856
|
+
log.info('filters --- ', d);
|
|
26857
|
+
};
|
|
26858
|
+
});
|
|
26859
|
+
wavesurfer.current.on('finish', function () {
|
|
26860
|
+
setPlayAudio(false);
|
|
26861
|
+
wavesurfer.current.seekTo(0);
|
|
26862
|
+
var audioDuration = wavesurfer.current.getDuration();
|
|
26863
|
+
setCurrentTime(formatAudioVideoTime(audioDuration));
|
|
26864
|
+
if (playingAudioId === file.id) {
|
|
26865
|
+
dispatch(setPlayingAudioIdAC(null));
|
|
26866
|
+
}
|
|
26867
|
+
clearInterval(intervalRef.current);
|
|
26868
|
+
});
|
|
26869
|
+
wavesurfer.current.on('pause', function () {
|
|
26870
|
+
setPlayAudio(false);
|
|
26871
|
+
if (playingAudioId === file.id) {
|
|
26872
|
+
dispatch(setPlayingAudioIdAC(null));
|
|
25084
26873
|
}
|
|
26874
|
+
clearInterval(intervalRef.current);
|
|
25085
26875
|
});
|
|
25086
|
-
|
|
26876
|
+
wavesurfer.current.on('interaction', function () {
|
|
26877
|
+
var currentTime = wavesurfer.current.getCurrentTime();
|
|
26878
|
+
setCurrentTime(formatAudioVideoTime(currentTime));
|
|
26879
|
+
});
|
|
26880
|
+
if (url !== '_') {
|
|
26881
|
+
setIsRendered(true);
|
|
26882
|
+
}
|
|
26883
|
+
} catch (e) {
|
|
25087
26884
|
log.error('Failed to init wavesurfer', e);
|
|
25088
|
-
}
|
|
25089
|
-
return Promise.resolve(
|
|
26885
|
+
}
|
|
26886
|
+
return Promise.resolve();
|
|
25090
26887
|
} catch (e) {
|
|
25091
26888
|
return Promise.reject(e);
|
|
25092
26889
|
}
|
|
@@ -25111,7 +26908,7 @@ var AudioPlayer = function AudioPlayer(_ref) {
|
|
|
25111
26908
|
}), /*#__PURE__*/React__default.createElement(AudioRate, {
|
|
25112
26909
|
color: textSecondary,
|
|
25113
26910
|
onClick: handleSetAudioRate
|
|
25114
|
-
}, audioRate, /*#__PURE__*/React__default.createElement("span", null, "X"))), /*#__PURE__*/React__default.createElement(Timer, {
|
|
26911
|
+
}, audioRate, /*#__PURE__*/React__default.createElement("span", null, "X"))), /*#__PURE__*/React__default.createElement(Timer$1, {
|
|
25115
26912
|
color: textSecondary
|
|
25116
26913
|
}, currentTime));
|
|
25117
26914
|
};
|
|
@@ -25124,7 +26921,7 @@ var AudioRate = styled__default.div(_templateObject4$g || (_templateObject4$g =
|
|
|
25124
26921
|
return props.color;
|
|
25125
26922
|
});
|
|
25126
26923
|
var WaveContainer = styled__default.div(_templateObject5$e || (_templateObject5$e = _taggedTemplateLiteralLoose(["\n width: 100%;\n display: flex;\n margin-left: 8px;\n"])));
|
|
25127
|
-
var Timer = styled__default.div(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 59px;\n bottom: 12px;\n display: inline-block;\n font-weight: 400;\n font-size: 11px;\n line-height: 12px;\n color: ", ";\n"])), function (props) {
|
|
26924
|
+
var Timer$1 = styled__default.div(_templateObject6$c || (_templateObject6$c = _taggedTemplateLiteralLoose(["\n position: absolute;\n left: 59px;\n bottom: 12px;\n display: inline-block;\n font-weight: 400;\n font-size: 11px;\n line-height: 12px;\n color: ", ";\n"])), function (props) {
|
|
25128
26925
|
return props.color;
|
|
25129
26926
|
});
|
|
25130
26927
|
|
|
@@ -30999,7 +32796,6 @@ function SvgRecordButton(props) {
|
|
|
30999
32796
|
|
|
31000
32797
|
var _templateObject$G, _templateObject2$B, _templateObject3$u, _templateObject4$q, _templateObject5$m, _templateObject6$i, _templateObject7$g;
|
|
31001
32798
|
var shouldDraw = false;
|
|
31002
|
-
var WaveSurfer;
|
|
31003
32799
|
var AudioRecord = function AudioRecord(_ref) {
|
|
31004
32800
|
var startRecording = function startRecording() {
|
|
31005
32801
|
try {
|
|
@@ -31241,60 +33037,48 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
31241
33037
|
if (recordedFile) {
|
|
31242
33038
|
var initWaveSurfer = function initWaveSurfer() {
|
|
31243
33039
|
try {
|
|
31244
|
-
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
wavesurfer.current.destroy();
|
|
31248
|
-
}
|
|
31249
|
-
wavesurfer.current = WaveSurfer["default"].create({
|
|
31250
|
-
container: wavesurferContainer.current,
|
|
31251
|
-
waveColor: textSecondary,
|
|
31252
|
-
skipLength: 0,
|
|
31253
|
-
progressColor: accentColor,
|
|
31254
|
-
barWidth: 1,
|
|
31255
|
-
barHeight: 2,
|
|
31256
|
-
audioRate: 1,
|
|
31257
|
-
hideScrollbar: true,
|
|
31258
|
-
barRadius: 1.5,
|
|
31259
|
-
cursorWidth: 0,
|
|
31260
|
-
barGap: 2.5,
|
|
31261
|
-
barMinHeight: 1.5,
|
|
31262
|
-
height: 28
|
|
31263
|
-
});
|
|
31264
|
-
wavesurfer.current.load(recordedFile.objectUrl);
|
|
31265
|
-
wavesurfer.current.on('ready', function () {
|
|
31266
|
-
setRecordingIsReadyToPlay(true);
|
|
31267
|
-
var audioDuration = wavesurfer.current.getDuration();
|
|
31268
|
-
setCurrentTime(audioDuration);
|
|
31269
|
-
});
|
|
31270
|
-
wavesurfer.current.on('finish', function () {
|
|
31271
|
-
setPlayAudio(false);
|
|
31272
|
-
wavesurfer.current.seekTo(0);
|
|
31273
|
-
var audioDuration = wavesurfer.current.getDuration();
|
|
31274
|
-
setCurrentTime(audioDuration);
|
|
31275
|
-
clearInterval(intervalRef.current);
|
|
31276
|
-
});
|
|
31277
|
-
wavesurfer.current.on('pause', function () {
|
|
31278
|
-
setPlayAudio(false);
|
|
31279
|
-
clearInterval(intervalRef.current);
|
|
31280
|
-
});
|
|
31281
|
-
wavesurfer.current.on('interaction', function () {
|
|
31282
|
-
var currentTime = wavesurfer.current.getCurrentTime();
|
|
31283
|
-
setCurrentTime(currentTime);
|
|
31284
|
-
});
|
|
33040
|
+
try {
|
|
33041
|
+
if (wavesurfer.current) {
|
|
33042
|
+
wavesurfer.current.destroy();
|
|
31285
33043
|
}
|
|
31286
|
-
|
|
31287
|
-
|
|
31288
|
-
|
|
31289
|
-
|
|
31290
|
-
|
|
31291
|
-
|
|
31292
|
-
|
|
31293
|
-
|
|
31294
|
-
|
|
33044
|
+
wavesurfer.current = WaveSurfer.create({
|
|
33045
|
+
container: wavesurferContainer.current,
|
|
33046
|
+
waveColor: textSecondary,
|
|
33047
|
+
progressColor: accentColor,
|
|
33048
|
+
barWidth: 1,
|
|
33049
|
+
barHeight: 2,
|
|
33050
|
+
audioRate: 1,
|
|
33051
|
+
hideScrollbar: true,
|
|
33052
|
+
barRadius: 1.5,
|
|
33053
|
+
cursorWidth: 0,
|
|
33054
|
+
barGap: 2.5,
|
|
33055
|
+
height: 28
|
|
33056
|
+
});
|
|
33057
|
+
wavesurfer.current.load(recordedFile.objectUrl);
|
|
33058
|
+
wavesurfer.current.on('ready', function () {
|
|
33059
|
+
setRecordingIsReadyToPlay(true);
|
|
33060
|
+
var audioDuration = wavesurfer.current.getDuration();
|
|
33061
|
+
setCurrentTime(audioDuration);
|
|
33062
|
+
});
|
|
33063
|
+
wavesurfer.current.on('finish', function () {
|
|
33064
|
+
setPlayAudio(false);
|
|
33065
|
+
wavesurfer.current.seekTo(0);
|
|
33066
|
+
var audioDuration = wavesurfer.current.getDuration();
|
|
33067
|
+
setCurrentTime(audioDuration);
|
|
33068
|
+
clearInterval(intervalRef.current);
|
|
33069
|
+
});
|
|
33070
|
+
wavesurfer.current.on('pause', function () {
|
|
33071
|
+
setPlayAudio(false);
|
|
33072
|
+
clearInterval(intervalRef.current);
|
|
33073
|
+
});
|
|
33074
|
+
wavesurfer.current.on('interaction', function () {
|
|
33075
|
+
var currentTime = wavesurfer.current.getCurrentTime();
|
|
33076
|
+
setCurrentTime(currentTime);
|
|
33077
|
+
});
|
|
33078
|
+
} catch (e) {
|
|
31295
33079
|
log.error('Failed to init wavesurfer', e);
|
|
31296
|
-
}
|
|
31297
|
-
return Promise.resolve(
|
|
33080
|
+
}
|
|
33081
|
+
return Promise.resolve();
|
|
31298
33082
|
} catch (e) {
|
|
31299
33083
|
return Promise.reject(e);
|
|
31300
33084
|
}
|
|
@@ -31312,9 +33096,9 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
31312
33096
|
React.useEffect(function () {
|
|
31313
33097
|
(function () {
|
|
31314
33098
|
try {
|
|
31315
|
-
var
|
|
33099
|
+
var _temp2 = function () {
|
|
31316
33100
|
if (!recorder) {
|
|
31317
|
-
var
|
|
33101
|
+
var _temp = _catch(function () {
|
|
31318
33102
|
return Promise.resolve(new Promise(function (resolve) { resolve(_interopNamespace(require('mic-recorder-to-mp3'))); })).then(function (MicRecorderModule) {
|
|
31319
33103
|
var MicRecorder = MicRecorderModule["default"];
|
|
31320
33104
|
var recorder = new MicRecorder({
|
|
@@ -31325,10 +33109,10 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
31325
33109
|
}, function (e) {
|
|
31326
33110
|
log.error('Failed to init mic-recorder-to-mp3', e);
|
|
31327
33111
|
});
|
|
31328
|
-
if (
|
|
33112
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
31329
33113
|
}
|
|
31330
33114
|
}();
|
|
31331
|
-
return
|
|
33115
|
+
return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
|
|
31332
33116
|
} catch (e) {
|
|
31333
33117
|
Promise.reject(e);
|
|
31334
33118
|
}
|
|
@@ -31352,7 +33136,7 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
31352
33136
|
hide: recordedFile,
|
|
31353
33137
|
id: 'waveform',
|
|
31354
33138
|
recording: recording
|
|
31355
|
-
}), recording && /*#__PURE__*/React__default.createElement(Timer$
|
|
33139
|
+
}), recording && /*#__PURE__*/React__default.createElement(Timer$2, {
|
|
31356
33140
|
color: textSecondary
|
|
31357
33141
|
}, formatAudioVideoTime(currentTime)), recordingIsReadyToPlay && (/*#__PURE__*/React__default.createElement(PlayPause$1, {
|
|
31358
33142
|
iconColor: accentColor,
|
|
@@ -31360,7 +33144,7 @@ var AudioRecord = function AudioRecord(_ref) {
|
|
|
31360
33144
|
}, playAudio ? /*#__PURE__*/React__default.createElement(SvgPauseRecord, null) : /*#__PURE__*/React__default.createElement(SvgPlayRecord, null))), /*#__PURE__*/React__default.createElement(AudioVisualization$1, {
|
|
31361
33145
|
ref: wavesurferContainer,
|
|
31362
33146
|
show: recordedFile
|
|
31363
|
-
}), recordingIsReadyToPlay && /*#__PURE__*/React__default.createElement(Timer$
|
|
33147
|
+
}), recordingIsReadyToPlay && /*#__PURE__*/React__default.createElement(Timer$2, {
|
|
31364
33148
|
color: textSecondary
|
|
31365
33149
|
}, formatAudioVideoTime(currentTime))), /*#__PURE__*/React__default.createElement(RecordIconWrapper, {
|
|
31366
33150
|
ref: recordButtonRef,
|
|
@@ -31408,7 +33192,7 @@ var Canvas = styled__default.canvas(_templateObject6$i || (_templateObject6$i =
|
|
|
31408
33192
|
var hide = _ref8.hide;
|
|
31409
33193
|
return hide && '-1';
|
|
31410
33194
|
});
|
|
31411
|
-
var Timer$
|
|
33195
|
+
var Timer$2 = styled__default.div(_templateObject7$g || (_templateObject7$g = _taggedTemplateLiteralLoose(["\n width: 40px;\n font-weight: 400;\n font-size: 16px;\n line-height: 12px;\n color: ", ";\n margin-left: auto;\n"])), function (props) {
|
|
31412
33196
|
return props.color;
|
|
31413
33197
|
});
|
|
31414
33198
|
|
|
@@ -31547,12 +33331,12 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
31547
33331
|
var _useColor = useColors(),
|
|
31548
33332
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
31549
33333
|
sectionBackground = _useColor[THEME_COLORS.SECTION_BACKGROUND],
|
|
31550
|
-
focusBackground = _useColor[THEME_COLORS.FOCUS_BACKGROUND],
|
|
31551
33334
|
surface1Background = _useColor[THEME_COLORS.SURFACE_1],
|
|
31552
33335
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
31553
33336
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
31554
33337
|
iconInactive = _useColor[THEME_COLORS.ICON_INACTIVE],
|
|
31555
|
-
errorColor = _useColor[THEME_COLORS.WARNING]
|
|
33338
|
+
errorColor = _useColor[THEME_COLORS.WARNING],
|
|
33339
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND];
|
|
31556
33340
|
var dispatch = reactRedux.useDispatch();
|
|
31557
33341
|
var ChatClient = getClient();
|
|
31558
33342
|
var user = ChatClient.user;
|
|
@@ -32648,13 +34432,13 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
32648
34432
|
color: errorColor
|
|
32649
34433
|
}, uploadErrorMessage), selectedMessagesMap && selectedMessagesMap.size > 0 ? (/*#__PURE__*/React__default.createElement(SelectedMessagesWrapper, null, selectedMessagesMap.size, " ", selectedMessagesMap.size > 1 ? ' messages selected' : ' message selected', /*#__PURE__*/React__default.createElement(CustomButton, {
|
|
32650
34434
|
onClick: handleToggleForwardMessagePopup,
|
|
32651
|
-
backgroundColor:
|
|
34435
|
+
backgroundColor: hoverBackground,
|
|
32652
34436
|
marginLeft: '32px',
|
|
32653
34437
|
color: textPrimary
|
|
32654
34438
|
}, /*#__PURE__*/React__default.createElement(SvgForward, null), "Forward"), /*#__PURE__*/React__default.createElement(CustomButton, {
|
|
32655
34439
|
onClick: handleToggleDeleteMessagePopup,
|
|
32656
34440
|
color: errorColor,
|
|
32657
|
-
backgroundColor:
|
|
34441
|
+
backgroundColor: hoverBackground,
|
|
32658
34442
|
marginLeft: '16px'
|
|
32659
34443
|
}, /*#__PURE__*/React__default.createElement(SvgDeleteIcon, null), "Delete"), /*#__PURE__*/React__default.createElement(CloseIconWrapper, {
|
|
32660
34444
|
onClick: handleCloseSelectMessages
|
|
@@ -32790,7 +34574,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
32790
34574
|
}, /*#__PURE__*/React__default.createElement(DropdownOptionsUl, null, showChooseMediaAttachment && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
32791
34575
|
key: 1,
|
|
32792
34576
|
textColor: textPrimary,
|
|
32793
|
-
hoverBackground:
|
|
34577
|
+
hoverBackground: hoverBackground,
|
|
32794
34578
|
onClick: function onClick() {
|
|
32795
34579
|
return onOpenFileUploader(mediaExtensions);
|
|
32796
34580
|
},
|
|
@@ -32799,7 +34583,7 @@ var SendMessageInput = function SendMessageInput(_ref3) {
|
|
|
32799
34583
|
}, /*#__PURE__*/React__default.createElement(SvgChoseMedia, null), chooseMediaAttachmentText != null ? chooseMediaAttachmentText : 'Photo or video')), showChooseFileAttachment && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
32800
34584
|
key: 2,
|
|
32801
34585
|
textColor: textPrimary,
|
|
32802
|
-
hoverBackground:
|
|
34586
|
+
hoverBackground: hoverBackground,
|
|
32803
34587
|
onClick: function onClick() {
|
|
32804
34588
|
return onOpenFileUploader('');
|
|
32805
34589
|
},
|
|
@@ -33314,7 +35098,7 @@ var Actions = function Actions(_ref) {
|
|
|
33314
35098
|
var _useColor = useColors(),
|
|
33315
35099
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
33316
35100
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
33317
|
-
|
|
35101
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND],
|
|
33318
35102
|
borderThemeColor = _useColor[THEME_COLORS.BORDER],
|
|
33319
35103
|
iconPrimary = _useColor[THEME_COLORS.ICON_PRIMARY],
|
|
33320
35104
|
errorColor = _useColor[THEME_COLORS.WARNING];
|
|
@@ -33484,7 +35268,7 @@ var Actions = function Actions(_ref) {
|
|
|
33484
35268
|
return /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33485
35269
|
textColor: textPrimary,
|
|
33486
35270
|
key: value + index,
|
|
33487
|
-
hoverBackground:
|
|
35271
|
+
hoverBackground: hoverBackground,
|
|
33488
35272
|
onClick: function onClick() {
|
|
33489
35273
|
return handleNotificationOnOff(value * oneHour);
|
|
33490
35274
|
}
|
|
@@ -33492,28 +35276,28 @@ var Actions = function Actions(_ref) {
|
|
|
33492
35276
|
}) : (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33493
35277
|
textColor: textPrimary,
|
|
33494
35278
|
key: 1,
|
|
33495
|
-
hoverBackground:
|
|
35279
|
+
hoverBackground: hoverBackground,
|
|
33496
35280
|
onClick: function onClick() {
|
|
33497
35281
|
return handleNotificationOnOff(oneHour);
|
|
33498
35282
|
}
|
|
33499
35283
|
}, "Mute for 1 hour"), /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33500
35284
|
textColor: textPrimary,
|
|
33501
35285
|
key: 2,
|
|
33502
|
-
hoverBackground:
|
|
35286
|
+
hoverBackground: hoverBackground,
|
|
33503
35287
|
onClick: function onClick() {
|
|
33504
35288
|
return handleNotificationOnOff(twoHours);
|
|
33505
35289
|
}
|
|
33506
35290
|
}, "Mute for 2 hours"), /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33507
35291
|
textColor: textPrimary,
|
|
33508
35292
|
key: 3,
|
|
33509
|
-
hoverBackground:
|
|
35293
|
+
hoverBackground: hoverBackground,
|
|
33510
35294
|
onClick: function onClick() {
|
|
33511
35295
|
return handleNotificationOnOff(oneDay);
|
|
33512
35296
|
}
|
|
33513
35297
|
}, "Mute for 1 day"))), /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33514
35298
|
textColor: textPrimary,
|
|
33515
35299
|
key: 4,
|
|
33516
|
-
hoverBackground:
|
|
35300
|
+
hoverBackground: hoverBackground,
|
|
33517
35301
|
onClick: function onClick() {
|
|
33518
35302
|
return handleNotificationOnOff();
|
|
33519
35303
|
}
|
|
@@ -33801,7 +35585,8 @@ var ChangeMemberRole = function ChangeMemberRole(_ref) {
|
|
|
33801
35585
|
surface1Background = _useColor[THEME_COLORS.SURFACE_1],
|
|
33802
35586
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
33803
35587
|
textFootnote = _useColor[THEME_COLORS.TEXT_FOOTNOTE],
|
|
33804
|
-
errorColor = _useColor[THEME_COLORS.WARNING]
|
|
35588
|
+
errorColor = _useColor[THEME_COLORS.WARNING],
|
|
35589
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND];
|
|
33805
35590
|
var dispatch = reactRedux.useDispatch();
|
|
33806
35591
|
var _useState = React.useState(false),
|
|
33807
35592
|
isChanged = _useState[0],
|
|
@@ -33860,7 +35645,7 @@ var ChangeMemberRole = function ChangeMemberRole(_ref) {
|
|
|
33860
35645
|
theme: theme
|
|
33861
35646
|
}, !!roles.length && roles.map(function (role) {
|
|
33862
35647
|
return /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
33863
|
-
hoverBackground:
|
|
35648
|
+
hoverBackground: hoverBackground,
|
|
33864
35649
|
key: role.name,
|
|
33865
35650
|
onClick: function onClick() {
|
|
33866
35651
|
return onChangeFunction(role.name);
|
|
@@ -33913,7 +35698,7 @@ var Members = function Members(_ref) {
|
|
|
33913
35698
|
var _useColor = useColors(),
|
|
33914
35699
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
33915
35700
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
33916
|
-
|
|
35701
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND],
|
|
33917
35702
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
33918
35703
|
errorColor = _useColor[THEME_COLORS.WARNING];
|
|
33919
35704
|
var dispatch = reactRedux.useDispatch();
|
|
@@ -34060,14 +35845,14 @@ var Members = function Members(_ref) {
|
|
|
34060
35845
|
key: 1,
|
|
34061
35846
|
onClick: handleAddMemberPopup,
|
|
34062
35847
|
color: textPrimary,
|
|
34063
|
-
hoverBackground: hoverBackgroundColor ||
|
|
35848
|
+
hoverBackground: hoverBackgroundColor || hoverBackground,
|
|
34064
35849
|
addMemberIconColor: accentColor,
|
|
34065
35850
|
fontSize: addMemberFontSize
|
|
34066
35851
|
}, addMemberIcon || /*#__PURE__*/React__default.createElement(SvgAddMember, null), "Add " + displayMemberText)), !!members.length && members.map(function (member, index) {
|
|
34067
35852
|
return /*#__PURE__*/React__default.createElement(MemberItem$1, {
|
|
34068
35853
|
key: member.id + index,
|
|
34069
35854
|
color: textPrimary,
|
|
34070
|
-
hoverBackground: hoverBackgroundColor ||
|
|
35855
|
+
hoverBackground: hoverBackgroundColor || hoverBackground,
|
|
34071
35856
|
onClick: function onClick() {
|
|
34072
35857
|
return handleCreateChat(member);
|
|
34073
35858
|
},
|
|
@@ -34102,7 +35887,7 @@ var Members = function Members(_ref) {
|
|
|
34102
35887
|
setCloseMenu('1');
|
|
34103
35888
|
},
|
|
34104
35889
|
key: 1,
|
|
34105
|
-
hoverBackground:
|
|
35890
|
+
hoverBackground: hoverBackground
|
|
34106
35891
|
}, "Change role")), showMakeMemberAdmin && checkActionPermission('changeMemberRole') && member.role !== 'owner' && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
34107
35892
|
onClick: function onClick(e) {
|
|
34108
35893
|
setSelectedMember(member);
|
|
@@ -34111,7 +35896,7 @@ var Members = function Members(_ref) {
|
|
|
34111
35896
|
},
|
|
34112
35897
|
textColor: member.role === 'admin' ? errorColor : '',
|
|
34113
35898
|
key: 2,
|
|
34114
|
-
hoverBackground:
|
|
35899
|
+
hoverBackground: hoverBackground
|
|
34115
35900
|
}, member.role === 'admin' ? 'Revoke Admin' : 'Make Admin')), showKickMember && checkActionPermission('kickMember') && member.role !== 'owner' && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
34116
35901
|
onClick: function onClick(e) {
|
|
34117
35902
|
setSelectedMember(member);
|
|
@@ -34120,11 +35905,11 @@ var Members = function Members(_ref) {
|
|
|
34120
35905
|
},
|
|
34121
35906
|
textColor: errorColor,
|
|
34122
35907
|
key: 3,
|
|
34123
|
-
hoverBackground:
|
|
35908
|
+
hoverBackground: hoverBackground
|
|
34124
35909
|
}, "Remove")), showKickAndBlockMember && checkActionPermission('kickAndBlockMember') && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
34125
35910
|
textColor: errorColor,
|
|
34126
35911
|
key: 4,
|
|
34127
|
-
hoverBackground:
|
|
35912
|
+
hoverBackground: hoverBackground,
|
|
34128
35913
|
onClick: function onClick(e) {
|
|
34129
35914
|
setSelectedMember(member);
|
|
34130
35915
|
toggleBlockMemberPopup(e);
|
|
@@ -34885,7 +36670,8 @@ var DetailsTab = function DetailsTab(_ref) {
|
|
|
34885
36670
|
var _useColor = useColors(),
|
|
34886
36671
|
accentColor = _useColor[THEME_COLORS.ACCENT],
|
|
34887
36672
|
textSecondary = _useColor[THEME_COLORS.TEXT_SECONDARY],
|
|
34888
|
-
borderThemeColor = _useColor[THEME_COLORS.BORDER]
|
|
36673
|
+
borderThemeColor = _useColor[THEME_COLORS.BORDER],
|
|
36674
|
+
backgroundColor = _useColor[THEME_COLORS.BACKGROUND];
|
|
34889
36675
|
var dispatch = reactRedux.useDispatch();
|
|
34890
36676
|
var isDirectChannel = channel.type === DEFAULT_CHANNEL_TYPE.DIRECT;
|
|
34891
36677
|
var showMembers = !isDirectChannel && checkActionPermission('getMembers');
|
|
@@ -34912,7 +36698,8 @@ var DetailsTab = function DetailsTab(_ref) {
|
|
|
34912
36698
|
borderColor: borderColor || borderThemeColor,
|
|
34913
36699
|
fontSize: tabItemsFontSize,
|
|
34914
36700
|
lineHeight: tabItemsLineHeight,
|
|
34915
|
-
minWidth: tabItemsMinWidth
|
|
36701
|
+
minWidth: tabItemsMinWidth,
|
|
36702
|
+
backgroundColor: backgroundColor
|
|
34916
36703
|
}, Object.keys(channelDetailsTabs).map(function (key) {
|
|
34917
36704
|
if (key === 'member') {
|
|
34918
36705
|
if (showMembers) {
|
|
@@ -34984,8 +36771,10 @@ var DetailsTab = function DetailsTab(_ref) {
|
|
|
34984
36771
|
})));
|
|
34985
36772
|
};
|
|
34986
36773
|
var Container$r = styled__default.div(_templateObject$R || (_templateObject$R = _taggedTemplateLiteralLoose(["\n //border-top: 1px solid ", ";\n"])), colors.gray1);
|
|
34987
|
-
var DetailsTabHeader = styled__default.div(_templateObject2$K || (_templateObject2$K = _taggedTemplateLiteralLoose(["\n overflow-x: auto;\n overflow-y: hidden;\n padding: 0 20px;\n border-bottom: 1px solid ", ";\n display: flex;\n justify-content: space-between;\n position: sticky;\n top: 0;\n z-index: 12;\n /* width */\n &::-webkit-scrollbar {\n width: 0;\n height: 0;\n }\n\n /* Track */\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n /* Handle on hover */\n &::-webkit-scrollbar-thumb:hover {\n background: transparent;\n }\n button {\n position: relative;\n border: none;\n background: transparent;\n outline: none;\n height: 44px;\n text-transform: capitalize;\n font-style: normal;\n font-weight: 500;\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n min-width: ", ";\n cursor: pointer;\n }\n\n & span {\n position: relative;\n display: inline-flex;\n align-items: center;\n height: 100%;\n }\n\n & .active span {\n color: ", ";\n\n &:after {\n content: '';\n width: 100%;\n border-radius: 2px;\n height: 2px;\n background-color: ", ";\n position: absolute;\n top: calc(100% - 1px);\n left: 0;\n }\n }\n"])), function (props) {
|
|
36774
|
+
var DetailsTabHeader = styled__default.div(_templateObject2$K || (_templateObject2$K = _taggedTemplateLiteralLoose(["\n overflow-x: auto;\n overflow-y: hidden;\n padding: 0 20px;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n display: flex;\n justify-content: space-between;\n position: sticky;\n top: 0;\n z-index: 12;\n /* width */\n &::-webkit-scrollbar {\n width: 0;\n height: 0;\n }\n\n /* Track */\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n &::-webkit-scrollbar-thumb {\n background: transparent;\n }\n\n /* Handle on hover */\n &::-webkit-scrollbar-thumb:hover {\n background: transparent;\n }\n button {\n position: relative;\n border: none;\n background: transparent;\n outline: none;\n height: 44px;\n text-transform: capitalize;\n font-style: normal;\n font-weight: 500;\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n min-width: ", ";\n cursor: pointer;\n }\n\n & span {\n position: relative;\n display: inline-flex;\n align-items: center;\n height: 100%;\n }\n\n & .active span {\n color: ", ";\n\n &:after {\n content: '';\n width: 100%;\n border-radius: 2px;\n height: 2px;\n background-color: ", ";\n position: absolute;\n top: calc(100% - 1px);\n left: 0;\n }\n }\n"])), function (props) {
|
|
34988
36775
|
return props.borderColor;
|
|
36776
|
+
}, function (props) {
|
|
36777
|
+
return props.backgroundColor || 'transparent';
|
|
34989
36778
|
}, function (props) {
|
|
34990
36779
|
return props.fontSize || '15px';
|
|
34991
36780
|
}, function (props) {
|
|
@@ -35025,7 +36814,8 @@ var EditChannel = function EditChannel(_ref) {
|
|
|
35025
36814
|
borderColor = _useColor[THEME_COLORS.BORDER],
|
|
35026
36815
|
textPrimary = _useColor[THEME_COLORS.TEXT_PRIMARY],
|
|
35027
36816
|
textFootnote = _useColor[THEME_COLORS.TEXT_FOOTNOTE],
|
|
35028
|
-
errorColor = _useColor[THEME_COLORS.WARNING]
|
|
36817
|
+
errorColor = _useColor[THEME_COLORS.WARNING],
|
|
36818
|
+
hoverBackground = _useColor[THEME_COLORS.HOVER_BACKGROUND];
|
|
35029
36819
|
var ChatClient = getClient();
|
|
35030
36820
|
var user = ChatClient.user;
|
|
35031
36821
|
var dispatch = reactRedux.useDispatch();
|
|
@@ -35170,7 +36960,7 @@ var EditChannel = function EditChannel(_ref) {
|
|
|
35170
36960
|
}, /*#__PURE__*/React__default.createElement(DropdownOptionsUl, null, /*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
35171
36961
|
key: 1,
|
|
35172
36962
|
textColor: textPrimary,
|
|
35173
|
-
hoverBackground:
|
|
36963
|
+
hoverBackground: hoverBackground,
|
|
35174
36964
|
onClick: function onClick() {
|
|
35175
36965
|
return onOpenFileUploader();
|
|
35176
36966
|
},
|
|
@@ -35182,7 +36972,7 @@ var EditChannel = function EditChannel(_ref) {
|
|
|
35182
36972
|
type: 'file'
|
|
35183
36973
|
})), newAvatar.url && (/*#__PURE__*/React__default.createElement(DropdownOptionLi, {
|
|
35184
36974
|
key: 2,
|
|
35185
|
-
hoverBackground:
|
|
36975
|
+
hoverBackground: hoverBackground,
|
|
35186
36976
|
textColor: errorColor,
|
|
35187
36977
|
onClick: handleToggleDeleteAvatarPopup,
|
|
35188
36978
|
iconWidth: '20px'
|