Refactor a bunch of Java to Kotlin, making it usable in an iOS port

This commit is contained in:
James Babcock committed 2026-09-18 22:46:08 -07:00
1 parent c0f8f7e9c2
commit 410fd5840b
162 files changed
+9650 -6224

No files matched your search

+2
View File
@@ -1,3 +1,4 @@
import { runKotlinProtocolSmokeTest } from './kotlin-protocol-smoke';
import { isAndroid } from "@nativescript/core";
// Handwritten declarations for this small native surface. NativeScript builds
@@ -18,6 +19,7 @@ export function runKotlinBridgeSmokeTest(): void {
if (!isAndroid) return;
try {
runKotlinProtocolSmokeTest();
const bridge = new com.faceclaw.shared.KotlinBridge();
const greeting = bridge.greet("Faceclaw");
const message = "Faceclaw \u2194 Kotlin \ud83d\udc53";
+20
View File
@@ -0,0 +1,20 @@
declare const com: any
/** Development-only checks of NativeScript metadata and bulk ByteBuffer crossings. */
export function runKotlinProtocolSmokeTest(): void {
const native = com.faceclaw.app
const hex = (data: any) => Array.from({ length: data.length }, (_, i) => (data[i] & 255).toString(16).padStart(2, '0')).join('')
const assert = (condition: boolean, what: string) => { if (!condition) throw new Error(`Kotlin protocol bridge: ${what}`) }
const auth = native.BleProtocol.buildAuthenticationRequest(101)
assert(hex(auth) === '080410651a0408011004', 'authentication')
const compositor = new native.SurfaceCompositor()
compositor.configureScreen(3, 2)
compositor.configureSurface('test', 0, 0, 3, 2, 0, 0)
const pixels = new Uint8Array([0, 16, 255, 32, 48, 64])
compositor.submitSurface('test', new native.AndroidByteReader(pixels.buffer), 0, 0, 3, 2, '1')
assert(hex(compositor.composite().gray) === '0010ff203040', 'composition/ByteBuffer')
assert(hex(native.BmpUtil.pack4bppFromGray8(compositor.composite().gray, 3, 2)) === '01f02340', 'packing')
const id = native.ImageAtlas.ensure('kotlin-smoke', 3, 2, new native.AndroidByteReader(pixels.buffer))
assert(id > 0 && native.ImageAtlas.get(id).width === 3, 'image atlas/reused buffer')
console.log('FACECLAW_KOTLIN_PROTOCOL_PASS Android')
}