@tokamakdev/platform-android-arm64 0.1.1-beta.154 → 0.1.1-beta.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,11 +4,9 @@ set -euo pipefail
4
4
  # The CLI runs the entrypoint from the pack root.
5
5
  pack=$PWD
6
6
 
7
- # The build tools of apps and of describing plugins. Coroutines are the version
8
- # androidx.lifecycle brings, so plugins' coroutines add no code.
7
+ # The build tools of apps and of describing plugins.
9
8
  agp_version=8.7.3
10
9
  kotlin_version=2.1.0
11
- coroutines_version=1.9.0
12
10
 
13
11
  # The start of a Gradle project's settings.gradle: the repositories it
14
12
  # resolves plugins and dependencies from.
@@ -22,7 +20,6 @@ pluginManagement {
22
20
  }
23
21
  }
24
22
  dependencyResolutionManagement {
25
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
26
23
  repositories {
27
24
  google()
28
25
  mavenCentral()
@@ -32,7 +29,10 @@ EOF
32
29
  }
33
30
 
34
31
  # The start of a Gradle project's build.gradle: the build tools its modules
35
- # apply.
32
+ # apply, and the Kotlin options every module compiles with. Interface default
33
+ # methods compile into the interface, not into each implementing class, which
34
+ # incremental builds do not recompile when a Tokamak interface in another
35
+ # module gains or changes one.
36
36
  gradle_plugins() {
37
37
  cat <<EOF
38
38
  plugins {
@@ -40,18 +40,30 @@ plugins {
40
40
  id 'com.android.library' version '$agp_version' apply false
41
41
  id 'org.jetbrains.kotlin.android' version '$kotlin_version' apply false
42
42
  }
43
+
44
+ subprojects {
45
+ plugins.withId('org.jetbrains.kotlin.android') {
46
+ kotlin {
47
+ jvmToolchain(17)
48
+ compilerOptions {
49
+ freeCompilerArgs.add('-Xjvm-default=all')
50
+ }
51
+ }
52
+ }
53
+ }
43
54
  EOF
44
55
  }
45
56
 
46
- # Describes the methods PLUGIN/android/Exports.kt exports into
57
+ # Describes the methods REGISTRATION, the plugin's Exports.kt, exports into
47
58
  # OUTPUT/description.json, with the dispatch that serves them,
48
- # OUTPUT/Exports.generated.kt. A JVM unit test of the plugin, compiled with
49
- # the plugin API and its dependencies, runs the registration and reflects on
50
- # the methods it lists.
59
+ # OUTPUT/Exports.generated.kt. A JVM unit test, which depends on the plugin's
60
+ # module, runs the registration and reflects on the methods it lists. The
61
+ # plugin's module builds outside its directory, without the dispatch
62
+ # describing regenerates.
51
63
  describe() {
52
- local plugin=$1 output=$2
53
- if [[ $# -ne 3 || $3 != android ]]; then
54
- echo "Android plugins run on android, not ${*:3}" >&2
64
+ local plugin=$1 registration=$2 output=$3
65
+ if [[ $# -ne 4 || $4 != android ]]; then
66
+ echo "Android plugins run on android, not ${*:4}" >&2
55
67
  exit 2
56
68
  fi
57
69
  local sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}
@@ -62,15 +74,28 @@ describe() {
62
74
  # Global, for the exit trap.
63
75
  temporary=$(mktemp -d "${TMPDIR:-/tmp}/tokamak-describe.XXXXXX")
64
76
  trap 'rm -rf "$temporary"' EXIT
65
- local module=$temporary/plugin
66
- mkdir -p "$module"
77
+ local describer=$temporary/describer plugin_build=$temporary/plugin-build
78
+ mkdir -p "$describer"
67
79
  {
68
80
  gradle_repositories
69
- printf '%s\n' "rootProject.name = 'tokamak-describe'" "include ':plugin'"
81
+ printf '%s\n' "rootProject.name = 'tokamak-describe'" "include ':tokamak-plugin', ':plugin', ':describer'"
82
+ printf "project(':tokamak-plugin').projectDir = file('%s')\n" "$pack/plugin-api"
83
+ printf "project(':plugin').projectDir = file('%s')\n" "$plugin/android"
70
84
  } > "$temporary/settings.gradle"
71
- gradle_plugins > "$temporary/build.gradle"
85
+ {
86
+ gradle_plugins
87
+ cat <<EOF
88
+
89
+ project(':plugin') {
90
+ layout.buildDirectory.set(file('$plugin_build'))
91
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
92
+ exclude { it.file == file('${registration%/*}/Exports.generated.kt') }
93
+ }
94
+ }
95
+ EOF
96
+ } > "$temporary/build.gradle"
72
97
  printf '%s\n' 'android.useAndroidX=true' > "$temporary/gradle.properties"
73
- cat > "$module/build.gradle" <<EOF
98
+ cat > "$describer/build.gradle" <<EOF
74
99
  plugins {
75
100
  id 'com.android.library'
76
101
  id 'org.jetbrains.kotlin.android'
@@ -79,9 +104,7 @@ plugins {
79
104
  android {
80
105
  namespace 'tokamak.describe'
81
106
  compileSdk 35
82
- // The plugin's own files, so compiler errors name them.
83
107
  sourceSets {
84
- main.kotlin.srcDirs = ['$pack/native-shell/plugin', '$plugin/android']
85
108
  test.kotlin.srcDirs = ['$pack/describer']
86
109
  }
87
110
  defaultConfig {
@@ -91,35 +114,22 @@ android {
91
114
  unitTests.returnDefaultValues = true
92
115
  unitTests.all {
93
116
  systemProperty 'tokamak.output', '$output'
94
- systemProperty 'tokamak.classes', layout.buildDirectory.dir('tmp/kotlin-classes/debug').get().asFile.path
117
+ systemProperty 'tokamak.classes', '$plugin_build/tmp/kotlin-classes/debug'
95
118
  outputs.upToDateWhen { false }
96
119
  }
97
120
  }
98
121
  }
99
122
 
100
- kotlin {
101
- jvmToolchain(17)
102
- compilerOptions {
103
- freeCompilerArgs.add('-Xjvm-default=all')
104
- }
105
- }
106
-
107
- // The dispatch describing regenerates.
108
- tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
109
- exclude '**/Exports.generated.kt'
110
- }
111
-
112
- def manifest = new groovy.json.JsonSlurper().parse(file('$plugin/tokamak-plugin.json'))
113
123
  dependencies {
114
- implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version'
115
- (manifest.platforms?.android?.dependencies ?: []).each { implementation it }
124
+ testImplementation project(':tokamak-plugin')
125
+ testImplementation project(':plugin')
116
126
  testImplementation 'junit:junit:4.13.2'
117
127
  testImplementation 'org.jetbrains.kotlin:kotlin-reflect:$kotlin_version'
118
128
  // android.jar's org.json is stubs; the describer writes JSON with the reference implementation.
119
129
  testImplementation 'org.json:json:20250517'
120
130
  }
121
131
  EOF
122
- gradle --quiet --project-dir "$temporary" :plugin:testDebugUnitTest
132
+ gradle --quiet --project-dir "$temporary" :describer:testDebugUnitTest
123
133
  if [[ -f "$output/error" ]]; then
124
134
  cat "$output/error" >&2
125
135
  rm "$output/error"
@@ -132,7 +142,7 @@ if [[ $# -ge 1 && $1 == describe ]]; then
132
142
  fi
133
143
 
134
144
  if [[ $# -ne 3 || $1 != build ]]; then
135
- echo "usage: entrypoint build INPUT OUTPUT | entrypoint describe PLUGIN OUTPUT android" >&2
145
+ echo "usage: entrypoint build INPUT OUTPUT | entrypoint describe PLUGIN REGISTRATION OUTPUT android" >&2
136
146
  exit 2
137
147
  fi
138
148
 
@@ -197,6 +207,7 @@ assets=$app/src/main/assets/app
197
207
  kotlin=$app/src/main/kotlin/com/tokamak/runtime
198
208
  plugin_api=$project/tokamak-plugin
199
209
  plugin_modules=$project/plugins
210
+ generated_modules=$project/generated
200
211
  # The oldest Android API level the app supports.
201
212
  min_sdk=$(<"$pack/build/min-sdk")
202
213
 
@@ -260,55 +271,6 @@ release_signing() {
260
271
  EOF
261
272
  }
262
273
 
263
- # The gateway's server certificate for the app host, with its key, in
264
- # assets/tokamak-gateway.p12. The network security config trusts the
265
- # certificate's authority for the app host alone, so the WebView verifies the
266
- # gateway itself. Each build creates its own authority and discards the
267
- # authority's key. The gateway's key ships in the app, which is safe only while
268
- # the WebView sends the app host's traffic to no listener but the gateway. The
269
- # keystore's password is public, so the keystore uses the algorithms every
270
- # Android version reads, at one iteration, and the certificates outlive any app.
271
- gateway_identity() {
272
- local keytool=keytool
273
- if [[ -n "${JAVA_HOME:-}" ]]; then
274
- keytool=$JAVA_HOME/bin/keytool
275
- fi
276
- if ! command -v "$keytool" > /dev/null; then
277
- echo "Android builds create the gateway certificate with keytool, which the JDK provides" >&2
278
- exit 69
279
- fi
280
- local resources=$app/src/main/res
281
- local keystore=(
282
- "$keytool"
283
- -J-Dkeystore.pkcs12.certProtectionAlgorithm=NONE
284
- -J-Dkeystore.pkcs12.keyProtectionAlgorithm=PBEWithSHA1AndDESede
285
- -J-Dkeystore.pkcs12.macAlgorithm=HmacPBESHA1
286
- -J-Dkeystore.pkcs12.keyPbeIterationCount=1
287
- -J-Dkeystore.pkcs12.macIterationCount=1
288
- -keystore "$app/src/main/assets/tokamak-gateway.p12" -storetype PKCS12 -storepass tokamak
289
- )
290
- local key=(-keyalg EC -groupname secp256r1 -sigalg SHA256withECDSA -validity 36500)
291
- mkdir -p "$resources/raw" "$resources/xml"
292
- "${keystore[@]}" -genkeypair -alias authority "${key[@]}" -dname 'CN=tokamak gateway' \
293
- -ext bc:c=ca:true,pathlen:0
294
- "${keystore[@]}" -genkeypair -alias gateway "${key[@]}" -dname "CN=$host" -signer authority \
295
- -ext "san=dns:$host" -ext eku=serverAuth -ext ku:c=digitalSignature
296
- "${keystore[@]}" -exportcert -alias authority -rfc -file "$resources/raw/tokamak_gateway_authority.pem"
297
- "${keystore[@]}" -delete -alias authority
298
- cat > "$resources/xml/tokamak_network_security_config.xml" <<EOF
299
- <?xml version="1.0" encoding="utf-8"?>
300
- <network-security-config>
301
- <base-config cleartextTrafficPermitted="false" />
302
- <domain-config>
303
- <domain includeSubdomains="false">$(xml_escape "$host")</domain>
304
- <trust-anchors>
305
- <certificates src="@raw/tokamak_gateway_authority" />
306
- </trust-anchors>
307
- </domain-config>
308
- </network-security-config>
309
- EOF
310
- }
311
-
312
274
  xml_escape() {
313
275
  printf '%s' "$1" |
314
276
  sed -e 's/&/\&amp;/g' \
@@ -318,26 +280,12 @@ xml_escape() {
318
280
  -e "s/'/\&apos;/g"
319
281
  }
320
282
 
321
- rm -rf "$app/src/main/assets" "$app/src/main/jniLibs" "$app/src/main/kotlin" "$app/src/main/res" "$app/user" "$plugin_api" "$plugin_modules" "$output"
322
- mkdir -p "$native" "$assets" "$kotlin" "$app/src/main/res" "$plugin_api/src/main/kotlin"
283
+ rm -rf "$app/src/main/assets" "$app/src/main/jniLibs" "$app/src/main/kotlin" "$app/src/main/res" "$app/user" "$plugin_api" "$plugin_modules" "$generated_modules" "$output"
284
+ mkdir -p "$native" "$assets" "$kotlin" "$app/src/main/res" "$plugin_modules" "$generated_modules"
323
285
  cp -R "$input/app/." "$assets/"
324
286
  link_runtime
325
287
  cp -R "$pack/native-shell/app/." "$kotlin/"
326
- cp -R "$pack/native-shell/plugin/." "$plugin_api/src/main/kotlin/"
327
- cat > "$plugin_api/build.gradle" <<EOF
328
- plugins {
329
- id 'com.android.library'
330
- id 'org.jetbrains.kotlin.android'
331
- }
332
-
333
- android {
334
- namespace 'com.tokamak.runtime.plugin'
335
- }
336
-
337
- dependencies {
338
- api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version'
339
- }
340
- EOF
288
+ cp -R "$pack/plugin-api" "$plugin_api"
341
289
 
342
290
  has_icon=false
343
291
  if [[ -n "$icon" ]]; then
@@ -350,46 +298,48 @@ if [[ -n "$icon" ]]; then
350
298
  fi
351
299
  has_icon=true
352
300
  fi
353
- gateway_identity
354
301
 
355
- # Each plugin is a library module, so its manifest merges below the app's and
356
- # its dependencies stay its own. Its class is a Kotlin class name in a package,
357
- # which the registry creates, and its dependencies are Maven coordinates.
302
+ # Each plugin's Gradle module is a library module of the app, so its manifest
303
+ # merges below the app's and its dependencies resolve with the app's. Its class
304
+ # is a Kotlin class name in a package, which the registry creates. The
305
+ # manifest and raw resources its build script generates are a library module of
306
+ # their own.
358
307
  kotlin_class='^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+$'
359
- maven_coordinate='^[A-Za-z0-9._-]+:[A-Za-z0-9._-]+:[A-Za-z0-9._-]+$'
360
308
  registry=$kotlin/TokamakPluginRegistry.kt
361
309
  printf '%s\n\n%s\n%s\n' 'package com.tokamak.runtime' 'internal fun tokamakPlugins(app: TokamakApplication): List<TokamakPlugin> =' ' listOf(' > "$registry"
362
310
  shopt -s nullglob
363
311
  raw_names=" "
364
- plugin_includes=
365
- plugin_dependencies=
312
+ module_includes=
313
+ module_dependencies=
314
+ # Includes the module $1 in the build, as a dependency of the app.
315
+ include_module() {
316
+ module_includes+="include '$1'"$'\n'
317
+ module_dependencies+=" implementation project('$1')"$'\n'
318
+ }
366
319
  for plugin in "$input/plugins"/*/; do
367
320
  plugin_id=$(basename "$plugin")
368
- plugin_includes+="include ':plugins:$plugin_id'"$'\n'
369
- plugin_dependencies+=" implementation project(':plugins:$plugin_id')"$'\n'
370
321
  class=$(cat "$plugin/class" 2>/dev/null || true)
371
322
  if [[ ! "$class" =~ $kotlin_class ]]; then
372
323
  echo "plugin '$plugin_id' has invalid android class '$class'" >&2
373
324
  exit 1
374
325
  fi
326
+ if [[ ! -f "$plugin/native/build.gradle.kts" && ! -f "$plugin/native/build.gradle" ]]; then
327
+ echo "plugin '$plugin_id' has no Gradle module, android/build.gradle.kts" >&2
328
+ exit 1
329
+ fi
330
+ cp -R "$plugin/native" "$plugin_modules/$plugin_id"
331
+ include_module ":plugins:$plugin_id"
375
332
  # A plugin that exports methods runs behind the dispatch generated for it,
376
333
  # whose companion object converts its values for its host.
377
- if [[ -f "$plugin/native/Exports.kt" ]]; then
334
+ if [[ -n "$(find "$plugin/native" -name Exports.kt -print -quit)" ]]; then
378
335
  printf ' %sDispatch(app.host("%s", %sDispatch)),\n' "$class" "$plugin_id" "$class" >> "$registry"
379
336
  else
380
337
  printf ' %s(app.host("%s")),\n' "$class" "$plugin_id" >> "$registry"
381
338
  fi
382
- module=$plugin_modules/$plugin_id
383
- mkdir -p "$module/src/main/kotlin"
384
- if [[ -d "$plugin/native" ]]; then
385
- while IFS= read -r -d '' source; do
386
- relative=${source#"$plugin/native/"}
387
- mkdir -p "$module/src/main/kotlin/$(dirname "$relative")"
388
- cp "$source" "$module/src/main/kotlin/$relative"
389
- done < <(find "$plugin/native" -name '*.kt' -print0)
390
- fi
339
+ generated=$generated_modules/$plugin_id
391
340
  if [[ -f "$plugin/manifest" ]]; then
392
- cp "$plugin/manifest" "$module/src/main/AndroidManifest.xml"
341
+ mkdir -p "$generated/src/main"
342
+ cp "$plugin/manifest" "$generated/src/main/AndroidManifest.xml"
393
343
  fi
394
344
  for resource in "$plugin/raw"/*; do
395
345
  [[ -f "$resource" ]] || continue
@@ -401,56 +351,60 @@ for plugin in "$input/plugins"/*/; do
401
351
  exit 1
402
352
  fi
403
353
  raw_names+=" ${name%%.*} "
404
- mkdir -p "$module/src/main/res/raw"
405
- cp "$resource" "$module/src/main/res/raw/$name"
354
+ mkdir -p "$generated/src/main/res/raw"
355
+ cp "$resource" "$generated/src/main/res/raw/$name"
406
356
  done
407
- {
408
- printf '%s\n' 'plugins {' " id 'com.android.library'" " id 'org.jetbrains.kotlin.android'"
409
- printf '%s\n\n' '}'
410
- printf '%s\n' 'android {'
411
- printf " namespace 'tokamak.plugins.%s'\n" "${plugin_id//-/_}"
412
- printf '%s\n\n' '}'
413
- printf '%s\n' 'dependencies {' " implementation project(':tokamak-plugin')"
414
- for dependency in "$plugin/dependencies"/*; do
415
- coordinate=$(cat "$dependency")
416
- if [[ ! "$coordinate" =~ $maven_coordinate ]]; then
417
- echo "plugin '$plugin_id' has invalid android dependency '$coordinate'; use group:artifact:version" >&2
418
- exit 1
419
- fi
420
- printf " implementation '%s'\n" "$coordinate"
421
- done
422
- printf '%s\n' '}'
423
- } > "$module/build.gradle"
357
+ if [[ -d "$generated" ]]; then
358
+ cat > "$generated/build.gradle" <<EOF
359
+ plugins {
360
+ id 'com.android.library'
361
+ }
362
+
363
+ android {
364
+ namespace 'tokamak.generated.${plugin_id//-/_}'
365
+ compileSdk 35
366
+ defaultConfig {
367
+ minSdk $min_sdk
368
+ }
369
+ }
370
+ EOF
371
+ include_module ":generated:$plugin_id"
372
+ fi
424
373
  done
425
374
  printf '%s\n' ' )' >> "$registry"
426
375
 
427
376
  {
428
377
  gradle_repositories
429
378
  printf '%s\n' "rootProject.name = 'tokamak'" "include ':app', ':tokamak-plugin'"
430
- printf '%s' "$plugin_includes"
379
+ printf '%s' "$module_includes"
431
380
  } > "$project/settings.gradle"
432
381
 
382
+ # Every module's dependencies resolve to at least the versions the app's lock
383
+ # pins, in Gradle's lock files. The lock is lenient because Gradle can resolve
384
+ # a locked build differently from the build that wrote the lock
385
+ # (gradle/gradle#21396). Without a lock, the build writes one, resolving every
386
+ # module's compile and runtime classpaths, which debug and release builds use.
387
+ lock=$input/lock
388
+ gradle_arguments=("-Ptokamak.version=$version" ":app:lint$task" ":app:assemble$task")
389
+ if [[ ! -d "$lock" ]]; then
390
+ gradle_arguments+=(--write-locks tokamakLockDependencies)
391
+ mkdir -p "$lock"
392
+ fi
433
393
  {
434
394
  gradle_plugins
435
395
  cat <<EOF
436
396
 
437
397
  subprojects {
438
398
  plugins.withType(com.android.build.gradle.api.AndroidBasePlugin) {
439
- android {
440
- compileSdk 35
441
- defaultConfig {
442
- minSdk $min_sdk
443
- }
399
+ dependencyLocking {
400
+ lockAllConfigurations()
401
+ lockMode = LockMode.LENIENT
402
+ lockFile = file('$lock/' + path.substring(1).replace(':', '.') + '.lockfile')
444
403
  }
445
- }
446
- plugins.withId('org.jetbrains.kotlin.android') {
447
- kotlin {
448
- jvmToolchain(17)
449
- // Interface default methods compile into the interface, not into each
450
- // implementing class, which incremental builds do not recompile when a
451
- // Tokamak interface in another module gains or changes one.
452
- compilerOptions {
453
- freeCompilerArgs.add('-Xjvm-default=all')
404
+ tasks.register('tokamakLockDependencies') {
405
+ def classpaths = configurations.matching { it.name.endsWith('CompileClasspath') || it.name.endsWith('RuntimeClasspath') }
406
+ doLast {
407
+ classpaths.each { it.incoming.resolutionResult.root }
454
408
  }
455
409
  }
456
410
  }
@@ -458,7 +412,9 @@ subprojects {
458
412
  EOF
459
413
  } > "$project/build.gradle"
460
414
 
461
- printf '%s\n' 'android.useAndroidX=true' > "$project/gradle.properties"
415
+ # Lint and R8 run in the Gradle daemon, whose default 512 MiB heap runs out
416
+ # when they analyse an app with several plugin modules.
417
+ printf '%s\n' 'android.useAndroidX=true' 'org.gradle.jvmargs=-Xmx4g' > "$project/gradle.properties"
462
418
  cat > "$project/app/build.gradle" <<EOF
463
419
  plugins {
464
420
  id 'com.android.application'
@@ -467,9 +423,11 @@ plugins {
467
423
 
468
424
  android {
469
425
  namespace 'com.tokamak.runtime'
426
+ compileSdk 35
470
427
 
471
428
  defaultConfig {
472
429
  applicationId '$identifier'
430
+ minSdk $min_sdk
473
431
  targetSdk 35
474
432
  versionCode 1
475
433
  versionName providers.gradleProperty('tokamak.version').get()
@@ -500,7 +458,7 @@ dependencies {
500
458
  implementation 'androidx.webkit:webkit:1.12.1'
501
459
  implementation project(':tokamak-plugin')
502
460
  EOF
503
- printf '%s}\n' "$plugin_dependencies" >> "$project/app/build.gradle"
461
+ printf '%s}\n' "$module_dependencies" >> "$project/app/build.gradle"
504
462
 
505
463
  if [[ -n "$user_manifest" ]]; then
506
464
  mkdir -p "$app/user"
@@ -524,7 +482,7 @@ manifest=$app/src/main/AndroidManifest.xml
524
482
  if [[ "$has_icon" == true ]]; then
525
483
  icon_attribute=' android:icon="@mipmap/ic_launcher"'
526
484
  fi
527
- printf ' <application android:name=".TokamakApplication" android:label="%s"%s android:networkSecurityConfig="@xml/tokamak_network_security_config">\n' "$(xml_escape "$app_name")" "$icon_attribute"
485
+ printf ' <application android:name=".TokamakApplication" android:label="%s"%s>\n' "$(xml_escape "$app_name")" "$icon_attribute"
528
486
  printf ' <meta-data android:name="tokamak.host" android:value="%s" />\n' "$host"
529
487
  if [[ -n "$dev_endpoint" ]]; then
530
488
  printf ' <meta-data android:name="tokamak.dev.endpoint" android:value="%s" />\n' "$dev_endpoint"
@@ -549,6 +507,6 @@ printf '%s\n' \
549
507
  '-keepclassmembers class * implements com.tokamak.runtime.TokamakRuntime$Plugins { *; }' \
550
508
  > "$app/tokamak-rules.pro"
551
509
 
552
- gradle --no-daemon "-Ptokamak.version=$version" ":app:lint$task" ":app:assemble$task" --project-dir "$project"
510
+ gradle --no-daemon "${gradle_arguments[@]}" --project-dir "$project"
553
511
  mkdir -p "$(dirname "$output")"
554
512
  cp "$app/build/outputs/apk/$variant/app-$variant.apk" "$output"
@@ -68,7 +68,7 @@ private fun registration(classes: File): TokamakExports<*> {
68
68
  .filter { TokamakExports::class.java.isAssignableFrom(it) && !it.isInterface }
69
69
  .toList()
70
70
  val registration = registrations.singleOrNull()
71
- ?: throw DescribeError("android/Exports.kt declares one object that implements TokamakExports, not ${registrations.size}")
71
+ ?: throw DescribeError("Exports.kt declares one object that implements TokamakExports, not ${registrations.size}")
72
72
  return registration.kotlin.objectInstance as? TokamakExports<*>
73
73
  ?: throw DescribeError("${registration.simpleName} is an object")
74
74
  }
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/android-arm64/lib/TokamakRuntime/libtokamak.a
3
- size: 35491552 bytes
4
- sha256: c6c8fa2befb1c13110a8277ac80a59d60429bd236abca8351ff68e17dc66e372
3
+ size: 35501050 bytes
4
+ sha256: 0b6750c489dc8075331637a2b990298e118528c270e5e30ee774134f32343d44
@@ -23,6 +23,9 @@ class TokamakActivity : Activity() {
23
23
  get() = application as TokamakApplication
24
24
  internal lateinit var webView: WebView
25
25
  private set
26
+ private var runtime: TokamakRuntime? = null
27
+ private var proxyPort: Int? = null
28
+ private var restoreGeneration = 0L
26
29
  private var destroyed = false
27
30
 
28
31
  override fun onCreate(savedInstanceState: Bundle?) {
@@ -51,6 +54,13 @@ class TokamakActivity : Activity() {
51
54
  deliver(intent)
52
55
  }
53
56
 
57
+ override fun onResume() {
58
+ super.onResume()
59
+ restoreGeneration += 1
60
+ val generation = restoreGeneration
61
+ runtime?.let { restoreGateway(it, generation) }
62
+ }
63
+
54
64
  override fun onDestroy() {
55
65
  destroyed = true
56
66
  if (tokamak.activity === this) tokamak.activity = null
@@ -85,9 +95,35 @@ class TokamakActivity : Activity() {
85
95
  show(FAILED)
86
96
  return
87
97
  }
98
+ this.runtime = runtime
99
+ proxyPort = runtime.port
88
100
  TokamakProxy.route(this, tokamak.appHost, runtime.port) { load(runtime) }
89
101
  }
90
102
 
103
+ /** Waits for the gateway and re-routes the proxy once its port moved. */
104
+ private fun restoreGateway(runtime: TokamakRuntime, generation: Long) {
105
+ Thread {
106
+ val result = runCatching { runtime.restoreGateway() }
107
+ runOnUiThread {
108
+ if (
109
+ destroyed ||
110
+ this.runtime !== runtime ||
111
+ generation != restoreGeneration
112
+ ) return@runOnUiThread
113
+ result
114
+ .onSuccess { port ->
115
+ if (port != proxyPort) {
116
+ proxyPort = port
117
+ TokamakProxy.route(this, tokamak.appHost, port) { load(runtime) }
118
+ }
119
+ }
120
+ .onFailure { error ->
121
+ Log.w(TAG, "tokamak gateway could not recover", error)
122
+ }
123
+ }
124
+ }.start()
125
+ }
126
+
91
127
  private fun load(runtime: TokamakRuntime) {
92
128
  if (destroyed) return
93
129
  webView.webViewClient =
@@ -11,7 +11,6 @@ import androidx.lifecycle.Lifecycle
11
11
  import androidx.lifecycle.LifecycleOwner
12
12
  import androidx.lifecycle.ProcessLifecycleOwner
13
13
  import java.io.File
14
- import java.security.KeyStore
15
14
  import java.util.concurrent.Executors
16
15
  import kotlin.coroutines.resume
17
16
  import kotlin.reflect.KClass
@@ -24,12 +23,6 @@ private const val DEV_SESSION_TOKEN_METADATA = "tokamak.dev.session-token"
24
23
  /** How long the Worker has for `resume` and `suspend`. */
25
24
  private const val LIFECYCLE_DEADLINE_MILLIS = 10_000L
26
25
 
27
- /** The asset holding the gateway's server certificate and key, which the build creates. */
28
- private const val GATEWAY_KEYSTORE = "tokamak-gateway.p12"
29
-
30
- /** The gateway keystore's password, which is public: the key ships in the app. */
31
- private const val GATEWAY_KEYSTORE_PASSWORD = "tokamak"
32
-
33
26
  /**
34
27
  * The tokamak process. Owns the runtime and native plugins, which outlive any activity, so a
35
28
  * plugin can run Worker code when the system starts the app in the background.
@@ -146,10 +139,10 @@ class TokamakApplication : Application(), TokamakPlugins {
146
139
 
147
140
  override fun <T : Any> fromJson(json: Any?, type: KClass<T>): T = codec(::unregistered).fromJson(json, type)
148
141
 
149
- /** The plugin's codec, or else the error [missing] gives: a plugin without `android/Exports.kt` has none. */
142
+ /** The plugin's codec, or else the error [missing] gives: a plugin without `Exports.kt` has none. */
150
143
  private fun codec(missing: () -> TokamakPluginError): TokamakCodec = codec ?: throw missing()
151
144
 
152
- private fun unregistered() = TokamakPluginError.typeError("$id has no android/Exports.kt")
145
+ private fun unregistered() = TokamakPluginError.typeError("$id has no Exports.kt")
153
146
 
154
147
  override fun fetch(path: String, timeoutMillis: Long): ByteArray =
155
148
  withRuntime(timeoutMillis) { runtime, remainingMillis -> runtime.fetch(path, remainingMillis) }
@@ -207,15 +200,14 @@ class TokamakApplication : Application(), TokamakPlugins {
207
200
  val endpoint = metadata?.getString(DEV_ENDPOINT_METADATA)
208
201
  val sessionToken = metadata?.getString(DEV_SESSION_TOKEN_METADATA)
209
202
  val startsInForeground = activity != null
210
- val server = gatewayIdentity()
211
203
  val runtime =
212
204
  if (!endpoint.isNullOrEmpty() && !sessionToken.isNullOrEmpty()) {
213
205
  TokamakRuntime.startDevelopment(
214
- stateDir(), appHost, endpoint, sessionToken, server, startsInForeground, workerPlugins,
206
+ stateDir(), appHost, endpoint, sessionToken, startsInForeground, workerPlugins,
215
207
  )
216
208
  } else {
217
209
  TokamakRuntime.start(
218
- unpackApp(), stateDir(), storageDir(), appHost, server, startsInForeground, workerPlugins,
210
+ unpackApp(), stateDir(), storageDir(), appHost, startsInForeground, workerPlugins,
219
211
  )
220
212
  }
221
213
  mainExecutor.execute {
@@ -224,14 +216,6 @@ class TokamakApplication : Application(), TokamakPlugins {
224
216
  return runtime
225
217
  }
226
218
 
227
- /** The gateway's server certificate and key. */
228
- private fun gatewayIdentity(): KeyStore.PrivateKeyEntry {
229
- val password = GATEWAY_KEYSTORE_PASSWORD.toCharArray()
230
- val keystore = KeyStore.getInstance("PKCS12")
231
- assets.open(GATEWAY_KEYSTORE).use { keystore.load(it, password) }
232
- return keystore.getEntry("gateway", KeyStore.PasswordProtection(password)) as KeyStore.PrivateKeyEntry
233
- }
234
-
235
219
  private fun metadata() =
236
220
  packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA).metaData
237
221
 
@@ -6,30 +6,36 @@ import androidx.webkit.ProxyController
6
6
 
7
7
  /**
8
8
  * Routes the app host, in every WebView of the process, through the gateway's port. The gateway
9
- * keeps one port for the life of the process, so the route is set once and never cleared: without
10
- * it the WebView would connect to the app host itself, where another app or device could answer.
11
- * Main thread only.
9
+ * can lose its port and bind another, so the route follows whichever port it reports. Without a
10
+ * route the WebView would connect to the app host itself, where another app or device could
11
+ * answer. Main thread only.
12
12
  */
13
13
  internal object TokamakProxy {
14
- private var routed = false
14
+ private var routed: Int? = null
15
+ private var requested: Int? = null
15
16
  private val waiting = mutableListOf<() -> Unit>()
16
17
 
17
- /** Routes [host] through the gateway's [port], then runs [ready] once the route is in place. */
18
+ /**
19
+ * Routes [host] through the gateway's [port], then runs [ready] once the route is in place. A
20
+ * call for another port while a route is pending replaces it, and every waiting [ready] runs
21
+ * once the latest route is in place.
22
+ */
18
23
  fun route(context: Context, host: String, port: Int, ready: () -> Unit) {
19
- if (routed) {
24
+ if (routed == port && requested == port) {
20
25
  ready()
21
26
  return
22
27
  }
23
28
  waiting += ready
24
- // Only the first caller requests the route.
25
- if (waiting.size > 1) return
29
+ if (requested == port) return
30
+ requested = port
26
31
  val config = ProxyConfig.Builder()
27
32
  .addProxyRule("http://127.0.0.1:$port")
28
33
  .addBypassRule(host)
29
34
  .setReverseBypassEnabled(true)
30
35
  .build()
31
36
  ProxyController.getInstance().setProxyOverride(config, context.mainExecutor) {
32
- routed = true
37
+ routed = port
38
+ if (requested != port) return@setProxyOverride
33
39
  waiting.forEach { it() }
34
40
  waiting.clear()
35
41
  }
@@ -1,7 +1,6 @@
1
1
  package com.tokamak.runtime
2
2
 
3
3
  import java.io.File
4
- import java.security.KeyStore
5
4
 
6
5
  /** The tokamak runtime, running for the life of the process. */
7
6
  internal class TokamakRuntime private constructor(private val handle: Long) {
@@ -28,6 +27,15 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
28
27
  val port: Int
29
28
  get() = nativePort(handle)
30
29
 
30
+ /**
31
+ * The authority a server certificate for [host] must chain to, or null
32
+ * when tokamak does not vouch for the host.
33
+ */
34
+ fun serverAuthority(host: String): ByteArray? = nativeServerAuthority(handle, host)
35
+
36
+ /** Wait for the runtime's loopback gateway and return its current port. */
37
+ fun restoreGateway(): Int = nativeRestoreGateway(handle)
38
+
31
39
  /**
32
40
  * Delivers the event [name] with its encoded [payload] to the Worker's listeners, blocking
33
41
  * until they return or [timeoutMillis] passes, and returns their encoded reply, which is empty
@@ -68,15 +76,14 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
68
76
  }
69
77
 
70
78
  /**
71
- * Start the runtime, which delivers `start` with [foreground], whose Worker calls
72
- * [plugins], and whose gateway presents [server], throwing when it cannot serve the app.
79
+ * Start the runtime, which delivers `start` with [foreground] and whose Worker calls
80
+ * [plugins], throwing when it cannot serve the app.
73
81
  */
74
82
  fun start(
75
83
  packagedDir: File,
76
84
  stateDir: File,
77
85
  storageDir: File,
78
86
  host: String,
79
- server: KeyStore.PrivateKeyEntry,
80
87
  foreground: Boolean,
81
88
  plugins: Plugins,
82
89
  ): TokamakRuntime =
@@ -86,8 +93,6 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
86
93
  stateDir.path,
87
94
  storageDir.path,
88
95
  host,
89
- server.chain(),
90
- server.privateKey.encoded,
91
96
  foreground,
92
97
  plugins,
93
98
  ),
@@ -95,15 +100,13 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
95
100
 
96
101
  /**
97
102
  * Start the runtime against a host development server, delivering `start` with
98
- * [foreground], whose development Worker calls [plugins], and whose gateway presents
99
- * [server].
103
+ * [foreground] and whose development Worker calls [plugins].
100
104
  */
101
105
  fun startDevelopment(
102
106
  stateDir: File,
103
107
  host: String,
104
108
  endpoint: String,
105
109
  sessionToken: String,
106
- server: KeyStore.PrivateKeyEntry,
107
110
  foreground: Boolean,
108
111
  plugins: Plugins,
109
112
  ): TokamakRuntime =
@@ -113,25 +116,17 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
113
116
  host,
114
117
  endpoint,
115
118
  sessionToken,
116
- server.chain(),
117
- server.privateKey.encoded,
118
119
  foreground,
119
120
  plugins,
120
121
  ),
121
122
  )
122
123
 
123
- /** The entry's certificates, leaf first, in DER. */
124
- private fun KeyStore.PrivateKeyEntry.chain(): Array<ByteArray> =
125
- certificateChain.map { it.encoded }.toTypedArray()
126
-
127
124
  @JvmStatic
128
125
  private external fun nativeStart(
129
126
  packagedDir: String,
130
127
  stateDir: String,
131
128
  storageDir: String,
132
129
  host: String,
133
- serverChain: Array<ByteArray>,
134
- serverKey: ByteArray,
135
130
  foreground: Boolean,
136
131
  plugins: Plugins,
137
132
  ): Long
@@ -142,12 +137,16 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
142
137
  host: String,
143
138
  endpoint: String,
144
139
  sessionToken: String,
145
- serverChain: Array<ByteArray>,
146
- serverKey: ByteArray,
147
140
  foreground: Boolean,
148
141
  plugins: Plugins,
149
142
  ): Long
150
143
 
144
+ @JvmStatic
145
+ private external fun nativeServerAuthority(handle: Long, host: String): ByteArray?
146
+
147
+ @JvmStatic
148
+ private external fun nativeRestoreGateway(handle: Long): Int
149
+
151
150
  @JvmStatic
152
151
  private external fun nativeSetForeground(handle: Long, foreground: Boolean): Boolean
153
152
 
@@ -4,7 +4,9 @@ import android.app.Activity
4
4
  import android.content.Intent
5
5
  import android.graphics.Bitmap
6
6
  import android.net.Uri
7
+ import android.net.http.SslError
7
8
  import android.webkit.ClientCertRequest
9
+ import android.webkit.SslErrorHandler
8
10
  import android.webkit.WebResourceRequest
9
11
  import android.webkit.WebView
10
12
  import android.webkit.WebViewClient
@@ -15,10 +17,7 @@ import java.security.cert.CertificateFactory
15
17
  import java.security.cert.X509Certificate
16
18
  import java.security.spec.PKCS8EncodedKeySpec
17
19
 
18
- /**
19
- * Answers the app origin's client certificate requests with the runtime's decision. The network
20
- * security config trusts the gateway's certificate, so no certificate error reaches the app.
21
- */
20
+ /** Answers the app origin's TLS challenges with the runtime's decision. */
22
21
  internal class TokamakWebViewClient(
23
22
  private val activity: Activity,
24
23
  private val host: String,
@@ -41,6 +40,19 @@ internal class TokamakWebViewClient(
41
40
  return true
42
41
  }
43
42
 
43
+ override fun onReceivedSslError(view: WebView, handler: SslErrorHandler, error: SslError) {
44
+ val host = Uri.parse(error.url).host
45
+ val authority = host?.let(runtime::serverAuthority)
46
+ val trusted = authority != null && chainsTo(error, authority)
47
+ if (trusted) {
48
+ android.util.Log.i("tokamak", "trusted the gateway's certificate for $host (${error.primaryError})")
49
+ handler.proceed()
50
+ return
51
+ }
52
+ if (authority != null) android.util.Log.w("tokamak", "refused the gateway's certificate: $error")
53
+ handler.cancel()
54
+ }
55
+
44
56
  override fun onReceivedClientCertRequest(view: WebView, request: ClientCertRequest) {
45
57
  val identity = runtime.clientIdentity(request.host)
46
58
  if (identity == null) {
@@ -76,4 +88,25 @@ internal class TokamakWebViewClient(
76
88
  runCatching {
77
89
  KeyFactory.getInstance("EC").generatePrivate(PKCS8EncodedKeySpec(der))
78
90
  }.getOrNull()
91
+
92
+ /**
93
+ * Whether the runtime's authority signed `error`'s certificate, allowing only the failures
94
+ * reported for an untrusted certificate or a wrong device clock: the runtime issues and renews
95
+ * the certificate itself, so its signature is the trust decision. The primary error is the most
96
+ * severe one, which hides a lesser hostname mismatch, so that is checked on its own.
97
+ */
98
+ private fun chainsTo(error: SslError, authority: ByteArray): Boolean {
99
+ if (!certificateError(error.primaryError)) return false
100
+ if (error.hasError(SslError.SSL_IDMISMATCH)) return false
101
+ val presented = error.certificate.x509Certificate ?: return false
102
+ val issuer = certificate(authority) ?: return false
103
+ return runCatching { presented.verify(issuer.publicKey) }.isSuccess
104
+ }
105
+
106
+ /** Whether `primary` names the certificate as untrusted or wrongly dated. */
107
+ private fun certificateError(primary: Int): Boolean =
108
+ primary == SslError.SSL_UNTRUSTED ||
109
+ primary == SslError.SSL_NOTYETVALID ||
110
+ primary == SslError.SSL_EXPIRED ||
111
+ primary == SslError.SSL_DATE_INVALID
79
112
  }
@@ -25,7 +25,6 @@
25
25
  },
26
26
  "pluginKeys": {
27
27
  "class": "string",
28
- "dependencies": "strings",
29
28
  "manifest": "path",
30
29
  "raw": "paths"
31
30
  }
@@ -0,0 +1,23 @@
1
+ // The plugin API, which plugins' modules depend on as project(":tokamak-plugin"). Its minimum SDK
2
+ // is the pack's. Coroutines are the version androidx.lifecycle brings, so plugins' coroutines add
3
+ // no code.
4
+ plugins {
5
+ id("com.android.library")
6
+ id("org.jetbrains.kotlin.android")
7
+ }
8
+
9
+ android {
10
+ namespace = "com.tokamak.runtime.plugin"
11
+ compileSdk = 35
12
+ defaultConfig {
13
+ minSdk = 31
14
+ }
15
+ }
16
+
17
+ kotlin {
18
+ jvmToolchain(17)
19
+ }
20
+
21
+ dependencies {
22
+ api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
23
+ }
@@ -17,7 +17,7 @@ import org.json.JSONArray
17
17
  import org.json.JSONObject
18
18
 
19
19
  /**
20
- * The methods a plugin's `android/Exports.kt` lists for the Worker to call, and the events the Worker
20
+ * The methods a plugin's `Exports.kt` lists for the Worker to call, and the events the Worker
21
21
  * receives. `tok plugin generate android` runs [exports] to write the plugin's dispatch and
22
22
  * TypeScript API; the app never does.
23
23
  */
@@ -35,32 +35,38 @@ enum class TokamakOverflow {
35
35
  }
36
36
 
37
37
  /** Records the methods a plugin exports, with their options, and the events it emits. */
38
- class TokamakExporter<P : TokamakPlugin> internal constructor() {
39
- internal class Export(val kind: String, val method: KFunction<*>, val doc: String, val overflow: TokamakOverflow)
38
+ class TokamakExporter<P : TokamakPlugin> {
39
+ class Export(val kind: String, val method: KFunction<*>, val doc: String, val overflow: TokamakOverflow)
40
40
 
41
- internal class Event(val name: String, val type: KClass<*>, val reply: KClass<*>?, val doc: String)
41
+ class Event(val name: String, val type: KClass<*>, val reply: KClass<*>?, val doc: String)
42
42
 
43
- internal val exports = mutableListOf<Export>()
44
- internal val events = mutableListOf<Event>()
43
+ private val listedExports = mutableListOf<Export>()
44
+ private val listedEvents = mutableListOf<Event>()
45
+
46
+ /** The methods exported, in order. */
47
+ val exports: List<Export> get() = listedExports
48
+
49
+ /** The events listed, in order. */
50
+ val events: List<Event> get() = listedEvents
45
51
 
46
52
  /** Lists the event [name], whose listeners receive a [type] and may reply with a [reply]. */
47
53
  fun event(name: String, type: KClass<*>, reply: KClass<*>? = null, doc: String = "") {
48
- events += Event(name, type, reply, doc)
54
+ listedEvents += Event(name, type, reply, doc)
49
55
  }
50
56
 
51
57
  /** Exports [method], which returns once. */
52
58
  fun call(method: KFunction<*>, doc: String = "") {
53
- exports += Export("call", method, doc, TokamakOverflow.ERROR)
59
+ listedExports += Export("call", method, doc, TokamakOverflow.ERROR)
54
60
  }
55
61
 
56
62
  /** Exports [method], whose values the Worker reads until it cancels. */
57
63
  fun stream(method: KFunction<Flow<*>>, overflow: TokamakOverflow = TokamakOverflow.ERROR, doc: String = "") {
58
- exports += Export("stream", method, doc, overflow)
64
+ listedExports += Export("stream", method, doc, overflow)
59
65
  }
60
66
 
61
67
  /** Exports [method], which returns a native object the Worker holds as a `NativeReference`. */
62
68
  fun resource(method: KFunction<Any>, doc: String = "") {
63
- exports += Export("resource", method, doc, TokamakOverflow.ERROR)
69
+ listedExports += Export("resource", method, doc, TokamakOverflow.ERROR)
64
70
  }
65
71
  }
66
72
 
@@ -99,16 +105,16 @@ class TokamakListeners<T>(private val holding: Boolean = false) {
99
105
  }
100
106
 
101
107
  /**
102
- * Converts the values a plugin's `android/Exports.kt` uses to and from JSON: its data classes and
108
+ * Converts the values a plugin's `Exports.kt` uses to and from JSON: its data classes and
103
109
  * sealed types, and its events and their replies. Each generated dispatch's companion object is
104
110
  * one, which the plugin's host uses, even while the plugin is being created.
105
111
  */
106
112
  interface TokamakCodec {
107
113
  /** [value] as the JSON org.json writes. */
108
- fun encodeValue(value: Any): Any = throw TokamakPluginError.typeError("android/Exports.kt uses no ${value.javaClass.simpleName}")
114
+ fun encodeValue(value: Any): Any = throw TokamakPluginError.typeError("Exports.kt uses no ${value.javaClass.simpleName}")
109
115
 
110
116
  /** [json] as a [type]. */
111
- fun decodeValue(json: TokamakValue, type: KClass<*>): Any = throw TokamakPluginError.typeError("android/Exports.kt uses no ${type.simpleName}")
117
+ fun decodeValue(json: TokamakValue, type: KClass<*>): Any = throw TokamakPluginError.typeError("Exports.kt uses no ${type.simpleName}")
112
118
 
113
119
  /** The JSON [json], as org.json reads it, as a [type], which [decodeValue] decodes. */
114
120
  fun <T : Any> fromJson(json: Any?, type: KClass<T>): T {
@@ -116,10 +122,10 @@ interface TokamakCodec {
116
122
  return type.castOrNull(value) ?: throw TokamakPluginError.typeError("json is ${value.javaClass.simpleName}, not ${type.simpleName}")
117
123
  }
118
124
 
119
- /** [event] as the JSON payload of the event [name], which `android/Exports.kt` lists. */
125
+ /** [event] as the JSON payload of the event [name], which `Exports.kt` lists. */
120
126
  fun eventPayload(name: String, event: Any): ByteArray = throw TokamakPluginError.unlistedEvent(name)
121
127
 
122
- /** The listeners' [reply] to the event [name], which `android/Exports.kt` lists with a reply, as its type. */
128
+ /** The listeners' [reply] to the event [name], which `Exports.kt` lists with a reply, as its type. */
123
129
  fun eventReply(name: String, reply: TokamakValue): Any = throw TokamakPluginError.unlistedReply(name)
124
130
 
125
131
  /** The listeners' encoded [payload] in reply to the event [name] as a [type], or null when none replied. */
@@ -231,7 +237,7 @@ class TokamakValue(private val json: Any?, private val path: String) {
231
237
  }
232
238
 
233
239
  /**
234
- * A plugin with the dispatch generated from its `android/Exports.kt`. The app's registry creates the
240
+ * A plugin with the dispatch generated from its `Exports.kt`. The app's registry creates the
235
241
  * generated subclass in place of [plugin], which plugins find with `tokamakPlugin(id)`.
236
242
  */
237
243
  abstract class TokamakDispatch<P : TokamakPlugin>(val plugin: P, protected val host: TokamakHost) : TokamakPlugin by plugin {
@@ -30,10 +30,10 @@ class TokamakPluginError(
30
30
  fun needsUI() = TokamakPluginError("NeedsUIError", "The app cannot show UI while it is in the background")
31
31
 
32
32
  /** The plugin emitted an event its registration does not list. */
33
- fun unlistedEvent(name: String) = typeError("android/Exports.kt lists no event $name")
33
+ fun unlistedEvent(name: String) = typeError("Exports.kt lists no event $name")
34
34
 
35
35
  /** The plugin asked for the reply to an event its registration lists without one. */
36
- fun unlistedReply(name: String) = typeError("android/Exports.kt lists no reply to event $name")
36
+ fun unlistedReply(name: String) = typeError("Exports.kt lists no reply to event $name")
37
37
  }
38
38
  }
39
39
 
@@ -195,7 +195,7 @@ interface TokamakHost {
195
195
 
196
196
  /**
197
197
  * Delivers [event] to the Worker's listeners of the plugin's event [name], which
198
- * `android/Exports.kt` lists. Starts the runtime when it is not running. Blocks, so call it off
198
+ * `Exports.kt` lists. Starts the runtime when it is not running. Blocks, so call it off
199
199
  * the main thread; throws unless the listeners return within [timeoutMillis], which includes
200
200
  * runtime startup.
201
201
  */
@@ -205,13 +205,13 @@ interface TokamakHost {
205
205
  fun <R : Any> emit(name: String, event: Any, reply: KClass<R>, timeoutMillis: Long): R?
206
206
 
207
207
  /**
208
- * [value], of a data class or sealed type `android/Exports.kt`'s methods and events use, as
208
+ * [value], of a data class or sealed type `Exports.kt`'s methods and events use, as
209
209
  * the JSON the Worker receives, which org.json writes, for a value the plugin stores.
210
210
  */
211
211
  fun json(value: Any): Any
212
212
 
213
213
  /**
214
- * The JSON [json], as org.json reads it, as a data class or sealed [type] `android/Exports.kt`'s
214
+ * The JSON [json], as org.json reads it, as a data class or sealed [type] `Exports.kt`'s
215
215
  * methods and events use, for a value the plugin stored with [json].
216
216
  */
217
217
  fun <T : Any> fromJson(json: Any?, type: KClass<T>): T
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/platform-android-arm64",
3
- "version": "0.1.1-beta.154",
3
+ "version": "0.1.1-beta.157",
4
4
  "description": "The tokamak platform pack for android-arm64",
5
5
  "repository": {
6
6
  "type": "git",