diff --git a/CHANGELOG.md b/CHANGELOG.md index 3021b52..1fc6afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All changes to this project will be documented in this file. +## [1.0.6] - 2022-07-06 +- Update dependancies +- Add origin headers +- Handle async errors + ## [1.0.5] - 2022-05-31 - Add `getMediaRecorderState()` method - Fix `stop()` method when the recorder is not started diff --git a/README.md b/README.md index 86cafaa..cd312f9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ - [`start(options?: { timeslice?: number })`](#startoptions--timeslice-number-) - [Options](#options-1) - [`stop(): Promise`](#stop-promisevideouploadresponse) + - [`addEventListener(event: string, listener: Function)`](#addeventlistenerevent-string-listener-function) - [`getMediaRecorderState(): RecordingState`](#getmediarecorderstate-recordingstate) - [Full example](#full-example) @@ -178,9 +179,25 @@ The start() method starts the upload of the content retrieved from the MediaStre The start() method stops the media recording. It upload the last part of content retrieved from the MediaStream (this will start the aggregation of the video parts on the api.video side). It takes no parameter. It returns a Promise that resolves with the newly created video. +### `addEventListener(event: string, listener: Function)` + +Define an event listener for the media recorder. The following events are available: +- `"error"`: when an error occurs +- `"recordingStopped"`: when the recording is stopped + +**Example** + +```javascript + // ... mediaRecorder instanciation + + mediaRecorder.addEventListener("error", (event) => { + console.log(event.data); + }); +``` + ### `getMediaRecorderState(): RecordingState` -Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder). +Return the state of the underlaying [MediaRecorder](https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder). The state can be one of the following: `inactive`, `paused`, `recording`. **Example** diff --git a/dist/index.js b/dist/index.js index f43abac..392b85c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -!function(t,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e=r();for(var n in e)("object"==typeof exports?exports:t)[n]=e[n]}}(this,(()=>(()=>{var t={6162:function(t){var r;r=()=>(()=>{var t={7633:(t,r,e)=>{e(9170),e(6992),e(1539),e(8674),e(7922),e(4668),e(7727),e(8783);var n=e(857);t.exports=n.Promise},9662:(t,r,e)=>{var n=e(7854),o=e(614),i=e(6330),a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not a function")}},9483:(t,r,e)=>{var n=e(7854),o=e(4411),i=e(6330),a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not a constructor")}},6077:(t,r,e)=>{var n=e(7854),o=e(614),i=n.String,a=n.TypeError;t.exports=function(t){if("object"==typeof t||o(t))return t;throw a("Can't set "+i(t)+" as a prototype")}},1223:(t,r,e)=>{var n=e(5112),o=e(30),i=e(3070),a=n("unscopables"),c=Array.prototype;null==c[a]&&i.f(c,a,{configurable:!0,value:o(null)}),t.exports=function(t){c[a][t]=!0}},5787:(t,r,e)=>{var n=e(7854),o=e(7976),i=n.TypeError;t.exports=function(t,r){if(o(r,t))return t;throw i("Incorrect invocation")}},9670:(t,r,e)=>{var n=e(7854),o=e(111),i=n.String,a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not an object")}},1318:(t,r,e)=>{var n=e(5656),o=e(1400),i=e(6244),a=function(t){return function(r,e,a){var c,u=n(r),s=i(u),f=o(a,s);if(t&&e!=e){for(;s>f;)if((c=u[f++])!=c)return!0}else for(;s>f;f++)if((t||f in u)&&u[f]===e)return t||f||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},206:(t,r,e)=>{var n=e(1702);t.exports=n([].slice)},7072:(t,r,e)=>{var n=e(5112)("iterator"),o=!1;try{var i=0,a={next:function(){return{done:!!i++}},return:function(){o=!0}};a[n]=function(){return this},Array.from(a,(function(){throw 2}))}catch(t){}t.exports=function(t,r){if(!r&&!o)return!1;var e=!1;try{var i={};i[n]=function(){return{next:function(){return{done:e=!0}}}},t(i)}catch(t){}return e}},4326:(t,r,e)=>{var n=e(1702),o=n({}.toString),i=n("".slice);t.exports=function(t){return i(o(t),8,-1)}},648:(t,r,e)=>{var n=e(7854),o=e(1694),i=e(614),a=e(4326),c=e(5112)("toStringTag"),u=n.Object,s="Arguments"==a(function(){return arguments}());t.exports=o?a:function(t){var r,e,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=function(t,r){try{return t[r]}catch(t){}}(r=u(t),c))?e:s?a(r):"Object"==(n=a(r))&&i(r.callee)?"Arguments":n}},7741:(t,r,e)=>{var n=e(1702),o=Error,i=n("".replace),a=String(o("zxcasd").stack),c=/\n\s*at [^:]*:[^\n]*/,u=c.test(a);t.exports=function(t,r){if(u&&"string"==typeof t&&!o.prepareStackTrace)for(;r--;)t=i(t,c,"");return t}},9920:(t,r,e)=>{var n=e(2597),o=e(3887),i=e(1236),a=e(3070);t.exports=function(t,r,e){for(var c=o(r),u=a.f,s=i.f,f=0;f{var n=e(7293);t.exports=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},4994:(t,r,e)=>{"use strict";var n=e(3383).IteratorPrototype,o=e(30),i=e(9114),a=e(8003),c=e(7497),u=function(){return this};t.exports=function(t,r,e,s){var f=r+" Iterator";return t.prototype=o(n,{next:i(+!s,e)}),a(t,f,!1,!0),c[f]=u,t}},8880:(t,r,e)=>{var n=e(9781),o=e(3070),i=e(9114);t.exports=n?function(t,r,e){return o.f(t,r,i(1,e))}:function(t,r,e){return t[r]=e,t}},9114:t=>{t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},654:(t,r,e)=>{"use strict";var n=e(2109),o=e(6916),i=e(1913),a=e(6530),c=e(614),u=e(4994),s=e(9518),f=e(7674),p=e(8003),l=e(8880),v=e(1320),h=e(5112),d=e(7497),y=e(3383),g=a.PROPER,b=a.CONFIGURABLE,m=y.IteratorPrototype,x=y.BUGGY_SAFARI_ITERATORS,w=h("iterator"),S="keys",O="values",P="entries",E=function(){return this};t.exports=function(t,r,e,a,h,y,T){u(e,r,a);var j,_,k,A=function(t){if(t===h&&N)return N;if(!x&&t in C)return C[t];switch(t){case S:case O:case P:return function(){return new e(this,t)}}return function(){return new e(this)}},R=r+" Iterator",I=!1,C=t.prototype,L=C[w]||C["@@iterator"]||h&&C[h],N=!x&&L||A(h),M="Array"==r&&C.entries||L;if(M&&(j=s(M.call(new t)))!==Object.prototype&&j.next&&(i||s(j)===m||(f?f(j,m):c(j[w])||v(j,w,E)),p(j,R,!0,!0),i&&(d[R]=E)),g&&h==O&&L&&L.name!==O&&(!i&&b?l(C,"name",O):(I=!0,N=function(){return o(L,this)})),h)if(_={values:A(O),keys:y?N:A(S),entries:A(P)},T)for(k in _)(x||I||!(k in C))&&v(C,k,_[k]);else n({target:r,proto:!0,forced:x||I},_);return i&&!T||C[w]===N||v(C,w,N,{name:h}),d[r]=N,_}},9781:(t,r,e)=>{var n=e(7293);t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:(t,r,e)=>{var n=e(7854),o=e(111),i=n.document,a=o(i)&&o(i.createElement);t.exports=function(t){return a?i.createElement(t):{}}},8324:t=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:(t,r,e)=>{var n=e(317)("span").classList,o=n&&n.constructor&&n.constructor.prototype;t.exports=o===Object.prototype?void 0:o},7871:t=>{t.exports="object"==typeof window&&"object"!=typeof Deno},1528:(t,r,e)=>{var n=e(8113),o=e(7854);t.exports=/ipad|iphone|ipod/i.test(n)&&void 0!==o.Pebble},6833:(t,r,e)=>{var n=e(8113);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)},5268:(t,r,e)=>{var n=e(4326),o=e(7854);t.exports="process"==n(o.process)},1036:(t,r,e)=>{var n=e(8113);t.exports=/web0s(?!.*chrome)/i.test(n)},8113:(t,r,e)=>{var n=e(5005);t.exports=n("navigator","userAgent")||""},7392:(t,r,e)=>{var n,o,i=e(7854),a=e(8113),c=i.process,u=i.Deno,s=c&&c.versions||u&&u.version,f=s&&s.v8;f&&(o=(n=f.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(o=+n[1]),t.exports=o},748:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:(t,r,e)=>{var n=e(7293),o=e(9114);t.exports=!n((function(){var t=Error("a");return!("stack"in t)||(Object.defineProperty(t,"stack",o(1,7)),7!==t.stack)}))},2109:(t,r,e)=>{var n=e(7854),o=e(1236).f,i=e(8880),a=e(1320),c=e(3505),u=e(9920),s=e(4705);t.exports=function(t,r){var e,f,p,l,v,h=t.target,d=t.global,y=t.stat;if(e=d?n:y?n[h]||c(h,{}):(n[h]||{}).prototype)for(f in r){if(l=r[f],p=t.noTargetGet?(v=o(e,f))&&v.value:e[f],!s(d?f:h+(y?".":"#")+f,t.forced)&&void 0!==p){if(typeof l==typeof p)continue;u(l,p)}(t.sham||p&&p.sham)&&i(l,"sham",!0),a(e,f,l,t)}}},7293:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},2104:(t,r,e)=>{var n=e(4374),o=Function.prototype,i=o.apply,a=o.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})},9974:(t,r,e)=>{var n=e(1702),o=e(9662),i=e(4374),a=n(n.bind);t.exports=function(t,r){return o(t),void 0===r?t:i?a(t,r):function(){return t.apply(r,arguments)}}},4374:(t,r,e)=>{var n=e(7293);t.exports=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},6916:(t,r,e)=>{var n=e(4374),o=Function.prototype.call;t.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},6530:(t,r,e)=>{var n=e(9781),o=e(2597),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,c=o(i,"name"),u=c&&"something"===function(){}.name,s=c&&(!n||n&&a(i,"name").configurable);t.exports={EXISTS:c,PROPER:u,CONFIGURABLE:s}},1702:(t,r,e)=>{var n=e(4374),o=Function.prototype,i=o.bind,a=o.call,c=n&&i.bind(a,a);t.exports=n?function(t){return t&&c(t)}:function(t){return t&&function(){return a.apply(t,arguments)}}},5005:(t,r,e)=>{var n=e(7854),o=e(614),i=function(t){return o(t)?t:void 0};t.exports=function(t,r){return arguments.length<2?i(n[t]):n[t]&&n[t][r]}},1246:(t,r,e)=>{var n=e(648),o=e(8173),i=e(7497),a=e(5112)("iterator");t.exports=function(t){if(null!=t)return o(t,a)||o(t,"@@iterator")||i[n(t)]}},8554:(t,r,e)=>{var n=e(7854),o=e(6916),i=e(9662),a=e(9670),c=e(6330),u=e(1246),s=n.TypeError;t.exports=function(t,r){var e=arguments.length<2?u(t):r;if(i(e))return a(o(e,t));throw s(c(t)+" is not iterable")}},8173:(t,r,e)=>{var n=e(9662);t.exports=function(t,r){var e=t[r];return null==e?void 0:n(e)}},7854:(t,r,e)=>{var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e.g&&e.g)||function(){return this}()||Function("return this")()},2597:(t,r,e)=>{var n=e(1702),o=e(7908),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,r){return i(o(t),r)}},3501:t=>{t.exports={}},842:(t,r,e)=>{var n=e(7854);t.exports=function(t,r){var e=n.console;e&&e.error&&(1==arguments.length?e.error(t):e.error(t,r))}},490:(t,r,e)=>{var n=e(5005);t.exports=n("document","documentElement")},4664:(t,r,e)=>{var n=e(9781),o=e(7293),i=e(317);t.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:(t,r,e)=>{var n=e(7854),o=e(1702),i=e(7293),a=e(4326),c=n.Object,u=o("".split);t.exports=i((function(){return!c("z").propertyIsEnumerable(0)}))?function(t){return"String"==a(t)?u(t,""):c(t)}:c},2788:(t,r,e)=>{var n=e(1702),o=e(614),i=e(5465),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return a(t)}),t.exports=i.inspectSource},8340:(t,r,e)=>{var n=e(111),o=e(8880);t.exports=function(t,r){n(r)&&"cause"in r&&o(t,"cause",r.cause)}},9909:(t,r,e)=>{var n,o,i,a=e(8536),c=e(7854),u=e(1702),s=e(111),f=e(8880),p=e(2597),l=e(5465),v=e(6200),h=e(3501),d="Object already initialized",y=c.TypeError,g=c.WeakMap;if(a||l.state){var b=l.state||(l.state=new g),m=u(b.get),x=u(b.has),w=u(b.set);n=function(t,r){if(x(b,t))throw new y(d);return r.facade=t,w(b,t,r),r},o=function(t){return m(b,t)||{}},i=function(t){return x(b,t)}}else{var S=v("state");h[S]=!0,n=function(t,r){if(p(t,S))throw new y(d);return r.facade=t,f(t,S,r),r},o=function(t){return p(t,S)?t[S]:{}},i=function(t){return p(t,S)}}t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(r){var e;if(!s(r)||(e=o(r)).type!==t)throw y("Incompatible receiver, "+t+" required");return e}}}},7659:(t,r,e)=>{var n=e(5112),o=e(7497),i=n("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||a[i]===t)}},614:t=>{t.exports=function(t){return"function"==typeof t}},4411:(t,r,e)=>{var n=e(1702),o=e(7293),i=e(614),a=e(648),c=e(5005),u=e(2788),s=function(){},f=[],p=c("Reflect","construct"),l=/^\s*(?:class|function)\b/,v=n(l.exec),h=!l.exec(s),d=function(t){if(!i(t))return!1;try{return p(s,f,t),!0}catch(t){return!1}},y=function(t){if(!i(t))return!1;switch(a(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return h||!!v(l,u(t))}catch(t){return!0}};y.sham=!0,t.exports=!p||o((function(){var t;return d(d.call)||!d(Object)||!d((function(){t=!0}))||t}))?y:d},4705:(t,r,e)=>{var n=e(7293),o=e(614),i=/#|\.prototype\./,a=function(t,r){var e=u[c(t)];return e==f||e!=s&&(o(r)?n(r):!!r)},c=a.normalize=function(t){return String(t).replace(i,".").toLowerCase()},u=a.data={},s=a.NATIVE="N",f=a.POLYFILL="P";t.exports=a},111:(t,r,e)=>{var n=e(614);t.exports=function(t){return"object"==typeof t?null!==t:n(t)}},1913:t=>{t.exports=!1},2190:(t,r,e)=>{var n=e(7854),o=e(5005),i=e(614),a=e(7976),c=e(3307),u=n.Object;t.exports=c?function(t){return"symbol"==typeof t}:function(t){var r=o("Symbol");return i(r)&&a(r.prototype,u(t))}},408:(t,r,e)=>{var n=e(7854),o=e(9974),i=e(6916),a=e(9670),c=e(6330),u=e(7659),s=e(6244),f=e(7976),p=e(8554),l=e(1246),v=e(9212),h=n.TypeError,d=function(t,r){this.stopped=t,this.result=r},y=d.prototype;t.exports=function(t,r,e){var n,g,b,m,x,w,S,O=e&&e.that,P=!(!e||!e.AS_ENTRIES),E=!(!e||!e.IS_ITERATOR),T=!(!e||!e.INTERRUPTED),j=o(r,O),_=function(t){return n&&v(n,"normal",t),new d(!0,t)},k=function(t){return P?(a(t),T?j(t[0],t[1],_):j(t[0],t[1])):T?j(t,_):j(t)};if(E)n=t;else{if(!(g=l(t)))throw h(c(t)+" is not iterable");if(u(g)){for(b=0,m=s(t);m>b;b++)if((x=k(t[b]))&&f(y,x))return x;return new d(!1)}n=p(t,g)}for(w=n.next;!(S=i(w,n)).done;){try{x=k(S.value)}catch(t){v(n,"throw",t)}if("object"==typeof x&&x&&f(y,x))return x}return new d(!1)}},9212:(t,r,e)=>{var n=e(6916),o=e(9670),i=e(8173);t.exports=function(t,r,e){var a,c;o(t);try{if(!(a=i(t,"return"))){if("throw"===r)throw e;return e}a=n(a,t)}catch(t){c=!0,a=t}if("throw"===r)throw e;if(c)throw a;return o(a),e}},3383:(t,r,e)=>{"use strict";var n,o,i,a=e(7293),c=e(614),u=e(30),s=e(9518),f=e(1320),p=e(5112),l=e(1913),v=p("iterator"),h=!1;[].keys&&("next"in(i=[].keys())?(o=s(s(i)))!==Object.prototype&&(n=o):h=!0),null==n||a((function(){var t={};return n[v].call(t)!==t}))?n={}:l&&(n=u(n)),c(n[v])||f(n,v,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:h}},7497:t=>{t.exports={}},6244:(t,r,e)=>{var n=e(7466);t.exports=function(t){return n(t.length)}},5948:(t,r,e)=>{var n,o,i,a,c,u,s,f,p=e(7854),l=e(9974),v=e(1236).f,h=e(261).set,d=e(6833),y=e(1528),g=e(1036),b=e(5268),m=p.MutationObserver||p.WebKitMutationObserver,x=p.document,w=p.process,S=p.Promise,O=v(p,"queueMicrotask"),P=O&&O.value;P||(n=function(){var t,r;for(b&&(t=w.domain)&&t.exit();o;){r=o.fn,o=o.next;try{r()}catch(t){throw o?a():i=void 0,t}}i=void 0,t&&t.enter()},d||b||g||!m||!x?!y&&S&&S.resolve?((s=S.resolve(void 0)).constructor=S,f=l(s.then,s),a=function(){f(n)}):b?a=function(){w.nextTick(n)}:(h=l(h,p),a=function(){h(n)}):(c=!0,u=x.createTextNode(""),new m(n).observe(u,{characterData:!0}),a=function(){u.data=c=!c})),t.exports=P||function(t){var r={fn:t,next:void 0};i&&(i.next=r),o||(o=r,a()),i=r}},133:(t,r,e)=>{var n=e(7392),o=e(7293);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},8536:(t,r,e)=>{var n=e(7854),o=e(614),i=e(2788),a=n.WeakMap;t.exports=o(a)&&/native code/.test(i(a))},8523:(t,r,e)=>{"use strict";var n=e(9662),o=function(t){var r,e;this.promise=new t((function(t,n){if(void 0!==r||void 0!==e)throw TypeError("Bad Promise constructor");r=t,e=n})),this.resolve=n(r),this.reject=n(e)};t.exports.f=function(t){return new o(t)}},6277:(t,r,e)=>{var n=e(1340);t.exports=function(t,r){return void 0===t?arguments.length<2?"":r:n(t)}},30:(t,r,e)=>{var n,o=e(9670),i=e(6048),a=e(748),c=e(3501),u=e(490),s=e(317),f=e(6200)("IE_PROTO"),p=function(){},l=function(t){return"