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

@enplug/sdk-player

Package Overview
Dependencies
Maintainers
5
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enplug/sdk-player - npm Package Compare versions

Comparing version 0.7.1 to 0.7.4-beta4

dist/player.js

2

package.json
{
"name": "@enplug/sdk-player",
"version": "0.7.1",
"version": "0.7.4-beta4",
"description": "Enplug Player SDK",

@@ -5,0 +5,0 @@ "main": "./src/index.ts",

@@ -20,2 +20,4 @@ /**

private playerEvents: PlayerEvents;
constructor() { }

@@ -79,2 +81,10 @@

/**
* Sets the PlayerEvents instance for this bridge for player events passing.
* @param {PlayerEvents} playerEvents
*/
setEventsBus(playerEvents: PlayerEvents) {
this.playerEvents = playerEvents;
}
/**
* Gets a value from URL query by key.

@@ -131,5 +141,5 @@ * @param {string} key

};
PlayerEvents.fireEvent(message.action, done);
this.playerEvents.fireEvent(message.action, done);
} else {
PlayerEvents.fireEvent(message.action, message.payload);
this.playerEvents.fireEvent(message.action, message.payload);
}

@@ -136,0 +146,0 @@ }

@@ -14,3 +14,3 @@ /**

/*tslint:disable:no-string-literal*/
window['epBridge'] = window['_epBridge'] = {
window['_epBridge'] = {
receive: this.receive.bind(this),

@@ -17,0 +17,0 @@ };

@@ -16,4 +16,2 @@ /**

sendToPlayer(message: OutboundMessage) {
// TODO: Remove when Java player supports `playerSdkVersion`
message.isNewSdk = true;
this.javaGlobal.send(JSON.stringify(message));

@@ -20,0 +18,0 @@ }

@@ -31,4 +31,2 @@ /**

sendToPlayer(message: OutboundMessage) {
// TODO: Remove when Java player supports `playerSdkVersion`
message.isNewSdk = true;
parent.postMessage(message, this.destination);

@@ -35,0 +33,0 @@ }

@@ -10,3 +10,3 @@ /**

Status = 'status',
PlayRecorder = 'play-recorder',
PlayRecorder = 'playrecorder',
Notifications = 'notification',

@@ -39,3 +39,3 @@ Social = 'social',

HideWhitelabel = 'hide-whitelabel',
Is4K = 'is4k',
Is4K = 'is4K',
IsMuted = 'is-muted',

@@ -49,2 +49,3 @@ TransitionType = 'transition-type',

Destroy = 'destroy',
SetListener = 'set-listener',
// Social

@@ -62,3 +63,2 @@ GetItems = 'get-items',

playerSdkVersion: string;
isNewSdk?: boolean;
}

@@ -65,0 +65,0 @@

@@ -32,2 +32,5 @@ /**

}
namespace social {
const getItems: () => Promise<any[]>;
}
const on: (eventName: string, eventHandler: (...args) => any) => void;

@@ -34,0 +37,0 @@ const off: (eventName: string) => void;

@@ -44,2 +44,3 @@ /**

const social = new Social(bridge);
const events = new PlayerEvents(bridge);

@@ -50,5 +51,5 @@ return {

notifications,
on: PlayerEvents.on,
off: PlayerEvents.off,
once: PlayerEvents.once,
on: events.on.bind(events),
off: events.off.bind(events),
once: events.once.bind(events),
playRecorder,

@@ -61,5 +62,5 @@ settings,

/* tslint:disable:variable-name */
const enplug = createEnplugPlayerSDK(window);
//const enplug =
export default enplug;
export default createEnplugPlayerSDK(window);
export {createEnplugPlayerSDK};

@@ -7,23 +7,29 @@ /**

import * as pkg from '../package.json';
import Bridge from './bridge/bridge';
import { Action, Service } from './enums';
export default class PlayerEvents {
private static handlerMap: Map<string, Set<(...args) => any>> = new Map();
private static version = (pkg as any).version as string;
private handlerMap: Map<string, Set<(...args) => any>> = new Map();
private version = (pkg as any).version as string;
static on(eventName: string, eventHandler: (...args) => any) {
PlayerEvents.checkArgumentTypes(eventName, eventHandler);
constructor(private bridge: Bridge) {
this.bridge.setEventsBus(this);
}
if (PlayerEvents.handlerMap.has(eventName)) {
PlayerEvents.handlerMap.get(eventName).add(eventHandler);
on(eventName: string, eventHandler: (...args) => any) {
this.checkArgumentTypes(eventName, eventHandler);
if (this.handlerMap.has(eventName)) {
this.handlerMap.get(eventName).add(eventHandler);
} else {
PlayerEvents.handlerMap.set(eventName, new Set([eventHandler]));
this.handlerMap.set(eventName, new Set([eventHandler]));
}
this.bridge.send(Service.Event, Action.SetListener, { eventName });
}
static off(eventName: string, eventHandler: (...args) => any) {
PlayerEvents.checkArgumentTypes(eventName, eventHandler);
off(eventName: string, eventHandler: (...args) => any) {
this.checkArgumentTypes(eventName, eventHandler);
if (PlayerEvents.handlerMap.has(eventName)) {
const handlerSet = PlayerEvents.handlerMap.get(eventName);
if (this.handlerMap.has(eventName)) {
const handlerSet = this.handlerMap.get(eventName);

@@ -36,17 +42,17 @@ if (handlerSet.has(eventHandler)) {

static once(eventName: string, eventHandler: (...args) => any) {
PlayerEvents.checkArgumentTypes(eventName, eventHandler);
once(eventName: string, eventHandler: (...args) => any) {
this.checkArgumentTypes(eventName, eventHandler);
const tmpFn = (...args) => {
PlayerEvents.off( eventName, tmpFn );
this.off( eventName, tmpFn );
eventHandler(...args);
};
PlayerEvents.on(eventName, tmpFn);
this.on(eventName, tmpFn);
}
static fireEvent(eventName: string, payload: any) {
const handlerSet = PlayerEvents.handlerMap.get(eventName);
fireEvent(eventName: string, ...args) {
const handlerSet = this.handlerMap.get(eventName);
if (handlerSet) {
handlerSet.forEach((handler) => {
handler(payload);
handler(args);
});

@@ -60,11 +66,11 @@ }

*/
private static checkArgumentTypes(eventName, eventHandler) {
checkArgumentTypes(eventName, eventHandler) {
if (eventName == null || typeof eventName !== 'string' ) {
throw new TypeError(`[Enplug SDK: ${PlayerEvents.version}] An event name is required to attach an event handler`);
throw new TypeError(`[Enplug SDK: ${this.version}] An event name is required to attach an event handler`);
}
if (eventHandler == null || typeof eventHandler !== 'function' ) {
throw new TypeError(`[Enplug SDK: ${PlayerEvents.version}] A handler function is required for .on/.off/.once`);
throw new TypeError(`[Enplug SDK: ${this.version}] A handler function is required for .on/.off/.once`);
}
}
}
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