From fc814f50262627b2c32c2fcb593969c1d77509d5 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Fri, 24 Apr 2026 23:16:50 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20replace=20Buffer.from().toString('base64?= =?UTF-8?q?')=20with=20btoa=20helper=20=E2=80=94=20Buffer=20not=20availabl?= =?UTF-8?q?e=20in=20Expo=20RN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/app/(tabs)/import.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mobile/app/(tabs)/import.tsx b/mobile/app/(tabs)/import.tsx index beb99dc..abf250b 100644 --- a/mobile/app/(tabs)/import.tsx +++ b/mobile/app/(tabs)/import.tsx @@ -228,10 +228,21 @@ async function fetchWheelBase64(instanceUrl: string): Promise { const resp = await fetch(wheelUrl); if (!resp.ok) throw new Error(`Could not download Bincio engine (${resp.status}). Is the instance running?`); const buf = await resp.arrayBuffer(); - _cachedWheelBase64 = Buffer.from(buf).toString('base64'); + _cachedWheelBase64 = arrayBufferToBase64(buf); return _cachedWheelBase64; } +function arrayBufferToBase64(buf: ArrayBuffer): string { + const bytes = new Uint8Array(buf); + let binary = ''; + // Process in chunks to avoid spread-operator stack overflow on large arrays. + const CHUNK = 8192; + for (let i = 0; i < bytes.length; i += CHUNK) { + binary += String.fromCharCode(...(bytes.subarray(i, i + CHUNK) as unknown as number[])); + } + return btoa(binary); +} + // ── Styles ─────────────────────────────────────────────────────────────────── const styles = StyleSheet.create({