fix: move PyodideWebView into Import tab; fix micropip blob URL error
Layout fix: WebView as a sibling in the root layout breaks flex geometry even with position:absolute. Moving it inside the Import tab screen (which Expo Router keeps mounted after first visit) eliminates the issue entirely and restores the original simple root layout. micropip fix: blob: URLs are not a recognised scheme in micropip — they are parsed as package requirement strings, producing InvalidRequirement. Write the wheel bytes to Pyodide's Emscripten FS (/tmp/bincio.whl) and install via emfs:/// instead.
This commit is contained in:
@@ -10,9 +10,12 @@ const PY_INSTALL_PACKAGES = [
|
||||
'await micropip.install(["fitdecode", "gpxpy"])',
|
||||
].join('\n');
|
||||
|
||||
// emfs:// is Pyodide's Emscripten-FS URL scheme — the only reliable way to
|
||||
// install a wheel from bytes without an http/https URL (blob: URLs are not
|
||||
// recognised by micropip and cause an InvalidRequirement parse error).
|
||||
const PY_INSTALL_WHEEL = [
|
||||
'import micropip',
|
||||
'await micropip.install(_blobUrl, deps=False)',
|
||||
'await micropip.install("emfs:///tmp/bincio.whl", deps=False)',
|
||||
].join('\n');
|
||||
|
||||
const PY_EXTRACT = [
|
||||
@@ -109,16 +112,14 @@ window._bincioExtract = async function(params) {
|
||||
if (initError) throw new Error(initError);
|
||||
|
||||
// Install bincio wheel on first extraction.
|
||||
// Wheel bytes arrive pre-fetched from the React Native side as base64,
|
||||
// so the WebView never needs to make an HTTP request (avoids ATS blocks).
|
||||
// Wheel bytes arrive pre-fetched from React Native (avoids ATS/HTTP issues).
|
||||
// Write to Pyodide's Emscripten FS so micropip can install via emfs:// URL
|
||||
// (blob: URLs are not recognised by micropip — they cause an InvalidRequirement error).
|
||||
if (!wheelReady) {
|
||||
post({ type: 'progress', msg: 'Loading Bincio…' });
|
||||
var wheelBytes = Uint8Array.from(atob(wheelBase64), function(c) { return c.charCodeAt(0); });
|
||||
var wheelBlob = new Blob([wheelBytes]);
|
||||
var blobUrl = URL.createObjectURL(wheelBlob);
|
||||
pyodide.globals.set('_blobUrl', blobUrl);
|
||||
pyodide.FS.writeFile('/tmp/bincio.whl', wheelBytes);
|
||||
await pyodide.runPythonAsync(_PY_INSTALL_WHEEL);
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
wheelReady = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user