Refactor code structure

This commit is contained in:
tapframe 2026-06-09 20:42:23 +05:30
parent 2a21f294c5
commit e31c39b1a6
4 changed files with 3809 additions and 3799 deletions

View file

@ -197,14 +197,20 @@ internal object NativePlayerBridge {
private fun exportControlsPageAssets(): ControlsPageAssets {
val root = File(System.getProperty("java.io.tmpdir"), "nuvio-player-ui").apply { mkdirs() }
val fontsDir = root.resolve("fonts").apply { mkdirs() }
val htmlResource = "/player-ui/controls.html"
val html = NativePlayerBridge::class.java.getResourceAsStream(htmlResource)
?.bufferedReader()
?.use { it.readText() }
?: error("Missing native player controls resource: $htmlResource")
val resolvedHtml = html.replace("/* __NUVIO_PLAYER_FONT_FACES__ */", nativePlayerFontFaces())
val htmlFile = root.resolve("controls.html")
writeTextIfChanged(htmlFile, resolvedHtml)
writeTextIfChanged(
target = htmlFile,
text = readTextResource("/player-ui/controls.html"),
)
writeTextIfChanged(
target = root.resolve("controls.css"),
text = readTextResource("/player-ui/controls.css")
.replace("/* __NUVIO_PLAYER_FONT_FACES__ */", nativePlayerFontFaces()),
)
copyResourceIfChanged(
resource = "/player-ui/controls.js",
target = root.resolve("controls.js"),
)
copyResourceIfChanged(
resource = "/composeResources/nuvio.composeapp.generated.resources/font/jetbrains_sans_regular.ttf",
target = fontsDir.resolve("jetbrains_sans_regular.ttf"),
@ -247,6 +253,12 @@ internal object NativePlayerBridge {
}
""".trimIndent()
private fun readTextResource(resource: String): String =
NativePlayerBridge::class.java.getResourceAsStream(resource)
?.bufferedReader(Charsets.UTF_8)
?.use { it.readText() }
?: error("Missing native player controls resource: $resource")
private fun writeTextIfChanged(target: File, text: String) {
val bytes = text.toByteArray(Charsets.UTF_8)
if (target.exists() && target.readBytes().contentEquals(bytes)) return

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff