@typed-assistant/builder 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed-assistant/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./appProcess": "./src/appProcess.tsx",
|
|
6
6
|
"./bunInstall": "./src/bunInstall.tsx",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"ts-toolbelt": "^9.6.0",
|
|
26
26
|
"typescript": "^5.3.3",
|
|
27
27
|
"@typed-assistant/eslint-config": "0.0.4",
|
|
28
|
-
"@typed-assistant/
|
|
29
|
-
"@typed-assistant/
|
|
30
|
-
"@typed-assistant/
|
|
28
|
+
"@typed-assistant/logger": "0.0.7",
|
|
29
|
+
"@typed-assistant/utils": "0.0.7",
|
|
30
|
+
"@typed-assistant/typescript-config": "0.0.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"home-assistant-js-websocket": "^8.2.0"
|
package/src/setupWebserver.tsx
CHANGED
package/src/webserver/App.tsx
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useState } from "react"
|
|
2
|
+
import { AppSection } from "./AppSection"
|
|
2
3
|
import { Terminal } from "./Terminal"
|
|
4
|
+
import { WSIndicator } from "./WSIndicator"
|
|
3
5
|
import { app } from "./api"
|
|
4
6
|
import { useWS } from "./useWS"
|
|
5
7
|
|
|
6
|
-
const basePath = process.env.BASE_PATH ?? ""
|
|
7
|
-
|
|
8
8
|
const App = () => {
|
|
9
9
|
return (
|
|
10
|
-
<div className="grid grid-cols-3">
|
|
10
|
+
<div className="grid md:grid-cols-3">
|
|
11
11
|
<div className="col-span-2">
|
|
12
|
-
<Terminal
|
|
12
|
+
<Terminal />
|
|
13
13
|
</div>
|
|
14
14
|
<div className="col-span-1">
|
|
15
15
|
<Logs />
|
|
@@ -19,7 +19,7 @@ const App = () => {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const Logs = () => {
|
|
22
|
-
const [limit, setLimit] = useState(
|
|
22
|
+
const [limit, setLimit] = useState(50)
|
|
23
23
|
const [logs, setLogs] = useState<string[]>([])
|
|
24
24
|
|
|
25
25
|
const ws = useWS({
|
|
@@ -33,10 +33,12 @@ const Logs = () => {
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
<AppSection
|
|
37
|
+
renderHeader={() => (
|
|
38
|
+
<>
|
|
39
|
+
<h2 className="mb-2 text-2xl flex items-baseline gap-3">
|
|
40
|
+
Logs <WSIndicator ws={ws.ws} />
|
|
41
|
+
</h2>
|
|
40
42
|
<div className="flex gap-2">
|
|
41
43
|
<label htmlFor="limit">Limit</label>
|
|
42
44
|
<input
|
|
@@ -47,17 +49,17 @@ const Logs = () => {
|
|
|
47
49
|
value={limit}
|
|
48
50
|
/>
|
|
49
51
|
</div>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<pre
|
|
52
|
+
</>
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<pre>
|
|
54
56
|
<ul>
|
|
55
57
|
{logs.map((log) => (
|
|
56
58
|
<li key={log}>{log}</li>
|
|
57
59
|
))}
|
|
58
60
|
</ul>
|
|
59
61
|
</pre>
|
|
60
|
-
</
|
|
62
|
+
</AppSection>
|
|
61
63
|
)
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const AppSection = ({
|
|
2
|
+
renderHeader,
|
|
3
|
+
children,
|
|
4
|
+
}: {
|
|
5
|
+
renderHeader: () => JSX.Element
|
|
6
|
+
children: JSX.Element
|
|
7
|
+
}) => {
|
|
8
|
+
return (
|
|
9
|
+
<div className="p-4 text-xs h-full max-h-dvh w-dvw md:w-auto overflow-x-auto flex flex-col">
|
|
10
|
+
<div className="flex gap-4 mb-4 items-center justify-between">
|
|
11
|
+
{renderHeader()}
|
|
12
|
+
</div>
|
|
13
|
+
<div className="overflow-x-auto">{children}</div>
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useCallback, useState } from "react"
|
|
2
2
|
import { app } from "./api"
|
|
3
3
|
import { useWS } from "./useWS"
|
|
4
|
+
import { WSIndicator } from "./WSIndicator"
|
|
5
|
+
import { AppSection } from "./AppSection"
|
|
4
6
|
|
|
5
|
-
export function Terminal(
|
|
7
|
+
export function Terminal() {
|
|
6
8
|
const [content, setContent] = useState("")
|
|
7
9
|
const ws = useWS({
|
|
8
10
|
subscribe: useCallback(() => app.ws.subscribe(), []),
|
|
@@ -10,24 +12,14 @@ export function Terminal({ basePath }: { basePath: string }) {
|
|
|
10
12
|
})
|
|
11
13
|
|
|
12
14
|
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Disconnected
|
|
23
|
-
</span>
|
|
24
|
-
)}
|
|
25
|
-
</h1>
|
|
26
|
-
<p>
|
|
27
|
-
<a href={`${basePath}/log.txt`}>View log.txt</a>
|
|
28
|
-
</p>
|
|
29
|
-
|
|
30
|
-
<pre className="" dangerouslySetInnerHTML={{ __html: content }} />
|
|
31
|
-
</>
|
|
15
|
+
<AppSection
|
|
16
|
+
renderHeader={() => (
|
|
17
|
+
<h1 className="mb-2 text-2xl flex items-baseline gap-3">
|
|
18
|
+
TypedAssistant <WSIndicator ws={ws.ws} />
|
|
19
|
+
</h1>
|
|
20
|
+
)}
|
|
21
|
+
>
|
|
22
|
+
<pre dangerouslySetInnerHTML={{ __html: content }} />
|
|
23
|
+
</AppSection>
|
|
32
24
|
)
|
|
33
25
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function WSIndicator({ ws }: { ws: WebSocket }) {
|
|
2
|
+
return ws.readyState === WebSocket.OPEN ? (
|
|
3
|
+
<div
|
|
4
|
+
title="Connected"
|
|
5
|
+
className="w-4 h-4 rounded-full bg-emerald-300 text-emerald-800 text-xs uppercase"
|
|
6
|
+
>
|
|
7
|
+
<span className="sr-only">Connected</span>
|
|
8
|
+
</div>
|
|
9
|
+
) : (
|
|
10
|
+
<div
|
|
11
|
+
title="Disconnected"
|
|
12
|
+
className="w-4 h-4 rounded-full bg-rose-300 text-rose-800 text-xs uppercase"
|
|
13
|
+
>
|
|
14
|
+
<span className="sr-only">Disconnected</span>
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
package/src/webserver/index.html
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<head>
|
|
3
3
|
<link rel="stylesheet" href="{{ STYLESHEET }}" />
|
|
4
4
|
</head>
|
|
5
|
-
<body class="bg-slate-950 text-white h-full">
|
|
6
|
-
<div id="root"></div>
|
|
5
|
+
<body class="bg-slate-950 text-white h-full max-h-dvh">
|
|
6
|
+
<div id="root" class="h-full max-h-dvh"></div>
|
|
7
7
|
{{ SCRIPTS }}
|
|
8
8
|
</body>
|
|
9
9
|
</html>
|