EvenHub compatibility for iOS

This commit is contained in:
James Babcock committed 2026-09-19 00:48:26 -07:00
1 parent 617cdc39eb
commit 7e58c7c05f
40 files changed
+629 -176

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
import { Http } from '@nativescript/core';
import { withUserAgent } from '../util/http';
import type { BinaryResponse } from './binary-http';
/** Bulk NSData -> ArrayBuffer; bypass fetch's Blob/FileReader copies. */
export async function downloadBinary(url: string, timeoutMs: number): Promise<BinaryResponse> {
const response = await Http.request({ url, method: 'GET', headers: withUserAgent(), timeout: timeoutMs });
const length = Object.entries(response.headers).find(([name]) => name.toLowerCase() === 'content-length')?.[1];
return { status: response.statusCode, bytes: new Uint8Array(response.content.toArrayBuffer()), contentLength: Number(length ?? 0) };
}
+15
View File
@@ -0,0 +1,15 @@
import { fetchWithUserAgent } from '../util/http';
export type BinaryResponse = { status: number; bytes: Uint8Array; contentLength: number };
export async function downloadBinary(url: string, timeoutMs: number): Promise<BinaryResponse> {
let timer: ReturnType<typeof setTimeout>;
const request = async () => {
const response = await fetchWithUserAgent(url);
return { status: response.status, bytes: new Uint8Array(await response.arrayBuffer()),
contentLength: Number(response.headers.get('Content-Length') ?? 0) };
};
try {
return await Promise.race([request(), new Promise<never>((_, reject) => {
timer = setTimeout(() => reject(new Error('Download timed out.')), timeoutMs);
})]);
} finally { clearTimeout(timer!); }
}
+9
View File
@@ -0,0 +1,9 @@
import { grayImageFromPacket } from './image-files';
import { fromData } from './kotlin-data';
import type { GrayImage } from '../graphics/image';
declare const FaceclawGraphics: any;
export function loadIconImage(path: string, maxWidth: number, maxHeight: number): GrayImage | null {
const data = FaceclawGraphics.decodeImageFileMaxWidthMaxHeight(path, Math.round(maxWidth), Math.round(maxHeight));
return data ? grayImageFromPacket(fromData(data)) : null;
}
+3
View File
@@ -0,0 +1,3 @@
import { loadImageFileAsGray } from './image-files';
/** UI artwork uses flat grayscale, preserving its source aspect ratio. */
export const loadIconImage = loadImageFileAsGray;