@dimina-kit/devtools 0.4.0 → 0.5.0

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 (507) hide show
  1. package/README.md +51 -660
  2. package/dist/main/api.d.ts +2 -1
  3. package/dist/main/app/app.d.ts +41 -12
  4. package/dist/main/app/app.js +299 -514
  5. package/dist/main/app/bootstrap.d.ts +8 -5
  6. package/dist/main/app/bootstrap.js +15 -15
  7. package/dist/main/app/editor-view.d.ts +21 -0
  8. package/dist/main/app/editor-view.js +71 -0
  9. package/dist/main/app/global-mirrors.d.ts +23 -0
  10. package/dist/main/app/global-mirrors.js +37 -0
  11. package/dist/main/app/host-sidebar-default.d.ts +19 -0
  12. package/dist/main/app/host-sidebar-default.js +44 -0
  13. package/dist/main/app/lifecycle.d.ts +12 -1
  14. package/dist/main/app/lifecycle.js +27 -1
  15. package/dist/main/app/menu-setup.d.ts +13 -0
  16. package/dist/main/app/menu-setup.js +49 -0
  17. package/dist/main/app/native-overview.d.ts +1 -1
  18. package/dist/main/app/open-project-ipc.d.ts +13 -0
  19. package/dist/main/app/open-project-ipc.js +21 -0
  20. package/dist/main/app/project-list-surface.d.ts +31 -0
  21. package/dist/main/app/project-list-surface.js +20 -0
  22. package/dist/main/app/project-window.d.ts +36 -0
  23. package/dist/main/app/project-window.js +93 -0
  24. package/dist/main/app/servers.d.ts +17 -0
  25. package/dist/main/app/servers.js +60 -0
  26. package/dist/main/app/ui-extension-targets.d.ts +42 -0
  27. package/dist/main/app/ui-extension-targets.js +101 -0
  28. package/dist/main/app/window-close-reveal.harness.d.ts +34 -0
  29. package/dist/main/app/window-close-reveal.harness.js +65 -0
  30. package/dist/main/app/window-events.d.ts +15 -0
  31. package/dist/main/app/window-events.js +45 -0
  32. package/dist/main/app/window-runtime-services.d.ts +41 -0
  33. package/dist/main/app/window-runtime-services.js +197 -0
  34. package/dist/main/app/workbench-modules.d.ts +24 -0
  35. package/dist/main/app/workbench-modules.js +51 -0
  36. package/dist/main/app/workbench-window.d.ts +85 -0
  37. package/dist/main/app/workbench-window.js +310 -0
  38. package/dist/main/index.bundle.js +11712 -9986
  39. package/dist/main/index.js +49 -1
  40. package/dist/main/ipc/app-lifecycle.d.ts +1 -31
  41. package/dist/main/ipc/app-lifecycle.js +1 -53
  42. package/dist/main/ipc/app.d.ts +4 -1
  43. package/dist/main/ipc/app.js +4 -3
  44. package/dist/main/ipc/bridge-router.d.ts +19 -116
  45. package/dist/main/ipc/bridge-router.js +28 -2128
  46. package/dist/main/ipc/device-picker.d.ts +16 -0
  47. package/dist/main/ipc/device-picker.js +27 -0
  48. package/dist/main/ipc/index.d.ts +5 -0
  49. package/dist/main/ipc/index.js +5 -0
  50. package/dist/main/ipc/internal-devtools.d.ts +16 -0
  51. package/dist/main/ipc/internal-devtools.js +10 -0
  52. package/dist/main/ipc/page-scroll.d.ts +1 -13
  53. package/dist/main/ipc/page-scroll.js +1 -16
  54. package/dist/main/ipc/popover.d.ts +4 -1
  55. package/dist/main/ipc/popover.js +26 -19
  56. package/dist/main/ipc/project-create.d.ts +16 -0
  57. package/dist/main/ipc/project-create.js +27 -0
  58. package/dist/main/ipc/project-fs.d.ts +38 -3
  59. package/dist/main/ipc/project-fs.js +53 -22
  60. package/dist/main/ipc/projects.d.ts +3 -3
  61. package/dist/main/ipc/projects.js +47 -11
  62. package/dist/main/ipc/session-listener-bag.d.ts +1 -40
  63. package/dist/main/ipc/session-listener-bag.js +1 -39
  64. package/dist/main/ipc/session.d.ts +4 -1
  65. package/dist/main/ipc/session.js +26 -26
  66. package/dist/main/ipc/settings.d.ts +4 -1
  67. package/dist/main/ipc/settings.js +17 -19
  68. package/dist/main/ipc/simulator-module.d.ts +9 -3
  69. package/dist/main/ipc/simulator-module.js +13 -10
  70. package/dist/main/ipc/simulator.d.ts +4 -1
  71. package/dist/main/ipc/simulator.js +12 -18
  72. package/dist/main/ipc/tooltip.d.ts +14 -0
  73. package/dist/main/ipc/tooltip.js +29 -0
  74. package/dist/main/ipc/views.d.ts +19 -2
  75. package/dist/main/ipc/views.js +76 -8
  76. package/dist/main/runtime/devtools-backend-before-quit.harness.d.ts +43 -0
  77. package/dist/main/runtime/devtools-backend-before-quit.harness.js +87 -0
  78. package/dist/main/runtime/devtools-backend.js +60 -4
  79. package/dist/main/runtime/devtools-runtime-mock.harness.d.ts +21 -0
  80. package/dist/main/runtime/devtools-runtime-mock.harness.js +313 -0
  81. package/dist/main/runtime/miniapp-runtime.d.ts +91 -22
  82. package/dist/main/services/app-services.d.ts +62 -0
  83. package/dist/main/services/app-services.js +64 -0
  84. package/dist/main/services/automation/connection-target.d.ts +36 -0
  85. package/dist/main/services/automation/connection-target.js +29 -0
  86. package/dist/main/services/automation/console-bridge.d.ts +28 -0
  87. package/dist/main/services/automation/console-bridge.js +91 -0
  88. package/dist/main/services/automation/handlers/app.js +4 -4
  89. package/dist/main/services/automation/handlers/element.js +55 -21
  90. package/dist/main/services/automation/index.d.ts +12 -1
  91. package/dist/main/services/automation/index.js +54 -133
  92. package/dist/main/services/cdp-session/index.d.ts +87 -0
  93. package/dist/main/services/cdp-session/index.js +173 -0
  94. package/dist/main/services/compile-standby.js +4 -0
  95. package/dist/main/services/console-forward/cdp-inject.d.ts +18 -0
  96. package/dist/main/services/console-forward/cdp-inject.js +30 -0
  97. package/dist/main/services/console-forward/global-console-mirror.d.ts +33 -0
  98. package/dist/main/services/console-forward/global-console-mirror.js +71 -0
  99. package/dist/main/services/console-forward/global-diagnostics-mirror.d.ts +33 -0
  100. package/dist/main/services/console-forward/global-diagnostics-mirror.js +73 -0
  101. package/dist/main/services/console-forward/index.d.ts +1 -46
  102. package/dist/main/services/console-forward/index.js +1 -185
  103. package/dist/main/services/console-forward/internal-log.d.ts +2 -0
  104. package/dist/main/services/console-forward/internal-log.js +2 -0
  105. package/dist/main/services/console-forward/open-gated-relay.d.ts +67 -0
  106. package/dist/main/services/console-forward/open-gated-relay.js +55 -0
  107. package/dist/main/services/default-adapter.js +1 -1
  108. package/dist/main/services/diagnostics/index.d.ts +1 -48
  109. package/dist/main/services/diagnostics/index.js +1 -60
  110. package/dist/main/services/dimina-resource-server.d.ts +1 -6
  111. package/dist/main/services/dimina-resource-server.js +1 -98
  112. package/dist/main/services/elements-forward/index.d.ts +132 -15
  113. package/dist/main/services/elements-forward/index.js +155 -304
  114. package/dist/main/services/fs-bridge-protocol.d.ts +61 -0
  115. package/dist/main/services/fs-bridge-protocol.js +34 -0
  116. package/dist/main/services/fs-watch-sse.d.ts +40 -0
  117. package/dist/main/services/fs-watch-sse.js +113 -0
  118. package/dist/main/services/http-json.d.ts +9 -0
  119. package/dist/main/services/http-json.js +6 -0
  120. package/dist/main/services/layout/index.d.ts +11 -0
  121. package/dist/main/services/layout/index.js +23 -0
  122. package/dist/main/services/mcp/connection-owner.d.ts +38 -0
  123. package/dist/main/services/mcp/connection-owner.js +79 -0
  124. package/dist/main/services/mcp/index.d.ts +3 -1
  125. package/dist/main/services/mcp/index.js +4 -3
  126. package/dist/main/services/mcp/opened-project.d.ts +88 -0
  127. package/dist/main/services/mcp/opened-project.js +60 -0
  128. package/dist/main/services/mcp/server.d.ts +2 -1
  129. package/dist/main/services/mcp/server.js +29 -4
  130. package/dist/main/services/mcp/target-manager.d.ts +71 -23
  131. package/dist/main/services/mcp/target-manager.js +269 -138
  132. package/dist/main/services/mcp/target-selection.d.ts +47 -0
  133. package/dist/main/services/mcp/target-selection.js +71 -0
  134. package/dist/main/services/mcp/tools/context-tools.js +20 -5
  135. package/dist/main/services/mcp/tools/project-tools.d.ts +72 -0
  136. package/dist/main/services/mcp/tools/project-tools.js +133 -0
  137. package/dist/main/services/module.d.ts +13 -5
  138. package/dist/main/services/network-forward/body-cache.d.ts +72 -0
  139. package/dist/main/services/network-forward/body-cache.js +179 -0
  140. package/dist/main/services/network-forward/frontend-dispatch.d.ts +91 -0
  141. package/dist/main/services/network-forward/frontend-dispatch.js +148 -0
  142. package/dist/main/services/network-forward/global-body-gate.d.ts +46 -0
  143. package/dist/main/services/network-forward/global-body-gate.js +93 -0
  144. package/dist/main/services/network-forward/global-mirror-test-fixtures.d.ts +48 -0
  145. package/dist/main/services/network-forward/global-mirror-test-fixtures.js +96 -0
  146. package/dist/main/services/network-forward/http.d.ts +47 -0
  147. package/dist/main/services/network-forward/http.js +162 -0
  148. package/dist/main/services/network-forward/index.d.ts +135 -15
  149. package/dist/main/services/network-forward/index.js +854 -224
  150. package/dist/main/services/network-forward/request-ids.d.ts +5 -0
  151. package/dist/main/services/network-forward/request-ids.js +5 -0
  152. package/dist/main/services/network-forward/user-facing.d.ts +21 -0
  153. package/dist/main/services/network-forward/user-facing.js +50 -0
  154. package/dist/main/services/network-forward/websocket.d.ts +36 -0
  155. package/dist/main/services/network-forward/websocket.js +120 -0
  156. package/dist/main/services/notifications/renderer-notifier.d.ts +71 -9
  157. package/dist/main/services/notifications/renderer-notifier.js +45 -8
  158. package/dist/main/services/projects/create-project-service.js +19 -5
  159. package/dist/main/services/projects/local-provider.js +8 -4
  160. package/dist/main/services/projects/project-repository.d.ts +59 -7
  161. package/dist/main/services/projects/project-repository.js +285 -51
  162. package/dist/main/services/projects/types.d.ts +44 -34
  163. package/dist/main/services/render-inspect/index.d.ts +12 -2
  164. package/dist/main/services/render-inspect/index.js +21 -102
  165. package/dist/main/services/safe-area/index.d.ts +21 -6
  166. package/dist/main/services/safe-area/index.js +92 -46
  167. package/dist/main/services/service-host-pool/pool.d.ts +1 -196
  168. package/dist/main/services/service-host-pool/pool.js +1 -363
  169. package/dist/main/services/settings/index.d.ts +7 -1
  170. package/dist/main/services/settings/index.js +22 -2
  171. package/dist/main/services/simulator/custom-apis.d.ts +1 -42
  172. package/dist/main/services/simulator/custom-apis.js +1 -46
  173. package/dist/main/services/simulator/referer.d.ts +1 -9
  174. package/dist/main/services/simulator/referer.js +1 -19
  175. package/dist/main/services/simulator/ui-extensions.d.ts +21 -0
  176. package/dist/main/services/simulator/ui-extensions.js +176 -0
  177. package/dist/main/services/simulator-appdata/index.d.ts +6 -0
  178. package/dist/main/services/simulator-appdata/index.js +21 -2
  179. package/dist/main/services/simulator-current-page/index.d.ts +5 -3
  180. package/dist/main/services/simulator-current-page/index.js +8 -1
  181. package/dist/main/services/simulator-storage/index.d.ts +34 -5
  182. package/dist/main/services/simulator-storage/index.js +73 -71
  183. package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
  184. package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
  185. package/dist/main/services/simulator-storage/window-scope.d.ts +20 -0
  186. package/dist/main/services/simulator-storage/window-scope.js +20 -0
  187. package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
  188. package/dist/main/services/simulator-temp-files/disk.js +1 -237
  189. package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
  190. package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
  191. package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
  192. package/dist/main/services/simulator-temp-files/index.js +1 -181
  193. package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
  194. package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
  195. package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
  196. package/dist/main/services/simulator-temp-files/resolver.js +1 -21
  197. package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
  198. package/dist/main/services/simulator-temp-files/store.js +1 -23
  199. package/dist/main/services/update/github-release-checker.js +22 -3
  200. package/dist/main/services/update/update-manager.d.ts +21 -4
  201. package/dist/main/services/update/update-manager.js +55 -11
  202. package/dist/main/services/views/clear-console-filter.d.ts +44 -0
  203. package/dist/main/services/views/clear-console-filter.js +86 -0
  204. package/dist/main/services/views/console-filter-test-fixtures.d.ts +94 -0
  205. package/dist/main/services/views/console-filter-test-fixtures.js +82 -0
  206. package/dist/main/services/views/console-filter.d.ts +94 -0
  207. package/dist/main/services/views/console-filter.js +190 -0
  208. package/dist/main/services/views/devtools-tabs.d.ts +24 -4
  209. package/dist/main/services/views/devtools-tabs.js +40 -21
  210. package/dist/main/services/views/frontend-bootstrap-gate.d.ts +59 -0
  211. package/dist/main/services/views/frontend-bootstrap-gate.js +117 -0
  212. package/dist/main/services/views/host-dialog-port-channel.d.ts +18 -0
  213. package/dist/main/services/views/host-dialog-port-channel.js +15 -0
  214. package/dist/main/services/views/host-dialog-session-runtime.d.ts +10 -0
  215. package/dist/main/services/views/host-dialog-session-runtime.js +17 -0
  216. package/dist/main/services/views/host-dialog-view.d.ts +95 -0
  217. package/dist/main/services/views/host-dialog-view.js +147 -0
  218. package/dist/main/services/views/host-sidebar-port-channel.d.ts +18 -0
  219. package/dist/main/services/views/host-sidebar-port-channel.js +15 -0
  220. package/dist/main/services/views/host-sidebar-session-runtime.d.ts +10 -0
  221. package/dist/main/services/views/host-sidebar-session-runtime.js +17 -0
  222. package/dist/main/services/views/host-sidebar-view.d.ts +59 -0
  223. package/dist/main/services/views/host-sidebar-view.js +44 -0
  224. package/dist/main/services/views/host-slot-port-channel.d.ts +124 -0
  225. package/dist/main/services/views/host-slot-port-channel.js +289 -0
  226. package/dist/main/services/views/host-slot-session-runtime.d.ts +40 -0
  227. package/dist/main/services/views/host-slot-session-runtime.js +50 -0
  228. package/dist/main/services/views/host-slot-view.d.ts +109 -0
  229. package/dist/main/services/views/host-slot-view.js +147 -0
  230. package/dist/main/services/views/host-toolbar-port-channel.d.ts +6 -91
  231. package/dist/main/services/views/host-toolbar-port-channel.js +10 -243
  232. package/dist/main/services/views/host-toolbar-session-runtime.d.ts +5 -30
  233. package/dist/main/services/views/host-toolbar-session-runtime.js +9 -47
  234. package/dist/main/services/views/host-toolbar-view.d.ts +34 -7
  235. package/dist/main/services/views/host-toolbar-view.js +30 -237
  236. package/dist/main/services/views/managed-web-contents-view.d.ts +48 -0
  237. package/dist/main/services/views/managed-web-contents-view.js +143 -0
  238. package/dist/main/services/views/miniapp-partition.d.ts +1 -89
  239. package/dist/main/services/views/miniapp-partition.js +1 -158
  240. package/dist/main/services/views/native-simulator-devtools-host.js +206 -68
  241. package/dist/main/services/views/native-simulator-view.d.ts +6 -0
  242. package/dist/main/services/views/native-simulator-view.js +47 -40
  243. package/dist/main/services/views/native-view-tree.d.ts +25 -0
  244. package/dist/main/services/views/native-view-tree.js +69 -0
  245. package/dist/main/services/views/overlay-panels-view.d.ts +63 -4
  246. package/dist/main/services/views/overlay-panels-view.js +257 -108
  247. package/dist/main/services/views/placement-reconciler.d.ts +18 -18
  248. package/dist/main/services/views/placement-reconciler.js +91 -29
  249. package/dist/main/services/views/placement-test-driver.d.ts +27 -0
  250. package/dist/main/services/views/placement-test-driver.js +29 -0
  251. package/dist/main/services/views/refresh-styles.d.ts +10 -0
  252. package/dist/main/services/views/refresh-styles.js +57 -0
  253. package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
  254. package/dist/main/services/views/simulator-session-policy.js +1 -98
  255. package/dist/main/services/views/view-manager-devtools-host-test-fixtures.d.ts +76 -0
  256. package/dist/main/services/views/view-manager-devtools-host-test-fixtures.js +184 -0
  257. package/dist/main/services/views/view-manager.d.ts +69 -88
  258. package/dist/main/services/views/view-manager.js +62 -7
  259. package/dist/main/services/views/workbench-view.d.ts +2 -0
  260. package/dist/main/services/views/workbench-view.js +104 -17
  261. package/dist/main/services/window-contexts/context-router.d.ts +36 -0
  262. package/dist/main/services/window-contexts/context-router.js +55 -0
  263. package/dist/main/services/workbench-coi-host.d.ts +52 -0
  264. package/dist/main/services/workbench-coi-host.js +227 -0
  265. package/dist/main/services/workbench-coi-server.d.ts +11 -0
  266. package/dist/main/services/workbench-coi-server.js +126 -126
  267. package/dist/main/services/workbench-coi-shutdown.d.ts +40 -0
  268. package/dist/main/services/workbench-coi-shutdown.js +69 -0
  269. package/dist/main/services/workbench-coi-static.d.ts +23 -0
  270. package/dist/main/services/workbench-coi-static.js +87 -0
  271. package/dist/main/services/workbench-context.d.ts +88 -8
  272. package/dist/main/services/workbench-context.js +54 -6
  273. package/dist/main/services/workspace/compile-log-buffer.d.ts +40 -0
  274. package/dist/main/services/workspace/compile-log-buffer.js +41 -0
  275. package/dist/main/services/workspace/compile-mode-adapter.d.ts +18 -0
  276. package/dist/main/services/workspace/compile-mode-adapter.js +57 -0
  277. package/dist/main/services/workspace/compile-mode-store.d.ts +25 -0
  278. package/dist/main/services/workspace/compile-mode-store.js +71 -0
  279. package/dist/main/services/workspace/open-project-guards.d.ts +16 -0
  280. package/dist/main/services/workspace/open-project-guards.js +42 -0
  281. package/dist/main/services/workspace/rebuild-status.d.ts +37 -0
  282. package/dist/main/services/workspace/rebuild-status.js +36 -0
  283. package/dist/main/services/workspace/session-status-store.d.ts +47 -0
  284. package/dist/main/services/workspace/session-status-store.js +73 -0
  285. package/dist/main/services/workspace/status-tap.d.ts +20 -0
  286. package/dist/main/services/workspace/status-tap.js +32 -0
  287. package/dist/main/services/workspace/workspace-compile-modes.d.ts +59 -0
  288. package/dist/main/services/workspace/workspace-compile-modes.js +93 -0
  289. package/dist/main/services/workspace/workspace-lifecycle-race.testutil.d.ts +22 -0
  290. package/dist/main/services/workspace/workspace-lifecycle-race.testutil.js +62 -0
  291. package/dist/main/services/workspace/workspace-referer.d.ts +17 -0
  292. package/dist/main/services/workspace/workspace-referer.js +26 -0
  293. package/dist/main/services/workspace/workspace-service.d.ts +7 -5
  294. package/dist/main/services/workspace/workspace-service.js +96 -135
  295. package/dist/main/services/workspace/workspace-thumbnails.d.ts +22 -0
  296. package/dist/main/services/workspace/workspace-thumbnails.js +67 -0
  297. package/dist/main/utils/ipc-context-source.d.ts +40 -0
  298. package/dist/main/utils/ipc-context-source.js +23 -0
  299. package/dist/main/utils/ipc-registry.d.ts +46 -21
  300. package/dist/main/utils/ipc-registry.js +166 -76
  301. package/dist/main/utils/paths.d.ts +18 -0
  302. package/dist/main/utils/paths.js +18 -0
  303. package/dist/main/utils/sender-policy.d.ts +10 -1
  304. package/dist/main/utils/sender-policy.js +42 -4
  305. package/dist/main/utils/theme.d.ts +18 -8
  306. package/dist/main/utils/theme.js +19 -9
  307. package/dist/main/windows/internal-devtools-window/index.d.ts +66 -0
  308. package/dist/main/windows/internal-devtools-window/index.js +160 -0
  309. package/dist/main/windows/main-window/create.d.ts +16 -0
  310. package/dist/main/windows/main-window/create.js +19 -11
  311. package/dist/main/windows/main-window/events.d.ts +1 -1
  312. package/dist/main/windows/main-window/events.js +26 -13
  313. package/dist/main/windows/main-window/index.d.ts +1 -1
  314. package/dist/main/windows/main-window/index.js +1 -1
  315. package/dist/main/windows/service-host-window/create.d.ts +1 -92
  316. package/dist/main/windows/service-host-window/create.js +1 -154
  317. package/dist/native-host/common/common.js +173 -53
  318. package/dist/native-host/container/pageFrame.css +1 -1
  319. package/dist/native-host/render/render.js +8278 -3659
  320. package/dist/native-host/service/service.js +2 -2
  321. package/dist/preload/index.d.ts +2 -0
  322. package/dist/preload/index.js +1 -0
  323. package/dist/preload/instrumentation/app-data.d.ts +2 -2
  324. package/dist/preload/instrumentation/app-data.js +1 -1
  325. package/dist/preload/instrumentation/wxml.js +1 -1
  326. package/dist/preload/runtime/bridge.d.ts +3 -3
  327. package/dist/preload/runtime/bridge.js +2 -2
  328. package/dist/preload/runtime/clipboard.d.ts +6 -0
  329. package/dist/preload/runtime/clipboard.js +12 -0
  330. package/dist/preload/runtime/host-dialog-advertiser.d.ts +22 -0
  331. package/dist/preload/runtime/host-dialog-advertiser.js +37 -0
  332. package/dist/preload/runtime/host-dialog-port.d.ts +44 -0
  333. package/dist/preload/runtime/host-dialog-port.js +53 -0
  334. package/dist/preload/runtime/host-dialog-runtime.d.ts +28 -0
  335. package/dist/preload/runtime/host-dialog-runtime.js +36 -0
  336. package/dist/preload/runtime/host-sidebar-advertiser.d.ts +19 -0
  337. package/dist/preload/runtime/host-sidebar-advertiser.js +35 -0
  338. package/dist/preload/runtime/host-sidebar-port.d.ts +44 -0
  339. package/dist/preload/runtime/host-sidebar-port.js +53 -0
  340. package/dist/preload/runtime/host-sidebar-runtime.d.ts +28 -0
  341. package/dist/preload/runtime/host-sidebar-runtime.js +36 -0
  342. package/dist/preload/runtime/host-slot-port-bridge.d.ts +18 -0
  343. package/dist/preload/runtime/host-slot-port-bridge.js +112 -0
  344. package/dist/preload/runtime/host-toolbar-advertiser.d.ts +5 -13
  345. package/dist/preload/runtime/host-toolbar-advertiser.js +18 -38
  346. package/dist/preload/runtime/host-toolbar-port.d.ts +9 -0
  347. package/dist/preload/runtime/host-toolbar-port.js +11 -95
  348. package/dist/preload/runtime/native-host.d.ts +14 -0
  349. package/dist/preload/runtime/native-host.js +5 -8
  350. package/dist/preload/runtime/node-bindings.d.ts +18 -0
  351. package/dist/preload/runtime/node-bindings.js +44 -0
  352. package/dist/preload/runtime/temp-files.js +9 -2
  353. package/dist/preload/runtime/wait-for-slot-root.d.ts +23 -0
  354. package/dist/preload/runtime/wait-for-slot-root.js +80 -0
  355. package/dist/preload/shared/api-compat.js +63 -41
  356. package/dist/preload/windows/host-dialog-runtime.cjs +360 -0
  357. package/dist/preload/windows/host-dialog-runtime.cjs.map +7 -0
  358. package/dist/preload/windows/host-dialog-runtime.d.ts +2 -0
  359. package/dist/preload/windows/host-dialog-runtime.js +13 -0
  360. package/dist/preload/windows/host-sidebar-runtime.cjs +361 -0
  361. package/dist/preload/windows/host-sidebar-runtime.cjs.map +7 -0
  362. package/dist/preload/windows/host-sidebar-runtime.d.ts +2 -0
  363. package/dist/preload/windows/host-sidebar-runtime.js +13 -0
  364. package/dist/preload/windows/host-toolbar-runtime.cjs +142 -52
  365. package/dist/preload/windows/host-toolbar-runtime.cjs.map +3 -3
  366. package/dist/preload/windows/main.cjs +4922 -1246
  367. package/dist/preload/windows/main.cjs.map +4 -4
  368. package/dist/preload/windows/main.css +428 -0
  369. package/dist/preload/windows/main.css.map +7 -0
  370. package/dist/preload/windows/simulator.cjs +376 -322
  371. package/dist/preload/windows/simulator.cjs.map +4 -4
  372. package/dist/preload/windows/simulator.js +376 -322
  373. package/dist/render-host/pageFrame.html +4 -4
  374. package/dist/render-host/preload.cjs +30 -0
  375. package/dist/render-host/render-inspect.js +184 -115
  376. package/dist/renderer/assets/button-CB2MWjHY.js +2 -0
  377. package/dist/renderer/assets/constants-CkoGPQTS.js +2 -0
  378. package/dist/renderer/assets/constants-zQZ2-y21.js +2 -0
  379. package/dist/renderer/assets/createLucideIcon-cZ9FlZZw.js +2 -0
  380. package/dist/renderer/assets/devicePicker-H2eIO4e1.js +2 -0
  381. package/dist/renderer/assets/dialog-pHzEA8Vx.js +46 -0
  382. package/dist/renderer/assets/dist-B5HADirS.js +2 -0
  383. package/dist/renderer/assets/dist-DIFlRMKe.js +2 -0
  384. package/dist/renderer/assets/hostSidebarDefault-DRWh6OCt.js +2 -0
  385. package/dist/renderer/assets/index-CEL_XFge.js +2 -0
  386. package/dist/renderer/assets/input-CAObw95L.js +2 -0
  387. package/dist/renderer/assets/ipc-channels-overlays-gIPUFnqc.js +2 -0
  388. package/dist/renderer/assets/jsx-runtime-DICEQH_0.css +1 -0
  389. package/dist/renderer/assets/jsx-runtime-DIw5wnYl.js +9 -0
  390. package/dist/renderer/assets/plus-BQ9u5EbL.js +2 -0
  391. package/dist/renderer/assets/popover-Cw7G2Ctp.js +2 -0
  392. package/dist/renderer/assets/presets-DMZOb9ay.js +2 -0
  393. package/dist/renderer/assets/project-api-YTOr_Yvo.js +2 -0
  394. package/dist/renderer/assets/projectCreateDialog-BmLqiYxn.js +2 -0
  395. package/dist/renderer/assets/search-BMvuYF48.js +2 -0
  396. package/dist/renderer/assets/select-nFP95TxM.js +2 -0
  397. package/dist/renderer/assets/settings-CnpVfSWt.js +2 -0
  398. package/dist/renderer/assets/settings-api-Ccsf-Nsj.js +2 -0
  399. package/dist/renderer/assets/settings-tab-bar-CAzrv32m.js +2 -0
  400. package/dist/renderer/assets/smartphone-Bb2GdIKy.js +2 -0
  401. package/dist/renderer/assets/tabs-CPKN3Mmq.js +2 -0
  402. package/dist/renderer/assets/tooltip-D6AxXRk5.js +2 -0
  403. package/dist/renderer/assets/types-Bh0hA7El.js +2 -0
  404. package/dist/renderer/assets/updateDialog-CwndJ0Bl.js +2 -0
  405. package/dist/renderer/assets/utils-sEB5OZEQ.js +2 -0
  406. package/dist/renderer/assets/view-api-B-2zPBR5.js +2 -0
  407. package/dist/renderer/assets/view-ids-BfaDVV5P.js +2 -0
  408. package/dist/renderer/assets/workbench-C0Jkdlps.js +5 -0
  409. package/dist/renderer/assets/workbenchSettings-YD0Ctbm_.js +8 -0
  410. package/dist/renderer/entries/device-picker/index.html +28 -0
  411. package/dist/renderer/entries/host-sidebar-default/index.html +22 -0
  412. package/dist/renderer/entries/main/index.html +16 -7
  413. package/dist/renderer/entries/popover/index.html +16 -6
  414. package/dist/renderer/entries/project-create-dialog/index.html +27 -0
  415. package/dist/renderer/entries/settings/index.html +10 -5
  416. package/dist/renderer/entries/tooltip/index.html +21 -0
  417. package/dist/renderer/entries/update-dialog/index.html +25 -0
  418. package/dist/renderer/entries/workbench/index.html +49 -0
  419. package/dist/renderer/entries/workbench-settings/index.html +12 -5
  420. package/dist/service-host/appdata-set-data.cjs +39 -0
  421. package/dist/service-host/host-env-update.cjs +23 -0
  422. package/dist/service-host/preload.cjs +54 -48
  423. package/dist/service-host/service-message-queue.cjs +71 -0
  424. package/dist/service-host/sync-impls/menu-button-geometry.js +16 -5
  425. package/dist/service-host/sync-impls/menu-button.js +5 -3
  426. package/dist/service-host/sync-impls/system-info.js +31 -9
  427. package/dist/shared/bridge-channels.d.ts +1 -416
  428. package/dist/shared/bridge-channels.js +1 -89
  429. package/dist/shared/compile-mode-state.d.ts +73 -0
  430. package/dist/shared/compile-mode-state.js +100 -0
  431. package/dist/shared/compile-modes.d.ts +152 -0
  432. package/dist/shared/compile-modes.js +237 -0
  433. package/dist/shared/constants.d.ts +22 -0
  434. package/dist/shared/constants.js +22 -0
  435. package/dist/shared/dmb-resource-url.d.ts +2 -0
  436. package/dist/shared/dmb-resource-url.js +2 -0
  437. package/dist/shared/ipc-channels-overlays.d.ts +162 -0
  438. package/dist/shared/ipc-channels-overlays.js +203 -0
  439. package/dist/shared/ipc-channels.d.ts +24 -154
  440. package/dist/shared/ipc-channels.js +48 -96
  441. package/dist/shared/ipc-schemas.d.ts +143 -54
  442. package/dist/shared/ipc-schemas.js +137 -45
  443. package/dist/shared/node-bindings.d.ts +2 -0
  444. package/dist/shared/node-bindings.js +2 -0
  445. package/dist/shared/project-window-types.d.ts +42 -0
  446. package/dist/shared/project-window-types.js +2 -0
  447. package/dist/shared/simulator-route.d.ts +8 -0
  448. package/dist/shared/simulator-route.js +15 -0
  449. package/dist/shared/simulator-ui.d.ts +61 -0
  450. package/dist/shared/simulator-ui.js +12 -0
  451. package/dist/shared/types.d.ts +126 -41
  452. package/dist/shared/view-ids.d.ts +10 -0
  453. package/dist/shared/view-ids.js +23 -0
  454. package/dist/simulator/assets/bridge-channels-B3JAmRfl.js +2 -0
  455. package/dist/simulator/assets/device-shell-ATEhHV2_.css +1 -0
  456. package/dist/simulator/assets/device-shell-DucLepkm.js +431 -0
  457. package/dist/simulator/assets/simulator-B4rbcOVt.js +10 -0
  458. package/dist/simulator/assets/simulator-mini-app-DFo7fhi5.js +2 -0
  459. package/dist/simulator/assets/simulator-ui-BupATgKo.css +1 -0
  460. package/dist/simulator/assets/simulator-ui-i3GCc7YJ.js +2 -0
  461. package/dist/simulator/simulator.html +4 -3
  462. package/dist/simulator/temp-files.d.ts +35 -0
  463. package/dist/simulator/temp-files.js +121 -0
  464. package/dist/simulator/types.d.ts +50 -0
  465. package/dist/simulator/types.js +2 -0
  466. package/dist/vscode-workbench/assets/__vite-browser-external-JIkWewFf.js +1 -0
  467. package/dist/vscode-workbench/assets/{dist-TpGpmMGi.js → dist-CXG-u1VB.js} +3 -3
  468. package/dist/vscode-workbench/assets/fs-core-worker-urls-DZ1nod84.js +1 -0
  469. package/dist/vscode-workbench/assets/fs-core.worker-Bnmpp6fo.js +1 -0
  470. package/dist/vscode-workbench/assets/fs-query.worker-cZ-7Fjch.js +2 -0
  471. package/dist/vscode-workbench/assets/{iconv-lite-umd-C9tiCAJa.js → iconv-lite-umd-Dxx9Qyb4.js} +1 -1
  472. package/dist/vscode-workbench/assets/{index-DJ1HyMZ7.js → index-6VJMsaWj.js} +475 -475
  473. package/dist/vscode-workbench/assets/{jschardet-DE1jV513.js → jschardet-Ba3D16vt.js} +1 -1
  474. package/dist/vscode-workbench/index.html +21 -1
  475. package/package.json +23 -13
  476. package/dist/main/services/views/destroy-child-view.d.ts +0 -9
  477. package/dist/main/services/views/destroy-child-view.js +0 -23
  478. package/dist/preload/instrumentation/wxml-extract.d.ts +0 -11
  479. package/dist/preload/instrumentation/wxml-extract.js +0 -382
  480. package/dist/preload/shared/sid-registry.d.ts +0 -11
  481. package/dist/preload/shared/sid-registry.js +0 -38
  482. package/dist/renderer/assets/constants-EAMiwL9_.js +0 -2
  483. package/dist/renderer/assets/index-BMqyDx71.js +0 -49
  484. package/dist/renderer/assets/input-CDAEwpBO.js +0 -2
  485. package/dist/renderer/assets/ipc-transport-B7eFOR68.css +0 -1
  486. package/dist/renderer/assets/ipc-transport-_G1k5V1p.js +0 -9
  487. package/dist/renderer/assets/popover-DEdjK14m.js +0 -2
  488. package/dist/renderer/assets/select-DpKPCh3y.js +0 -2
  489. package/dist/renderer/assets/settings-M5q2elUr.js +0 -2
  490. package/dist/renderer/assets/settings-api-CDlZoHiO.js +0 -2
  491. package/dist/renderer/assets/workbenchSettings-CT_H1WhV.js +0 -8
  492. package/dist/shared/appdata-accumulator.d.ts +0 -95
  493. package/dist/shared/appdata-accumulator.js +0 -218
  494. package/dist/shared/request-core.d.ts +0 -84
  495. package/dist/shared/request-core.js +0 -168
  496. package/dist/shared/simulator-api-metadata.d.ts +0 -26
  497. package/dist/shared/simulator-api-metadata.js +0 -59
  498. package/dist/shared/vpath.d.ts +0 -42
  499. package/dist/shared/vpath.js +0 -105
  500. package/dist/simulator/assets/bridge-channels-zhsumfky.js +0 -2
  501. package/dist/simulator/assets/device-shell-C-wcFq3Z.js +0 -2
  502. package/dist/simulator/assets/device-shell-CS1rqAQz.css +0 -1
  503. package/dist/simulator/assets/jsx-runtime-BDTY6fEq.js +0 -2
  504. package/dist/simulator/assets/simulator-DU3-fS3v.js +0 -10
  505. package/dist/simulator/assets/simulator-mini-app-DzfMfnVM.js +0 -2
  506. package/dist/simulator/device-shell/menu-button-geometry.js +0 -8
  507. package/dist/vscode-workbench/assets/__vite-browser-external-CXi6Kz9W.js +0 -1
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Pure candidate-ranking rules for the two MCP CDP targets.
3
+ *
4
+ * Split out of target-manager.ts: these functions only rank a raw CDP.List
5
+ * result by URL shape and carry no connection state of their own, so they can
6
+ * be pinned with direct unit tests independent of the connection lifecycle.
7
+ */
8
+ /**
9
+ * Resolve which CDP target the `simulator` MCP tools should drive.
10
+ *
11
+ * Default (non-native) path: the localhost:7788 simulator shell — identical
12
+ * to the original behavior; `activeBridgeId` is ignored.
13
+ *
14
+ * Native-host path: the active render-host <webview> guest
15
+ * (pageFrame.html?...bridgeId=<id>), preferring the guest matching
16
+ * `activeBridgeId`, then any pageFrame guest, then degrading to the shell.
17
+ */
18
+ export declare function selectSimulatorTarget<T extends {
19
+ url?: string;
20
+ type?: string;
21
+ }>(targets: T[], opts: {
22
+ nativeHost: boolean;
23
+ activeBridgeId: string | null;
24
+ }): T | undefined;
25
+ /**
26
+ * Resolve which CDP target the `workbench` MCP tools should drive.
27
+ *
28
+ * `projectPath` is the active project window's path, fixed when that window
29
+ * opened; null when no project window is open, and then the project list is
30
+ * the only workbench surface.
31
+ *
32
+ * A project window names its own renderer from the moment it exists, so the
33
+ * match is exact or nothing: another project's workbench page, or the project
34
+ * list standing in for a project that IS open, would leave every workbench
35
+ * tool answering for the wrong window with nothing to correct it.
36
+ *
37
+ * Matching is on the renderer ENTRY, never on "the URL mentions the project
38
+ * directory" — the service-host window carries the same directory in its own
39
+ * `pkgRoot` query and would win a substring match.
40
+ */
41
+ export declare function selectWorkbenchTarget<T extends {
42
+ url?: string;
43
+ type?: string;
44
+ }>(candidates: T[], opts: {
45
+ projectPath: string | null;
46
+ }): T | undefined;
47
+ //# sourceMappingURL=target-selection.d.ts.map
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Pure candidate-ranking rules for the two MCP CDP targets.
3
+ *
4
+ * Split out of target-manager.ts: these functions only rank a raw CDP.List
5
+ * result by URL shape and carry no connection state of their own, so they can
6
+ * be pinned with direct unit tests independent of the connection lifecycle.
7
+ */
8
+ import { DMB_PAGEFRAME_DOC_NAME } from '../../../shared/dmb-resource-url.js';
9
+ import { targetQuery } from './connection-owner.js';
10
+ const SIMULATOR_URL_PATTERN = 'localhost:7788';
11
+ // The two renderer entries MCP can drive: a project's workbench window and the
12
+ // always-present project list.
13
+ const WORKBENCH_ENTRY = 'entries/workbench/index.html';
14
+ const PROJECT_LIST_ENTRY = 'entries/main/index.html';
15
+ // Native-host: the real mini-app page runs in a nested render-host <webview>
16
+ // guest whose CDP target URL carries the render frame + the page's bridgeId.
17
+ // Import the shared reserved doc name rather than hand-writing a second
18
+ // literal — that duplication is exactly what let this pattern drift out of
19
+ // sync with the actual document URL shape (dmb-resource-url.ts).
20
+ const RENDER_GUEST_PATTERN = DMB_PAGEFRAME_DOC_NAME;
21
+ /**
22
+ * Resolve which CDP target the `simulator` MCP tools should drive.
23
+ *
24
+ * Default (non-native) path: the localhost:7788 simulator shell — identical
25
+ * to the original behavior; `activeBridgeId` is ignored.
26
+ *
27
+ * Native-host path: the active render-host <webview> guest
28
+ * (pageFrame.html?...bridgeId=<id>), preferring the guest matching
29
+ * `activeBridgeId`, then any pageFrame guest, then degrading to the shell.
30
+ */
31
+ export function selectSimulatorTarget(targets, opts) {
32
+ if (!opts.nativeHost) {
33
+ return targets.find((t) => t.url?.includes(SIMULATOR_URL_PATTERN));
34
+ }
35
+ // 1) Active-bridge guest takes priority over list order.
36
+ if (opts.activeBridgeId !== null) {
37
+ const bridgeMatch = `bridgeId=${opts.activeBridgeId}`;
38
+ const active = targets.find((t) => t.url?.includes(RENDER_GUEST_PATTERN) && t.url.includes(bridgeMatch));
39
+ if (active)
40
+ return active;
41
+ }
42
+ // 2) Any render guest (no active match / no active bridge).
43
+ const anyGuest = targets.find((t) => t.url?.includes(RENDER_GUEST_PATTERN));
44
+ if (anyGuest)
45
+ return anyGuest;
46
+ // 3) Degrade to the localhost:7788 shell when no render guest exists yet.
47
+ return targets.find((t) => t.url?.includes(SIMULATOR_URL_PATTERN));
48
+ }
49
+ /**
50
+ * Resolve which CDP target the `workbench` MCP tools should drive.
51
+ *
52
+ * `projectPath` is the active project window's path, fixed when that window
53
+ * opened; null when no project window is open, and then the project list is
54
+ * the only workbench surface.
55
+ *
56
+ * A project window names its own renderer from the moment it exists, so the
57
+ * match is exact or nothing: another project's workbench page, or the project
58
+ * list standing in for a project that IS open, would leave every workbench
59
+ * tool answering for the wrong window with nothing to correct it.
60
+ *
61
+ * Matching is on the renderer ENTRY, never on "the URL mentions the project
62
+ * directory" — the service-host window carries the same directory in its own
63
+ * `pkgRoot` query and would win a substring match.
64
+ */
65
+ export function selectWorkbenchTarget(candidates, opts) {
66
+ const pages = candidates.filter((t) => t.type === 'page' && !t.url?.includes(SIMULATOR_URL_PATTERN));
67
+ if (opts.projectPath === null)
68
+ return pages.find((t) => t.url?.includes(PROJECT_LIST_ENTRY));
69
+ return pages.find((t) => t.url?.includes(WORKBENCH_ENTRY) && targetQuery(t.url, 'path') === opts.projectPath);
70
+ }
71
+ //# sourceMappingURL=target-selection.js.map
@@ -136,8 +136,21 @@ export function registerContextTools(server) {
136
136
  return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
137
137
  }
