Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-store-iframe

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-store-iframe - npm Package Compare versions

Comparing version 2.2.9 to 2.3.0

331

dist/dfp.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateDfpTargets = exports.refreshDfpSlot = exports.destroyDfpSlot = exports.createDfpSlot = undefined;
exports.attachDfp = attachDfp;
exports.buildSizeMap = buildSizeMap;
exports.createDfpSlot = createDfpSlot;
exports.destroyDfpSlot = destroyDfpSlot;
exports.refreshDfpSlot = refreshDfpSlot;
exports.updateDfpTargets = updateDfpTargets;
var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray");
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _getIterator2 = _interopRequireDefault(require("@babel/runtime/core-js/get-iterator"));
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _regenerator = require("babel-runtime/regenerator");
// Constants
var hasWindow = typeof window !== "undefined";
var hasGpt = hasWindow && typeof window.googletag !== "undefined"; // Variables
var _regenerator2 = _interopRequireDefault(_regenerator);
var sizeMaps = {};
var slots = {}; // Dfp
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
function attachDfp(store) {
if (!hasGpt) {
return;
}
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
window.googletag.cmd.push(function () {
store.set("dfp.loaded", true);
window.googletag.pubads().addEventListener("slotRenderEnded",
/*#__PURE__*/
function () {
var _ref = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(event) {
var isEmpty, size, slot, divId;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
isEmpty = event.isEmpty, size = event.size, slot = event.slot;
divId = slot.getSlotElementId();
store.set("iframes.".concat(divId, ".rendered"), {
divId: divId,
isEmpty: isEmpty,
size: size
});
var createDfpSlot = exports.createDfpSlot = function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(options) {
case 3:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
window.googletag.pubads().addEventListener("slotOnload", function (event) {
var divId = event.slot.getSlotElementId();
store.set("iframes.".concat(divId, ".loaded"), true);
});
});
}
function buildSizeMap(_ref2) {
var dfp = _ref2.dfp,
unit = _ref2.unit;
if (sizeMaps[unit.id]) {
return sizeMaps[unit.id];
}
var map = window.googletag.sizeMapping();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator2.default)(dfp.viewportMaps.entries()), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
i = _step$value[0],
value = _step$value[1];
map.addSize([value[0], 0], unit.viewportSizes[i]);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return sizeMaps[unit.id] = map.build();
}
function createDfpSlot(_x2) {
return _createDfpSlot.apply(this, arguments);
}
function _createDfpSlot() {
_createDfpSlot = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee2(options) {
var iframeId, prev, props, state, store, dfp, iframes, iframe, valid, divId, _iframe$dfp, oop, path, targets, unitId, unit, slot, sizeMap, key;
return _regenerator2.default.wrap(function _callee2$(_context2) {
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {

@@ -52,11 +148,11 @@ switch (_context2.prev = _context2.next) {

unit = dfp.units[unitId];
slot = void 0;
if (oop) {
slot = window.googletag.defineOutOfPageSlot(path, divId);
} else {
sizeMap = buildSizeMap({ dfp: dfp, iframe: iframe, unit: unit });
sizeMap = buildSizeMap({
dfp: dfp,
iframe: iframe,
unit: unit
});
slot = window.googletag.defineSlot(path, unit.sizes, divId);

@@ -81,3 +177,3 @@

case 15:
case 14:
case "end":

@@ -89,25 +185,27 @@ return _context2.stop();

}));
return _createDfpSlot.apply(this, arguments);
}
return function createDfpSlot(_x2) {
return _ref3.apply(this, arguments);
};
}();
function destroyDfpSlot(_x3) {
return _destroyDfpSlot.apply(this, arguments);
}
var destroyDfpSlot = exports.destroyDfpSlot = function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(_ref5) {
var iframeId = _ref5.iframeId,
store = _ref5.store;
return _regenerator2.default.wrap(function _callee3$(_context3) {
function _destroyDfpSlot() {
_destroyDfpSlot = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee3(_ref3) {
var iframeId, store;
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
iframeId = _ref3.iframeId, store = _ref3.store;
_context3.next = 3;
return store.onceExists("dfp.loaded");
case 2:
case 3:
window.googletag.destroySlots([slots[iframeId]]);
slots[iframeId] = undefined;
case 4:
case 5:
case "end":

@@ -119,22 +217,23 @@ return _context3.stop();

}));
return _destroyDfpSlot.apply(this, arguments);
}
return function destroyDfpSlot(_x3) {
return _ref4.apply(this, arguments);
};
}();
function refreshDfpSlot(_x4) {
return _refreshDfpSlot.apply(this, arguments);
}
var refreshDfpSlot = exports.refreshDfpSlot = function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(_ref7) {
var iframeId = _ref7.iframeId,
state = _ref7.state,
store = _ref7.store;
var iframes, divId;
return _regenerator2.default.wrap(function _callee4$(_context4) {
function _refreshDfpSlot() {
_refreshDfpSlot = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee4(_ref4) {
var iframeId, state, store, iframes, divId;
return _regenerator.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
iframeId = _ref4.iframeId, state = _ref4.state, store = _ref4.store;
_context4.next = 3;
return store.onceExists("dfp.loaded");
case 2:
case 3:
iframes = state.iframes;

@@ -144,3 +243,3 @@ divId = iframes[iframeId].divId;

if (slots[divId]) {
_context4.next = 6;
_context4.next = 7;
break;

@@ -151,7 +250,8 @@ }

case 6:
case 7:
window.googletag.pubads().refresh([slots[divId]], {
changeCorrelator: false
});
window.googletag.pubads().refresh([slots[divId]], { changeCorrelator: false });
case 7:
case 8:
case "end":

@@ -163,23 +263,25 @@ return _context4.stop();

}));
return _refreshDfpSlot.apply(this, arguments);
}
return function refreshDfpSlot(_x4) {
return _ref6.apply(this, arguments);
};
}();
function updateDfpTargets(_x5) {
return _updateDfpTargets.apply(this, arguments);
}
var updateDfpTargets = exports.updateDfpTargets = function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(_ref9) {
var store = _ref9.store;
var targets, key;
return _regenerator2.default.wrap(function _callee5$(_context5) {
function _updateDfpTargets() {
_updateDfpTargets = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee5(_ref5) {
var store, targets, key;
return _regenerator.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
store = _ref5.store;
_context5.next = 3;
return store.onceExists("dfp.loaded");
case 2:
case 3:
targets = store.getSync("dfp.targets") || {};
for (key in targets) {

@@ -189,3 +291,3 @@ window.googletag.pubads().setTargeting(key, targets[key] || "");

case 4:
case 5:
case "end":

@@ -197,107 +299,4 @@ return _context5.stop();

}));
return function updateDfpTargets(_x5) {
return _ref8.apply(this, arguments);
};
}();
exports.attachDfp = attachDfp;
exports.buildSizeMap = buildSizeMap;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Constants
var hasWindow = typeof window !== "undefined";
var hasGpt = hasWindow && typeof window.googletag !== "undefined";
// Variables
var sizeMaps = {};
var slots = {};
// Dfp
function attachDfp(store) {
var _this = this;
if (!hasGpt) {
return;
}
window.googletag.cmd.push(function () {
store.set("dfp.loaded", true);
window.googletag.pubads().addEventListener("slotRenderEnded", function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(event) {
var isEmpty, size, slot, divId;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
isEmpty = event.isEmpty, size = event.size, slot = event.slot;
divId = slot.getSlotElementId();
store.set("iframes." + divId + ".rendered", {
divId: divId,
isEmpty: isEmpty,
size: size
});
case 3:
case "end":
return _context.stop();
}
}
}, _callee, _this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
window.googletag.pubads().addEventListener("slotOnload", function (event) {
var divId = event.slot.getSlotElementId();
store.set("iframes." + divId + ".loaded", true);
});
});
return _updateDfpTargets.apply(this, arguments);
}
function buildSizeMap(_ref2) {
var dfp = _ref2.dfp,
unit = _ref2.unit;
if (sizeMaps[unit.id]) {
return sizeMaps[unit.id];
}
var map = window.googletag.sizeMapping();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator3.default)(dfp.viewportMaps.entries()), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = (0, _slicedToArray3.default)(_step.value, 2),
i = _step$value[0],
value = _step$value[1];
map.addSize([value[0], 0], unit.viewportSizes[i]);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return sizeMaps[unit.id] = map.build();
}
//# sourceMappingURL=dfp.js.map
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createIframe = undefined;
exports.createIframe = createIframe;
exports.iframeSize = iframeSize;
var _regenerator = require("babel-runtime/regenerator");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
// Variables
var elements = {}; // Iframes
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function createIframe(_x) {
return _createIframe.apply(this, arguments);
}
// Iframes
var createIframe = exports.createIframe = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(options) {
function _createIframe() {
_createIframe = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(options) {
var iframeId, prev, props, state, store, iframes, iframe, valid, divId, url, loaded, onLoad, el;
return _regenerator2.default.wrap(function _callee$(_context) {
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {

@@ -38,3 +45,3 @@ switch (_context.prev = _context.next) {

divId = iframe.divId, url = iframe.url;
loaded = "iframes." + iframeId + ".loaded";
loaded = "iframes.".concat(iframeId, ".loaded");

@@ -46,8 +53,5 @@ onLoad = function onLoad() {

el = document.createElement("iframe");
el.onload = onLoad;
el.frameBorder = 0;
el.src = url;
document.getElementById(divId).appendChild(el);

@@ -63,19 +67,9 @@ elements[divId] = el;

}));
return _createIframe.apply(this, arguments);
}
return function createIframe(_x) {
return _ref.apply(this, arguments);
};
}();
exports.iframeSize = iframeSize;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Variables
var elements = {};function iframeSize(options) {
function iframeSize(options) {
var iframeId = options.iframeId,
state = options.state;
var iframes = state.iframes;
var iframe = iframes[iframeId];

@@ -85,4 +79,2 @@ var divId = iframe.divId,

width = iframe.width;
var el = document.getElementById(divId).firstChild;

@@ -89,0 +81,0 @@

@@ -6,24 +6,22 @@ "use strict";

});
exports.default = _default;
exports.default = function (store) {
var _dfp = require("./dfp");
var _iframes = require("./iframes");
// Dfp
// Iframes
// Composers
function _default(store) {
store.on("dfp.targets", _dfp.updateDfpTargets);
store.on("iframes.{iframeId}", _dfp.createDfpSlot);
store.on("iframes.{iframeId}", _iframes.createIframe);
store.on("afterDelete", "iframes.{iframeId}", _dfp.destroyDfpSlot);
store.on("iframes.{iframeId}.height", _iframes.iframeSize);
store.on("iframes.{iframeId}.width", _iframes.iframeSize);
store.on("iframes.{iframeId}.refresh", _dfp.refreshDfpSlot);
(0, _dfp.attachDfp)(store);
return store;
};
var _dfp = require("./dfp");
var _iframes = require("./iframes");
}
//# sourceMappingURL=index.js.map
{
"name": "dot-store-iframe",
"version": "2.2.9",
"version": "2.3.0",
"description": "Iframe controller integration for dot-store",

@@ -28,10 +28,13 @@ "keywords": [

},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"dot-store": "^2.2.8",
"@babel/cli": "^7.0.0-beta.47",
"@babel/core": "^7.0.0-beta.47",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.47",
"@babel/plugin-transform-runtime": "^7.0.0-beta.47",
"@babel/preset-env": "^7.0.0-beta.47",
"babel-core": "^7.0.0-bridge.0",
"dot-store": "^2.3.0",
"fxtr": "1",

@@ -41,4 +44,10 @@ "jest": "^22.4.3",

},
"dependencies": {
"babel-runtime": "^6.26.0"
"babel": {
"presets": [
"@babel/preset-env"
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime"
]
},

@@ -45,0 +54,0 @@ "jest": {

Sorry, the diff of this file is not supported yet

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