Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ampproject/toolbox-runtime-version

ampproject238.7kApache-2.02.10.1

AMP Runtime versions

amp

readme

AMP Runtime Version

npm version

Use it to query cdn.ampproject.org for the current release or canary version of the AMP Runtime. Uses a stale-while-revalidate caching strategy to avoid network requests in the critical path.

You can use the API to re-write AMP runtime URLs to their versioned counter parts to improve browser caching, e.g. to replace:

https://cdn.ampproject.org/v0.css

with:

https://cdn.ampproject.org/rtv/001515617716922/v0.css

Installation

Install via:

npm install @ampproject/toolbox-runtime-version

Usage

Basic usage:

const runtimeVersion = require('@ampproject/toolbox-runtime-version');

// Release version
runtimeVersion.currentVersion().then(version => {
  console.log(version);
});

// Canary version
runtimeVersion.currentVersion({canary: true}).then(version => {
  console.log(version);
});

// Rewriting cache URLs
const ampRuntimeUrl = 'https://cdn.ampproject.org/v0.js';
const version = await runtimeVersion.currentVersion();
const versionedAmpRuntimeUrl = ampRuntimeUrl.replace(
  'https://cdn.ampproject.org/',
  'https://cdn.ampproject.org/rtv/' + version + '/'
);
console.log(versionedAmpRuntimeUrl);

changelog

v2.8.0 (2021-05-31)

:rocket: Enhancement

:bug: Bug Fix

:memo: Documentation

Committers: 1

v2.7.6 (2021-02-01)

:rocket: Enhancement

:bug: Bug Fix

Committers: 1

v2.7.5 (2021-01-18)

:bug: Bug Fix

Committers: 4

v2.7.4 (2020-12-23)

:bug: Bug Fix

  • cli, core, linter, optimizer, runtime-fetch, validator-rules

Committers: 1

v2.7.3 (2020-12-17)

:rocket: Enhancement

:bug: Bug Fix

Committers: 1

v2.7.2 (2020-12-15)

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

  • linter, optimizer

Committers: 5

v2.7.1 (2020-10-26)

:rocket: Enhancement

  • linter
  • optimizer
    • #911 Allow users to specify version numbers for auto imported extensions (@digijin)

:bug: Bug Fix

Committers: 11

v2.7.0-alpha.3 (2020-08-25)

:rocket: Enhancement

Committers: 1

v2.7.0-alpha.2 (2020-08-21)

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

  • cache-url, cli, cors, linter, optimizer, runtime-fetch, runtime-version
  • linter
  • lighthouse-plugin-amp, linter, optimizer, update-cache

Committers: 3

v2.6.0 (2020-08-10)

:rocket: Enhancement

:bug: Bug Fix

:memo: Documentation

:house: Internal

Committers: 2

v2.5.14 (2020-07-24)

:rocket: Enhancement

:bug: Bug Fix

Committers: 3

v2.5.13 (2020-07-15)

:bug: Bug Fix

Committers: 1

v2.5.12 (2020-07-15)

:rocket: Enhancement

Committers: 2

v2.5.11 (2020-07-14)

:bug: Bug Fix

Committers: 1

v2.5.9 (2020-07-08)

:bug: Bug Fix

Committers: 1

v2.5.8 (2020-07-08)

:bug: Bug Fix

Committers: 1

v2.5.7 (2020-07-08)

:bug: Bug Fix

Committers: 1

v2.5.6 (2020-07-07)

:rocket: Enhancement

Committers: 1

v2.5.5 (2020-06-22)

:bug: Bug Fix

Committers: 1

v2.5.4 (2020-06-22)

:bug: Bug Fix

Committers: 1

v2.5.3 (2020-06-15)

:bug: Bug Fix

  • optimizer
    • #838 fix(optimizer): add missing dependency node-fetch (@merceyz)

Committers: 1

v2.5.2 (2020-06-11)

:bug: Bug Fix

:house: Internal

