-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add InvokeNew, GetValue & SetValue to JS interop API #61246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
df3822f
WIP implementation with JSInvocationInfo
oroztocil bdea46d
WIP implementation for other platforms, fix tests
oroztocil 8e51e9c
Fix function calls, add JS tests
oroztocil f227e09
Add JS interop tests
oroztocil 9717446
Add new interop methods to InProcessRuntime
oroztocil 1c525a4
Merge remote-tracking branch 'origin/main' into oroztocil/js-interop-…
oroztocil e653a00
WIP wasm & webview fixes
oroztocil 4009275
WebView test fixes
oroztocil 5e273e3
Add DotNetToJSInterop component to BasicTestApp
oroztocil 0443be5
Merge remote-tracking branch 'origin/main' into oroztocil/js-interop-…
oroztocil 951de51
WIP add E2E tests for new interop methods
oroztocil 7056120
Add & fix E2E tests for interop
oroztocil 200d736
Merge remote-tracking branch 'origin/main' into oroztocil/js-interop-…
oroztocil e7294ce
Add test for reading JS property from prototype
oroztocil 42617e4
Remove debug prints and unwanted changes
oroztocil 21caedd
Remove unwanted indentation changes in legacy code
oroztocil c7f49d6
Fix API, remove uneeded files
oroztocil 93d3006
Add missing extension overloads, clean up code
oroztocil 2508129
Rollback unwanted changes
oroztocil 45260dd
Revert submodule to origin/main state
oroztocil 5270dd8
Merge remote-tracking branch 'origin/main' into oroztocil/js-interop-…
oroztocil c6934f6
Rollback unwanted changes in submodule
oroztocil c13223b
Fix Microsoft.JSInterop tests
oroztocil 2f84ea0
Code review fixes
oroztocil 28c8d39
Minor code review changes
oroztocil 1d8495c
Remove JSInvocationInfo from interop bridge communication
oroztocil b79f224
Refactor resolving JS object members, fix tests
oroztocil bd0ea2b
Remove unused overloads from PublicAPI.Unshipped.txt
oroztocil 802f96a
Revert unwanted changes, fix style
oroztocil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 22 additions & 2 deletions
24
src/Components/Endpoints/src/DependencyInjection/UnsupportedJavaScriptRuntime.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using Microsoft.JSInterop; | ||
using static Microsoft.AspNetCore.Internal.LinkerFlags; | ||
|
||
namespace Microsoft.AspNetCore.Components.Endpoints; | ||
|
||
internal sealed class UnsupportedJavaScriptRuntime : IJSRuntime | ||
{ | ||
private const string Message = "JavaScript interop calls cannot be issued during server-side static rendering, because the page has not yet loaded in the browser. Statically-rendered components must wrap any JavaScript interop calls in conditional logic to ensure those interop calls are not attempted during static rendering."; | ||
|
||
public ValueTask<TValue> InvokeAsync<TValue>(string identifier, CancellationToken cancellationToken, object?[]? args) | ||
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier, CancellationToken cancellationToken, object?[]? args) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
ValueTask<TValue> IJSRuntime.InvokeAsync<TValue>(string identifier, object?[]? args) | ||
ValueTask<TValue> IJSRuntime.InvokeAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier, object?[]? args) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask<IJSObjectReference> InvokeNewAsync(string identifier, object?[]? args) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask<IJSObjectReference> InvokeNewAsync(string identifier, CancellationToken cancellationToken, object?[]? args) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask<TValue> GetValueAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask<TValue> GetValueAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier, CancellationToken cancellationToken) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask SetValueAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier, TValue value) | ||
=> throw new InvalidOperationException(Message); | ||
|
||
public ValueTask SetValueAsync<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string identifier, TValue value, CancellationToken cancellationToken) | ||
=> throw new InvalidOperationException(Message); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#nullable enable | ||
Microsoft.AspNetCore.Components.Web.Internal.IInternalWebJSInProcessRuntime.InvokeJS(in Microsoft.JSInterop.Infrastructure.JSInvocationInfo invocationInfo) -> string! | ||
virtual Microsoft.AspNetCore.Components.Routing.NavLink.ShouldMatch(string! uriAbsolute) -> bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/Components/WebAssembly/JSInterop/src/PublicAPI.Unshipped.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
#nullable enable | ||
override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.BeginInvokeJS(in Microsoft.JSInterop.Infrastructure.JSInvocationInfo invocationInfo) -> void | ||
override Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeJS(in Microsoft.JSInterop.Infrastructure.JSInvocationInfo invocationInfo) -> string! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.