From 7bcae7ebbb3382f783403505917e4627310075be Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:09:23 +0200 Subject: [PATCH 01/31] Math ml tag defs --- .../domtypes/defs/tags/MathMlTagDefs.scala | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala new file mode 100644 index 0000000..01852b3 --- /dev/null +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -0,0 +1,162 @@ +package com.raquo.domtypes.defs.attrs + +import com.raquo.domtypes.common.{AttrDef, HtmlTagType} + + +object MathMlTagDefs { + + val defs: List[TagDef] = List( + + TagDef( + tagType = MathMlTagType, + scalaName = "math", + domName = "math", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Math", + javascriptElementType = "MathMLElement", + commentLines = List( + "The top-level element in MathML, representing a mathematical expression.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mi", + domName = "mi", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mi", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a mathematical identifier, such as a variable name.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mo", + domName = "mo", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mo", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a mathematical operator.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mn", + domName = "mn", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mn", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a number in a mathematical expression.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "msup", + domName = "msup", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Msup", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a superscript expression.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "msub", + domName = "msub", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Msub", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a subscript expression.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mfrac", + domName = "mfrac", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mfrac", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a fraction.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "msqrt", + domName = "msqrt", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Msqrt", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a square root.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mroot", + domName = "mroot", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mroot", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents a root expression with a specified degree.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot", + ), + ), + + TagDef( + tagType = MathMlTagType, + scalaName = "mtext", + domName = "mtext", + isVoid = false, + scalaJsElementTypeAlias = "dom.mathml.Mtext", + javascriptElementType = "MathMLElement", + commentLines = List( + "Represents text within a mathematical expression.", + ), + docUrls = List( + "https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtext", + ), + ), + + ) + + } \ No newline at end of file From e9ac70f097a9172fbe6fcc580bd7cddcdc7aaefc Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:21:20 +0200 Subject: [PATCH 02/31] poke ci --- .../main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala index 01852b3..86d2369 100644 --- a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -97,6 +97,7 @@ object MathMlTagDefs { ), ), + TagDef( tagType = MathMlTagType, scalaName = "mfrac", From fc40d3f31b1ba5d2edd3974ad4e21fddb4214410 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:25:44 +0200 Subject: [PATCH 03/31] Fixy fixy --- shared/src/main/scala/com/raquo/domtypes/common/TagType.scala | 4 ++++ .../scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala index 60c2d9c..df4d124 100644 --- a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala +++ b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala @@ -16,3 +16,7 @@ object HtmlTagType extends TagType { object SvgTagType extends TagType { override val sourceStr: String = "SvgTagType" } + +object MathMlTagType extends TagType { + override val sourceStr: String = "MathMlTagType" +} diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala index 86d2369..b15eff8 100644 --- a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -1,6 +1,6 @@ package com.raquo.domtypes.defs.attrs -import com.raquo.domtypes.common.{AttrDef, HtmlTagType} +import com.raquo.domtypes.common.{MathMlTagType, TagDef} object MathMlTagDefs { From 0cdc50f27b69b21eeac7573e72ab0df56dcef8e6 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:32:02 +0200 Subject: [PATCH 04/31] . --- .../com/raquo/domtypes/GeneratorSpec.scala | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index afbca7d..12297f6 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -90,6 +90,31 @@ class GeneratorSpec extends AnyFunSpec with Matchers { ) } + it("Generate MathMl tags") { + println("=== MATHML TAGS ===") + + val traitName = "MathMlTags" + + val fileContent = generator.generateTagsTrait( + tagType = MathMlTagType, + defGroups = defGroups.mathMlTagsDefGroups, + printDefGroupComments = false, + traitCommentLines = Nil, + traitModifiers = Nil, + traitName = traitName, + keyKind = "SvgTag", + baseImplDefComments = Nil, + keyImplName = "mathTag", + defType = LazyVal + ) + + generator.writeToFile( + packagePath = generator.tagDefsPackagePath, + fileName = traitName, + fileContent = fileContent + ) + } + it("Generate HTML attributes ") { println("=== HTML ATTRS ===") From 96a8792ec081741d6d4d2a4f6a9871adafe88e1d Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:36:27 +0200 Subject: [PATCH 05/31] Test types --- jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala | 2 +- .../scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index 12297f6..ca510e3 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -2,7 +2,7 @@ package com.raquo.domtypes import com.raquo.domtypes.codegen.DefType.LazyVal import com.raquo.domtypes.codegen._ -import com.raquo.domtypes.common.{HtmlTagType, SvgTagType} +import com.raquo.domtypes.common.{HtmlTagType, SvgTagType, MathMlTagType} import com.raquo.domtypes.defs.styles.StyleTraitDefs import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers diff --git a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala index e094b2f..3d461a3 100644 --- a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala +++ b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala @@ -25,6 +25,10 @@ class CanonicalDefGroups { "SVG Tags" -> SvgTagDefs.defs, ) + val mathMlTagsDefGroups: List[(String, List[TagDef])] = List( + "MathMl Tags" -> MathMlTagDefs.defs, + ) + val htmlAttrDefGroups: List[(String, List[AttrDef])] = List( "HTML Attrs" -> HtmlAttrDefs.defs ) From 993aceba6f7d2bc0a92b327ff8ac432aaca473f7 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:46:28 +0200 Subject: [PATCH 06/31] claim they are HTML elements --- .../domtypes/defs/tags/MathMlTagDefs.scala | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala index b15eff8..d71cc1d 100644 --- a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -13,7 +13,7 @@ object MathMlTagDefs { domName = "math", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Math", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "The top-level element in MathML, representing a mathematical expression.", ), @@ -28,7 +28,7 @@ object MathMlTagDefs { domName = "mi", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mi", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a mathematical identifier, such as a variable name.", ), @@ -43,7 +43,7 @@ object MathMlTagDefs { domName = "mo", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mo", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a mathematical operator.", ), @@ -58,7 +58,7 @@ object MathMlTagDefs { domName = "mn", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mn", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a number in a mathematical expression.", ), @@ -73,7 +73,7 @@ object MathMlTagDefs { domName = "msup", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Msup", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a superscript expression.", ), @@ -88,7 +88,7 @@ object MathMlTagDefs { domName = "msub", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Msub", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a subscript expression.", ), @@ -104,7 +104,7 @@ object MathMlTagDefs { domName = "mfrac", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mfrac", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a fraction.", ), @@ -119,7 +119,7 @@ object MathMlTagDefs { domName = "msqrt", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Msqrt", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a square root.", ), @@ -134,7 +134,7 @@ object MathMlTagDefs { domName = "mroot", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mroot", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents a root expression with a specified degree.", ), @@ -149,7 +149,7 @@ object MathMlTagDefs { domName = "mtext", isVoid = false, scalaJsElementTypeAlias = "dom.mathml.Mtext", - javascriptElementType = "MathMLElement", + javascriptElementType = "HTMLElement", commentLines = List( "Represents text within a mathematical expression.", ), From 3cf76ff81f271f37d1a993f35d4a8ac4259a64ca Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:53:27 +0200 Subject: [PATCH 07/31] MathTagTrait --- js/src/test/scala/com/thirdparty/tags/Tag.scala | 4 ++++ jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/js/src/test/scala/com/thirdparty/tags/Tag.scala b/js/src/test/scala/com/thirdparty/tags/Tag.scala index b76e586..1ee9ec2 100644 --- a/js/src/test/scala/com/thirdparty/tags/Tag.scala +++ b/js/src/test/scala/com/thirdparty/tags/Tag.scala @@ -14,3 +14,7 @@ case class HtmlTag[El <: dom.html.Element]( case class SvgTag[El <: dom.svg.Element]( override val domName: String ) extends Tag[El] + +case class MathTag[El <: dom.svg.Element]( + override val domName: String +) extends Tag[El] diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index ca510e3..4a52709 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -102,7 +102,7 @@ class GeneratorSpec extends AnyFunSpec with Matchers { traitCommentLines = Nil, traitModifiers = Nil, traitName = traitName, - keyKind = "SvgTag", + keyKind = "MathTag", baseImplDefComments = Nil, keyImplName = "mathTag", defType = LazyVal From bfb318692c2dabcb541755db817ef85a69d4ba8a Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 14:56:21 +0200 Subject: [PATCH 08/31] . --- js/src/test/scala/com/thirdparty/tags/Tag.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/test/scala/com/thirdparty/tags/Tag.scala b/js/src/test/scala/com/thirdparty/tags/Tag.scala index 1ee9ec2..2392fa3 100644 --- a/js/src/test/scala/com/thirdparty/tags/Tag.scala +++ b/js/src/test/scala/com/thirdparty/tags/Tag.scala @@ -15,6 +15,6 @@ case class SvgTag[El <: dom.svg.Element]( override val domName: String ) extends Tag[El] -case class MathTag[El <: dom.svg.Element]( +case class MathTag[El <: dom.html.Element]( override val domName: String ) extends Tag[El] From eb7c4738b4af9bf384b8b19cad5a61313d04e024 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 15:08:44 +0200 Subject: [PATCH 09/31] hail mary --- .gitignore | 4 ++++ .vscode/settings.json | 5 +++++ project/build.properties | 2 +- .../raquo/domtypes/codegen/CanonicalGenerator.scala | 8 +++++++- .../com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala | 10 ++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala diff --git a/.gitignore b/.gitignore index 46f4ee5..12438a0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ js/yarn.lock .idea .DS_Store + +.bloop +.metals +metals.sbt \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e72490f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.watcherExclude": { + "**/target": true + } +} \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index b19d4e1..49214c4 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.9.7 +sbt.version = 1.9.9 diff --git a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala index d06386a..64bac92 100644 --- a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala +++ b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala @@ -168,10 +168,16 @@ class CanonicalGenerator( List( s"def ${keyImplName}[$scalaJsElementTypeParam <: $baseScalaJsHtmlElementType]($keyImplNameArgName: String, void: Boolean = false): ${keyKind}[$scalaJsElementTypeParam] = ${keyKindConstructor(keyKind)}($keyImplNameArgName, void)" ) - } else { + } else if (tagType == SvgTagType) { List( s"def ${keyImplName}[$scalaJsElementTypeParam <: $baseScalaJsSvgElementType]($keyImplNameArgName: String): ${keyKind}[$scalaJsElementTypeParam] = ${keyKindConstructor(keyKind)}($keyImplNameArgName)", ) + } else if (tagType == MathMlTagType) { + List( + s"def ${keyImplName}[$scalaJsElementTypeParam <: $baseScalaJsHtmlElementType]($keyImplNameArgName: String): ${keyKind}[$scalaJsElementTypeParam] = ${keyKindConstructor(keyKind)}($keyImplNameArgName)", + ) + } else { + ??? } val headerLines = List( diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala new file mode 100644 index 0000000..5c95816 --- /dev/null +++ b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala @@ -0,0 +1,10 @@ +package com.raquo.domtypes.defs.attrs + +import com.raquo.domtypes.common.{AttrDef, HtmlTagType} + + +object HtmlAttrDefs { + + + +} \ No newline at end of file From a9d8eed765a19e9ac6eb068e481f7466ed199b1f Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Fri, 20 Sep 2024 15:12:34 +0200 Subject: [PATCH 10/31] urgh --- .vscode/settings.json | 5 ----- .../com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala | 10 ---------- 2 files changed, 15 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e72490f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.watcherExclude": { - "**/target": true - } -} \ No newline at end of file diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala b/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala deleted file mode 100644 index 5c95816..0000000 --- a/shared/src/main/scala/com/raquo/domtypes/defs/attrs/MathMlAttrDef.scala +++ /dev/null @@ -1,10 +0,0 @@ -package com.raquo.domtypes.defs.attrs - -import com.raquo.domtypes.common.{AttrDef, HtmlTagType} - - -object HtmlAttrDefs { - - - -} \ No newline at end of file From deb0e9249f04f604a22efb74cc3d14070d98f342 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Mon, 9 Dec 2024 21:44:36 +0100 Subject: [PATCH 11/31] Update MathML tag type. Seems to pass tests with my local scalaJSDom... --- .vscode/settings.json | 5 + .../com/thirdparty/defs/tags/MathMLTags.scala | 97 +++++++++++++++++++ .../test/scala/com/thirdparty/tags/Tag.scala | 2 +- .../com/raquo/domtypes/GeneratorSpec.scala | 6 +- project/Versions.scala | 2 +- .../domtypes/codegen/CanonicalDefGroups.scala | 2 +- .../domtypes/codegen/CanonicalGenerator.scala | 2 +- .../com/raquo/domtypes/common/TagType.scala | 4 +- .../domtypes/defs/tags/MathMlTagDefs.scala | 24 ++--- 9 files changed, 123 insertions(+), 21 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e72490f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.watcherExclude": { + "**/target": true + } +} \ No newline at end of file diff --git a/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala new file mode 100644 index 0000000..107f275 --- /dev/null +++ b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala @@ -0,0 +1,97 @@ +package com.thirdparty.defs.tags + +import com.thirdparty.tags.MathTag +import org.scalajs.dom + +// #NOTE: GENERATED CODE +// - This file is generated at compile time from the data in Scala DOM Types +// - See `GeneratorSpec.scala` for code generation params +// - Contribute to https://github.com/raquo/scala-dom-types to add missing tags / attrs / props / etc. + +trait MathMLTags { + + + def mathTag[El <: dom.html.Element](name: String): MathTag[El] = new MathTag(name) + + + /** + * The top-level element in MathML, representing a mathematical expression. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math math @ MDN]] + */ + lazy val math: MathTag[dom.HTMLElement] = mathTag("math") + + + /** + * Represents a mathematical identifier, such as a variable name. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi mi @ MDN]] + */ + lazy val mi: MathTag[dom.HTMLElement] = mathTag("mi") + + + /** + * Represents a mathematical operator. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo mo @ MDN]] + */ + lazy val mo: MathTag[dom.HTMLElement] = mathTag("mo") + + + /** + * Represents a number in a mathematical expression. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn mn @ MDN]] + */ + lazy val mn: MathTag[dom.HTMLElement] = mathTag("mn") + + + /** + * Represents a superscript expression. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup msup @ MDN]] + */ + lazy val msup: MathTag[dom.HTMLElement] = mathTag("msup") + + + /** + * Represents a subscript expression. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub msub @ MDN]] + */ + lazy val msub: MathTag[dom.HTMLElement] = mathTag("msub") + + + /** + * Represents a fraction. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac mfrac @ MDN]] + */ + lazy val mfrac: MathTag[dom.HTMLElement] = mathTag("mfrac") + + + /** + * Represents a square root. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt msqrt @ MDN]] + */ + lazy val msqrt: MathTag[dom.HTMLElement] = mathTag("msqrt") + + + /** + * Represents a root expression with a specified degree. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot mroot @ MDN]] + */ + lazy val mroot: MathTag[dom.HTMLElement] = mathTag("mroot") + + + /** + * Represents text within a mathematical expression. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtext mtext @ MDN]] + */ + lazy val mtext: MathTag[dom.HTMLElement] = mathTag("mtext") + + +} diff --git a/js/src/test/scala/com/thirdparty/tags/Tag.scala b/js/src/test/scala/com/thirdparty/tags/Tag.scala index 2392fa3..10358e5 100644 --- a/js/src/test/scala/com/thirdparty/tags/Tag.scala +++ b/js/src/test/scala/com/thirdparty/tags/Tag.scala @@ -15,6 +15,6 @@ case class SvgTag[El <: dom.svg.Element]( override val domName: String ) extends Tag[El] -case class MathTag[El <: dom.html.Element]( +case class MathTag[El <: dom.html.MathMLElement]( override val domName: String ) extends Tag[El] diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index 4a52709..21ea9f8 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -2,7 +2,7 @@ package com.raquo.domtypes import com.raquo.domtypes.codegen.DefType.LazyVal import com.raquo.domtypes.codegen._ -import com.raquo.domtypes.common.{HtmlTagType, SvgTagType, MathMlTagType} +import com.raquo.domtypes.common.{HtmlTagType, SvgTagType, MathMLTagType} import com.raquo.domtypes.defs.styles.StyleTraitDefs import org.scalatest.funspec.AnyFunSpec import org.scalatest.matchers.should.Matchers @@ -93,10 +93,10 @@ class GeneratorSpec extends AnyFunSpec with Matchers { it("Generate MathMl tags") { println("=== MATHML TAGS ===") - val traitName = "MathMlTags" + val traitName = "MathMLTags" val fileContent = generator.generateTagsTrait( - tagType = MathMlTagType, + tagType = MathMLTagType, defGroups = defGroups.mathMlTagsDefGroups, printDefGroupComments = false, traitCommentLines = Nil, diff --git a/project/Versions.scala b/project/Versions.scala index e2f8628..6c11b43 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -8,7 +8,7 @@ object Versions { // -- Dependencies -- - val ScalaJsDom = "2.8.0" + val ScalaJsDom = "0.0.0+1556-73c38f87-SNAPSHOT" // -- Test -- diff --git a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala index 3d461a3..fee43e0 100644 --- a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala +++ b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalDefGroups.scala @@ -26,7 +26,7 @@ class CanonicalDefGroups { ) val mathMlTagsDefGroups: List[(String, List[TagDef])] = List( - "MathMl Tags" -> MathMlTagDefs.defs, + "MathMl Tags" -> MathMLTagDefs.defs, ) val htmlAttrDefGroups: List[(String, List[AttrDef])] = List( diff --git a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala index 64bac92..922e1a1 100644 --- a/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala +++ b/shared/src/main/scala/com/raquo/domtypes/codegen/CanonicalGenerator.scala @@ -172,7 +172,7 @@ class CanonicalGenerator( List( s"def ${keyImplName}[$scalaJsElementTypeParam <: $baseScalaJsSvgElementType]($keyImplNameArgName: String): ${keyKind}[$scalaJsElementTypeParam] = ${keyKindConstructor(keyKind)}($keyImplNameArgName)", ) - } else if (tagType == MathMlTagType) { + } else if (tagType == MathMLTagType) { List( s"def ${keyImplName}[$scalaJsElementTypeParam <: $baseScalaJsHtmlElementType]($keyImplNameArgName: String): ${keyKind}[$scalaJsElementTypeParam] = ${keyKindConstructor(keyKind)}($keyImplNameArgName)", ) diff --git a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala index df4d124..75fc85f 100644 --- a/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala +++ b/shared/src/main/scala/com/raquo/domtypes/common/TagType.scala @@ -17,6 +17,6 @@ object SvgTagType extends TagType { override val sourceStr: String = "SvgTagType" } -object MathMlTagType extends TagType { - override val sourceStr: String = "MathMlTagType" +object MathMLTagType extends TagType { + override val sourceStr: String = "MathMLTagType" } diff --git a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala index d71cc1d..e6536af 100644 --- a/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala +++ b/shared/src/main/scala/com/raquo/domtypes/defs/tags/MathMlTagDefs.scala @@ -1,14 +1,14 @@ package com.raquo.domtypes.defs.attrs -import com.raquo.domtypes.common.{MathMlTagType, TagDef} +import com.raquo.domtypes.common.{MathMLTagType, TagDef} -object MathMlTagDefs { +object MathMLTagDefs { val defs: List[TagDef] = List( TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "math", domName = "math", isVoid = false, @@ -23,7 +23,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mi", domName = "mi", isVoid = false, @@ -38,7 +38,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mo", domName = "mo", isVoid = false, @@ -53,7 +53,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mn", domName = "mn", isVoid = false, @@ -68,7 +68,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "msup", domName = "msup", isVoid = false, @@ -83,7 +83,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "msub", domName = "msub", isVoid = false, @@ -99,7 +99,7 @@ object MathMlTagDefs { TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mfrac", domName = "mfrac", isVoid = false, @@ -114,7 +114,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "msqrt", domName = "msqrt", isVoid = false, @@ -129,7 +129,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mroot", domName = "mroot", isVoid = false, @@ -144,7 +144,7 @@ object MathMlTagDefs { ), TagDef( - tagType = MathMlTagType, + tagType = MathMLTagType, scalaName = "mtext", domName = "mtext", isVoid = false, From dbd4aa8bfcf779f583612a565c8eea242d8c8804 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Mon, 9 Dec 2024 21:46:10 +0100 Subject: [PATCH 12/31] conv --- jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala index 21ea9f8..9896096 100644 --- a/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala +++ b/jvm/src/test/scala/com/raquo/domtypes/GeneratorSpec.scala @@ -104,7 +104,7 @@ class GeneratorSpec extends AnyFunSpec with Matchers { traitName = traitName, keyKind = "MathTag", baseImplDefComments = Nil, - keyImplName = "mathTag", + keyImplName = "mathMLTag", defType = LazyVal ) From cb9c9df56640978229e5bae5cd74b6115a49c6b3 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Thu, 12 Dec 2024 21:02:35 +0100 Subject: [PATCH 13/31] sbt has defeated me --- build.sbt | 4 +++- project/Versions.scala | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 1d4a790..740d4e4 100644 --- a/build.sbt +++ b/build.sbt @@ -2,6 +2,8 @@ import VersionHelper.{versionFmt, fallbackVersion} // Lets me depend on Maven Central artifacts immediately without waiting resolvers ++= Resolver.sonatypeOssRepos("public") +resolvers ++= Resolver.sonatypeOssRepos("snapshots") +resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" // Makes sure to increment the version for local development ThisBuild / version := dynverGitDescribeOutput.value @@ -14,7 +16,7 @@ ThisBuild / dynver := { .mkVersion(out => versionFmt(out, dynverSonatypeSnapshots.value), fallbackVersion(d)) } -(ThisBuild / scalaVersion) := Versions.Scala_2_12 +(ThisBuild / scalaVersion) := Versions.Scala_3 (ThisBuild / crossScalaVersions) := Seq( Versions.Scala_3, diff --git a/project/Versions.scala b/project/Versions.scala index 6c11b43..15ebbaa 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -7,8 +7,7 @@ object Versions { val Scala_3 = "3.3.3" // -- Dependencies -- - - val ScalaJsDom = "0.0.0+1556-73c38f87-SNAPSHOT" + val ScalaJsDom = "2.8.0+69-8c4ee126-SNAPSHOT" // -- Test -- From 12bfa0e9cbea26101fee094a190365f6ea167b46 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Thu, 12 Dec 2024 21:09:41 +0100 Subject: [PATCH 14/31] ahha! --- build.sbt | 8 +++++--- project/build.properties | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 740d4e4..339c070 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,9 @@ import VersionHelper.{versionFmt, fallbackVersion} // Lets me depend on Maven Central artifacts immediately without waiting -resolvers ++= Resolver.sonatypeOssRepos("public") -resolvers ++= Resolver.sonatypeOssRepos("snapshots") -resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" +ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("public") +ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots") + // Makes sure to increment the version for local development ThisBuild / version := dynverGitDescribeOutput.value @@ -14,6 +14,8 @@ ThisBuild / dynver := { sbtdynver.DynVer .getGitDescribeOutput(d) .mkVersion(out => versionFmt(out, dynverSonatypeSnapshots.value), fallbackVersion(d)) + + } (ThisBuild / scalaVersion) := Versions.Scala_3 diff --git a/project/build.properties b/project/build.properties index 49214c4..7a159c4 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.9.9 +sbt.version = 1.10.6 From 5d0f6683864992f2fbc3b46c6b4a2ca3b69cde4a Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Thu, 12 Dec 2024 21:42:23 +0100 Subject: [PATCH 15/31] Fix codegen, more tags --- .../com/thirdparty/defs/tags/MathMLTags.scala | 78 ++++++- .../test/scala/com/thirdparty/tags/Tag.scala | 5 +- .../domtypes/codegen/CanonicalGenerator.scala | 4 +- .../domtypes/defs/tags/MathMlTagDefs.scala | 211 ++++++++++++++++-- 4 files changed, 264 insertions(+), 34 deletions(-) diff --git a/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala index 107f275..52fcfd0 100644 --- a/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala +++ b/js/src/test/scala/com/thirdparty/defs/tags/MathMLTags.scala @@ -11,7 +11,7 @@ import org.scalajs.dom trait MathMLTags { - def mathTag[El <: dom.html.Element](name: String): MathTag[El] = new MathTag(name) + def mathMLTag[El <: dom.MathMLElement](name: String): MathTag[El] = new MathTag(name) /** @@ -19,7 +19,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math math @ MDN]] */ - lazy val math: MathTag[dom.HTMLElement] = mathTag("math") + lazy val math: MathTag[dom.MathMLElement] = mathMLTag("math") /** @@ -27,7 +27,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mi mi @ MDN]] */ - lazy val mi: MathTag[dom.HTMLElement] = mathTag("mi") + lazy val mi: MathTag[dom.MathMLElement] = mathMLTag("mi") /** @@ -35,7 +35,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo mo @ MDN]] */ - lazy val mo: MathTag[dom.HTMLElement] = mathTag("mo") + lazy val mo: MathTag[dom.MathMLElement] = mathMLTag("mo") /** @@ -43,7 +43,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mn mn @ MDN]] */ - lazy val mn: MathTag[dom.HTMLElement] = mathTag("mn") + lazy val mn: MathTag[dom.MathMLElement] = mathMLTag("mn") /** @@ -51,7 +51,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msup msup @ MDN]] */ - lazy val msup: MathTag[dom.HTMLElement] = mathTag("msup") + lazy val msup: MathTag[dom.MathMLElement] = mathMLTag("msup") /** @@ -59,7 +59,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msub msub @ MDN]] */ - lazy val msub: MathTag[dom.HTMLElement] = mathTag("msub") + lazy val msub: MathTag[dom.MathMLElement] = mathMLTag("msub") /** @@ -67,7 +67,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mfrac mfrac @ MDN]] */ - lazy val mfrac: MathTag[dom.HTMLElement] = mathTag("mfrac") + lazy val mfrac: MathTag[dom.MathMLElement] = mathMLTag("mfrac") /** @@ -75,7 +75,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msqrt msqrt @ MDN]] */ - lazy val msqrt: MathTag[dom.HTMLElement] = mathTag("msqrt") + lazy val msqrt: MathTag[dom.MathMLElement] = mathMLTag("msqrt") /** @@ -83,7 +83,7 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mroot mroot @ MDN]] */ - lazy val mroot: MathTag[dom.HTMLElement] = mathTag("mroot") + lazy val mroot: MathTag[dom.MathMLElement] = mathMLTag("mroot") /** @@ -91,7 +91,63 @@ trait MathMLTags { * * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtext mtext @ MDN]] */ - lazy val mtext: MathTag[dom.HTMLElement] = mathTag("mtext") + lazy val mtext: MathTag[dom.MathMLElement] = mathMLTag("mtext") + + + /** + * The MathML element is used to attach an accent or a limit under an expression. It uses the following syntax: base underscript + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/munderover munderover @ MDN]] + */ + lazy val munderover: MathTag[dom.MathMLElement] = mathMLTag("munderover") + + + /** + * The MathML element represents a row in a table or a matrix. It may only appear in a element and its children are elements representing cells. This element is similar to the element of HTML. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtr mtr @ MDN]] + */ + lazy val mtr: MathTag[dom.MathMLElement] = mathMLTag("mtr") + + + /** + * The MathML element represents a cell in a table or a matrix. It may only appear in an element. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtd mtd @ MDN]] + */ + lazy val mtd: MathTag[dom.MathMLElement] = mathMLTag("mtd") + + + /** + * The MathML element allows you to create tables or matrices. Its children are elements (representing rows), each of them having elements as its children (representing cells). These elements are similar to , and
elements of HTML. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable mtable @ MDN]] + */ + lazy val mtable: MathTag[dom.MathMLElement] = mathMLTag("mtable") + + + /** + * Represents a base with both a subscript and a superscript. + * + * [[https://developer.mozilla.org/en-US/docs/Web/MathML/Element/msubsup msubsup @ MDN]] + */ + lazy val msubsup: MathTag[dom.MathMLElement] = mathMLTag("msubsup") + + + /** + * The MathML element is used to change the style of its contents. It is similar to the