-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
88 lines (77 loc) · 3.01 KB
/
main.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from pathlib import PurePath
from typing import TYPE_CHECKING, Any, Callable, Coroutine, List, Type, Union
from textual.app import App, ComposeResult, log
from textual.containers import Horizontal, VerticalScroll
from textual.driver import Driver
from textual.reactive import reactive
from textual.widgets import Button, TabbedContent, Static
import sys,asyncio
from neko.ddstypes.vm import Event, VM
from e import JsonRpc
from neko.pages.home import Home
from neko.pages.inspector import Inspector
from neko.pages.debugger import Debugger
#enableTrace(True)
CSSPathType = Union[
str,
PurePath,
List[Union[str, PurePath]],
]
_events: dict[str, list[Callable[["Event"],Coroutine[Any, Any, None]]]] = {}
async def n(name,event:"Event"):
for i in _events.get(name,[]):
await i(event)
class DartDevtoolsCLI(App):
CSS = """.borderless {
border: none;
padding: 0
}
.autoh {
height: auto;
}"""
_vm = reactive({})
def __init__(self, driver_class: Type[Driver] | None = None, css_path: CSSPathType | None = None, watch_css: bool = False):
super().__init__(driver_class, "j.tcss", watch_css)
self.styles.layers = ("below", "above") # type: ignore
self.meow = sys.argv[1].replace("http","ws")+"ws"
self._ws = None
self._isolate = ""
def compose(self) -> ComposeResult:
if self._vm == {}:
yield Static("")
self.notify("Connecting to "+self.meow)
return
with Horizontal(id="m",classes="autoh"):
yield Button("Reload",id="r")
yield Button("Restart",id="R")
with VerticalScroll():
with TabbedContent("Home","Inspector","Timeline","Memory","Performance","Debugger","Network","Logging"):
yield Home(self._ws, self._vm) # type: ignore
yield Inspector(self._ws)
yield Static("jjejdn")
yield Static("maymory")
yield Static("speed")
yield Debugger(self._ws)
yield Static("s")
yield Static("word abuse")
async def on_ready(self, e):
log("ujejejebegebyeybwbywbgwg w")
ws = await JsonRpc().create(self.meow)
self.notify("Connected :)")
self._ws: Devtools = ws #type: ignore
data:VM = await ws.send_json("getVM")
self._isolate = data["isolates"][0]["id"]
self._vm = data
await self.recompose()
# Listen to event
for i in ["Debug"]:#["Debug", "Service"]:
await ws.send_json("streamListen",{"streamId": i})
async def on_button_pressed(self, e: Button.Pressed):
if e.button.id == "r":
await self._ws.send_json("s0.reloadSources",{"isolateId": self._isolate})
self.notify("Hot reload completed")
if e.button.id == "R":
await self._ws.send_json("s0.hotRestart",{"isolateId": self._isolate})
self.notify("Hot restart completed")
if __name__ == "__main__":
asyncio.run(DartDevtoolsCLI().run_async())