Socket
Socket
Sign inDemoInstall

@ampproject/toolbox-optimizer

Package Overview
Dependencies
Maintainers
16
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ampproject/toolbox-optimizer - npm Package Compare versions

Comparing version 2.8.4 to 3.0.0-canary.2

lib/transformers/AmpStoryCssTransformer.js

21

index.js

@@ -22,14 +22,27 @@ /**

TRANSFORMATIONS_PAIRED_AMP,
TRANSFORMATIONS_MINIMAL,
DEFAULT_CONFIG,
CONFIG_BUILD,
CONFIG_RUNTIME,
} = require('./lib/DomTransformer.js');
const NodeUtils = require('./lib/NodeUtils.js');
const DEFAULT_CONFIG = CONFIG_BUILD;
module.exports = {
create: (config = DEFAULT_CONFIG) => new DomTransformer(config),
/*
* @deprecated
*/
create: (config = CONFIG_BUILD) => new DomTransformer(config),
createFullOptimizer: (config = {}) => new DomTransformer(Object.assign({}, CONFIG_BUILD, config)),
createFastOptimizer: (config = {}) =>
new DomTransformer(Object.assign({}, CONFIG_RUNTIME, config)),
TRANSFORMATIONS_AMP_FIRST,
/* @private */ TRANSFORMATIONS_MINIMAL,
TRANSFORMATIONS_PAIRED_AMP,
CONFIG_BUILD,
CONFIG_RUNTIME,
/*
* @deprecated
*/
DEFAULT_CONFIG,
NodeUtils,
};

@@ -16,6 +16,8 @@ /**

*/
'mode strict';
'use strict';
const {hasAttribute} = require('./NodeUtils');
const AMP_STORY_DVH_POLYFILL_ATTR = 'amp-story-dvh-polyfill';
module.exports = {

@@ -27,2 +29,3 @@ AMP_TAGS: ['amp', '⚡', '⚡4ads', 'amp4ads', '⚡4email', 'amp4email'],

AMP_RUNTIME_CSS_PATH: '/v0.css',
AMP_STORY_DVH_POLYFILL_ATTR,
appendRuntimeVersion: (prefix, version) => prefix + '/rtv/' + version,

@@ -53,2 +56,5 @@ isTemplate: (node) => {

},
isAmpStoryDvhPolyfillScript: (node) => {
return node.tagName === 'script' && hasAttribute(node, AMP_STORY_DVH_POLYFILL_ATTR);
},
};

@@ -55,0 +61,0 @@

3

lib/cache.js

