UNPKG

2.58 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import { PackageRelativeUrl, ResolvedUrl } from 'polymer-analyzer';
15import { ProjectConfig } from 'polymer-project-config';
16import File = require('vinyl');
17import { LocalFsPath } from './path-transformers';
18import { AsyncTransformStream } from './streams';
19/**
20 * Push Manifest Types Definitions
21 * A push manifest is a JSON object representing relative application URL and
22 * the resources that should be pushed when those URLs are requested by the
23 * server. Below is a example of this data format:
24 *
25 * {
26 * "index.html": { // PushManifestEntryCollection
27 * "/css/app.css": { // PushManifestEntry
28 * "type": "style", // ResourceType
29 * "weight": 1
30 * },
31 * ...
32 * },
33 * "page.html": {
34 * "/css/page.css": {
35 * "type": "style",
36 * "weight": 1
37 * },
38 * ...
39 * }
40 * }
41 *
42 * NOTE(fks) 04-05-2017: Only weight=1 is supported by browsers at the moment.
43 * When support is added, we can add automatic weighting and support multiple
44 * numbers.
45 */
46export declare type ResourceType = 'document' | 'script' | 'style' | 'image' | 'font';
47export interface PushManifestEntry {
48 type?: ResourceType;
49 weight?: 1;
50}
51export interface PushManifestEntryCollection {
52 [dependencyAbsoluteUrl: string]: PushManifestEntry;
53}
54export interface PushManifest {
55 [requestAbsoluteUrl: string]: PushManifestEntryCollection;
56}
57/**
58 * A stream that reads in files from an application to generate an HTTP2/Push
59 * manifest that gets injected into the stream.
60 */
61export declare class AddPushManifest extends AsyncTransformStream<File, File> {
62 files: Map<ResolvedUrl, File>;
63 outPath: LocalFsPath;
64 private config;
65 private analyzer;
66 private basePath;
67 constructor(config: ProjectConfig, outPath?: LocalFsPath, basePath?: PackageRelativeUrl);
68 protected _transformIter(files: AsyncIterable<File>): AsyncIterable<File>;
69 generatePushManifest(): Promise<PushManifest>;
70}