Skip to content

Commit

Permalink
Remove last dep on vscode for component API
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Jan 16, 2025
1 parent eb79789 commit c2f157a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/api/components/manager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import vscode from "vscode";

import IBMi from "../IBMi";
import { ComponentState, IBMiComponent } from "./component";

interface ExtensionContextI {
extension: {
id: string
}
}

export class ComponentRegistry {
private readonly components: Map<string, IBMiComponent[]> = new Map;

public registerComponent(context: vscode.ExtensionContext, component: IBMiComponent) {
const key = context.extension.id;
public registerComponent(context: ExtensionContextI|string, component: IBMiComponent) {
const key = typeof context === `object` ? context.extension.id : context;

if (typeof key !== `string`) {
throw new Error(`Invalid extension context.`);
}

const extensionComponents = this.components.get(key);
if (extensionComponents) {
extensionComponents.push(component);
Expand Down

0 comments on commit c2f157a

Please sign in to comment.