2017-09-28 19:18:12 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {sha1} from './sha1';
|
|
|
|
|
|
|
|
export type ManifestHash = string;
|
|
|
|
|
|
|
|
export interface Manifest {
|
|
|
|
configVersion: number;
|
2019-03-05 08:24:07 -05:00
|
|
|
timestamp: number;
|
2017-09-28 19:18:12 -04:00
|
|
|
appData?: {[key: string]: string};
|
|
|
|
index: string;
|
|
|
|
assetGroups?: AssetGroupConfig[];
|
|
|
|
dataGroups?: DataGroupConfig[];
|
2018-04-12 11:04:11 -04:00
|
|
|
navigationUrls: {positive: boolean, regex: string}[];
|
2017-09-28 19:18:12 -04:00
|
|
|
hashTable: {[url: string]: string};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AssetGroupConfig {
|
|
|
|
name: string;
|
|
|
|
installMode: 'prefetch'|'lazy';
|
|
|
|
updateMode: 'prefetch'|'lazy';
|
|
|
|
urls: string[];
|
|
|
|
patterns: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DataGroupConfig {
|
|
|
|
name: string;
|
|
|
|
version: number;
|
|
|
|
strategy: 'freshness'|'performance';
|
|
|
|
patterns: string[];
|
|
|
|
maxSize: number;
|
|
|
|
timeoutMs?: number;
|
|
|
|
refreshAheadMs?: number;
|
|
|
|
maxAge: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hashManifest(manifest: Manifest): ManifestHash {
|
|
|
|
return sha1(JSON.stringify(manifest));
|
2018-04-12 11:04:11 -04:00
|
|
|
}
|