1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2016 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 | */
|
14 | /// <reference types="node" />
|
15 | import * as dom5 from 'dom5/lib/index-next';
|
16 | import { Transform } from 'stream';
|
17 | import File = require('vinyl');
|
18 | /**
|
19 | * HTMLSplitter represents the shared state of files as they are passed through
|
20 | * a splitting stream and then a rejoining stream. Creating a new instance of
|
21 | * HTMLSplitter and adding its streams to the build pipeline is the
|
22 | * supported user interface for splitting out and rejoining inlined CSS & JS in
|
23 | * the build process.
|
24 | */
|
25 | export declare class HtmlSplitter {
|
26 | private _splitFiles;
|
27 | private _parts;
|
28 | /**
|
29 | * Returns a new `Transform` stream that splits inline script and styles into
|
30 | * new, separate files that are passed out of the stream.
|
31 | */
|
32 | split(): Transform;
|
33 | /**
|
34 | * Returns a new `Transform` stream that rejoins inline scripts and styles
|
35 | * that were originally split from this `HTMLSplitter`'s `split()` back into
|
36 | * their parent HTML files.
|
37 | */
|
38 | rejoin(): Transform;
|
39 | isSplitFile(parentPath: string): boolean;
|
40 | getSplitFile(parentPath: string): SplitFile;
|
41 | addSplitPath(parentPath: string, childPath: string): void;
|
42 | getParentFile(childPath: string): SplitFile | undefined;
|
43 | }
|
44 | /**
|
45 | * Returns whether the given script tag was an inline script that was split out
|
46 | * into a fake file by HtmlSplitter.
|
47 | */
|
48 | export declare function scriptWasSplitByHtmlSplitter(script: dom5.Node): boolean;
|
49 | export declare type HtmlSplitterFile = File & {
|
50 | fromHtmlSplitter?: true;
|
51 | isModule?: boolean;
|
52 | };
|
53 | /**
|
54 | * Return whether the given Vinyl file was created by the HtmlSplitter from an
|
55 | * HTML document script tag.
|
56 | */
|
57 | export declare function isHtmlSplitterFile(file: File): file is HtmlSplitterFile;
|
58 | /**
|
59 | * Represents a file that is split into multiple files.
|
60 | */
|
61 | export declare class SplitFile {
|
62 | path: string;
|
63 | parts: Map<string, string | null>;
|
64 | outstandingPartCount: number;
|
65 | vinylFile: File | null;
|
66 | constructor(path: string);
|
67 | addPartPath(path: string): void;
|
68 | setPartContent(path: string, content: string): void;
|
69 | readonly isComplete: boolean;
|
70 | }
|