forked from Blendman974/faceclaw
Introduce oxlint, and fix lint warnings
This commit is contained in:
1 parent
cb6dddd120
commit
06146c2b08
89 files changed
+818
-469
No files matched your search
@@ -193,7 +193,7 @@ function finalizeBlocks(blocks: Map<number, StreamingBlock>): AnthropicContentBl
|
||||
}
|
||||
|
||||
/** Parse one SSE line; returns the JSON payload of a data: line, else null. */
|
||||
function parseSseDataLine(line: string): any | null {
|
||||
function parseSseDataLine(line: string): any {
|
||||
if (!line.startsWith("data:")) return null;
|
||||
const payload = line.slice(5).trim();
|
||||
if (!payload || payload === "[DONE]") return null;
|
||||
|
||||
@@ -24,7 +24,7 @@ async function requestPermission(): Promise<boolean> {
|
||||
okButtonText: "Open Settings",
|
||||
cancelButtonText: "Cancel",
|
||||
});
|
||||
if (open) await Utils.openUrl("app-settings:");
|
||||
if (open) Utils.openUrl("app-settings:");
|
||||
return false;
|
||||
}
|
||||
if (status === "restricted") {
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function readUpcomingEventsAsync(maxEvents = 50, windowMs = DEFAULT
|
||||
try {
|
||||
if (!hasCalendarPermission()) throw new Error("Calendar permission is required.");
|
||||
resolve(parseEvents(json, error, maxEvents, endMs));
|
||||
} catch (error) { reject(error); }
|
||||
} catch (err) { reject(err); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ export type { FirmwareInfo };
|
||||
|
||||
// Kotlin/Native facades exported by FaceclawKit (see native/kotlin/shared/src/iosMain/.../ble).
|
||||
declare const FaceclawKitIosGlassesSession: any;
|
||||
declare const FaceclawKitIosProtocolPlatform: any;
|
||||
declare const FaceclawKitFaceclawBleCommunicatorListener: any;
|
||||
declare const FaceclawKitIosAncsListener: any;
|
||||
declare const FaceclawKitIosAudioPacketListener: any;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { openSocket } from "./socket";
|
||||
import { toUint8Array } from "../util/array-util";
|
||||
|
||||
declare const com: any;
|
||||
declare const android: any;
|
||||
declare const java: any;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class IosBluetooth {
|
||||
this.state = Number(state); this.authorization = Number(authorization)
|
||||
this.emit({ kind: 'state', state: this.state, authorization: this.authorization })
|
||||
},
|
||||
onAdvertisementIdentifierNameManufacturerDataHexRssiConnectable: (identifier: string, name: string, manufacturerData: string, rssi: number, connectable: boolean) => {
|
||||
onAdvertisementIdentifierNameManufacturerDataHexRssiConnectable: (identifier: string, name: string, manufacturerData: string, rssi: number, connectable: boolean | undefined) => {
|
||||
// The Kotlin central already merges split advertisements and bounds its cache.
|
||||
const raw: IosAdvertisement = { identifier: String(identifier), name: String(name ?? ''), manufacturerData: String(manufacturerData ?? ''), rssi: Number(rssi), connectable: connectable !== false }
|
||||
this.emit({ kind: 'advertisement', ...raw })
|
||||
@@ -65,7 +65,7 @@ export class IosBluetooth {
|
||||
ensureReady(): Promise<void> {
|
||||
if (this.state === BLE_STATE_POWERED_ON) return Promise.resolve()
|
||||
return new Promise((resolve, reject) => {
|
||||
const finish = (error?: Error) => { clearTimeout(timer); off(); error ? reject(error) : resolve() }
|
||||
const finish = (error?: Error) => { clearTimeout(timer); off(); if (error) reject(error); else resolve() }
|
||||
const off = this.onEvent(event => {
|
||||
if (event.kind !== 'state') return
|
||||
if (event.state === BLE_STATE_POWERED_ON) finish()
|
||||
|
||||
@@ -33,6 +33,6 @@ export function runKotlinBridgeSmokeTest(): void {
|
||||
console.log("FACECLAW_KOTLIN_BRIDGE_PASS " + JSON.stringify({ platform, thread, reply }));
|
||||
} catch (error) {
|
||||
// Diagnostics must not prevent the rest of the app from launching.
|
||||
console.error("FACECLAW_KOTLIN_BRIDGE_FAIL " + error);
|
||||
console.error(`FACECLAW_KOTLIN_BRIDGE_FAIL ${error}`);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import type { KotlinBridge } from './kotlin-platform';
|
||||
// Handwritten declarations for the small native surface, checked against the
|
||||
// compiled API. NativeScript runtime metadata is generated from the AAR.
|
||||
declare namespace com.faceclaw.shared {
|
||||
// Used as com.faceclaw.shared.KotlinBridge; oxlint misses qualified references.
|
||||
// oxlint-disable-next-line no-unused-vars
|
||||
class KotlinBridge extends java.lang.Object {
|
||||
constructor();
|
||||
platform(): string;
|
||||
|
||||
@@ -30,8 +30,8 @@ type PendingRequest<T> = {
|
||||
* Holds at most one connection at a time.
|
||||
*/
|
||||
export class FaceclawMediaBrowserBridge {
|
||||
private browser: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private browser: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private nextRequestId = 1;
|
||||
private readonly pendingConnects = new Map<number, PendingRequest<string>>();
|
||||
private readonly pendingBrowses = new Map<number, PendingRequest<MediaBrowseItem[]>>();
|
||||
|
||||
@@ -59,8 +59,8 @@ const DEFAULT_MEDIA_STATE: MediaControllerState = {
|
||||
|
||||
export class FaceclawMediaControllerBridge {
|
||||
private readonly stateListeners = new Set<(state: MediaControllerState) => void>();
|
||||
private controller: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private controller: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private state: MediaControllerState = { ...DEFAULT_MEDIA_STATE };
|
||||
private stateUpdatedAtMs = Date.now();
|
||||
private started = false;
|
||||
|
||||
@@ -106,7 +106,6 @@ type NightscoutTreatmentResponse = {
|
||||
|
||||
const NIGHTSCOUT_REFRESH_MS = 60_000;
|
||||
const NIGHTSCOUT_HISTORY_COUNT = 30;
|
||||
const NIGHTSCOUT_GRAPH_WINDOW_MS = 2 * 60 * 60 * 1000;
|
||||
const NIGHTSCOUT_TREATMENT_LOOKBACK_MS = 3 * 60 * 60 * 1000;
|
||||
// The v1 treatments API silently adds `created_at >= now - 4 days` to any
|
||||
// query without an explicit date filter (lib/server/query.js enforceDateFilter),
|
||||
|
||||
@@ -20,7 +20,7 @@ let cachedIcons: GrayImage[] = [];
|
||||
let cachedAtMs = 0;
|
||||
const keyedIconCache = new Map<string, { icon: GrayImage | null; atMs: number }>();
|
||||
const KEYED_ICON_CACHE_MAX = 128;
|
||||
let notificationListenerProxy: any | null = null;
|
||||
let notificationListenerProxy: any = null;
|
||||
const notificationPostedListeners = new Set<(notificationKey: string) => void>();
|
||||
|
||||
function invalidateIconCaches(): void {
|
||||
|
||||
@@ -288,7 +288,7 @@ function extractMessageText(item: any): string {
|
||||
.join("");
|
||||
}
|
||||
|
||||
function parseSseDataLine(line: string): any | null {
|
||||
function parseSseDataLine(line: string): any {
|
||||
if (!line.startsWith("data:")) return null;
|
||||
const payload = line.slice(5).trim();
|
||||
if (!payload || payload === "[DONE]") return null;
|
||||
|
||||
@@ -14,7 +14,8 @@ export function scanQrCode(): Promise<string | null> {
|
||||
if (settled) return
|
||||
settled = true
|
||||
if (activeScanner === scanner) activeScanner = null
|
||||
error ? reject(new Error(String(error))) : resolve(text == null ? null : String(text))
|
||||
if (error) reject(new Error(String(error)))
|
||||
else resolve(text == null ? null : String(text))
|
||||
}
|
||||
try { scanner.startWithCompletion(finish) }
|
||||
catch (error) { finish(null, String(error)) }
|
||||
|
||||
@@ -64,8 +64,8 @@ export class IosVoiceControlBridge {
|
||||
const generation = ++this.generation
|
||||
this.log = log; this.source = 'glasses'; this.session = session; this.packets = 0; this.capturing = true
|
||||
this.completion = new Promise(resolve => { this.resolveCompletion = resolve })
|
||||
const error = String(this.ensureNative().startWithEndpointing(endpointing) ?? '')
|
||||
if (error) { this.stop(); this.setStatus(error); this.emitEnd(); return }
|
||||
const startError = String(this.ensureNative().startWithEndpointing(endpointing) ?? '')
|
||||
if (startError) { this.stop(); this.setStatus(startError); this.emitEnd(); return }
|
||||
try {
|
||||
await session.setMicrophone(true, packet => {
|
||||
if (generation !== this.generation || !this.capturing) return
|
||||
@@ -136,7 +136,7 @@ export class IosVoiceControlBridge {
|
||||
this.log(`Voice audio: ${event.seconds?.toFixed(1)}s, packets=${event.packets}, RMS=${event.rms?.toFixed(4)}, missing=${event.missing}, errors=${event.errors}`)
|
||||
if (this.capturing) this.setStatus(`Listening on ${this.source === 'phone' ? 'phone' : 'glasses'}… ${event.seconds?.toFixed(0)}s`)
|
||||
} else if (event.kind === 'finishing') {
|
||||
this.stopPushToTalk(); this.emitEnd()
|
||||
void this.stopPushToTalk(); this.emitEnd()
|
||||
} else if (event.kind === 'ended') {
|
||||
this.source = null
|
||||
this.capturing = this.finalizing = false
|
||||
|
||||
@@ -102,8 +102,8 @@ export class FaceclawVoiceControlBridge {
|
||||
private readonly speechPauseListeners = new Set<() => void>();
|
||||
private readonly speechPause = new SpeechPauseDetector();
|
||||
private readonly speechEndListeners = new Set<() => void>();
|
||||
private controller: any | null = null;
|
||||
private listenerProxy: any | null = null;
|
||||
private controller: any = null;
|
||||
private listenerProxy: any = null;
|
||||
private status = "Voice control stopped.";
|
||||
private listening = false;
|
||||
private detail = "";
|
||||
|
||||
@@ -54,14 +54,14 @@ type MessageListener = (message: WearMessage) => void;
|
||||
type ConnectionListener = (connection: WearWatchConnection) => void;
|
||||
|
||||
class WearBridge {
|
||||
private java: any | null | undefined = undefined;
|
||||
private java: any = undefined;
|
||||
// The Java-side listener proxy must stay referenced or it gets GC'd.
|
||||
private retainedListenerProxy: any = null;
|
||||
private readonly messageListeners = new Set<MessageListener>();
|
||||
private readonly connectionListeners = new Set<ConnectionListener>();
|
||||
private lastConnection: WearWatchConnection = { reachable: false, watchName: "" };
|
||||
|
||||
private getJava(): any | null {
|
||||
private getJava(): any {
|
||||
if (this.java !== undefined) return this.java;
|
||||
if (!global.isAndroid) {
|
||||
this.java = null;
|
||||
|
||||
Reference in new issue
Block a user