-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
47 lines (40 loc) · 1.2 KB
/
Copy pathdev.py
File metadata and controls
47 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from __future__ import annotations
import pathlib
import subprocess
import sys
import time
import signal
import os
import webview
from api.bridge import GameAPI
def _user_storage() -> str:
if sys.platform == "win32":
root = pathlib.Path(os.environ.get("LOCALAPPDATA", pathlib.Path.home()))
elif sys.platform == "darwin":
root = pathlib.Path.home() / "Library" / "Application Support"
else:
root = pathlib.Path(os.environ.get("XDG_DATA_HOME") or (pathlib.Path.home() / ".local" / "share"))
path = root / "ShowdownDraft" / "webview-dev"
path.mkdir(parents=True, exist_ok=True)
return str(path)
frontend_dir = os.path.join(os.path.dirname(__file__), "frontend")
npm_proc = subprocess.Popen(
["cmd", "/c", "npm run dev"],
cwd=frontend_dir,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
)
time.sleep(3)
api = GameAPI()
window = webview.create_window(
"Showdown Draft [DEV]",
url="http://localhost:5173",
js_api=api,
width=1920,
height=1080,
fullscreen=True,
resizable=True,
min_size=(1280, 720),
)
webview.start(private_mode=False, storage_path=_user_storage())
npm_proc.send_signal(signal.CTRL_BREAK_EVENT)
npm_proc.terminate()