@dimina-kit/devtools 0.3.2-dev.20260525152421 → 0.3.2-dev.20260610082053

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 (295) hide show
  1. package/README.md +43 -40
  2. package/dist/main/api.d.ts +0 -1
  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 +247 -110
  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 +6607 -2102
  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 +1300 -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 +57 -0
  19. package/dist/main/ipc/project-fs.js +448 -0
  20. package/dist/main/ipc/projects.d.ts +1 -1
  21. package/dist/main/ipc/session.d.ts +1 -1
  22. package/dist/main/ipc/settings.d.ts +1 -1
  23. package/dist/main/ipc/simulator-module.d.ts +6 -0
  24. package/dist/main/ipc/simulator-module.js +11 -1
  25. package/dist/main/ipc/simulator.d.ts +2 -2
  26. package/dist/main/ipc/simulator.js +49 -5
  27. package/dist/main/ipc/toolbar.d.ts +1 -1
  28. package/dist/main/ipc/views.d.ts +19 -0
  29. package/dist/main/ipc/views.js +65 -0
  30. package/dist/main/runtime/devtools-backend.d.ts +17 -0
  31. package/dist/main/runtime/devtools-backend.js +49 -0
  32. package/dist/main/runtime/miniapp-runtime.d.ts +39 -0
  33. package/dist/main/runtime/miniapp-runtime.js +17 -0
  34. package/dist/main/services/automation/exec.d.ts +27 -2
  35. package/dist/main/services/automation/exec.js +37 -3
  36. package/dist/main/services/automation/handlers/app.js +127 -11
  37. package/dist/main/services/automation/handlers/page.js +36 -19
  38. package/dist/main/services/automation/index.js +40 -13
  39. package/dist/main/services/automation/wait-active-page.d.ts +56 -0
  40. package/dist/main/services/automation/wait-active-page.js +71 -0
  41. package/dist/main/services/console-forward/index.d.ts +36 -0
  42. package/dist/main/services/console-forward/index.js +81 -0
  43. package/dist/main/services/dimina-resource-server.d.ts +7 -0
  44. package/dist/main/services/dimina-resource-server.js +99 -0
  45. package/dist/main/services/elements-forward/index.d.ts +66 -0
  46. package/dist/main/services/elements-forward/index.js +583 -0
  47. package/dist/main/services/layout/index.d.ts +23 -1
  48. package/dist/main/services/layout/index.js +28 -3
  49. package/dist/main/services/mcp/index.d.ts +1 -0
  50. package/dist/main/services/mcp/index.js +3 -0
  51. package/dist/main/services/mcp/server.d.ts +1 -1
  52. package/dist/main/services/mcp/server.js +1 -1
  53. package/dist/main/services/mcp/target-manager.d.ts +35 -0
  54. package/dist/main/services/mcp/target-manager.js +63 -1
  55. package/dist/main/services/mcp/tools/context-tools.js +15 -1
  56. package/dist/main/services/module.d.ts +1 -1
  57. package/dist/main/services/network-forward/index.d.ts +190 -0
  58. package/dist/main/services/network-forward/index.js +765 -0
  59. package/dist/main/services/notifications/renderer-notifier.d.ts +11 -0
  60. package/dist/main/services/notifications/renderer-notifier.js +7 -1
  61. package/dist/main/services/render-inspect/index.d.ts +41 -0
  62. package/dist/main/services/render-inspect/index.js +88 -0
  63. package/dist/main/services/safe-area/index.d.ts +17 -0
  64. package/dist/main/services/safe-area/index.js +59 -0
  65. package/dist/main/services/service-host-pool/pool.d.ts +197 -0
  66. package/dist/main/services/service-host-pool/pool.js +364 -0
  67. package/dist/main/services/simulator/custom-apis.d.ts +34 -0
  68. package/dist/main/services/simulator/custom-apis.js +22 -0
  69. package/dist/main/services/simulator-appdata/index.d.ts +35 -0
  70. package/dist/main/services/simulator-appdata/index.js +71 -0
  71. package/dist/main/services/simulator-current-page/index.d.ts +24 -0
  72. package/dist/main/services/simulator-current-page/index.js +19 -0
  73. package/dist/main/services/simulator-storage/index.d.ts +37 -2
  74. package/dist/main/services/simulator-storage/index.js +209 -32
  75. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +40 -0
  76. package/dist/main/services/simulator-storage/service-storage-ops.js +67 -0
  77. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -1
  78. package/dist/main/services/simulator-temp-files/index.d.ts +1 -1
  79. package/dist/main/services/simulator-temp-files/index.js +1 -1
  80. package/dist/main/services/simulator-temp-files/request-handler.js +1 -1
  81. package/dist/main/services/simulator-wxml/index.d.ts +29 -0
  82. package/dist/main/services/simulator-wxml/index.js +28 -0
  83. package/dist/main/services/update/update-manager.d.ts +10 -0
  84. package/dist/main/services/update/update-manager.js +16 -3
  85. package/dist/main/services/views/devtools-tabs.d.ts +47 -0
  86. package/dist/main/services/views/devtools-tabs.js +95 -0
  87. package/dist/main/services/views/view-manager.d.ts +142 -4
  88. package/dist/main/services/views/view-manager.js +909 -17
  89. package/dist/main/services/workbench-context.d.ts +66 -1
  90. package/dist/main/services/workbench-context.js +6 -1
  91. package/dist/main/services/workspace/workspace-service.d.ts +8 -0
  92. package/dist/main/services/workspace/workspace-service.js +12 -0
  93. package/dist/main/utils/ipc-registry.d.ts +11 -2
  94. package/dist/main/utils/ipc-registry.js +63 -3
  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 +11 -59
  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 +52 -0
  106. package/dist/main/windows/service-host-window/create.js +112 -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 +29 -11
  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 +1939 -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 +243 -573
  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/abap-DiwvWnMr.js +2 -0
  143. package/dist/renderer/assets/apex-CmtZjKlf.js +2 -0
  144. package/dist/renderer/assets/azcli-DL2My_i-.js +2 -0
  145. package/dist/renderer/assets/bat-B-nC98wG.js +2 -0
  146. package/dist/renderer/assets/bicep-Ju5MwOgh.js +3 -0
  147. package/dist/renderer/assets/cameligo-8Eu1TyBr.js +2 -0
  148. package/dist/renderer/assets/chunk-DPI0Y_ll.js +1 -0
  149. package/dist/renderer/assets/clojure-u-RpMkH3.js +2 -0
  150. package/dist/renderer/assets/codicon-ngg6Pgfi.ttf +0 -0
  151. package/dist/renderer/assets/coffee-CdA7bbTe.js +2 -0
  152. package/dist/renderer/assets/constants-CLAQX6VZ.js +2 -0
  153. package/dist/renderer/assets/cpp-CzNFP8ks.js +2 -0
  154. package/dist/renderer/assets/csharp-j1LThmcE.js +2 -0
  155. package/dist/renderer/assets/csp-CLRC61y6.js +2 -0
  156. package/dist/renderer/assets/css-r6rC_7P2.js +4 -0
  157. package/dist/renderer/assets/css.worker-DyDu5ynT.js +90 -0
  158. package/dist/renderer/assets/cssMode-BCBgxrnA.js +2 -0
  159. package/dist/renderer/assets/cypher-CW08XVUh.js +2 -0
  160. package/dist/renderer/assets/dart-Cs9aL5T_.js +2 -0
  161. package/dist/renderer/assets/dockerfile-BWM0M184.js +2 -0
  162. package/dist/renderer/assets/ecl-MJJuer5P.js +2 -0
  163. package/dist/renderer/assets/editor-CWI9TnMM.css +1 -0
  164. package/dist/renderer/assets/editor.api2-BTaYmRq7.js +873 -0
  165. package/dist/renderer/assets/editor.worker-Dpt_xPrs.js +27 -0
  166. package/dist/renderer/assets/elixir-D2AIuXqn.js +2 -0
  167. package/dist/renderer/assets/flow9-B2H24giC.js +2 -0
  168. package/dist/renderer/assets/freemarker2-DGDGzimW.js +4 -0
  169. package/dist/renderer/assets/fsharp-CMk2OIJN.js +2 -0
  170. package/dist/renderer/assets/go-BrMkuJg0.js +2 -0
  171. package/dist/renderer/assets/graphql-PSR1UKGv.js +2 -0
  172. package/dist/renderer/assets/handlebars-bOHhw3EG.js +2 -0
  173. package/dist/renderer/assets/hcl-DAQrbDOW.js +2 -0
  174. package/dist/renderer/assets/html-BMyuX0_c.js +2 -0
  175. package/dist/renderer/assets/html.worker-IWNXhnIC.js +503 -0
  176. package/dist/renderer/assets/htmlMode-DR4kXJ7l.js +2 -0
  177. package/dist/renderer/assets/index-CcJKzatF.js +50 -0
  178. package/dist/renderer/assets/ini-0TG5BxW0.js +2 -0
  179. package/dist/renderer/assets/input-QGx6FFX1.js +2 -0
  180. package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +1 -0
  181. package/dist/renderer/assets/{ipc-transport-BzPzxPwf.js → ipc-transport-DvZvwK-Z.js} +5 -5
  182. package/dist/renderer/assets/java-rgorz17v.js +2 -0
  183. package/dist/renderer/assets/javascript-Bu-tl1P7.js +2 -0
  184. package/dist/renderer/assets/json.worker-c4h5s80L.js +59 -0
  185. package/dist/renderer/assets/jsonMode-MQV_ffLR.js +8 -0
  186. package/dist/renderer/assets/julia-C8VMdHm8.js +2 -0
  187. package/dist/renderer/assets/kotlin-AhhC4Qhm.js +2 -0
  188. package/dist/renderer/assets/less-Cgca25AP.js +3 -0
  189. package/dist/renderer/assets/lexon-D0GHdBaw.js +2 -0
  190. package/dist/renderer/assets/liquid-ClkfOvhB.js +2 -0
  191. package/dist/renderer/assets/lspLanguageFeatures-Bke_4Ie9.js +5 -0
  192. package/dist/renderer/assets/lua-DmRsNG-P.js +2 -0
  193. package/dist/renderer/assets/m3-BgL5dNKT.js +2 -0
  194. package/dist/renderer/assets/markdown-BuJfycGS.js +2 -0
  195. package/dist/renderer/assets/mdx-RZdUskPu.js +2 -0
  196. package/dist/renderer/assets/mips-C9m_93PR.js +2 -0
  197. package/dist/renderer/assets/monaco.contribution-B7rUMaEv.js +3 -0
  198. package/dist/renderer/assets/msdax-CpFHC9OI.js +2 -0
  199. package/dist/renderer/assets/mysql-qFvltsqN.js +2 -0
  200. package/dist/renderer/assets/objective-c-Bnmr858J.js +2 -0
  201. package/dist/renderer/assets/pascal-WP0_D5AO.js +2 -0
  202. package/dist/renderer/assets/pascaligo-Blom4Rij.js +2 -0
  203. package/dist/renderer/assets/perl-B-vk8g64.js +2 -0
  204. package/dist/renderer/assets/pgsql-Cgvz6v67.js +2 -0
  205. package/dist/renderer/assets/php-8a3Lrw9m.js +2 -0
  206. package/dist/renderer/assets/pla-DuFqEZ8V.js +2 -0
  207. package/dist/renderer/assets/popover-BOH1If1J.js +2 -0
  208. package/dist/renderer/assets/postiats-DkLtSgkp.js +2 -0
  209. package/dist/renderer/assets/powerquery-BJ1aNepW.js +2 -0
  210. package/dist/renderer/assets/powershell-rE98k687.js +2 -0
  211. package/dist/renderer/assets/protobuf-CUheFacr.js +3 -0
  212. package/dist/renderer/assets/pug-LDcAMD8w.js +2 -0
  213. package/dist/renderer/assets/python-Cobrm_-8.js +2 -0
  214. package/dist/renderer/assets/qsharp-DUKSQoR1.js +2 -0
  215. package/dist/renderer/assets/r-D-QApv87.js +2 -0
  216. package/dist/renderer/assets/razor-BEUIQFNJ.js +2 -0
  217. package/dist/renderer/assets/redis-SXdDyWR9.js +2 -0
  218. package/dist/renderer/assets/redshift-Y6lsCryn.js +2 -0
  219. package/dist/renderer/assets/restructuredtext-edObr9a8.js +2 -0
  220. package/dist/renderer/assets/ruby-CNnUfF-8.js +2 -0
  221. package/dist/renderer/assets/rust-IHUZWzBr.js +2 -0
  222. package/dist/renderer/assets/sb-DrUvY44N.js +2 -0
  223. package/dist/renderer/assets/scala-B4hbXGLM.js +2 -0
  224. package/dist/renderer/assets/scheme-BGrd12j3.js +2 -0
  225. package/dist/renderer/assets/scss-x5G1ES4U.js +4 -0
  226. package/dist/renderer/assets/select-C7JQ8G5N.js +2 -0
  227. package/dist/renderer/assets/settings-DpAbTJyF.js +2 -0
  228. package/dist/renderer/assets/{settings-api-BXCw9vOZ.js → settings-api-RD2IZF53.js} +2 -2
  229. package/dist/renderer/assets/shell-DOehe2Y8.js +2 -0
  230. package/dist/renderer/assets/solidity-BeRvcwWV.js +2 -0
  231. package/dist/renderer/assets/sophia-DZbkUNjy.js +2 -0
  232. package/dist/renderer/assets/sparql-B7_oi5-h.js +2 -0
  233. package/dist/renderer/assets/sql-CTlsFWVE.js +2 -0
  234. package/dist/renderer/assets/st-DJVEJdPE.js +2 -0
  235. package/dist/renderer/assets/swift-CwhT3fYa.js +2 -0
  236. package/dist/renderer/assets/systemverilog-BQN63pkN.js +2 -0
  237. package/dist/renderer/assets/tcl-DqwfpskA.js +2 -0
  238. package/dist/renderer/assets/ts.worker-BwM5Ha3L.js +67720 -0
  239. package/dist/renderer/assets/tsMode-BHa7dl9v.js +12 -0
  240. package/dist/renderer/assets/twig-BiyenUgc.js +2 -0
  241. package/dist/renderer/assets/typescript-15aT0Yj8.js +2 -0
  242. package/dist/renderer/assets/typespec-CWOJribt.js +2 -0
  243. package/dist/renderer/assets/vb-Cq5F87m3.js +2 -0
  244. package/dist/renderer/assets/wgsl-BAvW2lVr.js +299 -0
  245. package/dist/renderer/assets/workbenchSettings-CNJX4Qna.js +8 -0
  246. package/dist/renderer/assets/workers-CRBS0W-v.js +2 -0
  247. package/dist/renderer/assets/xml-bR2Zh-HV.js +2 -0
  248. package/dist/renderer/assets/yaml-Bdk54Qrb.js +2 -0
  249. package/dist/renderer/entries/main/index.html +29 -6
  250. package/dist/renderer/entries/popover/index.html +7 -6
  251. package/dist/renderer/entries/settings/index.html +6 -5
  252. package/dist/renderer/entries/workbench-settings/index.html +6 -5
  253. package/dist/service-host/preload.cjs +254 -0
  254. package/dist/service-host/service.html +10 -0
  255. package/dist/service-host/sourcemap-rewrite.cjs +58 -0
  256. package/dist/service-host/sync-api-patch.js +20 -0
  257. package/dist/service-host/sync-impls/menu-button.js +16 -0
  258. package/dist/service-host/sync-impls/storage.js +50 -0
  259. package/dist/service-host/sync-impls/system-info.js +54 -0
  260. package/dist/shared/appdata-accumulator.d.ts +95 -0
  261. package/dist/shared/appdata-accumulator.js +213 -0
  262. package/dist/shared/bridge-channels.d.ts +364 -0
  263. package/dist/shared/bridge-channels.js +54 -0
  264. package/dist/shared/constants.d.ts +0 -4
  265. package/dist/shared/constants.js +0 -4
  266. package/dist/shared/ipc-channels.d.ts +108 -1
  267. package/dist/shared/ipc-channels.js +127 -10
  268. package/dist/shared/ipc-schemas.d.ts +65 -2
  269. package/dist/shared/ipc-schemas.js +79 -3
  270. package/dist/shared/open-in-editor.d.ts +71 -0
  271. package/dist/shared/open-in-editor.js +138 -0
  272. package/dist/shared/simulator-api-metadata.d.ts +21 -0
  273. package/dist/shared/simulator-api-metadata.js +23 -0
  274. package/dist/shared/types.d.ts +2 -2
  275. package/dist/shared/vpath.d.ts +42 -0
  276. package/dist/shared/vpath.js +105 -0
  277. package/dist/simulator/assets/device-shell-DsdcNEkt.css +1 -0
  278. package/dist/simulator/assets/device-shell-vwYSOVrh.js +2 -0
  279. package/dist/simulator/assets/jsx-runtime-P6ZegaOf.js +2 -0
  280. package/dist/simulator/assets/simulator-DddliUL5.js +10 -0
  281. package/dist/simulator/assets/simulator-mini-app-BDNu5n26.js +2 -0
  282. package/dist/simulator/device-shell/menu-button-geometry.js +8 -0
  283. package/dist/simulator/simulator.html +2 -112
  284. package/package.json +9 -9
  285. package/dist/main/utils/disposable.d.ts +0 -18
  286. package/dist/main/utils/disposable.js +0 -67
  287. package/dist/renderer/assets/constants-DI382mTP.js +0 -2
  288. package/dist/renderer/assets/index-4lkyF644.js +0 -46
  289. package/dist/renderer/assets/input-D4byFOLS.js +0 -2
  290. package/dist/renderer/assets/ipc-transport-DqbRdZNO.css +0 -1
  291. package/dist/renderer/assets/popover-cxKrg_os.js +0 -2
  292. package/dist/renderer/assets/select-BgSkkdHW.js +0 -2
  293. package/dist/renderer/assets/settings-oD2K1jdT.js +0 -2
  294. package/dist/renderer/assets/workbenchSettings-CTNBpTft.js +0 -8
  295. package/dist/simulator/assets/simulator-CVOFTpSj.js +0 -9
