mirror of
https://github.com/coder/code-server.git
synced 2026-06-22 18:07:10 +02:00
not finished
This commit is contained in:
45
packages/ide/src/uri.ts
Normal file
45
packages/ide/src/uri.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user