Committers: 2

v2.5.1 (2020-06-09)

:rocket: Enhancement

  • linter
  • cache-list, cli, core, cors, lighthouse-plugin-amp, linter, optimizer-express, optimizer, runtime-fetch, runtime-version, update-cache
  • cli, linter

:bug: Bug Fix

:house: Internal

Committers: 2

v2.5.0 (2020-05-29)

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

Committers: 4

v2.4.0 (2020-05-13)

:bug: Bug Fix

:rocket: Enhancement

  • core, optimizer
  • linter
    • #755 Added og:image and alt text checks to linter for Stories (@Dbrown910)

:memo: Documentation

:house: Internal

Committers: 4

2.3.1 (2020-05-05)

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

Committers: 5

2.3.0 (2020-04-15)

:rocket: Enhancement

  • runtime-fetch
    • #711 runtime-fetch: Update amp-geo for subdivision matching (@mdmower)
  • cli, optimizer
  • cli, runtime-version
    • #695 runtime-version: Update for custom hosts and lts (@mdmower)
  • cache-url
  • cache-url, cli
    • #705 Add support for serving types in createCacheUrl (@Enriqe)

:memo: Documentation

  • cors, optimizer-express, optimizer, update-cache
    • #690 Use relative links compatible with github&npmjs (@mdmower)
  • cli

:house: Internal

  • optimizer

Committers: 3

2.2.0 (2020-04-03)

:rocket: Enhancement

  • optimizer
    • #679 Update to use postcss and cssnano for SeparateKeyframes transform (@ijjk)
  • cli

:bug: Bug Fix

:house: Internal

Committers: 3

2.1.0 (2020-04-01)

:rocket: Enhancement

  • cli, download-runtime
    • #663 download-runtime: Add tool to download AMP runtime (@mdmower)
  • cache-url, cli
  • optimizer

:bug: Bug Fix

:memo: Documentation

:house: Internal

Committers: 4

2.0.1

:rocket: Enhancement

  • optimizer
    • #622 optimizer: Add meta tags for singleDoc self-host (@mdmower)

:bug: Bug Fix

:house: Internal

Committers: 3

2.0.0

Migration notes:

  • The SeparateKeyframe transformer's compress option has been renamed to minify. The same option will also be used by the MinifyHtml transformer. The default value continues to be true.
  • The API for implementing a custom transformer has changed. We no longer monkey patch the node class, but instead rely on helper methods defined in NodeUtils:

    const {firstChildByTag, appendChild, createElement} =
    require('@ampproject/toolbox-optimizer').NodeUtils; class CustomTransformer { constructor(config)
    { this.log_ = config.log.tag('CUSTOM'); } transform(tree, params) { this.log_.info('Running custom
    transformation for ', params.filePath); const html = firstChildByTag(tree, 'html'); if (!html)
    return; const head = firstChildByTag(html, 'head'); if (!head) return; const desc =
    createElement('meta', { name: 'description', content: 'this is just a demo', }); appendChild(head,
    desc); } }

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

  • cli, core, cors, optimizer, update-cache
  • linter, optimizer-express
  • cache-list, cache-url, cli, core, cors, lighthouse-plugin-amp, linter, optimizer-express, optimizer, runtime-version, script-csp, update-cache, validator-rules
    • #568 Adds "repository" and "homepage" to every package.json (@fstanis)

Committers: 2

v1.1.2 (2019-10-15)

:bug: Bug Fix

Committers: 1

v1.1.2-alpha.0 (2019-10-09)

:rocket: Enhancement

  • optimizer
    • #518 optimizer: Make dynamic component URL rewrites optional (@mattwomple)

:bug: Bug Fix

  • optimizer

Committers: 2

v1.1.0 (2019-10-08)

:rocket: Enhancement

Committers: 4

v1.1.0-beta.1 (2019-09-19)

:rocket: Enhancement

:bug: Bug Fix

:house: Internal

Committers: 6