@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
package/src/types.ts ADDED
@@ -0,0 +1,129 @@
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
+ }