138
138
  let result;
139
+ // Snapshot the provider AND the console/network summaries in the same
140
+ // tick as `getClient`: the provider reads the active window live off
141
+ // `resolveActiveOwner()`, and the buffers are process-wide and get
142
+ // cleared and re-owned the moment a reconnect lands on another window.
143
+ // Both awaits below (the CDP probe, the native provider) are windows the
144
+ // user can switch projects during; reading either after them would mix
145
+ // this window's probe with whichever window is active by then.
146
+ let nativeOverviewProvider;
147
+ let consoleSum;
148
+ let networkSum;
139
149
  try {
140
150
  const c = getClient('simulator');
151
+ nativeOverviewProvider = getNativeOverviewProvider();
152
+ consoleSum = summarizeConsole('simulator');
153
+ networkSum = summarizeNetwork('simulator');
141
154
  result = await c.Runtime.evaluate({ expression: SIMULATOR_PROBE_EXPR, returnByValue: true });
142
155
  }
143
156
  catch {
@@ -160,7 +173,6 @@ export function registerContextTools(server) {
160
173
  isError: true,
161
174
  };
162
175
  }
163
- const nativeOverviewProvider = getNativeOverviewProvider();
164
176
  if (nativeOverviewProvider) {
165
177
  try {
166
178
  const nativeOverview = await nativeOverviewProvider();
@@ -182,8 +194,6 @@ export function registerContextTools(server) {
182
194
  hints.push('no active miniapp page (empty page stack)');
183
195
  if (probe.storageCount > MAX_KEYS)
184
196
  hints.push(`storageKeys truncated to first ${MAX_KEYS} of ${probe.storageCount}`);
185
- const consoleSum = summarizeConsole('simulator');
186
- const networkSum = summarizeNetwork('simulator');
187
197
  const payload = {
188
198
  connected: true,
189
199
  url: probe.url,
@@ -213,8 +223,15 @@ export function registerContextTools(server) {
213
223
  return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
214
224
  }
215
225
  let result;
226
+ // Same snapshot rule as the simulator overview: the buffers belong to
227
+ // the connection `getClient` just vouched for, so they are read before
228
+ // the probe's await, not after it.
229
+ let consoleSum;
230
+ let networkSum;
216
231
  try {
217
232
  const c = getClient('workbench');
233
+ consoleSum = summarizeConsole('workbench');
234
+ networkSum = summarizeNetwork('workbench');
218
235
  result = await c.Runtime.evaluate({ expression: WORKBENCH_PROBE_EXPR, returnByValue: true });
219
236
  }
220
237
  catch {
@@ -237,8 +254,6 @@ export function registerContextTools(server) {
237
254
  isError: true,
238
255
  };
239
256
  }
240
- const consoleSum = summarizeConsole('workbench');
241
- const networkSum = summarizeNetwork('workbench');
242
257
  const payload = {
243
258
  connected: true,
244
259
  url: probe.url,
@@ -0,0 +1,72 @@
1
+ /**
2
+ * MCP project lifecycle tools: open (launch the mini-program in the
3
+ * simulator), close, query compile status, await the compile settling, and
4
+ * pull compile logs incrementally.
5
+ *
6
+ * `project_open` does NOT call `workspace.openProject` directly: the renderer
7
+ * owns the open path (mounting ProjectRuntime is what compiles AND attaches
8
+ * the simulator), so the tool pushes a `window:openProject` event and then
9
+ * awaits the session-status store — the same main-process authority the
10
+ * notifier tap feeds from the renderer-driven compile.
11
+ */
12
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import type { CompileLogBuffer } from '../../workspace/compile-log-buffer.js';
14
+ import type { SessionStatusStore } from '../../workspace/session-status-store.js';
15
+ import type { McpOpenedProject } from '../opened-project.js';
16
+ /**
17
+ * Narrow structural slice of WorkspaceService the project tools need.
18
+ * Structural (not a Pick of the real interface) so tests can hand in a
19
+ * plain object and this module never imports workbench-context.
20
+ */
21
+ export interface McpProjectWorkspace {
22
+ validateProjectDir(dirPath: string): Promise<string | null>;
23
+ hasProject(dirPath: string): Promise<boolean>;
24
+ addProject(dirPath: string): Promise<{
25
+ name: string;
26
+ path: string;
27
+ }>;
28
+ listProjects(): Promise<{
29
+ name: string;
30
+ path: string;
31
+ }[]>;
32
+ closeProject(): Promise<void>;
33
+ getProjectPath(): string;
34
+ hasActiveSession(): boolean;
35
+ }
36
+ /**
37
+ * One project window's surfaces, resolved together. A project lives in its own
38
+ * window with its own workspace, status store and log buffer, so a tool call
39
+ * that read them one by one could mix two projects: every surface here comes
40
+ * from the same window at the same instant.
41
+ */
42
+ export interface McpProjectTarget {
43
+ workspace: McpProjectWorkspace;
44
+ sessionStatus: SessionStatusStore;
45
+ compileLogs: CompileLogBuffer;
46
+ /** Close this target's project window; a no-op when it has none. */
47
+ closeWindow(): void;
48
+ }
49
+ /** Everything `registerProjectTools` needs, assembled by app bootstrap. */
50
+ export interface McpProjectHost {
51
+ /**
52
+ * The project window a call arriving now is aimed at. Taken ONCE per tool
53
+ * call and held for its whole lifetime: tools await compiles and teardowns,
54
+ * and the user is free to focus another project meanwhile — re-resolving
55
+ * afterwards would report one project's compile as another's, or close the
56
+ * window they just moved to.
57
+ */
58
+ currentProject(): McpProjectTarget;
59
+ /**
60
+ * Push the renderer to open the project (the user-click-equivalent path) and
61
+ * resolve with the window it landed in. A project lives in its own window
62
+ * with its own status store, so the caller can only await the right compile
63
+ * by holding that window — the window active when the call arrived is a
64
+ * different project.
65
+ */
66
+ requestOpenInUi(project: {
67
+ name: string;
68
+ path: string;
69
+ }): Promise<McpOpenedProject>;
70
+ }
71
+ export declare function registerProjectTools(server: McpServer, host: McpProjectHost): void;
72
+ //# sourceMappingURL=project-tools.d.ts.map
@@ -0,0 +1,133 @@
1
+ /**
2
+ * MCP project lifecycle tools: open (launch the mini-program in the
3
+ * simulator), close, query compile status, await the compile settling, and
4
+ * pull compile logs incrementally.
5
+ *
6
+ * `project_open` does NOT call `workspace.openProject` directly: the renderer
7
+ * owns the open path (mounting ProjectRuntime is what compiles AND attaches
8
+ * the simulator), so the tool pushes a `window:openProject` event and then
9
+ * awaits the session-status store — the same main-process authority the
10
+ * notifier tap feeds from the renderer-driven compile.
11
+ */
12
+ import path from 'node:path';
13
+ import { z } from 'zod';
14
+ const DEFAULT_OPEN_TIMEOUT_MS = 180_000;
15
+ const DEFAULT_WAIT_TIMEOUT_MS = 60_000;
16
+ function text(payload) {
17
+ return { content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }] };
18
+ }
19
+ function errorText(message) {
20
+ return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
21
+ }
22
+ /**
23
+ * Public phase: a settled store snapshot with no live session means no
24
+ * project is open ('idle'), while 'error'/'compiling' pass through as-is —
25
+ * `hasActiveSession()` is false during a compile and after a failed open,
26
+ * so those phases are the truthful answer even without a session.
27
+ */
28
+ function publicPhase(snapshot, sessionActive) {
29
+ if (!sessionActive && snapshot.phase === 'ready')
30
+ return 'idle';
31
+ return snapshot.phase;
32
+ }
33
+ /** Reads one window's own status: the pinned target, or the window an open landed in. */
34
+ function statusPayload(source) {
35
+ const snapshot = source.sessionStatus.get();
36
+ const sessionActive = source.workspace.hasActiveSession();
37
+ return {
38
+ phase: publicPhase(snapshot, sessionActive),
39
+ message: snapshot.message,
40
+ projectPath: source.workspace.getProjectPath(),
41
+ sessionActive,
42
+ watcherAlive: snapshot.watcherAlive,
43
+ updatedAt: snapshot.updatedAt,
44
+ generation: snapshot.generation,
45
+ };
46
+ }
47
+ export function registerProjectTools(server, host) {
48
+ server.tool('project_open', 'Open a mini-program project: registers the directory if needed, launches it in the simulator (compile + attach), and waits until the compile settles. Returns the settled status; on compile error, pull stderr via compile_logs.', {
49
+ path: z.string().describe('Absolute path to the mini-program project directory'),
50
+ timeoutMs: z.number().optional().default(DEFAULT_OPEN_TIMEOUT_MS)
51
+ .describe('Max time to wait for the compile to settle'),
52
+ }, async ({ path: rawPath, timeoutMs }) => {
53
+ const target = host.currentProject();
54
+ const dir = path.resolve(rawPath);
55
+ // Already open and settled: report instead of re-triggering a compile.
56
+ const current = target.sessionStatus.get();
57
+ if (target.workspace.getProjectPath() === dir
58
+ && target.workspace.hasActiveSession()
59
+ && current.phase === 'ready') {
60
+ return text({ ...statusPayload(target), note: 'project already open' });
61
+ }
62
+ const invalid = await target.workspace.validateProjectDir(dir);
63
+ if (invalid)
64
+ return errorText(invalid);
65
+ let project;
66
+ if (await target.workspace.hasProject(dir)) {
67
+ const known = (await target.workspace.listProjects()).find((p) => p.path === dir);
68
+ project = known ?? { name: path.basename(dir), path: dir };
69
+ }
70
+ else {
71
+ project = await target.workspace.addProject(dir);
72
+ }
73
+ // The open hands back the window it landed in; that window's store is the
74
+ // only place this compile is reported, and its `afterGeneration` keeps a
75
+ // state that predates the open from being read as this open's result.
76
+ let opened;
77
+ let settled;
78
+ try {
79
+ opened = await host.requestOpenInUi({ name: project.name, path: project.path });
80
+ settled = await opened.sessionStatus.waitForSettled({
81
+ afterGeneration: opened.afterGeneration,
82
+ timeoutMs,
83
+ });
84
+ }
85
+ catch (err) {
86
+ return errorText(err instanceof Error ? err.message : String(err));
87
+ }
88
+ if (settled.phase === 'error') {
89
+ return errorText(`compile failed: ${settled.message} — call compile_logs (stream: "stderr") for details`);
90
+ }
91
+ return text(statusPayload(opened));
92
+ });
93
+ server.tool('project_close', 'Close the currently open project session and return the workbench to the project list.', {}, async () => {
94
+ // Held across the await: `closeProject()` yields, and a window the user
95
+ // focuses while it runs must not become the window this close takes down.
96
+ const target = host.currentProject();
97
+ if (!target.workspace.getProjectPath() && !target.workspace.hasActiveSession()) {
98
+ return text({ closed: false, note: 'no project is open' });
99
+ }
100
+ await target.workspace.closeProject();
101
+ target.closeWindow();
102
+ return text({ closed: true });
103
+ });
104
+ server.tool('project_status', 'Query the current project compile status (phase: idle | compiling | ready | error). Includes `generation` — pass it to project_wait_ready to await the NEXT settled state.', {}, async () => text(statusPayload(host.currentProject())));
105
+ server.tool('project_wait_ready', 'Wait until the compile pipeline settles (phase leaves "compiling"). Watcher rebuilds emit no "compiling" phase, so to await a rebuild after editing files pass the `generation` from a prior project_status.', {
106
+ afterGeneration: z.number().optional()
107
+ .describe('Only accept states recorded after this generation (from project_status). Omit to accept the current state when already settled.'),
108
+ timeoutMs: z.number().optional().default(DEFAULT_WAIT_TIMEOUT_MS)
109
+ .describe('Max time to wait'),
110
+ }, async ({ afterGeneration, timeoutMs }) => {
111
+ // Held across the wait: the state this call reports must come from the
112
+ // window it was aimed at, whichever window is focused when it settles.
113
+ const target = host.currentProject();
114
+ try {
115
+ await target.sessionStatus.waitForSettled({ afterGeneration, timeoutMs });
116
+ }
117
+ catch (err) {
118
+ return errorText(err instanceof Error ? err.message : String(err));
119
+ }
120
+ return text(statusPayload(target));
121
+ });
122
+ server.tool('compile_logs', 'Pull compile log lines incrementally. Pass the previous call\'s nextCursor as `cursor` to receive only new lines. The buffer resets on each fresh project open; watcher rebuilds append to the same timeline.', {
123
+ cursor: z.number().optional().default(0)
124
+ .describe('Return only lines after this cursor (0 = from the start of the buffer)'),
125
+ limit: z.number().optional().default(100).describe('Max lines to return'),
126
+ stream: z.enum(['stdout', 'stderr']).optional()
127
+ .describe('Only lines from this stream (stderr carries compile errors)'),
128
+ }, async ({ cursor, limit, stream }) => {
129
+ const read = host.currentProject().compileLogs.read({ afterSeq: cursor, limit, stream });
130
+ return text(read);
131
+ });
132
+ }
133
+ //# sourceMappingURL=project-tools.js.map
@@ -1,17 +1,25 @@
1
1
  import type { Disposable } from '@dimina-kit/electron-deck/main';
2
2
  import type { WorkbenchContext } from './workbench-context.js';
3
+ import type { IpcContextSource } from '../utils/ipc-context-source.js';
3
4
  /**
4
5
  * A composable unit of workbench functionality.
5
6
  *
6
7
  * Built-in modules (projects, session, simulator, popover, settings) are
7
8
  * implemented as `WorkbenchModule` values.
8
9
  *
9
- * `setup` is invoked once during workbench bootstrap. The returned
10
- * Disposable is added to `ctx.registry` so module teardown is symmetric
11
- * with the rest of the workbench lifecycle.
10
+ * The two hooks differ in what they own. `setup` registers IPC once for the
11
+ * application and answers each message with the context the sender belongs to,
12
+ * so its handlers must read everything from that argument. `setupWindow` is the
13
+ * escape hatch for wiring that genuinely belongs to a single window — it
14
+ * receives that window's concrete context and may mutate it.
15
+ *
16
+ * Both returned Disposables are added to a registry so module teardown is
17
+ * symmetric with the rest of the workbench lifecycle.
12
18
  */
13
19
  export interface WorkbenchModule {
14
- /** Set up the module against ctx. Returns a Disposable owned by ctx.registry. */
15
- setup(ctx: WorkbenchContext): Disposable;
20
+ /** Register the module's IPC against every live window context. */
21
+ setup(source: IpcContextSource<WorkbenchContext>): Disposable;
22
+ /** Optional per-window wiring, run once for each window that opens. */
23
+ setupWindow?(ctx: WorkbenchContext): Disposable;
16
24
  }
17
25
  //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1,72 @@
1
+ /**
2
+ * PrefetchCache — a bounded, TTL'd "prime now / read later" promise cache.
3
+ *
4
+ * The network forwarder prefetches `Network.getResponseBody` /
5
+ * `Network.getRequestPostData` from the simulator's CDP session the moment a
6
+ * request finishes (the renderer may evict the resource soon after), keyed by
7
+ * the namespaced virtual requestId. A later Response-tab click resolves from
8
+ * here instead of re-issuing a debugger round-trip against a session that may
9
+ * have moved on.
10
+ *
11
+ * Contract:
12
+ * - `prime(id, fetch)` is idempotent per id: while an entry is pending or a
13
+ * settled entry is still live, later primes are ignored.
14
+ * - A fetch rejection — or a resolved value whose `sizeOf` exceeds
15
+ * `perEntryMaxChars` — becomes an ERROR SENTINEL: the id stays known but
16
+ * every lookup rejects with the canonical not-found message (the same
17
+ * answer a real CDP backend gives for an unknown requestId, so the
18
+ * front-end renders its normal failure state).
19
+ * - `lookup(id)` resolves the cached value, awaits a still-pending fetch (a
20
+ * panel click can land before the prefetch settles), and rejects
21
+ * not-found for unknown / expired / evicted / sentinel entries.
22
+ * - Bounds apply to SETTLED entries only: LRU by settle/lookup recency up to
23
+ * `maxEntries`, plus a `maxTotalChars` budget over `sizeOf`. A pending
24
+ * entry counts 0 and is never evicted — evicting an in-flight prefetch
25
+ * would strand its waiters.
26
+ * - TTL is anchored to the SETTLE time (not the prime() call time) and is
27
+ * enforced lazily on the next prime/lookup.
28
+ */
29
+ /**
30
+ * Default per-entry size ceiling (chars). Exported so callers that need to
31
+ * pre-screen a fetch BEFORE issuing it (e.g. skipping a CDP round-trip for a
32
+ * response already known to be oversized) reference the exact same number
33
+ * `PrefetchCache`'s own default enforces — one source of truth, not two
34
+ * independently-configured limits that could silently drift apart.
35
+ */
36
+ export declare const DEFAULT_PER_ENTRY_MAX_CHARS: number;
37
+ export interface PrefetchCacheOptions {
38
+ maxEntries?: number;
39
+ maxTotalChars?: number;
40
+ perEntryMaxChars?: number;
41
+ ttlMs?: number;
42
+ /** Injectable clock for TTL tests. */
43
+ now?: () => number;
44
+ }
45
+ export declare class PrefetchCache<V> {
46
+ private readonly sizeOf;
47
+ private readonly map;
48
+ private readonly maxEntries;
49
+ private readonly maxTotalChars;
50
+ private readonly perEntryMaxChars;
51
+ private readonly ttlMs;
52
+ private readonly now;
53
+ constructor(sizeOf: (v: V) => number, opts?: PrefetchCacheOptions);
54
+ /**
55
+ * Returns `true` when this call actually started a new fetch, `false` when
56
+ * it was a no-op (idempotent re-prime of an id that's already pending or
57
+ * still live). Callers that admission-gate priming (a concurrency cap) need
58
+ * this to know whether they actually consumed a slot — incrementing a
59
+ * counter unconditionally would leak a slot on every no-op re-prime.
60
+ */
61
+ prime(id: string, fetch: () => Promise<V>): boolean;
62
+ lookup(id: string): Promise<V>;
63
+ /** Retire a previous redirect hop without disturbing unrelated cached requests. */
64
+ delete(id: string): void;
65
+ clear(): void;
66
+ get size(): number;
67
+ private isExpired;
68
+ private sweepExpired;
69
+ /** Evict oldest SETTLED entries until both bounds hold; pending are exempt. */
70
+ private evict;
71
+ }
72
+ //# sourceMappingURL=body-cache.d.ts.map
@@ -0,0 +1,179 @@
1
+ /**
2
+ * PrefetchCache — a bounded, TTL'd "prime now / read later" promise cache.
3
+ *
4
+ * The network forwarder prefetches `Network.getResponseBody` /
5
+ * `Network.getRequestPostData` from the simulator's CDP session the moment a
6
+ * request finishes (the renderer may evict the resource soon after), keyed by
7
+ * the namespaced virtual requestId. A later Response-tab click resolves from
8
+ * here instead of re-issuing a debugger round-trip against a session that may
9
+ * have moved on.
10
+ *
11
+ * Contract:
12
+ * - `prime(id, fetch)` is idempotent per id: while an entry is pending or a
13
+ * settled entry is still live, later primes are ignored.
14
+ * - A fetch rejection — or a resolved value whose `sizeOf` exceeds
15
+ * `perEntryMaxChars` — becomes an ERROR SENTINEL: the id stays known but
16
+ * every lookup rejects with the canonical not-found message (the same
17
+ * answer a real CDP backend gives for an unknown requestId, so the
18
+ * front-end renders its normal failure state).
19
+ * - `lookup(id)` resolves the cached value, awaits a still-pending fetch (a
20
+ * panel click can land before the prefetch settles), and rejects
21
+ * not-found for unknown / expired / evicted / sentinel entries.
22
+ * - Bounds apply to SETTLED entries only: LRU by settle/lookup recency up to
23
+ * `maxEntries`, plus a `maxTotalChars` budget over `sizeOf`. A pending
24
+ * entry counts 0 and is never evicted — evicting an in-flight prefetch
25
+ * would strand its waiters.
26
+ * - TTL is anchored to the SETTLE time (not the prime() call time) and is
27
+ * enforced lazily on the next prime/lookup.
28
+ */
29
+ const NOT_FOUND = 'No resource with given identifier found';
30
+ /**
31
+ * Default per-entry size ceiling (chars). Exported so callers that need to
32
+ * pre-screen a fetch BEFORE issuing it (e.g. skipping a CDP round-trip for a
33
+ * response already known to be oversized) reference the exact same number
34
+ * `PrefetchCache`'s own default enforces — one source of truth, not two
35
+ * independently-configured limits that could silently drift apart.
36
+ */
37
+ export const DEFAULT_PER_ENTRY_MAX_CHARS = 16 * 1024 * 1024;
38
+ export class PrefetchCache {
39
+ sizeOf;
40
+ map = new Map();
41
+ maxEntries;
42
+ maxTotalChars;
43
+ perEntryMaxChars;
44
+ ttlMs;
45
+ now;
46
+ constructor(sizeOf, opts = {}) {
47
+ this.sizeOf = sizeOf;
48
+ this.maxEntries = opts.maxEntries ?? 256;
49
+ this.maxTotalChars = opts.maxTotalChars ?? 64 * 1024 * 1024;
50
+ this.perEntryMaxChars = opts.perEntryMaxChars ?? DEFAULT_PER_ENTRY_MAX_CHARS;
51
+ this.ttlMs = opts.ttlMs ?? 5 * 60_000;
52
+ this.now = opts.now ?? (() => Date.now());
53
+ }
54
+ /**
55
+ * Returns `true` when this call actually started a new fetch, `false` when
56
+ * it was a no-op (idempotent re-prime of an id that's already pending or
57
+ * still live). Callers that admission-gate priming (a concurrency cap) need
58
+ * this to know whether they actually consumed a slot — incrementing a
59
+ * counter unconditionally would leak a slot on every no-op re-prime.
60
+ */
61
+ prime(id, fetch) {
62
+ this.sweepExpired();
63
+ const existing = this.map.get(id);
64
+ if (existing && (existing.pending || !this.isExpired(existing)))
65
+ return false;
66
+ if (existing)
67
+ this.map.delete(id);
68
+ // A synchronously-throwing fetch (destroyed webContents) is a rejection.
69
+ let fetched;
70
+ try {
71
+ fetched = fetch();
72
+ }
73
+ catch (err) {
74
+ fetched = Promise.reject(err instanceof Error ? err : new Error(String(err)));
75
+ }
76
+ const entry = {
77
+ promise: fetched,
78
+ pending: true,
79
+ failed: false,
80
+ value: null,
81
+ size: 0,
82
+ settledAt: 0,
83
+ };
84
+ entry.promise = fetched.then((v) => {
85
+ entry.pending = false;
86
+ entry.settledAt = this.now();
87
+ const size = this.sizeOf(v);
88
+ if (size > this.perEntryMaxChars) {
89
+ entry.failed = true;
90
+ throw new Error(NOT_FOUND);
91
+ }
92
+ entry.value = v;
93
+ entry.size = size;
94
+ // Refresh recency at settle time (identity-checked: a clear() while
95
+ // pending must not resurrect the entry) and enforce the bounds now
96
+ // that this entry's real size is known.
97
+ if (this.map.get(id) === entry) {
98
+ this.map.delete(id);
99
+ this.map.set(id, entry);
100
+ this.evict();
101
+ }
102
+ return v;
103
+ }, () => {
104
+ entry.pending = false;
105
+ entry.failed = true;
106
+ entry.settledAt = this.now();
107
+ throw new Error(NOT_FOUND);
108
+ });
109
+ // A never-looked-up sentinel must not surface as an unhandled rejection.
110
+ entry.promise.catch(() => { });
111
+ this.map.set(id, entry);
112
+ return true;
113
+ }
114
+ lookup(id) {
115
+ this.sweepExpired();
116
+ const e = this.map.get(id);
117
+ if (!e)
118
+ return Promise.reject(new Error(NOT_FOUND));
119
+ // A pending entry's normalized promise already carries the outcome the
120
+ // waiter needs (value, sentinel, or size overflow) — hand it out directly
121
+ // so the answer never races the map bookkeeping.
122
+ if (e.pending)
123
+ return e.promise;
124
+ if (e.failed || this.isExpired(e)) {
125
+ if (!e.failed)
126
+ this.map.delete(id);
127
+ return Promise.reject(new Error(NOT_FOUND));
128
+ }
129
+ const v = e.value;
130
+ if (v === null)
131
+ return Promise.reject(new Error(NOT_FOUND));
132
+ // A hit refreshes LRU recency.
133
+ this.map.delete(id);
134
+ this.map.set(id, e);
135
+ return Promise.resolve(v);
136
+ }
137
+ /** Retire a previous redirect hop without disturbing unrelated cached requests. */
138
+ delete(id) {
139
+ this.map.delete(id);
140
+ }
141
+ clear() {
142
+ this.map.clear();
143
+ }
144
+ get size() {
145
+ return this.map.size;
146
+ }
147
+ isExpired(e) {
148
+ return !e.pending && this.now() - e.settledAt > this.ttlMs;
149
+ }
150
+ sweepExpired() {
151
+ for (const [k, e] of this.map) {
152
+ if (this.isExpired(e))
153
+ this.map.delete(k);
154
+ }
155
+ }
156
+ /** Evict oldest SETTLED entries until both bounds hold; pending are exempt. */
157
+ evict() {
158
+ let settled = 0;
159
+ let total = 0;
160
+ for (const e of this.map.values()) {
161
+ if (!e.pending) {
162
+ settled++;
163
+ total += e.size;
164
+ }
165
+ }
166
+ if (settled <= this.maxEntries && total <= this.maxTotalChars)
167
+ return;
168
+ for (const [k, e] of this.map) {
169
+ if (settled <= this.maxEntries && total <= this.maxTotalChars)
170
+ break;
171
+ if (e.pending)
172
+ continue;
173
+ this.map.delete(k);
174
+ settled--;
175
+ total -= e.size;
176
+ }
177
+ }
178
+ }
179
+ //# sourceMappingURL=body-cache.js.map