Coder Social home page Coder Social logo

browserinterop's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar redradist avatar remibou avatar thepra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browserinterop's Issues

Android Chrome support

I can't run geolocation on android chrome (ver. 86.0.4240.198). Dotnet 5.0

var window = await jsRuntime.Window();
var navigator = await window.Navigator(); //error line

Android firefox is OK. Can anyone check it out?

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Unhandled exception in circuit '3jXC60Frj0Yr97Nesw5jzNAZn8pqDWoTx22ACo9osDo'.
Microsoft.JSInterop.JSException: An exception occurred executing JS interop: The JSON value could not be converted to System.Double. Path: $.connection.downlinkMax | LineNumber: 0 | BytePositionInLine: 267.. See InnerException for more details.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Double. Path: $.connection.downlinkMax | LineNumber: 0 | BytePositionInLine: 267.
---> System.InvalidOperationException: Cannot get the value of a token type 'String' as a number.
at System.Text.Json.Utf8JsonReader.TryGetDouble(Double& value)
at System.Text.Json.Utf8JsonReader.GetDouble()
at System.Text.Json.Serialization.Converters.DoubleConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.JsonConverter`1.ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadValueCore[TValue](JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
at Microsoft.JSInterop.JSRuntime.EndInvokeJS(Int64 taskId, Boolean succeeded, Utf8JsonReader& jsonReader)
--- End of inner exception stack trace ---
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at BrowserInterop.Extensions.BrowserInteropJsRuntimeExtension.GetInstanceProperty[T](IJSRuntime jsRuntime, JsRuntimeObjectRef jsObjectRef, String propertyPath, Object serializationSpec)
at BrowserInterop.Extensions.BrowserInteropJsRuntimeExtension.GetInstancePropertyWrapper[T](IJSRuntime jsRuntime, JsRuntimeObjectRef jsObjectRef, String propertyPath, Object serializationSpec)
at BrowserInterop.WindowInterop.Navigator()
at HAWebClient.Pages.Test.GetGeolocation() in C:\projekty\HolyAttendanceMobile\HAWebClient\HAWebClient\Pages\Test.razor:line 32
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

JavaScript interop calls cannot be issued at this time - problem and solution

That code can be executed not correctly:

protected override async Task OnInitialized()
{
var window = await jsRuntime.Window();
}

In that case, you will get the error:

JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendererd. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method.

In most cases, it can be easily solved when we will move that to another method that is executed later.

Uncaught (in promise) DOMException: The operation is insecure.

On firefox I have endless console error logs about this, the interested section in the script.js is at the line 183:

for (var i in data) {
    var currentMember = data[i]; // <- This line

    if (typeof currentMember === 'function' || currentMember === null) {
        continue;
    }
   //...
}

Can you figure out how to make it scream this log?

alerts by chrome

I am trying to recover my GPS position and receive these alerts from the chrome browser.

scripts.js:183 [Deprecation] 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.

scripts.js:238 [Violation] Only request geolocation information in response to a user gesture.

WindowVisualViewPort

The Window page in the sample app throws a JSON error (Chrome 84).

The properties in WindowVisualViewPort needs to be changed to doubles.

Public API review

Here I track progress on public API review

  • Naming consistency
  • "Interop" suffix
  • "Async" suffix
  • Public members listing
  • Expose interface
  • Namespace/inner classes

Documentation

Here I track the documentation progress toward v1 release

  • Improve utilities documentation
  • Review "getting started" documentation

document API

This issue is here for tracking document API that will be wrapped. The purpose is to target all API that provide informations not already available in Blazor

  • document.characterSet
  • document.compatMode
  • document.contentType
  • document.doctype
  • document.implementation
  • document.visibilityState
  • document.xmlEncoding
  • document.cookie
  • document.designMode
  • document.dir
  • document.astModified
  • document.readyState
  • document.referrer
  • document.title
  • document.onfullscreenchange
  • document.onvisibilitychange
  • document.onreadystatechange

Window events

Item for tracking progress on window event wraping. Here is the list of event I plan on implementing :

  • window.onappinstalled
  • Window.onbeforeinstallprompt
  • Window.ondevicemotion
  • Window.ondeviceorientation
  • onorientationchange
  • WindowEventHandlers.onafterprint
  • WindowEventHandlers.onbeforeprint
  • WindowEventHandlers.onbeforeunload
  • GlobalEventHandlers.onblur
  • GlobalEventHandlers.onclose
  • GlobalEventHandlers.oncontextmenu
  • GlobalEventHandlers.onerror
  • GlobalEventHandlers.onfocus
  • WindowEventHandlers.onhashchange
  • WindowEventHandlers.onlanguagechange
  • GlobalEventHandlers.onload=
  • WindowEventHandlers.onoffline
  • WindowEventHandlers.ononline
  • WindowEventHandlers.onpagehide
  • WindowEventHandlers.onpageshow
  • WindowEventHandlers.onpopstate
  • GlobalEventHandlers.onresize
  • GlobalEventHandlers.onscroll
  • GlobalEventHandlers.onwheel
  • WindowEventHandlers.onstorage
  • WindowEventHandlers.onunload

Documentation https://developer.mozilla.org/en-US/docs/Web/API/Window#Events

`JsRuntime` is null on dispose on `JsObjectWrapperBase`

When I dispose my JsObjectWrapperBase-derived object in the DisposeAsync of a component, I get an exception that JsRuntime is null. The problem is from there:

public class JsRuntimeObjectRef : IAsyncDisposable
  {
    internal IJSRuntime JsRuntime { get; set; }

    [JsonPropertyName("__jsObjectRefId")]
    public int JsObjectRefId { get; set; }

    public async ValueTask DisposeAsync()
    {
      JsRuntimeObjectRef runtimeObjectRef = this;
	  // HERE: runtimeObjectRef.JsRuntime is null in the next line
      await JSRuntimeExtensions.InvokeVoidAsync(runtimeObjectRef.JsRuntime, "browserInterop.removeObjectRef", new object[1]
      {
        (object) runtimeObjectRef.JsObjectRefId
      }).ConfigureAwait(false);
      GC.SuppressFinalize((object) runtimeObjectRef);
    }
  }

Not sure what might be causing this, it's not null in the object itself, so I added this method to my object:

    public new async ValueTask DisposeAsync()
    {
        // NOTE: For some reason JsObjectRef's JsRuntime is null in DisposeAsync, so this is copied from there
        await JsRuntime.InvokeVoidAsync("browserInterop.removeObjectRef", new object[1]
        {
            JsObjectRef.JsObjectRefId
        });
        GC.SuppressFinalize(JsObjectRef);
        GC.SuppressFinalize(this);
    }

I'm using Blazor WASM 6.0.6 on .NET 6.

SetJSRuntime inconsistent

In the code the casing of SetJSRuntime is inconsistent mixture of SetJSRuntime/SetJsRuntime; please consider using consistent casing and/or using an interface/abstract class to enforce the standard.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.