Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run in background? #151

Open
rj-hwang opened this issue Jan 15, 2023 · 2 comments
Open

How to run in background? #151

rj-hwang opened this issue Jan 15, 2023 · 2 comments

Comments

@rj-hwang
Copy link

No description provided.

@JOTSR
Copy link

JOTSR commented Jan 17, 2023

You want to run webiview without freezing the main script ?
As I know, there is no simple way to run in background since webview handle the client event loop. You can run webview in a worker or a sub process and send data to client via websocket but you don't have direct access of the server part. I'm working on a pull request to solve that via an async api but this project seems to be slowing down.

@DNAScanner
Copy link

If what you want is what JOTSR described, you can achieve this by doing an non-awaited asynchronous function as I did.

import {Webview, SizeHint} from "jsr:@webview/webview";
import {loadImage} from "https://deno.land/x/canvas@v1.4.1/mod.ts";

(async () => {
	const image = await loadImage("E:/AniWorld.png");

	const webview = new Webview(false, {height: image.height(), width: image.width(), hint: SizeHint.FIXED});

	// Load image file at "E:\AniWorld.png"
	webview.navigate("E:/AniWorld.png");
	webview.run();
})();

const urls = [
	"https://aniworld.to/anime/stream/golden-time",
];

console.log(urls.join("\n"));

The main part is

(async () => { /* Code here */ })()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants