• M
    Add experimental service-worker based loading of webview content · 1319038e
    Matt Bierner 提交于
    ## Problem
    We use a custom `vscode-resource` protocol to control access to local resources inside of webviews. This will not work on the web, but we still would prefer a way to intercept webview requests from the main client
    
    ## Proposed solution
    Move webviews into their own origin and register a service worker on this origin. This service worker can talk with the outer iframe of our webview. When a request for a resource comes in to the service worker:
    
    * In the service worker, add the request to a map and post a message back to the client saying we want to load this resource
    * The outer iframe gets the message from the sercice worker and forwards it to our main process
    * This process handles the message and use the normal file system api to read the resource (also restricting which files can be read)
    * We post the result back into the inner iframe which fowards it back to the service worker
    * The service worker now resolves the pending request.
    
    The prototype version in this change works but does not correctly handle multiple clients existing at the same time (plus probably a lot of other edge cases too)
    1319038e
web.main.ts 8.7 KB