Skip to content

Commit

Permalink
adds vast-client-js folder
Browse files Browse the repository at this point in the history
  • Loading branch information
radiantmediaplayer committed Nov 11, 2020
1 parent 1416109 commit 93406a9
Show file tree
Hide file tree
Showing 37 changed files with 4,157 additions and 0 deletions.
26 changes: 26 additions & 0 deletions vast-client-js/src/ad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export function createAd(adAttributes = {}) {
return {
id: adAttributes.id || null,
sequence: adAttributes.sequence || null,
adType: adAttributes.adType || null,
adServingId: null,
categories: [],
expires: null,
viewableImpression: {},
system: null,
title: null,
description: null,
advertiser: null,
#: null,
survey: null, // @deprecated in VAST 4.1
errorURLTemplates: [],
impressionURLTemplates: [],
creatives: [],
extensions: [],
adVerifications: [],
blockedAdCategories: [],
followAdditionalWrappers: true,
allowMultipleAds: false,
fallbackOnNoAd: null
};
}
11 changes: 11 additions & 0 deletions vast-client-js/src/ad_verification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function createAdVerification() {
return {
resource: null,
vendor: null,
browserOptional: false,
apiFramework: null,
type: null,
parameters: null,
trackingEvents: {}
};
}
7 changes: 7 additions & 0 deletions vast-client-js/src/closed_caption_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function createClosedCaptionFile(closedCaptionAttributes = {}) {
return {
type: closedCaptionAttributes.type || null,
language: closedCaptionAttributes.language || null,
fileURL: null
};
}
29 changes: 29 additions & 0 deletions vast-client-js/src/companion_ad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export function createCompanionAd(creativeAttributes = {}) {
return {
id: creativeAttributes.id || null,
adType: 'companionAd',
width: creativeAttributes.width || 0,
height: creativeAttributes.height || 0,
assetWidth: creativeAttributes.assetWidth || null,
assetHeight: creativeAttributes.assetHeight || null,
expandedWidth: creativeAttributes.expandedWidth || null,
expandedHeight: creativeAttributes.expandedHeight || null,
apiFramework: creativeAttributes.apiFramework || null,
adSlotID: creativeAttributes.adSlotID || null,
pxratio: creativeAttributes.pxratio || '1',
renderingMode: creativeAttributes.renderingMode || 'default',
staticResources: [],
htmlResources: [],
iframeResources: [],
adParameters: null,
xmlEncoded: null,
altText: null,
companionClickThroughURLTemplate: null,
companionClickTrackingURLTemplates: [],
trackingEvents: {}
};
}

export function isCompanionAd(ad) {
return ad.adType === 'companionAd';
}
10 changes: 10 additions & 0 deletions vast-client-js/src/creative/creative.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function createCreative(creativeAttributes = {}) {
return {
id: creativeAttributes.id || null,
adId: creativeAttributes.adId || null,
sequence: creativeAttributes.sequence || null,
apiFramework: creativeAttributes.apiFramework || null,
universalAdId: { value: null, idRegistry: 'unknown' },
creativeExtensions: []
};
}
16 changes: 16 additions & 0 deletions vast-client-js/src/creative/creative_companion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createCreative } from './creative';

export function createCreativeCompanion(creativeAttributes = {}) {
const { id, adId, sequence, apiFramework } = createCreative(
creativeAttributes
);
return {
id,
adId,
sequence,
apiFramework,
type: 'companion',
required: null,
variations: []
};
}
30 changes: 30 additions & 0 deletions vast-client-js/src/creative/creative_linear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createCreative } from './creative';

export function createCreativeLinear(creativeAttributes = {}) {
const { id, adId, sequence, apiFramework } = createCreative(
creativeAttributes
);
return {
id,
adId,
sequence,
apiFramework,
type: 'linear',
duration: 0,
skipDelay: null,
mediaFiles: [],
mezzanine: null,
interactiveCreativeFile: null,
closedCaptionFiles: [],
videoClickThroughURLTemplate: null,
videoClickTrackingURLTemplates: [],
videoCustomClickURLTemplates: [],
adParameters: null,
icons: [],
trackingEvents: {}
};
}

export function isCreativeLinear(ad) {
return ad.type === 'linear';
}
16 changes: 16 additions & 0 deletions vast-client-js/src/creative/creative_non_linear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createCreative } from './creative';

export function createCreativeNonLinear(creativeAttributes = {}) {
const { id, adId, sequence, apiFramework } = createCreative(
creativeAttributes
);
return {
id,
adId,
sequence,
apiFramework,
type: 'nonlinear',
variations: [],
trackingEvents: {}
};
}
16 changes: 16 additions & 0 deletions vast-client-js/src/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export function createExtension() {
return {
name: null,
value: null,
attributes: {},
children: []
};
}

export function isEmptyExtension(extension) {
return (
extension.value === null &&
Object.keys(extension.attributes).length === 0 &&
extension.children.length === 0
);
}
20 changes: 20 additions & 0 deletions vast-client-js/src/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export function createIcon() {
return {
program: null,
height: 0,
width: 0,
xPosition: 0,
yPosition: 0,
apiFramework: null,
offset: null,
duration: 0,
type: null,
staticResource: null,
htmlResource: null,
iframeResource: null,
pxratio: '1',
iconClickThroughURLTemplate: null,
iconClickTrackingURLTemplates: [],
iconViewTrackingURLTemplate: null
};
}
5 changes: 5 additions & 0 deletions vast-client-js/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { VASTParser } from './parser/vast_parser.js';
import { VASTClient } from './vast_client.js';
import { VASTTracker } from './vast_tracker.js';

export { VASTClient, VASTParser, VASTTracker };
14 changes: 14 additions & 0 deletions vast-client-js/src/interactive_creative_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { parserUtils } from './parser/parser_utils';

export function createInteractiveCreativeFile(
interactiveCreativeAttributes = {}
) {
return {
type: interactiveCreativeAttributes.type || null,
apiFramework: interactiveCreativeAttributes.apiFramework || null,
variableDuration: parserUtils.parseBoolean(
interactiveCreativeAttributes.variableDuration
),
fileURL: null
};
}
19 changes: 19 additions & 0 deletions vast-client-js/src/media_file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function createMediaFile() {
return {
id: null,
fileURL: null,
fileSize: 0,
deliveryType: 'progressive',
mimeType: null,
mediaType: null,
codec: null,
bitrate: 0,
minBitrate: 0,
maxBitrate: 0,
width: 0,
height: 0,
apiFramework: null, // @deprecated in VAST 4.1. <InteractiveCreativeFile> should be used instead.
scalable: null,
maintainAspectRatio: null
};
}
13 changes: 13 additions & 0 deletions vast-client-js/src/mezzanine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function createMezzanine() {
return {
id: null,
fileURL: null,
delivery: null,
codec: null,
type: null,
width: 0,
height: 0,
fileSize: 0,
mediaType: '2D'
};
}
25 changes: 25 additions & 0 deletions vast-client-js/src/non_linear_ad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function createNonLinearAd() {
return {
id: null,
width: 0,
height: 0,
expandedWidth: 0,
expandedHeight: 0,
scalable: true,
maintainAspectRatio: true,
minSuggestedDuration: 0,
apiFramework: 'static',
adType: 'nonLinearAd',
type: null,
staticResource: null,
htmlResource: null,
iframeResource: null,
nonlinearClickThroughURLTemplate: null,
nonlinearClickTrackingURLTemplates: [],
adParameters: null
};
}

export function isNonLinearAd(ad) {
return ad.adType === 'nonLinearAd';
}
Loading

0 comments on commit 93406a9

Please # to comment.