@octane-xplat/devtools 0.0.0-nightly.g1b95ef7 → 0.0.0-stage
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 +2 -4
- package/package.json +5 -87
- package/dist/app.d.ts +0 -28
- package/dist/app.js +0 -66
- package/dist/backend.d.ts +0 -31
- package/dist/backend.js +0 -182
- package/dist/client.d.ts +0 -49
- package/dist/client.js +0 -168
- package/dist/host/desktop.d.ts +0 -15
- package/dist/host/desktop.js +0 -133
- package/dist/host/panels.d.ts +0 -14
- package/dist/host/panels.js +0 -156
- package/dist/host/records.d.ts +0 -5
- package/dist/host/records.js +0 -46
- package/dist/host/server.d.ts +0 -8
- package/dist/host/server.js +0 -67
- package/dist/host/web.d.ts +0 -5
- package/dist/host/web.js +0 -74
- package/dist/macos/index.macos.d.ts +0 -3
- package/dist/macos/index.macos.js +0 -5
- package/dist/macos/servers.macos.d.ts +0 -4
- package/dist/macos/servers.macos.js +0 -57
- package/dist/macos/socket.macos.d.ts +0 -2
- package/dist/macos/socket.macos.js +0 -152
- package/dist/macos/ws-frames.d.ts +0 -24
- package/dist/macos/ws-frames.js +0 -205
- package/dist/node.d.ts +0 -12
- package/dist/node.js +0 -51
- package/dist/record.d.ts +0 -9
- package/dist/record.js +0 -38
- package/dist/types.d.ts +0 -128
- package/dist/types.js +0 -25
- package/src/app.ts +0 -105
- package/src/assets.d.ts +0 -2
- package/src/backend.ts +0 -278
- package/src/client.ts +0 -248
- package/src/desktop/Shell.macos.tsrx +0 -158
- package/src/desktop/Shell.ts +0 -16
- package/src/desktop/index.macos.ts +0 -7
- package/src/desktop/main.macos.ts +0 -130
- package/src/desktop/panels.d.ts +0 -10
- package/src/desktop/target.ts +0 -34
- package/src/host/desktop.ts +0 -176
- package/src/host/panels.ts +0 -193
- package/src/host/records.ts +0 -62
- package/src/host/server.ts +0 -92
- package/src/host/web.ts +0 -68
- package/src/macos/index.macos.ts +0 -7
- package/src/macos/servers.macos.ts +0 -83
- package/src/macos/socket.macos.ts +0 -218
- package/src/macos/ws-frames.ts +0 -249
- package/src/node.ts +0 -60
- package/src/panel/App.tsrx +0 -288
- package/src/panel/index.html +0 -12
- package/src/panel/index.ts +0 -24
- package/src/panel/main.tsrx +0 -2
- package/src/panel/main.web.tsrx +0 -89
- package/src/panel/model.ts +0 -216
- package/src/panel/panel.css +0 -189
- package/src/panel/plugin.ts +0 -65
- package/src/panel/styles.ts +0 -5
- package/src/panel/tsconfig.browser.json +0 -9
- package/src/record.ts +0 -66
- package/src/types.ts +0 -129
package/src/panel/panel.css
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
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
|
-
}
|
package/src/panel/plugin.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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/panel/styles.ts
DELETED
package/src/record.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// Shared wire types for the xplat dev hub's devtools channels. The Go hub
|
|
2
|
-
// routes opaque per-channel JSON between app sessions (/app), per-target Node
|
|
3
|
-
// backends (/backend) and devtools panels (/devtools); these are the frame
|
|
4
|
-
// shapes the three peers exchange.
|
|
5
|
-
|
|
6
|
-
/** A declared dev action as the app's registry announces it. */
|
|
7
|
-
export interface DevActionRef {
|
|
8
|
-
id: string
|
|
9
|
-
title?: string
|
|
10
|
-
description?: string
|
|
11
|
-
input?: { fields?: Record<string, unknown> } & Record<string, unknown>
|
|
12
|
-
result?: Record<string, unknown>
|
|
13
|
-
effects?: Record<string, unknown>
|
|
14
|
-
availability?: {
|
|
15
|
-
platforms?: string[]
|
|
16
|
-
readyWhen?: string
|
|
17
|
-
route?: { url?: string; fromInput?: boolean }
|
|
18
|
-
ready?: boolean
|
|
19
|
-
reason?: string
|
|
20
|
-
}
|
|
21
|
-
execution?: { timeoutMs?: number; cancellable?: boolean } & Record<string, unknown>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** A connected app session as the hub reports it in `ready`/`sessions`. */
|
|
25
|
-
export interface SessionSnapshot {
|
|
26
|
-
sessionId: string
|
|
27
|
-
targetId: string
|
|
28
|
-
appInstanceId: string
|
|
29
|
-
platform: string
|
|
30
|
-
appLabel?: string
|
|
31
|
-
registryRevision: number
|
|
32
|
-
state: 'ready' | 'disconnected' | string
|
|
33
|
-
ownership: string
|
|
34
|
-
origin: string
|
|
35
|
-
readiness: string
|
|
36
|
-
connectedAt: string
|
|
37
|
-
disconnectedAt: string
|
|
38
|
-
inspection?: unknown
|
|
39
|
-
actions?: DevActionRef[]
|
|
40
|
-
channels: { id: string; version: number }[]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** A routing failure reported to a frame's sender (never a close). */
|
|
44
|
-
export interface ChannelError {
|
|
45
|
-
type: 'channel-error'
|
|
46
|
-
code: 'oversize' | 'undeclared_channel' | 'no_backend' | 'no_session' | 'invalid_target'
|
|
47
|
-
channel?: string
|
|
48
|
-
detail: string
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** A connected backend as the hub reports it in `ready`/`backends`. */
|
|
52
|
-
export interface BackendRef {
|
|
53
|
-
channel: string
|
|
54
|
-
targetId: string
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface ReadyFrame {
|
|
58
|
-
type: 'ready'
|
|
59
|
-
panel?: string
|
|
60
|
-
sessions?: SessionSnapshot[]
|
|
61
|
-
backends?: BackendRef[]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface SessionsFrame {
|
|
65
|
-
type: 'sessions'
|
|
66
|
-
sessions?: SessionSnapshot[]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface BackendsFrame {
|
|
70
|
-
type: 'backends'
|
|
71
|
-
backends?: BackendRef[]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Frames the hub sends to a `/backend` connection. */
|
|
75
|
-
export type BackendInboundFrame =
|
|
76
|
-
| ReadyFrame
|
|
77
|
-
| SessionsFrame
|
|
78
|
-
| { type: 'channel'; channel?: string; from: 'app'; session: string; data: unknown }
|
|
79
|
-
| { type: 'channel'; channel?: string; from: 'panel'; panel: string; data: unknown }
|
|
80
|
-
| ChannelError
|
|
81
|
-
|
|
82
|
-
/** Frames the hub sends to a `/devtools` panel connection. */
|
|
83
|
-
export type PanelInboundFrame =
|
|
84
|
-
| ReadyFrame
|
|
85
|
-
| SessionsFrame
|
|
86
|
-
| BackendsFrame
|
|
87
|
-
| { type: 'channel'; channel: string; from: 'app'; session: string; data: unknown }
|
|
88
|
-
| { type: 'channel'; channel: string; from: 'backend'; targetId: string; data: unknown }
|
|
89
|
-
| ChannelError
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Parse one hub frame at the JSON boundary. The `as` here is the single
|
|
93
|
-
* documented assertion point: frame field validation happens at each call
|
|
94
|
-
* site on the narrowed `type` union, so untrusted input never needs a cast
|
|
95
|
-
* anywhere else.
|
|
96
|
-
*/
|
|
97
|
-
export function parseHubFrame(text: string): BackendInboundFrame | PanelInboundFrame | undefined {
|
|
98
|
-
try {
|
|
99
|
-
const frame = JSON.parse(text) as { type?: unknown }
|
|
100
|
-
|
|
101
|
-
return typeof frame?.type === 'string'
|
|
102
|
-
? (frame as BackendInboundFrame | PanelInboundFrame)
|
|
103
|
-
: undefined
|
|
104
|
-
} catch {
|
|
105
|
-
return undefined
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Structural WebSocket contract shared by Node, browser and JSC hosts. */
|
|
110
|
-
export interface DevSocket {
|
|
111
|
-
readyState: number
|
|
112
|
-
onopen: (() => void) | null
|
|
113
|
-
onmessage: ((event: { data: unknown }) => void) | null
|
|
114
|
-
onerror: (() => void) | null
|
|
115
|
-
onclose: ((event: { code: number; reason: string }) => void) | null
|
|
116
|
-
send(data: string): void
|
|
117
|
-
close(): void
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** Named host environment for the global WebSocket constructor. */
|
|
121
|
-
export interface DevGlobalWebSocket {
|
|
122
|
-
WebSocket?: new (url: string) => DevSocket
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function devSocket(url: string): DevSocket | undefined {
|
|
126
|
-
const Constructor = (globalThis as DevGlobalWebSocket).WebSocket
|
|
127
|
-
|
|
128
|
-
return Constructor ? new Constructor(url) : undefined
|
|
129
|
-
}
|