UNPKG

2.07 kBTypeScriptView Raw
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 */
14import { PackageRelativeUrl, ScannedImport } from '../index';
15import { FileRelativeUrl, ResolvedUrl } from '../model/url';
16/**
17 * Resolves the given URL to the concrete URL that a resource can
18 * be loaded from.
19 *
20 * This can be useful to resolve name to paths, such as resolving 'polymer' to
21 * '../polymer/polymer.html', or component paths, like '../polymer/polymer.html'
22 * to '/bower_components/polymer/polymer.html'.
23 */
24export declare abstract class UrlResolver {
25 /**
26 * Resoves `url` to a new location.
27 *
28 * Returns `undefined` if the given url cannot be resolved.
29 */
30 abstract resolve(url: PackageRelativeUrl): ResolvedUrl | undefined;
31 abstract resolve(baseUrl: ResolvedUrl, url: FileRelativeUrl, scannedImport?: ScannedImport): ResolvedUrl | undefined;
32 abstract relative(to: ResolvedUrl): PackageRelativeUrl;
33 abstract relative(from: ResolvedUrl, to: ResolvedUrl, kind?: string): FileRelativeUrl;
34 protected getBaseAndUnresolved(url1: PackageRelativeUrl | ResolvedUrl, url2?: FileRelativeUrl): [ResolvedUrl | undefined, FileRelativeUrl | PackageRelativeUrl];
35 protected simpleUrlResolve(baseUrl: ResolvedUrl, url: FileRelativeUrl | PackageRelativeUrl, defaultProtocol: string): ResolvedUrl;
36 protected simpleUrlRelative(from: ResolvedUrl, to: ResolvedUrl): FileRelativeUrl;
37 protected brandAsFileRelative(url: string): FileRelativeUrl;
38 protected brandAsPackageRelative(url: string): PackageRelativeUrl;
39 protected brandAsResolved(url: string): ResolvedUrl;
40}