code-server/packages/ide/src/uri.ts
2019-02-05 11:15:42 -06:00

46 lines
754 B
TypeScript

export interface IURI {
readonly path: string;
readonly fsPath: string;
readonly scheme: string;
}
export interface IURIFactory {
/**
* Convert the object to an instance of a real URI.
*/
create<T extends IURI>(uri: IURI): T;
file(path: string): IURI;
parse(raw: string): IURI;
}
let activeUriFactory: IURIFactory;
/**
* Get the active URI factory
*/
export const getFactory = (): IURIFactory => {
if (!activeUriFactory) {
throw new Error("default uri factory not set");
}
return activeUriFactory;
};
/**
* Update the active URI factory.
*/
export const setUriFactory = (factory: IURIFactory): void => {
activeUriFactory = factory;
};
export interface IUriSwitcher {
strip(uri: IURI): IURI;
prepend(uri: IURI): IURI;
}