chore: remove finalmarkdown
This commit is contained in:
parent
5c2e6bc02e
commit
cc721e9b53
|
|
@ -1,14 +0,0 @@
|
|||
package chat.stoat.ndk
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class FinalMarkdownNodeTest(
|
||||
val test: Int,
|
||||
)
|
||||
|
||||
@Suppress("KotlinJniMissingFunction")
|
||||
object FinalMarkdown {
|
||||
external fun init(debug: Boolean)
|
||||
external fun process(input: String): FinalMarkdownNodeTest
|
||||
}
|
||||
|
|
@ -1,19 +1,14 @@
|
|||
package chat.stoat.ndk
|
||||
|
||||
import chat.stoat.BuildConfig
|
||||
|
||||
annotation class NativeLibrary(val name: String) {
|
||||
companion object {
|
||||
const val LIB_NAME_NATIVE_MARKDOWN = "stendal"
|
||||
const val LIB_NAME_NATIVE_MARKDOWN_V2 = "finalmarkdown"
|
||||
}
|
||||
}
|
||||
|
||||
object NativeLibraries {
|
||||
fun init() {
|
||||
System.loadLibrary(NativeLibrary.LIB_NAME_NATIVE_MARKDOWN)
|
||||
System.loadLibrary(NativeLibrary.LIB_NAME_NATIVE_MARKDOWN_V2)
|
||||
Stendal.init()
|
||||
FinalMarkdown.init(BuildConfig.DEBUG)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,10 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import chat.stoat.R
|
||||
import chat.stoat.ui.theme.FragmentMono
|
||||
|
||||
enum class LabsHomeScreenTab {
|
||||
Home,
|
||||
|
|
@ -178,15 +175,6 @@ fun LabsHomeScreen(navController: NavController, topNav: NavController) {
|
|||
}
|
||||
)
|
||||
HorizontalDivider()
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Text("Final Markdown")
|
||||
},
|
||||
modifier = Modifier.clickable {
|
||||
navController.navigate("sandboxes/finalmarkdown")
|
||||
}
|
||||
)
|
||||
HorizontalDivider()
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Text("Gradient Editor")
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import androidx.navigation.compose.composable
|
|||
import androidx.navigation.compose.rememberNavController
|
||||
import chat.stoat.api.settings.FeatureFlags
|
||||
import chat.stoat.screens.labs.ui.mockups.NewLoginExperienceMockup
|
||||
import chat.stoat.screens.labs.ui.sandbox.FinalMarkdownSandbox
|
||||
import chat.stoat.screens.labs.ui.sandbox.GradientEditorSandbox
|
||||
import chat.stoat.screens.labs.ui.sandbox.JBMSandbox
|
||||
import chat.stoat.screens.labs.ui.sandbox.NewCardSandboxScreen
|
||||
|
|
@ -75,9 +74,6 @@ fun LabsRootScreen(topNav: NavController) {
|
|||
composable("sandboxes/jbm") {
|
||||
JBMSandbox(labsNav)
|
||||
}
|
||||
composable("sandboxes/finalmarkdown") {
|
||||
FinalMarkdownSandbox(labsNav)
|
||||
}
|
||||
composable("sandboxes/gradienteditor") {
|
||||
GradientEditorSandbox(labsNav)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
package chat.stoat.screens.labs.ui.sandbox
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.navigation.NavController
|
||||
import chat.stoat.ndk.FinalMarkdown
|
||||
import chat.stoat.settings.dsl.SettingsPage
|
||||
|
||||
@Composable
|
||||
fun FinalMarkdownSandbox(navController: NavController) {
|
||||
var mdSource by remember { mutableStateOf("") }
|
||||
var submitMdSource by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
LaunchedEffect(submitMdSource) {
|
||||
submitMdSource?.let {
|
||||
FinalMarkdown.process(it)
|
||||
}
|
||||
}
|
||||
|
||||
SettingsPage(
|
||||
navController = navController,
|
||||
title = {
|
||||
Text(
|
||||
text = "Final Markdown Sandbox",
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
) {
|
||||
Subcategory(
|
||||
title = { Text("Source", maxLines = 1, overflow = TextOverflow.Ellipsis) },
|
||||
) {
|
||||
TextField(
|
||||
value = mdSource,
|
||||
onValueChange = { mdSource = it },
|
||||
label = { Text("Markdown source") },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
TextButton(onClick = {
|
||||
submitMdSource = mdSource
|
||||
}) {
|
||||
Text("Submit")
|
||||
}
|
||||
TextButton(onClick = {
|
||||
submitMdSource = """# Full range of MD now supported!
|
||||
1. Text with **bold**, *italics*, and ***both***!
|
||||
2. You ~~can't see me~~.
|
||||
3. [I'm a link to another website.](<https://revolt.chat>)
|
||||
4. I'm a spoiler with ||**bold text inside it**||
|
||||
- I'm a sub-item on this list...
|
||||
- Let's go even deeper...
|
||||
|
||||
`Inline code`
|
||||
|
||||
```js
|
||||
let x = "I'm a multi-line code block!";
|
||||
```
|
||||
|
||||
> > ${'$'}${'$'}E = mc^2${'$'}${'$'}
|
||||
>
|
||||
> — Albert Einstein
|
||||
|
||||
| Timestamp | Mention | Channel Link | Message Link |
|
||||
|:-:|:-:|:-:|:-:|
|
||||
| <t:1663846662:f> | <@01EX2NCWQ0CHS3QJF0FEQS1GR4> | <#01H73F4RAHTPBHKJ1XBQDXK3NQ> | https://revolt.chat/server/01F7ZSBSFHQ8TA81725KQCSDDP/channel/01F92C5ZXBQWQ8KY7J8KY917NM/01J25XZM9JXVVJDDKFPB7Q48HZ |"""
|
||||
}) {
|
||||
Text("Submit test document")
|
||||
}
|
||||
Subcategory(
|
||||
title = { Text("Output", maxLines = 1, overflow = TextOverflow.Ellipsis) },
|
||||
) {
|
||||
Text("TBD!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import { resolve } from "jsr:@std/path"
|
||||
import { parseArgs } from "jsr:@std/cli/parse-args"
|
||||
import { ZipReader, Uint8ArrayReader, Uint8ArrayWriter } from "jsr:@zip-js/zip-js"
|
||||
|
||||
const args = parseArgs(Deno.args, {
|
||||
boolean: ["yes", "y", "auto-accept"],
|
||||
|
|
@ -12,11 +11,8 @@ const args = parseArgs(Deno.args, {
|
|||
const autoAccept = args.yes || args["auto-accept"]
|
||||
|
||||
const outputFolderParent = resolve(Deno.cwd(), "app", "src", "main", "assets")
|
||||
const jniLibsFolder = resolve(Deno.cwd(), "app", "src", "main", "jniLibs")
|
||||
|
||||
try {
|
||||
Deno.statSync(outputFolderParent)
|
||||
Deno.statSync(jniLibsFolder)
|
||||
} catch (_) {
|
||||
console.error(
|
||||
"\x1b[31m" + // red
|
||||
|
|
@ -333,80 +329,4 @@ for (const dep of deps) {
|
|||
console.log(`Downloaded ${dep.file} to ${file}`)
|
||||
}
|
||||
|
||||
const libsQuery = "https://git.revolt.chat/api/v1/repos/android/final-markdown/releases/latest"
|
||||
|
||||
console.log("The script will now query the Revolt version control server for the latest version"
|
||||
+ " of the final-markdown native library and download it. If you do not wish to use pre-built"
|
||||
+ " libraries, you can build final-markdown yourself from the source code at"
|
||||
+ " https://git.revolt.chat/android/final-markdown, and copy the files to the"
|
||||
+ " app/src/main/jniLibs folder. Note the files that are downloaded are exactly the same as"
|
||||
+ " the ones we use for the app on Google Play, so you can be sure they are safe to use.")
|
||||
|
||||
if (!autoAccept) {
|
||||
console.log(`Will now query ${libsQuery} for the latest version of the library and download it.`)
|
||||
if (!confirm("Continue?")) {
|
||||
console.log("Aborted.")
|
||||
Deno.exit(0)
|
||||
}
|
||||
} else {
|
||||
console.log(`Will now query ${libsQuery} for the latest version of the library and download it. (auto-accepted)`)
|
||||
}
|
||||
|
||||
const queryLibsRes = await fetch(libsQuery)
|
||||
if (!queryLibsRes.ok) {
|
||||
console.error(`Failed to fetch the latest library version: ${queryLibsRes.status} ${queryLibsRes.statusText}`)
|
||||
Deno.exit(1)
|
||||
}
|
||||
|
||||
const libsJson = await queryLibsRes.json()
|
||||
const zipUrl = libsJson
|
||||
.assets
|
||||
.find((asset: { name: string }) => asset.name === "jniLibs.zip")?.browser_download_url
|
||||
|
||||
if (!zipUrl) {
|
||||
console.error("No jniLibs.zip found in the latest release.")
|
||||
Deno.exit(1)
|
||||
}
|
||||
|
||||
const libsRes = await fetch(zipUrl)
|
||||
if (!libsRes.ok) {
|
||||
console.error(`Failed to fetch the jniLibs.zip: ${libsRes.status} ${libsRes.statusText}`)
|
||||
Deno.exit(1)
|
||||
}
|
||||
const libsData = await libsRes.arrayBuffer()
|
||||
|
||||
const libArchitectures = ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"]
|
||||
|
||||
const zipFileBytes = new Uint8Array(libsData)
|
||||
|
||||
const zipReader = new ZipReader(new Uint8ArrayReader(zipFileBytes))
|
||||
|
||||
const entries = await zipReader.getEntries()
|
||||
|
||||
const createDirPromises = libArchitectures.map(arch => {
|
||||
const dirPath = resolve(jniLibsFolder, arch)
|
||||
return Deno.mkdir(dirPath, { recursive: true })
|
||||
})
|
||||
await Promise.all(createDirPromises)
|
||||
|
||||
const writeFilePromises = libArchitectures.map(async arch => {
|
||||
const filePathInZip = `${arch}/libfinalmarkdown.so`
|
||||
|
||||
const entry = entries.find(e => e.filename === filePathInZip)
|
||||
|
||||
if (!entry) {
|
||||
throw new Error(`Expected file not found in zip: ${filePathInZip}`)
|
||||
}
|
||||
|
||||
const writer = new Uint8ArrayWriter()
|
||||
const fileData = await entry.getData!(writer)
|
||||
|
||||
const destinationPath = resolve(jniLibsFolder, filePathInZip)
|
||||
return Deno.writeFile(destinationPath, fileData)
|
||||
})
|
||||
|
||||
await Promise.all(writeFilePromises)
|
||||
|
||||
// Close the zip reader
|
||||
await zipReader.close()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue