alibaba / alibaba/serverless-vscode

Adopt VS Code's 'asWebviewUri' API

Open
#232 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
289
Forks
38
PR merge metrics
No merged PRs in 30d

Description

Hi, I maintain VS Code's Webview API

## Issue
Our telemetry suggests that your extension uses webviews and may be loading resources in these webviews using hardcoded `vscode-resource:` URIs. These URIs have some important limitations and don't work properly when VS Code is run in a browser. We are also making changes in the desktop version of VS Code that may cause these URIs to not work properly in future versions of VS Code.

While we are making our best effort to continue support existing webview extensions that use `vscode-resource:` URIs on desktop versions of VS Code, we will not able to fully support all uses cases.

## Fix
To ensure that your extension continues to work in as many environments as possible—including on web and remotely—please:

- Switch to use the [`Webview.asWebviewUri` function](https://github.com/microsoft/vscode/blob/307cb32f306a527a30a5b1756e8bf548c141192c/src/vs/vscode.d.ts#L6703) for loading resources.

- Switch to use the [`Webview.cspSource` property](https://github.com/microsoft/vscode/blob/307cb32f306a527a30a5b1756e8bf548c141192c/src/vs/vscode.d.ts#L6714) in content security policies.

These APIs shipped around 2 years ago so they should be available in all modern versions of VS Code. You can find additional information about the issue here: https://github.com/microsoft/vscode/issues/97962

Let me know if you have any questions about this change

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the extension for hardcoded `vscode-resource:` URIs and webview content security policies. Replace resource and CSP handling with the VS Code webview APIs described in the issue, then verify the extension's webviews in desktop, web, and remote VS Code environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.