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

vistar-html5player

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vistar-html5player - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

lib/ad_cache.js

45

lib/ad_stream.js

@@ -18,4 +18,2 @@ (function() {

AdStream.scope = 'SINGLETON';
AdStream.prototype.config = inject('config');

@@ -42,27 +40,38 @@

name: 'AdStream',
message: "begin read, buf length " + this._readableState.buffer.length
message: "begin _read, readableState buffer len " + this._readableState.buffer.length + ",\nflowing " + this._readableState.flowing + ", reading " + this._readableState.reading + ",\nlen " + this._readableState.length
});
success = function(response) {
var ad, _i, _len, _ref, _results;
_ref = (response != null ? response.advertisement : void 0) || [];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ad = _ref[_i];
_results.push(this.push(ad));
}
return _results;
};
return this.request.fetch().then(success.bind(this)).done();
success = (function(_this) {
return function(response) {
var ad, _i, _len, _ref, _results;
_ref = (response != null ? response.advertisement : void 0) || [];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ad = _ref[_i];
_this.push(ad);
_results.push(_this.log.write({
name: 'AdStream',
message: "pushed ad " + ad.asset_url + ",\nreadableState buffer len " + _this._readableState.buffer.length + ",\nflowing " + _this._readableState.flowing + ", reading " + _this._readableState.reading + ",\nlen " + _this._readableState.length
}));
}
return _results;
};
})(this);
return this.request.fetch().then(success).done();
};
AdStream.prototype._check = function() {
if (this._readableState.buffer.length === 0) {
if (this._readableState.length < this._lowWaterMark()) {
this.log.write({
name: 'AdStream',
message: 'buffer empty, initiating read'
name: 'AdStream'
}, {
message: "buffer " + this._readableState.length + ", making request"
});
return this.read();
return this.read(0);
}
};
AdStream.prototype._lowWaterMark = function() {
return this._readableState.highWaterMark / 2;
};
return AdStream;

@@ -69,0 +78,0 @@

133

lib/ajax.js
(function() {
var Ajax, Deferred, XMLHttpAjax,
var Ajax, Deferred, Download, XMLHttpAjax, inject, now, sum,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
inject = require('honk-di');
Deferred = require('deferred');
now = function() {
return (new Date).getTime();
};
Ajax = (function() {

@@ -45,5 +53,9 @@ Ajax.scope = 'singleton';

xhr = new window.XMLHttpRequest();
xhr.responseType = options.responseType;
xhr.onload = (function(_this) {
return function(e) {
if (xhr.status === 200) {
if (xhr.responseType === 'blob') {
return deferred.resolve(xhr.response);
}
switch (options.dataType) {

@@ -68,4 +80,121 @@ case 'json':

sum = function(list, acc) {
var head, tail;
if (acc == null) {
acc = 0;
}
if ((list != null ? list.length : void 0) === 0) {
return acc;
} else {
head = list[0], tail = 2 <= list.length ? __slice.call(list, 1) : [];
return sum(tail, head + acc);
}
};
Download = (function(_super) {
var _ref;
__extends(Download, _super);
Download.prototype.cacheClearInterval = 15 * 60 * 1000;
Download.prototype.http = inject(Ajax);
Download.prototype.ttl = 6 * 60 * 60 * 1000;
Download.prototype.cache = inject('download-cache');
Download.prototype.net = typeof window !== "undefined" && window !== null ? (_ref = window.Cortex) != null ? _ref.net : void 0 : void 0;
function Download() {
this.expire = __bind(this.expire, this);
if (this.shouldCache()) {
this._intervalId = setInterval(this.expire, this.cacheClearInterval);
}
Download.__super__.constructor.call(this);
}
Download.prototype.expire = function() {
var diff, entry, started, url, _ref1, _results;
started = now();
_ref1 = this.cache;
_results = [];
for (url in _ref1) {
entry = _ref1[url];
diff = started - entry.lastSeenAt;
if (diff > this.ttl) {
URL.revokeObjectURL(entry.dataUrl);
_results.push(delete this.cache[url]);
} else {
_results.push(void 0);
}
}
return _results;
};
Download.prototype.cacheSizeInBytes = function() {
var o, url;
return sum((function() {
var _ref1, _results;
_ref1 = this.cache;
_results = [];
for (url in _ref1) {
o = _ref1[url];
_results.push(o.sizeInBytes);
}
return _results;
}).call(this));
};
Download.prototype.shouldCache = function() {
var _ref1;
return ((_ref1 = this.net) != null ? _ref1.download : void 0) == null;
};
Download.prototype._request = function(options, deferred) {
var method, request, ttl, url, _ref1;
method = options.type || 'GET';
ttl = options.ttl || this.ttl;
url = options.url;
if ((_ref1 = this.net) != null ? _ref1.download : void 0) {
return this.net.download(url, {
cache: ttl
}, function(path) {
return deferred.resolve(path);
});
} else {
if (!this.cache[url]) {
request = this.http.request({
url: url,
responseType: 'blob',
type: method
});
return request.then((function(_this) {
return function(response) {
var path;
path = URL.createObjectURL(response);
_this.cache[url] = {
cachedAt: now(),
dataUrl: path,
lastSeenAt: now(),
mimeType: response.type,
sizeInBytes: response.size
};
return deferred.resolve(path);
};
})(this));
} else {
this.cache[url].lastSeenAt = now();
return deferred.resolve(this.cache[url].dataUrl);
}
}
};
return Download;
})(Ajax);
module.exports = {
Ajax: Ajax,
Download: Download,
XMLHttpAjax: XMLHttpAjax

@@ -72,0 +201,0 @@ };

(function() {
var AdStream, Ajax, Player, ProofOfPlay, XMLHttpAjax, inject, _ref,
var AdCache, AdStream, Ajax, Player, ProofOfPlay, XMLHttpAjax, inject, _ref,
__hasProp = {}.hasOwnProperty,

@@ -8,6 +8,6 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

AdCache = require('./ad_cache');
AdStream = require('./ad_stream');
_ref = require('./ajax'), Ajax = _ref.Ajax, XMLHttpAjax = _ref.XMLHttpAjax;
Player = require('./player');

@@ -17,5 +17,7 @@

_ref = require('./ajax'), Ajax = _ref.Ajax, XMLHttpAjax = _ref.XMLHttpAjax;
if (typeof window !== "undefined" && window !== null) {
window.Vistar = function(config) {
var Binder, ads, injector, player, pop;
var Binder, ads, cache, injector, player, pop, store;
Binder = (function(_super) {

@@ -33,2 +35,3 @@ __extends(Binder, _super);

this.bindConstant('image').to(document.querySelector('.player img'));
this.bindConstant('download-cache').to({});
return this.bindConstant('config').to({

@@ -38,5 +41,4 @@ url: 'http://dev.api.vistarmedia.com/api/v1/get_ad/json',

networkId: 'Ex-f6cCtRcydns8mcQqFWQ',
debug: true,
width: 1024,
height: 768,
width: 1280,
height: 720,
allowAudio: true,

@@ -48,9 +50,8 @@ directConnection: false,

longitude: -75.1299363,
queueSize: 12,
mimeTypes: ['video/webm'],
queueSize: 10,
displayArea: [
{
id: 'display-0',
width: 1024,
height: 768,
width: 1280,
height: 720,
allow_audio: false,

@@ -67,6 +68,15 @@ cpm_floor_cents: 90

injector = new inject.Injector(new Binder);
store = injector.getInstance('download-cache');
ads = injector.getInstance(AdStream);
cache = injector.getInstance(AdCache);
player = injector.getInstance(Player);
pop = injector.getInstance(ProofOfPlay);
return ads.pipe(player).pipe(pop);
window.__vistarplayer = {
ads: ads,
cache: cache,
player: player,
pop: pop,
store: store
};
return ads.pipe(cache).pipe(player).pipe(pop);
};

@@ -73,0 +83,0 @@ }

(function() {
var AdRequest, AdStream, Ajax, App, Player, ProofOfPlay, XMLHttpAjax, _ref;
var AdCache, AdRequest, AdStream, Ajax, App, Player, ProofOfPlay, XMLHttpAjax, _ref;
AdCache = require('./ad_cache');
AdRequest = require('./ad_request');

@@ -5,0 +7,0 @@

@@ -31,3 +31,3 @@ (function() {

Player.__super__.constructor.call(this, {
highWaterMark: this.config.queueSize,
highWaterMark: 0,
objectMode: true

@@ -77,6 +77,4 @@ });

Player.prototype.playVideo = function(advertisement) {
var duration;
Player.prototype.playVideo = function(advertisement, callback) {
this.hide();
duration = advertisement.length_in_milliseconds;
return this.video.setAttribute('src', advertisement.asset_url);

@@ -89,3 +87,3 @@ };

name: 'Player',
message: "receiving advertisement, buf length " + this._writableState.buffer.length
message: "receiving advertisement:\nwritable buf length " + this._writableState.buffer.length + "\"\nreadable buf length " + this._readableState.buffer.length + "\""
});

@@ -92,0 +90,0 @@ this._currentAd = advertisement;

@@ -8,6 +8,6 @@ (function() {

Logger = require('./logger');
Ajax = require('./ajax').Ajax;
Logger = require('./logger');
Transform = require('stream').Transform;

@@ -18,4 +18,2 @@

ProofOfPlay.scope = 'SINGLETON';
ProofOfPlay.prototype.http = inject(Ajax);

@@ -29,3 +27,4 @@

ProofOfPlay.__super__.constructor.call(this, {
objectMode: true
objectMode: true,
highWaterMark: 100
});

@@ -35,3 +34,3 @@ }

ProofOfPlay.prototype.expire = function(ad) {
var req, url;
var url;
this.log.write({

@@ -43,13 +42,11 @@ name: 'ProofOfPlay',

url = ad.expiration_url;
req = this.http.request({
return this.http.request({
type: 'GET',
url: url
url: url,
dataType: 'json'
});
return req.then(function(response) {
return JSON.parse(response);
});
};
ProofOfPlay.prototype.confirm = function(ad) {
var req, url;
var url;
this.log.write({

@@ -61,5 +58,6 @@ name: 'ProofOfPlay',

url = ad.proof_of_play_url;
req = this.http.request({
return this.http.request({
type: 'POST',
url: url,
dataType: 'json',
data: JSON.stringify({

@@ -69,5 +67,2 @@ display_time: ad.display_time

});
return req.then(function(response) {
return JSON.parse(response);
});
};

@@ -77,9 +72,13 @@

if (this._wasDisplayed(ad)) {
return this.confirm(ad).then(function(response) {
return callback(null, response);
});
return this.confirm(ad).then((function(_this) {
return function(response) {
return _this._process(response, callback);
};
})(this));
} else {
return this.expire(ad).then(function(response) {
return callback(null, response);
});
return this.expire(ad).then((function(_this) {
return function(response) {
return _this._process(response, callback);
};
})(this));
}

@@ -93,2 +92,10 @@ };

ProofOfPlay.prototype._process = function(response, cb) {
if (this._readableState.pipesCount > 0) {
return cb(null, response);
} else {
return cb();
}
};
return ProofOfPlay;

@@ -95,0 +102,0 @@

@@ -5,3 +5,3 @@ {

"description": "An HTML 5 Player for Vistar Media assets.",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "http://kb.vistarmedia.com/display/sell/HTML5+Player",

@@ -25,4 +25,3 @@ "repository": {

"deferred": "0.7.1",
"honk-di": "0.0.10",
"react": "0.12.x"
"honk-di": "0.0.10"
},

@@ -38,3 +37,3 @@ "devDependencies": {

"domino": "1.0.17",
"gulp": "3.8.x",
"gulp": "3.8.8",
"gulp-browserify": "0.5.x",

@@ -48,8 +47,8 @@ "gulp-cjsx": "2.0.x",

"gulp-util": "2.2.x",
"honk-test-net": "0.1.0",
"mocha": "^1",
"serve-static": "1.5.3",
"sinon": "1.12.2",
"sinon-chai": "2.6.0"
"sinon-chai": "2.6.0",
"through2": "0.6.3"
}
}
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