2024-07-11 12:42:23 +08:00
|
|
|
import * as vscode from 'vscode';
|
2024-07-01 12:25:28 +08:00
|
|
|
import QuickAccessTreeProvider from './views/quick-access-tree';
|
2024-07-16 23:28:56 +08:00
|
|
|
import DSHome from './home';
|
2025-02-25 11:43:06 +08:00
|
|
|
import {openProjectWithoutLogging} from './remote-container';
|
2024-06-27 01:20:37 +08:00
|
|
|
|
2024-09-18 13:52:19 +08:00
|
|
|
export class DevStarExtension {
|
2024-07-16 23:28:56 +08:00
|
|
|
dsHome: DSHome;
|
2024-06-27 01:20:37 +08:00
|
|
|
|
2024-07-02 12:15:39 +08:00
|
|
|
constructor(private context: vscode.ExtensionContext) {
|
2024-07-16 23:28:56 +08:00
|
|
|
this.dsHome = new DSHome(context);
|
2024-06-27 01:20:37 +08:00
|
|
|
|
2025-02-19 10:16:46 +08:00
|
|
|
this.registerGlobalCommands(context);
|
|
|
|
|
|
|
|
const handler = vscode.window.registerUriHandler({
|
|
|
|
handleUri: async (uri: vscode.Uri) => {
|
|
|
|
if (uri.path === '/openProject') {
|
|
|
|
const params = new URLSearchParams(uri.query);
|
|
|
|
const host = params.get('host');
|
|
|
|
const port = params.get('port');
|
|
|
|
const username = params.get('username');
|
|
|
|
const path = params.get('path');
|
|
|
|
|
2025-02-25 11:43:06 +08:00
|
|
|
if (host && port && username && path) {
|
|
|
|
await openProjectWithoutLogging(host, parseInt(port, 10), username, decodeURIComponent(path))
|
|
|
|
|
2025-02-19 10:16:46 +08:00
|
|
|
} else {
|
|
|
|
vscode.window.showErrorMessage('Missing required parameters.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
context.subscriptions.push(handler);
|
|
|
|
|
2024-07-02 12:15:39 +08:00
|
|
|
context.subscriptions.push(
|
2024-06-27 01:20:37 +08:00
|
|
|
vscode.window.registerTreeDataProvider(
|
2024-07-16 23:28:56 +08:00
|
|
|
'devstar.quickAccess',
|
2024-06-27 01:20:37 +08:00
|
|
|
new QuickAccessTreeProvider()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-09-18 13:52:19 +08:00
|
|
|
this.startDevStarHome();
|
2024-06-27 01:20:37 +08:00
|
|
|
}
|
|
|
|
|
2024-09-18 13:52:19 +08:00
|
|
|
async startDevStarHome() {
|
2024-07-16 23:28:56 +08:00
|
|
|
vscode.commands.executeCommand('devstar.showHome');
|
2024-06-27 01:20:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-07-02 12:15:39 +08:00
|
|
|
registerGlobalCommands(context: vscode.ExtensionContext) {
|
|
|
|
context.subscriptions.push(
|
2024-07-16 23:28:56 +08:00
|
|
|
vscode.commands.registerCommand('devstar.showHome', (url: string) =>
|
|
|
|
this.dsHome.toggle(url)
|
2025-02-25 11:43:06 +08:00
|
|
|
)
|
2024-06-27 01:20:37 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-02 12:15:39 +08:00
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
2024-09-18 13:52:19 +08:00
|
|
|
return new DevStarExtension(context);
|
2024-06-27 01:20:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function deactivate() {
|
|
|
|
}
|