import { Range } from 'vscode-languageserver-types'; import { AbsoluteRepoFile, PositionSpec, RangeSpec, RenderModeSpec, RepoFile, ViewStateSpec } from '../repo'; /** * Represents a line, a position, a line range, or a position range. It forbids * just a character, or a range from a line to a position or vice versa (such as * "L1-2:3" or "L1:2-3"), none of which would make much sense. * * 1-indexed. */ export declare type LineOrPositionOrRange = { line?: undefined; character?: undefined; endLine?: undefined; endCharacter?: undefined; } | { line: number; character?: number; endLine?: undefined; endCharacter?: undefined; } | { line: number; character?: undefined; endLine?: number; endCharacter?: undefined; } | { line: number; character: number; endLine: number; endCharacter: number; }; /** * Tells if the given fragment component is a legacy blob hash component or not. * * @param hash The URL fragment. */ export declare function isLegacyFragment(hash: string): boolean; /** * Parses the URL fragment (hash) portion, which consists of a line, position, or range in the file, plus an * optional "viewState" parameter (that encodes other view state, such as for the panel). * * For example, in the URL fragment "#L17:19-21:23$foo:bar", the "viewState" is "foo:bar". * * @template V The type that describes the view state (typically a union of string constants). There is no runtime * check that the return value satisfies V. */ export declare function parseHash(hash: string): LineOrPositionOrRange & { viewState?: V; }; /** * Returns the LineOrPositionOrRange and given URLSearchParams as a string. */ export declare function formatHash(lpr: LineOrPositionOrRange, searchParams: URLSearchParams): string; export declare function lprToRange(lpr: LineOrPositionOrRange): Range | undefined; /** * @param ctx 1-indexed partial position or range spec */ export declare function toPositionOrRangeHash(ctx: { position?: { line: number; character?: number; }; range?: { start: { line: number; character?: number; }; end: { line: number; character?: number; }; }; }): string; /** Encodes a repository at a revspec for use in a URL. */ export declare function encodeRepoRev(repo: string, rev?: string): string; /** * Encodes rev with encodeURIComponent, except that slashes ('/') are preserved, * because they are not ambiguous in any of the current places where used, and URLs * for (e.g.) branches with slashes look a lot nicer with '/' than '%2F'. */ export declare function escapeRevspecForURL(rev: string): string; export declare function toViewStateHashComponent(viewState: string | undefined): string; /** * Returns the URL path for the given repository name. * * @deprecated Obtain the repository's URL from the GraphQL Repository.url field instead. */ export declare function toRepoURL(repoName: string): string; export declare function toPrettyBlobURL(ctx: RepoFile & Partial & Partial & Partial & Partial): string; export declare function toAbsoluteBlobURL(ctx: AbsoluteRepoFile & Partial & Partial & Partial): string; export declare function toTreeURL(ctx: RepoFile): string; /** * Correctly handle use of meta/ctrl/alt keys during onClick events that open new pages */ export declare function openFromJS(path: string, event?: MouseEvent): void; //# sourceMappingURL=url.d.ts.map