UNPKG

1.56 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 '../model/url';
15import { UrlLoader } from './url-loader';
16/**
17 * Resolves requests first from an in-memory map of file contents, and if a
18 * file isn't found there, defers to another url loader.
19 *
20 * Useful for the editor use case. An editor will have a number of files in open
21 * buffers at any time. For these files, the editor's in-memory buffer is
22 * canonical, so that their contents are read even when they have unsaved
23 * changes. For all other files, we can load the files using another loader,
24 * e.g. from disk.
25 *
26 * TODO(rictic): make this a mixin that mixes another loader.
27 */
28export declare class InMemoryOverlayUrlLoader implements UrlLoader {
29 private readonly _fallbackLoader;
30 urlContentsMap: Map<ResolvedUrl, string>;
31 constructor(fallbackLoader?: UrlLoader);
32 canLoad(url: ResolvedUrl): boolean;
33 load(url: ResolvedUrl): Promise<string>;
34 readDirectory?: (pathFromRoot: string, deep?: boolean) => Promise<PackageRelativeUrl[]>;
35}