UNPKG

1.89 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 } from 'polymer-analyzer';
15export declare class LocalFsPathBrand {
16 private LocalFsPathBrand;
17}
18export declare type LocalFsPath = string & LocalFsPathBrand;
19export declare class PosixPathBrand {
20 private PosixPathBrand;
21}
22export declare type PosixPath = string & PosixPathBrand;
23/**
24 * Returns a properly encoded URL representing the relative URL from the root
25 * to the target. This function will throw an error if the target is outside
26 * the root. We use this to map a file from the filesystem to the relative
27 * URL that represents it in the build.
28 */
29export declare function urlFromPath(root: LocalFsPath, target: LocalFsPath): PackageRelativeUrl;
30/**
31 * Returns a filesystem path for the url, relative to the root.
32 */
33export declare function pathFromUrl(root: LocalFsPath, url: PackageRelativeUrl): LocalFsPath;
34/**
35 * Returns a string where all Windows path separators are converted to forward
36 * slashes.
37 * NOTE(usergenic): We will generate only canonical Windows paths, but this
38 * function is exported so that we can create a forward-slashed Windows root
39 * path when dealing with the `sw-precache` library, which uses `glob` npm
40 * module generates only forward-slash paths in building its `precacheConfig`
41 * map.
42 */
43export declare function posixifyPath(filepath: LocalFsPath): PosixPath;