Skip to content

Commit

Permalink
Bundle release 3.0.0-alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kobawan committed May 27, 2019
1 parent 5b44778 commit af0c400
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 41 deletions.
2 changes: 1 addition & 1 deletion dist/vast-client-browser.min.js

Large diffs are not rendered by default.

77 changes: 58 additions & 19 deletions dist/vast-client-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,28 @@ function flatten(arr) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
/**
* Joins two arrays without duplicates
* @param {Array} arr1
* @param {Array} arr2
* @return {Array}
*/


function joinArrayUnique() {
var arr1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var arr2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var firstArr = Array.isArray(arr1) ? arr1 : [];
var secondArr = Array.isArray(arr2) ? arr2 : [];
var arr = firstArr.concat(secondArr);
return arr.reduce(function (res, val) {
if (res.indexOf(val) === -1) {
res.push(val);
}

return res;
}, []);
}

var util = {
track: track,
Expand All @@ -291,7 +313,8 @@ var util = {
leftpad: leftpad,
range: range,
isNumeric: isNumeric,
flatten: flatten
flatten: flatten,
joinArrayUnique: joinArrayUnique
};

/**
Expand Down Expand Up @@ -504,7 +527,24 @@ function mergeWrapperAdData(unwrappedAd, wrapper) {
unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates);
unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates);
unwrappedAd.extensions = wrapper.extensions.concat(unwrappedAd.extensions);
var wrapperCompanions = (wrapper.creatives || []).filter(function (creative) {
return creative && creative.type === 'companion';
});
var wrapperCompanionClickTracking = wrapperCompanions.reduce(function (result, creative) {
(creative.variations || []).forEach(function (variation) {
(variation.companionClickTrackingURLTemplates || []).forEach(function (url) {
if (result.indexOf(url) === -1) {
result.push(url);
}
});
});
return result;
}, []);
unwrappedAd.creatives = wrapperCompanions.concat(unwrappedAd.creatives);
var wrapperHasVideoClickTracking = wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length;
var wrapperHasVideoCustomClick = wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length;
unwrappedAd.creatives.forEach(function (creative) {
// merge tracking events
if (wrapper.trackingEvents && wrapper.trackingEvents[creative.type]) {
for (var eventName in wrapper.trackingEvents[creative.type]) {
var urls = wrapper.trackingEvents[creative.type][eventName];
Expand All @@ -516,32 +556,31 @@ function mergeWrapperAdData(unwrappedAd, wrapper) {
creative.trackingEvents[eventName] = creative.trackingEvents[eventName].concat(urls);
}
}
});

if (wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear') {
if (creative.type === 'linear') {
// merge video click tracking url
if (wrapperHasVideoClickTracking) {
creative.videoClickTrackingURLTemplates = creative.videoClickTrackingURLTemplates.concat(wrapper.videoClickTrackingURLTemplates);
}
});
}
} // merge video custom click url

if (wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear') {

if (wrapperHasVideoCustomClick) {
creative.videoCustomClickURLTemplates = creative.videoCustomClickURLTemplates.concat(wrapper.videoCustomClickURLTemplates);
}
});
} // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null
} // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null


if (wrapper.videoClickThroughURLTemplate) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear' && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) {
if (wrapper.videoClickThroughURLTemplate && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) {
creative.videoClickThroughURLTemplate = wrapper.videoClickThroughURLTemplate;
}
});
}
} // pass wrapper companion trackers to all companions


if (creative.type === 'companion' && wrapperCompanionClickTracking.length) {
(creative.variations || []).forEach(function (variation) {
variation.companionClickTrackingURLTemplates = util.joinArrayUnique(variation.companionClickTrackingURLTemplates, wrapperCompanionClickTracking);
});
}
});
}

var parserUtils = {
Expand Down
2 changes: 1 addition & 1 deletion dist/vast-client-node.min.js

Large diffs are not rendered by default.

77 changes: 58 additions & 19 deletions dist/vast-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,28 @@
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
/**
* Joins two arrays without duplicates
* @param {Array} arr1
* @param {Array} arr2
* @return {Array}
*/


function joinArrayUnique() {
var arr1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var arr2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var firstArr = Array.isArray(arr1) ? arr1 : [];
var secondArr = Array.isArray(arr2) ? arr2 : [];
var arr = firstArr.concat(secondArr);
return arr.reduce(function (res, val) {
if (res.indexOf(val) === -1) {
res.push(val);
}

return res;
}, []);
}

var util = {
track: track,
Expand All @@ -293,7 +315,8 @@
leftpad: leftpad,
range: range,
isNumeric: isNumeric,
flatten: flatten
flatten: flatten,
joinArrayUnique: joinArrayUnique
};

/**
Expand Down Expand Up @@ -506,7 +529,24 @@
unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates);
unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates);
unwrappedAd.extensions = wrapper.extensions.concat(unwrappedAd.extensions);
var wrapperCompanions = (wrapper.creatives || []).filter(function (creative) {
return creative && creative.type === 'companion';
});
var wrapperCompanionClickTracking = wrapperCompanions.reduce(function (result, creative) {
(creative.variations || []).forEach(function (variation) {
(variation.companionClickTrackingURLTemplates || []).forEach(function (url) {
if (result.indexOf(url) === -1) {
result.push(url);
}
});
});
return result;
}, []);
unwrappedAd.creatives = wrapperCompanions.concat(unwrappedAd.creatives);
var wrapperHasVideoClickTracking = wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length;
var wrapperHasVideoCustomClick = wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length;
unwrappedAd.creatives.forEach(function (creative) {
// merge tracking events
if (wrapper.trackingEvents && wrapper.trackingEvents[creative.type]) {
for (var eventName in wrapper.trackingEvents[creative.type]) {
var urls = wrapper.trackingEvents[creative.type][eventName];
Expand All @@ -518,32 +558,31 @@
creative.trackingEvents[eventName] = creative.trackingEvents[eventName].concat(urls);
}
}
});

if (wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear') {
if (creative.type === 'linear') {
// merge video click tracking url
if (wrapperHasVideoClickTracking) {
creative.videoClickTrackingURLTemplates = creative.videoClickTrackingURLTemplates.concat(wrapper.videoClickTrackingURLTemplates);
}
});
}
} // merge video custom click url

if (wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear') {

if (wrapperHasVideoCustomClick) {
creative.videoCustomClickURLTemplates = creative.videoCustomClickURLTemplates.concat(wrapper.videoCustomClickURLTemplates);
}
});
} // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null
} // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null


if (wrapper.videoClickThroughURLTemplate) {
unwrappedAd.creatives.forEach(function (creative) {
if (creative.type === 'linear' && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) {
if (wrapper.videoClickThroughURLTemplate && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) {
creative.videoClickThroughURLTemplate = wrapper.videoClickThroughURLTemplate;
}
});
}
} // pass wrapper companion trackers to all companions


if (creative.type === 'companion' && wrapperCompanionClickTracking.length) {
(creative.variations || []).forEach(function (variation) {
variation.companionClickTrackingURLTemplates = util.joinArrayUnique(variation.companionClickTrackingURLTemplates, wrapperCompanionClickTracking);
});
}
});
}

var parserUtils = {
Expand Down
2 changes: 1 addition & 1 deletion dist/vast-client.min.js

Large diffs are not rendered by default.

0 comments on commit af0c400

Please sign in to comment.