Skip to content

Commit d4603f6

Browse files
authored
Add JavaScript API to template
Add prompts and guidance for JavaScript sample code and JavaScript API reference documentation to the template.
1 parent ab8420c commit d4603f6

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

specs/template.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ _(This is conceptual documentation that will go to learn.microsoft.com "how to"
9797
example code with each description in both C# (for our WinRT API or .NET API) and
9898
in C++ for our COM API. Use snippets of the sample code you wrote for the sample apps.
9999
The sample code for C++ and C# should demonstrate the same thing.
100+
If you are introducing a JavaScript API or otherwise the sample relies on HTML or JS
101+
include that and consider including it in its own HTML or JS sample code.
102+
103+
As an example of this section, see the Examples section for the Custom Downloads
104+
APIs (https://github.com/MicrosoftEdge/WebView2Feedback/blob/master/specs/CustomDownload.md).
100105
101106
The general format is:
102107
@@ -120,6 +125,14 @@ _(This is conceptual documentation that will go to learn.microsoft.com "how to"
120125
}
121126
```
122127
128+
If the sample code requires JS or HTML include that as well
129+
130+
```html
131+
<script>
132+
chrome.webview.postMessage(...);
133+
</script>
134+
```
135+
123136
## SecondFeatureName
124137
125138
Feature explanation text goes here, including why an app would use it, how it
@@ -140,8 +153,15 @@ _(This is conceptual documentation that will go to learn.microsoft.com "how to"
140153
}
141154
```
142155
143-
As an example of this section, see the Examples section for the Custom Downloads
144-
APIs (https://github.com/MicrosoftEdge/WebView2Feedback/blob/master/specs/CustomDownload.md).
156+
157+
If the sample code requires JS or HTML include that as well
158+
159+
```html
160+
<script>
161+
chrome.webview.postMessage(...);
162+
</script>
163+
```
164+
145165
-->
146166

147167
# API Details
@@ -194,6 +214,33 @@ namespace Microsoft.Web.WebView2.Core
194214
}
195215
}
196216
```
217+
218+
If you are introducing a WebView2 JavaScript API include the TypeScript
219+
definition of that API and reference documentation for it as well.
220+
You can use https://www.typescriptlang.org/play to verify your TypeScript
221+
222+
```ts
223+
interface WebView extends EventTarget {
224+
postMessage(message: any) : void;
225+
hostObjects: HostObjectsAsyncRoot;
226+
// ...
227+
}
228+
229+
interface HostObjectsAsyncRoot {
230+
cleanupSome() : void;
231+
options: HostObjectsOptions;
232+
}
233+
234+
interface HostObjectsOptions {
235+
forceLocalProperties: string[];
236+
log: (...data: any[]) => void;
237+
shouldSerializeDates: boolean;
238+
defaultSyncProxy: boolean;
239+
forceAsyncMethodMatches: RegExp[];
240+
ignoreMemberNotFoundError: boolean;
241+
}
242+
```
243+
197244
-->
198245

199246

0 commit comments

Comments
 (0)