Skip to content

Commit ca8cd35

Browse files
committed
fix(recipe-scraper): remove dependency on deleted bridge methods
isMountRequested and subscribeMount were removed from PyodideBridgeImpl during the bridge refactor. runtimeMount.ios.ts now tracks mount state locally, consistent with the non-iOS implementation.
1 parent 26c1d10 commit ca8cd35

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

modules/recipe-scraper/src/runtimeMount.ios.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,42 @@
55
* PyodideWebView only when a scrape call has actually been issued.
66
*/
77

8-
import {PyodideBridge} from './ios/PyodideBridge';
8+
let mountRequested = false;
9+
const subscribers = new Set<() => void>();
10+
11+
/**
12+
* Triggers a mount request and notifies all subscribers.
13+
* Call this when the first scrape is initiated.
14+
*/
15+
export function requestPythonRuntime(): void {
16+
if (mountRequested) return;
17+
mountRequested = true;
18+
subscribers.forEach(cb => cb());
19+
subscribers.clear();
20+
}
921

1022
/**
1123
* Reports whether a consumer has already requested the PyodideWebView to mount.
1224
*/
1325
export function isPythonRuntimeRequested(): boolean {
14-
return PyodideBridge.isMountRequested();
26+
return mountRequested;
1527
}
1628

1729
/**
1830
* Subscribes to mount-request events. The callback fires the first time
19-
* a scrape call triggers `PyodideBridge.requestMount()`.
31+
* `requestPythonRuntime()` is called.
2032
*
2133
* @param callback - Invoked when the WebView mount is requested.
2234
* @returns Unsubscribe function.
2335
*/
2436
export function subscribeToPythonRuntimeRequest(callback: () => void): () => void {
25-
return PyodideBridge.subscribeMount(callback);
37+
if (mountRequested) {
38+
callback();
39+
return () => {
40+
};
41+
}
42+
subscribers.add(callback);
43+
return () => {
44+
subscribers.delete(callback);
45+
};
2646
}

0 commit comments

Comments
 (0)