@@ -0,0 +1,583 @@
1
+ /**
2
+ * Elements-panel forwarding — reflect the ACTIVE RENDER GUEST's live DOM tree in
3
+ * the right-panel Chrome DevTools front-end, which natively inspects the
4
+ * service-host (logic layer).
5
+ *
6
+ * ── Mechanism (no preload, no broker) ────────────────────────────────────────
7
+ * The DevTools front-end is a `devtools://` page with NO dimina preload, so we
8
+ * drive it through the same two-way poll bridge the network-forward path uses:
9
+ * • front-end → main : we wrap `InspectorFrontendHost.sendMessageToBackend` in
10
+ * the front-end realm. Commands whose method is in the RENDER domain set
11
+ * (DOM/CSS/Overlay/DOMSnapshot/DOMDebugger) are NOT passed to the original
12
+ * embedder channel — they're pushed onto `globalThis.__diminaElementsOutbound`
13
+ * and main drains that array (splice) on a poll. EVERY OTHER method
14
+ * (Runtime/Console/Page/Target/Emulation/…) calls through to the original, so
15
+ * the service-host inspection (Console, Sources) and crucially the safe-area
16
+ * `Emulation.setSafeAreaInsetsOverride` are untouched.
17
+ * • main → front-end : we re-inject responses + render-side EVENTS via
18
+ * `window.DevToolsAPI.dispatchMessage(json)` (chunked for large payloads —
19
+ * `DOM.getDocument` can be big — mirroring network-forward/index.ts).
20
+ *
21
+ * ── Why no broker / no safe-area changes ─────────────────────────────────────
22
+ * `webContents.debugger` is single-owner per wc, and the safe-area service has
23
+ * already `attach('1.3')`-ed each render guest. We REUSE that already-attached
24
+ * session (`sendCommand` + an extra `on('message')` listener on the SAME
25
+ * `wc.debugger`); we never attach a second session and never detach one we don't
26
+ * own. `DOM.enable`/`CSS.enable`/`Overlay.enable` do not reset the safe-area
27
+ * `Emulation` override, so this is purely additive. ONLY when a guest's debugger
28
+ * is NOT attached (safe-area degraded) do we `attach('1.3')` ourselves — tracked
29
+ * in a `Set<wc.id>` so dispose/guest-destroy detaches ONLY the sessions we own;
30
+ * safe-area's are never touched.
31
+ *
32
+ * ── Staleness (active-guest, NOT a generation counter) ───────────────────────
33
+ * A response/event is honoured only while its originating guest is STILL the
34
+ * active render guest — resolved fresh from the bridge per check (`isActiveWcId`),
35
+ * not snapshotted. So a late response or stray render EVENT from a guest that is
36
+ * no longer active is dropped (its in-flight command id is settled with an error
37
+ * so the front-end never leaks a pending request, and stale nodes never bleed into
38
+ * the new tree); and switching away and BACK to a previously-wired guest RESUMES
39
+ * its forwarding (a snapshot would strand it — that was bug B2).
40
+ *
41
+ * ── Degradation ──────────────────────────────────────────────────────────────
42
+ * Hook unavailable / `DevToolsAPI` missing / no active guest → routing is simply
43
+ * inert; the Elements panel falls back to the front-end's native service-host
44
+ * DOM (the prior behaviour). Everything is try/catch + feature-detect + bounded
45
+ * polling: it never throws, never blocks, never disturbs Console/Network/safe-area.
46
+ *
47
+ * This is a production feature (no env gate, default on for the native simulator).
48
+ * It deliberately re-implements the small pure helpers it needs (routing table,
49
+ * hook + dispatch scripts) rather than importing the throwaway spike file.
50
+ */
51
+ import { webContents as electronWebContents } from 'electron';
52
+ /**
53
+ * CDP domains that target the RENDER GUEST'S document tree. A command in one of
54
+ * these is intercepted and sent to the active render guest's debugger instead of
55
+ * the service host the front-end nominally inspects.
56
+ */
57
+ const RENDER_DOMAIN_PREFIXES = [
58
+ 'DOM.',
59
+ 'CSS.',
60
+ 'Overlay.',
61
+ 'DOMSnapshot.',
62
+ 'DOMDebugger.',
63
+ ];
64
+ /**
65
+ * Decide where a front-end CDP `method` is routed.
66
+ *
67
+ * render → DOM./CSS./Overlay./DOMSnapshot./DOMDebugger. (the Elements tree)
68
+ * service → EVERYTHING ELSE, and in particular:
69
+ * • Emulation.* — RED LINE: routing this to the render guest would let the
70
+ * front-end overwrite the safe-area service's `setSafeAreaInsetsOverride`.
71
+ * It MUST stay on the service-host inspection path (pass-through).
72
+ * • Runtime./Console./Debugger./Network./Page./Target./Input./Profiler./Log.
73
+ * — the service host owns these; leave them on the original channel.
74
+ *
75
+ * Pure (no I/O). The hook script inlines an equivalent prefix test driven by the
76
+ * same `RENDER_DOMAIN_PREFIXES` literal, so the two cannot silently drift.
77
+ */
78
+ export function routeByDomain(method) {
79
+ for (const prefix of RENDER_DOMAIN_PREFIXES) {
80
+ if (method.startsWith(prefix))
81
+ return 'render';
82
+ }
83
+ return 'service';
84
+ }
85
+ /** True for an event method we re-inject from the render guest into the panel. */
86
+ export function isRenderEventMethod(method) {
87
+ return routeByDomain(method) === 'render';
88
+ }
89
+ // ── front-end injection (the front-end → main half of the bridge) ────────────
90
+ /**
91
+ * The JS injected into the DevTools front-end realm. Idempotent (sentinel guard).
92
+ * Wraps `InspectorFrontendHost.sendMessageToBackend`: a RENDER-domain command is
93
+ * pushed onto `globalThis.__diminaElementsOutbound` (drained by main) and NOT
94
+ * forwarded to the original embedder channel (main answers it from the render
95
+ * guest); every other command calls through to the original (service-host path).
96
+ *
97
+ * Returns `'installed'` / `'already'` on success, `'partial'` while the embedder
98
+ * global is not yet present (so the caller retries), `'error:…'` on a real fault.
99
+ */
100
+ export function buildElementsHookScript() {
101
+ const prefixes = JSON.stringify(RENDER_DOMAIN_PREFIXES);
102
+ return `(function(){try{
103
+ if (globalThis.__diminaElementsHookInstalled) return 'already';
104
+ var OUT = (globalThis.__diminaElementsOutbound = globalThis.__diminaElementsOutbound || []);
105
+ var PREFIXES = ${prefixes};
106
+ function isRender(method){
107
+ if (!method) return false;
108
+ for (var i=0;i<PREFIXES.length;i++){ if (method.indexOf(PREFIXES[i])===0) return true; }
109
+ return false;
110
+ }
111
+ var IFH = globalThis.InspectorFrontendHost;
112
+ if (IFH && typeof IFH.sendMessageToBackend === 'function' && !IFH.__diminaElementsWrapped){
113
+ var origSend = IFH.sendMessageToBackend.bind(IFH);
114
+ IFH.sendMessageToBackend = function(message){
115
+ try {
116
+ var m = (typeof message === 'string') ? JSON.parse(message) : message;
117
+ if (m && isRender(m.method)){
118
+ // Intercept: hand it to main to route at the render guest. Do NOT
119
+ // call the original embedder channel (would hit the service host).
120
+ OUT.push({ id: (m && typeof m.id === 'number') ? m.id : null,
121
+ method: m.method, params: m.params || {},
122
+ sessionId: (m && m.sessionId) ? m.sessionId : null });
123
+ return;
124
+ }
125
+ } catch(_){ /* fall through to original on any parse hiccup */ }
126
+ return origSend(message);
127
+ };
128
+ IFH.__diminaElementsWrapped = true;
129
+ globalThis.__diminaElementsHookInstalled = true;
130
+ return 'installed';
131
+ }
132
+ return 'partial';
133
+ }catch(e){ return 'error:' + (e && e.message); }})()`;
134
+ }
135
+ // ── main → front-end dispatch (mirrored from network-forward/index.ts) ────────
136
+ // network-forward keeps these file-private and the task forbids touching it, so
137
+ // they're re-implemented here. Keep the chunk contract in sync if that changes.
138
+ const PROBE_DEVTOOLS_API = `(window.DevToolsAPI && typeof window.DevToolsAPI.dispatchMessage === 'function')`;
139
+ /** A single dispatch payload may not exceed this many UTF-16 chars; chunk above. */
140
+ const MAX_SINGLE_DISPATCH_CHARS = 1_000_000;
141
+ const CHUNK_CHARS = 256 * 1024;
142
+ /** Dispatch ONE small CDP message (response or event) into the front-end. */
143
+ function buildDispatchScript(message) {
144
+ return `(()=>{try{`
145
+ + `if(!${PROBE_DEVTOOLS_API})return false;`
146
+ + `window.DevToolsAPI.dispatchMessage(JSON.parse(${JSON.stringify(message)}));`
147
+ + `return true;`
148
+ + `}catch(_){return false}})()`;
149
+ }
150
+ /**
151
+ * Dispatch one LARGE message via `dispatchMessageChunk`: the FIRST chunk carries
152
+ * the total size, every SUBSEQUENT chunk omits the second arg (Chromium's
153
+ * continuation contract). Returns false when the chunk API isn't present yet.
154
+ */
155
+ function buildChunkedDispatchScript(chunks, totalSize) {
156
+ const arr = JSON.stringify(chunks);
157
+ return `(()=>{try{`
158
+ + `if(!(window.DevToolsAPI&&typeof window.DevToolsAPI.dispatchMessageChunk==='function'))return false;`
159
+ + `const cs=JSON.parse(${JSON.stringify(arr)});`
160
+ + `for(let i=0;i<cs.length;i++){`
161
+ + `try{`
162
+ + `if(i===0){window.DevToolsAPI.dispatchMessageChunk(cs[i], ${totalSize})}`
163
+ + `else{window.DevToolsAPI.dispatchMessageChunk(cs[i])}`
164
+ + `}catch(_){}`
165
+ + `}`
166
+ + `return true;`
167
+ + `}catch(_){return false}})()`;
168
+ }
169
+ /** Script that nudges the front-end to discard its document and lazily re-pull. */
170
+ function buildDocumentUpdatedScript() {
171
+ const msg = JSON.stringify({ method: 'DOM.documentUpdated', params: {} });
172
+ return buildDispatchScript(msg);
173
+ }
174
+ const DRAIN_INTERVAL_MS = 150;
175
+ /** Bounded retry for the front-end hook install (front-end boots asynchronously). */
176
+ const INSTALL_POLL_TRIES = 80;
177
+ const INSTALL_POLL_INTERVAL_MS = 50;
178
+ /**
179
+ * Install Elements forwarding on a DevTools front-end host wc. Returns a disposer
180
+ * (`stop`) that clears timers, unsubscribes render events, detaches ONLY the
181
+ * debugger sessions this feature attached, and removes every listener it added.
182
+ *
183
+ * Best-effort + defensive throughout: a destroyed wc ends the feature; every
184
+ * executeJavaScript / sendCommand is wrapped so a torn-down guest never throws
185
+ * and an in-flight command always settles (we dispatch an error back rather than
186
+ * leaving the front-end pending).
187
+ */
188
+ export function installElementsForward(deps) {
189
+ const { devtoolsWc, bridge } = deps;
190
+ let disposed = false;
191
+ let installTimer = null;
192
+ let drainTimer = null;
193
+ // Staleness is keyed on the CURRENT active render guest, resolved fresh from the
194
+ // bridge per check — NOT a generation snapshot. An event/response is honoured
195
+ // only while its originating guest is still the active one, so switching away
196
+ // and BACK to a previously-wired guest RESUMES its forwarding (a snapshot would
197
+ // strand it forever — that was bug B2). It also means destroying some OTHER
198
+ // (non-active) guest never stales the active guest's in-flight commands.
199
+ const isActiveWcId = (id) => {
200
+ const a = activeRenderWc();
201
+ return a != null && a.id === id;
202
+ };
203
+ // Render guests we've added our `on('message')` listener to (keyed wc.id →
204
+ // cleanup) so a re-resolve of the same guest doesn't double-subscribe.
205
+ const wiredGuests = new Map();
206
+ // Debugger sessions THIS feature attached (safe-area was degraded). dispose /
207
+ // guest-destroy detaches ONLY these; sessions safe-area owns are never touched.
208
+ const selfAttached = new Set();
209
+ const stop = () => {
210
+ disposed = true;
211
+ if (installTimer) {
212
+ clearInterval(installTimer);
213
+ installTimer = null;
214
+ }
215
+ if (drainTimer) {
216
+ clearInterval(drainTimer);
217
+ drainTimer = null;
218
+ }
219
+ for (const cleanup of wiredGuests.values()) {
220
+ try {
221
+ cleanup();
222
+ }
223
+ catch { /* guest gone */ }
224
+ }
225
+ wiredGuests.clear();
226
+ detachSelfAttached();
227
+ };
228
+ /** Detach every session we own; leave safe-area's alone. */
229
+ function detachSelfAttached() {
230
+ for (const wcId of selfAttached) {
231
+ const wc = wcFromId(wcId);
232
+ if (!wc)
233
+ continue;
234
+ try {
235
+ if (!wc.isDestroyed() && wc.debugger.isAttached())
236
+ wc.debugger.detach();
237
+ }
238
+ catch { /* already detached / destroyed */ }
239
+ }
240
+ selfAttached.clear();
241
+ }
242
+ // ── main → front-end dispatch ──────────────────────────────────────────────
243
+ function dispatchToFrontend(message) {
244
+ if (disposed || devtoolsWc.isDestroyed())
245
+ return;
246
+ let json;
247
+ try {
248
+ json = JSON.stringify(message);
249
+ }
250
+ catch {
251
+ return;
252
+ }
253
+ if (json.length > MAX_SINGLE_DISPATCH_CHARS) {
254
+ const chunks = [];
255
+ for (let i = 0; i < json.length; i += CHUNK_CHARS) {
256
+ chunks.push(json.slice(i, i + CHUNK_CHARS));
257
+ }
258
+ let script;
259
+ try {
260
+ script = buildChunkedDispatchScript(chunks, json.length);
261
+ }
262
+ catch {
263
+ return;
264
+ }
265
+ devtoolsWc.executeJavaScript(script, true).catch(() => { });
266
+ return;
267
+ }
268
+ let script;
269
+ try {
270
+ script = buildDispatchScript(json);
271
+ }
272
+ catch {
273
+ return;
274
+ }
275
+ devtoolsWc.executeJavaScript(script, true).catch(() => { });
276
+ }
277
+ /** Tell the front-end its document is stale → it re-pulls lazily (routed). */
278
+ function pushDocumentUpdated() {
279
+ if (disposed || devtoolsWc.isDestroyed())
280
+ return;
281
+ let script;
282
+ try {
283
+ script = buildDocumentUpdatedScript();
284
+ }
285
+ catch {
286
+ return;
287
+ }
288
+ devtoolsWc.executeJavaScript(script, true).catch(() => { });
289
+ }
290
+ /**
291
+ * Reply to a front-end command id, passing the ORIGINAL id + sessionId straight
292
+ * through (no mapping). Only the front-end-supplied sessionId is echoed back.
293
+ */
294
+ function replyResult(cmd, result) {
295
+ const msg = { id: cmd.id, result };
296
+ if (cmd.sessionId)
297
+ msg.sessionId = cmd.sessionId;
298
+ dispatchToFrontend(msg);
299
+ }
300
+ function replyError(cmd, message) {
301
+ const msg = { id: cmd.id, error: { code: -32000, message } };
302
+ if (cmd.sessionId)
303
+ msg.sessionId = cmd.sessionId;
304
+ dispatchToFrontend(msg);
305
+ }
306
+ // ── webContents lookup (id → wc), tolerant of fakes/teardown ────────────────
307
+ function wcFromId(id) {
308
+ try {
309
+ return electronWebContents?.fromId?.(id) ?? null;
310
+ }
311
+ catch {
312
+ return null;
313
+ }
314
+ }
315
+ // ── render-guest CDP session (reuse safe-area's; self-attach only if needed) ─
316
+ /** The active render guest, re-resolved fresh (pool/page swaps go stale). */
317
+ function activeRenderWc() {
318
+ try {
319
+ const wc = bridge.getActiveRenderWc(deps.appId);
320
+ return wc && !wc.isDestroyed() ? wc : null;
321
+ }
322
+ catch {
323
+ return null;
324
+ }
325
+ }
326
+ /**
327
+ * Ensure the guest's debugger is usable. Reuse the already-attached session if
328
+ * safe-area attached it; only `attach('1.3')` ourselves when nobody has — and
329
+ * record that wc in `selfAttached` so we (and only we) detach it later. Returns
330
+ * false when the debugger can't be made usable.
331
+ */
332
+ function ensureGuestDebugger(wc) {
333
+ try {
334
+ if (wc.debugger.isAttached())
335
+ return true;
336
+ }
337
+ catch {
338
+ return false;
339
+ }
340
+ try {
341
+ wc.debugger.attach('1.3');
342
+ selfAttached.add(wc.id);
343
+ return true;
344
+ }
345
+ catch {
346
+ // Either someone else just attached (race → it IS usable) or attach truly
347
+ // failed. Treat "already attached" as success, anything else as failure.
348
+ try {
349
+ return wc.debugger.isAttached();
350
+ }
351
+ catch {
352
+ return false;
353
+ }
354
+ }
355
+ }
356
+ /**
357
+ * Add our render-event re-injection listener to a guest's debugger ONCE. DOM./
358
+ * CSS./Overlay./DOMSnapshot./DOMDebugger. EVENTS (no id) from the CURRENT
359
+ * generation are dispatched into the front-end so the Elements panel updates
360
+ * live; events arriving after the generation moved on are dropped. The listener
361
+ * is removed when the guest wc is destroyed (and on stop()).
362
+ */
363
+ function wireGuestEvents(wc) {
364
+ if (wiredGuests.has(wc.id))
365
+ return;
366
+ const onMessage = (_event, method, params) => {
367
+ if (disposed)
368
+ return;
369
+ // Honour events only while this guest is STILL the active one — checked per
370
+ // event, so re-activating a previously-wired guest resumes forwarding.
371
+ if (!isActiveWcId(wc.id))
372
+ return;
373
+ if (isRenderEventMethod(method)) {
374
+ dispatchToFrontend({ method, params });
375
+ }
376
+ };
377
+ try {
378
+ wc.debugger.on('message', onMessage);
379
+ }
380
+ catch {
381
+ return;
382
+ }
383
+ const onDestroyed = () => {
384
+ const cleanup = wiredGuests.get(wc.id);
385
+ if (cleanup) {
386
+ wiredGuests.delete(wc.id);
387
+ try {
388
+ cleanup();
389
+ }
390
+ catch { /* gone */ }
391
+ }
392
+ // A destroyed guest is no longer the active one, so its in-flight commands
393
+ // fail `isActiveWcId` and settle as errors on their own — no global bump
394
+ // (which would wrongly stale OTHER, still-active guests' commands: bug MINOR-3).
395
+ // If we own this wc's session there is nothing left to detach; drop it.
396
+ selfAttached.delete(wc.id);
397
+ };
398
+ let closedSub;
399
+ try {
400
+ // Route the guest teardown through the connection registry's `'closed'`
401
+ // event when present. Render guests are NEVER pool-reset, so `'closed'`
402
+ // (fires only on real wc destroy) is the correct lifetime — and crucially
403
+ // `on('closed')` returns a handle whose `dispose()` REMOVES the listener
404
+ // WITHOUT firing it, matching the original `removeListener` semantics.
405
+ // (`own()` would fire `onDestroyed` on release AND mutate `wiredGuests`
406
+ // mid-drain in stop() — wrong here; see foundation.md §4.3.) Same
407
+ // try/catch guards a fake/minimal wc that lacks once/emitter wiring.
408
+ if (deps.connections)
409
+ closedSub = deps.connections.acquire(wc).on('closed', onDestroyed);
410
+ else
411
+ wc.once('destroyed', onDestroyed);
412
+ }
413
+ catch { /* fake/minimal wc */ }
414
+ wiredGuests.set(wc.id, () => {
415
+ try {
416
+ wc.debugger.removeListener('message', onMessage);
417
+ }
418
+ catch { /* gone */ }
419
+ try {
420
+ closedSub?.dispose();
421
+ }
422
+ catch { /* gone */ }
423
+ try {
424
+ wc.removeListener('destroyed', onDestroyed);
425
+ }
426
+ catch { /* gone */ }
427
+ });
428
+ }
429
+ /** enable DOM/CSS/Overlay + wire events on a guest. Best-effort. */
430
+ function primeGuest(wc) {
431
+ if (!ensureGuestDebugger(wc))
432
+ return;
433
+ wireGuestEvents(wc);
434
+ for (const domain of ['DOM.enable', 'CSS.enable', 'Overlay.enable']) {
435
+ wc.debugger.sendCommand(domain).catch(() => { });
436
+ }
437
+ }
438
+ // ── front-end → render command routing ─────────────────────────────────────
439
+ function routeCommand(cmd) {
440
+ const wc = activeRenderWc();
441
+ if (!wc) {
442
+ replyError(cmd, 'no active render guest');
443
+ return;
444
+ }
445
+ if (!ensureGuestDebugger(wc)) {
446
+ replyError(cmd, 'render guest debugger unavailable');
447
+ return;
448
+ }
449
+ wireGuestEvents(wc);
450
+ // The wc this command is dispatched to. A response that resolves after the
451
+ // active guest changed (this wc is no longer active) is for a tree the
452
+ // front-end has abandoned: settle the id with an error (no pending leak) but
453
+ // do NOT feed its result into the new tree.
454
+ const cmdWcId = wc.id;
455
+ wc.debugger
456
+ .sendCommand(cmd.method, (cmd.params ?? {}))
457
+ .then((result) => {
458
+ if (disposed)
459
+ return;
460
+ if (!isActiveWcId(cmdWcId)) {
461
+ replyError(cmd, 'stale render generation');
462
+ return;
463
+ }
464
+ replyResult(cmd, result);
465
+ })
466
+ .catch((err) => {
467
+ if (disposed)
468
+ return;
469
+ replyError(cmd, err instanceof Error ? err.message : String(err));
470
+ });
471
+ }
472
+ /** Process a drained batch of front-end commands. */
473
+ function handleOutbound(batch) {
474
+ if (!Array.isArray(batch))
475
+ return;
476
+ for (const raw of batch) {
477
+ if (!raw || typeof raw !== 'object')
478
+ continue;
479
+ const cmd = raw;
480
+ if (typeof cmd.method !== 'string')
481
+ continue;
482
+ routeCommand(cmd);
483
+ }
484
+ }
485
+ // ── follow the active guest across page switches ───────────────────────────
486
+ const onRenderEvent = (event) => {
487
+ if (disposed)
488
+ return;
489
+ if (event.kind !== 'activePage')
490
+ return;
491
+ // Active guest changed: late responses/events from the previous guest now
492
+ // fail `isActiveWcId` and are discarded; the (re-)activated guest's traffic
493
+ // is honoured again (no snapshot to strand it).
494
+ const wc = activeRenderWc();
495
+ if (!wc)
496
+ return;
497
+ primeGuest(wc);
498
+ // Front-end (which eager-pulls DOM at bootstrap) re-pulls against the now
499
+ // current guest; if the user is already on Elements it refreshes live.
500
+ pushDocumentUpdated();
501
+ };
502
+ const unsubscribeRenderEvents = bridge.onRenderEvent(onRenderEvent);
503
+ // ── startup: install hook (retry until embedder exists), then drain ─────────
504
+ const onReady = () => {
505
+ if (disposed)
506
+ return;
507
+ let tries = 0;
508
+ installTimer = setInterval(() => {
509
+ tries++;
510
+ if (disposed || devtoolsWc.isDestroyed()) {
511
+ stop();
512
+ return;
513
+ }
514
+ devtoolsWc
515
+ .executeJavaScript(buildElementsHookScript())
516
+ .then((status) => {
517
+ if (disposed)
518
+ return;
519
+ if (status === 'installed' || status === 'already') {
520
+ if (installTimer) {
521
+ clearInterval(installTimer);
522
+ installTimer = null;
523
+ }
524
+ // Prime the current guest, then nudge the front-end to (re-)pull DOM
525
+ // so the bootstrap document.getDocument is routed at the render guest.
526
+ // We deliberately do NOT force showView('elements') — the panel stays
527
+ // on the user-preferred Console default; the eager DOM pull (and any
528
+ // later Elements click) is already routed to render.
529
+ const wc = activeRenderWc();
530
+ if (wc)
531
+ primeGuest(wc);
532
+ pushDocumentUpdated();
533
+ }
534
+ })
535
+ .catch(() => { });
536
+ if (tries > INSTALL_POLL_TRIES && installTimer) {
537
+ clearInterval(installTimer);
538
+ installTimer = null;
539
+ }
540
+ }, INSTALL_POLL_INTERVAL_MS);
541
+ // Poll-drain the outbound command queue.
542
+ drainTimer = setInterval(() => {
543
+ if (disposed || devtoolsWc.isDestroyed()) {
544
+ stop();
545
+ return;
546
+ }
547
+ devtoolsWc
548
+ .executeJavaScript('(globalThis.__diminaElementsOutbound ? __diminaElementsOutbound.splice(0) : [])')
549
+ .then(handleOutbound)
550
+ .catch(() => { });
551
+ }, DRAIN_INTERVAL_MS);
552
+ };
553
+ if (devtoolsWc.isLoading()) {
554
+ devtoolsWc.once('dom-ready', onReady);
555
+ }
556
+ else {
557
+ onReady();
558
+ }
559
+ let devtoolsClosedSub;
560
+ try {
561
+ // Devtools front-end wc is never pool-reset → use `'closed'` (fires only on
562
+ // real destroy). `on('closed')` dispose() removes WITHOUT firing, so the
563
+ // returned teardown releases it then calls `stop()` directly — no stale
564
+ // `stop` disposers accumulate across re-install on a surviving devtoolsWc.
565
+ if (deps.connections)
566
+ devtoolsClosedSub = deps.connections.acquire(devtoolsWc).on('closed', stop);
567
+ else
568
+ devtoolsWc.once('destroyed', stop);
569
+ }
570
+ catch { /* fake/minimal wc */ }
571
+ return () => {
572
+ try {
573
+ unsubscribeRenderEvents();
574
+ }
575
+ catch { /* already gone */ }
576
+ try {
577
+ devtoolsClosedSub?.dispose();
578
+ }
579
+ catch { /* already gone */ }
580
+ stop();
581
+ };
582
+ }
583
+ //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  /** Layout constants (px) */
2
2
  export declare const SPLITTER_W = 4;
