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

@advertol/service-google-dfp

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@advertol/service-google-dfp - npm Package Compare versions

Comparing version 1.0.4-alpha.0 to 1.1.0

CHANGELOG.md

170

index.cjs.js
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var core = require('@advertol/core');
var manageSideEffects = _interopDefault(require('manage-side-effects'));

@@ -8,5 +11,11 @@ function _inheritsLoose(subClass, superClass) {

subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {

@@ -16,18 +25,12 @@ if (self === void 0) {

}
return self;
}
var GoogleDfpService =
/*#__PURE__*/
function (_Service) {
var GoogleDfpService = /*#__PURE__*/function (_Service) {
_inheritsLoose(GoogleDfpService, _Service);
function GoogleDfpService(options) {
var _this;
if (options === void 0) {
options = {};
}
_this = _Service.call(this) || this;

@@ -42,15 +45,15 @@ _this.slots = {};

_this.displayedZones = [];
_this.sideEffects = manageSideEffects();
var _options = options,
_options$zones = _options.zones,
zones = _options$zones === void 0 ? [] : _options$zones,
_options$onSetup = _options.onSetup,
onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup,
_options$refreshZones = _options.refreshZones,
refreshZones = _options$refreshZones === void 0 ? _this.refreshZones : _options$refreshZones;
_options$zones = _options.zones,
zones = _options$zones === void 0 ? [] : _options$zones,
_options$onSetup = _options.onSetup,
onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup,
_options$refreshZones = _options.refreshZones,
refreshZones = _options$refreshZones === void 0 ? _this.refreshZones : _options$refreshZones;
_this.refreshZones = refreshZones.bind(_assertThisInitialized(_this));
zones.forEach(function (_ref) {
var id = _ref.id,
adUnitPath = _ref.adUnitPath,
slot = _ref.slot;
adUnitPath = _ref.adUnitPath,
slot = _ref.slot;
_this.addZone({

@@ -62,14 +65,12 @@ id: id,

});
/* istanbul ignore next */
_this.cmd(function () {
_this.setupService();
onSetup.call(_assertThisInitialized(_this));
_this.setupEvents();
});
return _this;
}
/**

@@ -80,40 +81,30 @@ * @param {string} id

*/
var _proto = GoogleDfpService.prototype;
_proto.addZone = function addZone(_ref2) {
var id = _ref2.id,
adUnitPath = _ref2.adUnitPath,
slot = _ref2.slot;
adUnitPath = _ref2.adUnitPath,
slot = _ref2.slot;
if (id in this.slots && id in this.adUnitPaths) {
return;
}
this.slots[id] = slot;
this.adUnitPaths[id] = adUnitPath;
}
/**
* @param {Function} callback [description]
*/
;
_proto.cmd
/* istanbul ignore next */
= function cmd(callback) {
*/;
_proto.cmd /* istanbul ignore next */ = function cmd(callback) {
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.cmd.push(callback);
};
_proto.setupService
/* istanbul ignore next */
= function setupService() {
_proto.setupService /* istanbul ignore next */ = function setupService() {
if (typeof window.googletag === 'undefined') {
return;
}
if (window.googletag.pubadsReady) {
return;
}
window.googletag.pubads().enableSingleRequest();

@@ -124,65 +115,53 @@ window.googletag.pubads().collapseEmptyDivs(true);

};
_proto.setupEvents
/* istanbul ignore next */
= function setupEvents() {
_proto.setupEvents /* istanbul ignore next */ = function setupEvents() {
var _this2 = this;
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.pubads().addEventListener('slotRenderEnded', function (data) {
var adUnitPath = data.slot.getAdUnitPath();
var response = data.slot.getResponseInformation();
var callback = _this2.isZoneEmpty(response) ? _this2.emptyZoneCallbacks[adUnitPath] : _this2.filledZoneCallbacks[adUnitPath];
if (typeof callback === 'function') {
callback();
}
delete _this2.filledZoneCallbacks[adUnitPath];
delete _this2.emptyZoneCallbacks[adUnitPath];
this.sideEffects.add(function () {
var handler = function handler(data) {
var adUnitPath = data.slot.getAdUnitPath();
var response = data.slot.getResponseInformation();
var callback = _this2.isZoneEmpty(response) ? _this2.emptyZoneCallbacks[adUnitPath] : _this2.filledZoneCallbacks[adUnitPath];
if (typeof callback === 'function') {
callback();
}
delete _this2.filledZoneCallbacks[adUnitPath];
delete _this2.emptyZoneCallbacks[adUnitPath];
};
window.googletag.pubads().addEventListener('slotRenderEnded', handler);
return function () {
window.googletag.pubads().removeEventListener('slotRenderEnded', handler);
};
});
}
/**
* @param {HTMLElement} zone.element
* @param {string} zone.id
*/
;
_proto.displayZone
/* istanbul ignore next */
= function displayZone(_ref3) {
*/;
_proto.displayZone /* istanbul ignore next */ = function displayZone(_ref3) {
var element = _ref3.element,
id = _ref3.id;
id = _ref3.id;
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.display(element.id);
}
/**
* @param {googletag.Slot[]} slots
*/
;
_proto.refreshZones
/* istanbul ignore next */
= function refreshZones(slots) {
*/;
_proto.refreshZones /* istanbul ignore next */ = function refreshZones(slots) {
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.pubads().refresh(slots);
}
/**
* @param {Object[]} zones
*/
;
*/;
_proto.beforeWriteZones = function beforeWriteZones(zones) {
var _this3 = this;
this.cmd(function () {

@@ -192,3 +171,2 @@ if (zones.length === 0) {

}
zones.filter(function (_ref4) {

@@ -199,5 +177,3 @@ var id = _ref4.id;

var id = _ref5.id;
_this3.slotResolvedZones.push(id);
_this3.resolvedSlots[id] = _this3.slots[id]();

@@ -207,10 +183,8 @@ });

}
/**
* @param {Object[]} zones
*/
;
*/;
_proto.afterWriteZones = function afterWriteZones(zones) {
var _this4 = this;
this.cmd(function () {

@@ -220,3 +194,2 @@ if (zones.length === 0) {

}
var slots = zones.filter(function (_ref6) {

@@ -227,15 +200,12 @@ var id = _ref6.id;

var id = _ref7.id;
_this4.refreshedZones.push(id);
return _this4.resolvedSlots[id];
});
if (slots.length === 0) {
return;
}
_this4.refreshZones(slots);
});
}
/**

@@ -246,25 +216,18 @@ * @param {HTMLElement} zone.element

* @return {Promise<boolean>}
*/
;
*/;
_proto.writeZone = function writeZone(_ref8) {
var _this5 = this;
var element = _ref8.element,
id = _ref8.id;
id = _ref8.id;
return new Promise(function (resolve) {
var adUnitPath = _this5.adUnitPaths[id];
_this5.filledZoneCallbacks[adUnitPath] = function () {
return resolve(true);
};
_this5.emptyZoneCallbacks[adUnitPath] = function () {
return resolve(false);
};
_this5.cmd(function () {
if (_this5.displayedZones.indexOf(id) === -1 && id in _this5.slots === true) {
_this5.displayedZones.push(id);
_this5.displayZone({

@@ -278,2 +241,3 @@ element: element,

}
/**

@@ -283,9 +247,9 @@ * @param {*} response

* @return {boolean}
*/
;
*/;
_proto.isZoneEmpty = function isZoneEmpty(response) {
return response === null;
};
_proto.destroy = function destroy() {
this.sideEffects.removeAll();
};
return GoogleDfpService;

@@ -292,0 +256,0 @@ }(core.Service);

import { Service } from '@advertol/core';
import manageSideEffects from 'manage-side-effects';

@@ -6,5 +7,11 @@ function _inheritsLoose(subClass, superClass) {

subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {

@@ -14,18 +21,12 @@ if (self === void 0) {

}
return self;
}
var GoogleDfpService =
/*#__PURE__*/
function (_Service) {
var GoogleDfpService = /*#__PURE__*/function (_Service) {
_inheritsLoose(GoogleDfpService, _Service);
function GoogleDfpService(options) {
var _this;
if (options === void 0) {
options = {};
}
_this = _Service.call(this) || this;

@@ -40,15 +41,15 @@ _this.slots = {};

_this.displayedZones = [];
_this.sideEffects = manageSideEffects();
var _options = options,
_options$zones = _options.zones,
zones = _options$zones === void 0 ? [] : _options$zones,
_options$onSetup = _options.onSetup,
onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup,
_options$refreshZones = _options.refreshZones,
refreshZones = _options$refreshZones === void 0 ? _this.refreshZones : _options$refreshZones;
_options$zones = _options.zones,
zones = _options$zones === void 0 ? [] : _options$zones,
_options$onSetup = _options.onSetup,
onSetup = _options$onSetup === void 0 ? function () {} : _options$onSetup,
_options$refreshZones = _options.refreshZones,
refreshZones = _options$refreshZones === void 0 ? _this.refreshZones : _options$refreshZones;
_this.refreshZones = refreshZones.bind(_assertThisInitialized(_this));
zones.forEach(function (_ref) {
var id = _ref.id,
adUnitPath = _ref.adUnitPath,
slot = _ref.slot;
adUnitPath = _ref.adUnitPath,
slot = _ref.slot;
_this.addZone({

@@ -60,14 +61,12 @@ id: id,

});
/* istanbul ignore next */
_this.cmd(function () {
_this.setupService();
onSetup.call(_assertThisInitialized(_this));
_this.setupEvents();
});
return _this;
}
/**

@@ -78,40 +77,30 @@ * @param {string} id

*/
var _proto = GoogleDfpService.prototype;
_proto.addZone = function addZone(_ref2) {
var id = _ref2.id,
adUnitPath = _ref2.adUnitPath,
slot = _ref2.slot;
adUnitPath = _ref2.adUnitPath,
slot = _ref2.slot;
if (id in this.slots && id in this.adUnitPaths) {
return;
}
this.slots[id] = slot;
this.adUnitPaths[id] = adUnitPath;
}
/**
* @param {Function} callback [description]
*/
;
_proto.cmd
/* istanbul ignore next */
= function cmd(callback) {
*/;
_proto.cmd /* istanbul ignore next */ = function cmd(callback) {
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.cmd.push(callback);
};
_proto.setupService
/* istanbul ignore next */
= function setupService() {
_proto.setupService /* istanbul ignore next */ = function setupService() {
if (typeof window.googletag === 'undefined') {
return;
}
if (window.googletag.pubadsReady) {
return;
}
window.googletag.pubads().enableSingleRequest();

@@ -122,65 +111,53 @@ window.googletag.pubads().collapseEmptyDivs(true);

};
_proto.setupEvents
/* istanbul ignore next */
= function setupEvents() {
_proto.setupEvents /* istanbul ignore next */ = function setupEvents() {
var _this2 = this;
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.pubads().addEventListener('slotRenderEnded', function (data) {
var adUnitPath = data.slot.getAdUnitPath();
var response = data.slot.getResponseInformation();
var callback = _this2.isZoneEmpty(response) ? _this2.emptyZoneCallbacks[adUnitPath] : _this2.filledZoneCallbacks[adUnitPath];
if (typeof callback === 'function') {
callback();
}
delete _this2.filledZoneCallbacks[adUnitPath];
delete _this2.emptyZoneCallbacks[adUnitPath];
this.sideEffects.add(function () {
var handler = function handler(data) {
var adUnitPath = data.slot.getAdUnitPath();
var response = data.slot.getResponseInformation();
var callback = _this2.isZoneEmpty(response) ? _this2.emptyZoneCallbacks[adUnitPath] : _this2.filledZoneCallbacks[adUnitPath];
if (typeof callback === 'function') {
callback();
}
delete _this2.filledZoneCallbacks[adUnitPath];
delete _this2.emptyZoneCallbacks[adUnitPath];
};
window.googletag.pubads().addEventListener('slotRenderEnded', handler);
return function () {
window.googletag.pubads().removeEventListener('slotRenderEnded', handler);
};
});
}
/**
* @param {HTMLElement} zone.element
* @param {string} zone.id
*/
;
_proto.displayZone
/* istanbul ignore next */
= function displayZone(_ref3) {
*/;
_proto.displayZone /* istanbul ignore next */ = function displayZone(_ref3) {
var element = _ref3.element,
id = _ref3.id;
id = _ref3.id;
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.display(element.id);
}
/**
* @param {googletag.Slot[]} slots
*/
;
_proto.refreshZones
/* istanbul ignore next */
= function refreshZones(slots) {
*/;
_proto.refreshZones /* istanbul ignore next */ = function refreshZones(slots) {
if (typeof window.googletag === 'undefined') {
return;
}
window.googletag.pubads().refresh(slots);
}
/**
* @param {Object[]} zones
*/
;
*/;
_proto.beforeWriteZones = function beforeWriteZones(zones) {
var _this3 = this;
this.cmd(function () {

@@ -190,3 +167,2 @@ if (zones.length === 0) {

}
zones.filter(function (_ref4) {

@@ -197,5 +173,3 @@ var id = _ref4.id;

var id = _ref5.id;
_this3.slotResolvedZones.push(id);
_this3.resolvedSlots[id] = _this3.slots[id]();

@@ -205,10 +179,8 @@ });

}
/**
* @param {Object[]} zones
*/
;
*/;
_proto.afterWriteZones = function afterWriteZones(zones) {
var _this4 = this;
this.cmd(function () {

@@ -218,3 +190,2 @@ if (zones.length === 0) {

}
var slots = zones.filter(function (_ref6) {

@@ -225,15 +196,12 @@ var id = _ref6.id;

var id = _ref7.id;
_this4.refreshedZones.push(id);
return _this4.resolvedSlots[id];
});
if (slots.length === 0) {
return;
}
_this4.refreshZones(slots);
});
}
/**

@@ -244,25 +212,18 @@ * @param {HTMLElement} zone.element

* @return {Promise<boolean>}
*/
;
*/;
_proto.writeZone = function writeZone(_ref8) {
var _this5 = this;
var element = _ref8.element,
id = _ref8.id;
id = _ref8.id;
return new Promise(function (resolve) {
var adUnitPath = _this5.adUnitPaths[id];
_this5.filledZoneCallbacks[adUnitPath] = function () {
return resolve(true);
};
_this5.emptyZoneCallbacks[adUnitPath] = function () {
return resolve(false);
};
_this5.cmd(function () {
if (_this5.displayedZones.indexOf(id) === -1 && id in _this5.slots === true) {
_this5.displayedZones.push(id);
_this5.displayZone({

@@ -276,2 +237,3 @@ element: element,

}
/**

@@ -281,9 +243,9 @@ * @param {*} response

* @return {boolean}
*/
;
*/;
_proto.isZoneEmpty = function isZoneEmpty(response) {
return response === null;
};
_proto.destroy = function destroy() {
this.sideEffects.removeAll();
};
return GoogleDfpService;

@@ -290,0 +252,0 @@ }(Service);

{
"name": "@advertol/service-google-dfp",
"version": "1.0.4-alpha.0",
"version": "1.1.0",
"description": "Google DFP/Ad Manager service.",

@@ -12,2 +12,3 @@ "main": "index.cjs.js",

"index.esm.{js,js.map}",
"CHANGELOG.md",
"LICENSE.md",

@@ -23,10 +24,13 @@ "README.md"

"lint": "eslint '{index,lib/**/*,test/**/*}.js'",
"postpublish": "GITHUB_TOKEN=$GITHUB_RELEASE_TOKEN github-release-from-changelog",
"prepublishOnly": "npm run build",
"release": "np",
"release": "np --no-release-draft",
"test": "npm run lint && npm run test:automated",
"test:automated": "BABEL_ENV=test karma start",
"test:automated:watch": "npm run test:automated -- --auto-watch --no-single-run"
"test:automated:watch": "npm run test:automated -- --auto-watch --no-single-run",
"version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md"
},
"dependencies": {
"@advertol/core": "^1.0.2-alpha.0"
"@advertol/core": "^1.0.0",
"manage-side-effects": "^1.1.0"
},

@@ -41,2 +45,3 @@ "devDependencies": {

"babel-preset-niksy": "^4.1.0",
"changelog-verify": "^1.1.2",
"core-js": "^2.6.5",

@@ -52,2 +57,3 @@ "eslint": "^5.4.0",

"esm": "^3.0.51",
"github-release-from-changelog": "^1.3.2",
"istanbul-instrumenter-loader": "^3.0.1",

@@ -63,8 +69,9 @@ "karma": "^4.0.1",

"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.0",
"karma-webpack": "^4.0.2",
"mocha": "^4.1.0",
"np": "^3.0.4",
"np": "^5.2.1",
"rollup": "^1.0.0",
"rollup-plugin-babel": "^4.2.0",
"sinon": "^2.4.1",
"version-changelog": "^3.1.1",
"webpack": "^4.12.0"

@@ -89,9 +96,8 @@ },

"type": "git",
"url": "git+https://github.com/niksy/advertol.git"
"url": "git+https://github.com/niksy/advertol-service-google-dfp.git"
},
"bugs": {
"url": "https://github.com/niksy/advertol/issues"
"url": "https://github.com/niksy/advertol-service-google-dfp/issues"
},
"homepage": "https://github.com/niksy/advertol#readme",
"gitHead": "0c9d64757515bebb1bffe19ad98669e95f782d8c"
"homepage": "https://github.com/niksy/advertol-service-google-dfp#readme"
}

@@ -109,8 +109,8 @@ # @advertol/service-google-dfp

[ci]: https://travis-ci.com/niksy/advertol
[ci-img]: https://travis-ci.com/niksy/advertol.svg?branch=master
[ci]: https://travis-ci.com/niksy/advertol-service-google-dfp
[ci-img]: https://travis-ci.com/niksy/advertol-service-google-dfp.svg?branch=master
[browserstack]: https://www.browserstack.com/
[browserstack-img]: https://www.browserstack.com/automate/badge.svg?badge_key=OEoyeTlOV05LL25aemN4WU5kN3VGQzBFT3lrc0FZcjhSeDJNS0hwWDU5RT0tLTI3blFyU3d2a3dCT2xGb1NBczZtVXc9PQ==--e720201c13e584cd0b47e31366072e08d7d87710
[browserstack-img]: https://www.browserstack.com/automate/badge.svg?badge_key=RENheEJRRGlDMGo3QWFhSTRoYy8wUHlwZFNPM2FhTHB3RUVDZzFGS0NaWT0tLXNheHBwbHpGcDJuMVB4Zjd1THlIUEE9PQ==--e54ee2f7777a7d1006c46c7a74113388d8e89ead
[googletag-define-slot]: https://developers.google.com/doubleclick-gpt/reference#googletag.defineSlot
[googletag-define-outofpage-slot]: https://developers.google.com/doubleclick-gpt/reference#googletag.defineOutOfPageSlot
[googletag-refresh]: https://developers.google.com/doubleclick-gpt/reference#googletag.PubAdsService_refresh

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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