-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add v2-web components based widgets and get rid of iframes in operators. #534
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Nov 28, 2023
This PR is now reviewable. |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
8 tasks
8 tasks
Thank you very much for your great work! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR adds v2 widgets and operators, wich will work with web components now. v1 widgets (that work with iframes) will still work well. v2 widgets are not directly compatible due to the impossibility of isolating javascript without iframes, but they are very similar to their v1 counterparts.
The idea is that widgets (and operators) will now define a class in one of their script files in the window object, which will be instantiated for each widget. Each class will receive the MashupPlatform object as a parameter, which is tailored to the specific widget (just like the iframe) as well as any extra objects (such as StyledElements, NGSI...). They will also receive a reference to a shadowDOM that will contain all of the HTML and CSS of the widget, so that they can work in their isolated frame.
Operators not only won't use iframes, but not even web components, as they are pure javascript, which will be instantiated for each operator by adding their corresponding scripts without further DOM modifications.
For this to work, a new fieldhas been added into the Mashable Application Components Description Language, named
entrypoint
for both widgets and operators, which contains the name of the class that is instantiated for every widget and/or operator. Also, widgets now accept scripts, which are loaded into the main DOM, instead of the shadowDOM (altough they'll work the same way).To differentiate between old, v1 widgets and operators (which will still work well), the
macversion
number has been increased to 2 for the new type of MACs, and 1 is left for the old ones. For this reason, this PR depends on #533 (includes #533 commits, so this can be merged and #533 closed).Types of changes
Checklist
Further comments
Other alternatives considered where to use just a shadowDOM. Unfortunately, javascript and only javascript is not isolated, and since the way things were working right now required modifying the window object, it was impossible to get rid of iframes (which is the only way to isolate javascript without creating a javascript sandbox). This can cause some problems sometimes, such as 2 different widgets using different versions of the same library, as conflicts can occur. This PR can be further expanded to create new fields in the MACs configuration files that allow to specify which libraries have been used and what version, in order to Wirecloud to handle conflicts to an extent, as well as warn the user about the conficts.
This PR is still in development, and while the main functionality has been made, there may be bugs left to fix. Moreover, documentation and testing is still missing, which is why this is still a draft.Already finished.