vscode-opa icon indicating copy to clipboard operation
vscode-opa copied to clipboard

Publish as web extension

Open anderseknert opened this issue 10 months ago • 5 comments

Web extensions are extensions that can be installed in the web interface for VS Code, such as presented in GitHub et. al.

While we can't do things like calling out to the OPA binary in this context, we could still provide basic features like syntax highlighting.

Note that extensions can be published both as a "desktop" version and a web one, which is what we'll want to do here. We don't want to limit the capabilities of the desktop one, so this would be a new additional part of the project.

More info here: https://code.visualstudio.com/api/extension-guides/web-extensions

(It's even possible to run a language server inside of a web worker, so we could compile Regal to Wasm (as @srenatus previously demonstrated) or if not that, at least the Regal policies, and have linting enabled too. But let's start with the basics)

anderseknert avatar Apr 09 '24 06:04 anderseknert

While we can't do things like calling out to the OPA binary in this context, we could still provide basic features like syntax highlighting.

It has to be tried, but if we can compile regal to Wasm and use it, then it should work for opa eval, too.

srenatus avatar Apr 09 '24 07:04 srenatus

That's true, but things like evaluation isn't covered by a language server, at least not without custom extensions. I guess it's possible to run parts of the client in Wasm too, and if so we could have OPA run there. Considering the size and performance of Regal compiled to Wasm last time we tried, perhaps a good middle ground, or at least first step, would be to compile the Regal policies only, and invoke those inside of the LSP web worker 🤔 Oh well, things may look very different when we get there.

anderseknert avatar Apr 09 '24 10:04 anderseknert

https://code.visualstudio.com/blogs/2023/06/05/vscode-wasm-wasi

anderseknert avatar Apr 22 '24 17:04 anderseknert

In response to:

TCP https://github.com/StyraInc/regal/issues/764 on the LSP server side won't solve the problem with connecting extensions from the Web?

It'd be part of it for sure, if we didn't go the WASM route, the other major parts to this as I understand it are:

  • something to read in the file contents (rather than just the open buffers), the local version of the server reads from disk.
  • some system of hosting a TCP Regal LS instance that supports multiple users. Even if this were to be a self hosted component, we'd need to think of a good way to make this available for users (container image etc.).

charlieegan3 avatar Aug 19 '24 15:08 charlieegan3

I think I accidentally deleted the comment

TCP support on the LSP server side won't solve the problem with connecting extensions from the Web?

nikpivkin avatar Aug 19 '24 15:08 nikpivkin