GordonSmith / vscode-ojs

VS Code extension for ObservableHQ notebooks
https://marketplace.visualstudio.com/items?itemName=GordonSmith.observable-js
MIT License
56 stars 5 forks source link

Add web extension support #52

Open gnestor opened 1 year ago

gnestor commented 1 year ago

It would be great if this extension could be installed and used in a browser context. The motivation is to be able to share notebooks with people by simply sharing a URL (assuming that the notebook is publicly available on Github or somewhere else that's accessible from vscode.dev). Additionally, in Zen Mode, VS Code notebooks look pretty approachable:

image

Currently, the Observable JS extension can't be installed from vscode.dev:

image

According to the docs: https://code.visualstudio.com/api/extension-guides/web-extensions#web-extension-enablement

VS Code automatically treats an extension as a web extension if:

  • The extension manifest (package.json) has browser entry point.
  • The extension manifest has no main entry point and none of the following contribution points: localizations, debuggers, terminal, typescriptServerPlugins.

If an extension wants to provide a debugger or terminal that also work in the web extension host, a browser entry point needs to be defined.

Some VS Code APIs are not available in a browser context so it may require a bit of refactoring, or not!

GordonSmith commented 1 year ago

FYI GitHub Blocks will allow this (in early access): OJS

GordonSmith commented 1 year ago

Which also allows you to write OJS to view other file types: DuckDB

gnestor commented 1 year ago

@GordonSmith Wait, you're blowing my mind right now! I signed up for the beta a while ago and still waiting for access. So it looks like you created some custom blocks, one for Observable notebooks and Data File Preview which renders specific file types (like CSV and Parquet) and uses the Observable runtime to provide table preview, data wrangler, etc., is that correct? This is a game-changer for Github! It seems like Blocks is not intended for editing though, so if you wanted to share a notebook with someone and allow them to edit, they would need to download and install VS Code. If this extension worked in the browser (web extension), then notebooks could be easily edited in the browser.

GordonSmith commented 1 year ago

@gnestor - correct, FWIW the blocks API does support editing, but recreating a functional notebook UI is a bit of work... Mind you supporting an editable OMD document wouldn't be hard...