feat: facilitate webview dependencies

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2025-01-01 22:23:16 +01:00
parent d95c0ef29d
commit 628d17d7bc
3 changed files with 89 additions and 7 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ local.properties
revoltbuild.properties
sentry.properties
/.kotlin/sessions
app/src/main/assets/embedded

View File

@ -78,7 +78,11 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"
</Tabs>
3. Clone the repository.
3. Download [Deno](https://deno.com).
_Please see the [Deno Runtime Manual](https://docs.deno.com/runtime/getting_started/installation/) for installation guidance._
4. Clone the repository.
```sh
git clone --recursive https://github.com/revoltchat/android.git
@ -86,16 +90,22 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"
Specify `--recursive` to ensure that submodules are cloned as well.
4. Open the project in Android Studio.
5. Open the project in Android Studio.
5. Install the required dependencies.
6. Install the required dependencies.
- Android SDK, latest version
- Android NDK, latest version
You can install these from the SDK Manager in Android Studio.
6. Copy the `revoltbuild.properties.example` file to `revoltbuild.properties` and fill in the required values.
7. Download required additional, embedded dependencies using the provided script.
```sh
deno run -A scripts/download_deps.ts
```
8. Copy the `revoltbuild.properties.example` file to `revoltbuild.properties` and fill in the required values.
```sh
cp revoltbuild.properties.example revoltbuild.properties
@ -110,7 +120,7 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"
| `build.debug.app_name` | The name of the app in debug builds, arbitrary |
| `build.flavour_id` | Leave as `ZZUU` |
7. Copy the `sentry.properties.example` file to `sentry.properties` and fill in the required values.
9. Copy the `sentry.properties.example` file to `sentry.properties` and fill in the required values.
```sh
cp sentry.properties.example sentry.properties
@ -127,11 +137,11 @@ import { Tabs, TabItem, Steps } from "@astrojs/starlight/components"
You can get these values from the Sentry dashboard.
8. Build the project.
10. Build the project.
You can build the project by clicking on the 'Run' button in Android Studio.
If asked, build the `:app` module.
9. **You're all set!** You can now start contributing to Revolt on Android.
11. **You're all set!** You can now start contributing to Revolt on Android.
</Steps>

71
scripts/download_deps.ts Normal file
View File

@ -0,0 +1,71 @@
import { resolve } from "jsr:@std/path"
const outputFolderParent = resolve(Deno.cwd(), "app", "src", "main", "assets")
try {
Deno.statSync(outputFolderParent)
} catch (_) {
console.error(
"\x1b[31m" + // red
"Did you run this script from the correct directory?" +
"\x1b[0m"
)
console.error(
"Usage: " +
"\x1b[35m" + // magenta
"deno run -A scripts/download_deps.ts" +
"\x1b[0m" +
" from the " +
"\x1b[1;31;4m" + // bold red underline
"root" +
"\x1b[0m" +
" directory of the project."
)
Deno.exit(1)
}
const outputFolder = resolve(outputFolderParent, "embedded")
// If it exists, delete it
try {
Deno.removeSync(outputFolder, { recursive: true })
} catch (_) {
// Ignore, might not exist
}
// Create the output folder
Deno.mkdirSync(outputFolder, { recursive: true })
const deps = [
{
file: "katex.min.css",
url: "https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.css",
},
{
file: "katex.min.js",
url: "https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js",
},
{
file: "micromark.bundle.js",
url: "https://esm.sh/v135/micromark@4.0.1/es2022/micromark.bundle.mjs",
},
]
console.log("Will download the following files:")
for (const dep of deps) {
console.log(`- ${dep.file} from ${dep.url}`)
}
if (!confirm("Continue?")) {
console.log("Aborted.")
Deno.exit(0)
}
for (const dep of deps) {
const response = await fetch(dep.url)
const data = await response.arrayBuffer()
const file = resolve(outputFolder, dep.file)
Deno.writeFileSync(file, new Uint8Array(data))
console.log(`Downloaded ${dep.file} to ${file}`)
}
console.log("Done.")