-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help extensions adopt asWebviewUri
#97962
Comments
wow @mjbvz I see you had a busy Friday night :) I wonder if it's time we create webview channel in vscode ext. devs slack for you to join and make major announcements on these api changes to keep us in the loop, or some email subscription list. There must be a better way to do this without so much effort on your part in addition to resolving those issues on vscode api's end. In any case, I appreciate you looking into this and updating us with a recipe to fix it. Thanks! |
Appreciate that you took the time to notify so many extensions. I just looked at the API and found out that |
@dzhavat Yes sorry I got the year wrong when writing the message. To clarify, here's what is required to get If your extension gets
If your extension gets
In both cases, you should be able to safely update your extension to require VS Code 1.38+ without leaving many users behind. A very high percentage of VS Code users are on either current stable release or the previous release. We on VS Code also only support current release |
Closing this issue since there's not much more to do from the VS Code side. All of our examples and documentation should now be using |
Background
Back when webviews first shipped with VS Code, we used
vscode-resource:
uris to load local resources. For example:The
vscode-resource
format however has a few important issues:It does not specify the scheme used to load the resources.
This prevents
vscode-resrouce
from being used to read resources from custom VS Code file systems.vscode-resource:
does not work on web.VS Code has to rewrite
vscode-resource
uris. This rewriting is not complete.vscode-resource
will also not work with new builds of VS Code that that replacevscode-resource
with a new protocol: Add vscode-webview-resource protocol #97777We again have to rewrite uris.
To fix these issues, a while back we introduced the
Webview.asWebviewUri
helper function. This function takes a local uri and returns a uri that can be used inside a webview to load that resource.However a number of extensions are still using hardcoded
vscode-resoruce:
uris. We have already added a warning if you usevscode-resource:
: #81685Fix
If your extension is using
vscode-resource:
to load resources—scripts, css, images, ...—switch to instead use theWebview.asWebviewUri
function.If your extension is using
vscode-resource:
in a content security policy, replacevscode-resource:
withWebview.cspSource
Make sure your code always calls
asWebviewUri
andcspSource
when generating html. These values may change between VS Code version, so it is import that you do not cache these valuesIf you see issues after making these changes, please file a new issue against VS Code and I'll take a look.
The text was updated successfully, but these errors were encountered: