@dimina-kit/devtools 0.3.2-dev.20260601115343 → 0.3.2-dev.20260610114009

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 (189) hide show
  1. package/README.md +49 -59
  2. package/dist/main/api.d.ts +1 -2
  3. package/dist/main/api.js +5 -1
  4. package/dist/main/app/app.d.ts +15 -5
  5. package/dist/main/app/app.js +249 -122
  6. package/dist/main/app/bootstrap.d.ts +16 -0
  7. package/dist/main/app/bootstrap.js +20 -0
  8. package/dist/main/app/launch.d.ts +8 -4
  9. package/dist/main/app/launch.js +9 -4
  10. package/dist/main/index.bundle.js +6071 -1863
  11. package/dist/main/index.js +9 -1
  12. package/dist/main/ipc/app.d.ts +1 -1
  13. package/dist/main/ipc/bridge-router.d.ts +61 -0
  14. package/dist/main/ipc/bridge-router.js +1333 -0
  15. package/dist/main/ipc/panels.d.ts +1 -1
  16. package/dist/main/ipc/panels.js +6 -2
  17. package/dist/main/ipc/popover.d.ts +1 -1
  18. package/dist/main/ipc/project-fs.d.ts +1 -1
  19. package/dist/main/ipc/projects.d.ts +1 -1
  20. package/dist/main/ipc/session.d.ts +1 -1
  21. package/dist/main/ipc/settings.d.ts +1 -1
  22. package/dist/main/ipc/simulator-module.d.ts +6 -0
  23. package/dist/main/ipc/simulator-module.js +9 -1
  24. package/dist/main/ipc/simulator.d.ts +2 -2
  25. package/dist/main/ipc/simulator.js +29 -5
  26. package/dist/main/ipc/toolbar.d.ts +1 -1
  27. package/dist/main/ipc/views.d.ts +1 -1
  28. package/dist/main/ipc/views.js +40 -2
  29. package/dist/main/runtime/devtools-backend.d.ts +17 -0
  30. package/dist/main/runtime/devtools-backend.js +49 -0
  31. package/dist/main/runtime/miniapp-runtime.d.ts +39 -0
  32. package/dist/main/runtime/miniapp-runtime.js +17 -0
  33. package/dist/main/services/automation/exec.d.ts +27 -2
  34. package/dist/main/services/automation/exec.js +37 -3
  35. package/dist/main/services/automation/handlers/app.js +127 -11
  36. package/dist/main/services/automation/handlers/page.js +36 -19
  37. package/dist/main/services/automation/index.js +40 -13
  38. package/dist/main/services/automation/wait-active-page.d.ts +56 -0
  39. package/dist/main/services/automation/wait-active-page.js +71 -0
  40. package/dist/main/services/console-forward/index.d.ts +36 -0
  41. package/dist/main/services/console-forward/index.js +81 -0
  42. package/dist/main/services/dimina-resource-server.d.ts +7 -0
  43. package/dist/main/services/dimina-resource-server.js +99 -0
  44. package/dist/main/services/elements-forward/index.d.ts +66 -0
  45. package/dist/main/services/elements-forward/index.js +583 -0
  46. package/dist/main/services/layout/index.d.ts +22 -0
  47. package/dist/main/services/layout/index.js +25 -0
  48. package/dist/main/services/mcp/index.d.ts +1 -0
  49. package/dist/main/services/mcp/index.js +3 -0
  50. package/dist/main/services/mcp/server.d.ts +1 -1
  51. package/dist/main/services/mcp/server.js +1 -1
  52. package/dist/main/services/mcp/target-manager.d.ts +35 -0
  53. package/dist/main/services/mcp/target-manager.js +63 -1
  54. package/dist/main/services/mcp/tools/context-tools.js +15 -1
  55. package/dist/main/services/module.d.ts +1 -1
  56. package/dist/main/services/network-forward/index.d.ts +190 -0
  57. package/dist/main/services/network-forward/index.js +765 -0
  58. package/dist/main/services/notifications/renderer-notifier.d.ts +11 -0
  59. package/dist/main/services/notifications/renderer-notifier.js +7 -1
  60. package/dist/main/services/render-inspect/index.d.ts +41 -0
  61. package/dist/main/services/render-inspect/index.js +88 -0
  62. package/dist/main/services/safe-area/index.d.ts +17 -0
  63. package/dist/main/services/safe-area/index.js +59 -0
  64. package/dist/main/services/service-host-pool/pool.d.ts +197 -0
  65. package/dist/main/services/service-host-pool/pool.js +364 -0
  66. package/dist/main/services/simulator/custom-apis.d.ts +34 -0
  67. package/dist/main/services/simulator/custom-apis.js +22 -0
  68. package/dist/main/services/simulator-appdata/index.d.ts +35 -0
  69. package/dist/main/services/simulator-appdata/index.js +71 -0
  70. package/dist/main/services/simulator-current-page/index.d.ts +24 -0
  71. package/dist/main/services/simulator-current-page/index.js +19 -0
  72. package/dist/main/services/simulator-storage/index.d.ts +37 -2
  73. package/dist/main/services/simulator-storage/index.js +209 -32
  74. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +40 -0
  75. package/dist/main/services/simulator-storage/service-storage-ops.js +67 -0
  76. package/dist/main/services/simulator-temp-files/index.d.ts +1 -1
  77. package/dist/main/services/simulator-temp-files/index.js +39 -17
  78. package/dist/main/services/simulator-wxml/index.d.ts +29 -0
  79. package/dist/main/services/simulator-wxml/index.js +28 -0
  80. package/dist/main/services/toolbar/toolbar-store.d.ts +3 -3
  81. package/dist/main/services/toolbar/toolbar-store.js +1 -18
  82. package/dist/main/services/views/devtools-tabs.d.ts +47 -0
  83. package/dist/main/services/views/devtools-tabs.js +95 -0
  84. package/dist/main/services/views/miniapp-partition.d.ts +80 -0
  85. package/dist/main/services/views/miniapp-partition.js +138 -0
  86. package/dist/main/services/views/simulator-session-policy.d.ts +28 -0
  87. package/dist/main/services/views/simulator-session-policy.js +82 -0
  88. package/dist/main/services/views/view-manager.d.ts +125 -0
  89. package/dist/main/services/views/view-manager.js +852 -4
  90. package/dist/main/services/workbench-context.d.ts +67 -7
  91. package/dist/main/services/workbench-context.js +6 -1
  92. package/dist/main/services/workspace/workspace-service.js +7 -13
  93. package/dist/main/utils/ipc-registry.d.ts +1 -1
  94. package/dist/main/utils/ipc-registry.js +21 -4
  95. package/dist/main/utils/paths.d.ts +15 -0
  96. package/dist/main/utils/paths.js +19 -0
  97. package/dist/main/utils/sender-policy.d.ts +9 -3
  98. package/dist/main/utils/sender-policy.js +18 -4
  99. package/dist/main/utils/theme.d.ts +1 -1
  100. package/dist/main/utils/theme.js +1 -1
  101. package/dist/main/windows/main-window/create.d.ts +0 -6
  102. package/dist/main/windows/main-window/create.js +6 -80
  103. package/dist/main/windows/main-window/events.d.ts +1 -1
  104. package/dist/main/windows/main-window/events.js +1 -1
  105. package/dist/main/windows/service-host-window/create.d.ts +67 -0
  106. package/dist/main/windows/service-host-window/create.js +138 -0
  107. package/dist/native-host/common/common.js +368 -0
  108. package/dist/native-host/container/pageFrame.css +1 -0
  109. package/dist/native-host/render/render.js +9334 -0
  110. package/dist/native-host/service/service.js +6 -0
  111. package/dist/preload/index.d.ts +2 -0
  112. package/dist/preload/index.js +6 -0
  113. package/dist/preload/instrumentation/app-data.d.ts +18 -20
  114. package/dist/preload/instrumentation/app-data.js +23 -160
  115. package/dist/preload/instrumentation/wxml-extract.d.ts +1 -1
  116. package/dist/preload/instrumentation/wxml-extract.js +1 -1
  117. package/dist/preload/runtime/bridge.d.ts +3 -8
  118. package/dist/preload/runtime/bridge.js +2 -32
  119. package/dist/preload/runtime/custom-apis.js +20 -17
  120. package/dist/preload/runtime/host-toolbar-advertiser.d.ts +27 -0
  121. package/dist/preload/runtime/host-toolbar-advertiser.js +55 -0
  122. package/dist/preload/runtime/main-api-runner.d.ts +9 -0
  123. package/dist/preload/runtime/main-api-runner.js +85 -0
  124. package/dist/preload/runtime/native-host.d.ts +43 -0
  125. package/dist/preload/runtime/native-host.js +83 -0
  126. package/dist/preload/shared/expose.d.ts +10 -5
  127. package/dist/preload/shared/expose.js +30 -12
  128. package/dist/preload/shared/sid-registry.d.ts +11 -0
  129. package/dist/preload/shared/sid-registry.js +38 -0
  130. package/dist/preload/windows/host-toolbar.cjs +161 -0
  131. package/dist/preload/windows/host-toolbar.cjs.map +7 -0
  132. package/dist/preload/windows/host-toolbar.d.ts +2 -0
  133. package/dist/preload/windows/host-toolbar.js +12 -0
  134. package/dist/preload/windows/main.cjs +1935 -0
  135. package/dist/preload/windows/main.cjs.map +4 -4
  136. package/dist/preload/windows/simulator.cjs +925 -0
  137. package/dist/preload/windows/simulator.cjs.map +7 -0
  138. package/dist/preload/windows/simulator.js +244 -574
  139. package/dist/render-host/pageFrame.html +29 -0
  140. package/dist/render-host/preload.cjs +154 -0
  141. package/dist/render-host/render-inspect.js +295 -0
  142. package/dist/renderer/assets/index-CcJKzatF.js +50 -0
  143. package/dist/renderer/assets/{input-CCYS8Ave.js → input-QGx6FFX1.js} +2 -2
  144. package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +1 -0
  145. package/dist/renderer/assets/{ipc-transport-Bn4KXvhu.js → ipc-transport-DvZvwK-Z.js} +2 -2
  146. package/dist/renderer/assets/{popover-CH4rwpdt.js → popover-BOH1If1J.js} +2 -2
  147. package/dist/renderer/assets/select-C7JQ8G5N.js +2 -0
  148. package/dist/renderer/assets/{settings-CMTB-t0x.js → settings-DpAbTJyF.js} +2 -2
  149. package/dist/renderer/assets/{settings-api-Csdngf9Z.js → settings-api-RD2IZF53.js} +2 -2
  150. package/dist/renderer/assets/{workbenchSettings-CODFCzOg.js → workbenchSettings-CNJX4Qna.js} +2 -2
  151. package/dist/renderer/entries/main/index.html +5 -5
  152. package/dist/renderer/entries/popover/index.html +5 -5
  153. package/dist/renderer/entries/settings/index.html +5 -5
  154. package/dist/renderer/entries/workbench-settings/index.html +4 -4
  155. package/dist/service-host/preload.cjs +254 -0
  156. package/dist/service-host/service.html +10 -0
  157. package/dist/service-host/sourcemap-rewrite.cjs +58 -0
  158. package/dist/service-host/sync-api-patch.js +20 -0
  159. package/dist/service-host/sync-impls/menu-button-geometry.js +8 -0
  160. package/dist/service-host/sync-impls/menu-button.js +16 -0
  161. package/dist/service-host/sync-impls/storage.js +50 -0
  162. package/dist/service-host/sync-impls/system-info.js +54 -0
  163. package/dist/shared/appdata-accumulator.d.ts +95 -0
  164. package/dist/shared/appdata-accumulator.js +213 -0
  165. package/dist/shared/bridge-channels.d.ts +378 -0
  166. package/dist/shared/bridge-channels.js +81 -0
  167. package/dist/shared/ipc-channels.d.ts +84 -1
  168. package/dist/shared/ipc-channels.js +90 -10
  169. package/dist/shared/ipc-schemas.d.ts +59 -2
  170. package/dist/shared/ipc-schemas.js +64 -3
  171. package/dist/shared/open-in-editor.d.ts +71 -0
  172. package/dist/shared/open-in-editor.js +138 -0
  173. package/dist/shared/simulator-api-metadata.d.ts +21 -0
  174. package/dist/shared/simulator-api-metadata.js +23 -0
  175. package/dist/shared/types.d.ts +2 -39
  176. package/dist/simulator/assets/device-shell-DsdcNEkt.css +1 -0
  177. package/dist/simulator/assets/device-shell-fH2cI-3q.js +2 -0
  178. package/dist/simulator/assets/jsx-runtime-P6ZegaOf.js +2 -0
  179. package/dist/simulator/assets/simulator-DHylZf9Z.js +10 -0
  180. package/dist/simulator/assets/simulator-mini-app-BDNu5n26.js +2 -0
  181. package/dist/simulator/device-shell/menu-button-geometry.js +8 -0
  182. package/dist/simulator/simulator.html +2 -112
  183. package/package.json +12 -12
  184. package/dist/main/utils/disposable.d.ts +0 -18
  185. package/dist/main/utils/disposable.js +0 -67
  186. package/dist/renderer/assets/index-BDMxXUfn.js +0 -50
  187. package/dist/renderer/assets/ipc-transport-Cu7tubyg.css +0 -1
  188. package/dist/renderer/assets/select-Ct4-sijm.js +0 -2
  189. package/dist/simulator/assets/simulator-B4e3c6_O.js +0 -9
