@octane-xplat/devtools 0.0.0-nightly.g1b95ef7

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.
Files changed (64) hide show
  1. package/README.md +5 -0
  2. package/dist/app.d.ts +28 -0
  3. package/dist/app.js +66 -0
  4. package/dist/backend.d.ts +31 -0
  5. package/dist/backend.js +182 -0
  6. package/dist/client.d.ts +49 -0
  7. package/dist/client.js +168 -0
  8. package/dist/host/desktop.d.ts +15 -0
  9. package/dist/host/desktop.js +133 -0
  10. package/dist/host/panels.d.ts +14 -0
  11. package/dist/host/panels.js +156 -0
  12. package/dist/host/records.d.ts +5 -0
  13. package/dist/host/records.js +46 -0
  14. package/dist/host/server.d.ts +8 -0
  15. package/dist/host/server.js +67 -0
  16. package/dist/host/web.d.ts +5 -0
  17. package/dist/host/web.js +74 -0
  18. package/dist/macos/index.macos.d.ts +3 -0
  19. package/dist/macos/index.macos.js +5 -0
  20. package/dist/macos/servers.macos.d.ts +4 -0
  21. package/dist/macos/servers.macos.js +57 -0
  22. package/dist/macos/socket.macos.d.ts +2 -0
  23. package/dist/macos/socket.macos.js +152 -0
  24. package/dist/macos/ws-frames.d.ts +24 -0
  25. package/dist/macos/ws-frames.js +205 -0
  26. package/dist/node.d.ts +12 -0
  27. package/dist/node.js +51 -0
  28. package/dist/record.d.ts +9 -0
  29. package/dist/record.js +38 -0
  30. package/dist/types.d.ts +128 -0
  31. package/dist/types.js +25 -0
  32. package/package.json +88 -0
  33. package/src/app.ts +105 -0
  34. package/src/assets.d.ts +2 -0
  35. package/src/backend.ts +278 -0
  36. package/src/client.ts +248 -0
  37. package/src/desktop/Shell.macos.tsrx +158 -0
  38. package/src/desktop/Shell.ts +16 -0
  39. package/src/desktop/index.macos.ts +7 -0
  40. package/src/desktop/main.macos.ts +130 -0
  41. package/src/desktop/panels.d.ts +10 -0
  42. package/src/desktop/target.ts +34 -0
  43. package/src/host/desktop.ts +176 -0
  44. package/src/host/panels.ts +193 -0
  45. package/src/host/records.ts +62 -0
  46. package/src/host/server.ts +92 -0
  47. package/src/host/web.ts +68 -0
  48. package/src/macos/index.macos.ts +7 -0
  49. package/src/macos/servers.macos.ts +83 -0
  50. package/src/macos/socket.macos.ts +218 -0
  51. package/src/macos/ws-frames.ts +249 -0
  52. package/src/node.ts +60 -0
  53. package/src/panel/App.tsrx +288 -0
  54. package/src/panel/index.html +12 -0
  55. package/src/panel/index.ts +24 -0
  56. package/src/panel/main.tsrx +2 -0
  57. package/src/panel/main.web.tsrx +89 -0
  58. package/src/panel/model.ts +216 -0
  59. package/src/panel/panel.css +189 -0
  60. package/src/panel/plugin.ts +65 -0
  61. package/src/panel/styles.ts +5 -0
  62. package/src/panel/tsconfig.browser.json +9 -0
  63. package/src/record.ts +66 -0
  64. package/src/types.ts +129 -0
