@nlo/ping-video-loader
Advanced tools
Comparing version 0.0.1-alpha.95 to 0.0.1-alpha.124
@@ -11,2 +11,3 @@ declare type WebplayerFunc = (elementId: string | null, widthStyle?: string | null, topStyle?: string | null, videoId?: string | null, scriptName?: string | null, // Extra VARS/HASH for video personalisation | ||
Webplayer?: WebplayerFunc; | ||
loaded?: boolean; | ||
} | ||
@@ -18,12 +19,19 @@ declare global { | ||
$?: any; | ||
pingvpCallback?: () => void; | ||
} | ||
} | ||
declare class PingVideoLoader { | ||
export default class PingVideoLoader { | ||
private scriptId; | ||
private pingVideoPlayerIsLoaded; | ||
private scriptIsCreated; | ||
private videosToLoadBuffer; | ||
constructor(scriptId: string); | ||
loadVideo(elementId: string, videoName: string, autoStart: boolean): Promise<void> | void; | ||
private awaitElementLoad; | ||
private createScriptTag; | ||
private pingVpLoadedCallback; | ||
private setPingVpLoadedCallback; | ||
private webplayerExists; | ||
private loadPingVpAsync; | ||
} | ||
declare const _default: PingVideoLoader; | ||
export default _default; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* Globals PingVP */ | ||
var pingVideoPlayerIsLoaded = false; | ||
var scriptIsCreated = false; | ||
var PingVideoLoader = /** @class */ (function () { | ||
function PingVideoLoader() { | ||
function PingVideoLoader(scriptId) { | ||
this.pingVideoPlayerIsLoaded = false; | ||
this.scriptIsCreated = false; | ||
this.videosToLoadBuffer = []; | ||
this.scriptId = scriptId; | ||
} | ||
@@ -30,14 +31,22 @@ PingVideoLoader.prototype.loadVideo = function (elementId, videoName, autoStart) { | ||
PingVideoLoader.prototype.createScriptTag = function () { | ||
if (scriptIsCreated) { | ||
if (this.scriptIsCreated) { | ||
return; | ||
} | ||
// The PingVP script checks for jQuery but uses $, so this ensures that the alias is always set | ||
window.$ = window.jQuery; | ||
var tag = document.createElement('script'); | ||
tag.src = 'https://www.pingvp.com/p/aXNejdEHiu'; | ||
tag.src = "https://www.pingvp.com/p/" + this.scriptId; | ||
document.body.appendChild(tag); | ||
scriptIsCreated = true; | ||
this.scriptIsCreated = true; | ||
}; | ||
PingVideoLoader.prototype.pingVpLoadedCallback = function () { | ||
var _this = this; | ||
this.pingVideoPlayerIsLoaded = true; | ||
this.videosToLoadBuffer.forEach(function (args) { return _this.loadPingVpAsync.apply(_this, args); }); | ||
}; | ||
PingVideoLoader.prototype.setPingVpLoadedCallback = function () { | ||
if (!window.pingvpCallback) { | ||
window.pingvpCallback = this.pingVpLoadedCallback.bind(this); | ||
} | ||
}; | ||
PingVideoLoader.prototype.webplayerExists = function (pingvp) { | ||
return pingVideoPlayerIsLoaded; | ||
return this.pingVideoPlayerIsLoaded; | ||
}; | ||
@@ -54,18 +63,8 @@ PingVideoLoader.prototype.loadPingVpAsync = function () { | ||
} | ||
this.setPingVpLoadedCallback(); | ||
this.createScriptTag(); | ||
var checkPingVp = setInterval(function () { | ||
var _a; | ||
// In reality, this is not exactly the point at which the whole script loading is completed; | ||
// ideally we would get a flag from window.pingvp indicating when the script is properly loaded. | ||
// This does mean that when two PingVP videos are clicked rapidly in succession, the second one | ||
// or both will not be loaded depending on where in the cycle the second video is clicked. | ||
if (window.pingvp && window.pingvp.Webplayer) { | ||
clearInterval(checkPingVp); | ||
(_a = window.pingvp).Webplayer.apply(_a, webplayerArgs); | ||
pingVideoPlayerIsLoaded = true; | ||
} | ||
}, 100); | ||
this.videosToLoadBuffer.push(webplayerArgs); | ||
}; | ||
return PingVideoLoader; | ||
}()); | ||
exports.default = new PingVideoLoader(); | ||
exports.default = PingVideoLoader; |
{ | ||
"name": "@nlo/ping-video-loader", | ||
"version": "0.0.1-alpha.95+3b5729b", | ||
"version": "0.0.1-alpha.124+31c427b", | ||
"description": "", | ||
@@ -13,3 +13,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"tsc": "tsc --build", | ||
"build": "tsc --build", | ||
"watch": "tsc --watch" | ||
@@ -24,3 +24,3 @@ }, | ||
}, | ||
"gitHead": "3b5729bd38c9905bed5e0543bcecb322a246836a" | ||
"gitHead": "31c427b6e4b9e1c0b6446f192f597b91f6f1af27" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
112
4852
2