Implement extension store

This commit is contained in:
Syer10
2026-06-16 22:38:03 -04:00
parent 85fe9802e2
commit 41ef220a0b
44 changed files with 1338 additions and 381 deletions

View File

@@ -276,30 +276,38 @@ class ServerConfig(
description = "Ignore re-uploaded chapters from auto-download",
)
val extensionRepos: MutableStateFlow<List<String>> by ListSetting<String>(
@Deprecated("Will get removed", replaceWith = ReplaceWith("extensionStores"))
val extensionRepos: MutableStateFlow<List<String>> by MigratedConfigValue(
protoNumber = 22,
group = SettingGroup.EXTENSION,
privacySafe = false,
defaultValue = emptyList(),
itemValidator = { url ->
if (url.matches(repoMatchRegex)) {
null
} else {
"Invalid repository URL format"
}
},
itemToValidValue = { url ->
if (url.matches(repoMatchRegex)) {
url
} else {
null
}
},
deprecated =
SettingsRegistry.SettingDeprecated(
replaceWith = "extensionStores",
message = "Replaced with extensionStores",
migrateConfigValue = {
(it.unwrapped() as? List<String>)
?.map {
if (it.contains("github")) {
it.replace(repoMatchRegex) {
"https://raw.githubusercontent.com/${it.groupValues[2]}/${it.groupValues[3]}/" +
(it.groupValues.getOrNull(4)?.ifBlank { null } ?: "repo") +
"/" +
(it.groupValues.getOrNull(5)?.ifBlank { null } ?: "index.min.json")
}
} else {
it
}
}
},
),
readMigrated = { extensionStores.value },
setMigrated = { extensionStores.value = it },
typeInfo =
SettingsRegistry.PartialTypeInfo(
specificType = "List<String>",
),
description = "example: [\"https://github.com/MY_ACCOUNT/MY_REPO/tree/repo\"]",
)
val maxSourcesInParallel: MutableStateFlow<Int> by IntSetting(
@@ -1104,7 +1112,32 @@ class ServerConfig(
privacySafe = true,
defaultValue = false,
description = "Skips the metadata feed and provides download/stream links directly in the chapter list. Improves compatibility with KOReader auto-downloader. KoSync strategies are applied, but PROMPT conflicts are ignored (treating local progress as priority)."
)
val extensionStores: MutableStateFlow<List<String>> by ListSetting<String>(
protoNumber = 97,
group = SettingGroup.EXTENSION,
privacySafe = false,
defaultValue = emptyList(),
itemValidator = { url ->
if (url.isNotEmpty()) {
null
} else {
"Invalid store URL format"
}
},
itemToValidValue = { url ->
if (url.isNotEmpty()) {
url
} else {
null
}
},
typeInfo =
SettingsRegistry.PartialTypeInfo(
specificType = "List<String>",
),
description = "List of extension store index URLs",
)
/** ****************************************************************** **/