@@ -6,11 +6,53 @@
6
6
  * requires a single edit.
7
7
  */
8
8
  export declare const SimulatorChannel: {
9
- readonly Attach: "simulator:attach";
9
+ readonly AttachNative: "simulator:attach-native";
10
+ readonly SetNativeBounds: "simulator:set-native-bounds";
11
+ readonly SetDeviceInfo: "simulator:set-device-info";
10
12
  readonly Detach: "simulator:detach";
11
13
  readonly Resize: "simulator:resize";
12
14
  readonly SetVisible: "simulator:setVisible";
13
15
  readonly Console: "simulator:console";
16
+ readonly CurrentPage: "simulator:current-page";
17
+ };
18
+ /** iPhone bezel cutout family driving the device-shell notch visual. */
19
+ export type NotchType = 'none' | 'notch' | 'dynamic-island';
20
+ /** Per-device safe-area insets in CSS px (portrait). */
21
+ export interface SafeAreaInsets {
22
+ top: number;
23
+ right: number;
24
+ bottom: number;
25
+ left: number;
26
+ }
27
+ /**
28
+ * Logical device metrics pushed by the renderer device dropdown under
29
+ * native-host (`SimulatorChannel.SetDeviceInfo`). Mirrors a row of the renderer
30
+ * `DEVICES` table; main maps it onto a `HostEnvSnapshot` for the service-host
31
+ * window so `wx.getSystemInfoSync()` reflects the selected device, relays it to
32
+ * the simulator WCV (DeviceShell: bezel size + status bar + notch), and drives
33
+ * the CSS `env(safe-area-inset-*)` override on render-host guests.
34
+ */
35
+ export interface NativeDeviceInfo {
36
+ brand: string;
37
+ model: string;
38
+ system: string;
39
+ platform: string;
40
+ pixelRatio: number;
41
+ screenWidth: number;
42
+ screenHeight: number;
43
+ statusBarHeight: number;
44
+ safeAreaBottom: number;
45
+ notchType: NotchType;
46
+ safeAreaInsets: SafeAreaInsets;
47
+ }
48
+ export declare const ServiceHostChannel: {
49
+ /**
50
+ * NATIVE-HOST ONLY. Live-update the service-host window's host-env snapshot
51
+ * (device metrics) so subsequent `wx.getSystemInfoSync()` reflects a device
52
+ * change without a relaunch. The service-host preload mutates
53
+ * `__diminaSpawnContext.hostEnvSnapshot` in place (see `service-host/preload.cjs`).
54
+ */
55
+ readonly HostEnvUpdate: "service-host:host-env:update";
14
56
  };
