[Prototype] Typed browser platform APIs for Blazor, starting with Web Storage - #69305
jsakamotoIGJP wants to merge 9 commits into
Conversation
Introduce Microsoft.AspNetCore.Components.Platform with typed Web Storage, URL, and Fetch projections. Add focused unit and browser coverage through Microsoft.AspNetCore.Components.Testing and include a reusable porting skill. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 72b07274-a61f-41d3-ac15-3d0df5c4f818
Remove the URL and Fetch projections and migrate protected browser storage registrations to the typed Web Storage API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 72b07274-a61f-41d3-ac15-3d0df5c4f818
The synchronization context guarantees that only one thread runs at a time, so Storage does not need a lock. Review comment. kotlarmilos#1 (comment)
|
Hey @dotnet/aspnet-build, looks like this PR is something you want to take a look at. |
|
Thanks for your PR, @jsakamotoIGJP. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
I know some CI checks failed. I'll fix them later. |
Only the overloads without a token get DefaultAsyncTimeout, so this matters on Blazor Server. Review feedback.
Window creates these objects and hands the same one to every caller, so a dispose call from application code used to break the rest of the scope. The interface is implemented explicitly now, following OwningComponentBase, and disposal only releases the JS reference instead of poisoning the instance. The scope still disposes everything through BrowserPlatform.
…omponents-platform-api skill
|
Aside: The build is still failing, but I'm sure that the only red item now is a flake that this change doesn't touch. Here is what changed since I opened this, and what I need decisions on. Fixed
Reverted, and this is the decision I need first I temporarily reverted the adoption in Still open
The branch is rebased on the current |
A prototype of typed browser platform APIs for Blazor
Description
A draft for design feedback, not a request to merge. Milos asked me to open it here so that @maraf and @javiercn can review it. The API proposal is #69304.
This adds
Microsoft.AspNetCore.Components.Platform, which gives typed access to standard browser APIs instead of string-basedIJSRuntimecalls. The first family is Web Storage. DOM APIs and application-specific JavaScript are out of scope.IBrowserPlatform,Window,Storage, andAddBrowserPlatform.LocalStorageandSessionStorageare extension properties onWindow, so the trimmer can remove the one an application does not use.ProtectedLocalStorageandProtectedSessionStorageuse the projection for their default registration. Their public constructors still work.Microsoft.AspNetCore.Components.Server.Tests, and a test application with E2E tests for Interactive Server and WebAssembly..github/skills/port-components-platform-api/SKILL.md, which writes down the rules for adding the next family, including the trimming one.The first two commits are by @kotlarmilos, from kotlarmilos#1 and kotlarmilos#2, rebased on the current
main. Javier already reviewed the prototype and asked to remove the lock inStorage, which a later commit does.Questions
Microsoft.AspNetCore.Components.Serveris in the shared framework and references it.PlatformTestApp.E2E.Testsout because this is a prototype.LocalStorageafter you typeWindow.. Normal properties are easier to find, but then the trimmer cannot remove the unused one.