-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
New Blazor JS interop #27016
Comments
This comment was marked as resolved.
This comment was marked as resolved.
@pavelsavara ... Ok ... Came back this afternoon to try again, and I had better luck 🍀 ...
... and that seems to work 🎉. Lot's of ❓tho about what devs need to read on it ... best practices and critical info on things like ...
... stuff like that. Whatever you feel is the best general approach for the most common basic use case. |
All previous options how Blazor could deploy the JS file are still there. My favorite is next to the razor component.
I'm not really Blazor expert yet, but this seems that the script download would be delayed too late and slow down the first render with the JS code impact. Is there event which could do it earlier ?
This is marshaled interop and it's so fast you could replace any legacy unmarshaled interop with it. And you should because
It means that (user and) the code generator in Roslyn compiler could use pointers. Not a security concern. Rather developer would not be prevented from using lower level concepts in that assembly.
It's standard ES6 module. The module name in the
So far I did my as
JS download takes time. |
Link to ES6 modules doc, you could probably even link it from our docs https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules |
Also the new API is only available in the browser (not on server side). The code analyzer would complain about it with
|
|
I don't know what was Blazor previous guidance on Blazor component instances together with
|
Ideally these 2 articles would not be part of Net 7 because we don't want people to use it for new code. The JS APIs on |
We cover that, too. I'll be sure to link our module coverage in the new sections. One thing that I need to discuss with Dan and Artak is how we still favor the easy/quick placement of scripts in the
It won't because it's after render (hence the need to call
This means that we can just drop the existing unmarshalled interop coverage from the 7.0 and later docs in favor of two new sections on the new interop approaches. That's cool. 👍
No need at this point. I'm aware of how the draft should be assembled. We'll get feedback from Dan on the PR later. I'll work up a 2nd example the other way with As for the rest, LGTM. I think I have enough to draft the PR now. I'll ping u back here if I have more ❓. I'm about out of hours ... and 🧠 power 😩 ... for the week. I'm going to pick back up with this on Monday morning, and I think the PR would will be ready no later than Wednesday of next week, as long as nothing high priority hits me in the meantime ⛰️⛏️😅. |
I see that you added a few more comments. I'll get back to you. I'm going OOF for a few hours, but I'll be back online later today ... and then again on Monday. |
I'm BACK. 🏃♂️🏃♂️🏃♂️🏃♂️
Not recommended for general use because it isn't hosting model agnostic. I think 🤔 we only cover it in one spot at ... For the use cases you mentioned in your bullet points, we'd cover basic use cases but probably not advanced ones ... probably not initially anyway. I'll put the simple, basic use cases on the PR, then we can see what the team thinks about additional use cases to add.
I'm happy to hear that 👍. That's easy. We'll be swapping the old sections for the new bits. What I'll probably do is keep a section and/or NOTE for one or two release cycles (.NET 7 to .NET 8 or 9) that tells readers about how that API is obsolete and recommends the new bits with a cross-link. If you put up an I'm feel'in good about this. I think I have enough to get the PR set up. I think it will be up on ... mmmm 🤔 ... Wednesday/Thursday. I'll work on it locally for a few days before putting up something that I'm not embarrassed to show to the PU 🙈😆. If I run into trouble 😈, I'll shoot you a message here. Otherwise, I'll ping u on the PR next week. |
Note to self:
|
... and a quick update. I've been held up just a little bit by new Blazor issues, but the JS interop work is proceeding. I have the code examples for the PR. I plan to start writing the section today (Tuesday). I still think it will be up by Thursday for review. It will be helpful if fewer Blazor issues come in, but you know how that goes. I can go weeks without a peep from the readership, and then get slammed with a dozen issues in just a couple of days 🏃♂️😅. |
Another PR + a gRPC review (#27053) cut into my writing time today. It's looking more like Friday for the PR. Sorry for the delays ... it's a very 🏃♂️🏃♂️🏃♂️🏃♂️🏃♂️😅 time of year! |
@pavelsavara ... Update: It's going well. I think the PR will be up on Friday morning. Pavel, I see that the the API and the syntactic approach ( Otherwise ... It seems more reasonable to create a new temporary for .NET 7 article to cover this for a couple of reasons:
|
This is question for @danroth27 . Technically it would need it's own Roslyn code generator and the low level behavior of the marshaler would be different as it's a remote protocol via JSON. It would be another attribute. Somebody would need to do a prototype to see if it's good idea. I don't know. Also do we commit our future plans in the documentation ? The "new JS interop" is rather the "JS interop" from runtime perspective, because the previous API was private and undocumented. I work on an article for dotnet blog which describes many details of it. Do you have access to https://github.com/microsoft/dotnet-blog/pull/903 ? |
No, only what's available, and we don't usually say in one version of the docs what's going on in another version. For example, we would rarely tell devs in a 6.0 doc, 'if you update to 7.0, you can do this better with new 7.0 bits.' It's too much work to do that constantly across the docs and for new releases. What we do is cover everything in the What's New doc for a given release and cross-link the new doc sections there. In the Migration topic we'd cover aspects like this, too. For example, we'll say that unmarshalled interop is obsolete and cross-link the new coverage for devs to migrate to 7.0.
I mean just for coverage. I just mean that a new topic in the JS interop folder SxS would be a good temporary bridge to JS interop changing (perhaps only ever for WASM) to use
That sounds right to me 👂 because we focus on Blazor things here almost exclusively. However, @danroth27 will inform me if that's not going to be the case ... and then if not ... how the coverage should be laid out in the Blazor node (or another node perhaps). I'll be 👂 for that guidance. In the meantime tho, I can at least get the Blazor-specific pieces put together by Friday so that we have a full explanation of the basics, and then you and Dan can see what else you'd like to change and add to that.
It 404s for me. |
UPDATE (Thursday, 2pm CST): Looking good! 👍 I have a first draft now. I'll sleep 🛌💤 on it, make a final round of updates on Friday morning, and have it up in a PR no later than mid-morning (11am CST). If you're going OOF for the weekend and want to hit it on Monday, that's cool. I'll be going OOF myself Friday afternoon for the weekend and back on Monday. I don't think we're in a super-rush for this given that we're still only in RC1 times. It will be a bit rough, no doubt with some broken technical remarks to address 🙈 and lacking aspects that you'll want to add to it, including perhaps additional examples, but it should get us going in the right direction. If it turns out that a new article for this in the JS interop folder SxS with current coverage isn't the best approach, no problem. This article breaks down cleanly into ...
My recommendation is that you and I should make this content as nice as we can before pinging Dan and Artak on the PR. That way, they won't get pinged to death 🗣️💀 with a lot of back-and-forth discussion if we need to do a lot of work to it. |
I wonder if the "new" JS interop could be named ... .NET JavaScript Import/Export Interop ... to distinguish it from the existing interop (as a proper noun). .NET JavaScript ... but that seems a bit unwieldy, and the attributes wouldn't localize. If it can be distinguished in some way like that, it would be easy to add it to the existing topics (now or later) without causing confusion or requiring unusual adjectives like "new" or "alternative" JS interop. UPDATE: Changed my mind. I think Dan would prefer to use the attributes after all, so I'll float it that way on the PR (with a lowercase "i" in "interop" ... .NET JavaScript |
❓ @pavelsavara ...
[SupportedOSPlatform("browser")]
public partial class Interop
{
[JSImport("getMessage", "Interop")]
internal static partial string GetWelcomeMessage();
}
Nevermind! ... I see it in the sample app. What I'm recalling is probably from a framework test, where it probably would break the test. |
Why JSImport not support Blazor Server? |
Per dotnet/blazor-samples#41 ...
It's best if we have a section and extend the snippet sample apps, as opposed to adding a new sample app. Every sample app adds overhead costs 💸☹️ .
cc: @pavelsavara
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: