Giter Site home page Giter Site logo

jspuij / twokab Goto Github PK

View Code? Open in Web Editor NEW
133.0 133.0 16.0 6.46 MB

Blazor WebView control for WPF, Android, macOS, iOS. Run Blazor on .NET Core and Mono natively inside a Webview.

Home Page: https://jspuij.github.io/BlazorWebView.Docs/pages/index.html

License: Apache License 2.0

C# 49.15% TypeScript 42.13% JavaScript 1.07% C++ 3.25% CMake 0.31% Batchfile 0.22% HTML 3.88%

twokab's People

Contributors

chucker avatar dependabot[bot] avatar jspuij avatar vanderstack 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  avatar  avatar  avatar  avatar

twokab's Issues

'RemoteNavigationManager' has not been initialized

We are trying to convert our electron app to BlazorWebView and our index page and other components requires the NavigationManager. The app fails with the default "An unhandled error has occured" and when running with "Just My Code" disabled - we can see the following exception

System.InvalidOperationException HResult=0x80131509 Message='RemoteNavigationManager' has not been initialized. Source=Microsoft.AspNetCore.Components StackTrace: at Microsoft.AspNetCore.Components.NavigationManager.AssertInitialized() in /_/src/Components/Components/src/NavigationManager.cs:line 223

Any suggestions?

Slow when first loading with wpf

I used the default sample. However, I found that unless I wait a few minutes to do something, when i click the counter for example, it does nothing for quite a while and i can't navigate to any of the other pages. Hopefully there is a way to improve startup performance so when the page loads and you go to the counter page, then its responsive right away.

Help: MSB3030 Could not copy the file `obj\Debug\netstandard2.1\compressed\_framework\_bin\Azure.Core.dll.br" because it was not found`

Severity Code Description Project File Line Suppression State
Error MSB3030 Could not copy the file ".................\Prod\AdminWebUI\obj\Debug\netstandard2.1\compressed_framework_bin\Azure.Core.dll.br" because it was not found. WpfHostAdminWebUI C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 4651

AdminWebUI is the target client side blazor app
WpfHostAdminWebUI is the wrapper wpf app following the steps in the "How to do on Windows"

Win 10 Pro x64
Visual Studio 2019 6.4 (or 6.5) Pro

Rinse and repeat error for every dll that is gz compressed within AdminWebUI\bin\Debug\netstandard2.1\wwwroot\_framework\_bin

Native Preview 7 not on nuget

I was trying to use the preview 7 for wpf. However, it would not allow me to use it because it required preview 7 of the native but that never showed on nuget.

Problem with registering CustomEventArgs

Hello, first at all Great Project.
Second does this Blazor version supports registering custom EventArgs using Blazor.registerCustomEventType(). I doubt it, since i get always an Error saying " Blazor.registerCustomEventType is not a function". But maybe i am wrong.

   <script src="framework://blazor.desktop.js"></script>

   <script>
           Blazor.registerCustomEventType('customevent',
               {
                   browserEventName: 'click',
                   createEventArgs: e => {
                       return {
                           //currentTarget = e.currentTarget,
                           //target = e.target
                           test: "BLBLA"
                       }
                   }
               });
   </script>

local web server server development doesn't seem to work

I have my web application running on http://localhost:8080

I had attempted
this.run = BlazorWebViewHost.Run(this.BlazorWebView, "http://localhost:8080");
OR
this.run = BlazorWebViewHost.Run(this.BlazorWebView, "wwwroot/index.html");
this.BlazorWebView.NavigateToUrl("http://localhost:8080");

I wanted to simply point the webview at my local server as my webapp has hot reloading for fast development, but it seems the web view only serves local files.

Handle wwwroot packaging on android.

Android does not support copying the wwwroot folder into the APK. You need to add your assets to the "Assets" folder for the android apk mechanism to pick them up. More importantly there are naming restrictions to the assets (no double dots in file names, no uppercase chars).

Best way seems to be to zip the assets before build. Then unzip the asset on first application startup.

Todo:

  • unzip only on first start of new build (date check?).
  • Add build task to nuget.

Hiding until render?

Is there a simple way to hide the view until it's fully rendered?

My window is dark so it's a bit jarring to have a white screen show up just before loading in. I see some messaging functions but I'm not really sure how to use them. I could have a guess timer but I'd like to do it properly if possible.

