Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #272

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@
"error"
]
},
"globals": {
"pdfjsLib": "readonly",
"channel": "readonly"
},
"ignorePatterns": [
"pdf.js",
"pdf.worker.js"
"app/src/*/assets/viewer"
]
}
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build application
on: [pull_request, push]

jobs:
build:
build-linux:
runs-on: ubuntu-latest

steps:
Expand All @@ -18,6 +18,19 @@ jobs:
java-version: 20
cache: gradle

- run: npm ci --ignore-scripts
- name: Build with Gradle
run: ./gradlew build --no-daemon

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17 # Build is broken with JDK 20
cache: gradle
- run: ./gradlew.bat build --no-daemon
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ keystore.properties
/.idea
/releases
/node_modules
/app/src/*/assets/viewer
32 changes: 30 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import java.util.Properties
import org.apache.tools.ant.taskdefs.condition.Os
import java.io.FileInputStream
import java.util.Properties

val keystorePropertiesFile = rootProject.file("keystore.properties")
val useKeystoreProperties = keystorePropertiesFile.canRead()
Expand Down Expand Up @@ -47,7 +48,7 @@ android {
applicationId = "app.grapheneos.pdfviewer"
minSdk = 26
targetSdk = 33
versionCode = 16
versionCode = 18
versionName = versionCode.toString()
resourceConfigurations.add("en")
}
Expand Down Expand Up @@ -94,3 +95,30 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
}

fun getCommand(command: String, winExt: String = "cmd"): String {
return if (Os.isFamily(Os.FAMILY_WINDOWS)) "$command.$winExt" else command
}

val npmSetup = tasks.register("npmSetup", Exec::class) {
workingDir = rootDir
commandLine(getCommand("npm"), "ci", "--ignore-scripts")
}

val processStatic = tasks.register("processStatic", Exec::class) {
workingDir = rootDir
dependsOn(npmSetup)
commandLine(getCommand("node_modules/.bin/ts-node-esm"), "process_static.ts")
}

val cleanStatic = tasks.register("cleanStatic", Delete::class) {
delete("src/main/assets/viewer", "src/debug/assets/viewer")
}

tasks.preBuild {
dependsOn(processStatic)
}

tasks.clean {
dependsOn(cleanStatic)
}
1 change: 0 additions & 1 deletion app/src/main/assets/pdf.js

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/assets/pdf.worker.js

This file was deleted.

281 changes: 0 additions & 281 deletions app/src/main/assets/viewer.js

This file was deleted.

Loading