15
57
  export declare const SimulatorCustomApiChannel: {
16
58
  readonly List: "simulator:custom-apis:list";
@@ -58,6 +100,17 @@ export declare const SimulatorElementChannel: {
58
100
  readonly Inspect: "simulator:element:inspect";
59
101
  readonly Clear: "simulator:element:clear";
60
102
  };
103
+ export declare const WorkbenchRuntimeChannel: {
104
+ readonly GetNativeHost: "workbench:runtime:native-host";
105
+ };
106
+ export declare const SimulatorWxmlChannel: {
107
+ readonly GetSnapshot: "simulator:wxml:snapshot";
108
+ readonly Event: "simulator:wxml:event";
109
+ };
110
+ export declare const SimulatorAppDataChannel: {
111
+ readonly GetSnapshot: "simulator:appdata:snapshot";
112
+ readonly Event: "simulator:appdata:event";
113
+ };
61
114
  export interface ElementInspection {
62
115
  sid: string;
63
116
  rect: {
@@ -110,6 +163,19 @@ export declare const ProjectFsChannel: {
110
163
  readonly WriteFileSync: "project:fs:writeFileSync";
111
164
  readonly ListFiles: "project:fs:listFiles";
112
165
  };
166
+ export declare const EditorChannel: {
167
+ /** main → renderer: open `path` (project-relative POSIX) at `line`/`column`. */
168
+ readonly OpenFile: "editor:openFile";
169
+ };
170
+ /** Payload for `editor:openFile`. `line`/`column` are 1-based for Monaco. */
171
+ export interface EditorOpenFilePayload {
172
+ /** Project-relative POSIX path (the same key Monaco opens files by). */
173
+ path: string;
174
+ /** 1-based line to reveal; omitted/<=0 means open without moving the cursor. */
175
+ line?: number;
176
+ /** 1-based column to reveal; defaults to 1 when a line is given. */
177
+ column?: number;
178
+ }
113
179
  export declare const ProjectsChannel: {
114
180
  readonly List: "projects:list";
115
181
  readonly Add: "projects:add";
@@ -140,6 +206,23 @@ export declare const PanelChannel: {
140
206
  export declare const ViewChannel: {
141
207
  /** Update the simulator DevTools view's bounds (or hide if w/h = 0). */
142
208
  readonly SimulatorDevtoolsBounds: "view:simulator:devtools-bounds";
209
+ /**
210
+ * Host-controllable toolbar WebContentsView (sits ABOVE the devtools built-in
211
+ * header). Forward anchor: the main renderer reports the toolbar placeholder's
212
+ * bounds (or w/h=0 to hide). invoke.
213
+ */
214
+ readonly HostToolbarBounds: "view:host-toolbar:bounds";
215
+ /**
216
+ * Reverse size-advertiser: the host-toolbar WCV's OWN renderer advertises its
217
+ * intrinsic content height so main reserves exactly that much. Payload
218
+ * `{ axis: 'block', extent }`. fire-and-forget (send), NOT invoke.
219
+ */
220
+ readonly HostToolbarAdvertiseHeight: "view:host-toolbar:advertise-height";
221
+ /**
222
+ * main → main-window renderer: push the reserved host-toolbar height so the
223
+ * renderer placeholder div resizes (closing the dynamic-height loop).
224
+ */
225
+ readonly HostToolbarHeightChanged: "view:host-toolbar:height-changed";
143
226
  };
144
227
  export interface ViewBounds {
145
228
  x: number;
@@ -7,29 +7,58 @@
7
7
  */
8
8
  // ── Simulator (preload → host / renderer ↔ main) ────────────────────────
9
9
  export const SimulatorChannel = {
10
- Attach: 'simulator:attach',
10
+ // Ask main to create the simulator as a top-level WebContentsView (so nested
11
+ // render-host <webview>s can attach). Native-host is the sole runtime.
12
+ AttachNative: 'simulator:attach-native',
13
+ // Renderer reports the device-bezel inner-screen rect (CSS px from content
14
+ // top-left) + zoom so main can overlay the simulator WCV on it.
15
+ SetNativeBounds: 'simulator:set-native-bounds',
16
+ // Renderer pushes the selected device's LOGICAL metrics (screen size,
17
+ // pixelRatio, statusBarHeight, …) when the device dropdown changes. Main
18
+ // maps it to a HostEnvSnapshot and live-updates the running service-host
19
+ // window — the authoritative `wx.getSystemInfoSync()` source — so the
20
+ // mini-app sees the selected device without a relaunch.
21
+ SetDeviceInfo: 'simulator:set-device-info',
11
22
  Detach: 'simulator:detach',
12
23
  Resize: 'simulator:resize',
13
24
  SetVisible: 'simulator:setVisible',
14
25
  Console: 'simulator:console',
26
+ // Main → renderer push of the visible top-of-stack page route whenever the
27
+ // mini-app navigates (navigateTo / switchTab / back). Payload: the page path
28
+ // string (same bare format as `getCurrentPagePath`), or '' when unknown.
29
+ CurrentPage: 'simulator:current-page',
30
+ };
31
+ // ── Service host (main → hidden service-host window) ─────────────────────
32
+ export const ServiceHostChannel = {
33
+ /**
34
+ * NATIVE-HOST ONLY. Live-update the service-host window's host-env snapshot
35
+ * (device metrics) so subsequent `wx.getSystemInfoSync()` reflects a device
36
+ * change without a relaunch. The service-host preload mutates
37
+ * `__diminaSpawnContext.hostEnvSnapshot` in place (see `service-host/preload.cjs`).
38
+ */
39
+ HostEnvUpdate: 'service-host:host-env:update',
15
40
  };
16
41
  // ── Custom simulator APIs (downstream-registered, main-process handlers) ──
17
42
  // list: simulator queries the names registered via instance.registerSimulatorApi().
18
43
  // invoke: simulator forwards an API call to the registry; result/reject propagates.
19
44
  //
20
45
  // These are ipcMain.handle channels invoked by the **main-window renderer**
21
- // only (trusted host). The simulator <webview> never reaches them directly —
22
- // it proxies through the host via the bridge channels below, so the
23
- // sender-policy can keep the webview off the IPC white-list.
46
+ // only (trusted host). The simulator guest never reaches them directly — it
47
+ // reaches the host via the bridge channels below, so the sender-policy can keep
48
+ // the simulator off the IPC white-list.
24
49
  export const SimulatorCustomApiChannel = {
25
50
  List: 'simulator:custom-apis:list',
26
51
  Invoke: 'simulator:custom-apis:invoke',
27
52
  };
28
- // ── Custom APIs bridge proxy (simulator <webview> ↔ main-window renderer) ──
29
- // Request: webview host via `ipcRenderer.sendToHost`,
30
- // payload = { id, op: 'list' } | { id, op: 'invoke', name, params }
31
- // Response: host webview via `<webview>.send`,
32
- // payload = { id, result } | { id, error }
53
+ // ── Custom APIs bridge (simulator host) ──
54
+ // payload = { id, op: 'list' } | { id, op: 'invoke', name, params } for Request,
55
+ // { id, result } | { id, error } for Response. Transport (in
56
+ // `src/preload/runtime/custom-apis.ts`): native-host the simulator is a
57
+ // top-level WebContentsView (no embedder), so Request goes via
58
+ // `ipcRenderer.send` → `ipcMain.on` dispatcher bound to that simWc (view-manager
59
+ // `attachNativeCustomApiBridge`) → Response via `simWc.send`. (The old
60
+ // renderer-proxied `<webview>` transport, `ipcRenderer.sendToHost` →
61
+ // `<webview>.send`, no longer exists — native-host is the sole runtime.)
33
62
  //
34
63
  // Request/response are correlated by `id` so multiple concurrent invokes can
35
64
  // be in flight at once.
@@ -38,7 +67,7 @@ export const SimulatorCustomApiBridgeChannel = {
38
67
  Response: 'simulator:custom-apis:bridge-response',
39
68
  };
40
69
  // ── Storage (CDP-backed; main process attaches the debugger to the
41
- // simulator <webview> and forwards DOMStorage events to the renderer) ──
70
+ // simulator guest and forwards DOMStorage events to the renderer) ──
42
71
  export const SimulatorStorageChannel = {
43
72
  GetSnapshot: 'simulator:storage:snapshot',
44
73
  GetActivePrefix: 'simulator:storage:activePrefix',
@@ -53,6 +82,28 @@ export const SimulatorElementChannel = {
53
82
  Inspect: 'simulator:element:inspect',
54
83
  Clear: 'simulator:element:clear',
55
84
  };
85
+ // ── Workbench runtime info (renderer reads once to pick panel data sources) ──
86
+ // Under native-host the page DOM / service logic live in separate webContents,
87
+ // so WXML + AppData are sourced from the main process instead of the simulator
88
+ // guest's miniappSnapshot transport. The renderer queries this flag once and
89
+ // branches usePanelData accordingly.
90
+ export const WorkbenchRuntimeChannel = {
91
+ GetNativeHost: 'workbench:runtime:native-host',
92
+ };
93
+ // ── WXML tree (native-host: main pulls the tree from the active render-host
94
+ // <webview> guest via render-inspect, and pushes/answers here — mirroring the
95
+ // Storage panel's main→renderer contract so the renderer panel is unchanged) ──
96
+ export const SimulatorWxmlChannel = {
97
+ GetSnapshot: 'simulator:wxml:snapshot',
98
+ Event: 'simulator:wxml:event',
99
+ };
100
+ // ── AppData (native-host: main taps the service→render setData stream in
101
+ // bridge-router and pushes the cumulative snapshot here — the service logic runs
102
+ // in the hidden service-host window, not a Worker in the simulator guest) ──
103
+ export const SimulatorAppDataChannel = {
104
+ GetSnapshot: 'simulator:appdata:snapshot',
105
+ Event: 'simulator:appdata:event',
106
+ };
56
107
  // ── Workbench settings ───────────────────────────────────────────────────
57
108
  export const WorkbenchSettingsChannel = {
58
109
  Get: 'workbenchSettings:get',
@@ -95,6 +146,18 @@ export const ProjectFsChannel = {
95
146
  WriteFileSync: 'project:fs:writeFileSync',
96
147
  ListFiles: 'project:fs:listFiles',
97
148
  };
149
+ // ── Editor (main → renderer) ──────────────────────────────────────────────
150
+ //
151
+ // Drives the in-renderer Monaco editor from the main process. Used by the
152
+ // "click a console file link → open the file at line:col" pipeline: the
153
+ // embedded DevTools front-end routes a source-link click through an open-
154
+ // resource handler → Electron `devtools-open-url` on the service host → main
155
+ // maps the resource URL to a project-relative path → this event opens it in
156
+ // Monaco. Payload: `EditorOpenFilePayload`.
157
+ export const EditorChannel = {
158
+ /** main → renderer: open `path` (project-relative POSIX) at `line`/`column`. */
159
+ OpenFile: 'editor:openFile',
160
+ };
98
161
  // ── Project list / workspace ─────────────────────────────────────────────
99
162
  export const ProjectsChannel = {
100
163
  List: 'projects:list',
@@ -135,6 +198,23 @@ export const PanelChannel = {
135
198
  export const ViewChannel = {
136
199
  /** Update the simulator DevTools view's bounds (or hide if w/h = 0). */
137
200
  SimulatorDevtoolsBounds: 'view:simulator:devtools-bounds',
201
+ /**
202
+ * Host-controllable toolbar WebContentsView (sits ABOVE the devtools built-in
203
+ * header). Forward anchor: the main renderer reports the toolbar placeholder's
204
+ * bounds (or w/h=0 to hide). invoke.
205
+ */
206
+ HostToolbarBounds: 'view:host-toolbar:bounds',
207
+ /**
208
+ * Reverse size-advertiser: the host-toolbar WCV's OWN renderer advertises its
209
+ * intrinsic content height so main reserves exactly that much. Payload
210
+ * `{ axis: 'block', extent }`. fire-and-forget (send), NOT invoke.
211
+ */
212
+ HostToolbarAdvertiseHeight: 'view:host-toolbar:advertise-height',
213
+ /**
214
+ * main → main-window renderer: push the reserved host-toolbar height so the
215
+ * renderer placeholder div resizes (closing the dynamic-height loop).
216
+ */
217
+ HostToolbarHeightChanged: 'view:host-toolbar:height-changed',
138
218
  };
139
219
  // ── Popover ──────────────────────────────────────────────────────────────
140
220
  export const PopoverChannel = {
@@ -25,16 +25,73 @@ export declare const ProjectSaveCompileConfigSchema: z.ZodTuple<[z.ZodString, z.
25
25
  }, z.core.$loose>], null>;
26
26
  /** popover:show — must be an object (not undefined/null/string). */
27
27
  export declare const PopoverShowSchema: z.ZodTuple<[z.ZodObject<{}, z.core.$loose>], null>;
28
- /** simulator:attach — webContents id (positive int) + simulator width. */
29
- export declare const SimulatorAttachSchema: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
28
+ /**
29
+ * simulator:attach-native (native-host only) — the simulator URL to load into
30
+ * the top-level WebContentsView + simulator width. The URL is the dev-server
31
+ * `http://localhost:<port>/simulator.html?…` the renderer would otherwise put
32
+ * on the `<webview src>`; we validate it's an http(s) URL to keep the WCV off
33
+ * arbitrary origins (will-navigate hardening re-checks at navigation time).
34
+ */
35
+ export declare const SimulatorAttachNativeSchema: z.ZodTuple<[z.ZodString, z.ZodNumber], null>;
30
36
  /** simulator:resize — simulator width. */
31
37
  export declare const SimulatorResizeSchema: z.ZodTuple<[z.ZodNumber], null>;
38
+ /**
39
+ * simulator:set-native-bounds (native-host only) — the renderer-measured
40
+ * device-bezel inner-screen rect (CSS px, from `getBoundingClientRect()`, may
41
+ * be fractional/zero) plus the device zoom percent. Positioned 1:1 as the
42
+ * simulator WCV overlay bounds. Coordinates are plain finite numbers (x/y may
43
+ * be negative when scrolled off-screen); zoom is the ZOOM_OPTIONS percent.
44
+ */
45
+ export declare const SimulatorSetNativeBoundsSchema: z.ZodTuple<[z.ZodObject<{
46
+ x: z.ZodNumber;
47
+ y: z.ZodNumber;
48
+ width: z.ZodNumber;
49
+ height: z.ZodNumber;
50
+ zoom: z.ZodNumber;
51
+ }, z.core.$strip>], null>;
52
+ /**
53
+ * simulator:set-device-info (native-host only) — the selected device's logical
54
+ * metrics, mapped by main into the service-host window's HostEnvSnapshot. Sizes
55
+ * are bounded positive ints (logical device px); strings are bounded to keep the
56
+ * payload small. Matches `NativeDeviceInfo` in ipc-channels.ts.
57
+ */
58
+ export declare const SimulatorSetDeviceInfoSchema: z.ZodTuple<[z.ZodObject<{
59
+ brand: z.ZodString;
60
+ model: z.ZodString;
61
+ system: z.ZodString;
62
+ platform: z.ZodString;
63
+ pixelRatio: z.ZodNumber;
64
+ screenWidth: z.ZodNumber;
65
+ screenHeight: z.ZodNumber;
66
+ statusBarHeight: z.ZodNumber;
67
+ safeAreaBottom: z.ZodNumber;
68
+ notchType: z.ZodEnum<{
69
+ none: "none";
70
+ notch: "notch";
71
+ "dynamic-island": "dynamic-island";
72
+ }>;
73
+ safeAreaInsets: z.ZodObject<{
74
+ top: z.ZodNumber;
75
+ right: z.ZodNumber;
76
+ bottom: z.ZodNumber;
77
+ left: z.ZodNumber;
78
+ }, z.core.$strip>;
79
+ }, z.core.$strip>], null>;
32
80
  export declare const ViewBoundsSchema: z.ZodTuple<[z.ZodObject<{
33
81
  x: z.ZodNumber;
34
82
  y: z.ZodNumber;
35
83
  width: z.ZodNumber;
36
84
  height: z.ZodNumber;
37
85
  }, z.core.$strip>], null>;
86
+ /**
87
+ * host-toolbar reverse size-advertiser payload — the toolbar WCV renderer
88
+ * advertises its intrinsic content height on the block axis. Mirrors
89
+ * `@dimina-kit/view-anchor`'s `AdvertisedSize`.
90
+ */
91
+ export declare const HostToolbarAdvertiseHeightSchema: z.ZodTuple<[z.ZodObject<{
92
+ axis: z.ZodLiteral<"block">;
93
+ extent: z.ZodNumber;
94
+ }, z.core.$strip>], null>;
38
95
  /** simulator:setVisible — visible flag + simulator width. */
39
96
  export declare const SimulatorSetVisibleSchema: z.ZodTuple<[z.ZodBoolean, z.ZodNumber], null>;
40
97
  /**
@@ -50,13 +50,63 @@ export const PopoverShowSchema = z.tuple([z.looseObject({})]);
50
50
  * we still reject obvious garbage (negative, zero, absurdly large).
51
51
  */
52
52
  const SimWidth = z.number().int().min(100).max(2000);
53
- /** simulator:attach — webContents id (positive int) + simulator width. */
54
- export const SimulatorAttachSchema = z.tuple([
55
- z.number().int().positive(),
53
+ /**
54
+ * simulator:attach-native (native-host only) — the simulator URL to load into
55
+ * the top-level WebContentsView + simulator width. The URL is the dev-server
56
+ * `http://localhost:<port>/simulator.html?…` the renderer would otherwise put
57
+ * on the `<webview src>`; we validate it's an http(s) URL to keep the WCV off
58
+ * arbitrary origins (will-navigate hardening re-checks at navigation time).
59
+ */
60
+ export const SimulatorAttachNativeSchema = z.tuple([
61
+ z.string().url().refine((u) => u.startsWith('http://') || u.startsWith('https://'), {
62
+ message: 'simulator URL must be http(s)',
63
+ }),
56
64
  SimWidth,
57
65
  ]);
58
66
  /** simulator:resize — simulator width. */
59
67
  export const SimulatorResizeSchema = z.tuple([SimWidth]);
68
+ /**
69
+ * simulator:set-native-bounds (native-host only) — the renderer-measured
70
+ * device-bezel inner-screen rect (CSS px, from `getBoundingClientRect()`, may
71
+ * be fractional/zero) plus the device zoom percent. Positioned 1:1 as the
72
+ * simulator WCV overlay bounds. Coordinates are plain finite numbers (x/y may
73
+ * be negative when scrolled off-screen); zoom is the ZOOM_OPTIONS percent.
74
+ */
75
+ export const SimulatorSetNativeBoundsSchema = z.tuple([
76
+ z.object({
77
+ x: z.number().finite(),
78
+ y: z.number().finite(),
79
+ width: z.number().finite(),
80
+ height: z.number().finite(),
81
+ zoom: z.number().finite().positive(),
82
+ }),
83
+ ]);
84
+ /**
85
+ * simulator:set-device-info (native-host only) — the selected device's logical
86
+ * metrics, mapped by main into the service-host window's HostEnvSnapshot. Sizes
87
+ * are bounded positive ints (logical device px); strings are bounded to keep the
88
+ * payload small. Matches `NativeDeviceInfo` in ipc-channels.ts.
89
+ */
90
+ export const SimulatorSetDeviceInfoSchema = z.tuple([
91
+ z.object({
92
+ brand: z.string().max(64),
93
+ model: z.string().max(64),
94
+ system: z.string().max(64),
95
+ platform: z.string().max(32),
96
+ pixelRatio: z.number().finite().positive(),
97
+ screenWidth: z.number().int().min(100).max(4000),
98
+ screenHeight: z.number().int().min(100).max(4000),
99
+ statusBarHeight: z.number().finite().min(0).max(400),
100
+ safeAreaBottom: z.number().finite().min(0).max(400),
101
+ notchType: z.enum(['none', 'notch', 'dynamic-island']),
102
+ safeAreaInsets: z.object({
103
+ top: z.number().finite().min(0).max(400),
104
+ right: z.number().finite().min(0).max(400),
105
+ bottom: z.number().finite().min(0).max(400),
106
+ left: z.number().finite().min(0).max(400),
107
+ }),
108
+ }),
109
+ ]);
60
110
  /**
61
111
  * view:*:bounds — renderer-measured CSS pixel rectangle in window content
62
112
  * coordinates. Width/height = 0 is the canonical "overlay hidden" signal.
@@ -72,6 +122,17 @@ export const ViewBoundsSchema = z.tuple([
72
122
  height: NonNegInt,
73
123
  }),
74
124
  ]);
125
+ /**
126
+ * host-toolbar reverse size-advertiser payload — the toolbar WCV renderer
127
+ * advertises its intrinsic content height on the block axis. Mirrors
128
+ * `@dimina-kit/view-anchor`'s `AdvertisedSize`.
129
+ */
130
+ export const HostToolbarAdvertiseHeightSchema = z.tuple([
131
+ z.object({
132
+ axis: z.literal('block'),
133
+ extent: NonNegInt,
134
+ }),
135
+ ]);
75
136
  /** simulator:setVisible — visible flag + simulator width. */
76
137
  export const SimulatorSetVisibleSchema = z.tuple([z.boolean(), SimWidth]);
77
138
  /**
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Shared, pure helpers for the "click a console file link → open the built-in
3
+ * Monaco editor" pipeline (native-host).
4
+ *
5
+ * The right-panel console is the embedded Chromium DevTools front-end inspecting
6
+ * the service host. When a sourcemap maps a console frame back to source, the
7
+ * front-end can be made to route a source-link click through an "open resource
8
+ * handler" instead of its own Sources panel (the same hook IDEs use to integrate
9
+ * with Chrome DevTools). Our handler can't talk IPC directly from the closed
10
+ * DevTools realm, so it encodes the target as a sentinel URL and asks the
11
+ * front-end to "open" it; Electron surfaces that as a `devtools-open-url` event
12
+ * on the inspected webContents, which main decodes here.
13
+ *
14
+ * This module owns ONLY the pure string/URL logic (encode + decode + map a
15
+ * DevTools resource URL to a project-relative path). It has no electron / DOM /
16
+ * node deps so it is unit-testable and shared by main + the injected front-end
17
+ * snippet's expectations.
18
+ */
19
+ /**
20
+ * Sentinel scheme for the encoded "open in editor" request. A bare custom scheme
21
+ * (no `//authority`) keeps the encoded payload entirely in the URL's path/query,
22
+ * which `InspectorFrontendHost.openInNewTab` forwards verbatim to Electron's
23
+ * `devtools-open-url` event.
24
+ */
25
+ export declare const OPEN_IN_EDITOR_SCHEME = "dimina-open-in-editor";
26
+ /** A decoded open-in-editor request: a project source location. */
27
+ export interface OpenInEditorRequest {
28
+ /** The DevTools resource URL of the clicked source (the map `sources` entry, absolute). */
29
+ url: string;
30
+ /** 0-based line as reported by DevTools (may be undefined for a bare file link). */
31
+ line?: number;
32
+ /** 0-based column as reported by DevTools (may be undefined). */
33
+ column?: number;
34
+ }
35
+ /**
36
+ * Encode an open-in-editor request as a sentinel URL the DevTools front-end can
37
+ * hand to `InspectorFrontendHost.openInNewTab(...)`. All fields ride in the
38
+ * query string so no value is ever interpolated into a path segment.
39
+ */
40
+ export declare function encodeOpenInEditorUrl(req: OpenInEditorRequest): string;
41
+ /**
42
+ * Decode a sentinel URL produced by `encodeOpenInEditorUrl`. Returns null for
43
+ * any URL that is not our sentinel scheme (so a real "open in new tab" link the
44
+ * user clicked is left to Electron's default external-open path).
45
+ */
46
+ export declare function decodeOpenInEditorUrl(raw: string): OpenInEditorRequest | null;
47
+ /**
48
+ * Map a DevTools resource URL to a PROJECT-RELATIVE source path (POSIX, no
49
+ * leading slash) — the same key the in-renderer Monaco editor opens files by
50
+ * (`joinPosix(root, rel)` → `project:fs:readFile`).
51
+ *
52
+ * The compiler emits each `logic.js.map` with `sources` = the project-relative
53
+ * source path (e.g. `pages/home/home.js`, or `subpkg/pages/x/x.js` for a sub-
54
+ * package — both already rooted at the project). DevTools resolves those against
55
+ * the map URL on the dev server, producing
56
+ * `http://127.0.0.1:<port>/<appId>/<source-path>`. So recovering the project-
57
+ * relative path is exactly: strip the origin, then strip the FIRST path segment
58
+ * (the `<appId>` the dev server namespaces the bundle under). What remains is
59
+ * the source path the compiler recorded, which is the editor's open key — this
60
+ * holds for both the main package and sub-packages without needing the project's
61
+ * appId / root threaded in.
62
+ *
63
+ * @param resourceUrl The absolute URL DevTools reported for the clicked source.
64
+ * @param expectedOrigin Optional dev-server origin to gate on
65
+ * (`http://127.0.0.1:<port>`); when given, a URL from a different origin (a
66
+ * framework/`webpack://`/`node:` frame) returns null instead of mis-mapping.
67
+ * @returns the project-relative POSIX path, or null when the URL is not a
68
+ * mappable dev-server source.
69
+ */
70
+ export declare function resourceUrlToProjectRelativePath(resourceUrl: string, expectedOrigin?: string): string | null;
71
+ //# sourceMappingURL=open-in-editor.d.ts.map
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Shared, pure helpers for the "click a console file link → open the built-in
3
+ * Monaco editor" pipeline (native-host).
4
+ *
5
+ * The right-panel console is the embedded Chromium DevTools front-end inspecting
6
+ * the service host. When a sourcemap maps a console frame back to source, the
7
+ * front-end can be made to route a source-link click through an "open resource
8
+ * handler" instead of its own Sources panel (the same hook IDEs use to integrate
9
+ * with Chrome DevTools). Our handler can't talk IPC directly from the closed
10
+ * DevTools realm, so it encodes the target as a sentinel URL and asks the
11
+ * front-end to "open" it; Electron surfaces that as a `devtools-open-url` event
12
+ * on the inspected webContents, which main decodes here.
13
+ *
14
+ * This module owns ONLY the pure string/URL logic (encode + decode + map a
15
+ * DevTools resource URL to a project-relative path). It has no electron / DOM /
16
+ * node deps so it is unit-testable and shared by main + the injected front-end
17
+ * snippet's expectations.
18
+ */
19
+ /**
20
+ * Sentinel scheme for the encoded "open in editor" request. A bare custom scheme
21
+ * (no `//authority`) keeps the encoded payload entirely in the URL's path/query,
22
+ * which `InspectorFrontendHost.openInNewTab` forwards verbatim to Electron's
23
+ * `devtools-open-url` event.
24
+ */
25
+ export const OPEN_IN_EDITOR_SCHEME = 'dimina-open-in-editor';
26
+ /**
27
+ * Encode an open-in-editor request as a sentinel URL the DevTools front-end can
28
+ * hand to `InspectorFrontendHost.openInNewTab(...)`. All fields ride in the
29
+ * query string so no value is ever interpolated into a path segment.
30
+ */
31
+ export function encodeOpenInEditorUrl(req) {
32
+ const params = new URLSearchParams();
33
+ params.set('u', req.url);
34
+ if (typeof req.line === 'number' && Number.isFinite(req.line)) {
35
+ params.set('l', String(Math.trunc(req.line)));
36
+ }
37
+ if (typeof req.column === 'number' && Number.isFinite(req.column)) {
38
+ params.set('c', String(Math.trunc(req.column)));
39
+ }
40
+ return `${OPEN_IN_EDITOR_SCHEME}:?${params.toString()}`;
41
+ }
42
+ /**
43
+ * Decode a sentinel URL produced by `encodeOpenInEditorUrl`. Returns null for
44
+ * any URL that is not our sentinel scheme (so a real "open in new tab" link the
45
+ * user clicked is left to Electron's default external-open path).
46
+ */
47
+ export function decodeOpenInEditorUrl(raw) {
48
+ if (typeof raw !== 'string')
49
+ return null;
50
+ const prefix = `${OPEN_IN_EDITOR_SCHEME}:`;
51
+ if (!raw.startsWith(prefix))
52
+ return null;
53
+ // Strip the scheme; tolerate an optional leading `?` on the query.
54
+ let query = raw.slice(prefix.length);
55
+ if (query.startsWith('?'))
56
+ query = query.slice(1);
57
+ const params = new URLSearchParams(query);
58
+ const url = params.get('u');
59
+ if (!url)
60
+ return null;
61
+ const out = { url };
62
+ const l = params.get('l');
63
+ const c = params.get('c');
64
+ if (l !== null && l !== '') {
65
+ const n = Number(l);
66
+ if (Number.isFinite(n))
67
+ out.line = Math.trunc(n);
68
+ }
69
+ if (c !== null && c !== '') {
70
+ const n = Number(c);
71
+ if (Number.isFinite(n))
72
+ out.column = Math.trunc(n);
73
+ }
74
+ return out;
75
+ }
76
+ /**
77
+ * Map a DevTools resource URL to a PROJECT-RELATIVE source path (POSIX, no
78
+ * leading slash) — the same key the in-renderer Monaco editor opens files by
79
+ * (`joinPosix(root, rel)` → `project:fs:readFile`).
80
+ *
81
+ * The compiler emits each `logic.js.map` with `sources` = the project-relative
82
+ * source path (e.g. `pages/home/home.js`, or `subpkg/pages/x/x.js` for a sub-
83
+ * package — both already rooted at the project). DevTools resolves those against
84
+ * the map URL on the dev server, producing
85
+ * `http://127.0.0.1:<port>/<appId>/<source-path>`. So recovering the project-
86
+ * relative path is exactly: strip the origin, then strip the FIRST path segment
87
+ * (the `<appId>` the dev server namespaces the bundle under). What remains is
88
+ * the source path the compiler recorded, which is the editor's open key — this
89
+ * holds for both the main package and sub-packages without needing the project's
90
+ * appId / root threaded in.
91
+ *
92
+ * @param resourceUrl The absolute URL DevTools reported for the clicked source.
93
+ * @param expectedOrigin Optional dev-server origin to gate on
94
+ * (`http://127.0.0.1:<port>`); when given, a URL from a different origin (a
95
+ * framework/`webpack://`/`node:` frame) returns null instead of mis-mapping.
96
+ * @returns the project-relative POSIX path, or null when the URL is not a
97
+ * mappable dev-server source.
98
+ */
99
+ export function resourceUrlToProjectRelativePath(resourceUrl, expectedOrigin) {
100
+ if (typeof resourceUrl !== 'string' || !resourceUrl)
101
+ return null;
102
+ let resource;
103
+ try {
104
+ resource = new URL(resourceUrl);
105
+ }
106
+ catch {
107
+ return null;
108
+ }
109
+ // Only http(s) dev-server sources map to project files; schemes like
110
+ // `webpack://`, `node:`, `data:` are framework/runtime frames with no file.
111
+ if (resource.protocol !== 'http:' && resource.protocol !== 'https:')
112
+ return null;
113
+ if (expectedOrigin) {
114
+ let base;
115
+ try {
116
+ base = new URL(expectedOrigin);
117
+ }
118
+ catch {
119
+ return null;
120
+ }
121
+ if (resource.origin !== base.origin)
122
+ return null;
123
+ }
124
+ // pathname is `/<appId>/<source-path>`. Drop the leading appId segment; the
125
+ // remainder, percent-decoded per segment, is the project-relative path.
126
+ const segments = resource.pathname.split('/').filter(Boolean).map((s) => {
127
+ try {
128
+ return decodeURIComponent(s);
129
+ }
130
+ catch {
131
+ return s;
132
+ }
133
+ });
134
+ if (segments.length < 2)
135
+ return null;
136
+ return segments.slice(1).join('/');
137
+ }
138
+ //# sourceMappingURL=open-in-editor.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Persistent (subscription) simulator APIs — a call that, once made, keeps
3
+ * delivering a response on every underlying event instead of settling once.
4
+ *
5
+ * The dimina service runtime strips `keep` / `evtId` / `success` before the
6
+ * call leaves the service host (it stores them service-local in
7
+ * `callback.store`), so by the time `audioListen` reaches the container its
8
+ * `keep: true` intent is gone and it would degrade to a one-shot call —
9
+ * dropping every audio DOM event after the first. The container and router
10
+ * therefore recognise these APIs by NAME and treat them as persistent
11
+ * regardless of the (stripped) params.
12
+ *
13
+ * Currently only `audioListen` — the InnerAudioContext DOM-event bridge
14
+ * (canplay / play / pause / ended / error / timeupdate / waiting / seeking /
15
+ * seeked). Add any new subscription API here: this is the single source of
16
+ * truth, consumed by `bridge-router` (skip the one-shot timeout, keep-alive
17
+ * responses) and `run-api-async` (no premature settle, re-fire on every event).
18
+ */
19
+ export declare const PERSISTENT_SIMULATOR_APIS: ReadonlySet<string>;
20
+ export declare function isPersistentSimulatorApi(name: string): boolean;
21
+ //# sourceMappingURL=simulator-api-metadata.d.ts.map