microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
161.73k stars 28.43k forks source link

[PWA] Register vscode.dev as file handler for well-supported file types #135784

Open digitarald opened 2 years ago

digitarald commented 2 years ago

Using the File Handling API, the vscode.dev PWA could register as handler for files (mime types and extensions); makin it easier to open, view, and edit files .

File Handling is currently in origin trials and slotted to ship in stable soon.

VS Code already has a list of file extensions for both Windows and macOS and could generate a file handler list from those entries.

cc @joaomoreno @bamurtaugh @thejohnjansen @captainbrosset

thejohnjansen commented 2 years ago

I'm tagging @diekus in this issue as well. He's the PM for file handlers. We've been working closely with Google on this one, and I know there are changes being planned because there are several very similar features, and we all want to make sure developers and end-users understand how they relate and how best to leverage them.

BenjaminAster commented 1 year ago

File Handling has been in stable Chrome & Edge for over half a year now (since Chromium version 102), so the API surface is very unlikely to change in the future. A code editor without the ability to open files directly from the operating system's file explorer is incomplete in my opinion.

I've worked with File Handling before; it integrates perfectly with the File System Access API that vscode.dev already uses.

Resources:

If you have any questions, please feel free to ask.

FossPrime commented 1 year ago

If anyone is interested... I was working on a PR for monaco to do this... Monaco is a lot easier to work on.

I got as far as injecting a working manifest, hosting it on github pages and getting it to sometimes work for opening JSON files from your computer's file manager.

Monaco doesn't really have examples of this sort of thing publically.. so a PR would only be visible to contributors. So I was thinking of publishing a mini sample app. I could do a PR for VSCode, but it would be limited to a handful of file types.

https://fossprime.github.io/monaco-editor/playground.html?source=v0.38.0#example-creating-the-editor-file-handlers

Manifest: https://github.com/FossPrime/monaco-editor/blob/main/website/static/manifest.json#L18

The PR needed for this would be about 50 lines of TS and JSON. I don't enjoy working on this... someone else please do make a PR :) (I hate the tooling with a passion... playwright, gyp, ripgrep, yarn proxy)

That said, it is not a hard PR to make... you don't need to run the bulking test framework, starting the web app's dev server wasn't too hard. You'll need to download about 3GB of random stuff and hijack your temp folder and the cache files for ripgrep and some weird enterprise proxy stuff. I also had to google some hacks for Playwright, but I had done that before so I know of its issues. All in this should be doable by someone with experience in less than an hour.

Screenshot 2023-06-03 19 34 47

I'll make a tiny PR to the manifest just to test the waters... i'm not sure how things work around here. I only need this for CSV, JSON, YAML and very basic js/ts... so monaco is more than enough and could have great spinoffs.

Also, I have no idea if theres a way to open folders... but that would be amazing, even better than what native VSCode can do right now. Not sure if it would PR though. If all else fails, there's always theia. Also, replit and stackblitz proved how far you can go with emacs tooling (dap-mode, typescript-language-server), monaco and a bit of courage.

FossPrime commented 1 year ago

The day is coming sooner than expected... If anyone wants to help make this a reality... https://github.com/kat-tax/vslite

It's got Node WebContainers in tow as well... So if Node is enough for you, you may not need WSL, Crostini or Docker.

digitarald commented 7 months ago

Brigit, not sure if this came up anywhere else, but might help to use vscode.dev as primary editor for some files.

(pardon the assignment noise)