Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMP schema 1.6.0 integration #7

Open
wants to merge 3 commits into
base: feature/metric-events-mapping
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Changed arguments that are passed to the listeners `amp:banner:attached`, `amp:banner:state-changed`, `amp:fetch:error` and `amp:fetch:success`. Arguments are now passed as an object, so instead of `(banner) => {}` it is necessary to write `({ banner }) => {}`, respectively `({ response }) => {}` in case of events `amp:fetch:error` and `amp:fetch:success`.
- Moved `dimensions` field from the `positionData` to the content object of type `img` according to changes in AMP v2.16.0 API changes.
- Updated docs.

### Removed
Expand Down
2 changes: 1 addition & 1 deletion dist/amp-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/amp-client.standalone.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@68publishers/amp-client",
"version": "1.7.0-beta.2",
"version": "1.7.0-beta.4",
"description": "JS Client for 68publishers/amp",
"homepage": "http://www.68publishers.io/",
"main": "index.mjs",
Expand Down
4 changes: 4 additions & 0 deletions src/banner/managed/banner-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class BannerData {
this.#contents = new Contents(dimensionsProvider, breakpointType);

for (let content of this.#data.contents) {
if ('img' === content.type && !('dimensions' in content)) { // BC compatibility
content.dimensions = { width: null, height: null };
}

this.#contents.addContent(content['breakpoint'], content);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/banner/managed/managed-banner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export class ManagedBanner extends Banner {
rotationSeconds: responseData['rotation_seconds'],
displayType: responseData['display_type'],
breakpointType: responseData['breakpoint_type'],
dimensions: responseData['dimensions'] || { width: null, height: null },
});

if ('options' in responseData) {
Expand Down
12 changes: 1 addition & 11 deletions src/banner/position-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ export class PositionData {
* @param {int} rotationSeconds
* @param {string|null} displayType
* @param {string|null} breakpointType
* @param {{width: int|null, height: int|null}} dimensions
*/
constructor({ id, code, name, rotationSeconds, displayType, breakpointType, dimensions }) {
constructor({ id, code, name, rotationSeconds, displayType, breakpointType }) {
this.id = id;
this.code = code;
this.name = name;
this.rotationSeconds = rotationSeconds;
this.displayType = displayType;
this.breakpointType = breakpointType;
this.dimensions = {
width: dimensions.width || null,
height: dimensions.height || null,
}
}

static createInitial(code) {
Expand All @@ -29,10 +24,6 @@ export class PositionData {
rotationSeconds: 0,
displayType: null,
breakpointType: null,
dimensions: {
width: null,
height: null,
},
});
}

Expand All @@ -56,7 +47,6 @@ export class PositionData {
rotationSeconds: this.rotationSeconds,
displayType: this.displayType,
breakpointType: this.breakpointType,
dimensions: this.dimensions,
}
}
}
4 changes: 2 additions & 2 deletions src/template/multiple.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default `
src="<%= b.content.src %>"
sizes="<%- b.content.sizes %>"
alt="<%- b.content.alt %>"
<% if(null !== banner.positionData.dimensions.width) { %>width="<%- banner.positionData.dimensions.width %>"<% } %>
<% if(null !== banner.positionData.dimensions.height) { %>height="<%- banner.positionData.dimensions.height %>"<% } %>
<% if(null !== b.content.dimensions.width) { %>width="<%- b.content.dimensions.width %>"<% } %>
<% if(null !== b.content.dimensions.height) { %>height="<%- b.content.dimensions.height %>"<% } %>
<% if('' !== b.content.title) { %>title="<%- b.content.title %>"<% } %>
<% var loading; if(loading = banner.options.evaluate('loading', index)) { %>loading="<%- loading %>"<% } %>
<% var fetchPriority; if(fetchPriority = banner.options.evaluate('fetchpriority', index)) { %>fetchpriority="<%- fetchPriority %>"<% } %>>
Expand Down
4 changes: 2 additions & 2 deletions src/template/random.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default `
src="<%= data.content.src %>"
sizes="<%- data.content.sizes %>"
alt="<%- data.content.alt %>"
<% if(null !== banner.positionData.dimensions.width) { %>width="<%- banner.positionData.dimensions.width %>"<% } %>
<% if(null !== banner.positionData.dimensions.height) { %>height="<%- banner.positionData.dimensions.height %>"<% } %>
<% if(null !== data.content.dimensions.width) { %>width="<%- data.content.dimensions.width %>"<% } %>
<% if(null !== data.content.dimensions.height) { %>height="<%- data.content.dimensions.height %>"<% } %>
<% if('' !== data.content.title) { %>title="<%- data.content.title %>"<% } %>
<% var loading; if(loading = banner.options.evaluate('loading', 0)) { %>loading="<%- loading %>"<% } %>
<% var fetchPriority; if(fetchPriority = banner.options.evaluate('fetchpriority', 0)) { %>fetchpriority="<%- fetchPriority %>"<% } %>>
Expand Down
4 changes: 2 additions & 2 deletions src/template/single.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default `
src="<%= data.content.src %>"
sizes="<%- data.content.sizes %>"
alt="<%- data.content.alt %>"
<% if(null !== banner.positionData.dimensions.width) { %>width="<%- banner.positionData.dimensions.width %>"<% } %>
<% if(null !== banner.positionData.dimensions.height) { %>height="<%- banner.positionData.dimensions.height %>"<% } %>
<% if(null !== data.content.dimensions.width) { %>width="<%- data.content.dimensions.width %>"<% } %>
<% if(null !== data.content.dimensions.height) { %>height="<%- data.content.dimensions.height %>"<% } %>
<% if('' !== data.content.title) { %>title="<%- data.content.title %>"<% } %>
<% var loading; if(loading = banner.options.evaluate('loading', 0)) { %>loading="<%- loading %>"<% } %>
<% var fetchPriority; if(fetchPriority = banner.options.evaluate('fetchpriority', 0)) { %>fetchpriority="<%- fetchPriority %>"<% } %>>
Expand Down