Commit Graph

104 Commits

Author SHA1 Message Date
Matt Bierner
989caf1849 Remove extra type 2022-03-17 11:56:38 -07:00
Matt Bierner
3268bbfb8a Move webview shared code to workbench/common instead of workbench-api
For #141921
2022-02-01 14:26:54 -08:00
Matt Bierner
12ff67ad9d Use SerializableObjectWithBuffers instead of spread
Fixes #137757
2021-12-10 17:20:44 -08:00
Matt Bierner
6902a65a76 Align ext host name with internal name 2021-11-09 16:47:00 -08:00
Matt Bierner
b85a272298 Fix csp for CDN extension locations
This rule needs to end in a `/` so that all files under the extension are allowed
2021-10-15 14:12:46 -07:00
Matt Bierner
29d0c902a6 Include extension cdn in webview.cspSource 2021-10-14 09:32:36 -07:00
Matt Bierner
0e52275271 Introduce WebviewOptions.forms
Fixes #132157
2021-09-02 13:24:49 -07:00
Matt Bierner
9847783f62 Remove uuid from webview resource uris
This is no longer be needed. We still serve the webview code itself from a unique subdomain

This also removes the need for `serviceWorkerFetchIgnoreSubdomain`
2021-05-21 09:28:43 -07:00
Matt Bierner
07a2aab8f2 Remove duplication around checking isRemote 2021-05-20 16:00:40 -07:00
Matt Bierner
18ea5ac15e Use isRemote instead of remote authority to determine where to load from 2021-05-20 11:30:43 -07:00
Matt Bierner
2270c36cff Use extension location instead of remote for asWebviewUri 2021-05-20 10:32:47 -07:00
Matt Bierner
1ddc623e58 Simplify logic for webview resource uris (#123740)
* Simplify logic for webview resource uris

This change attempts to simplify the logic around webview resource uris by doing the following:

- Hard code the resource origin. We always will be hitting a service worker for these paths so they don't need to be dynamic (although in the future we may want to pull them from `product.json`)

    This lets us remove these properties from the environment service

- Move remote handling from the resource loader in `asWebviewUri`.

- Remove the handling of http and https paths from the resource loader.

    I don't think these cases can be hit any longer (although I need to confirm this with more testing for the web case). Instead I added a check to `asWebviewUri` so that we return the original uri if a http(s) uri is passed in

* Restore normalizeResourcePath

We still need to convert between a remote uri and one that our remote file system can read

* Fix test

* Restore passing in remote on extension side

* Remove only
2021-05-19 17:26:51 -07:00
Matt Bierner
18a986bef5 Fixing array buffer serialization
Fixes #115807
2021-04-30 17:05:07 -07:00
Matt Bierner
3499f63dc1 Exploration: Better transferring of TypedArrays used in Webview.postMessage (#115664)
* Improve passing of ArrayBuffers to and from webviews

Fixes #115807

* Serialize and restore typed arrays too

This also makes it so that if you pass the same ArrayBuffer twice in an object, we use a single object on the receiver side too

* Fix spelling

* Require VS Code 1.56+
2021-03-30 06:49:34 +00:00
Matt Bierner
ea5f05a435 Trying to clairify how webview options are used and passed around
- Move protocol types into protocol
- Hold off on combining the options objects until serialization
- Add explicit converstions instead of using `...`
- Make a few methods take property bags to help avoid passing arguments in wrong order
2021-03-05 18:49:17 -08:00
Matt Bierner
d29fc5038a Make sure we dispose/track disposed webviews in webview views
Fixes #106826
2020-09-16 15:33:10 -07:00
Matt Bierner
23fe7a39de Split extHost webview panels to own file 2020-08-26 16:46:26 -07:00
Matt Bierner
72cbf699d8 Split out main thread webview panels into own class/file 2020-08-26 16:46:26 -07:00
Matt Bierner
7e4ccf1676 Rename WebviewPanelHandle -> WebviewHandle 2020-08-26 16:46:25 -07:00
Matt Bierner
79d7a9569d Undoing exthost side of the webview serializer split 2020-08-26 16:46:25 -07:00
Matt Bierner
4d88b39b7d Split up main thread webview services 2020-08-26 16:46:25 -07:00
Matt Bierner
daf5143e35 Split webview serializers into own ext host service 2020-08-20 16:45:45 -07:00
Matt Bierner
6db81f6ab2 Move custom editors into own ext host services 2020-08-20 16:45:45 -07:00
Matt Bierner
4fd7f660a4 Move webview views into own ext host class
Also fixes message passing for webview views
2020-08-20 16:45:45 -07:00
Matt Bierner
61f799f53b Add proposed webview view API (#104601)
Add proposed webview view API

For #46585

This adds a new `WebviewView` proposed api to VS Code that lets webview be used inside views. Webview views can be contributed using a contribution point such as :

```json
    "views": {
      "explorer": [
        {
          "type": "webview",
          "id": "cats.cat",
          "name": "Cats",
          "visibility": "visible"
        }
      ]
    },
```

* Use proper activation event

* Transparent background

* Fix resize observer

* Adding documentation

* Move webview view to new directory under workbench

* Remove resolver

By moving the webviews view into their own fodler, I was able to avoid the cycle the resolver was originally introduced for

* Use enum in more places

* Hook up title and visible properties for webview views

* Remove test view

* Prefer Thenable

* Add unknown view type error to collector
2020-08-20 13:59:22 -07:00
Johannes Rieken
43184b2bed add storageUri and globalStorageUri to ExtensionContext, https://github.com/microsoft/vscode/issues/101857 2020-07-09 12:48:03 +02:00
Matt Bierner
6fd6910527 Don't try getting a storage root for non-editable custom documents 2020-06-10 16:44:10 -07:00
Matt Bierner
50f907f0ba Add more strict typing for webview options
We can only send URI components over from the extension host to the renderer process. Make sure the typings reflect that

Follow up on #98746
2020-05-30 11:03:18 -07:00
Matt Bierner
4862602c4c Align custom editor API proposal with notebook API
Fixes #95854
Fixes #95849
For #77131

- Move all editing functionality back onto the provider. This better matches the notebook API.

- Rename `CustomEditorProvider` to `CustomReadonlyEditorProvider`.  `CustomEditorProvider` is now how editable custom editors are implemented

- Give extension a full suggested backup path instead of just a folder
2020-04-24 14:47:08 -07:00
Matt Bierner
f35758ab21 Rename supportsMultipleEditorsPerResource -> supportsMultipleEditorsPerDocument
For #77131
2020-04-23 17:33:06 -07:00
Matt Bierner
e0a4eec778 Rename some custom editor types/functions and introduce backup context
Fixes #95846
Fixes #95851
For #77131

- Rename `EditableCustomDocument` to `CustomEditableDocument`
- Rename `CustomDocumentBackup.dispose` to `CustomDocumentBackup.delete` to make it clearer how this is supposed to be used
- Rename `OpenCustomDocumentContext` to `CustomDocumentOpenContext`
- Add a context to backup. Pass in `workspaceStorageUri`
2020-04-23 16:32:56 -07:00
Matt Bierner
5913061e1b Allow a custom editor to opt out of supporting multiple instances for a single resource
#77131
2020-04-16 17:40:20 -07:00
Matt Bierner
5426f5ff70 Add CustomDocumentContentChangeEvent
For #77131

- Rename `onDidEdit` to `onDidChange`
- Allow custom editors to fire a `CustomDocumentContentChangeEvent` that only marks the editor as dirty but does not enable undo/redo. The only way for editor to get out of this dirty state is to either save or revert the file
2020-04-16 17:40:20 -07:00
Matt Bierner
d4ce7148dd New custom editor API proposal
For #77131

Fixes #93963
Fixes #94515
Fixes #94517
Fixes #94527
Fixes #94509
Fixes #94514
Fixes #93996
Fixes #93913

This removes explicit edits from the API and reshapes the API to more closely match VS Code's internal API. The change also tries to better express the lifecycle of backups
2020-04-08 17:53:39 -07:00
Matt Bierner
bd6ad5592f Check in saveAs cancellation 2020-04-01 17:22:37 -07:00
Matt Bierner
d41997790c Remove CustomDocument.viewType
Fixes #93867
For #77131

This property is no longer needed (or very helpful) with the current api design
2020-03-31 12:00:17 -07:00
Matt Bierner
f62784d7ac use private fields for webview panel
From #93608
2020-03-27 14:31:12 -07:00
Matt Bierner
2977047ebe Use private fields for most webview properties
#93608
2020-03-27 14:31:12 -07:00
Matt Bierner
ebb2030e1d Fixing some index bugs with edits api for custom editors 2020-03-23 14:54:47 -07:00
Matt Bierner
579dab3196 Update custom editor api
For #77131

- Use a class for `CustomDocument` instead of an interface. Extensions can now add their own data to a `CustomDocument` by sublassing

- Renamed `resolveCustomDocument` to `openCustomDocument` and require that extensions return a `CustomDocument`

- Exposed edits on `CustomDocument`

- Made the third parameter of `registerCustomEditorProvider` a generic options bag that takes a `webviewOptions`
2020-03-23 13:10:49 -07:00
Matt Bierner
7f6f3c28a6 Add cancellation parameter to custom editor resolve methods
Adds placeholder cancellation arguments to the custom editor api. These requests are currently never cancelled
2020-03-16 20:15:57 -07:00
Matt Bierner
041a5907b1 Add experimental moveCustomTextEditor hook
For #77131

Adds a hook that lets extensions preserve the webview for a custom editor across a rename
2020-03-13 17:49:52 -07:00
Matt Bierner
9dae408dc3 Switch webview api back to use delegate model
For #77131

Going back the the delegate based model for a few reasons:

- It gives us a better approach to add additional API hooks in the future (such as for rename)

- In practive, the capabilities were almost always the same as the `userData` on the document. It is rather confusing to have both `userData` and the capabilities 'on' the document
2020-03-12 16:54:48 -07:00
Matt Bierner
3ef02fe7b0 Use the UndoRedoService for CustomEditors (#92408)
* Use the UndoRedoService for CustomEditors

For #90110

Changes custom editors (the ones not based on text) to use the UndoRedoService. This involved:

- Moving edit lifecycle back into the main process again (this is actually the bulk of the changes)
- Removing the `undo`/`redo` methods on  `CustomEditorModel`
- Using the undoRedoService to trigger undo/redo
2020-03-12 11:34:40 -07:00
Matt Bierner
033a5d476f Add a revert method for custom editors
Fixes #91700
For #77131

Having an explicit revert method is a helpful signal that the extension should reload the changes from disk
2020-03-09 15:47:14 -07:00
Matt Bierner
077cd38d26 Add cancellation on CustomEditor.save
For #91702
2020-03-04 15:49:10 -08:00
Matt Bierner
44c76bd3b9 Rework management of custom editor custom models
Fixes #91670

- Move model type logic out of `CustomEditorInput` and into two different implementations of `ICustomEditorModel`
- Add `CustomTextEditorModel` that owns a proper model reference to a text document. This should ensure the text document is disposed of if there are no more references to it
- Move most of the previous `CustomEditorModel` into `mainThreadWebviews` directly. This removes some of the indirection that was previously required (such as using `waitUntil`)
2020-03-02 20:27:06 -08:00
Matt Bierner
4b046579d8 Using private fields for more in extHostWebviews 2020-02-28 14:45:35 -08:00
Matt Bierner
8ef18acdaf Don't require return value backup
Fixes #91703

All custom editors should implement backup or throw an exception if they cannot for some reason.
2020-02-27 11:55:39 -08:00
Matt Bierner
9d06f1bdd1 Better encapsulation of CustomDocument
- Prefer using private fields
- Explicitly mark internal hook method and prefix them with _
- Renaming
2020-02-26 10:59:36 -08:00