@typed-assistant/builder 0.0.12 → 0.0.13

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.12",
3
+ "version": "0.0.13",
4
4
  "exports": {
5
5
  "./appProcess": "./src/appProcess.tsx",
6
6
  "./bunInstall": "./src/bunInstall.tsx",
@@ -11,7 +11,9 @@
11
11
  "ansi-to-html": "^0.7.2",
12
12
  "elysia": "^0.8.9",
13
13
  "@mdi/svg": "^7.3.67",
14
- "ignore": "^5.3.0"
14
+ "ignore": "^5.3.0",
15
+ "react": "^18",
16
+ "react-dom": "^18"
15
17
  },
16
18
  "devDependencies": {
17
19
  "@types/node": "^20.10.6",
@@ -21,8 +23,8 @@
21
23
  "typescript": "^5.3.3",
22
24
  "@typed-assistant/eslint-config": "0.0.4",
23
25
  "@typed-assistant/typescript-config": "0.0.4",
24
- "@typed-assistant/logger": "0.0.5",
25
- "@typed-assistant/utils": "0.0.7"
26
+ "@typed-assistant/utils": "0.0.7",
27
+ "@typed-assistant/logger": "0.0.5"
26
28
  },
27
29
  "peerDependencies": {
28
30
  "home-assistant-js-websocket": "^8.2.0"
@@ -82,7 +82,10 @@ export async function setupWatcher(
82
82
  },
83
83
  )
84
84
 
85
- startWebappServer({ getSubprocesses: () => subprocesses })
85
+ startWebappServer({
86
+ basePath: addonInfo?.ingress_entry ?? "",
87
+ getSubprocesses: () => subprocesses,
88
+ })
86
89
 
87
90
  return subprocesses
88
91
  }
@@ -123,6 +126,6 @@ const getAddonInfo = async () => {
123
126
  log("🔍 Getting addon info...")
124
127
 
125
128
  return withErrorHandling(getSupervisorAPI)<{
126
- data: { ingress_entry: string }
129
+ ingress_entry: string
127
130
  }>("/addons/self/info")
128
131
  }
@@ -41,8 +41,10 @@ const subscribers = new Map<number, (message: string) => void>()
41
41
  let lastMessage = ""
42
42
 
43
43
  export const startWebappServer = async ({
44
+ basePath,
44
45
  getSubprocesses,
45
46
  }: {
47
+ basePath: string
46
48
  getSubprocesses: () => {
47
49
  app: Subprocess<"ignore", "pipe", "pipe">
48
50
  }
@@ -51,7 +53,7 @@ export const startWebappServer = async ({
51
53
  entrypoints: [tsEntryPoint],
52
54
  outdir: "./build",
53
55
  define: {
54
- "process.env.BASE_PATH": "'lmao'",
56
+ "process.env.BASE_PATH": `"${basePath}"`,
55
57
  },
56
58
  })
57
59
  if (!buildResult.success) {
@@ -79,29 +81,14 @@ export const startWebappServer = async ({
79
81
  )
80
82
 
81
83
  const server = new Elysia()
82
- .get("/", ({ request }) => {
83
- getIngressPath(request)
84
- return new Response(
85
- `
86
- <html>
87
- <meta charset="UTF-8">
88
- <body>
89
- <a href="${getIngressPath(request)}/log.txt">Logs</a>
90
- <a href="${getIngressPath(request)}/terminal">Terminal</a>
91
- </body>
92
- </html>
93
- `,
94
- { headers: { "content-type": "text/html" } },
95
- )
96
- })
97
- .get("/terminal", Bun.file(terminalHtmlUrl))
98
84
  .get(
99
- "/terminal2",
85
+ "/",
100
86
  () =>
101
87
  new Response(indexHtml, {
102
88
  headers: { "content-type": "text/html" },
103
89
  }),
104
90
  )
91
+ .get("/terminal", Bun.file(terminalHtmlUrl))
105
92
  .get("/log.txt", Bun.file("./log.txt"))
106
93
  .ws("/ws", {
107
94
  async open(ws) {
@@ -1,15 +1,8 @@
1
1
  import { useEffect, useState } from "react"
2
2
 
3
- const basePath = process.env.BASE_PATH
4
- console.log("😅😅😅 ~ basePath:", basePath)
5
-
6
3
  const getWS = () => {
7
4
  const url = new URL(window.location.href)
8
- const endPathname = url.pathname.split("/")
9
- url.pathname = url.pathname.replace(
10
- `/${endPathname[endPathname.length - 1]}`,
11
- "/ws",
12
- )
5
+ url.pathname = `${process.env.BASE_PATH}/ws`
13
6
  url.protocol = "ws:"
14
7
  const ws = new WebSocket(url)
15
8