New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@peertube/embed-api

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peertube/embed-api - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

dist/definitions.d.ts

2

build/player.min.js

@@ -1,1 +0,1 @@

(function(S,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(S=typeof globalThis<"u"?globalThis:S||self,C(S.PeerTubePlayer={}))})(this,function(S){"use strict";var C=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},q={exports:{}};(function(L,r){(function(d,p){L.exports=p()})(C,function(){var d=function(){var p=Math.floor(Math.random()*1000001),a={};function E(n,s,f,g){function l(R){for(var k=0;k<R.length;k++)if(R[k].win===n)return!0;return!1}var c=!1;if(s==="*"){for(var o in a)if(a.hasOwnProperty(o)&&o!=="*"&&typeof a[o][f]=="object"&&(c=l(a[o][f]),c))break}else a["*"]&&a["*"][f]&&(c=l(a["*"][f])),!c&&a[s]&&a[s][f]&&(c=l(a[s][f]));if(c)throw"A channel is already bound to the same window which overlaps with origin '"+s+"' and has scope '"+f+"'";typeof a[s]!="object"&&(a[s]={}),typeof a[s][f]!="object"&&(a[s][f]=[]),a[s][f].push({win:n,handler:g})}function W(n,s,f){for(var g=a[s][f],l=0;l<g.length;l++)g[l].win===n&&g.splice(l,1);a[s][f].length===0&&delete a[s][f]}function D(n){return Array.isArray?Array.isArray(n):n.constructor.toString().indexOf("Array")!=-1}var N={},j=function(n){try{var s=JSON.parse(n.data);if(typeof s!="object"||s===null)throw"malformed"}catch{return}var f=n.source,g=n.origin,l,c,o;if(typeof s.method=="string"){var R=s.method.split("::");R.length==2?(l=R[0],o=R[1]):o=s.method}if(typeof s.id<"u"&&(c=s.id),typeof o=="string"){var k=!1;if(a[g]&&a[g][l]){for(var M=0;M<a[g][l].length;M++)if(a[g][l][M].win===f){a[g][l][M].handler(g,o,s),k=!0;break}}if(!k&&a["*"]&&a["*"][l]){for(var M=0;M<a["*"][l].length;M++)if(a["*"][l][M].win===f){a["*"][l][M].handler(g,o,s);break}}}else typeof c<"u"&&N[c]&&N[c](g,o,s)};return window.addEventListener?window.addEventListener("message",j,!1):window.attachEvent&&window.attachEvent("onmessage",j),{build:function(n){var s=function(e){if(n.debugOutput&&window.console&&window.console.log){try{typeof e!="string"&&(e=JSON.stringify(e))}catch{}window.console.log("["+l+"] "+e)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if(typeof n!="object")throw"Channel build invoked without a proper object argument";if(!n.window||!n.window.postMessage)throw"Channel.build() called without a valid window argument";window===n.window&&s("target window is same as present window -- use at your own risk");var f=!1;if(typeof n.origin=="string"){var g;n.origin==="*"?f=!0:(g=n.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))!==null&&(n.origin=g[0].toLowerCase(),f=!0)}if(!f)throw"Channel.build() called with an invalid origin";if(typeof n.scope<"u"){if(typeof n.scope!="string")throw"scope, when specified, must be a string";if(n.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}else n.scope="__default";var l=function(){for(var e="",i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=0;t<5;t++)e+=i.charAt(Math.floor(Math.random()*i.length));return e}(),c={},o={},R={},k=!1,M=[],x=[],F=function(e,i,t){var y=!1,_=!1;return{origin:i,invoke:function(v,b){if(!R[e])throw"attempting to invoke a callback of a nonexistent transaction: "+e;for(var h=!1,m=0;m<t.length;m++)if(v===t[m]){h=!0;break}if(!h)throw"request supports no such callback '"+v+"'";T({id:e,callback:v,params:b})},error:function(v,b){if(_=!0,!R[e])throw"error called for nonexistent message: "+e;delete R[e],T({id:e,error:v,message:b})},complete:function(v){if(_=!0,!R[e])throw"complete called for nonexistent message: "+e;delete R[e],T({id:e,result:v})},delayReturn:function(v){return typeof v=="boolean"&&(y=v===!0),y},completed:function(){return _}}},Z=function(e,i,t){return window.setTimeout(function(){if(o[e]){var y="timeout ("+i+"ms) exceeded on method '"+t+"'";o[e].error&&o[e].error("timeout_error",y),delete o[e],delete N[e]}},i)},V=function(e,i,t){if(typeof n.gotMessageObserver=="function")try{n.gotMessageObserver(e,t)}catch(u){s("gotMessageObserver() raised an exception: "+u.toString())}if(t.id&&i){R[t.id]={};var y=F(t.id,e,t.callbacks?t.callbacks:[]);if(c[i])try{if(t.callbacks&&D(t.callbacks)&&t.callbacks.length>0)for(var _=0;_<t.callbacks.length;_++){for(var v=t.callbacks[_],b=t.params,h=v.split("/"),m=0;m<h.length-1;m++){var O=h[m];typeof b[O]!="object"&&(b[O]={}),b=b[O]}b[h[h.length-1]]=function(){var u=v;return function(z){return y.invoke(u,z)}}()}var $=c[i](y,t.params);!y.delayReturn()&&!y.completed()&&y.complete($)}catch(u){var J="runtime_error",P=null;if(typeof u=="string"?P=u:typeof u=="object"&&(u instanceof Error?(J=u.constructor.name,P=u.message):u&&D(u)&&u.length==2?(J=u[0],P=u[1]):typeof u.error=="string"&&(J=u.error,u.message?typeof u.message=="string"?P=u.message:u=u.message:P="")),P===null)try{P=JSON.stringify(u),typeof P>"u"&&(P=u.toString())}catch{P=u.toString()}y.error(J,P)}else y.error("method_not_found","No method '"+i+"' was (yet) bound by the provider")}else t.id&&t.callback?!o[t.id]||!o[t.id].callbacks||!o[t.id].callbacks[t.callback]?s("ignoring invalid callback, id:"+t.id+" ("+t.callback+")"):o[t.id].callbacks[t.callback](t.params):t.id?o[t.id]?(t.error?o[t.id].error&&o[t.id].error(t.error,t.message):t.result!==void 0?o[t.id].success(t.result):o[t.id].success(),delete o[t.id],delete N[t.id]):s("ignoring invalid response: "+t.id):i&&c[i]&&c[i]({origin:e},t.params)};E(n.window,n.origin,n.scope,V);var A=function(e){return[n.scope,e].join("::")},T=function(e,i){if(!e)throw"postMessage called with null message";if(!i&&!k)s("queue message: "+JSON.stringify(e)),M.push(e);else{if(typeof n.postMessageObserver=="function")try{n.postMessageObserver(n.origin,e)}catch(t){s("postMessageObserver() raised an exception: "+t.toString())}s("post message: "+JSON.stringify(e)+" with origin "+n.origin),n.window.postMessage(JSON.stringify(e),n.origin)}},K=function(e,i){if(s("ready msg received"),k&&!n.reconnect)throw"received ready message while in ready state.";k=!0,l.length<6&&(i.type==="publish-request"?l+="-R":l+="-L"),s("ready msg accepted."),i.type==="publish-request"&&w.notify({method:"__ready",params:{type:"publish-reply",publish:x}});for(var t=0;t<i.publish.length;t++)i.publish[t].action==="bind"?U([i.publish[t].method],w.remote):delete w.remote[i.publish[t].method];for(n.reconnect||w.unbind("__ready",!0);M.length;)T(M.splice(0,1)[0]);x=[],typeof n.onReady=="function"&&n.onReady(w)},U=function(e,i){e=[].concat(e);for(var t,y=0;y<e.length;y++)t=e[y].toString(),i[t]=function(_){return function(v,b,h){b?w.call({method:_,params:v,success:b,error:h}):w.notify({method:_,params:v})}}(t)},X=function(e,i){U([i],w.remote)},Y=function(e,i){w.remote[i]&&delete w.remote[i]},w={remote:{},unbind:function(e,i){if(c[e]){if(!delete c[e])throw"can't delete method: "+e;return n.publish&&!i&&(k?w.notify({method:"__unbind",params:e}):x.push({action:"unbind",method:e})),!0}return!1},bind:function(e,i,t){if(!e||typeof e!="string")throw"'method' argument to bind must be string";if(!i||typeof i!="function")throw"callback missing from bind params";if(c[e])throw"method '"+e+"' is already bound!";return c[e]=i,n.publish&&!t&&(k?w.notify({method:"__bind",params:e}):x.push({action:"bind",method:e})),this},call:function(e){if(!e)throw"missing arguments to call function";if(!e.method||typeof e.method!="string")throw"'method' argument to call must be string";if(!e.success||typeof e.success!="function")throw"'success' callback missing from call";var i={},t=[],y=[],_=function(b,h){if(y.indexOf(h)>=0)throw"params cannot be a recursive data structure";if(h&&y.push(h),typeof h=="object"){for(var m in h)if(h.hasOwnProperty(m)){var O=b+(b.length?"/":"")+m;typeof h[m]=="function"?(i[O]=h[m],t.push(O),delete h[m]):typeof h[m]=="object"&&_(O,h[m])}}};_("",e.params);var v={id:p,method:A(e.method),params:e.params};t.length&&(v.callbacks=t),e.timeout&&Z(p,e.timeout,A(e.method)),o[p]={callbacks:i,error:e.error,success:e.success},N[p]=V,p++,T(v)},notify:function(e){if(!e)throw"missing arguments to notify function";if(!e.method||typeof e.method!="string")throw"'method' argument to notify must be string";T({method:A(e.method),params:e.params})},destroy:function(){W(n.window,n.origin,n.scope),window.removeEventListener?window.removeEventListener("message",V,!1):window.detachEvent&&window.detachEvent("onmessage",V),k=!1,c={},R={},o={},n.origin=null,M=[],s("channel destroyed"),l=""}};return w.bind("__ready",K,!0),w.bind("__bind",X,!0),w.bind("__unbind",Y,!0),n.remote&&U(n.remote,w.remote),setTimeout(function(){l.length>0&&T({method:A("__ready"),params:{type:"publish-request",publish:x}},!0)},0),w}}}();return d})})(q);var G=q.exports;class H{constructor(){this.eventRegistrations={}}bindToChannel(r){for(const d of Object.keys(this.eventRegistrations))r.bind(d,(p,a)=>this.fire(d,a))}registerTypes(r){for(const d of r)this.eventRegistrations[d]={registrations:[]}}fire(r,d){this.eventRegistrations[r].registrations.forEach(p=>p(d))}addListener(r,d){return this.eventRegistrations[r]?(this.eventRegistrations[r].registrations.push(d),!0):(console.warn("PeerTube: addEventListener(): The event '".concat(r,"' is not supported")),!1)}removeListener(r,d){return this.eventRegistrations[r]?(this.eventRegistrations[r].registrations=this.eventRegistrations[r].registrations.filter(p=>p!==d),!0):!1}}const Q=["pause","play","playbackStatusUpdate","playbackStatusChange","resolutionUpdate","volumeChange"];class B{constructor(r,d){this.embedElement=r,this.scope=d,this.eventRegistrar=new H,this.eventRegistrar.registerTypes(Q),this.constructChannel(),this.prepareToBeReady()}destroy(){this.embedElement.remove()}addEventListener(r,d){return this.eventRegistrar.addListener(r,d)}removeEventListener(r,d){return this.eventRegistrar.removeListener(r,d)}get ready(){return this.readyPromise}async play(){await this.sendMessage("play")}async pause(){await this.sendMessage("pause")}async setVolume(r){await this.sendMessage("setVolume",r)}async getVolume(){return this.sendMessage("getVolume")}async setCaption(r){await this.sendMessage("setCaption",r)}async getCaptions(){return this.sendMessage("getCaptions")}async seek(r){await this.sendMessage("seek",r)}async setResolution(r){await this.sendMessage("setResolution",r)}async getResolutions(){return this.sendMessage("getResolutions")}async getPlaybackRates(){return this.sendMessage("getPlaybackRates")}async getPlaybackRate(){return this.sendMessage("getPlaybackRate")}async setPlaybackRate(r){await this.sendMessage("setPlaybackRate",r)}async playNextVideo(){await this.sendMessage("playNextVideo")}async playPreviousVideo(){await this.sendMessage("playPreviousVideo")}async getCurrentPosition(){return this.sendMessage("getCurrentPosition")}async setVideoPassword(r){await this.sendMessage("setVideoPassword",r)}async getImageDataUrl(){return this.sendMessage("getImageDataUrl")}constructChannel(){this.channel=G.build({window:this.embedElement.contentWindow,origin:"*",scope:this.scope||"peertube"}),this.eventRegistrar.bindToChannel(this.channel)}prepareToBeReady(){let r,d;this.readyPromise=new Promise((p,a)=>{r=p,d=a}),this.channel.bind("ready",p=>p?r():d()),this.channel.call({method:"isReady",success:p=>p?r():null})}sendMessage(r,d){return new Promise((p,a)=>{this.channel.call({method:r,params:d,success:E=>p(E),error:E=>a(E)})})}}window.PeerTubePlayer=B,S.PeerTubePlayer=B,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
(function(S,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(S=typeof globalThis<"u"?globalThis:S||self,x(S.PeerTubePlayer={}))})(this,function(S){"use strict";var x=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},q={exports:{}};(function(L,r){(function(d,p){L.exports=p()})(x,function(){var d=function(){var p=Math.floor(Math.random()*1000001),a={};function E(n,s,f,v){function l(M){for(var k=0;k<M.length;k++)if(M[k].win===n)return!0;return!1}var c=!1;if(s==="*"){for(var o in a)if(a.hasOwnProperty(o)&&o!=="*"&&typeof a[o][f]=="object"&&(c=l(a[o][f]),c))break}else a["*"]&&a["*"][f]&&(c=l(a["*"][f])),!c&&a[s]&&a[s][f]&&(c=l(a[s][f]));if(c)throw"A channel is already bound to the same window which overlaps with origin '"+s+"' and has scope '"+f+"'";typeof a[s]!="object"&&(a[s]={}),typeof a[s][f]!="object"&&(a[s][f]=[]),a[s][f].push({win:n,handler:v})}function W(n,s,f){for(var v=a[s][f],l=0;l<v.length;l++)v[l].win===n&&v.splice(l,1);a[s][f].length===0&&delete a[s][f]}function D(n){return Array.isArray?Array.isArray(n):n.constructor.toString().indexOf("Array")!=-1}var N={},j=function(n){try{var s=JSON.parse(n.data);if(typeof s!="object"||s===null)throw"malformed"}catch{return}var f=n.source,v=n.origin,l,c,o;if(typeof s.method=="string"){var M=s.method.split("::");M.length==2?(l=M[0],o=M[1]):o=s.method}if(typeof s.id<"u"&&(c=s.id),typeof o=="string"){var k=!1;if(a[v]&&a[v][l]){for(var R=0;R<a[v][l].length;R++)if(a[v][l][R].win===f){a[v][l][R].handler(v,o,s),k=!0;break}}if(!k&&a["*"]&&a["*"][l]){for(var R=0;R<a["*"][l].length;R++)if(a["*"][l][R].win===f){a["*"][l][R].handler(v,o,s);break}}}else typeof c<"u"&&N[c]&&N[c](v,o,s)};return window.addEventListener?window.addEventListener("message",j,!1):window.attachEvent&&window.attachEvent("onmessage",j),{build:function(n){var s=function(e){if(n.debugOutput&&window.console&&window.console.log){try{typeof e!="string"&&(e=JSON.stringify(e))}catch{}window.console.log("["+l+"] "+e)}};if(!window.postMessage)throw"jschannel cannot run this browser, no postMessage";if(!window.JSON||!window.JSON.stringify||!window.JSON.parse)throw"jschannel cannot run this browser, no JSON parsing/serialization";if(typeof n!="object")throw"Channel build invoked without a proper object argument";if(!n.window||!n.window.postMessage)throw"Channel.build() called without a valid window argument";window===n.window&&s("target window is same as present window -- use at your own risk");var f=!1;if(typeof n.origin=="string"){var v;n.origin==="*"?f=!0:(v=n.origin.match(/^https?:\/\/(?:[-a-zA-Z0-9_\.])+(?::\d+)?/))!==null&&(n.origin=v[0].toLowerCase(),f=!0)}if(!f)throw"Channel.build() called with an invalid origin";if(typeof n.scope<"u"){if(typeof n.scope!="string")throw"scope, when specified, must be a string";if(n.scope.split("::").length>1)throw"scope may not contain double colons: '::'"}else n.scope="__default";var l=function(){for(var e="",i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=0;t<5;t++)e+=i.charAt(Math.floor(Math.random()*i.length));return e}(),c={},o={},M={},k=!1,R=[],C=[],F=function(e,i,t){var y=!1,P=!1;return{origin:i,invoke:function(g,b){if(!M[e])throw"attempting to invoke a callback of a nonexistent transaction: "+e;for(var h=!1,m=0;m<t.length;m++)if(g===t[m]){h=!0;break}if(!h)throw"request supports no such callback '"+g+"'";_({id:e,callback:g,params:b})},error:function(g,b){if(P=!0,!M[e])throw"error called for nonexistent message: "+e;delete M[e],_({id:e,error:g,message:b})},complete:function(g){if(P=!0,!M[e])throw"complete called for nonexistent message: "+e;delete M[e],_({id:e,result:g})},delayReturn:function(g){return typeof g=="boolean"&&(y=g===!0),y},completed:function(){return P}}},Z=function(e,i,t){return window.setTimeout(function(){if(o[e]){var y="timeout ("+i+"ms) exceeded on method '"+t+"'";o[e].error&&o[e].error("timeout_error",y),delete o[e],delete N[e]}},i)},V=function(e,i,t){if(typeof n.gotMessageObserver=="function")try{n.gotMessageObserver(e,t)}catch(u){s("gotMessageObserver() raised an exception: "+u.toString())}if(t.id&&i){M[t.id]={};var y=F(t.id,e,t.callbacks?t.callbacks:[]);if(c[i])try{if(t.callbacks&&D(t.callbacks)&&t.callbacks.length>0)for(var P=0;P<t.callbacks.length;P++){for(var g=t.callbacks[P],b=t.params,h=g.split("/"),m=0;m<h.length-1;m++){var O=h[m];typeof b[O]!="object"&&(b[O]={}),b=b[O]}b[h[h.length-1]]=function(){var u=g;return function(z){return y.invoke(u,z)}}()}var $=c[i](y,t.params);!y.delayReturn()&&!y.completed()&&y.complete($)}catch(u){var J="runtime_error",T=null;if(typeof u=="string"?T=u:typeof u=="object"&&(u instanceof Error?(J=u.constructor.name,T=u.message):u&&D(u)&&u.length==2?(J=u[0],T=u[1]):typeof u.error=="string"&&(J=u.error,u.message?typeof u.message=="string"?T=u.message:u=u.message:T="")),T===null)try{T=JSON.stringify(u),typeof T>"u"&&(T=u.toString())}catch{T=u.toString()}y.error(J,T)}else y.error("method_not_found","No method '"+i+"' was (yet) bound by the provider")}else t.id&&t.callback?!o[t.id]||!o[t.id].callbacks||!o[t.id].callbacks[t.callback]?s("ignoring invalid callback, id:"+t.id+" ("+t.callback+")"):o[t.id].callbacks[t.callback](t.params):t.id?o[t.id]?(t.error?o[t.id].error&&o[t.id].error(t.error,t.message):t.result!==void 0?o[t.id].success(t.result):o[t.id].success(),delete o[t.id],delete N[t.id]):s("ignoring invalid response: "+t.id):i&&c[i]&&c[i]({origin:e},t.params)};E(n.window,n.origin,n.scope,V);var A=function(e){return[n.scope,e].join("::")},_=function(e,i){if(!e)throw"postMessage called with null message";if(!i&&!k)s("queue message: "+JSON.stringify(e)),R.push(e);else{if(typeof n.postMessageObserver=="function")try{n.postMessageObserver(n.origin,e)}catch(t){s("postMessageObserver() raised an exception: "+t.toString())}s("post message: "+JSON.stringify(e)+" with origin "+n.origin),n.window.postMessage(JSON.stringify(e),n.origin)}},K=function(e,i){if(s("ready msg received"),k&&!n.reconnect)throw"received ready message while in ready state.";k=!0,l.length<6&&(i.type==="publish-request"?l+="-R":l+="-L"),s("ready msg accepted."),i.type==="publish-request"&&w.notify({method:"__ready",params:{type:"publish-reply",publish:C}});for(var t=0;t<i.publish.length;t++)i.publish[t].action==="bind"?U([i.publish[t].method],w.remote):delete w.remote[i.publish[t].method];for(n.reconnect||w.unbind("__ready",!0);R.length;)_(R.splice(0,1)[0]);C=[],typeof n.onReady=="function"&&n.onReady(w)},U=function(e,i){e=[].concat(e);for(var t,y=0;y<e.length;y++)t=e[y].toString(),i[t]=function(P){return function(g,b,h){b?w.call({method:P,params:g,success:b,error:h}):w.notify({method:P,params:g})}}(t)},X=function(e,i){U([i],w.remote)},Y=function(e,i){w.remote[i]&&delete w.remote[i]},w={remote:{},unbind:function(e,i){if(c[e]){if(!delete c[e])throw"can't delete method: "+e;return n.publish&&!i&&(k?w.notify({method:"__unbind",params:e}):C.push({action:"unbind",method:e})),!0}return!1},bind:function(e,i,t){if(!e||typeof e!="string")throw"'method' argument to bind must be string";if(!i||typeof i!="function")throw"callback missing from bind params";if(c[e])throw"method '"+e+"' is already bound!";return c[e]=i,n.publish&&!t&&(k?w.notify({method:"__bind",params:e}):C.push({action:"bind",method:e})),this},call:function(e){if(!e)throw"missing arguments to call function";if(!e.method||typeof e.method!="string")throw"'method' argument to call must be string";if(!e.success||typeof e.success!="function")throw"'success' callback missing from call";var i={},t=[],y=[],P=function(b,h){if(y.indexOf(h)>=0)throw"params cannot be a recursive data structure";if(h&&y.push(h),typeof h=="object"){for(var m in h)if(h.hasOwnProperty(m)){var O=b+(b.length?"/":"")+m;typeof h[m]=="function"?(i[O]=h[m],t.push(O),delete h[m]):typeof h[m]=="object"&&P(O,h[m])}}};P("",e.params);var g={id:p,method:A(e.method),params:e.params};t.length&&(g.callbacks=t),e.timeout&&Z(p,e.timeout,A(e.method)),o[p]={callbacks:i,error:e.error,success:e.success},N[p]=V,p++,_(g)},notify:function(e){if(!e)throw"missing arguments to notify function";if(!e.method||typeof e.method!="string")throw"'method' argument to notify must be string";_({method:A(e.method),params:e.params})},destroy:function(){W(n.window,n.origin,n.scope),window.removeEventListener?window.removeEventListener("message",V,!1):window.detachEvent&&window.detachEvent("onmessage",V),k=!1,c={},M={},o={},n.origin=null,R=[],s("channel destroyed"),l=""}};return w.bind("__ready",K,!0),w.bind("__bind",X,!0),w.bind("__unbind",Y,!0),n.remote&&U(n.remote,w.remote),setTimeout(function(){l.length>0&&_({method:A("__ready"),params:{type:"publish-request",publish:C}},!0)},0),w}}}();return d})})(q);var G=q.exports;class H{constructor(){this.eventRegistrations={}}bindToChannel(r){for(const d of Object.keys(this.eventRegistrations))r.bind(d,(p,a)=>this.fire(d,a))}registerTypes(r){for(const d of r)this.eventRegistrations[d]={registrations:[]}}fire(r,d){this.eventRegistrations[r].registrations.forEach(p=>p(d))}addListener(r,d){return this.eventRegistrations[r]?(this.eventRegistrations[r].registrations.push(d),!0):(console.warn("PeerTube: addEventListener(): The event '".concat(r,"' is not supported")),!1)}removeListener(r,d){return this.eventRegistrations[r]?(this.eventRegistrations[r].registrations=this.eventRegistrations[r].registrations.filter(p=>p!==d),!0):!1}}const Q=["pause","play","playbackStatusUpdate","playbackStatusChange","resolutionUpdate","volumeChange"];class B{constructor(r,d){this.embedElement=r,this.scope=d,this.eventRegistrar=new H,this.eventRegistrar.registerTypes(Q),this.constructChannel(),this.prepareToBeReady()}destroy(){this.embedElement.remove()}addEventListener(r,d){return this.eventRegistrar.addListener(r,d)}removeEventListener(r,d){return this.eventRegistrar.removeListener(r,d)}get ready(){return this.readyPromise}async isPlaying(){return this.sendMessage("isPlaying")}async play(){await this.sendMessage("play")}async pause(){await this.sendMessage("pause")}async setVolume(r){await this.sendMessage("setVolume",r)}async getVolume(){return this.sendMessage("getVolume")}async setCaption(r){await this.sendMessage("setCaption",r)}async getCaptions(){return this.sendMessage("getCaptions")}async getCurrentTime(){return this.sendMessage("getCurrentTime")}async seek(r){await this.sendMessage("seek",r)}async setResolution(r){await this.sendMessage("setResolution",r)}async getResolutions(){return this.sendMessage("getResolutions")}async getPlaybackRates(){return this.sendMessage("getPlaybackRates")}async getPlaybackRate(){return this.sendMessage("getPlaybackRate")}async setPlaybackRate(r){await this.sendMessage("setPlaybackRate",r)}async playNextVideo(){await this.sendMessage("playNextVideo")}async playPreviousVideo(){await this.sendMessage("playPreviousVideo")}async getCurrentPosition(){return this.sendMessage("getCurrentPosition")}async setVideoPassword(r){await this.sendMessage("setVideoPassword",r)}async getImageDataUrl(){return this.sendMessage("getImageDataUrl")}constructChannel(){this.channel=G.build({window:this.embedElement.contentWindow,origin:"*",scope:this.scope||"peertube"}),this.eventRegistrar.bindToChannel(this.channel)}prepareToBeReady(){let r,d;this.readyPromise=new Promise((p,a)=>{r=p,d=a}),this.channel.bind("ready",p=>p?r():d()),this.channel.call({method:"isReady",success:p=>p?r():null})}sendMessage(r,d){return new Promise((p,a)=>{this.channel.call({method:r,params:d,success:E=>p(E),error:E=>a(E)})})}}window.PeerTubePlayer=B,S.PeerTubePlayer=B,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});

@@ -75,2 +75,9 @@ "use strict";

});
PeerTubePlayer.prototype.isPlaying = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage('isPlaying')];
});
});
};
PeerTubePlayer.prototype.play = function () {

@@ -138,2 +145,9 @@ return __awaiter(this, void 0, void 0, function () {

};
PeerTubePlayer.prototype.getCurrentTime = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage('getCurrentTime')];
});
});
};
PeerTubePlayer.prototype.seek = function (seconds) {

@@ -140,0 +154,0 @@ return __awaiter(this, void 0, void 0, function () {

{
"name": "@peertube/embed-api",
"private": false,
"version": "0.1.0",
"version": "0.2.0",
"description": "API to communicate with the PeerTube player embed",

@@ -6,0 +6,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc