smapiot / piral.blazor Goto Github PK
View Code? Open in Web Editor NEWAll .NET things to make Blazor work seamlessly in microfrontends using Piral. :jigsaw:
Home Page: https://piral.io
License: MIT License
All .NET things to make Blazor work seamlessly in microfrontends using Piral. :jigsaw:
Home Page: https://piral.io
License: MIT License
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
Hy. I've been tracking down a problem in my app and i think i've found the source of the problem now.
I have created this mvp to show the problem:
https://github.com/luckyluggi/-mvp_piral_statehaschanged
There i have a StateContainer (my-pilet\State\ShoppingCartState.cs) with Items.
Whenever i add items i call StateHasChanged() in my-pilet\Pages\ShopPage.razor and my-pilet\Components\ShoppingCartIcon.razor but the state does not get updated.
see mvp
Component should reload and show new state
does not reload
[Optionally, share your idea to fix the issue]
For more information, see the CONTRIBUTING
guide.
Right now satellite assemblies used for localizations are not picked up. They should be.
Most users will actually use the localization system from .NET (https://learn.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-7.0&pivots=webassembly). This way, multiple satellite assemblies will be created - depending on the provided localization resources.
How should the language be changed? The main idea would be that this would / could work implicitly, but the behavior could also be determined when configuring piral-blazor
. For standalone pilets a dedicated API to configure / change this would be provided.
Content coming from other referenced libs should be appropriately copied over. Otherwise, some runtime behavior may not work or stop working unexpectedly.
For more information, see the CONTRIBUTING
guide.
Right now pilets are published by opening a terminal and changing directory to the scaffolded folder of a pilet. Then, the npx pilet
command has to be used with the publish
subcommand to trigger the publishing.
This should be simplified.
It should be possible to just publish a pilet without any terminal interaction at all.
Right now we want to automatically have the publishing provider adjusted to make this just work nicely. Two options exist:
Piral.Blazor.Tools
and it would take (optional) input such as the API key (otherwise, interactive would be used anyway, opening a web browser to authenticate) or the feed URL to publish.(The second way has the benefit that it would automatically also work with dotnet publish
.)
Extend the documentation describing the <Version>
tag, for example here: https://github.com/smapiot/Piral.Blazor#build-configuration
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
Image loaded from wwwroot
via IPiletService.GetUrl()
are not found.
I've reproduced the bug here:
https://github.com/luckyluggi/piral_extensions_and_aimages
[What you expected to happen]
[What actually happened]
[Optionally, share your idea to fix the issue]
For more information, see the CONTRIBUTING
guide.
Now that .NET 7 / Blazor 7 is officially released we should also have a blazor-7.0
branch with an associated release.
One of the things with .NET 7 is that Blazor now has a stable custom elements API - which would be another capability for Piral.Blazor. Using .NET 7 we would not need the DOM projection any more, but instead of web components. Otherwise, it's still the same as .NET 6.
Anything else in Blazor 7 that is of particular interest for Piral / would make our live here easier / better?
For more information, see the CONTRIBUTING
guide.
Currently the App. razor file is locked away and has to be taken as it is.
If f.e. Microsoft.AspNetCore.Components.Authorization
should be used The App.razor must be edited like this:
<CascadingAuthenticationState>
<Router ...>
<Found ...>
<AuthorizeRouteView RouteData="@routeData"
DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView ...>
...
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
This should be possible.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
For more information, see the CONTRIBUTING
guide.
See an example here (Problem nr. 2 in the Readme.md file):
https://github.com/luckyluggi/piral_meeting_examples
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
Related to PR #38
afaik the _piletFolderPath
already has the MSBuildProjectName
included, so it should already be considered when scaffolding. This being merged now includes the project name twice (e.g. piral~/projectname/projectname
) and results in the scaffold always happening.
Originally posted by @DanteDeRuwe in #38 (comment)
Reposted here to get opinion of @FlorianRappl about this
For more information, see the CONTRIBUTING
guide.
If you switch Change Routes in the app the active
class in Components is not updated.
Also NavigationManager.LocationChanged does not get called.
I Have created an MVP to make this clearer.
https://github.com/luckyluggi/mvp_route_update
For more information, see the CONTRIBUTING
guide.
Since the ILogger is configured in piral core we currently can not configure it. We need a possibility to do that.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
Currently version 3.2.1 is released, 5 is in prerelease and there isn't anything for dotnet6 blazor. Will eventually 5 and 6 be released?
By the way, amazing work!
For more information, see the CONTRIBUTING
guide.
Right now the Kras proxy cannot be configured / used with the Piral.Blazor.DevServer. This should be changed
One of the reasons is that we don't forward non-pilet requests to the Kras proxy. As a mitigation, the Kras proxy scripts should be placed (configurably) in some directory, with the kras config being read and all proxy-endpoints being forwarded properly.
I think a good starting point would be the definition of the mocks directory (e.g., <MocksDir>mocks</Mocks>
), which might contain a .krasrc
file and other files. The .krasrc
file would then be merged / brought over to the pilet, with the scripts being referenced / used directly. The keys of the map
property will be used as forwarding endpoints.
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
I've created an mvp showing the problem:
https://github.com/luckyluggi/mvp_route_reload
When you enter the root Page you can switch between all pages using the buttons at the top like it should be. In this case <base href="http://localhost:1234/">
is set in the .
But if you go to http://localhost:1234/winter/posts and press F5 -> <base href="http://localhost:1234/winter/posts">
gets written into the <head>
. Now you can switch between all /winter/-Pages like it should be, but as soon as you switch to a /summer/-Page the browser window reloads.
I belive it has something to do with the <base>
.
[What you expected to happen]
[What actually happened]
[Optionally, share your idea to fix the issue]
In case the core dependencies are not found, e.g.,
Piral Blazor was not found in the Piral Instance, and the needed dependencies are also not found. Installing them now...
it may throw an error
(node:12052) UnhandledPromiseRejectionWarning: ReferenceError: piralVersion is not defined
This should be fixed in blazor.codegen. ("the error is throwing from the line blazor.codegen:276:77")
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
See an example here (Problem nr. 1 in the Readme.md file):
https://github.com/luckyluggi/piral_meeting_examples
[What you expected to happen]
[What actually happened]
[Optionally, share your idea to fix the issue]
Right now the DI works only partially. Full DI (i.e., pilet-local specified dependencies) can be fully injected in a pilet (i.e., components within the pilet), however, for components coming from other DLLs this is not working.
In general it is very difficult (almost impossible) to reliably inject the right dependencies in such components. While we could track the happy path (i.e., Component from pilet -> Component from library) and therefore use the right service container, the problem becomes much more difficult when there are interruptions along the way. (i.e., Component from pilet 1 -> async waiting; Component from pilet 2 -> done; async waiting over -> Component from library => which service container would we choose now? last rendering indicates pilet 2, but the actual path / rendering origin was originating from pilet 1).
What we therefore want to do is to enable the global shared dependencies (i.e., obtained from the ConfigureShared
method, not ConfigureServices
in Module.cs
) to be used here. The advantage is that in this case we do not need to track the origin - it would just work and be in this case reliable.
Describe how to make use of overwrite.package.json
file.
How does it help, what are the common use cases for it?
The Blazor pilet seems to remain at 1.0.0, but it should be synced with the version defined in the .NET project. This way, there is no need to touch the contents of the package.json or override them.
Right now when somebody starts a new Piral.Blazor pilet without the template one may be tempted to just reference Piral.Blazor.Core
(instead of the usually wanted Piral.Blazor.Utils
). Since Piral.Blazor.Core
is an application and only meant as a carrier for the shared dependencies we should be very explicit to discourage this.
Ideally, the referencing does not work (how?). In the worst case we just show some warning or info in Visual Studio.
Whatever we do, we should not impact the NuGet experience for piral-blazor
, which downloads and unzips the package to get / use the content.
For more information, see the CONTRIBUTING
guide.
Our project has y Layout pilet which configures services (in ConfigureShared) needed by every other pilet.
For that to work wee need it to be loaded first.
Currently this can not be guaranteed. As discussed we'd need a way to set the pilets priority to load. This priority should be used when running all pilets from the feed, when running one pilet locally and all others from the feed and when running multiple pilets locally.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
Similar to #59 we need to ensure that a failed scaffold (e.g., due to some missing dependency) does not prevent a scaffold in the future.
Right now when the initial scaffold fail (but still created the folder structure) a subsequent scaffold will not touch it. This is sub-optimal.
Ideally, we introduce a flag that also includes all used dependencies, allowing us to determine when we need to upgrade / re-scaffold etc.
One of my biggest concerns (still) is that we need to run the debug from VS, but also from the command line (sure this can also be done from within VS, but the thing is that its still 2 commands where it should be just one).
Ideally, there is a way to run a process / command when the IIS express starts.
Maybe someone in the aspnetcore gitter or so knows how / if this works.
Piral.Blazor should be adjusted to v3.2.1.
In this process we should start aligning the version numbers. The NuGets coming from this repo should always have the same version (Major, Minor, Patch) as Blazor. Thus anyone interested in a particular version of Blazor only needs to know this version for choosing the right version of Piral.Blazor.
I would like to have a list of possible variables listed in a document for the blazor project.cs.
e.g.:
PiralInstanceVersion what it does how to use it
PiralInstance
NpmRegistry
etc.
Currently, I can't find a comprehensive list of vars supported.
The @page
directive is used to automatically add pages to the router. Internally, this just adds the [PageAttribute]
to the generated class.
Most likely, we could do some "magic" and introduce an auto inclusion of these pages. Potentially, it makes sense to trigger this via piral-blazor
(explicitly), such that it could be turned off - if not desired.
export function setup(api) {
api.defineBlazorReferences([...], {
includePages: true, //set to false or omit to not auto discover
});
}
For more information, see the CONTRIBUTING
guide.
The possibility to set configs in the feed service is great, but while running pilets locally via pilet debug
the configs are currently empty. It would be great if they were also pulled if i add the feed via --feed.
Or even better if they could be configured in a json file just for running and debugging pilets localy.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
For more information, see the CONTRIBUTING
guide.
It Should be supported to order Extensions inside Blazor Pilets
In js pilets this is already supported like so:
<piral.Extension
name="topbar-left"
order={(extensions: Array<ExtensionRegistration>) => {
return extensions.sort((a, b) => {
if(a.defaults?.order > b.defaults?.order) return 1;
if(a.defaults?.order < b.defaults?.order) return -1;
return 0;
})
}}
/>
other pilets can then add items like so:
app.registerExtension("topbar-left", () => {
return <li>First</li>;
}, {order: 50});
and even blazor pilets can add items like so:
app.registerExtension('topbar-left', app.fromBlazor('my-extension'),{order: 10});
In Blazor we can create the extension like so:
<Extension name="topbar-left" />
but we currently don't have the possibility to sort the items.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
For the current model we've introduced the custom Anchor
element. Blazor's "primitives" here (just standard a
or something like NavLink
) should, however, also just work.
So instead, I propose to just override the standard routing behavior. The mechanism should be to use the context's Router instead of the history API. Most likely, this is a change in the piral-blazor
code.
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
When i want to move to another page programmatically by injecting "Navigationmanager" and calling "_navigationManager.NavigateTo($"/item/create");" the page does not change.
I can ofcourse add true as a second param to bypass client side routing and load the new page from the server, and it does work, but that's not rly nice and slow.
I've added an example page to the mvp (/navigationmanager):
https://github.com/luckyluggi/mvp_piral_route_params
More info on Navigationmanager:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.navigationmanager.navigateto?view=aspnetcore-6.0
see mvp
should move to another route
does not move to another route
[Optionally, share your idea to fix the issue]
Would like to have a way to configure a feed to pull other enabled pilets from a configured feed during a specific Blazor pilets debug session. This could potentially be a parameter to somehow pass to Piral.Blazor.DevServer or via the devserver config directly. We see npx pilet debug
has a --feed
param but we are not able to hook into this as Piral.Blazor.DevServer abstracts the blazor pilet debug process,
ref: https://github.com/smapiot/piral/blob/main/docs/commands/debug-pilet.md#--feed
This would allow us to ensure pilets integrate together well during development workflows.
Right now with the standard template the contents of the actual pilet are pretty much "hidden" for the end-user.
We should add a way (e.g., using a file "overrides.json") to merge in custom settings (should be deep merged, not shallow merged) just like we did with "setup.ts".
Right now the scaffolded pilet is a bit "too sticky". In order to apply, e.g., an update of the Piral instance / emulator package, you'd need to manually go to the pilet's directory and run pilet upgrade
. Sure, this is the "usual" way, however, for a Blazor Pilet (Blazelet?) it should not be necessary. Ideally, this can be done directly from Visual Studio - and even better: it may even be implicit.
We should add at least a task to do that, but maybe even automate it appropriately. Easiest way would be to have something like <PiralInstanceVersion>
in the csproj, such that it is (by default set to) "latest" (which auto-checks), but could also be set to anything else (and, e.g., in case of explicit versions may only check if the version match, resulting in an update of the scaffolded pilet, or not).
For the upcoming Blazor / Piral.Blazor 5.0.0 release the new lazy loading of Blazor should be used.
This makes especially sense regarding framework support for larger applications. It should bring an additional layer of reliability, too.
More information can be found:
For more information, see the CONTRIBUTING
guide.
Currentl the folder is created one directory up. We would like to configure it to be 2 directories up.
[Provide any additional background for the feature, e.g., why is the current solution insufficient, what problem will it solve, etc.]
[Optionally, outline any pros and cons you can currently think of to provide the basis for a solid discussion]
For more information, see the CONTRIBUTING
guide.
Latest version of Piral Blazor 6.
Piral does not find referenced packages if they are renamed using <AssemblyName>
The behavior can be reproduced with this project (Infos in the readme):
https://github.com/luckyluggi/mvp_piral_blazor_extension
The custom AssemblyName
- if given - is used to determine the DLL name.
No custom name can be used.
N/A
I followed the instructions for setting up a Piral shell and a Blazor Pilet from the template and I'm getting the following error when debugging the Blazor app:
Uncaught RuntimeError: memory access out of boundsUncaught RangeError: Invalid typed array length: 534384Uncaught Error: Failed to start platform. Reason: RangeError: Invalid typed array length: 43920The thread 0x3a84 has exited with code 0 (0x0).
Any idea what I'm doing wrong?
Under certain conditions this might not work, especially if a container requires global access but is then instantiated multiple times. We need to find a way to solve this.
See for instance:
https://github.com/stephdewit/piral-blazor-ioc-mwe
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
Parameters given to piral extensions are not working.
I've reproduced the bug here:
https://github.com/luckyluggi/piral_extensions_and_aimages
[What you expected to happen]
[What actually happened]
[Optionally, share your idea to fix the issue]
For more information, see the CONTRIBUTING
guide.
[Package Version, Blazor Version, OS, Browser,...]
When i try to reference an image from inside the wwwroot folder it is not shown.
Example:
The image does exist in wwwroot/img/logo.png but is not shown.
[What you expected to happen]
[What actually happened]
[Optionally, share your idea to fix the issue]
Right now the template still needs to be enhanced to allow for more rapid development.
The most important feature is to have the source maps properly working. That means not only debugging in the browser is fine, but also that a breakpoint in VS is triggered properly.
We should check and ensure that this works as expected.
For more information, see the CONTRIBUTING
guide.
The meta.json
files should be configurable to override some default values in debug environment, similar to packages-override.json
.
As far as I understood, you can set default configs via piletConfig, that are overridden by the feed service. When running the Blazor DevServer there is a meta.json
that overrides the piletConfig - but I can't define what else should be overriden in local development. Somewhat like
{
"backendUrl": "http://localhost:7345/"
}
For more information, see the CONTRIBUTING
guide.
In Blazor WASM, it is sometimes necessary to reference static JS assets defined in imported NuGet packages or referenced Razor Class Libraries. One example is Microsoft.Authentication.WebAssembly.Msal
, which provides a static script file named AuthenticationService.js
which needs to be referenced in the HTML body of wwwroot/index.html
like so:
<script src="_content/Microsoft.Authentication.WebAssembly.Msal/AuthenticationService.js"></script>
The same applies to any shared Razor Class Libraries referenced by a pilet, which may also provide static JS files to be used in the same fashion as described above.
Piral.Blazor should support this pattern and provide a way to reference these assets.
As of now, there is no obvious way to reference static JS files within RCLs or NuGet packages from within a Blazor pilet.
Right now our structure requires NPM v7/v8:
The command is the one from the Prial.Blazor.Tools.targets: npx --package=piral-cli -y pilet new
$(PiralInstance) --base $ (_piletFolderBase) --target$(MSBuildProjectName) --registry $ (NpmRegistry) --bundler $(_bundler). the command "new" is not found.
It works with:
npm init pilet --source $(PiralInstance) --base $(_piletFolderBase) --target $(MSBuildProjectName) --registry $(NpmRegistry) --bundler $(_bundler) --defaults
So we'd need to find out the current version and switch command appropriately.
That way it can not only be leveraged directly in Piral.Blazor.Core, but also in pilets (expert users).
For more information, see the CONTRIBUTING
guide.
Blazor WASM provides a way of providing environment-specific client-side configuration by placing appsettings.*.json
files into the wwwroot
folder. The active environment can then be set using, for example, a startup configuration as outlined here.
It would be helpful if appsettings.*.json
files could be used for client-side app configuration within a Blazor pilet to populate an IConfiguration
instance, and if that instance would then be passed to the Module.ConfigureServices
method as outlined in the minimal example below.
appsettings.json:
{
"Api": {
"BaseUrl": "https://my.api.com/"
}
}
ApiOptions.cs:
public class ApiOptions
{
public string? BaseUrl { get; set; }
}
Module.cs:
[...]
public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddOptions();
services.Configure<ApiOptions>(options => configuration.Bind("Api", options));
// or
services.Configure<ApiOptions>(configuration.GetSection("Api"));
}
[...]
As of now, IConfiguration
is not bound. This leaves the pilet author with hard-coding necessary configuration values within the ConfigureServices
method and also neglects the need for environment-specific configuration within pilets.
In the sample:
https://github.com/smapiot/Piral.Blazor/blob/blazor-5.0/example/pilet/Pilet/Components/SampleExtension.razor
the react-counter
is called with params new { count = 10, diff = 3 }
however upon loading the page the starting value is 0 and the increment is 1, so the props have the default value.
Adding a console.log(params);
to the react-counter
extension shows that the params
is not undefined, but empty and have no properties.
So calling Extensions from Blazor with Params, the Params is not correctly passed through.
Calling a Blazor Extension from React works.
When doing this on a non-Windows system the blazor.codegen
has slashes (/
) everywhere where backslashes ( \
) have been used. This breaks the code as regular expressions (and other things) suddenly become invalid syntax.
When i do the following:
"hotReloadProfile": "blazorwasm"
in the launchSettings.json like explained herenpm start
inside myproject/piral~/my-pilet
dotnet watch
inside myproject/my-pilet
The Browser should reload and show the changes applied
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.