(I'm using it in WPF)

''RemoteNavigationManager' has not been initialized.'

We are trying to convert our electron app to BlazorWebView and our index page and other components requires the NavigationManager. The app fails with the default "An unhandled error has occured" and when running with "Just My Code" disabled - we can see the following exception

System.InvalidOperationException HResult=0x80131509 Message='RemoteNavigationManager' has not been initialized. Source=Microsoft.AspNetCore.Components StackTrace: at Microsoft.AspNetCore.Components.NavigationManager.AssertInitialized() in /_/src/Components/Components/src/NavigationManager.cs:line 223

Any suggestions?

Crash on windows 7

For an example, I chose this solution: https://github.com/jspuij/BlazorWebViewTutorial/tree/5_wpf
I created a configuration for publishing an application something like this:
image
Output: image
Information about installed browser etc:
image
I got an exception when I run the application on Windows 7 inside the MainWindow constructor when calling the “InitializeComponent” method:
err_log

Question: BlazorWebView and ApiAuthorization

I'm looking if BlazorWebView is a possible path to display a blazor wasm app inside a Wpf application. My blazor wasm app runs fine inside the browser, but we want to provide integration inside an existing Wpf application by showing this blazor app inside a dockable window. At the moment I use an embedded browser (FireFox / GeckoFX) control, but the BlazorWebView way looks a better solution to me.

If I try to start the blazor app I get exceptions from the Microsoft.AspNetCore.Components.WebAssembly.Authentication Api authorization components because it tries to connect to a non http(s) scheme.

Any idea if it is possible to get this to work?

Race condition in BlazorWebViewHost.cs intermittently prevents web window from opening

This is the same issue as I found with SteveSanderson's web window.

I found a race condition and isolated it to line 148 of BlazorWebViewHost.cs. If you insert a Thread.Sleep(2000) you will see it consistently as the task on line 143 does not get through enough initialization before the code on line 160 WebWindow.NavigateToUrl(BlazorAppScheme + "://app/"); gets executed.

i.e. Task.Factory.StartNew(async () =>
{
try
{
var ipc = new IPC(BlazorWebView);

            Thread.Sleep(2000);
            await RunAsync<TStartup>(ipc, appLifetimeCts.Token);

        }
        catch (Exception ex)
        {
            UnhandledException(ex);
            throw;
        }
    });

will prevent the web window from initializing correctly.

This seems to fix the problem. But further investigation is needed
.
.
.
var completed = new ManualResetEventSlim();

    CancellationTokenSource appLifetimeCts = new CancellationTokenSource();


    Task.Factory.StartNew(async () =>
    {
        try
        {
            var ipc = new IPC(BlazorWebView);

            Thread.Sleep(2000);
            await RunAsync<TStartup>(ipc, appLifetimeCts.Token, completed);

        }
        catch (Exception ex)
        {
            UnhandledException(ex);
            throw;
        }
    });

    try
    {
        completed.Wait();
        WebWindow.NavigateToUrl(BlazorAppScheme + "://app/");
       
        WebWindow.WaitForExit();
    }
    finally
    {
        appLifetimeCts.Cancel();
    }
}

.....

