@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.
- package/README.md +5 -0
- package/dist/app.d.ts +28 -0
- package/dist/app.js +66 -0
- package/dist/backend.d.ts +31 -0
- package/dist/backend.js +182 -0
- package/dist/client.d.ts +49 -0
- package/dist/client.js +168 -0
- package/dist/host/desktop.d.ts +15 -0
- package/dist/host/desktop.js +133 -0
- package/dist/host/panels.d.ts +14 -0
- package/dist/host/panels.js +156 -0
- package/dist/host/records.d.ts +5 -0
- package/dist/host/records.js +46 -0
- package/dist/host/server.d.ts +8 -0
- package/dist/host/server.js +67 -0
- package/dist/host/web.d.ts +5 -0
- package/dist/host/web.js +74 -0
- package/dist/macos/index.macos.d.ts +3 -0
- package/dist/macos/index.macos.js +5 -0
- package/dist/macos/servers.macos.d.ts +4 -0
- package/dist/macos/servers.macos.js +57 -0
- package/dist/macos/socket.macos.d.ts +2 -0
- package/dist/macos/socket.macos.js +152 -0
- package/dist/macos/ws-frames.d.ts +24 -0
- package/dist/macos/ws-frames.js +205 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.js +51 -0
- package/dist/record.d.ts +9 -0
- package/dist/record.js +38 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.js +25 -0
- package/package.json +88 -0
- package/src/app.ts +105 -0
- package/src/assets.d.ts +2 -0
- package/src/backend.ts +278 -0
- package/src/client.ts +248 -0
- package/src/desktop/Shell.macos.tsrx +158 -0
- package/src/desktop/Shell.ts +16 -0
- package/src/desktop/index.macos.ts +7 -0
- package/src/desktop/main.macos.ts +130 -0
- package/src/desktop/panels.d.ts +10 -0
- package/src/desktop/target.ts +34 -0
- package/src/host/desktop.ts +176 -0
- package/src/host/panels.ts +193 -0
- package/src/host/records.ts +62 -0
- package/src/host/server.ts +92 -0
- package/src/host/web.ts +68 -0
- package/src/macos/index.macos.ts +7 -0
- package/src/macos/servers.macos.ts +83 -0
- package/src/macos/socket.macos.ts +218 -0
- package/src/macos/ws-frames.ts +249 -0
- package/src/node.ts +60 -0
- package/src/panel/App.tsrx +288 -0
- package/src/panel/index.html +12 -0
- package/src/panel/index.ts +24 -0
- package/src/panel/main.tsrx +2 -0
- package/src/panel/main.web.tsrx +89 -0
- package/src/panel/model.ts +216 -0
- package/src/panel/panel.css +189 -0
- package/src/panel/plugin.ts +65 -0
- package/src/panel/styles.ts +5 -0
- package/src/panel/tsconfig.browser.json +9 -0
- package/src/record.ts +66 -0
- package/src/types.ts +129 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** @jsxImportSource @octane-xplat/jsx/dom */
|
|
2
|
+
// Web entry for the devtools panel — a thin picker over the shared App: fetch
|
|
3
|
+
// /devtools/servers from the hosting dev server, keep the selected record,
|
|
4
|
+
// and let App own the connection. Served under /devtools/app/ by `xplat dev`.
|
|
5
|
+
import { createRoot, useEffect, useState } from 'octane'
|
|
6
|
+
import { App } from './App.tsrx'
|
|
7
|
+
import type { ListedDevtoolsServer } from '../record.ts'
|
|
8
|
+
import plugins from 'virtual:octane-devtools-panels'
|
|
9
|
+
|
|
10
|
+
declare const __XPLAT_DEVTOOLS_PROJECT__: string | null
|
|
11
|
+
|
|
12
|
+
async function fetchServers(): Promise<ListedDevtoolsServer[]> {
|
|
13
|
+
try {
|
|
14
|
+
const body = (await (await fetch('/devtools/servers')).json()) as {
|
|
15
|
+
servers?: ListedDevtoolsServer[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const servers = Array.isArray(body.servers) ? body.servers : []
|
|
19
|
+
return __XPLAT_DEVTOOLS_PROJECT__
|
|
20
|
+
? servers.filter((server) => server.appRoot === __XPLAT_DEVTOOLS_PROJECT__)
|
|
21
|
+
: servers
|
|
22
|
+
} catch {
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Picker() {
|
|
28
|
+
const [servers, setServers] = useState<ListedDevtoolsServer[]>([])
|
|
29
|
+
const [record, setRecord] = useState<ListedDevtoolsServer | null>(null)
|
|
30
|
+
|
|
31
|
+
const refresh = async () => {
|
|
32
|
+
const next = await fetchServers()
|
|
33
|
+
|
|
34
|
+
setServers(next)
|
|
35
|
+
setRecord((current) => {
|
|
36
|
+
if (current && next.some((server) => server.key === current.key)) {
|
|
37
|
+
return current
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return next[0] ?? null
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
void refresh()
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="dt-shell">
|
|
50
|
+
<header className="dt-header">
|
|
51
|
+
<span className="dt-brand">devtools</span>
|
|
52
|
+
<select
|
|
53
|
+
className="dt-select"
|
|
54
|
+
aria-label="Dev server"
|
|
55
|
+
value={record?.key ?? ''}
|
|
56
|
+
onChange={(event) => {
|
|
57
|
+
const key = (event.target as HTMLSelectElement).value
|
|
58
|
+
|
|
59
|
+
setRecord(servers.find((server) => server.key === key) ?? null)
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{servers.length ? (
|
|
63
|
+
servers.map((server) => (
|
|
64
|
+
<option key={server.key} value={server.key}>
|
|
65
|
+
{server.appRoot}
|
|
66
|
+
</option>
|
|
67
|
+
))
|
|
68
|
+
) : (
|
|
69
|
+
<option value="">No xplat dev servers found</option>
|
|
70
|
+
)}
|
|
71
|
+
</select>
|
|
72
|
+
<button
|
|
73
|
+
className="dt-refresh"
|
|
74
|
+
title="Rescan dev server records"
|
|
75
|
+
onClick={() => void refresh()}
|
|
76
|
+
>
|
|
77
|
+
Refresh
|
|
78
|
+
</button>
|
|
79
|
+
</header>
|
|
80
|
+
{record ? (
|
|
81
|
+
<App key={record.key} record={record} plugins={plugins} />
|
|
82
|
+
) : (
|
|
83
|
+
<div className="dt-empty">Pick a dev server above to connect.</div>
|
|
84
|
+
)}
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
createRoot(document.getElementById('root')!).render(<Picker />)
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Hook-free panel model — owns the connectDevtools lifecycle and exposes each
|
|
2
|
+
// render slice as a store. Actions go through the reserved xplat-actions app
|
|
3
|
+
// channel; logs come from the xplat-logs engine backend. Behavior mirrors the
|
|
4
|
+
// retired vanilla panel (app/panel.js): bare outcomes map back to actions by
|
|
5
|
+
// requestId, logs subscribe on the backend ref's first appearance, and the log
|
|
6
|
+
// view keeps the newest 500 records.
|
|
7
|
+
|
|
8
|
+
import { createStore } from '@octane-xplat/ui/data'
|
|
9
|
+
import {
|
|
10
|
+
connectDevtools,
|
|
11
|
+
type BackendRef,
|
|
12
|
+
type DevtoolsConnection,
|
|
13
|
+
type DevtoolsServerRecord,
|
|
14
|
+
type SessionSnapshot,
|
|
15
|
+
} from '../client.ts'
|
|
16
|
+
|
|
17
|
+
import type { DevSocket } from '../types.ts'
|
|
18
|
+
|
|
19
|
+
export type DevSocketFactory = (url: string) => DevSocket | undefined
|
|
20
|
+
|
|
21
|
+
export interface LogLine {
|
|
22
|
+
level: string
|
|
23
|
+
line: string
|
|
24
|
+
at?: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ActionRun {
|
|
28
|
+
status: string
|
|
29
|
+
result?: unknown
|
|
30
|
+
error?: unknown
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const LOG_KEEP = 500
|
|
34
|
+
|
|
35
|
+
export class PanelModel {
|
|
36
|
+
readonly connState$ = createStore<'connecting' | 'live' | 'closed'>('connecting')
|
|
37
|
+
readonly panel$ = createStore<string | null>(null)
|
|
38
|
+
readonly sessions$ = createStore<readonly SessionSnapshot[]>([])
|
|
39
|
+
readonly backends$ = createStore<readonly BackendRef[]>([])
|
|
40
|
+
readonly logs$ = createStore<readonly LogLine[]>([])
|
|
41
|
+
readonly runs$ = createStore<ReadonlyMap<string, ActionRun>>(new Map())
|
|
42
|
+
readonly motionRates$ = createStore<ReadonlyMap<string, number>>(new Map())
|
|
43
|
+
readonly logTarget$ = createStore<string | null>(null)
|
|
44
|
+
|
|
45
|
+
private conn: DevtoolsConnection | null = null
|
|
46
|
+
private readonly requests = new Map<string, string>()
|
|
47
|
+
private readonly runs = new Map<string, ActionRun>()
|
|
48
|
+
private logs: LogLine[] = []
|
|
49
|
+
private requestCounter = 0
|
|
50
|
+
|
|
51
|
+
connect(record: DevtoolsServerRecord, socket?: DevSocketFactory) {
|
|
52
|
+
this.dispose()
|
|
53
|
+
this.requests.clear()
|
|
54
|
+
this.runs.clear()
|
|
55
|
+
this.logs = []
|
|
56
|
+
this.connState$.set('connecting')
|
|
57
|
+
this.panel$.set(null)
|
|
58
|
+
this.sessions$.set([])
|
|
59
|
+
this.backends$.set([])
|
|
60
|
+
this.logs$.set([])
|
|
61
|
+
this.runs$.set(new Map())
|
|
62
|
+
this.logTarget$.set(null)
|
|
63
|
+
this.motionRates$.set(new Map())
|
|
64
|
+
|
|
65
|
+
const conn = connectDevtools(record, socket ? { socket } : {})
|
|
66
|
+
|
|
67
|
+
this.conn = conn
|
|
68
|
+
|
|
69
|
+
conn.onState((state) => {
|
|
70
|
+
this.connState$.set(state)
|
|
71
|
+
this.panel$.set(conn.panel)
|
|
72
|
+
// The ready frame seeds sessions/backends without firing their
|
|
73
|
+
// listeners — read the snapshots when the connection goes live.
|
|
74
|
+
if (state === 'live') {
|
|
75
|
+
this.sessions$.set(conn.sessions())
|
|
76
|
+
this.backends$.set(conn.backends())
|
|
77
|
+
this.subscribeLogs()
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
conn.onSessions((sessions) => {
|
|
82
|
+
this.sessions$.set(sessions)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
conn.onBackends((backends) => {
|
|
86
|
+
this.backends$.set(backends)
|
|
87
|
+
this.subscribeLogs()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
conn.subscribe((message) => {
|
|
91
|
+
if (
|
|
92
|
+
message.channel === 'xplat-motion' &&
|
|
93
|
+
message.from === 'app' &&
|
|
94
|
+
isMotionState(message.data)
|
|
95
|
+
) {
|
|
96
|
+
const rates = new Map(this.motionRates$.getSnapshot())
|
|
97
|
+
|
|
98
|
+
rates.set(message.session, message.data.rate)
|
|
99
|
+
this.motionRates$.set(rates)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (message.channel === 'xplat-actions' && isOutcome(message.data)) {
|
|
103
|
+
const actionId = this.requests.get(message.data.outcome.requestId)
|
|
104
|
+
|
|
105
|
+
if (actionId) {
|
|
106
|
+
this.runs.set(actionId, message.data.outcome)
|
|
107
|
+
this.runs$.set(new Map(this.runs))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (message.channel === 'xplat-logs' && isLogFrame(message.data)) {
|
|
112
|
+
this.logs.push(...message.data.records)
|
|
113
|
+
if (this.logs.length > LOG_KEEP) {
|
|
114
|
+
this.logs.splice(0, this.logs.length - LOG_KEEP)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.logs$.set([...this.logs])
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
this.connState$.set(conn.state)
|
|
122
|
+
this.panel$.set(conn.panel)
|
|
123
|
+
this.subscribeLogs()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The live panel connection — panel plugins talk to sessions/backends
|
|
127
|
+
* through it instead of opening their own. */
|
|
128
|
+
get connection(): DevtoolsConnection | null {
|
|
129
|
+
return this.conn
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
requestMotionRate(session: SessionSnapshot, rate?: number) {
|
|
133
|
+
return (
|
|
134
|
+
this.conn?.sendToApp('xplat-motion', session.sessionId, {
|
|
135
|
+
type: rate === undefined ? 'get' : 'set',
|
|
136
|
+
requestId: nextRequestId(++this.requestCounter),
|
|
137
|
+
rate,
|
|
138
|
+
}) ?? false
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
invoke(session: SessionSnapshot, actionId: string) {
|
|
143
|
+
const requestId = nextRequestId(++this.requestCounter)
|
|
144
|
+
|
|
145
|
+
this.requests.set(requestId, actionId)
|
|
146
|
+
this.runs.set(actionId, { status: 'running' })
|
|
147
|
+
this.runs$.set(new Map(this.runs))
|
|
148
|
+
this.conn?.sendToApp('xplat-actions', session.sessionId, {
|
|
149
|
+
type: 'invoke',
|
|
150
|
+
requestId,
|
|
151
|
+
actionId,
|
|
152
|
+
input: {},
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
clearLogs() {
|
|
157
|
+
this.logs = []
|
|
158
|
+
this.logs$.set([])
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
dispose() {
|
|
162
|
+
this.conn?.close()
|
|
163
|
+
this.conn = null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private subscribeLogs() {
|
|
167
|
+
const backend = this.backends$.getSnapshot().find((ref) => ref.channel === 'xplat-logs')
|
|
168
|
+
|
|
169
|
+
if (!backend || backend.targetId === this.logTarget$.getSnapshot() || !this.conn) {
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this.logTarget$.set(backend.targetId)
|
|
174
|
+
this.conn.sendToBackend('xplat-logs', backend.targetId, { type: 'subscribe' })
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function isOutcome(
|
|
179
|
+
data: unknown,
|
|
180
|
+
): data is { type: 'outcome'; outcome: ActionRun & { requestId: string } } {
|
|
181
|
+
return (
|
|
182
|
+
typeof data === 'object' &&
|
|
183
|
+
data !== null &&
|
|
184
|
+
(data as { type?: unknown }).type === 'outcome' &&
|
|
185
|
+
typeof (data as { outcome?: { requestId?: unknown } }).outcome?.requestId === 'string'
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function isLogFrame(data: unknown): data is { records: LogLine[] } {
|
|
190
|
+
return (
|
|
191
|
+
typeof data === 'object' &&
|
|
192
|
+
data !== null &&
|
|
193
|
+
Array.isArray((data as { records?: unknown }).records)
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function nextRequestId(counter: number): string {
|
|
198
|
+
const crypto = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto
|
|
199
|
+
|
|
200
|
+
return typeof crypto?.randomUUID === 'function'
|
|
201
|
+
? crypto.randomUUID()
|
|
202
|
+
: `req-${Date.now()}-${counter}`
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function isMotionState(value: unknown): value is { type: 'state'; rate: number } {
|
|
206
|
+
return (
|
|
207
|
+
!!value &&
|
|
208
|
+
typeof value === 'object' &&
|
|
209
|
+
'type' in value &&
|
|
210
|
+
value.type === 'state' &&
|
|
211
|
+
'rate' in value &&
|
|
212
|
+
typeof value.rate === 'number' &&
|
|
213
|
+
value.rate > 0 &&
|
|
214
|
+
value.rate <= 1
|
|
215
|
+
)
|
|
216
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/* Devtools panel chrome — the AppKit/web shared surface, ported from the
|
|
2
|
+
retired vanilla panel (app/panel.css) with class-only selectors and
|
|
3
|
+
flexbox-only right-alignment (mason has no auto margins). The dt-shell/
|
|
4
|
+
dt-header rules style the web-only picker wrapper in main.web.tsrx. */
|
|
5
|
+
html, body { margin: 0; height: 100%; }
|
|
6
|
+
body {
|
|
7
|
+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
|
|
8
|
+
font-size: 13px;
|
|
9
|
+
line-height: 18px;
|
|
10
|
+
color: #1a1a1a;
|
|
11
|
+
background: #ffffff;
|
|
12
|
+
}
|
|
13
|
+
#root { height: 100%; }
|
|
14
|
+
.dt-shell { display: flex; flex-direction: column; height: 100%; }
|
|
15
|
+
.dt-header {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: 8px;
|
|
19
|
+
padding: 0 10px;
|
|
20
|
+
height: 34px;
|
|
21
|
+
flex: none;
|
|
22
|
+
border-bottom: 1px solid #e3e3e3;
|
|
23
|
+
background: #fafafa;
|
|
24
|
+
}
|
|
25
|
+
.dt-brand { font-weight: 600; font-size: 12px; letter-spacing: 0.02em; color: #555555; }
|
|
26
|
+
.dt-select, .dt-refresh {
|
|
27
|
+
font: inherit;
|
|
28
|
+
height: 24px;
|
|
29
|
+
border: 1px solid #d4d4d4;
|
|
30
|
+
border-radius: 5px;
|
|
31
|
+
background: #ffffff;
|
|
32
|
+
color: inherit;
|
|
33
|
+
padding: 0 8px;
|
|
34
|
+
}
|
|
35
|
+
.dt-select { max-width: 420px; text-overflow: ellipsis; }
|
|
36
|
+
.dt-refresh { cursor: pointer; }
|
|
37
|
+
.dt-refresh:hover { background: #f0f0f0; }
|
|
38
|
+
.dt-root {
|
|
39
|
+
background-color: #ffffff;
|
|
40
|
+
color: #1a1a1a;
|
|
41
|
+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
|
|
42
|
+
font-size: 13px;
|
|
43
|
+
line-height: 18px;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
min-height: 0;
|
|
47
|
+
}
|
|
48
|
+
.dt-nav {
|
|
49
|
+
align-items: center;
|
|
50
|
+
padding: 0 8px;
|
|
51
|
+
height: 30px;
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
border-bottom-width: 1px;
|
|
54
|
+
border-bottom-color: #e3e3e3;
|
|
55
|
+
background-color: #fafafa;
|
|
56
|
+
}
|
|
57
|
+
.dt-tabs { flex: 1; align-items: center; gap: 2px; }
|
|
58
|
+
.dt-tab {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
height: 30px;
|
|
62
|
+
padding: 0 12px;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
border-bottom-width: 2px;
|
|
65
|
+
border-bottom-color: transparent;
|
|
66
|
+
}
|
|
67
|
+
.dt-tab-label { color: #666666; font-size: 13px; }
|
|
68
|
+
.dt-tab-active { border-bottom-color: #3b82f6; }
|
|
69
|
+
.dt-tab-active .dt-tab-label { color: #1a1a1a; font-weight: 500; }
|
|
70
|
+
.dt-badge {
|
|
71
|
+
font-size: 11px;
|
|
72
|
+
padding: 1px 7px;
|
|
73
|
+
border-radius: 9px;
|
|
74
|
+
background-color: #eeeeee;
|
|
75
|
+
color: #666666;
|
|
76
|
+
}
|
|
77
|
+
.dt-badge-live { background-color: #e2f3e4; color: #2c7a33; }
|
|
78
|
+
.dt-badge-connecting { background-color: #fdf3d7; color: #8a6d1a; }
|
|
79
|
+
.dt-badge-closed { background-color: #f6e2e2; color: #c92a2a; }
|
|
80
|
+
.dt-main { flex: 1; flex-basis: 0px; height: 0; min-height: 0; width: 100%; }
|
|
81
|
+
/* Plugin tabs own their own scrolling; the host just stretches them. */
|
|
82
|
+
.dt-plugin-host { flex: 1; flex-basis: 0px; height: 0; min-height: 0; width: 100%; }
|
|
83
|
+
.dt-plugin-host > * { flex: 1; min-height: 0; }
|
|
84
|
+
.dt-content { width: 100%; padding: 8px 10px 24px; flex-shrink: 0; }
|
|
85
|
+
.dt-empty { color: #999999; padding: 24px 4px; }
|
|
86
|
+
.dt-heading {
|
|
87
|
+
font-size: 11px;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
text-transform: uppercase;
|
|
90
|
+
letter-spacing: 0.6px;
|
|
91
|
+
color: #888888;
|
|
92
|
+
margin: 14px 0 4px;
|
|
93
|
+
}
|
|
94
|
+
.dt-heading-first { margin-top: 0; }
|
|
95
|
+
.dt-row {
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: 8px;
|
|
98
|
+
min-height: 28px;
|
|
99
|
+
padding: 2px 6px;
|
|
100
|
+
border-bottom-width: 1px;
|
|
101
|
+
border-bottom-color: #f1f1f1;
|
|
102
|
+
}
|
|
103
|
+
.dt-name { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
|
|
104
|
+
.dt-meta { color: #999999; font-size: 11px; }
|
|
105
|
+
.dt-right { flex: 1; justify-content: flex-end; gap: 6px; align-items: center; min-width: 0; }
|
|
106
|
+
.dt-chip {
|
|
107
|
+
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
108
|
+
font-size: 10px;
|
|
109
|
+
padding: 1px 6px;
|
|
110
|
+
border-radius: 8px;
|
|
111
|
+
background-color: #eef2ff;
|
|
112
|
+
color: #3b5bdb;
|
|
113
|
+
}
|
|
114
|
+
.dt-run { height: 20px; }
|
|
115
|
+
.dt-outcome {
|
|
116
|
+
padding-left: 14px;
|
|
117
|
+
}
|
|
118
|
+
.dt-outcome-status { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; }
|
|
119
|
+
.dt-outcome-failed .dt-outcome-status { color: #c92a2a; }
|
|
120
|
+
.dt-outcome-cancelled .dt-outcome-status { color: #8a6d1a; }
|
|
121
|
+
.dt-outcome-succeeded .dt-outcome-status { color: #2c7a33; }
|
|
122
|
+
.dt-pre {
|
|
123
|
+
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
124
|
+
font-size: 11px;
|
|
125
|
+
color: #444444;
|
|
126
|
+
margin: 2px 0 0;
|
|
127
|
+
white-space: pre-wrap;
|
|
128
|
+
}
|
|
129
|
+
.dt-toolbar { align-items: center; gap: 8px; margin-bottom: 6px; }
|
|
130
|
+
.dt-log-line {
|
|
131
|
+
align-items: baseline;
|
|
132
|
+
gap: 8px;
|
|
133
|
+
min-height: 22px;
|
|
134
|
+
padding: 1px 6px;
|
|
135
|
+
border-bottom-width: 1px;
|
|
136
|
+
border-bottom-color: #f6f6f6;
|
|
137
|
+
}
|
|
138
|
+
.dt-level {
|
|
139
|
+
width: 44px;
|
|
140
|
+
flex-shrink: 0;
|
|
141
|
+
color: #999999;
|
|
142
|
+
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
143
|
+
font-size: 11.5px;
|
|
144
|
+
}
|
|
145
|
+
.dt-log-warn .dt-level { color: #b07800; }
|
|
146
|
+
.dt-log-error .dt-level { color: #c92a2a; }
|
|
147
|
+
.dt-text {
|
|
148
|
+
flex: 1;
|
|
149
|
+
min-width: 0;
|
|
150
|
+
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
151
|
+
font-size: 11.5px;
|
|
152
|
+
white-space: pre-wrap;
|
|
153
|
+
}
|
|
154
|
+
/* AppKit labels keep their native wrapping; word-break is a browser rule. */
|
|
155
|
+
@platform web {
|
|
156
|
+
.dt-pre, .dt-text { word-break: break-all; }
|
|
157
|
+
}
|
|
158
|
+
.dt-at {
|
|
159
|
+
color: #bbbbbb;
|
|
160
|
+
font-size: 10px;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* Desktop shell — target header and server picker (Shell.macos.tsrx). */
|
|
166
|
+
.dt-target-bar {
|
|
167
|
+
align-items: center;
|
|
168
|
+
gap: 8px;
|
|
169
|
+
padding: 0 8px;
|
|
170
|
+
height: 30px;
|
|
171
|
+
flex-shrink: 0;
|
|
172
|
+
border-bottom-width: 1px;
|
|
173
|
+
border-bottom-color: #e3e3e3;
|
|
174
|
+
background-color: #fafafa;
|
|
175
|
+
}
|
|
176
|
+
.dt-target-name { font-weight: 600; font-size: 12px; }
|
|
177
|
+
.dt-targeted { flex: 1; min-height: 0; width: 100%; }
|
|
178
|
+
.dt-pick-row {
|
|
179
|
+
padding: 8px 10px;
|
|
180
|
+
border-bottom-width: 1px;
|
|
181
|
+
border-bottom-color: #f1f1f1;
|
|
182
|
+
}
|
|
183
|
+
.dt-pick-name { font-weight: 600; font-size: 13px; }
|
|
184
|
+
.dt-pick-path { color: #999999; font-size: 11px; }
|
|
185
|
+
|
|
186
|
+
.dt-session-settings {
|
|
187
|
+
padding: 12px;
|
|
188
|
+
gap: 8px;
|
|
189
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Panel plugin contract — a package opts in with the `octaneXplat.devtoolsPanel`
|
|
2
|
+
// field in its package.json; the desktop app's Vite config discovers the
|
|
3
|
+
// module through `devtoolsPanels` (src/host/panels.ts) and passes the default
|
|
4
|
+
// exports to App via `plugins`. Each plugin renders inside the shared shell
|
|
5
|
+
// and talks to sessions/backends through the App's live connection.
|
|
6
|
+
import type { DevtoolsConnection } from '../client.ts'
|
|
7
|
+
|
|
8
|
+
export interface DevtoolsPanelPluginProps {
|
|
9
|
+
/** The App's live connectDevtools connection to the targeted dev server. */
|
|
10
|
+
connection: DevtoolsConnection
|
|
11
|
+
/** Connection state, kept in props so a plugin does not re-subscribe. */
|
|
12
|
+
state: 'connecting' | 'live' | 'closed'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DevtoolsPanelPlugin {
|
|
16
|
+
/** `/^[a-z][a-z0-9-]{0,31}$/` — the tab id; built-in ids are reserved. */
|
|
17
|
+
id: string
|
|
18
|
+
/** Tab label. */
|
|
19
|
+
title: string
|
|
20
|
+
/** The tab's Octane component; it owns its own scrolling. */
|
|
21
|
+
Panel: (props: DevtoolsPanelPluginProps) => unknown
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const DEVTOOLS_PANEL_ID = /^[a-z][a-z0-9-]{0,31}$/
|
|
25
|
+
export const DEVTOOLS_BUILTIN_TABS = new Set(['sessions', 'actions', 'logs'])
|
|
26
|
+
|
|
27
|
+
export function defineDevtoolsPanel(plugin: DevtoolsPanelPlugin): DevtoolsPanelPlugin {
|
|
28
|
+
if (!DEVTOOLS_PANEL_ID.test(plugin.id)) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`[devtools] invalid panel plugin id "${plugin.id}" — expected ${DEVTOOLS_PANEL_ID.source}`,
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (DEVTOOLS_BUILTIN_TABS.has(plugin.id)) {
|
|
35
|
+
throw new Error(`[devtools] panel plugin id "${plugin.id}" is a built-in tab id`)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return plugin
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Defensive filter for plugin lists passed straight to App — invalid or
|
|
42
|
+
* duplicate ids are dropped with one console.error each. */
|
|
43
|
+
export function resolveDevtoolsPanelPlugins(
|
|
44
|
+
plugins: readonly DevtoolsPanelPlugin[],
|
|
45
|
+
): DevtoolsPanelPlugin[] {
|
|
46
|
+
const seen = new Set<string>(DEVTOOLS_BUILTIN_TABS)
|
|
47
|
+
const out: DevtoolsPanelPlugin[] = []
|
|
48
|
+
|
|
49
|
+
for (const plugin of plugins) {
|
|
50
|
+
if (
|
|
51
|
+
!plugin ||
|
|
52
|
+
!DEVTOOLS_PANEL_ID.test(plugin.id) ||
|
|
53
|
+
DEVTOOLS_BUILTIN_TABS.has(plugin.id) ||
|
|
54
|
+
seen.has(plugin.id)
|
|
55
|
+
) {
|
|
56
|
+
console.error(`[devtools] skipping invalid or duplicate panel plugin id "${plugin?.id}"`)
|
|
57
|
+
continue
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
seen.add(plugin.id)
|
|
61
|
+
out.push(plugin)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return out
|
|
65
|
+
}
|
package/src/record.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Host-neutral discovery-record validation, shared by the Node records leaf
|
|
2
|
+
// (src/host/records.ts) and the macOS Foundation leaf
|
|
3
|
+
// (src/macos/servers.macos.ts). Mirrors dev_server_record.go: records live
|
|
4
|
+
// under the native history cache in dev-servers-v1/<app-key>/server.json, one
|
|
5
|
+
// per app, each carrying the panel's devtoolsToken. The RPC token is never
|
|
6
|
+
// returned to the panel.
|
|
7
|
+
|
|
8
|
+
export interface ListedDevtoolsServer {
|
|
9
|
+
/** app-key directory the record was published under. */
|
|
10
|
+
key: string
|
|
11
|
+
appRoot: string
|
|
12
|
+
endpoint: string
|
|
13
|
+
instanceId: string
|
|
14
|
+
devtoolsToken: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ENDPOINT = /^http:\/\/127\.0\.0\.1:\d{1,5}\/rpc$/
|
|
18
|
+
|
|
19
|
+
// Light validation only — connectDevtools enforces the full contract before
|
|
20
|
+
// opening a socket. Records that fail here are omitted, not fatal.
|
|
21
|
+
// `isAbsolutePath` is the host's own absolute-path check (node:path on Node,
|
|
22
|
+
// a POSIX leading-slash check on the JSC host).
|
|
23
|
+
export function parseDevtoolsServerRecord(
|
|
24
|
+
key: string,
|
|
25
|
+
data: string,
|
|
26
|
+
isAbsolutePath: (path: string) => boolean,
|
|
27
|
+
): ListedDevtoolsServer | null {
|
|
28
|
+
let record: unknown
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
record = JSON.parse(data)
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
typeof record !== 'object' ||
|
|
38
|
+
record === null ||
|
|
39
|
+
(record as { protocol?: unknown }).protocol !== 'octane-dev-server' ||
|
|
40
|
+
(record as { version?: unknown }).version !== 1
|
|
41
|
+
) {
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { appRoot, endpoint, instanceId, devtoolsToken } = record as {
|
|
46
|
+
appRoot?: unknown
|
|
47
|
+
endpoint?: unknown
|
|
48
|
+
instanceId?: unknown
|
|
49
|
+
devtoolsToken?: unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
typeof appRoot !== 'string' ||
|
|
54
|
+
!isAbsolutePath(appRoot) ||
|
|
55
|
+
typeof endpoint !== 'string' ||
|
|
56
|
+
!ENDPOINT.test(endpoint) ||
|
|
57
|
+
typeof instanceId !== 'string' ||
|
|
58
|
+
!/^[a-f0-9]{32}$/.test(instanceId) ||
|
|
59
|
+
typeof devtoolsToken !== 'string' ||
|
|
60
|
+
!/^[a-f0-9]{64}$/.test(devtoolsToken)
|
|
61
|
+
) {
|
|
62
|
+
return null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return { key, appRoot, endpoint, instanceId, devtoolsToken }
|
|
66
|
+
}
|