Skip to content

Commit

Permalink
Run Typst Rust library in isolated process and more
Browse files Browse the repository at this point in the history
Also splits the libraries in two, one for text and markdown, and one for typst.

Some misc improvements and dependency bumps too also
  • Loading branch information
soupslurpr committed Jan 21, 2024
1 parent 77f99b5 commit e9cee78
Show file tree
Hide file tree
Showing 74 changed files with 4,033 additions and 1,545 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ beautyxt_rs/upx.exe
/app/release/apk/release/app-release.apk
/app/release/apk/release/output-metadata.json
/app/release/apk/release/beautyxt-0.17.0.apk
/app/src/main/jniLibs/arm64-v8a/libbeautyxt_rs_plain_text_and_markdown.so
/app/src/main/jniLibs/x86_64/libbeautyxt_rs_plain_text_and_markdown.so
/app/src/main/jniLibs/x86_64/libbeautyxt_rs_typst.so
/app/src/main/jniLibs/arm64-v8a/libbeautyxt_rs_typst.so
/beautyxt_rs_plain_text_and_markdown/upx.exe
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# BeauTyXT

BeauTyXT is a beautiful, private, and minimalistic Text, Markdown, and Typst editor.\
Now supports Typst for uses that need more than just Markdown.\
Implements Material Design 3 and dynamic color schemes – because that's what the cool kids do 😎
BeauTyXT is a beautiful, private, secure, and minimalistic Text, Markdown, and Typst editor.\
Now sandboxes all Rust code in separate processes for better protection against exploitation – because that's what
the cool kids do 😎

## About

Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
}

android {
Expand Down Expand Up @@ -80,7 +81,7 @@ android {

dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation("androidx.navigation:navigation-compose:2.7.6")
implementation("com.google.android.material:material:1.11.0")
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
android:exported="false"
android:isolatedProcess="true"
android:process=":file_view_model_rust_library_isolated_process"></service>
<service
android:name=".ui.TypstProjectViewModelRustLibraryIsolatedService"
android:exported="false"
android:isolatedProcess="true"
android:process=":typst_project_view_model_rust_library_isolated_process"></service>
<activity
android:name="dev.soupslurpr.beautyxt.MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ITypstProjectViewModelRustLibraryAidlInterface.aidl
package dev.soupslurpr.beautyxt;

// Declare any non-default types here with import statements
import dev.soupslurpr.beautyxt.PathAndPfd;

interface ITypstProjectViewModelRustLibraryAidlInterface {
void initializeTypstWorld();
void setMainTypstProjectFile(in PathAndPfd papfd);
void addTypstProjectFiles(in List<PathAndPfd> papfdList);
String getTypstProjectFileText(String path);
Bundle getTypstSvg();
byte[] getTypstPdf();
String updateTypstProjectFile(String newText, String path);
void clearTypstProjectFiles();
}
6 changes: 6 additions & 0 deletions app/src/main/aidl/dev/soupslurpr/beautyxt/PathAndPfd.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// PathAndPfd.aidl
package dev.soupslurpr.beautyxt;

// Declare any non-default types here with import statements

parcelable PathAndPfd;
Binary file not shown.
Binary file not shown.
29 changes: 20 additions & 9 deletions app/src/main/kotlin/dev/soupslurpr/beautyxt/BeauTyXT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@ import dev.soupslurpr.beautyxt.ui.DonationScreen
import dev.soupslurpr.beautyxt.ui.FileEditScreen
import dev.soupslurpr.beautyxt.ui.FileViewModel
import dev.soupslurpr.beautyxt.ui.LicenseScreen
import dev.soupslurpr.beautyxt.ui.PlainTextAndMarkdownRustLibraryCreditsScreen
import dev.soupslurpr.beautyxt.ui.PrivacyPolicyScreen
import dev.soupslurpr.beautyxt.ui.RustLibraryCreditsScreen
import dev.soupslurpr.beautyxt.ui.SettingsScreen
import dev.soupslurpr.beautyxt.ui.StartupScreen
import dev.soupslurpr.beautyxt.ui.TypstProjectScreen
import dev.soupslurpr.beautyxt.ui.TypstProjectViewModel
import dev.soupslurpr.beautyxt.ui.TypstRustLibraryCreditsScreen
import java.time.LocalDateTime
import kotlin.random.Random

Expand All @@ -100,7 +101,8 @@ enum class BeauTyXTScreens(@StringRes val title: Int) {
License(title = R.string.license),
PrivacyPolicy(title = R.string.privacy_policy),
Credits(title = R.string.credits),
RustLibraryCredits(title = R.string.rust_library_credits),
PlainTextAndMarkdownRustLibraryCredits(title = R.string.plain_text_and_markdown_rust_library_credits),
TypstRustLibraryCredits(title = R.string.typst_rust_library_credits),
Donation(title = R.string.donation),
}

Expand Down Expand Up @@ -603,7 +605,7 @@ fun BeauTyXTApp(
if (it != null) {
typstProjectViewModel.refreshProjectFiles(context)
typstProjectViewModel.setCurrentOpenedPath(it, context.contentResolver)
typstProjectUiState.currentOpenedContent.value = typstProjectViewModel.getTypstProjectFileText(
typstProjectViewModel.setTypstProjectFileText(
typstProjectUiState.currentOpenedPath.value
)
}
Expand All @@ -618,7 +620,7 @@ fun BeauTyXTApp(
typstProjectViewModel.refreshProjectFiles(context)
typstProjectViewModel.setCurrentOpenedPath(it, context.contentResolver)
typstProjectViewModel.refreshProjectFiles(context)
typstProjectUiState.currentOpenedContent.value = typstProjectViewModel.getTypstProjectFileText(
typstProjectViewModel.setTypstProjectFileText(
typstProjectUiState.currentOpenedPath.value
)
}
Expand All @@ -634,6 +636,7 @@ fun BeauTyXTApp(
0 -> "Text, but beautiful."
1 -> "TeXTacular!"
2 -> "In Rust We Trust."
3, 4, 5, 6, 7 -> "Supremely sandboxed!"
else -> "Text, but beautiful."
}
}
Expand Down Expand Up @@ -1413,12 +1416,20 @@ ${
PrivacyPolicyScreen()
}
composable(route = BeauTyXTScreens.Credits.name) {
CreditsScreen(onRustLibraryCreditsButtonClicked = {
navController.navigate(BeauTyXTScreens.RustLibraryCredits.name)
})
CreditsScreen(
onPlainTextAndMarkdownRustLibraryCreditsButtonClicked = {
navController.navigate(BeauTyXTScreens.PlainTextAndMarkdownRustLibraryCredits.name)
},
onTypstRustLibraryCreditsButtonClicked = {
navController.navigate(BeauTyXTScreens.TypstRustLibraryCredits.name)
}
)
}
composable(route = BeauTyXTScreens.PlainTextAndMarkdownRustLibraryCredits.name) {
PlainTextAndMarkdownRustLibraryCreditsScreen()
}
composable(route = BeauTyXTScreens.RustLibraryCredits.name) {
RustLibraryCreditsScreen()
composable(route = BeauTyXTScreens.TypstRustLibraryCredits.name) {
TypstRustLibraryCreditsScreen()
}
composable(route = BeauTyXTScreens.Donation.name) {
DonationScreen()
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/kotlin/dev/soupslurpr/beautyxt/PathAndPfd.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.soupslurpr.beautyxt

import android.os.ParcelFileDescriptor
import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class PathAndPfd(
var path: String,
var pfd: ParcelFileDescriptor
) : Parcelable

0 comments on commit e9cee78

Please sign in to comment.