@@ -0,0 +1,249 @@
1
+ // Pure WebSocket framing: handshake request/accept, masked client frame
2
+ // encoding, and an incremental decoder (chunked input, fragmented
3
+ // continuation frames, 16/64-bit lengths). No host APIs — node --test-able.
4
+
5
+ export function utf8Encode(s: string): Uint8Array {
6
+ const out = new Uint8Array(s.length * 4)
7
+ let n = 0
8
+
9
+ for (let i = 0; i < s.length; i++) {
10
+ let c = s.charCodeAt(i)
11
+
12
+ if (c >= 0xd800 && c < 0xdc00 && i + 1 < s.length) {
13
+ c = 0x10000 + ((c - 0xd800) << 10) + (s.charCodeAt(++i) - 0xdc00)
14
+ }
15
+
16
+ if (c < 0x80) {
17
+ out[n++] = c
18
+ } else if (c < 0x800) {
19
+ out[n++] = 0xc0 | (c >> 6)
20
+ out[n++] = 0x80 | (c & 0x3f)
21
+ } else if (c < 0x10000) {
22
+ out[n++] = 0xe0 | (c >> 12)
23
+ out[n++] = 0x80 | ((c >> 6) & 0x3f)
24
+ out[n++] = 0x80 | (c & 0x3f)
25
+ } else {
26
+ out[n++] = 0xf0 | (c >> 18)
27
+ out[n++] = 0x80 | ((c >> 12) & 0x3f)
28
+ out[n++] = 0x80 | ((c >> 6) & 0x3f)
29
+ out[n++] = 0x80 | (c & 0x3f)
30
+ }
31
+ }
32
+
33
+ return out.subarray(0, n)
34
+ }
35
+
36
+ export function utf8Decode(bytes: Uint8Array): string {
37
+ let s = ''
38
+
39
+ for (let i = 0; i < bytes.length; i++) {
40
+ const b = bytes[i]
41
+
42
+ if (b < 0x80) {
43
+ s += String.fromCharCode(b)
44
+ } else if (b < 0xe0) {
45
+ s += String.fromCharCode(((b & 0x1f) << 6) | (bytes[++i] & 0x3f))
46
+ } else if (b < 0xf0) {
47
+ s += String.fromCharCode(
48
+ ((b & 0x0f) << 12) | ((bytes[++i] & 0x3f) << 6) | (bytes[++i] & 0x3f),
49
+ )
50
+ } else {
51
+ const cp =
52
+ ((b & 0x07) << 18) |
53
+ ((bytes[++i] & 0x3f) << 12) |
54
+ ((bytes[++i] & 0x3f) << 6) |
55
+ (bytes[++i] & 0x3f)
56
+
57
+ s += String.fromCharCode(0xd800 + ((cp - 0x10000) >> 10), 0xdc00 + ((cp - 0x10000) & 0x3ff))
58
+ }
59
+ }
60
+
61
+ return s
62
+ }
63
+
64
+ const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
65
+
66
+ export function base64Encode(bytes: Uint8Array): string {
67
+ let out = ''
68
+
69
+ for (let i = 0; i < bytes.length; i += 3) {
70
+ const a = bytes[i],
71
+ b = bytes[i + 1],
72
+ c = bytes[i + 2]
73
+
74
+ out +=
75
+ B64[a >> 2] +
76
+ B64[((a & 3) << 4) | ((b ?? 0) >> 4)] +
77
+ (b === undefined ? '=' : B64[((b & 15) << 2) | ((c ?? 0) >> 6)]) +
78
+ (c === undefined ? '=' : B64[c & 63])
79
+ }
80
+
81
+ return out
82
+ }
83
+
84
+ export function handshakeRequest(host: string, port: string, path: string): Uint8Array {
85
+ const key = base64Encode(utf8Encode(`${Date.now()}${Math.random()}`).subarray(0, 16))
86
+ const request =
87
+ `GET ${path} HTTP/1.1\r\nHost: ${host}:${port}\r\nUpgrade: websocket\r\n` +
88
+ `Connection: Upgrade\r\nSec-WebSocket-Key: ${key}\r\nSec-WebSocket-Version: 13\r\n\r\n`
89
+
90
+ return utf8Encode(request)
91
+ }
92
+
93
+ // Returns the byte offset past the headers on 101, or -1 when incomplete,
94
+ // or throws on a rejected upgrade.
95
+ export function handshakeAccept(buffer: Uint8Array): number {
96
+ const text = utf8Decode(buffer)
97
+ const end = text.indexOf('\r\n\r\n')
98
+
99
+ if (end < 0) {
100
+ return -1
101
+ }
102
+
103
+ const status = /^HTTP\/[\d.]+ (\d+)/.exec(text)?.[1]
104
+
105
+ if (status !== '101') {
106
+ throw new Error(`websocket upgrade rejected: ${text.slice(0, end)}`)
107
+ }
108
+
109
+ return end + 4
110
+ }
111
+
112
+ export type FrameEvent =
113
+ | { type: 'text'; data: string }
114
+ | { type: 'close' }
115
+ | { type: 'ping'; payload: Uint8Array }
116
+ | { type: 'pong'; payload: Uint8Array }
117
+
118
+ export function encodeFrame(opcode: number, payload: Uint8Array, maskKey?: Uint8Array): Uint8Array {
119
+ const mask = maskKey ?? new Uint8Array(4)
120
+
121
+ if (!maskKey) {
122
+ for (let i = 0; i < 4; i++) {
123
+ mask[i] = (Math.random() * 256) | 0
124
+ }
125
+ }
126
+
127
+ const len = payload.length
128
+ const header: number[] = [0x80 | opcode]
129
+
130
+ if (len < 126) {
131
+ header.push(0x80 | len)
132
+ } else if (len < 65536) {
133
+ header.push(0x80 | 126, len >> 8, len & 0xff)
134
+ } else {
135
+ header.push(0x80 | 127)
136
+ for (let s = 56; s >= 0; s -= 8) {
137
+ header.push(((len / 2 ** s) | 0) & 0xff)
138
+ }
139
+ }
140
+
141
+ const out = new Uint8Array(header.length + 4 + len)
142
+
143
+ out.set(header, 0)
144
+ out.set(mask, header.length)
145
+ for (let i = 0; i < len; i++) {
146
+ out[header.length + 4 + i] = payload[i] ^ mask[i & 3]
147
+ }
148
+
149
+ return out
150
+ }
151
+
152
+ // Incremental server→client decoder. Server frames arrive unmasked; control
153
+ // frames are never fragmented; data frames may fragment — continuation
154
+ // payloads accumulate until FIN.
155
+ export class FrameDecoder {
156
+ private buffer = new Uint8Array(0)
157
+ private fragments: Uint8Array[] = []
158
+ private fragmentOpcode = -1
159
+
160
+ push(chunk: Uint8Array): FrameEvent[] {
161
+ const merged = new Uint8Array(this.buffer.length + chunk.length)
162
+
163
+ merged.set(this.buffer, 0)
164
+ merged.set(chunk, this.buffer.length)
165
+ this.buffer = merged
166
+
167
+ const events: FrameEvent[] = []
168
+
169
+ for (;;) {
170
+ if (this.buffer.length < 2) {
171
+ return events
172
+ }
173
+
174
+ const b = this.buffer
175
+ const fin = (b[0] & 0x80) !== 0
176
+ const opcode = b[0] & 0x0f
177
+
178
+ if (b[1] & 0x80) {
179
+ throw new Error('masked server frame')
180
+ }
181
+
182
+ const len0 = b[1] & 0x7f
183
+ const off = len0 < 126 ? 2 : len0 === 126 ? 4 : 10
184
+ let len = len0
185
+
186
+ if (len0 === 126) {
187
+ len = (b[2] << 8) | b[3]
188
+ } else if (len0 === 127) {
189
+ const n =
190
+ (BigInt(b[2]) << 56n) |
191
+ (BigInt(b[3]) << 48n) |
192
+ (BigInt(b[4]) << 40n) |
193
+ (BigInt(b[5]) << 32n) |
194
+ (BigInt(b[6]) << 24n) |
195
+ (BigInt(b[7]) << 16n) |
196
+ (BigInt(b[8]) << 8n) |
197
+ BigInt(b[9])
198
+
199
+ len = Number(n)
200
+ }
201
+
202
+ if (this.buffer.length < off + len) {
203
+ return events
204
+ }
205
+
206
+ const payload = b.subarray(off, off + len)
207
+
208
+ this.buffer = b.subarray(off + len)
209
+
210
+ if (opcode === 0) {
211
+ if (this.fragmentOpcode < 0) {
212
+ throw new Error('continuation without start')
213
+ }
214
+
215
+ this.fragments.push(payload)
216
+ if (fin) {
217
+ const total = this.fragments.reduce((n, f) => n + f.length, 0)
218
+ const joined = new Uint8Array(total)
219
+ let o = 0
220
+
221
+ for (const f of this.fragments) {
222
+ joined.set(f, o)
223
+ o += f.length
224
+ }
225
+
226
+ this.fragments = []
227
+ if (this.fragmentOpcode === 1) {
228
+ events.push({ type: 'text', data: utf8Decode(joined) })
229
+ }
230
+
231
+ this.fragmentOpcode = -1
232
+ }
233
+ } else if (opcode === 1) {
234
+ if (fin) {
235
+ events.push({ type: 'text', data: utf8Decode(payload) })
236
+ } else {
237
+ this.fragmentOpcode = 1
238
+ this.fragments = [payload]
239
+ }
240
+ } else if (opcode === 8) {
241
+ events.push({ type: 'close' })
242
+ } else if (opcode === 9) {
243
+ events.push({ type: 'ping', payload })
244
+ } else if (opcode === 10) {
245
+ events.push({ type: 'pong', payload })
246
+ }
247
+ }
248
+ }
249
+ }
package/src/node.ts ADDED
@@ -0,0 +1,60 @@
1
+ // Node-side devtools host entry — `@octane-xplat/devtools/node`.
2
+ // The Go `xplat devtools` command (or a direct `node dist/node.js --serve`)
3
+ // launches this module; it serves the panel over loopback and prints the
4
+ // endpoint as a single JSON line for the launching process.
5
+
6
+ import { serveDevtools, type DevtoolsHost } from './host/server.ts'
7
+ import { listDevtoolsServers } from './host/records.ts'
8
+
9
+ export { serveDevtools, listDevtoolsServers }
10
+ export type { DevtoolsHost } from './host/server.ts'
11
+ export type { ListedDevtoolsServer } from './host/records.ts'
12
+
13
+ /**
14
+ * Starts the panel host. `--port N` pins a port (default 0 = ephemeral);
15
+ * `--json` reports the endpoint as JSON for launchers, otherwise a URL line
16
+ * is printed. Resolves once the server is listening and stays alive until
17
+ * SIGINT/SIGTERM.
18
+ */
19
+ export async function devtoolsHostMain(argv: string[] = process.argv.slice(2)): Promise<void> {
20
+ let port = 0
21
+ let json = false
22
+
23
+ for (let i = 0; i < argv.length; i++) {
24
+ if (argv[i] === '--json') {
25
+ json = true
26
+ } else if (argv[i] === '--port') {
27
+ port = Number.parseInt(argv[++i] ?? '', 10)
28
+ if (!Number.isInteger(port) || port < 0 || port > 65535) {
29
+ throw new Error('devtools host port must be an integer from 0 to 65535')
30
+ }
31
+ } else {
32
+ throw new Error(`Unknown devtools host argument: ${argv[i]}`)
33
+ }
34
+ }
35
+
36
+ const host = await serveDevtools({ port })
37
+
38
+ if (json) {
39
+ process.stdout.write(`${JSON.stringify({ endpoint: host.endpoint })}\n`)
40
+ } else {
41
+ process.stdout.write(`Octane Xplat devtools: ${host.endpoint}\n`)
42
+ }
43
+
44
+ const close = async () => {
45
+ await host.close()
46
+ process.exit(0)
47
+ }
48
+
49
+ process.once('SIGINT', close)
50
+ process.once('SIGTERM', close)
51
+ }
52
+
53
+ const invoked = process.argv[1]
54
+
55
+ if (invoked && import.meta.url === new URL(`file://${invoked}`).href) {
56
+ devtoolsHostMain().catch((error) => {
57
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`)
58
+ process.exit(1)
59
+ })
60
+ }
@@ -0,0 +1,288 @@
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
+ // Shared devtools panel shell — Sessions/Actions/Logs tabs driven by a
3
+ // connectDevtools session. The web build wraps this in a server picker; the
4
+ // macOS app mounts one App per discovered record (the window is the picker).
5
+ import './styles'
6
+ import { useEffect, useLazyRef, useRef, useState } from 'octane'
7
+ import { useStore } from '@octane-xplat/ui/data'
8
+ import {
9
+ Button,
10
+ HStack,
11
+ Pressable,
12
+ Popover,
13
+ ScrollableArea,
14
+ Text,
15
+ VStack,
16
+ View,
17
+ type ScrollableAreaHandle,
18
+ } from '@octane-xplat/ui'
19
+
20
+ import type { DevtoolsServerRecord, SessionSnapshot } from '../client.ts'
21
+ import type { DevSocket } from '../types.ts'
22
+ import { PanelModel, type ActionRun, type LogLine } from './model'
23
+ import { resolveDevtoolsPanelPlugins, type DevtoolsPanelPlugin } from './plugin.ts'
24
+
25
+ export interface DevtoolsPanelProps {
26
+ /** The dev-server discovery record this panel connects to. */
27
+ record: DevtoolsServerRecord
28
+ /** Socket factory override — macOS passes nwDevSocket (no host WebSocket). */
29
+ socket?: (url: string) => DevSocket | undefined
30
+ /** Panel plugins appended after the built-in tabs. */
31
+ plugins?: readonly DevtoolsPanelPlugin[]
32
+ /** Tab to show on mount; ignored when it names no known tab. */
33
+ initialTab?: string
34
+ }
35
+
36
+ const TABS = [
37
+ { id: 'sessions', label: 'Sessions' },
38
+ { id: 'actions', label: 'Actions' },
39
+ { id: 'logs', label: 'Logs' },
40
+ ] as const
41
+
42
+ const LOG_DISPLAY = 300
43
+
44
+ function SessionRow(props: { session: SessionSnapshot; model: PanelModel }) @{
45
+ const session = props.session
46
+ const anchor = useRef<object | null>(null)
47
+ const [open, setOpen] = useState(false)
48
+ const rates = useStore(props.model.motionRates$)
49
+ const rate = rates.get(session.sessionId)
50
+ const supported =
51
+ session.state === 'ready' &&
52
+ session.channels.some((channel) => channel.id === 'xplat-motion' && channel.version === 1)
53
+
54
+ useEffect(() => {
55
+ if (open && supported) {
56
+ props.model.requestMotionRate(session)
57
+ }
58
+ }, [open, supported, session.sessionId])
59
+
60
+ <HStack className="dt-row">
61
+ <Text className="dt-name">{session.sessionId.slice(0, 8)}</Text>
62
+ <Text className="dt-meta">{session.platform ?? ''}</Text>
63
+ <Text className="dt-meta">{session.state ?? ''}</Text>
64
+ <HStack className="dt-right">
65
+ @for (const channel of session.channels ?? []; key channel.id) {
66
+ <Text className="dt-chip">{`${channel.id}@${channel.version}`}</Text>
67
+ }
68
+ <View ref={anchor}>
69
+ <Button label="⚙" accessibilityLabel="Session settings" onPress={() => setOpen(!open)} />
70
+ </View>
71
+ </HStack>
72
+ <Popover
73
+ anchor={anchor}
74
+ open={open}
75
+ onDismiss={() => setOpen(false)}
76
+ placement="bottom"
77
+ alignment="end"
78
+ >
79
+ <VStack className="dt-session-settings">
80
+ <Text className="dt-name">Motion speed</Text>
81
+ @if (supported) {
82
+ <>
83
+ <Text className="dt-meta">
84
+ {rate === undefined ? 'Reading speed…' : `${rate}×`}
85
+ </Text>
86
+ <HStack className="dt-right">
87
+ <Button
88
+ label="Normal (1×)"
89
+ onPress={() => props.model.requestMotionRate(session, 1)}
90
+ />
91
+ <Button
92
+ label="Slow (0.25×)"
93
+ onPress={() => props.model.requestMotionRate(session, 0.25)}
94
+ />
95
+ </HStack>
96
+ <Text className="dt-meta">Also slows delays tied to animations.</Text>
97
+ </>
98
+ } @else {
99
+ <Text className="dt-meta">Unavailable for this session.</Text>
100
+ }
101
+ </VStack>
102
+ </Popover>
103
+ </HStack>
104
+ }
105
+
106
+ function ActionRow(props: {
107
+ action: NonNullable<SessionSnapshot['actions']>[number]
108
+ run: ActionRun | undefined
109
+ onRun: () => void
110
+ }) @{
111
+ const action = props.action
112
+ const run = props.run
113
+
114
+ <>
115
+ <HStack className="dt-row">
116
+ <Text className="dt-name">{action.id}</Text>
117
+ {action.title ? <Text className="dt-meta">{action.title}</Text> : null}
118
+ <HStack className="dt-right">
119
+ @if (action.availability?.ready === false) {
120
+ <Text className="dt-meta">unavailable</Text>
121
+ } @else {
122
+ <Button
123
+ className="dt-run"
124
+ label={run?.status === 'running' ? '…' : 'Run'}
125
+ isDisabled={run?.status === 'running'}
126
+ onPress={props.onRun}
127
+ />
128
+ }
129
+ </HStack>
130
+ </HStack>
131
+ @if (run && run.status !== 'running') {
132
+ <VStack className={['dt-outcome', `dt-outcome-${run.status}`]}>
133
+ <Text className="dt-outcome-status">{run.status}</Text>
134
+ {run.error ? (
135
+ <Text className="dt-pre">{JSON.stringify(run.error, null, 2)}</Text>
136
+ ) : null}
137
+ {run.result !== undefined ? (
138
+ <Text className="dt-pre">{JSON.stringify(run.result, null, 2)}</Text>
139
+ ) : null}
140
+ </VStack>
141
+ }
142
+ </>
143
+ }
144
+
145
+ function LogRow(props: { record: LogLine }) @{
146
+ const record = props.record
147
+
148
+ <HStack className={['dt-log-line', `dt-log-${record.level}`]}>
149
+ <Text className="dt-level">{record.level}</Text>
150
+ <Text className="dt-text">{record.line}</Text>
151
+ <Text className="dt-at">{(record.at ?? '').slice(11, 19)}</Text>
152
+ </HStack>
153
+ }
154
+
155
+ export function App(props: DevtoolsPanelProps) @{
156
+ const model = useLazyRef(() => new PanelModel())
157
+ const plugins = useLazyRef(() => resolveDevtoolsPanelPlugins(props.plugins ?? []))
158
+ const tabs = [
159
+ ...TABS,
160
+ ...plugins.current.map((plugin) => ({ id: plugin.id, label: plugin.title })),
161
+ ]
162
+
163
+ const [tab, setTab] = useState<string>(
164
+ tabs.some((item) => item.id === props.initialTab) ? props.initialTab! : 'sessions',
165
+ )
166
+ const [connectionVersion, setConnectionVersion] = useState(0)
167
+
168
+ const scrollRef = useRef<ScrollableAreaHandle | null>(null)
169
+
170
+ useEffect(() => {
171
+ model.current.connect(props.record, props.socket)
172
+ setConnectionVersion((version) => version + 1)
173
+ return () => model.current.dispose()
174
+ }, [props.record.instanceId, props.socket])
175
+
176
+ const connState = useStore(model.current.connState$)
177
+ const panel = useStore(model.current.panel$)
178
+ const sessions = useStore(model.current.sessions$)
179
+ const backends = useStore(model.current.backends$)
180
+ const logs = useStore(model.current.logs$)
181
+ const runs = useStore(model.current.runs$)
182
+ const logTarget = useStore(model.current.logTarget$)
183
+
184
+ // Newest log line stays pinned to the viewport end — the scrollIntoView
185
+ // behavior of the retired DOM panel.
186
+ useEffect(() => {
187
+ if (tab === 'logs' && logs.length) {
188
+ scrollRef.current?.scrollToOffset({ block: Number.MAX_SAFE_INTEGER })
189
+ }
190
+ }, [logs.length, tab])
191
+
192
+ const badge = connState === 'live' ? `live — ${panel ?? ''}` : connState
193
+ const withActions = sessions.filter((session) => session.actions?.length)
194
+ const pluginTab = plugins.current.find((plugin) => plugin.id === tab)
195
+ const connection = model.current.connection
196
+
197
+ <VStack className="dt-root">
198
+ <HStack className="dt-nav">
199
+ <HStack className="dt-tabs">
200
+ @for (const item of tabs; key item.id) {
201
+ <Pressable
202
+ className={['dt-tab', tab === item.id && 'dt-tab-active']}
203
+ onPress={() => setTab(item.id)}
204
+ >
205
+ <Text className="dt-tab-label">{item.label}</Text>
206
+ </Pressable>
207
+ }
208
+ </HStack>
209
+ <Text className={['dt-badge', `dt-badge-${connState}`]}>{badge}</Text>
210
+ </HStack>
211
+ @if (pluginTab) {
212
+ // Plugin tabs own their own scrolling — no dt-main ScrollableArea.
213
+ <VStack className="dt-plugin-host">
214
+ @if (connection) {
215
+ // Plugins bind their subscriptions to the connection they mount with.
216
+ <pluginTab.Panel key={connectionVersion} connection={connection} state={connState} />
217
+ }
218
+ </VStack>
219
+ } @else {
220
+ <ScrollableArea className="dt-main" ref={scrollRef}>
221
+ <VStack className="dt-content">
222
+ @if (tab === 'sessions') {
223
+ <>
224
+ <Text
225
+ className={['dt-heading', 'dt-heading-first']}
226
+ >{`Sessions (${sessions.length})`}</Text>
227
+ @if (!sessions.length) {
228
+ <Text className="dt-empty">No app sessions connected.</Text>
229
+ }
230
+ @for (const session of sessions; key session.sessionId) {
231
+ <SessionRow session={session} model={model.current} />
232
+ }
233
+ <Text className="dt-heading">{`Backends (${backends.length})`}</Text>
234
+ @if (!backends.length) {
235
+ <Text className="dt-empty">No engine backends connected.</Text>
236
+ }
237
+ @for (const backend of backends; key `${backend.channel}:${backend.targetId}`) {
238
+ <HStack className="dt-row">
239
+ <Text className="dt-name">{backend.channel}</Text>
240
+ <Text className="dt-meta">{backend.targetId}</Text>
241
+ </HStack>
242
+ }
243
+ </>
244
+ } @else if (tab === 'actions') {
245
+ <>
246
+ @if (!withActions.length) {
247
+ <Text className="dt-empty">
248
+ No session declares dev actions.
249
+ </Text>
250
+ }
251
+ @for (const session of withActions; key session.sessionId) {
252
+ <>
253
+ <Text className={['dt-heading', 'dt-heading-first']}>
254
+ {`${session.sessionId.slice(0, 8)} — ${session.platform ?? 'app'}`}
255
+ </Text>
256
+ @for (const action of session.actions ?? []; key action.id) {
257
+ <ActionRow
258
+ action={action}
259
+ run={runs.get(action.id)}
260
+ onRun={() => model.current.invoke(session, action.id)}
261
+ />
262
+ }
263
+ </>
264
+ }
265
+ </>
266
+ } @else {
267
+ <>
268
+ <HStack className="dt-toolbar">
269
+ <Text className="dt-meta">
270
+ {logTarget ? `target ${logTarget}` : 'no xplat-logs backend'}
271
+ </Text>
272
+ <HStack className="dt-right">
273
+ <Button label="Clear" onPress={() => model.current.clearLogs()} />
274
+ </HStack>
275
+ </HStack>
276
+ @if (!logs.length) {
277
+ <Text className="dt-empty">No log records yet.</Text>
278
+ }
279
+ @for (const record of logs.slice(-LOG_DISPLAY); index i; key i) {
280
+ <LogRow record={record} />
281
+ }
282
+ </>
283
+ }
284
+ </VStack>
285
+ </ScrollableArea>
286
+ }
287
+ </VStack>
288
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Octane Xplat Devtools</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./main.web.tsrx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,24 @@
1
+ // Shared devtools panel — `@octane-xplat/devtools/panel`. The web build wraps
2
+ // App in a server picker (main.web.tsrx); the macOS app targets one record
3
+ // through the Shell. `plugin.ts` is the panel-plugin contract — a package
4
+ // default-exports a `defineDevtoolsPanel` result from the subpath named by
5
+ // its `octaneXplat.devtoolsPanel` field, and App renders it as a tab after
6
+ // the built-ins. The generic web panel (/devtools/app/) shows the built-ins;
7
+ // the project browser build and macOS launch include discovered plugins.
8
+
9
+ export { App } from './App.tsrx'
10
+ export type { DevtoolsPanelProps } from './App.tsrx'
11
+ export { PanelModel } from './model'
12
+ export type { DevSocketFactory, LogLine, ActionRun } from './model'
13
+ export { defineDevtoolsPanel, resolveDevtoolsPanelPlugins } from './plugin.ts'
14
+ export type { DevtoolsPanelPlugin, DevtoolsPanelPluginProps } from './plugin.ts'
15
+ export type {
16
+ BackendRef,
17
+ DevtoolsConnection,
18
+ DevtoolsMessage,
19
+ DevtoolsServerRecord,
20
+ SessionSnapshot,
21
+ } from '../client.ts'
22
+
23
+ export type { ListedDevtoolsServer } from '../record.ts'
24
+ export type { DevSocket } from '../types.ts'
@@ -0,0 +1,2 @@
1
+ // Type contract only. The target build must select a platform implementation.
2
+ export {}