-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Refactor everything in SDT for compile-time code generation #89
Conversation
…ion. Fixes #87. This commit parses existing SDT traits into the new structures, and clean up scaladocs, and adds a bunch more documentation links.
I've implemented most generators that will generate Laminar / Outwatch / etc. source code from the new SDT data. For some examples:
The code generation is configurable / extendable, but not infinitely so. At some point it might be easier to write your own non-generic generator, but I expect all reasonable frontend use cases to be covered by the canonical generator hosted in SDT. If some required customization is missing, it can be added later. The traits in thirdparty/defs are currently generated by GeneratorSpec as an example. I still need to finish the parsing and generation of CSS styles, and work on edge cases like composite keys, aliases, etc. |
For now I am hardcoding this (every project will need to copy-paste a few files) because this is a new feature in SDT, and I am not sure how it should be encoded yet. This feature is also relatively code-heavy (as opposed to data-heavy), so I am not sure if it even makes sense to make a generator for it at all.
FYI I'm also dropping Scala 2.11 support, seems like a waste of cpu cycles nowadays. |
Dropped built-in support for TypedTargetEvent. I think it only complicated type signatures, and for little gain, since the best type we could infer would be If you really want to support -- Also, temporarily dropped support for the |
…aits into new SDT data structures
So that the file names are different from generated file names, to reduce confusion
…on and mix-blend-mode style props
- Rename many tags by adding `Tag` suffix to scalaName - Use real scala-js-dom types for elements instead of dom.{html, svg}.* type aliases - Fix svg rect element element type - Extract animation event props into a separate trait
See #87 for rationale and discussion.
This PR is taking the second approach – consuming libraries will call an SDT method at compile time to generate the code of all the traits that previously lived in SDT (
HtmlAttrs
,Props
,Styles
, etc.) They can also write their own code generators.In the initial commit, I made parser to parse existing SDT traits and generate the code of the new SDT. The generated code is in
src/main/scala/com/raquo/domtypes/shared/defs
, and the new type definitions are insrc/main/scala/com/raquo/domtypes/shared/common
. Basically everything else in this project will be nuked.Lots of stuff is still WIP, but if you're interested you might want to look in the two directories mentioned above.
Next step for me is writing the code generators that will take this new SDT data and generate the source code of the traits that you would want to actually use in third party libraries.
SDT also used to contain a few small helpers like
Codec
-s,SvgNamespaces,
andVendorPrefixes
. I'm not yet sure if I will keep those in SDT, or if each library will just need to copy-paste a few files. These particular helpers don't really ever change.