private static async Task RunAsync(IPC ipc, CancellationToken appLifetime, ManualResetEventSlim completed)
{

    var configurationBuilder = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json", optional: true);

    JSRuntime = new PlatformJSRuntime(ipc);
    completed.Set();
    await PerformHandshakeAsync(ipc);

The ManualResetEventSlim will prevent the WebWindow.NavigateToUrl from running until DesktopJSRuntime has been initialized. This seems to fix the problem but I'm not sure if there are other issues or not with the race between NavigateToUrl and RunAsync.

I found this because I am re implementing IBlazorWebView to be able to open a webview on a remote host and it fails every time.

.net 5 support

Is there any possibility of this control being able to use .net 5? Because I know that blazor mobile bindings will not support .net 5 and would be disappointed if i can't use anything from .net 5 until .net 6 since i use blazor for both desktop and web assembly.

BlazorWebView bridge

hi jspuij,
Thank you for this control.
Is it possible to have a bridge which transmits messages/data between Blazor and the native code of the platform?
Blazor <-> WPF
Blazor <-> Xamarin

Thank you for your help.

Status?

Just noticed that the repo was renamed. What's happening? It's going to be available in a more official capacity? Should we be using this package anymore or switching to a different one?

Uncaught Error: Cannot find module '@microsoft/dotnet-js-interop'

The nugets work fine, but when cloning this repo and building from source it looks like it is either pulling in newer stuff for the javascript side.

I can get it to work by editing the package.json and replacing

"@dotnet/jsinterop": "3.1.3",

with

"@microsoft/dotnet-js-interop": "5.0.0-preview.4.20257.10",

and

import '@dotnet/jsinterop/dist/Microsoft.JSInterop';

with

import '@microsoft/dotnet-js-interop/dist/Microsoft.JSInterop';

in the src*.ts files

I notice microsoft recently moved the js code into this renamed module.

Auth Library breaks hosts

I've been using the webview project you stubbed out and have been enjoying it a lot. I'm attempting to add authentication so I can put in an admin dashboard, but whenever I attempt to run my application using the WPF host I get an error that it cannot find an assembly referenced by my shared project.

I began by using your template and then adding Microsoft.Authentication.WebAssembly.Msal to my Shared project. I then added an extension method which is responsible for configuring the auth provider:
image

Finally I wire this up in my WPF project Startup and get this message when I run the project:
image

This surprises me because I'm able to use the exact same process just fine in my WebAssembly Host.

The commit where I add Auth and everything breaks is here (and very isolated)
vanderstack/vanderstack.github.io@563983b

Is this an issue you've run into or expect to have occur? Do you have any suggestion for what may be causing or how to resolve?

Unable to show images

The only case I can't get this to work is if the blazor app uses images. After lots of testing, I found that somehow a person has to copy the images to the wwwroot folder. For server side and web assembly, it worked.
However, with the web control, when i do the same thing, still shows the image is not there. If there was a way to get images without copying to wwwroot on the main project, that would be ever better. As of now, the only case this does not work is if images was used either in svg or in img tag and its not an image from the internet.

NETSDK1130 under net5.0

Just a heads up as I know this isn't supported anymore. I get this error when trying to compile under net5.0.

I'm kind of in limbo because as far as I can tell MobileBlazorBindings doesn't support net5.0 right now either.

Blazor WASM in Xamarin Forms

Currently I have an application in blazor WASM, a part of the application has a registration form, in the xamarin application through a WebView I only show that part, there is a problem, the entire WASM web is downloaded and this has a cost. Is there any possibility to reuse only that page, not the entire WASM application?

Calling WPF method from Blazor

I want to interact with some windows components witch is only available through WPF, how can I call a WPF method from Blazor and get its result?

Bug when publishing

When I try to publish and run on another computer, it never works. Even the most simple sample does not work. The problem just won't open. I even tried to have the sample not try to go to a page and it still does not work. However, if I created the sample app with just a welcome text with no reference to the webview, then it works fine. Even tried to publish and do as self contained just in case its an issue of wrong .net core version on the target machine. To reproduce the problem, do the following:

  1. publish the sample.
  2. copy all the files to another computer that does not have visual studio installed.
  3. run that exe.
    Most likely, it will not run at all. I hope there is a way to fix it because it would be a real disappointment if those apps only work on the machines that has visual studio installed on it.

BlazorNewEdgeWebView - memory leaking, throttling

In my app everything works well with the old web view, but with the BlazorNewEdgeWebView version it seems to get slower and slower as time goes on. This seems to correspond with memory usage increasing at an unexpected rate.

image

image

I'm not sure if this is a bug with BlazorWebView, or with the Edge stuff but thought I would mention it anyway since it doesn't seem to happen in chrome, edge, canary edge, or the old edge web view,

(currently using Edge Version 84.0.516.0)

To give an idea about what I'm doing. It's a debug console. It's getting a debug line from a socket, adding it to a list and calling StateHasChanged for each line. Around 1000 lines in it starts to get a bit crazy.

image

edge 86 issues

Hi

I saw that for edge you said the first version with support was 83. I am using edge 86.0.622.51 and I can call c# from js with window.external.sendMessage. However when I attempt to call js from c# the window.external.receiveMessage event handler is not fired. If I upgrade to Canary 88.0.680.0 then everything works as expected.

Also I did see that you said WPF desktop support would continue for Mobile Blazor Bindings (#24 (comment)) but I also wanted to confirm that these event handlers are not going away and that its not expected you use razor pages. Atm I am doing a proof of concept using this as a light weight alternative to electron like in the example this is based off of (https://blog.stevensanderson.com/2019/11/18/2019-11-18-webwindow-a-cross-platform-webview-for-dotnet-core/).

My goal is to make a vuejs project with .net core back end. I don't have interest in razor pages atm. I want to be able to just drop a compiled vuejs/ts project into the wwwroot folder and have it magically work.

Thanks for your project,
Mitch

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.