-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648314f
commit 4e08ee3
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// This is the minified and stringified code of the extendable-media-recorder-wav-encoder-worker package. | ||
export const worker = `(()=>{var e={312:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,l=r(i),c=o(l,i),u=t(c);e.addUniqueNumber=u,e.generateUniqueNumber=c}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),o=(t,r)=>async o=>{let{data:{id:i,method:l,params:c}}=o;const u=r[l];try{if(void 0===u)throw(e=>s('The requested method called "'.concat(e,'" is not supported.'),n))(l);const r=void 0===c?u():u(c);if(void 0===r)throw(t=>s('The handler of the method called "'.concat(t,'" returned no required result.'),e))(l);const o=r instanceof Promise?await r:r;if(null===i){if(void 0!==o.result)throw a(l)}else{if(void 0===o.result)throw a(l);const{result:e,transferables:r=[]}=o;t.postMessage({id:i,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:i})}};var i=r(312);const l=new Map,c=(e,r,n)=>({...r,connect:t=>{let{port:n}=t;n.start();const s=e(n,r),a=(0,i.generateUniqueNumber)(l);return l.set(a,(()=>{s(),n.close(),l.delete(a)})),{result:a}},disconnect:e=>{let{portId:r}=e;const n=l.get(r);if(void 0===n)throw(e=>s('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(r);return n(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=t=>{let{data:r}=t;return e(null!==r)},n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=function(e,t){const r=c(u,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0),n=o(e,r);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},d=e=>e.reduce(((e,t)=>e+t.length),0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach(((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))}))}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map((e=>[e])),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach(((e,t)=>e.push(n[t]))),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,l=r.length,c=e(r[0]),u=new ArrayBuffer(c*l*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,l,"complete"===n?c:Number.POSITIVE_INFINITY,a),r.forEach(((e,t)=>{let r=i+t*o;e.forEach((e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=l*o}}))})),[u]})(d,((e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)})),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:e=>{let{recordingId:t,timeslice:r}=e;const n=v.get(t);void 0!==n&&(v.delete(t),n.reject(new Error("Another request was made to initiate an encoding.")));const s=f.get(t);if(null!==r){if(void 0===s||d(s.channelDataArrays[0])*(1e3/s.sampleRate)<r)return new Promise(((e,n)=>{v.set(t,{reject:n,resolve:e,timeslice:r})}));const e=h(s.channelDataArrays,Math.ceil(r*(s.sampleRate/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,s.sampleRate);return s.isComplete=!1,{result:n,transferables:n}}if(void 0!==s){const e=p(s.channelDataArrays,s.isComplete?"complete":"subsequent",16,s.sampleRate);return f.delete(t),{result:e,transferables:e}}return{result:[],transferables:[]}},record:e=>{let{recordingId:t,sampleRate:r,typedArrays:n}=e;const s=m(t,r,n),a=v.get(t);if(void 0!==a&&d(s.channelDataArrays[0])*(1e3/r)>=a.timeslice){const e=h(s.channelDataArrays,Math.ceil(a.timeslice*(r/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,r);s.isComplete=!1,v.delete(t),a.resolve({result:n,transferables:n})}return{result:null}}})})()})();`; // tslint:disable-line:max-line-length | ||
export const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,l=r(i),c=o(l,i),u=t(c);e.addUniqueNumber=u,e.generateUniqueNumber=c}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),o=(t,r)=>async o=>{let{data:{id:i,method:l,params:c}}=o;const u=r[l];try{if(void 0===u)throw(e=>s('The requested method called "'.concat(e,'" is not supported.'),n))(l);const r=void 0===c?u():u(c);if(void 0===r)throw(t=>s('The handler of the method called "'.concat(t,'" returned no required result.'),e))(l);const o=r instanceof Promise?await r:r;if(null===i){if(void 0!==o.result)throw a(l)}else{if(void 0===o.result)throw a(l);const{result:e,transferables:r=[]}=o;t.postMessage({id:i,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:i})}};var i=r(455);const l=new Map,c=(e,r,n)=>({...r,connect:t=>{let{port:n}=t;n.start();const s=e(n,r),a=(0,i.generateUniqueNumber)(l);return l.set(a,(()=>{s(),n.close(),l.delete(a)})),{result:a}},disconnect:e=>{let{portId:r}=e;const n=l.get(r);if(void 0===n)throw(e=>s('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(r);return n(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=t=>{let{data:r}=t;return e(null!==r)},n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=function(e,t){const r=c(u,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0),n=o(e,r);return e.addEventListener("message",n),()=>e.removeEventListener("message",n)},d=e=>e.reduce(((e,t)=>e+t.length),0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach(((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))}))}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map((e=>[e])),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach(((e,t)=>e.push(n[t]))),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,l=r.length,c=e(r[0]),u=new ArrayBuffer(c*l*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,l,"complete"===n?c:Number.POSITIVE_INFINITY,a),r.forEach(((e,t)=>{let r=i+t*o;e.forEach((e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=l*o}}))})),[u]})(d,((e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)})),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:e=>{let{recordingId:t,timeslice:r}=e;const n=v.get(t);void 0!==n&&(v.delete(t),n.reject(new Error("Another request was made to initiate an encoding.")));const s=f.get(t);if(null!==r){if(void 0===s||d(s.channelDataArrays[0])*(1e3/s.sampleRate)<r)return new Promise(((e,n)=>{v.set(t,{reject:n,resolve:e,timeslice:r})}));const e=h(s.channelDataArrays,Math.ceil(r*(s.sampleRate/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,s.sampleRate);return s.isComplete=!1,{result:n,transferables:n}}if(void 0!==s){const e=p(s.channelDataArrays,s.isComplete?"complete":"subsequent",16,s.sampleRate);return f.delete(t),{result:e,transferables:e}}return{result:[],transferables:[]}},record:e=>{let{recordingId:t,sampleRate:r,typedArrays:n}=e;const s=m(t,r,n),a=v.get(t);if(void 0!==a&&d(s.channelDataArrays[0])*(1e3/r)>=a.timeslice){const e=h(s.channelDataArrays,Math.ceil(a.timeslice*(r/1e3))),n=p(e,s.isComplete?"initial":"subsequent",16,r);s.isComplete=!1,v.delete(t),a.resolve({result:n,transferables:n})}return{result:null}}})})()})();`; // tslint:disable-line:max-line-length |