@@ -19,3 +19,2 @@ /**

const {FileSystemCache} = require('@ampproject/toolbox-core');
const path = require('path');
const log = require('./log');

@@ -26,5 +25,5 @@

log,
baseDir: path.join(__dirname, '..', '.cache'),
name: 'amp-optimizer',
});
module.exports = cache;

@@ -20,6 +20,6 @@ /**

const log = require('./log');
let fetch = require('cross-fetch');
let fetch = require('node-fetch');
const RuntimeVersion = require('@ampproject/toolbox-runtime-version/lib/RuntimeVersion');
const fetchRuntimeParameters = require('./fetchRuntimeParameters');
const cache = require('./cache');
const cache = require('./cache.js');

@@ -44,2 +44,6 @@ /**

'OptimizeAmpBind',
// Applies amp-story related optimizations such as appending a link[rel=stylesheet]
// to the amp-story css, server side rendering attributes, and adding css polyfills
// and fixes.
'AmpStoryCssTransformer',
// Applies server-side-rendering optimizations

@@ -114,31 +118,3 @@ 'ServerSideRendering',

/**
* AMP Optimizer Configuration only applying the minimal set of AMP transformations ensuring maximum performance.
*/
const TRANSFORMATIONS_MINIMAL = [
// Applies image optimizations, must run before PreloadHeroImage
'OptimizeImages',
// Detect hero image and preload link rel=preload, needs to run after OptimizeImages
'OptimizeHeroImages',
// Inject a querySelectorAll query-able i-amphtml-binding attribute on elements with bindings.
// This needs to run after AutoExtensionImporter.
'OptimizeAmpBind',
// Applies server-side-rendering optimizations
'ServerSideRendering',
// Removes the boilerplate
// needs to run after ServerSideRendering
'AmpBoilerplateTransformer',
// Adds amp-onerror to disable boilerplate early
// needs to run after ServerSideRendering
'AmpBoilerplateErrorHandler',
'RewriteAmpUrls',
'GoogleFontsPreconnect',
'PruneDuplicateResourceHints',
// Optimizes script import order
// needs to run after ServerSideRendering
'ReorderHeadTransformer',
'AddTransformedFlag',
];
const DEFAULT_CONFIG = {
const CONFIG_DEFAULT = {
cache,

@@ -156,4 +132,38 @@ fetch,

verbose: false,
// keep these enabled for backward compatibility
autoAddMandatoryTags: true,
autoExtensionImport: true,
esmModulesEnabled: true,
markdown: true,
minify: true,
optimizeAmpBind: true,
optimizeAmpStory: false,
optimizeHeroImages: true,
separateKeyframes: true,
};
const CONFIG_BUILD = Object.assign({}, CONFIG_DEFAULT, {
autoAddMandatoryTags: true,
autoExtensionImport: true,
esmModulesEnabled: true,
markdown: true,
minify: true,
optimizeAmpBind: true,
optimizeAmpStory: false,
optimizeHeroImages: true,
separateKeyframes: true,
});
const CONFIG_RUNTIME = Object.assign({}, CONFIG_DEFAULT, {
autoAddMandatoryTags: false,
autoExtensionImport: false,
esmModulesEnabled: true,
markdown: false,
minify: false,
optimizeAmpBind: true,
optimizeAmpStory: false,
optimizeHeroImages: true,
separateKeyframes: false,
});
/**

@@ -168,3 +178,3 @@ * Applies a set of transformations to a DOM tree.

*/
constructor(config = DEFAULT_CONFIG) {
constructor(config = CONFIG_DEFAULT) {
this.setConfig(config);

@@ -225,3 +235,3 @@ }

setConfig(config) {
this.config = Object.assign({}, DEFAULT_CONFIG, config);
this.config = Object.assign({}, CONFIG_DEFAULT, config);
if (!this.config.runtimeVersion) {

@@ -254,6 +264,6 @@ // Re-use custom fetch implementation for runtime version provider

DomTransformer,
DEFAULT_CONFIG,
CONFIG_BUILD,
CONFIG_RUNTIME,
TRANSFORMATIONS_AMP_FIRST,
TRANSFORMATIONS_PAIRED_AMP,
TRANSFORMATIONS_MINIMAL,
};

@@ -1,1 +0,1 @@

[{"name":"amp-3d-gltf","version":"0.1","latestVersion":"0.1"},{"name":"amp-3q-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-access","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-access-laterpay","version":["0.1","0.2"],"latestVersion":"0.2","options":{"hasCss":true}},{"name":"amp-access-poool","version":"0.1","latestVersion":"0.1"},{"name":"amp-access-scroll","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-accordion","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-accordion","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-action-macro","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-ad-custom","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-exit","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-adsense-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-adzerk-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-doubleclick-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-fake-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-nws-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-valueimpression-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-addthis","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-analytics","version":"0.1","latestVersion":"0.1"},{"name":"amp-anim","version":"0.1","latestVersion":"0.1"},{"name":"amp-animation","version":"0.1","latestVersion":"0.1"},{"name":"amp-animation-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-apester-media","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-app-banner","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-audio","version":"0.1","latestVersion":"0.1"},{"name":"amp-auto-ads","version":"0.1","latestVersion":"0.1"},{"name":"amp-auto-lightbox","version":"0.1","latestVersion":"0.1"},{"name":"amp-autocomplete","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-base-carousel","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-base-carousel","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-beopinion","version":"0.1","latestVersion":"0.1"},{"name":"amp-bind","version":"0.1","latestVersion":"0.1"},{"name":"amp-bodymovin-animation","version":"0.1","latestVersion":"0.1"},{"name":"amp-brid-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-brightcove","version":"0.1","latestVersion":"0.1"},{"name":"amp-byside-content","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-cache-url","version":"0.1","latestVersion":"0.1"},{"name":"amp-call-tracking","version":"0.1","latestVersion":"0.1"},{"name":"amp-carousel","version":["0.1","0.2"],"latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-connatix-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-consent","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-crypto-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-dailymotion","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-countdown","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-countdown","version":"1.0","latestVersion":"0.1","options":{"npm":true}},{"name":"amp-date-display","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-display","version":"1.0","latestVersion":"0.1","options":{"npm":true}},{"name":"amp-date-picker","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-delight-player","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-dynamic-css-classes","version":"0.1","latestVersion":"0.1"},{"name":"amp-embedly-card","version":"0.1","latestVersion":"0.1"},{"name":"amp-experiment","version":["0.1","1.0"],"latestVersion":"0.1"},{"name":"amp-facebook","version":"0.1","latestVersion":"0.1"},{"name":"amp-facebook-comments","version":["0.1","1.0"],"latestVersion":"0.1"},{"name":"amp-facebook-like","version":"0.1","latestVersion":"0.1"},{"name":"amp-facebook-page","version":"0.1","latestVersion":"0.1"},{"name":"amp-fit-text","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-fit-text","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-font","version":"0.1","latestVersion":"0.1"},{"name":"amp-form","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-fx-collection","version":"0.1","latestVersion":"0.1"},{"name":"amp-fx-flying-carpet","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-geo","version":"0.1","latestVersion":"0.1"},{"name":"amp-gfycat","version":"0.1","latestVersion":"0.1"},{"name":"amp-gist","version":"0.1","latestVersion":"0.1"},{"name":"amp-google-assistant-assistjs","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-google-document-embed","version":"0.1","latestVersion":"0.1"},{"name":"amp-gwd-animation","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-hulu","version":"0.1","latestVersion":"0.1"},{"name":"amp-iframe","version":"0.1","latestVersion":"0.1"},{"name":"amp-ima-video","version":"0.1","latestVersion":"0.1"},{"name":"amp-image-lightbox","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-image-slider","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-image-viewer","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-imgur","version":"0.1","latestVersion":"0.1"},{"name":"amp-inline-gallery","version":"0.1","latestVersion":"0.1","options":{"hasCss":true,"cssBinaries":["amp-inline-gallery","amp-inline-gallery-captions","amp-inline-gallery-pagination","amp-inline-gallery-slide","amp-inline-gallery-thumbnails"]}},{"name":"amp-inline-gallery","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"cssBinaries":["amp-inline-gallery-pagination"],"npm":true}},{"name":"amp-inputmask","version":"0.1","latestVersion":"0.1"},{"name":"amp-instagram","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-instagram","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-install-serviceworker","version":"0.1","latestVersion":"0.1"},{"name":"amp-intersection-observer-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-izlesene","version":"0.1","latestVersion":"0.1"},{"name":"amp-jwplayer","version":"0.1","latestVersion":"0.1"},{"name":"amp-kaltura-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-lightbox","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-lightbox","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-lightbox-gallery","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-link-rewriter","version":"0.1","latestVersion":"0.1"},{"name":"amp-list","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-live-list","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-loader","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-mathml","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-mega-menu","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-megaphone","version":"0.1","latestVersion":"0.1"},{"name":"amp-minute-media-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-mowplayer","version":"0.1","latestVersion":"0.1"},{"name":"amp-mraid","version":"0.1","latestVersion":"0.1"},{"name":"amp-mustache","version":["0.1","0.2"],"latestVersion":"0.2"},{"name":"amp-nested-menu","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-next-page","version":["0.1","1.0"],"latestVersion":"1.0","options":{"hasCss":true}},{"name":"amp-nexxtv-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-o2-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-onetap-google","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-ooyala-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-orientation-observer","version":"0.1","latestVersion":"0.1"},{"name":"amp-pan-zoom","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-pinterest","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-playbuzz","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-position-observer","version":"0.1","latestVersion":"0.1"},{"name":"amp-powr-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-reach-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-recaptcha-input","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-redbull-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-reddit","version":"0.1","latestVersion":"0.1"},{"name":"amp-render","version":"1.0","latestVersion":"1.0"},{"name":"amp-resize-observer-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-riddle-quiz","version":"0.1","latestVersion":"0.1"},{"name":"amp-script","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-selector","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-selector","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-shadow-dom-polyfill","version":"0.1","latestVersion":"0.1","options":{"noWrapper":true}},{"name":"amp-sidebar","version":["0.1","0.2","1.0"],"latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-skimlinks","version":"0.1","latestVersion":"0.1"},{"// 1":"`amp-slides` is deprecated","// 2":"Please use `<amp-carousel type=slides>` instead.","name":"amp-slides","version":"0.1","latestVersion":"0.1"},{"name":"amp-smartlinks","version":"0.1","latestVersion":"0.1"},{"name":"amp-social-share","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-social-share","version":"1.0","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-soundcloud","version":"0.1","latestVersion":"0.1"},{"name":"amp-springboard-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-standalone","version":"0.1","latestVersion":"0.1"},{"name":"amp-sticky-ad","version":"1.0","latestVersion":"1.0","options":{"hasCss":true}},{"name":"amp-story","version":"1.0","latestVersion":"1.0","options":{"hasCss":true,"cssBinaries":["amp-story-consent","amp-story-draggable-drawer-header","amp-story-hint","amp-story-info-dialog","amp-story-open-page-attachment","amp-story-share","amp-story-share-menu","amp-story-system-layer","amp-story-tooltip","amp-story-unsupported-browser-layer","amp-story-viewport-warning-layer"]}},{"name":"amp-story-360","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-story-auto-ads","version":"0.1","latestVersion":"0.1","options":{"hasCss":true,"cssBinaries":["amp-story-auto-ads-ad-badge","amp-story-auto-ads-attribution","amp-story-auto-ads-cta-button","amp-story-auto-ads-inabox","amp-story-auto-ads-progress-bar","amp-story-auto-ads-shared"]}},{"name":"amp-story-auto-analytics","version":"0.1","latestVersion":"0.1"},{"name":"amp-story-dev-tools","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-story-education","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-story-interactive","version":"0.1","latestVersion":"0.1","options":{"hasCss":true,"cssBinaries":["amp-story-interactive-binary-poll","amp-story-interactive-poll","amp-story-interactive-quiz","amp-story-interactive-results"]}},{"name":"amp-story-panning-media","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-story-player","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-stream-gallery","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-stream-gallery","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}},{"name":"amp-subscriptions","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-subscriptions-google","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-tiktok","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-timeago","version":"0.1","latestVersion":"0.1"},{"name":"amp-timeago","version":"1.0","latestVersion":"0.1","options":{"npm":true}},{"name":"amp-truncate-text","version":"0.1","latestVersion":"0.1","options":{"hasCss":true,"cssBinaries":["amp-truncate-text","amp-truncate-text-shadow"]}},{"name":"amp-twitter","version":"0.1","latestVersion":"0.1"},{"name":"amp-twitter","version":"1.0","latestVersion":"0.1","options":{"npm":true}},{"name":"amp-user-notification","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-video","version":"0.1","latestVersion":"0.1"},{"name":"amp-video","version":"1.0","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-video-docking","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-video-iframe","version":"0.1","latestVersion":"0.1"},{"name":"amp-video-iframe","version":"1.0","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-viewer-integration","version":"0.1","latestVersion":"0.1","options":{"// 1":"The viewer integration code needs to run asap, so that viewers","// 2":"can influence document state asap. Otherwise the document may ","// 3":"take a long time to learn that it should start process other","// 4":"extensions faster.","loadPriority":"high"}},{"name":"amp-vimeo","version":"0.1","latestVersion":"0.1"},{"name":"amp-vimeo","version":"1.0","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-vine","version":"0.1","latestVersion":"0.1"},{"name":"amp-viqeo-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-viz-vega","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-vk","version":"0.1","latestVersion":"0.1"},{"name":"amp-web-push","version":"0.1","latestVersion":"0.1","options":{"hasCss":true}},{"name":"amp-wistia-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-yotpo","version":"0.1","latestVersion":"0.1"},{"name":"amp-youtube","version":"0.1","latestVersion":"0.1"},{"name":"amp-youtube","version":"1.0","latestVersion":"0.1","options":{"hasCss":true,"npm":true}}]
[{"name":"amp-3d-gltf","version":"0.1","latestVersion":"0.1"},{"name":"amp-3q-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-access","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-access-fewcents","version":"0.1","options":{"hasCss":true}},{"name":"amp-access-laterpay","version":["0.1","0.2"],"options":{"hasCss":true},"latestVersion":"0.2"},{"name":"amp-access-poool","version":"0.1","latestVersion":"0.1"},{"name":"amp-access-scroll","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-accordion","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-accordion","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-action-macro","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-ad-custom","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-exit","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-adsense-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-adzerk-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-dianomi-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-doubleclick-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-fake-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-nws-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-ad-network-smartadserver-impl","version":"0.1"},{"name":"amp-ad-network-valueimpression-impl","version":"0.1","latestVersion":"0.1"},{"name":"amp-addthis","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-analytics","version":"0.1","latestVersion":"0.1"},{"name":"amp-anim","version":"0.1","latestVersion":"0.1"},{"name":"amp-animation","version":"0.1","latestVersion":"0.1"},{"name":"amp-animation-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-apester-media","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-app-banner","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-audio","version":"0.1","latestVersion":"0.1"},{"name":"amp-auto-ads","version":"0.1","latestVersion":"0.1"},{"name":"amp-auto-lightbox","version":"0.1","latestVersion":"0.1"},{"name":"amp-autocomplete","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-base-carousel","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-base-carousel","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-beopinion","version":"0.1","latestVersion":"0.1"},{"name":"amp-bind","version":"0.1","latestVersion":"0.1"},{"name":"amp-bodymovin-animation","version":"0.1","latestVersion":"0.1"},{"name":"amp-brid-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-brightcove","version":"0.1","latestVersion":"0.1"},{"name":"amp-brightcove","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-byside-content","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-cache-url","version":"0.1","latestVersion":"0.1"},{"name":"amp-call-tracking","version":"0.1","latestVersion":"0.1"},{"name":"amp-carousel","version":["0.1","0.2"],"options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-connatix-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-consent","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-crypto-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-dailymotion","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-countdown","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-countdown","version":"1.0","options":{"npm":true,"bento":true,"hasCss":true},"latestVersion":"0.1"},{"name":"amp-date-display","version":"0.1","latestVersion":"0.1"},{"name":"amp-date-display","version":"1.0","options":{"npm":true,"bento":true,"hasCss":true},"latestVersion":"0.1"},{"name":"amp-date-picker","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-delight-player","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-dynamic-css-classes","version":"0.1","latestVersion":"0.1"},{"name":"amp-embedly-card","version":"0.1","latestVersion":"0.1"},{"name":"amp-embedly-card","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-experiment","version":["0.1","1.0"],"latestVersion":"0.1"},{"name":"amp-facebook","version":"0.1","latestVersion":"0.1"},{"name":"amp-facebook","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-facebook-comments","version":"0.1","latestVersion":"0.1"},{"name":"amp-facebook-like","version":"0.1","latestVersion":"0.1"},{"name":"amp-facebook-page","version":"0.1","latestVersion":"0.1"},{"name":"amp-fit-text","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-fit-text","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-font","version":"0.1","latestVersion":"0.1"},{"name":"amp-form","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-fx-collection","version":"0.1","latestVersion":"0.1"},{"name":"amp-fx-flying-carpet","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-geo","version":"0.1","latestVersion":"0.1"},{"name":"amp-gfycat","version":"0.1","latestVersion":"0.1"},{"name":"amp-gist","version":"0.1","latestVersion":"0.1"},{"name":"amp-google-document-embed","version":"0.1","latestVersion":"0.1"},{"name":"amp-gwd-animation","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-hulu","version":"0.1","latestVersion":"0.1"},{"name":"amp-iframe","version":"0.1","latestVersion":"0.1"},{"name":"amp-iframe","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-iframely","version":"0.1","latestVersion":"0.1"},{"name":"amp-ima-video","version":"0.1","latestVersion":"0.1"},{"name":"amp-image-lightbox","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-image-slider","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-image-viewer","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-imgur","version":"0.1","latestVersion":"0.1"},{"name":"amp-inline-gallery","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-inline-gallery","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-inputmask","version":"0.1","latestVersion":"0.1"},{"name":"amp-instagram","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-instagram","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-install-serviceworker","version":"0.1","latestVersion":"0.1"},{"name":"amp-intersection-observer-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-izlesene","version":"0.1","latestVersion":"0.1"},{"name":"amp-jwplayer","version":"0.1","latestVersion":"0.1"},{"name":"amp-jwplayer","version":"1.0","options":{"hasCss":true,"bento":true,"npm":true},"latestVersion":"0.1"},{"name":"amp-kaltura-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-lightbox","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-lightbox","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-lightbox-gallery","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-lightbox-gallery","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-link-rewriter","version":"0.1","latestVersion":"0.1"},{"name":"amp-list","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-live-list","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-loader","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-mathml","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-mathml","version":"1.0","options":{"hasCss":true,"bento":true,"npm":true},"latestVersion":"0.1"},{"name":"amp-mega-menu","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-megaphone","version":"0.1","latestVersion":"0.1"},{"name":"amp-minute-media-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-mowplayer","version":"0.1","latestVersion":"0.1"},{"name":"amp-mraid","version":"0.1","latestVersion":"0.1"},{"name":"amp-mustache","version":["0.1","0.2"],"latestVersion":"0.2"},{"name":"amp-nested-menu","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-next-page","version":["0.1","1.0"],"options":{"hasCss":true},"latestVersion":"1.0"},{"name":"amp-nexxtv-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-o2-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-onetap-google","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-ooyala-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-orientation-observer","version":"0.1","latestVersion":"0.1"},{"name":"amp-pan-zoom","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-pinterest","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-playbuzz","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-position-observer","version":"0.1","latestVersion":"0.1"},{"name":"amp-powr-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-reach-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-recaptcha-input","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-redbull-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-reddit","version":"0.1","latestVersion":"0.1"},{"name":"amp-render","version":"1.0","latestVersion":"1.0"},{"name":"amp-resize-observer-polyfill","version":"0.1","latestVersion":"0.1"},{"name":"amp-riddle-quiz","version":"0.1","latestVersion":"0.1"},{"name":"amp-script","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-selector","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-selector","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-shadow-dom-polyfill","version":"0.1","options":{"wrapper":"none"},"latestVersion":"0.1"},{"name":"amp-sidebar","version":["0.1","0.2"],"options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-sidebar","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-skimlinks","version":"0.1","latestVersion":"0.1"},{"// 1":"`amp-slides` is deprecated","// 2":"Please use `<amp-carousel type=slides>` instead.","name":"amp-slides","version":"0.1","latestVersion":"0.1"},{"name":"amp-smartlinks","version":"0.1","latestVersion":"0.1"},{"name":"amp-social-share","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-social-share","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-soundcloud","version":"0.1","latestVersion":"0.1"},{"name":"amp-soundcloud","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-springboard-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-standalone","version":"0.1","latestVersion":"0.1"},{"name":"amp-sticky-ad","version":"1.0","options":{"hasCss":true},"latestVersion":"1.0"},{"name":"amp-story","version":"1.0","options":{"hasCss":true},"latestVersion":"1.0"},{"name":"amp-story-360","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-auto-ads","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-auto-analytics","version":"0.1","latestVersion":"0.1"},{"name":"amp-story-captions","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-dev-tools","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-education","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-interactive","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-page-attachment","version":"0.1","options":{"hasCss":true}},{"name":"amp-story-panning-media","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-player","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-story-share-menu","version":"0.1","options":{"hasCss":true}},{"name":"amp-story-shopping","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-stream-gallery","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-stream-gallery","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-subscriptions","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-subscriptions-google","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-tiktok","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-timeago","version":"0.1","latestVersion":"0.1"},{"name":"amp-timeago","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-truncate-text","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-twitter","version":"0.1","latestVersion":"0.1"},{"name":"amp-twitter","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-user-notification","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-video","version":"0.1","latestVersion":"0.1"},{"name":"amp-video","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-video-docking","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-video-iframe","version":"0.1","latestVersion":"0.1"},{"name":"amp-video-iframe","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-viewer-integration","version":"0.1","options":{"// 1":"The viewer integration code needs to run asap, so that viewers","// 2":"can influence document state asap. Otherwise the document may ","// 3":"take a long time to learn that it should start process other","// 4":"extensions faster.","loadPriority":"high"},"latestVersion":"0.1"},{"name":"amp-vimeo","version":"0.1","latestVersion":"0.1"},{"name":"amp-vimeo","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"},{"name":"amp-vine","version":"0.1","latestVersion":"0.1"},{"name":"amp-viqeo-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-vk","version":"0.1","latestVersion":"0.1"},{"name":"amp-web-push","version":"0.1","options":{"hasCss":true},"latestVersion":"0.1"},{"name":"amp-wistia-player","version":"0.1","latestVersion":"0.1"},{"name":"amp-wordpress-embed","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"1.0"},{"name":"amp-yotpo","version":"0.1","latestVersion":"0.1"},{"name":"amp-youtube","version":"0.1","latestVersion":"0.1"},{"name":"amp-youtube","version":"1.0","options":{"hasCss":true,"npm":true,"bento":true},"latestVersion":"0.1"}]

@@ -16,3 +16,3 @@ /**

*/
'mode strict';
'use strict';

@@ -19,0 +19,0 @@ module.exports = {

@@ -16,3 +16,3 @@ /**

*/
'mode strict';
'use strict';

@@ -23,2 +23,11 @@ const URL_COMPONENT_VERSIONS =

const {MaxAge} = require('@ampproject/toolbox-core');
let fallbackRuntime;
try {
fallbackRuntime = require('./runtimeData.json');
} catch (e) {
// `npm run build` has not been executed
fallbackRuntime = {ampRuntimeStyles: '', ampRuntimeVersion: ''};
}
const {

@@ -65,2 +74,6 @@ AMP_CACHE_HOST,

async function initValidatorRules(runtimeParameters, customRuntimeParameters, config) {
if (!config.autoExtensionImport) {
// Validation rules are large, don't import if not needed
return;
}
try {

@@ -72,3 +85,4 @@ runtimeParameters.validatorRules =

} catch (error) {
config.log.error('Could not fetch validator rules', error);
config.log.error('Could not fetch validator rules');
config.log.verbose(error);
}

@@ -86,3 +100,2 @@ try {

}
async function fetchComponentVersionsFromCache_(config, runtimeParameters) {

@@ -157,3 +170,6 @@ const cacheKey = `component-versions-${runtimeParameters.ampRuntimeVersion}`;

} catch (error) {
config.log.error('Could not fetch AMP runtime CSS', error);
config.log.warn('Could not fetch AMP runtime CSS, falling back to built-in runtime styles.');
config.log.verbose(error);
// fallback to build-in runtime
runtimeParameters.ampRuntimeStyles = fallbackRuntime.ampRuntimeStyles;
}

@@ -178,8 +194,4 @@ }

}
try {
runtimeParameters.ampRuntimeVersion =
ampRuntimeVersion || (await fetchAmpRuntimeVersion_({config, ampUrlPrefix, lts}));
} catch (error) {
config.log.error('Could not fetch latest AMP runtime version', error);
}
runtimeParameters.ampRuntimeVersion =
ampRuntimeVersion || (await fetchAmpRuntimeVersion_({config, ampUrlPrefix, lts}));
}

@@ -212,3 +224,3 @@

};
if (!ampRuntimeData.version && ampUrlPrefix !== AMP_CACHE_HOST) {
if (!ampRuntimeData.version && ampUrlPrefix && ampUrlPrefix !== AMP_CACHE_HOST) {
config.log.error(

@@ -221,2 +233,8 @@ `Could not download runtime version from ${ampUrlPrefix}. Falling back to ${AMP_CACHE_HOST}`

);
} else if (!ampRuntimeData.version) {
config.log.warn(
'Could not fetch latest AMP runtime version, falling back to bundled runtime styles.'
);
// Fallback to built-in runtime version
ampRuntimeData.version = fallbackRuntime.ampRuntimeVersion;
} else if (ampRuntimeData.version && versionKey) {

@@ -246,3 +264,3 @@ writeToCache_(config, versionKey, ampRuntimeData);

if (!styles) {
config.log.error(`Could not download ${runtimeCssUrl}. Falling back to latest v0.css.`);
config.log.warn(`Could not download ${runtimeCssUrl}. Falling back to bundled v0.css.`);
if (ampUrlPrefix || ampRuntimeVersion) {

@@ -249,0 +267,0 @@ // Try to download latest from cdn.ampproject.org instead

@@ -1,1 +0,1 @@

{"ampRuntimeStyles":"html{overflow-x:hidden!important}html.i-amphtml-fie{height:100%!important;width:100%!important}html:not([amp4ads]),html:not([amp4ads]) body{height:auto!important}html:not([amp4ads]) body{margin:0!important}body{-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%}html.i-amphtml-singledoc.i-amphtml-embedded{-ms-touch-action:pan-y pinch-zoom;touch-action:pan-y pinch-zoom}html.i-amphtml-fie>body,html.i-amphtml-singledoc>body{overflow:visible!important}html.i-amphtml-fie:not(.i-amphtml-inabox)>body,html.i-amphtml-singledoc:not(.i-amphtml-inabox)>body{position:relative!important}html.i-amphtml-ios-embed-legacy>body{overflow-x:hidden!important;overflow-y:auto!important;position:absolute!important}html.i-amphtml-ios-embed{overflow-y:auto!important;position:static}#i-amphtml-wrapper{overflow-x:hidden!important;overflow-y:auto!important;position:absolute!important;top:0!important;left:0!important;right:0!important;bottom:0!important;margin:0!important;display:block!important}html.i-amphtml-ios-embed.i-amphtml-ios-overscroll,html.i-amphtml-ios-embed.i-amphtml-ios-overscroll>#i-amphtml-wrapper{-webkit-overflow-scrolling:touch!important}#i-amphtml-wrapper>body{position:relative!important;border-top:1px solid transparent!important}#i-amphtml-wrapper+body{visibility:visible}#i-amphtml-wrapper+body .i-amphtml-lightbox-element,#i-amphtml-wrapper+body[i-amphtml-lightbox]{visibility:hidden}#i-amphtml-wrapper+body[i-amphtml-lightbox] .i-amphtml-lightbox-element{visibility:visible}#i-amphtml-wrapper.i-amphtml-scroll-disabled,.i-amphtml-scroll-disabled{overflow-x:hidden!important;overflow-y:hidden!important}amp-instagram{padding:54px 0px 0px!important;background-color:#fff}amp-iframe iframe{box-sizing:border-box!important}[amp-access][amp-access-hide]{display:none}[subscriptions-dialog],body:not(.i-amphtml-subs-ready) [subscriptions-action],body:not(.i-amphtml-subs-ready) [subscriptions-section]{display:none!important}amp-experiment,amp-live-list>[update]{display:none}amp-list[resizable-children]>.i-amphtml-loading-container.amp-hidden{display:none!important}amp-list [fetch-error],amp-list[load-more] [load-more-button],amp-list[load-more] [load-more-end],amp-list[load-more] [load-more-failed],amp-list[load-more] [load-more-loading]{display:none}amp-list[diffable] div[role=list]{display:block}amp-story-page,amp-story[standalone]{min-height:1px!important;display:block!important;height:100%!important;margin:0!important;padding:0!important;overflow:hidden!important;width:100%!important}amp-story[standalone]{background-color:#202125!important;position:relative!important}amp-story-page{background-color:#757575}amp-story .amp-active>div,amp-story .i-amphtml-loader-background{display:none!important}amp-story-page:not(:first-of-type):not([distance]):not([active]){transform:translateY(1000vh)!important}amp-autocomplete{position:relative!important;display:inline-block!important}amp-autocomplete>input,amp-autocomplete>textarea{padding:0.5rem;border:1px solid rgba(0,0,0,0.33)}.i-amphtml-autocomplete-results,amp-autocomplete>input,amp-autocomplete>textarea{font-size:1rem;line-height:1.5rem}[amp-fx^=fly-in]{visibility:hidden}amp-script[nodom]{position:fixed!important;top:0!important;width:1px!important;height:1px!important;overflow:hidden!important;visibility:hidden}\n/*# sourceURL=/css/ampdoc.css*/[hidden]{display:none!important}.i-amphtml-element{display:inline-block}.i-amphtml-blurry-placeholder{transition:opacity 0.3s cubic-bezier(0.0,0.0,0.2,1)!important;pointer-events:none}[layout=nodisplay]:not(.i-amphtml-element){display:none!important}.i-amphtml-layout-fixed,[layout=fixed][width][height]:not(.i-amphtml-layout-fixed){display:inline-block;position:relative}.i-amphtml-layout-responsive,[layout=responsive][width][height]:not(.i-amphtml-layout-responsive),[width][height][heights]:not([layout]):not(.i-amphtml-layout-responsive),[width][height][sizes]:not([layout]):not(.i-amphtml-layout-responsive){display:block;position:relative}.i-amphtml-layout-intrinsic,[layout=intrinsic][width][height]:not(.i-amphtml-layout-intrinsic){display:inline-block;position:relative;max-width:100%}.i-amphtml-layout-intrinsic .i-amphtml-sizer{max-width:100%}.i-amphtml-intrinsic-sizer{max-width:100%;display:block!important}.i-amphtml-layout-container,.i-amphtml-layout-fixed-height,[layout=container],[layout=fixed-height][height]:not(.i-amphtml-layout-fixed-height){display:block;position:relative}.i-amphtml-layout-fill,.i-amphtml-layout-fill.i-amphtml-notbuilt,[layout=fill]:not(.i-amphtml-layout-fill),body noscript>*{display:block;overflow:hidden!important;position:absolute;top:0;left:0;bottom:0;right:0}body noscript>*{position:absolute!important;width:100%;height:100%;z-index:2}body noscript{display:inline!important}.i-amphtml-layout-flex-item,[layout=flex-item]:not(.i-amphtml-layout-flex-item){display:block;position:relative;-ms-flex:1 1 auto;flex:1 1 auto}.i-amphtml-layout-fluid{position:relative}.i-amphtml-layout-size-defined{overflow:hidden!important}.i-amphtml-layout-awaiting-size{position:absolute!important;top:auto!important;bottom:auto!important}i-amphtml-sizer{display:block!important}@supports (aspect-ratio:1/1){i-amphtml-sizer.i-amphtml-disable-ar{display:none!important}}.i-amphtml-blurry-placeholder,.i-amphtml-fill-content{display:block;height:0;max-height:100%;max-width:100%;min-height:100%;min-width:100%;width:0;margin:auto}.i-amphtml-layout-size-defined .i-amphtml-fill-content{position:absolute;top:0;left:0;bottom:0;right:0}.i-amphtml-replaced-content,.i-amphtml-screen-reader{padding:0!important;border:none!important}.i-amphtml-screen-reader{position:fixed!important;top:0px!important;left:0px!important;width:4px!important;height:4px!important;opacity:0!important;overflow:hidden!important;margin:0!important;display:block!important;visibility:visible!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:8px!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:12px!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:16px!important}.i-amphtml-unresolved{position:relative;overflow:hidden!important}.i-amphtml-select-disabled{-webkit-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.i-amphtml-notbuilt,[layout]:not(.i-amphtml-element),[width][height][heights]:not([layout]):not(.i-amphtml-element),[width][height][sizes]:not([layout]):not(.i-amphtml-element){position:relative;overflow:hidden!important;color:transparent!important}.i-amphtml-notbuilt:not(.i-amphtml-layout-container)>*,[layout]:not([layout=container]):not(.i-amphtml-element)>*,[width][height][heights]:not([layout]):not(.i-amphtml-element)>*,[width][height][sizes]:not([layout]):not(.i-amphtml-element)>*{display:none}amp-img:not(.i-amphtml-element)[i-amphtml-ssr]>img.i-amphtml-fill-content{display:block}.i-amphtml-notbuilt:not(.i-amphtml-layout-container),[layout]:not([layout=container]):not(.i-amphtml-element),[width][height][heights]:not([layout]):not(.i-amphtml-element),[width][height][sizes]:not([layout]):not(.i-amphtml-element){color:transparent!important;line-height:0!important}.i-amphtml-ghost{visibility:hidden!important}.i-amphtml-element>[placeholder],[layout]:not(.i-amphtml-element)>[placeholder],[width][height][heights]:not([layout]):not(.i-amphtml-element)>[placeholder],[width][height][sizes]:not([layout]):not(.i-amphtml-element)>[placeholder]{display:block;line-height:normal}.i-amphtml-element>[placeholder].amp-hidden,.i-amphtml-element>[placeholder].hidden{visibility:hidden}.i-amphtml-element:not(.amp-notsupported)>[fallback],.i-amphtml-layout-container>[placeholder].amp-hidden,.i-amphtml-layout-container>[placeholder].hidden{display:none}.i-amphtml-layout-size-defined>[fallback],.i-amphtml-layout-size-defined>[placeholder]{position:absolute!important;top:0!important;left:0!important;right:0!important;bottom:0!important;z-index:1}amp-img.i-amphtml-ssr:not(.i-amphtml-element)>[placeholder]{z-index:auto}.i-amphtml-notbuilt>[placeholder]{display:block!important}.i-amphtml-hidden-by-media-query{display:none!important}.i-amphtml-element-error{background:red!important;color:#fff!important;position:relative!important}.i-amphtml-element-error:before{content:attr(error-message)}i-amp-scroll-container,i-amphtml-scroll-container{position:absolute;top:0;left:0;right:0;bottom:0;display:block}i-amp-scroll-container.amp-active,i-amphtml-scroll-container.amp-active{overflow:auto;-webkit-overflow-scrolling:touch}.i-amphtml-loading-container{display:block!important;pointer-events:none;z-index:1}.i-amphtml-notbuilt>.i-amphtml-loading-container{display:block!important}.i-amphtml-loading-container.amp-hidden{visibility:hidden}.i-amphtml-element>[overflow]{cursor:pointer;position:relative;z-index:2;visibility:hidden;display:initial;line-height:normal}.i-amphtml-layout-size-defined>[overflow]{position:absolute}.i-amphtml-element>[overflow].amp-visible{visibility:visible}template{display:none!important}.amp-border-box,.amp-border-box *,.amp-border-box :after,.amp-border-box :before{box-sizing:border-box}amp-pixel{display:none!important}amp-analytics,amp-auto-ads,amp-story-auto-ads{position:fixed!important;top:0!important;width:1px!important;height:1px!important;overflow:hidden!important;visibility:hidden}html.i-amphtml-fie>amp-analytics{position:initial!important}[visible-when-invalid]:not(.visible),form [submit-error],form [submit-success],form [submitting]{display:none}amp-accordion{display:block!important}@media (min-width:1px){:where(amp-accordion>section)>:first-child{margin:0;background-color:#efefef;padding-right:20px;border:1px solid #dfdfdf}:where(amp-accordion>section)>:last-child{margin:0}}amp-accordion>section{float:none!important}amp-accordion>section>*{float:none!important;display:block!important;overflow:hidden!important;position:relative!important}amp-accordion,amp-accordion>section{margin:0}amp-accordion:not(.i-amphtml-built)>section>:last-child{display:none!important}amp-accordion:not(.i-amphtml-built)>section[expanded]>:last-child{display:block!important}\n/*# sourceURL=/css/ampshared.css*/","ampRuntimeVersion":"012105072136000"}
{"ampRuntimeStyles":"html{overflow-x:hidden!important}html.i-amphtml-fie{height:100%!important;width:100%!important}html:not([amp4ads]),html:not([amp4ads]) body{height:auto!important}html:not([amp4ads]) body{margin:0!important}body{-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%}html.i-amphtml-singledoc.i-amphtml-embedded{-ms-touch-action:pan-y pinch-zoom;touch-action:pan-y pinch-zoom}html.i-amphtml-fie>body,html.i-amphtml-singledoc>body{overflow:visible!important}html.i-amphtml-fie:not(.i-amphtml-inabox)>body,html.i-amphtml-singledoc:not(.i-amphtml-inabox)>body{position:relative!important}html.i-amphtml-ios-embed-legacy>body{overflow-x:hidden!important;overflow-y:auto!important;position:absolute!important}html.i-amphtml-ios-embed{overflow-y:auto!important;position:static}#i-amphtml-wrapper{overflow-x:hidden!important;overflow-y:auto!important;position:absolute!important;top:0!important;left:0!important;right:0!important;bottom:0!important;margin:0!important;display:block!important}html.i-amphtml-ios-embed.i-amphtml-ios-overscroll,html.i-amphtml-ios-embed.i-amphtml-ios-overscroll>#i-amphtml-wrapper{-webkit-overflow-scrolling:touch!important}#i-amphtml-wrapper>body{position:relative!important;border-top:1px solid transparent!important}#i-amphtml-wrapper+body{visibility:visible}#i-amphtml-wrapper+body .i-amphtml-lightbox-element,#i-amphtml-wrapper+body[i-amphtml-lightbox]{visibility:hidden}#i-amphtml-wrapper+body[i-amphtml-lightbox] .i-amphtml-lightbox-element{visibility:visible}#i-amphtml-wrapper.i-amphtml-scroll-disabled,.i-amphtml-scroll-disabled{overflow-x:hidden!important;overflow-y:hidden!important}amp-instagram{padding:54px 0px 0px!important;background-color:#fff}amp-iframe iframe{box-sizing:border-box!important}[amp-access][amp-access-hide]{display:none}[subscriptions-dialog],body:not(.i-amphtml-subs-ready) [subscriptions-action],body:not(.i-amphtml-subs-ready) [subscriptions-section]{display:none!important}amp-experiment,amp-live-list>[update]{display:none}amp-list[resizable-children]>.i-amphtml-loading-container.amp-hidden{display:none!important}amp-list [fetch-error],amp-list[load-more] [load-more-button],amp-list[load-more] [load-more-end],amp-list[load-more] [load-more-failed],amp-list[load-more] [load-more-loading]{display:none}amp-list[diffable] div[role=list]{display:block}amp-story-page,amp-story[standalone]{min-height:1px!important;display:block!important;height:100%!important;margin:0!important;padding:0!important;overflow:hidden!important;width:100%!important}amp-story[standalone]{background-color:#000!important;position:relative!important}amp-story-page{background-color:#757575}amp-story .amp-active>div,amp-story .i-amphtml-loader-background{display:none!important}amp-story-page:not(:first-of-type):not([distance]):not([active]){transform:translateY(1000vh)!important}amp-autocomplete{position:relative!important;display:inline-block!important}amp-autocomplete>input,amp-autocomplete>textarea{padding:0.5rem;border:1px solid rgba(0,0,0,0.33)}.i-amphtml-autocomplete-results,amp-autocomplete>input,amp-autocomplete>textarea{font-size:1rem;line-height:1.5rem}[amp-fx^=fly-in]{visibility:hidden}amp-script[nodom],amp-script[sandboxed]{position:fixed!important;top:0!important;width:1px!important;height:1px!important;overflow:hidden!important;visibility:hidden}\n/*# sourceURL=/css/ampdoc.css*/[hidden]{display:none!important}.i-amphtml-element{display:inline-block}.i-amphtml-blurry-placeholder{transition:opacity 0.3s cubic-bezier(0.0,0.0,0.2,1)!important;pointer-events:none}[layout=nodisplay]:not(.i-amphtml-element){display:none!important}.i-amphtml-layout-fixed,[layout=fixed][width][height]:not(.i-amphtml-layout-fixed){display:inline-block;position:relative}.i-amphtml-layout-responsive,[layout=responsive][width][height]:not(.i-amphtml-layout-responsive),[width][height][heights]:not([layout]):not(.i-amphtml-layout-responsive),[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-layout-responsive){display:block;position:relative}.i-amphtml-layout-intrinsic,[layout=intrinsic][width][height]:not(.i-amphtml-layout-intrinsic){display:inline-block;position:relative;max-width:100%}.i-amphtml-layout-intrinsic .i-amphtml-sizer{max-width:100%}.i-amphtml-intrinsic-sizer{max-width:100%;display:block!important}.i-amphtml-layout-container,.i-amphtml-layout-fixed-height,[layout=container],[layout=fixed-height][height]:not(.i-amphtml-layout-fixed-height){display:block;position:relative}.i-amphtml-layout-fill,.i-amphtml-layout-fill.i-amphtml-notbuilt,[layout=fill]:not(.i-amphtml-layout-fill),body noscript>*{display:block;overflow:hidden!important;position:absolute;top:0;left:0;bottom:0;right:0}body noscript>*{position:absolute!important;width:100%;height:100%;z-index:2}body noscript{display:inline!important}.i-amphtml-layout-flex-item,[layout=flex-item]:not(.i-amphtml-layout-flex-item){display:block;position:relative;-ms-flex:1 1 auto;flex:1 1 auto}.i-amphtml-layout-fluid{position:relative}.i-amphtml-layout-size-defined{overflow:hidden!important}.i-amphtml-layout-awaiting-size{position:absolute!important;top:auto!important;bottom:auto!important}i-amphtml-sizer{display:block!important}@supports (aspect-ratio:1/1){i-amphtml-sizer.i-amphtml-disable-ar{display:none!important}}.i-amphtml-blurry-placeholder,.i-amphtml-fill-content{display:block;height:0;max-height:100%;max-width:100%;min-height:100%;min-width:100%;width:0;margin:auto}.i-amphtml-layout-size-defined .i-amphtml-fill-content{position:absolute;top:0;left:0;bottom:0;right:0}.i-amphtml-replaced-content,.i-amphtml-screen-reader{padding:0!important;border:none!important}.i-amphtml-screen-reader{position:fixed!important;top:0px!important;left:0px!important;width:4px!important;height:4px!important;opacity:0!important;overflow:hidden!important;margin:0!important;display:block!important;visibility:visible!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:8px!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:12px!important}.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader~.i-amphtml-screen-reader{left:16px!important}.i-amphtml-unresolved{position:relative;overflow:hidden!important}.i-amphtml-select-disabled{-webkit-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.i-amphtml-notbuilt,[layout]:not(.i-amphtml-element),[width][height][heights]:not([layout]):not(.i-amphtml-element),[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-element){position:relative;overflow:hidden!important;color:transparent!important}.i-amphtml-notbuilt:not(.i-amphtml-layout-container)>*,[layout]:not([layout=container]):not(.i-amphtml-element)>*,[width][height][heights]:not([layout]):not(.i-amphtml-element)>*,[width][height][sizes]:not([layout]):not(.i-amphtml-element)>*{display:none}amp-img:not(.i-amphtml-element)[i-amphtml-ssr]>img.i-amphtml-fill-content{display:block}.i-amphtml-notbuilt:not(.i-amphtml-layout-container),[layout]:not([layout=container]):not(.i-amphtml-element),[width][height][heights]:not([layout]):not(.i-amphtml-element),[width][height][sizes]:not(img):not([layout]):not(.i-amphtml-element){color:transparent!important;line-height:0!important}.i-amphtml-ghost{visibility:hidden!important}.i-amphtml-element>[placeholder],[layout]:not(.i-amphtml-element)>[placeholder],[width][height][heights]:not([layout]):not(.i-amphtml-element)>[placeholder],[width][height][sizes]:not([layout]):not(.i-amphtml-element)>[placeholder]{display:block;line-height:normal}.i-amphtml-element>[placeholder].amp-hidden,.i-amphtml-element>[placeholder].hidden{visibility:hidden}.i-amphtml-element:not(.amp-notsupported)>[fallback],.i-amphtml-layout-container>[placeholder].amp-hidden,.i-amphtml-layout-container>[placeholder].hidden{display:none}.i-amphtml-layout-size-defined>[fallback],.i-amphtml-layout-size-defined>[placeholder]{position:absolute!important;top:0!important;left:0!important;right:0!important;bottom:0!important;z-index:1}amp-img[i-amphtml-ssr]:not(.i-amphtml-element)>[placeholder]{z-index:auto}.i-amphtml-notbuilt>[placeholder]{display:block!important}.i-amphtml-hidden-by-media-query{display:none!important}.i-amphtml-element-error{background:red!important;color:#fff!important;position:relative!important}.i-amphtml-element-error:before{content:attr(error-message)}i-amp-scroll-container,i-amphtml-scroll-container{position:absolute;top:0;left:0;right:0;bottom:0;display:block}i-amp-scroll-container.amp-active,i-amphtml-scroll-container.amp-active{overflow:auto;-webkit-overflow-scrolling:touch}.i-amphtml-loading-container{display:block!important;pointer-events:none;z-index:1}.i-amphtml-notbuilt>.i-amphtml-loading-container{display:block!important}.i-amphtml-loading-container.amp-hidden{visibility:hidden}.i-amphtml-element>[overflow]{cursor:pointer;position:relative;z-index:2;visibility:hidden;display:initial;line-height:normal}.i-amphtml-layout-size-defined>[overflow]{position:absolute}.i-amphtml-element>[overflow].amp-visible{visibility:visible}template{display:none!important}.amp-border-box,.amp-border-box *,.amp-border-box :after,.amp-border-box :before{box-sizing:border-box}amp-pixel{display:none!important}amp-analytics,amp-auto-ads,amp-story-auto-ads{position:fixed!important;top:0!important;width:1px!important;height:1px!important;overflow:hidden!important;visibility:hidden}html.i-amphtml-fie>amp-analytics{position:initial!important}[visible-when-invalid]:not(.visible),form [submit-error],form [submit-success],form [submitting]{display:none}amp-accordion{display:block!important}@media (min-width:1px){:where(amp-accordion>section)>:first-child{margin:0;background-color:#efefef;padding-right:20px;border:1px solid #dfdfdf}:where(amp-accordion>section)>:last-child{margin:0}}amp-accordion>section{float:none!important}amp-accordion>section>*{float:none!important;display:block!important;overflow:hidden!important;position:relative!important}amp-accordion,amp-accordion>section{margin:0}amp-accordion:not(.i-amphtml-built)>section>:last-child{display:none!important}amp-accordion:not(.i-amphtml-built)>section[expanded]>:last-child{display:block!important}\n/*# sourceURL=/css/ampshared.css*/","ampRuntimeVersion":"012112231523001"}

@@ -81,3 +81,3 @@ /**

if (this.blurredPlaceholders_) {
this.log_.warn(
this.log_.error(
'jimp and lru-cache need to be installed via `npm install jimp lru-cache` ' +

@@ -84,0 +84,0 @@ 'for this transformer to work'

@@ -76,4 +76,3 @@ /**

// eslint-disable-next-line max-len
text:
'body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}',
text: 'body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}',
},

@@ -96,4 +95,3 @@ ],

// eslint-disable-next-line max-len
text:
'body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}',
text: 'body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}',
},

@@ -100,0 +98,0 @@ },

@@ -127,2 +127,3 @@ /**

const sizer = createElement('i-amphtml-sizer', {
slot: 'i-amphtml-svc',
style: `display:block;padding-top:${parseFloat(padding.toFixed(4))}%`,

@@ -138,2 +139,3 @@ });

const sizer = createElement('i-amphtml-sizer', {
slot: 'i-amphtml-svc',
class: 'i-amphtml-sizer',

@@ -140,0 +142,0 @@ });

@@ -62,3 +62,3 @@ /**

constructor(config) {
this.enabled = config.autoExtensionImport !== false;
this.enabled = !!config.autoExtensionImport;
this.format = config.format || DEFAULT_FORMAT;

@@ -65,0 +65,0 @@ this.log_ = config.log.tag('AutoExtensionImporter');

@@ -18,3 +18,3 @@ /**

const {minify} = require('terser');
const isDependencyInstalled = require('../isDependencyInstalled');
const {remove} = require('../NodeUtils');

@@ -135,4 +135,18 @@ const normalizeWhitespace = require('normalize-html-whitespace');

async minifyAmpScript(child) {
if (!isDependencyInstalled('terser')) {
this.log_.error(
'terser needs to be installed via `npm install terser` for minifying inline amp-script'
);
return;
}
try {
const result = await minify(child.data, {});
const {minify} = require('terser');
const result = await minify(child.data, {
format: {
// Always use the original quotes.
quote_style: 3,
// Do not wrap function expressions that are passed as arguments in parenthesis.
wrap_func_args: false,
},
});
if (result.error) {

@@ -139,0 +153,0 @@ this.log.warn(

@@ -22,2 +22,3 @@ /**

/**
* Allow the runtime to detect amp-bimd elements more efficiently by adding `i-amphtml-binding` attributes to elements that have bindings.
*/

@@ -27,11 +28,5 @@ class OptimizeAmpBind {

this.log_ = config.log.tag('OptimizeAmpBind');
this.enabled_ = config.optimizeAmpBind !== false;
if (!this.enabled_) {
this.log_.debug('disabled');
}
}
/**
*/
transform(root) {

@@ -38,0 +33,0 @@ if (!this.enabled_) return;

@@ -30,25 +30,4 @@ /**

const SRCSET_WIDTH = [
39,
47,
56,
68,
82,
100,
120,
150,
180,
220,
270,
330,
390,
470,
560,
680,
820,
1000,
1200,
1440,
1750,
2000,
2500,
39, 47, 56, 68, 82, 100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820, 1000, 1200, 1440,
1750, 2000, 2500,
];

@@ -55,0 +34,0 @@

@@ -19,2 +19,3 @@ /**

const {appendChild, appendAll, hasAttribute, firstChildByTag} = require('../NodeUtils');
const {isAmpStoryDvhPolyfillScript} = require('../AmpConstants');
const {isRenderDelayingExtension} = require('../Extensions.js');

@@ -26,2 +27,3 @@

this._linkStyleAmpRuntime = null;
this._linkStyleAmpStory = null;
this._metaCharset = null;

@@ -34,2 +36,3 @@ this._metaViewport = null;

this._scriptNonRenderDelayingExtensions = new Map();
this._scriptAmpStoryDvhPollyfill = null;
this._linkIcons = [];

@@ -67,4 +70,8 @@ this._styleAmpCustom = null;

appendAll(head, this._metaOther);
// We want the dvh polyfill to be before the amp-story styles to prevent
// triggering an increase to CLS score.
appendChild(head, this._scriptAmpStoryDvhPollyfill);
appendChild(head, this._linkStyleAmpRuntime);
appendChild(head, this._styleAmpRuntime);
appendChild(head, this._linkStyleAmpStory);
appendAll(head, this._scriptAmpEngine);

@@ -134,2 +141,6 @@ appendAll(head, this._scriptRenderDelayingExtensions);

}
if (isAmpStoryDvhPolyfillScript(node)) {
this._scriptAmpStoryDvhPollyfill = node;
return;
}
this._others.push(node);

@@ -167,2 +178,6 @@ }

}
if (node.attribs.href.endsWith('/amp-story-1.0.css')) {
this._linkStyleAmpStory = node;
return;
}
if (!this._styleAmpCustom) {

@@ -203,13 +218,15 @@ // We haven't seen amp-custom yet.

* (0) <meta charset> tag
* (1) <style amp-runtime> (inserted by ampruntimecss.go)
* (2) remaining <meta> tags (those other than <meta charset>)
* (3) AMP runtime .js <script> tag
* (4) <script> tags that are render delaying
* (5) <script> tags for remaining extensions
* (6) <link> tag for favicons
* (7) <link> tag for resource hints
* (8) <link rel=stylesheet> tags before <style amp-custom>
* (9) <style amp-custom>
* (10) any other tags allowed in <head>
* (11) AMP boilerplate (first style amp-boilerplate, then noscript)
* (1) <script amp-story-dvh-polyfill> inline script tag
* (2) <style amp-runtime> (inserted by ampruntimecss.go)
* (3) <link amp-extension=amp-story> (amp-story stylesheet)
* (4) remaining <meta> tags (those other than <meta charset>)
* (5) AMP runtime .js <script> tag
* (6) <script> tags that are render delaying
* (7) <script> tags for remaining extensions
* (8) <link> tag for favicons
* (9) <link> tag for resource hints
* (10) <link rel=stylesheet> tags before <style amp-custom>
* (11) <style amp-custom>
* (12) any other tags allowed in <head>
* (13) AMP boilerplate (first style amp-boilerplate, then noscript)
*/

@@ -216,0 +233,0 @@ class ReorderHeadTransformer {

@@ -132,3 +132,3 @@ /**

const url = new URL(host);
this._addMeta(head, 'runtime-host', url.origin);
this._addMeta(head, 'runtime-host', url.origin + url.pathname);
} catch (e) {

@@ -135,0 +135,0 @@ this.log.warn('ampUrlPrefix must be an absolute URL');

@@ -18,8 +18,5 @@ /**

const isDependencyInstalled = require('../isDependencyInstalled');
const {insertText, createElement, hasAttribute, firstChildByTag} = require('../NodeUtils');
const safeParser = require('postcss-safe-parser');
const postcss = require('postcss');
const cssnano = require('cssnano-simple');
const allowedKeyframeProps = new Set([

@@ -49,5 +46,24 @@ 'animation-timing-function',

this.minify = config.minify !== false;
this.enabled = !!config.separateKeyframes;
if (
this.enabled &&
(!isDependencyInstalled('postcss') ||
!isDependencyInstalled('postcss-safe-parser') ||
!isDependencyInstalled('cssnano-simple'))
) {
this.enabled = false;
this.log_.error(
'Install postcss to move keyframe animations into amp-keyframes via `npm install postcss postcss-safe-parser cssnano-simple`.'
);
return;
}
this.safeParser = require('postcss-safe-parser');
this.postcss = require('postcss');
this.cssnano = require('cssnano-simple');
}
async transform(tree) {
if (!this.enabled) {
return;
}
const html = firstChildByTag(tree, 'html');

@@ -78,3 +94,3 @@ if (!html) return;

const extraPlugins = this.minify ? [cssnano] : [];
const extraPlugins = this.minify ? [this.cssnano] : [];

@@ -89,3 +105,3 @@ // If no custom styles, there's nothing to do

// initialize an empty keyframes tree
const keyframesTree = postcss.parse('');
const keyframesTree = this.postcss.parse('');

@@ -150,6 +166,6 @@ const isInvalidKeyframe = (keyframe) => {

const {css: cssResult} = await postcss([...extraPlugins, keyframesPlugin])
const {css: cssResult} = await this.postcss([...extraPlugins, keyframesPlugin])
.process(stylesText, {
from: undefined,
parser: safeParser,
parser: this.safeParser,
})

@@ -184,7 +200,9 @@ .catch((err) => {

const keyframesTextNode = stylesKeyframesTag.children[0];
const currentKeyframesTree = postcss.parse((keyframesTextNode && keyframesTextNode.data) || '');
const currentKeyframesTree = this.postcss.parse(
(keyframesTextNode && keyframesTextNode.data) || ''
);
currentKeyframesTree.nodes = keyframesTree.nodes.concat(currentKeyframesTree.nodes);
let keyframesText = '';
postcss.stringify(currentKeyframesTree, (part) => {
this.postcss.stringify(currentKeyframesTree, (part) => {
keyframesText += part;

@@ -195,5 +213,5 @@ });

if (extraPlugins.length > 0) {
const cssResult = await postcss(extraPlugins).process(keyframesText, {
const cssResult = await this.postcss(extraPlugins).process(keyframesText, {
from: undefined,
parser: safeParser,
parser: this.safeParser,
});

@@ -200,0 +218,0 @@ keyframesText = cssResult.css;

@@ -118,3 +118,3 @@ /**

for (let node = head.firstChild; node; node = node.nextSibling) {
// amp-experiment is a render delaying extension iff the tag is used in
// amp-experiment is a render delaying extension if the tag is used in
// the doc, which we checked for above.

@@ -121,0 +121,0 @@ if (

{
"name": "@ampproject/toolbox-optimizer",
"version": "2.8.4",
"version": "3.0.0-canary.2",
"description": "Server-side rendering for AMPs.",

@@ -11,2 +11,5 @@ "main": "index.js",

},
"scripts": {
"build": "node build/downloadRuntimeParameters.js"
},
"files": [

@@ -27,22 +30,30 @@ "index.js",

"optional": true
},
"cssnano-simple": {
"optional": true
},
"postcss": {
"optional": true
},
"postcss-safe-parser": {
"optional": true
},
"terser": {
"optional": true
}
},
"dependencies": {
"@ampproject/toolbox-core": "2.8.0",
"@ampproject/toolbox-runtime-version": "2.8.0",
"@ampproject/toolbox-core": "3.0.0-canary.2",
"@ampproject/toolbox-runtime-version": "3.0.0-canary.2",
"@ampproject/toolbox-script-csp": "2.8.0",
"@ampproject/toolbox-validator-rules": "2.8.0",
"abort-controller": "3.0.0",
"cross-fetch": "3.1.2",
"cssnano-simple": "2.0.0",
"@ampproject/toolbox-validator-rules": "3.0.0-canary.2",
"dom-serializer": "1.3.2",
"domhandler": "4.2.2",
"domutils": "2.8.0",
"htmlparser2": "7.2.0",
"domelementtype": "2.2.0",
"domhandler": "4.2.0",
"domutils": "2.7.0",
"htmlparser2": "6.1.0",
"https-proxy-agent": "5.0.0",
"lru-cache": "6.0.0",
"normalize-html-whitespace": "1.0.0",
"postcss": "8.2.13",
"postcss-safe-parser": "5.0.2",
"terser": "5.5.1"
"node-fetch": "2.6.1",
"normalize-html-whitespace": "1.0.0"
},

@@ -53,3 +64,3 @@ "bugs": {

"homepage": "https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer",
"gitHead": "5dfab2df0c550698f03d7f45634cf4079f02c66e"
"gitHead": "0f63a77e8081f0fb7d6b63280e2fd8701836c4f9"
}

@@ -26,8 +26,24 @@ # AMP Optimizer

### API
AMP Optimizer provides two different default modes:
1. **Fast:** this will perform only critical optimizations minimizing bundle install size and execution time. Use this when running AMP Optimizer in your critical rendering path, for example, when running AMP Optimizer in your server.
2. **Full:** this will perform all available optimizations, resulting in the best AMP performance. This mode offers a better AMP developer experience as missing AMP specific markup and imports are added automatically. This makes it a great choice when integrating it into a static site generator. **Important:** use only when running AMP Optimizer does not negatively affect the rendering time of your page, for example, when building a static site.
Please note: both modes just provide defaults and can be individually configured via these [options](#options). The main differences between these two modes are listed here:
| Option | Fast | Full |
|-----------------------|---------|--------|
| autoAddMandatoryTags | `true` | `true` |
| autoExtensionImport | `false` | `true` |
| markdown | `false` | `true` |
| minify | `false` | `true` |
| separateKeyframes | `false` | `true` |
### Using `fast` mode
Install via:
```
npm install @ampproject/toolbox-optimizer
npm install @ampproject/toolbox-optimizer
```

@@ -40,3 +56,3 @@

const ampOptimizer = AmpOptimizer.create();
const ampOptimizer = AmpOptimizer.createFastOptimizer();

@@ -54,4 +70,52 @@ const originalHtml = `

You can find a sample implementation [here](/packages/optimizer/demo/simple). If you're using express to serve your site, you can use the [AMP Optimizer Middleware](/packages/optimizer-express).
It's also possible to add additional options, for example, to enable Markdown mode:
```js
const AmpOptimizer = require('@ampproject/toolbox-optimizer');
const ampOptimizer = AmpOptimizer.createFastOptimizer({
autoExtensionImport: true,
imageBasePath: '../img',
markdown: true
});
const originalHtml = `
<img src="img.jpg"/>
`;
ampOptimizer.transformHtml(originalHtml).then((optimizedHtml) => {
console.log(optimizedHtml);
});
```
### Using `full` mode
Install via:
```
npm install @ampproject/toolbox-optimizer terser postcss postcss-safe-parser cssnano-simple
```
Note: `full` mode requires additional dependencies for all features, such as CSS minification, to work. AMP Optimizer will skip transformations if dependencies are missing. Check the log output for debugging.
Minimal usage:
```js
const AmpOptimizer = require('@ampproject/toolbox-optimizer');
const ampOptimizer = AmpOptimizer.createFullOptimizer({
// optional parameters
});
const originalHtml = `
<!doctype html>
<html ⚡>
...
</html>`;
ampOptimizer.transformHtml(originalHtml).then((optimizedHtml) => {
console.log(optimizedHtml);
});
```
### CLI

@@ -74,11 +138,2 @@

Options are passed when creating a new AMP Optimizer instance:
```js
const ampOptimizer = AmpOptimizer.create({
verbose: true
});
...
```
Available options are:

@@ -88,2 +143,3 @@

- [autoExtensionImport](#autoextensionimport)
- [cache](#cache)
- [esmModulesEnabled](#esmmodulesenabled)

@@ -99,4 +155,6 @@ - [extensionVersions](#extensionversions)

- [optimizeAmpBind](#optimizeampbind)
- [optimizeAmpStory](#optimizeampstory)
- [optimizeHeroImages](#optimizeheroimages)
- [preloadHeroImage](#preloadheroimage)
- [separateKeyframes](#separateKeyframes)
- [verbose](#verbose)

@@ -115,9 +173,26 @@

Automatically import any missing AMP Extensions (e.g. amp-carousel).
Automatically import any missing AMP Extensions (e.g. amp-carousel). This is not recommended if AMP Optimizer is run in the critical serving path.
- name: `autoExtensionImport`
- valid options: `[true|false]`
- default: `true`
- default: `false`
- used by: [AutoExtensionImport](lib/transformers/AutoExtensionImporter.js)
#### `cache`
Specifies the cache implementation to use for caching artifacts required during transformation (runtime CSS, validation rules, latest runtime version,...). A cache needs to conform to the following interface:
```typescript
interface Cache {
set(key: Object, value: Object?): Promise<void>;
get(key: Object): Promise<Object?>;
}
```
By default, artifacts will be cached in a temporary directory. If there is no filesystem access available, the cache will fallback to an in memory implementation.
- name: `cache`
- valid options: `[Cache|false]` (`false` will disable caching)
- default: [cache.js](lib/cache.js)
#### `esmModulesEnabled`

@@ -158,2 +233,9 @@

#### `fetch`
Specifies the [fetch](https://fetch.spec.whatwg.org) implementation to use:
- name: `fetch`
- default: `node-fetch`
#### `format`

@@ -227,11 +309,10 @@

Minifies the generated HTML output and inlined CSS.
Minifies the generated HTML output. Requires [`terser`](https://www.npmjs.com/package/terser) to be installed when inlined `amp-script` should be minified. Combine with [separateKeyframes](#separateKeyframes) to also minify CSS.
- name: `minify`
- valid options: `[true|false]`
- default: `true`
- default: `false`
- used by: [MinifyHtml](lib/transformers/MinifyHtml.js), [SeparateKeyframes](lib/transformers/SeparateKeyframes.js)
- additional dependency (when using amp-script): `npm install terser`
**Warning:** this setting is not recommended when running AMP Optimizer in your backend on every request as execution time can increase by up to 7x.
#### `optimizeAmpBind`

@@ -246,2 +327,12 @@

### `optimizeAmpStory`
Enables AMP Story optimizations such as linking to the amp-story-1.0.css, and server side rendering
attributes.
- name: `optimizeAmpStory`
- valid options: `[true|false]`
- default: `false`
- used by: [AmpStoryCssTransformer](lib/transformers/AmpStoryCssTransformer.js)
#### `optimizeHeroImages`

@@ -268,2 +359,12 @@

#### `separateKeyframes`
Automatically move keyframe animations to a separate `amp-keyframes` style block at the end of the document. Putting keyframes declarations at the bottom of a document allows them to exceed size limitations and avoids blocking first contentful paint to parse them (see [documentation](https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml/?format=ads#keyframes-stylesheet)).
- name: `separateKeyframes`
- valid options: `[true|false]`
- default: `true`
- used by: [SeparateKeyframes](lib/transformers/SeparateKeyframes.js)
- additional dependencies: `npm install postcss postcss-safe-parser cssnano-simple`
#### `verbose`

@@ -270,0 +371,0 @@

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