3
3
  /**
4
- * X coordinate where the right panel starts (simulator width + splitter).
4
+ * X coordinate where the legacy right-side overlay starts.
5
5
  */
6
6
  export declare function getRightX(simWidth: number): number;
7
7
  export interface Bounds {
@@ -15,6 +15,28 @@ export declare function computeRightPanelBounds(contentWidth: number, contentHei
15
15
  * Compute bounds for DevTools view (same as right panel, overlays it).
16
16
  */
17
17
  export declare function computeSimulatorBounds(contentWidth: number, contentHeight: number, simWidth: number, headerHeight: number): Bounds;
18
+ /**
19
+ * NATIVE-HOST ONLY. Translate the renderer-measured simulator panel REGION rect
20
+ * (CSS px from the main window content top-left — the flex:1 placeholder slot)
21
+ * into the params needed to overlay the simulator `WebContentsView` on it.
22
+ *
23
+ * The renderer reports `getBoundingClientRect()` of the panel region. Because
24
+ * the simulator is a top-level overlay WebContentsView (not a nested guest),
25
+ * that CSS-px rect maps directly to `setBounds` DIP — no conversion. We just
26
+ * round to integers (setBounds rejects fractionals) and clamp width/height
27
+ * non-negative. The WCV fills the region as a plain rectangle (no native border
28
+ * radius); DeviceShell draws the rounded phone and scrolls it inside. `zoomFactor`
29
+ * feeds `webContents.setZoomFactor`.
30
+ */
31
+ export declare function computeNativeSimulatorViewParams(rect: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ }, zoomPercent: number): {
37
+ bounds: Bounds;
38
+ zoomFactor: number;
39
+ };
18
40
  export declare const SETTINGS_W = 320;
19
41
  export declare function computeSettingsBounds(contentWidth: number, contentHeight: number, headerHeight: number): Bounds;
20
42
  export declare function computePopoverBounds(contentWidth: number, contentHeight: number, headerHeight: number): Bounds;
@@ -1,7 +1,7 @@
1
1
  /** Layout constants (px) */
2
2
  export const SPLITTER_W = 4;
3
3
  /**
4
- * X coordinate where the right panel starts (simulator width + splitter).
4
+ * X coordinate where the legacy right-side overlay starts.
5
5
  */
6
6
  export function getRightX(simWidth) {
7
7
  return simWidth + SPLITTER_W;
@@ -21,12 +21,37 @@ export function computeRightPanelBounds(contentWidth, contentHeight, simWidth, h
21
21
  export function computeSimulatorBounds(contentWidth, contentHeight, simWidth, headerHeight) {
22
22
  return computeRightPanelBounds(contentWidth, contentHeight, simWidth, headerHeight);
23
23
  }
24
+ /**
25
+ * NATIVE-HOST ONLY. Translate the renderer-measured simulator panel REGION rect
26
+ * (CSS px from the main window content top-left — the flex:1 placeholder slot)
27
+ * into the params needed to overlay the simulator `WebContentsView` on it.
28
+ *
29
+ * The renderer reports `getBoundingClientRect()` of the panel region. Because
30
+ * the simulator is a top-level overlay WebContentsView (not a nested guest),
31
+ * that CSS-px rect maps directly to `setBounds` DIP — no conversion. We just
32
+ * round to integers (setBounds rejects fractionals) and clamp width/height
33
+ * non-negative. The WCV fills the region as a plain rectangle (no native border
34
+ * radius); DeviceShell draws the rounded phone and scrolls it inside. `zoomFactor`
35
+ * feeds `webContents.setZoomFactor`.
36
+ */
37
+ export function computeNativeSimulatorViewParams(rect, zoomPercent) {
38
+ const zoomFactor = zoomPercent / 100;
39
+ return {
40
+ bounds: {
41
+ x: Math.round(rect.x),
42
+ y: Math.round(rect.y),
43
+ width: Math.max(0, Math.round(rect.width)),
44
+ height: Math.max(0, Math.round(rect.height)),
45
+ },
46
+ zoomFactor,
47
+ };
48
+ }
24
49
  export const SETTINGS_W = 320;
25
50
  export function computeSettingsBounds(contentWidth, contentHeight, headerHeight) {
26
51
  return {
27
52
  x: Math.max(0, contentWidth - SETTINGS_W),
28
53
  y: headerHeight,
29
- width: SETTINGS_W,
54
+ width: Math.min(SETTINGS_W, Math.max(1, contentWidth)),
30
55
  height: Math.max(1, contentHeight - headerHeight),
31
56
  };
32
57
  }
@@ -34,7 +59,7 @@ export function computePopoverBounds(contentWidth, contentHeight, headerHeight)
34
59
  return {
35
60
  x: 0,
36
61
  y: headerHeight,
37
- width: contentWidth,
62
+ width: Math.max(1, contentWidth),
38
63
  height: contentHeight - headerHeight,
39
64
  };
40
65
  }
@@ -13,4 +13,5 @@
13
13
  */
14
14
  export { startMcpServer } from './server.js';
15
15
  export { getMcpStatus, type McpRuntimeStatus } from './status.js';
16
+ export { setNativeHost, setActiveBridgeId, setNativeOverviewProvider, getNativeOverviewProvider, } from './target-manager.js';
16
17
  //# sourceMappingURL=index.d.ts.map