wavesurfer.js 6.3.0 → 6.5.0
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/LICENSE +1 -1
- package/README.md +36 -47
- package/dist/plugin/wavesurfer.cursor.js +45 -54
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +24 -51
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +62 -74
- package/dist/plugin/wavesurfer.markers.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +2 -2
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +8 -16
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +48 -63
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +20 -69
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +6 -30
- package/dist/plugin/wavesurfer.playhead.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +2 -2
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +203 -260
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +55 -147
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +53 -88
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +34 -54
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +490 -1003
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +11 -11
- package/src/mediaelement.js +3 -0
- package/src/plugin/cursor/index.js +15 -3
- package/src/plugin/markers/index.js +40 -1
- package/src/plugin/regions/index.js +4 -0
- package/src/plugin/regions/region.js +76 -1
- package/src/util/silence-mode.js +7 -0
- package/src/wavesurfer.js +4 -0
- package/CHANGES.md +0 -482
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js 6.
|
|
2
|
+
* wavesurfer.js 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -29,19 +29,14 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
29
29
|
value: true
|
|
30
30
|
}));
|
|
31
31
|
exports["default"] = void 0;
|
|
32
|
-
|
|
33
32
|
var _loadScript = _interopRequireDefault(__webpack_require__(/*! load-script */ "./node_modules/load-script/index.js"));
|
|
34
|
-
|
|
35
33
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
-
|
|
37
34
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
38
|
-
|
|
39
35
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
40
|
-
|
|
41
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
42
|
-
|
|
36
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
43
37
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
44
|
-
|
|
38
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
39
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
45
40
|
/**
|
|
46
41
|
* @typedef {Object} InitParams
|
|
47
42
|
* @property {WavesurferParams} [defaults={backend: 'MediaElement,
|
|
@@ -54,7 +49,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
54
49
|
* @property {function} loadPlugin If set overwrites the default request function,
|
|
55
50
|
* can be used to inject plugins differently.
|
|
56
51
|
*/
|
|
57
|
-
|
|
58
52
|
/**
|
|
59
53
|
* The HTML initialisation API is not part of the main library bundle file and
|
|
60
54
|
* must be additionally included.
|
|
@@ -103,24 +97,21 @@ var Init = /*#__PURE__*/function () {
|
|
|
103
97
|
*/
|
|
104
98
|
function Init(WaveSurfer) {
|
|
105
99
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
106
|
-
|
|
107
100
|
_classCallCheck(this, Init);
|
|
108
|
-
|
|
109
101
|
if (!WaveSurfer) {
|
|
110
102
|
throw new Error('WaveSurfer is not available!');
|
|
111
103
|
}
|
|
104
|
+
|
|
112
105
|
/**
|
|
113
106
|
* cache WaveSurfer
|
|
114
107
|
* @private
|
|
115
108
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
109
|
this.WaveSurfer = WaveSurfer;
|
|
110
|
+
|
|
119
111
|
/**
|
|
120
112
|
* build parameters, cache them in _params so minified builds are smaller
|
|
121
113
|
* @private
|
|
122
114
|
*/
|
|
123
|
-
|
|
124
115
|
var _params = this.params = Object.assign({}, {
|
|
125
116
|
// wavesurfer parameter defaults so by default the audio player is
|
|
126
117
|
// usable with native media element controls
|
|
@@ -137,7 +128,6 @@ var Init = /*#__PURE__*/function () {
|
|
|
137
128
|
// and pass it to a callback
|
|
138
129
|
loadPlugin: function loadPlugin(name, cb) {
|
|
139
130
|
var src = _params.pluginCdnTemplate.replace('[name]', name);
|
|
140
|
-
|
|
141
131
|
(0, _loadScript.default)(src, {
|
|
142
132
|
async: false
|
|
143
133
|
}, function (err, plugin) {
|
|
@@ -145,7 +135,6 @@ var Init = /*#__PURE__*/function () {
|
|
|
145
135
|
// eslint-disable-next-line no-console
|
|
146
136
|
return console.error("WaveSurfer plugin ".concat(name, " not found at ").concat(src));
|
|
147
137
|
}
|
|
148
|
-
|
|
149
138
|
cb(window.WaveSurfer[name]);
|
|
150
139
|
});
|
|
151
140
|
}
|
|
@@ -154,46 +143,40 @@ var Init = /*#__PURE__*/function () {
|
|
|
154
143
|
* The nodes that should have instances attached to them
|
|
155
144
|
* @type {NodeList}
|
|
156
145
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
146
|
this.containers = typeof _params.containers == 'string' ? document.querySelectorAll(_params.containers) : _params.containers;
|
|
160
147
|
/** @private */
|
|
161
|
-
|
|
162
148
|
this.pluginCache = {};
|
|
163
149
|
/**
|
|
164
150
|
* An array of wavesurfer instances
|
|
165
151
|
* @type {Object[]}
|
|
166
152
|
*/
|
|
167
|
-
|
|
168
153
|
this.instances = [];
|
|
169
154
|
this.initAllEls();
|
|
170
155
|
}
|
|
156
|
+
|
|
171
157
|
/**
|
|
172
158
|
* Initialize all container elements
|
|
173
159
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
160
|
_createClass(Init, [{
|
|
177
161
|
key: "initAllEls",
|
|
178
162
|
value: function initAllEls() {
|
|
179
163
|
var _this = this;
|
|
180
|
-
|
|
181
164
|
// iterate over all the container elements
|
|
182
165
|
Array.prototype.forEach.call(this.containers, function (el) {
|
|
183
166
|
// load the plugins as an array of plugin names
|
|
184
|
-
var plugins = el.dataset.plugins ? el.dataset.plugins.split(',') : [];
|
|
167
|
+
var plugins = el.dataset.plugins ? el.dataset.plugins.split(',') : [];
|
|
185
168
|
|
|
169
|
+
// no plugins to be loaded, just render
|
|
186
170
|
if (!plugins.length) {
|
|
187
171
|
return _this.initEl(el);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
172
|
+
}
|
|
173
|
+
// … or: iterate over all the plugins
|
|
191
174
|
plugins.forEach(function (name, i) {
|
|
192
175
|
// plugin is not cached already, load it
|
|
193
176
|
if (!_this.pluginCache[name]) {
|
|
194
177
|
_this.params.loadPlugin(name, function (lib) {
|
|
195
|
-
_this.pluginCache[name] = lib;
|
|
196
|
-
|
|
178
|
+
_this.pluginCache[name] = lib;
|
|
179
|
+
// plugins were all loaded, render the element
|
|
197
180
|
if (i + 1 === plugins.length) {
|
|
198
181
|
_this.initEl(el, plugins);
|
|
199
182
|
}
|
|
@@ -205,6 +188,7 @@ var Init = /*#__PURE__*/function () {
|
|
|
205
188
|
});
|
|
206
189
|
});
|
|
207
190
|
}
|
|
191
|
+
|
|
208
192
|
/**
|
|
209
193
|
* Initialize a single container element and add to `this.instances`
|
|
210
194
|
*
|
|
@@ -212,61 +196,57 @@ var Init = /*#__PURE__*/function () {
|
|
|
212
196
|
* @param {PluginDefinition[]} plugins An Array of plugin names to initialize with
|
|
213
197
|
* @return {Object} Wavesurfer instance
|
|
214
198
|
*/
|
|
215
|
-
|
|
216
199
|
}, {
|
|
217
200
|
key: "initEl",
|
|
218
201
|
value: function initEl(el) {
|
|
219
202
|
var _this2 = this;
|
|
220
|
-
|
|
221
203
|
var plugins = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
222
|
-
var jsonRegex = /^[[|{]/;
|
|
223
|
-
|
|
204
|
+
var jsonRegex = /^[[|{]/;
|
|
205
|
+
// initialize plugins with the correct options
|
|
224
206
|
var initialisedPlugins = plugins.map(function (plugin) {
|
|
225
|
-
var options = {};
|
|
226
|
-
|
|
207
|
+
var options = {};
|
|
208
|
+
// the regex to find this plugin attributes
|
|
227
209
|
var attrNameRegex = new RegExp('^' + plugin);
|
|
228
|
-
var attrName;
|
|
210
|
+
var attrName;
|
|
211
|
+
// iterate over all the data attributes and find ones for this
|
|
229
212
|
// plugin
|
|
230
|
-
|
|
231
213
|
for (attrName in el.dataset) {
|
|
232
214
|
var regexResult = attrNameRegex.exec(attrName);
|
|
233
|
-
|
|
234
215
|
if (regexResult) {
|
|
235
|
-
var attr = el.dataset[attrName];
|
|
236
|
-
|
|
237
|
-
var prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;
|
|
216
|
+
var attr = el.dataset[attrName];
|
|
217
|
+
// if the string begins with a [ or a { parse it as JSON
|
|
218
|
+
var prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;
|
|
219
|
+
// this removes the plugin prefix and changes the first letter
|
|
238
220
|
// of the resulting string to lower case to follow the naming
|
|
239
221
|
// convention of ws params
|
|
240
|
-
|
|
241
222
|
var unprefixedOptionName = attrName.slice(plugin.length, plugin.length + 1).toLowerCase() + attrName.slice(plugin.length + 1);
|
|
242
223
|
options[unprefixedOptionName] = prop;
|
|
243
224
|
}
|
|
244
225
|
}
|
|
245
|
-
|
|
246
226
|
return _this2.pluginCache[plugin].create(options);
|
|
247
|
-
});
|
|
248
|
-
|
|
227
|
+
});
|
|
228
|
+
// build parameter object for this container
|
|
249
229
|
var params = Object.assign({
|
|
250
230
|
container: el
|
|
251
231
|
}, this.params.defaults, el.dataset, {
|
|
252
232
|
plugins: initialisedPlugins
|
|
253
|
-
});
|
|
233
|
+
});
|
|
254
234
|
|
|
255
|
-
|
|
235
|
+
// @TODO make nicer
|
|
236
|
+
el.style.display = 'block';
|
|
256
237
|
|
|
238
|
+
// initialize wavesurfer, load audio (with peaks if provided)
|
|
257
239
|
var instance = this.WaveSurfer.create(params);
|
|
258
240
|
var peaks = params.peaks ? JSON.parse(params.peaks) : undefined;
|
|
259
|
-
instance.load(params.url, peaks);
|
|
241
|
+
instance.load(params.url, peaks);
|
|
260
242
|
|
|
243
|
+
// push this instance into the instances cache
|
|
261
244
|
this.instances.push(instance);
|
|
262
245
|
return instance;
|
|
263
246
|
}
|
|
264
247
|
}]);
|
|
265
|
-
|
|
266
248
|
return Init;
|
|
267
249
|
}(); // if window object exists and window.WS_StopAutoInit is not true
|
|
268
|
-
|
|
269
|
-
|
|
270
250
|
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.WS_StopAutoInit) {
|
|
271
251
|
// call init when document is ready, apply any custom default settings
|
|
272
252
|
// in window.WS_InitOptions
|
|
@@ -277,9 +257,9 @@ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object'
|
|
|
277
257
|
window.WaveSurferInit = new Init(window.WaveSurfer, window.WS_InitOptions);
|
|
278
258
|
});
|
|
279
259
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
260
|
+
}
|
|
282
261
|
|
|
262
|
+
// export init for manual usage
|
|
283
263
|
var _default = Init;
|
|
284
264
|
exports["default"] = _default;
|
|
285
265
|
module.exports = exports.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer-html-init.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;ACVA;;;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACMA;EACF;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACI,cAAYC,UAAZ,EAAqC;IAAA,IAAbC,MAAa,uEAAJ,EAAI;;IAAA;;IACjC,IAAI,CAACD,UAAL,EAAiB;MACb,MAAM,IAAIE,KAAJ,CAAU,8BAAV,CAAN;IACH;IAED;AACR;AACA;AACA;;;IACQ,KAAKF,UAAL,GAAkBA,UAAlB;IAEA;AACR;AACA;AACA;;IACQ,IAAMG,OAAO,GAAI,KAAKF,MAAL,GAAcG,MAAM,CAACC,MAAP,CAC3B,EAD2B,EAE3B;MACI;MACA;MACAC,QAAQ,EAAE;QACNC,OAAO,EAAE,cADH;QAENC,aAAa,EAAE;MAFT,CAHd;MAOI;MACAC,UAAU,EAAE,YARhB;MASI;MACAC,iBAAiB,EACb,mDAXR;MAYI;MACA;MACA;MACAC,UAfJ,sBAeeC,IAff,EAeqBC,EAfrB,EAeyB;QACjB,IAAMC,GAAG,GAAGX,OAAO,C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AJ,CACpBuB,MAAM,CAACtB,UADa,EAEpBsB,MAAM,CAACgD,cAFa,CAAxB;EAIH,CALD,MAKO;IACHhD,MAAM,CAACiD,gBAAP,CAAwB,MAAxB,EAAgC,YAAM;MAClCjD,MAAM,CAAC+C,cAAP,GAAwB,IAAItE,IAAJ,CACpBuB,MAAM,CAACtB,UADa,EAEpBsB,MAAM,CAACgD,cAFa,CAAxB;IAIH,CALD;EAMH;AACJ,EAED;;;eACevE;;;;;;;;;;;;;AC/Of;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;UChEA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/html-init.js","webpack://WaveSurfer/./node_modules/load-script/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(self, () => {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/html-init.js\");\n",""],"names":["Init","WaveSurfer","params","Error","_params","Object","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","loadScript","async","err","plugin","console","error","window","document","querySelectorAll","pluginCache","instances","initAllEls","Array","prototype","forEach","call","el","plugins","dataset","split","length","initEl","i","lib","jsonRegex","initialisedPlugins","map","options","attrNameRegex","RegExp","attrName","regexResult","exec","attr","prop","test","JSON","parse","unprefixedOptionName","slice","toLowerCase","create","container","style","display","instance","peaks","undefined","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer-html-init.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;ACVA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,mBAAA;AAAqC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAH,GAAA,sCAAAG,OAAA,wBAAAC,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAL,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAI,MAAA,IAAAJ,GAAA,CAAAM,WAAA,KAAAF,MAAA,IAAAJ,GAAA,KAAAI,MAAA,CAAAG,SAAA,qBAAAP,GAAA,KAAAG,OAAA,CAAAH,GAAA;AAAA,SAAAQ,gBAAAC,QAAA,EAAAC,WAAA,UAAAD,QAAA,YAAAC,WAAA,eAAAC,SAAA;AAAA,SAAAC,kBAAAC,MAAA,EAAAC,KAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAD,KAAA,CAAAE,MAAA,EAAAD,CAAA,UAAAE,UAAA,GAAAH,KAAA,CAAAC,CAAA,GAAAE,UAAA,CAAAC,UAAA,GAAAD,UAAA,CAAAC,UAAA,WAA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AA,GAAAA,OAAA,CAAA7G,OAAA;;;;;;;;;;;AC/OnB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;UChEA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/html-init.js","webpack://WaveSurfer/./node_modules/load-script/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(self, () => {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/html-init.js\");\n",""],"names":["_loadScript","_interopRequireDefault","require","obj","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","protoProps","staticProps","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","Number","Init","WaveSurfer","params","arguments","Error","_params","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","loadScript","async","err","plugin","console","error","concat","window","document","querySelectorAll","pluginCache","instances","initAllEls","value","_this","Array","forEach","el","plugins","dataset","split","initEl","lib","_this2","jsonRegex","initialisedPlugins","map","options","attrNameRegex","RegExp","attrName","regexResult","exec","attr","prop","test","JSON","parse","unprefixedOptionName","slice","toLowerCase","create","container","style","display","peaks","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","_default","exports","module"],"sourceRoot":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js 6.
|
|
2
|
+
* wavesurfer.js 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer["html-init"]=t())}(self,(()=>{return e={531:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(90))&&r.__esModule?r:{default:r};function
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer["html-init"]=t())}(self,(()=>{return e={531:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(90))&&r.__esModule?r:{default:r};function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,a=void 0,a=function(e,t){if("object"!==i(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===i(a)?a:String(a)),r)}var o,a}var l=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new Error("WaveSurfer is not available!");this.WaveSurfer=t;var r=this.params=Object.assign({},{defaults:{backend:"MediaElement",mediaControls:!0},containers:"wavesurfer",pluginCdnTemplate:"//localhost:8080/dist/plugin/wavesurfer.[name].js",loadPlugin:function(e,t){var n=r.pluginCdnTemplate.replace("[name]",e);(0,o.default)(n,{async:!1},(function(r,o){if(r)return console.error("WaveSurfer plugin ".concat(e," not found at ").concat(n));t(window.WaveSurfer[e])}))}},n);this.containers="string"==typeof r.containers?document.querySelectorAll(r.containers):r.containers,this.pluginCache={},this.instances=[],this.initAllEls()}var t,n,r;return t=e,n=[{key:"initAllEls",value:function(){var e=this;Array.prototype.forEach.call(this.containers,(function(t){var n=t.dataset.plugins?t.dataset.plugins.split(","):[];if(!n.length)return e.initEl(t);n.forEach((function(r,o){e.pluginCache[r]?o===n.length&&e.initEl(t,n):e.params.loadPlugin(r,(function(i){e.pluginCache[r]=i,o+1===n.length&&e.initEl(t,n)}))}))}))}},{key:"initEl",value:function(e){var t=this,n=/^[[|{]/,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).map((function(r){var o,i={},a=new RegExp("^"+r);for(o in e.dataset)if(a.exec(o)){var l=e.dataset[o],u=n.test(l)?JSON.parse(l):l;i[o.slice(r.length,r.length+1).toLowerCase()+o.slice(r.length+1)]=u}return t.pluginCache[r].create(i)})),o=Object.assign({container:e},this.params.defaults,e.dataset,{plugins:r});e.style.display="block";var i=this.WaveSurfer.create(o),a=o.peaks?JSON.parse(o.peaks):void 0;return i.load(o.url,a),this.instances.push(i),i}}],n&&a(t.prototype,n),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();"object"!==("undefined"==typeof window?"undefined":i(window))||window.WS_StopAutoInit||("complete"===document.readyState?window.WaveSurferInit=new l(window.WaveSurfer,window.WS_InitOptions):window.addEventListener("load",(function(){window.WaveSurferInit=new l(window.WaveSurfer,window.WS_InitOptions)})));var u=l;t.default=u,e.exports=t.default},90:e=>{function t(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function n(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}e.exports=function(e,r,o){var i=document.head||document.getElementsByTagName("head")[0],a=document.createElement("script");"function"==typeof r&&(o=r,r={}),r=r||{},o=o||function(){},a.type=r.type||"text/javascript",a.charset=r.charset||"utf8",a.async=!("async"in r)||!!r.async,a.src=e,r.attrs&&function(e,t){for(var n in t)e.setAttribute(n,t[n])}(a,r.attrs),r.text&&(a.text=""+r.text),("onload"in a?t:n)(a,o),a.onload||t(a,o),i.appendChild(a)}}},t={},function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}(531);var e,t}));
|
|
7
7
|
//# sourceMappingURL=wavesurfer-html-init.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer-html-init.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,CAAC,EA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B,K,EJO9C,I,EGTIF,ECEAC,C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/html-init.js","webpack://WaveSurfer/./node_modules/load-script/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(self, () => {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(531);\n"],"names":["root","factory","exports","module","define","amd","self","Init","WaveSurfer","params","Error","this","_params","Object","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","loadScript","async","err","plugin","console","error","window","document","querySelectorAll","pluginCache","instances","initAllEls","Array","prototype","forEach","call","el","plugins","dataset","split","length","initEl","i","lib","jsonRegex","initialisedPlugins","map","attrName","options","attrNameRegex","RegExp","exec","attr","prop","test","JSON","parse","slice","toLowerCase","create","container","style","display","instance","peaks","undefined","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","stdOnEnd","script","onload","onerror","ieOnEnd","onreadystatechange","opts","head","getElementsByTagName","createElement","type","charset","attrs","setAttribute","setAttributes","text","appendChild","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer-html-init.min.js","mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,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AASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBtG,IAAjBuG,EACH,OAAOA,EAAavI,QAGrB,IAAIC,EAASmI,EAAyBE,GAAY,CAGjDtI,QAAS,CAAC,GAOX,OAHAwI,EAAoBF,GAAUrI,EAAQA,EAAOD,QAASqI,GAG/CpI,EAAOD,OACf,CCnB0BqI,CAAoB,KJO9C,I,EGTID,C","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/html-init.js","webpack://WaveSurfer/./node_modules/load-script/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"html-init\"] = factory();\n})(self, () => {\nreturn ","import loadScript from 'load-script';\n\n/**\n * @typedef {Object} InitParams\n * @property {WavesurferParams} [defaults={backend: 'MediaElement,\n * mediaControls: true}] The default wavesurfer initialisation parameters\n * @property {string|NodeList} containers='wavesurfer' Selector or NodeList of\n * elements to attach instances to\n * @property {string}\n * pluginCdnTemplate='//localhost:8080/dist/plugin/wavesurfer.[name].js' URL\n * template for the dynamic loading of plugins\n * @property {function} loadPlugin If set overwrites the default request function,\n * can be used to inject plugins differently.\n */\n/**\n * The HTML initialisation API is not part of the main library bundle file and\n * must be additionally included.\n *\n * The API attaches wavesurfer instances to all `<wavesurfer>` (can be\n * customised), parsing their `data-` attributes to construct an options object\n * for initialisation. Among other things it can dynamically load plugin code.\n *\n * The automatic initialisation can be prevented by setting the\n * `window.WS_StopAutoInit` flag to true. The `html-init[.min].js` file exports\n * the `Init` class, which can be called manually.\n *\n * Site-wide defaults can be added by setting `window.WS_InitOptions`.\n *\n * @example\n * <!-- with minimap and timeline plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"minimap,timeline\"\n * data-minimap-height=\"30\"\n * data-minimap-wave-color=\"#ddd\"\n * data-minimap-progress-color=\"#999\"\n * data-timeline-font-size=\"13px\"\n * data-timeline-container=\"#timeline\"\n * >\n * </wavesurfer>\n * <div id=\"timeline\"></div>\n *\n * <!-- with regions plugin -->\n * <wavesurfer\n * data-url=\"../media/demo.wav\"\n * data-plugins=\"regions\"\n * data-regions-regions='[{\"start\": 1,\"end\": 3,\"color\": \"hsla(400, 100%, 30%, 0.5)\"}]'\n * >\n * </wavesurfer>\n */\nclass Init {\n /**\n * Instantiate Init class and initialize elements\n *\n * This is done automatically if `window` is defined and\n * `window.WS_StopAutoInit` is not set to true\n *\n * @param {WaveSurfer} WaveSurfer The WaveSurfer library object\n * @param {InitParams} params initialisation options\n */\n constructor(WaveSurfer, params = {}) {\n if (!WaveSurfer) {\n throw new Error('WaveSurfer is not available!');\n }\n\n /**\n * cache WaveSurfer\n * @private\n */\n this.WaveSurfer = WaveSurfer;\n\n /**\n * build parameters, cache them in _params so minified builds are smaller\n * @private\n */\n const _params = (this.params = Object.assign(\n {},\n {\n // wavesurfer parameter defaults so by default the audio player is\n // usable with native media element controls\n defaults: {\n backend: 'MediaElement',\n mediaControls: true\n },\n // containers to instantiate on, can be selector string or NodeList\n containers: 'wavesurfer',\n // @TODO insert plugin CDN URIs\n pluginCdnTemplate:\n '//localhost:8080/dist/plugin/wavesurfer.[name].js',\n // loadPlugin function can be overridden to inject plugin definition\n // objects, this default function uses load-script to load a plugin\n // and pass it to a callback\n loadPlugin(name, cb) {\n const src = _params.pluginCdnTemplate.replace(\n '[name]',\n name\n );\n loadScript(src, { async: false }, (err, plugin) => {\n if (err) {\n // eslint-disable-next-line no-console\n return console.error(\n `WaveSurfer plugin ${name} not found at ${src}`\n );\n }\n cb(window.WaveSurfer[name]);\n });\n }\n },\n params\n ));\n /**\n * The nodes that should have instances attached to them\n * @type {NodeList}\n */\n this.containers =\n typeof _params.containers == 'string'\n ? document.querySelectorAll(_params.containers)\n : _params.containers;\n /** @private */\n this.pluginCache = {};\n /**\n * An array of wavesurfer instances\n * @type {Object[]}\n */\n this.instances = [];\n\n this.initAllEls();\n }\n\n /**\n * Initialize all container elements\n */\n initAllEls() {\n // iterate over all the container elements\n Array.prototype.forEach.call(this.containers, el => {\n // load the plugins as an array of plugin names\n const plugins = el.dataset.plugins\n ? el.dataset.plugins.split(',')\n : [];\n\n // no plugins to be loaded, just render\n if (!plugins.length) {\n return this.initEl(el);\n }\n // … or: iterate over all the plugins\n plugins.forEach((name, i) => {\n // plugin is not cached already, load it\n if (!this.pluginCache[name]) {\n this.params.loadPlugin(name, lib => {\n this.pluginCache[name] = lib;\n // plugins were all loaded, render the element\n if (i + 1 === plugins.length) {\n this.initEl(el, plugins);\n }\n });\n } else if (i === plugins.length) {\n // plugin was cached and this plugin was the last\n this.initEl(el, plugins);\n }\n });\n });\n }\n\n /**\n * Initialize a single container element and add to `this.instances`\n *\n * @param {HTMLElement} el The container to instantiate wavesurfer to\n * @param {PluginDefinition[]} plugins An Array of plugin names to initialize with\n * @return {Object} Wavesurfer instance\n */\n initEl(el, plugins = []) {\n const jsonRegex = /^[[|{]/;\n // initialize plugins with the correct options\n const initialisedPlugins = plugins.map(plugin => {\n const options = {};\n // the regex to find this plugin attributes\n const attrNameRegex = new RegExp('^' + plugin);\n let attrName;\n // iterate over all the data attributes and find ones for this\n // plugin\n for (attrName in el.dataset) {\n const regexResult = attrNameRegex.exec(attrName);\n if (regexResult) {\n const attr = el.dataset[attrName];\n // if the string begins with a [ or a { parse it as JSON\n const prop = jsonRegex.test(attr) ? JSON.parse(attr) : attr;\n // this removes the plugin prefix and changes the first letter\n // of the resulting string to lower case to follow the naming\n // convention of ws params\n const unprefixedOptionName =\n attrName\n .slice(plugin.length, plugin.length + 1)\n .toLowerCase() + attrName.slice(plugin.length + 1);\n options[unprefixedOptionName] = prop;\n }\n }\n return this.pluginCache[plugin].create(options);\n });\n // build parameter object for this container\n const params = Object.assign(\n { container: el },\n this.params.defaults,\n el.dataset,\n { plugins: initialisedPlugins }\n );\n\n // @TODO make nicer\n el.style.display = 'block';\n\n // initialize wavesurfer, load audio (with peaks if provided)\n const instance = this.WaveSurfer.create(params);\n const peaks = params.peaks ? JSON.parse(params.peaks) : undefined;\n instance.load(params.url, peaks);\n\n // push this instance into the instances cache\n this.instances.push(instance);\n return instance;\n }\n}\n\n// if window object exists and window.WS_StopAutoInit is not true\nif (typeof window === 'object' && !window.WS_StopAutoInit) {\n // call init when document is ready, apply any custom default settings\n // in window.WS_InitOptions\n if (document.readyState === 'complete') {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n } else {\n window.addEventListener('load', () => {\n window.WaveSurferInit = new Init(\n window.WaveSurfer,\n window.WS_InitOptions\n );\n });\n }\n}\n\n// export init for manual usage\nexport default Init;\n","\nmodule.exports = function load (src, opts, cb) {\n var head = document.head || document.getElementsByTagName('head')[0]\n var script = document.createElement('script')\n\n if (typeof opts === 'function') {\n cb = opts\n opts = {}\n }\n\n opts = opts || {}\n cb = cb || function() {}\n\n script.type = opts.type || 'text/javascript'\n script.charset = opts.charset || 'utf8';\n script.async = 'async' in opts ? !!opts.async : true\n script.src = src\n\n if (opts.attrs) {\n setAttributes(script, opts.attrs)\n }\n\n if (opts.text) {\n script.text = '' + opts.text\n }\n\n var onend = 'onload' in script ? stdOnEnd : ieOnEnd\n onend(script, cb)\n\n // some good legacy browsers (firefox) fail the 'in' detection above\n // so as a fallback we always set onload\n // old IE will ignore this and new IE will set onload\n if (!script.onload) {\n stdOnEnd(script, cb);\n }\n\n head.appendChild(script)\n}\n\nfunction setAttributes(script, attrs) {\n for (var attr in attrs) {\n script.setAttribute(attr, attrs[attr]);\n }\n}\n\nfunction stdOnEnd (script, cb) {\n script.onload = function () {\n this.onerror = this.onload = null\n cb(null, script)\n }\n script.onerror = function () {\n // this.onload = null here is necessary\n // because even IE9 works not like others\n this.onerror = this.onload = null\n cb(new Error('Failed to load ' + this.src), script)\n }\n}\n\nfunction ieOnEnd (script, cb) {\n script.onreadystatechange = function () {\n if (this.readyState != 'complete' && this.readyState != 'loaded') return\n this.onreadystatechange = null\n cb(null, script) // there is no way to catch loading errors in IE8\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(531);\n"],"names":["root","factory","exports","module","define","amd","self","obj","_loadScript","require","__esModule","default","_typeof","Symbol","iterator","constructor","prototype","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","arg","key","input","hint","prim","toPrimitive","undefined","res","call","TypeError","String","Number","_toPrimitive","Init","WaveSurfer","params","arguments","instance","Constructor","_classCallCheck","Error","this","_params","assign","defaults","backend","mediaControls","containers","pluginCdnTemplate","loadPlugin","name","cb","src","replace","loadScript","async","err","plugin","console","error","concat","window","document","querySelectorAll","pluginCache","instances","initAllEls","protoProps","staticProps","value","_this","Array","forEach","el","plugins","dataset","split","initEl","lib","_this2","jsonRegex","initialisedPlugins","map","attrName","options","attrNameRegex","RegExp","exec","attr","prop","test","JSON","parse","slice","toLowerCase","create","container","style","display","peaks","load","url","push","WS_StopAutoInit","readyState","WaveSurferInit","WS_InitOptions","addEventListener","_default","stdOnEnd","script","onload","onerror","ieOnEnd","onreadystatechange","opts","head","getElementsByTagName","createElement","type","charset","attrs","setAttribute","setAttributes","text","appendChild","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"sourceRoot":""}
|