A high-level build construct to define a VSCode Extension.

const myExt = new VSCodeExtension({  main: x9.root(''),});

Commands

Commands are tricky to implement in VSCode because (most commands) need to be defined in two places:

As your extension grows, this is a source of trouble

In x9, we provide a little helper for this

// must be a top-level declaration

const openFileCommand = new x9.vscode.Command<string, void>({
  command: extensionId + ".open",
  title: "Open File",
  category: "Acme Files",
})
// bonus: you can extract this to its own const
const extensionId = "acme.fileopener"

Then, within your extension activation code you can use it like this:

export function activate(ctx) {
  //  this will call vscode.commands.registerCommand

  openFileCommand.register((file) => {
    // file is correctly typed
    console.log("opening file")
  })
}

When building your vscode extension, any commands that are actually used by your extension will be added automatically to your extension’s package.json. Just more cool dragon stuff :)

Adding TreeViews using React