Skip to content

Rework Webview.resourceRoot api proposal #76489

@mjbvz

Description

@mjbvz

Follow up on #72155

The current Webview.resourceRoot api proposal is problematic for a few reasons:

  • It's easy to use the value incorrectly, especially when dealing with windows (or, even more fun, windows networked drives!)
  • It exposes too much of the implementation detail to extensions, which means that we don't have enough freedom to change the implementation

This iteration, I'd like to revise this API proposal and be closer an idea brought up in #72155:

export interface Webview {
    /** Convert a file uri to a webview uri */
    toResource(resource: Uri): Thenable<Uri>;

   readonly cspRoot: Thenable<string>;
}

The important bits are:

  • Encapsulate all the complexity of going from a file uri to a webview URI inside a function
  • Add an explicit cspRoot property instead of trying to shoehorn this into toResource.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions