RuneStone 1.0.0
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const sessions = new WeakMap();
|
||||
|
||||
export async function nativeRequest(page, command, args = {}) {
|
||||
const invoke = (name, value) => page.evaluate(({ name, value }) => window.__TAURI_INTERNALS__.invoke(name, value), { name, value });
|
||||
if (command === 'browser_request') {
|
||||
let session = sessions.get(page);
|
||||
if (!session) { session = await invoke('browser_connect', {}); sessions.set(page, session); }
|
||||
return invoke(command, { ...args, session });
|
||||
}
|
||||
if (command === 'browser_stop') sessions.delete(page);
|
||||
return invoke(command, args);
|
||||
}
|
||||
Reference in New Issue
Block a user