UNPKG

2.5 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 */
14/// <reference types="node" />
15import { Url } from 'url';
16import { FileRelativeUrl, PackageRelativeUrl, ScannedImport } from '../index';
17import { ResolvedUrl } from '../model/url';
18import { UrlResolver } from './url-resolver';
19/**
20 * Resolves package-relative urls to a configured root directory.
21 *
22 * For file-relative URLs it does the normal URL resolution algorithm relative
23 * to the base url.
24 *
25 * It does no remapping of urls in source to urls on the filesystem, but a
26 * subclass can override modifyFsPath for this purpose.
27 */
28export declare class FsUrlResolver extends UrlResolver {
29 private readonly host?;
30 protected readonly protocol: string;
31 protected readonly packageDir: string;
32 protected readonly packageUrl: ResolvedUrl;
33 constructor(packageDir: string | undefined, host?: string | undefined, protocol?: string);
34 resolve(firstHref: ResolvedUrl | PackageRelativeUrl, secondHref?: FileRelativeUrl, _import?: ScannedImport): ResolvedUrl | undefined;
35 protected shouldHandleAsFileUrl(url: Url): boolean;
36 /**
37 * Take the given URL which is either a file:// url or a url with the
38 * configured hostname, and treat its pathname as though it points to a file
39 * on the local filesystem, producing a file:/// url.
40 *
41 * Also corrects sibling URLs like `../foo` to point to
42 * `./${component_dir}/foo`
43 */
44 private handleFileUrl;
45 /**
46 * Overridable method, for subclasses that want to redirect some filesystem
47 * paths.
48 *
49 * @param fsPath An absolute path on the file system. Note that it will be
50 * OS-specific.
51 * @return An absolute path on the file system that we should resolve to.
52 */
53 protected modifyFsPath(fsPath: string): string;
54 relative(to: ResolvedUrl): PackageRelativeUrl;
55 relative(from: ResolvedUrl, to: ResolvedUrl, _kind?: string): FileRelativeUrl;
56 protected filesystemPathForPathname(decodedPathname: string): string;
57}
58
\No newline at end of file