diff --git a/buildSrc/src/main/kotlin/karakum/react/Converter.kt b/buildSrc/src/main/kotlin/karakum/react/Converter.kt index 6e294cf6c..4e4e938c4 100644 --- a/buildSrc/src/main/kotlin/karakum/react/Converter.kt +++ b/buildSrc/src/main/kotlin/karakum/react/Converter.kt @@ -32,22 +32,29 @@ internal fun convertDefinitions( .replace("""fetchPriority?: "high" | "low" | "auto";""", """fetchPriority?: FetchPriority;""") .replace(" | undefined", " | undefined") .replace(" | (string & {})", "") + .replace("((formData: FormData) => void | Promise) |", "") .withDefaultLineBreaks() - val svgTypes = content.substringAfter(" interface IntrinsicElements {\n") - .substringAfter("// SVG\n") + val intrinsicsContent = content.substringAfter(" interface IntrinsicElements {\n") .substringBefore("\n }") .replace("\n\n", "\n") - .replaceIndent(" ") + .replace(" picture", "picture") + .replace(", \n", ",") + .replaceIndent(" ") + + val htmlIntrinsics = intrinsicsContent.substringAfter("// HTML\n") + .substringBefore("// SVG\n") + + val svgIntrinsics = intrinsicsContent.substringAfter("// SVG\n") val reactContent = content .substringAfter("declare namespace React {\n") .substringBefore("\n}\n") - .replace(Regex("""( ReactSVG \{\n).+?(\n\s+})""", RegexOption.DOT_MATCHES_ALL)) { - "${it.groupValues[1]}$svgTypes${it.groupValues[2]}" - } .trimIndent() .plus(ADDITIONAL_TYPES) + .plus("\ninterface ReactSVG {\n$svgIntrinsics\n}") + .plus("\ninterface ReactHTML {\n$htmlIntrinsics\n}") + .trimIndent() return convertInterfaces(reactContent) .plus(convertUnions(reactContent)) diff --git a/buildSrc/src/main/kotlin/karakum/react/Deprecated.kt b/buildSrc/src/main/kotlin/karakum/react/Deprecated.kt index 2671a315b..e69d8a5e1 100644 --- a/buildSrc/src/main/kotlin/karakum/react/Deprecated.kt +++ b/buildSrc/src/main/kotlin/karakum/react/Deprecated.kt @@ -2,4 +2,4 @@ package karakum.react internal fun String.removeDeprecatedMembers(): String = replace(Regex(""" +/\*\*[ \n]*.*@deprecated .*[ \n]*\*/\n +.+?\n"""), "") - .replace(" param: DetailedHTMLFactory, HTMLParamElement>;\n", "") + .replace("param: React.DetailedHTMLProps, HTMLParamElement>;\n", "") diff --git a/buildSrc/src/main/kotlin/karakum/react/EventConverter.kt b/buildSrc/src/main/kotlin/karakum/react/EventConverter.kt index ada545b05..8d11cc86d 100644 --- a/buildSrc/src/main/kotlin/karakum/react/EventConverter.kt +++ b/buildSrc/src/main/kotlin/karakum/react/EventConverter.kt @@ -43,6 +43,8 @@ internal fun convertEventHandlers( } private const val DEFAULT_EVENT_IMPORTS = """ +import react.dom.html.OldState +import react.dom.html.NewState import web.dom.Element import web.window.Window import web.events.Event diff --git a/buildSrc/src/main/kotlin/karakum/react/Generator.kt b/buildSrc/src/main/kotlin/karakum/react/Generator.kt index 98bdda2e7..0e970c494 100644 --- a/buildSrc/src/main/kotlin/karakum/react/Generator.kt +++ b/buildSrc/src/main/kotlin/karakum/react/Generator.kt @@ -52,6 +52,8 @@ private val EXCLUDED_TYPES = setOf( "AutoFillContactField", "AutoFillBase", "AutoFillAddressKind", + "HTMLElementType", + "SVGElementType", ) fun generateKotlinDeclarations( diff --git a/buildSrc/src/main/kotlin/karakum/react/InterfaceConverter.kt b/buildSrc/src/main/kotlin/karakum/react/InterfaceConverter.kt index cdcc211e1..8ae04d24f 100644 --- a/buildSrc/src/main/kotlin/karakum/react/InterfaceConverter.kt +++ b/buildSrc/src/main/kotlin/karakum/react/InterfaceConverter.kt @@ -169,6 +169,7 @@ private fun convertIntrinsicTypes( convert: (String) -> String, ): ConversionResult { val content = source.substringAfter("{\n") + .substringBefore("\n}") .trimIndent() .splitToSequence("\n") .filter { it.isNotEmpty() } @@ -193,9 +194,10 @@ private fun convertHtmlType( val name = source.substringBefore(": ") .removeSurrounding("\"") - val propsType = source.substringAfter(": DetailedHTMLFactory<") + val propsType = source.substringAfter(": React.DetailedHTMLProps<") .substringBefore(",") .replaceFirst("<", "<") + .removePrefix("React.") val type = "IntrinsicType<$propsType>" val id = when (name) { diff --git a/gradle.properties b/gradle.properties index 3dcd71e8c..eb5192e58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ csstype.version=3.1.3 popperjs-core.version=2.11.8 tanstack-react-query.version=5.62.10 tanstack-react-table.version=8.20.6 -types-react.version=18.3.12 +types-react.version=19.0.0 tanstack-react-virtual.version=3.11.2 kotlin-wrappers.version=0.0.1-pre.855 diff --git a/package-lock.json b/package-lock.json index d352bede7..799ad3fee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1119,19 +1119,12 @@ "undici-types": "~6.20.0" } }, - "node_modules/@types/prop-types": { - "version": "15.7.14", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.14.tgz", - "integrity": "sha512-gNMvNH49DJ7OJYv+KAKn0Xp45p8PLl6zo2YnvDIbTd4J6MER2BmWN49TG7n9LvkyihINxeKW8+3bfS2yDC9dzQ==", - "license": "MIT" - }, "node_modules/@types/react": { - "version": "18.3.12", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.12.tgz", - "integrity": "sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw==", + "version": "19.0.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.0.0.tgz", + "integrity": "sha512-MY3oPudxvMYyesqs/kW1Bh8y9VqSmf+tzqw3ae8a9DZW68pUe3zAdHeI1jc6iAysuRdACnVknHP8AhwD4/dxtg==", "license": "MIT", "dependencies": { - "@types/prop-types": "*", "csstype": "^3.0.2" } }, @@ -3032,7 +3025,7 @@ "packages/react-kotlin": { "version": "0.0.0-unspecified", "dependencies": { - "@types/react": "18.3.12", + "@types/react": "19.0.0", "react": "^19.0.0" }, "devDependencies": {}