-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(core): implement CapacitorCustomPlatform for 3rd party platforms #4771
Conversation
This seems fine when I pulled down this and the electron build, it is failing the lint so could you fix that to make sure it passes the rest of the tests? Also tagged @jcesarmobile as a reviewer so he could look over it too, but this seems good to me |
Not sure why lint test failed, it uses the same code base as the main repo. Says the issue is:
However the use of a |
those are warnings, not errors, try deleting node_modules and running |
Now I have 151 changes to commit 😅 |
then don't commit, I'll take a look |
Yeah figured that'd be a bad commit |
What was the lint issue? |
I just ran |
It seems to have been it wasn't using ignore lists probably and formatting a bunch of files it shouldn't have been |
Pushed out a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been messing with this over the weekend and didn't run into any major issues, so approving this 👍 @jcesarmobile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this can be accomplished in a non breaking way? deprecating the platforms API instead of removing it?
We are not sure at this point if other custom platforms exist, there has been a few people asking about how to create custom platforms.
Also, would be good if you could give a better insight on why this is needed for supporting context isolation, all I see in this change is platforms plugins defaulting to web plugins if not defined in native, but don't really see how this would fix the native plugins.
We can deprecate sure. I don't know if any other custom platforms exist beyond my own tinkers with the likes of uwp, tauri, etc., however this should be easy to use with others in this form and this seems like an easier way to do custom platform plugins overall. The main reason we have to do something like these changes is that the platforms API as it is, assumes that the platform has access to the app in a way where it can initialize the capacitor runtime prior to the web app being loaded. However in the case of the context isolation in electron you can not initialize the runtime as the window object etc. are not shared between the preload script and the web app. You can expose properties to the web app's window object however they are limited in what can be copied across the context bridge. Thus exposing the So in the electron platform's case, the platform generates a set of function calls that implement IPC dynamically on both the renderer side and the main process side. These IPC calls allow plugin code to run in the main electron process on node-js, but only if they are generated by the platform, making it safer by not allowing node integration on the renederer process which could be leveraged by remote code. (read more here https://www.electronjs.org/docs/tutorial/context-isolation) On using web versions of plugins by default, this is more of an electron thing as far as I know, but because electron is a full chromium browser essentially, web plugins should function just fine on there, and lots of plugins may not need native electron options because of that. |
Well, even if there aren't any other platforms, it will break current electron platform until users update, so better deprecate it now and we will remove it before capacitor 4.0.0 |
Okay I will make the adjustments to this PR for deprecation then re-request review 👍 |
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
I have added back in the old platform API and set it to deprecated |
Is there anything else you'd like to see @jcesarmobile ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works fine and doesn't break existing platforms
…#4771) Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
The whole API for platforms may not work out in the current form but with the changes outlined in this, at least from Electron point of view, will function much better with how Context Isolation works.
See
next
branch of Electron platform for working example. https://github.com/capacitor-community/electron/tree/next