@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.
- package/README.md +51 -660
- package/dist/main/api.d.ts +2 -1
- package/dist/main/app/app.d.ts +41 -12
- package/dist/main/app/app.js +299 -514
- package/dist/main/app/bootstrap.d.ts +8 -5
- package/dist/main/app/bootstrap.js +15 -15
- package/dist/main/app/editor-view.d.ts +21 -0
- package/dist/main/app/editor-view.js +71 -0
- package/dist/main/app/global-mirrors.d.ts +23 -0
- package/dist/main/app/global-mirrors.js +37 -0
- package/dist/main/app/host-sidebar-default.d.ts +19 -0
- package/dist/main/app/host-sidebar-default.js +44 -0
- package/dist/main/app/lifecycle.d.ts +12 -1
- package/dist/main/app/lifecycle.js +27 -1
- package/dist/main/app/menu-setup.d.ts +13 -0
- package/dist/main/app/menu-setup.js +49 -0
- package/dist/main/app/native-overview.d.ts +1 -1
- package/dist/main/app/open-project-ipc.d.ts +13 -0
- package/dist/main/app/open-project-ipc.js +21 -0
- package/dist/main/app/project-list-surface.d.ts +31 -0
- package/dist/main/app/project-list-surface.js +20 -0
- package/dist/main/app/project-window.d.ts +36 -0
- package/dist/main/app/project-window.js +93 -0
- package/dist/main/app/servers.d.ts +17 -0
- package/dist/main/app/servers.js +60 -0
- package/dist/main/app/ui-extension-targets.d.ts +42 -0
- package/dist/main/app/ui-extension-targets.js +101 -0
- package/dist/main/app/window-close-reveal.harness.d.ts +34 -0
- package/dist/main/app/window-close-reveal.harness.js +65 -0
- package/dist/main/app/window-events.d.ts +15 -0
- package/dist/main/app/window-events.js +45 -0
- package/dist/main/app/window-runtime-services.d.ts +41 -0
- package/dist/main/app/window-runtime-services.js +197 -0
- package/dist/main/app/workbench-modules.d.ts +24 -0
- package/dist/main/app/workbench-modules.js +51 -0
- package/dist/main/app/workbench-window.d.ts +85 -0
- package/dist/main/app/workbench-window.js +310 -0
- package/dist/main/index.bundle.js +11712 -9986
- package/dist/main/index.js +49 -1
- package/dist/main/ipc/app-lifecycle.d.ts +1 -31
- package/dist/main/ipc/app-lifecycle.js +1 -53
- package/dist/main/ipc/app.d.ts +4 -1
- package/dist/main/ipc/app.js +4 -3
- package/dist/main/ipc/bridge-router.d.ts +19 -116
- package/dist/main/ipc/bridge-router.js +28 -2128
- package/dist/main/ipc/device-picker.d.ts +16 -0
- package/dist/main/ipc/device-picker.js +27 -0
- package/dist/main/ipc/index.d.ts +5 -0
- package/dist/main/ipc/index.js +5 -0
- package/dist/main/ipc/internal-devtools.d.ts +16 -0
- package/dist/main/ipc/internal-devtools.js +10 -0
- package/dist/main/ipc/page-scroll.d.ts +1 -13
- package/dist/main/ipc/page-scroll.js +1 -16
- package/dist/main/ipc/popover.d.ts +4 -1
- package/dist/main/ipc/popover.js +26 -19
- package/dist/main/ipc/project-create.d.ts +16 -0
- package/dist/main/ipc/project-create.js +27 -0
- package/dist/main/ipc/project-fs.d.ts +38 -3
- package/dist/main/ipc/project-fs.js +53 -22
- package/dist/main/ipc/projects.d.ts +3 -3
- package/dist/main/ipc/projects.js +47 -11
- package/dist/main/ipc/session-listener-bag.d.ts +1 -40
- package/dist/main/ipc/session-listener-bag.js +1 -39
- package/dist/main/ipc/session.d.ts +4 -1
- package/dist/main/ipc/session.js +26 -26
- package/dist/main/ipc/settings.d.ts +4 -1
- package/dist/main/ipc/settings.js +17 -19
- package/dist/main/ipc/simulator-module.d.ts +9 -3
- package/dist/main/ipc/simulator-module.js +13 -10
- package/dist/main/ipc/simulator.d.ts +4 -1
- package/dist/main/ipc/simulator.js +12 -18
- package/dist/main/ipc/tooltip.d.ts +14 -0
- package/dist/main/ipc/tooltip.js +29 -0
- package/dist/main/ipc/views.d.ts +19 -2
- package/dist/main/ipc/views.js +76 -8
- package/dist/main/runtime/devtools-backend-before-quit.harness.d.ts +43 -0
- package/dist/main/runtime/devtools-backend-before-quit.harness.js +87 -0
- package/dist/main/runtime/devtools-backend.js +60 -4
- package/dist/main/runtime/devtools-runtime-mock.harness.d.ts +21 -0
- package/dist/main/runtime/devtools-runtime-mock.harness.js +313 -0
- package/dist/main/runtime/miniapp-runtime.d.ts +91 -22
- package/dist/main/services/app-services.d.ts +62 -0
- package/dist/main/services/app-services.js +64 -0
- package/dist/main/services/automation/connection-target.d.ts +36 -0
- package/dist/main/services/automation/connection-target.js +29 -0
- package/dist/main/services/automation/console-bridge.d.ts +28 -0
- package/dist/main/services/automation/console-bridge.js +91 -0
- package/dist/main/services/automation/handlers/app.js +4 -4
- package/dist/main/services/automation/handlers/element.js +55 -21
- package/dist/main/services/automation/index.d.ts +12 -1
- package/dist/main/services/automation/index.js +54 -133
- package/dist/main/services/cdp-session/index.d.ts +87 -0
- package/dist/main/services/cdp-session/index.js +173 -0
- package/dist/main/services/compile-standby.js +4 -0
- package/dist/main/services/console-forward/cdp-inject.d.ts +18 -0
- package/dist/main/services/console-forward/cdp-inject.js +30 -0
- package/dist/main/services/console-forward/global-console-mirror.d.ts +33 -0
- package/dist/main/services/console-forward/global-console-mirror.js +71 -0
- package/dist/main/services/console-forward/global-diagnostics-mirror.d.ts +33 -0
- package/dist/main/services/console-forward/global-diagnostics-mirror.js +73 -0
- package/dist/main/services/console-forward/index.d.ts +1 -46
- package/dist/main/services/console-forward/index.js +1 -185
- package/dist/main/services/console-forward/internal-log.d.ts +2 -0
- package/dist/main/services/console-forward/internal-log.js +2 -0
- package/dist/main/services/console-forward/open-gated-relay.d.ts +67 -0
- package/dist/main/services/console-forward/open-gated-relay.js +55 -0
- package/dist/main/services/default-adapter.js +1 -1
- package/dist/main/services/diagnostics/index.d.ts +1 -48
- package/dist/main/services/diagnostics/index.js +1 -60
- package/dist/main/services/dimina-resource-server.d.ts +1 -6
- package/dist/main/services/dimina-resource-server.js +1 -98
- package/dist/main/services/elements-forward/index.d.ts +132 -15
- package/dist/main/services/elements-forward/index.js +155 -304
- package/dist/main/services/fs-bridge-protocol.d.ts +61 -0
- package/dist/main/services/fs-bridge-protocol.js +34 -0
- package/dist/main/services/fs-watch-sse.d.ts +40 -0
- package/dist/main/services/fs-watch-sse.js +113 -0
- package/dist/main/services/http-json.d.ts +9 -0
- package/dist/main/services/http-json.js +6 -0
- package/dist/main/services/layout/index.d.ts +11 -0
- package/dist/main/services/layout/index.js +23 -0
- package/dist/main/services/mcp/connection-owner.d.ts +38 -0
- package/dist/main/services/mcp/connection-owner.js +79 -0
- package/dist/main/services/mcp/index.d.ts +3 -1
- package/dist/main/services/mcp/index.js +4 -3
- package/dist/main/services/mcp/opened-project.d.ts +88 -0
- package/dist/main/services/mcp/opened-project.js +60 -0
- package/dist/main/services/mcp/server.d.ts +2 -1
- package/dist/main/services/mcp/server.js +29 -4
- package/dist/main/services/mcp/target-manager.d.ts +71 -23
- package/dist/main/services/mcp/target-manager.js +269 -138
- package/dist/main/services/mcp/target-selection.d.ts +47 -0
- package/dist/main/services/mcp/target-selection.js +71 -0
- package/dist/main/services/mcp/tools/context-tools.js +20 -5
- package/dist/main/services/mcp/tools/project-tools.d.ts +72 -0
- package/dist/main/services/mcp/tools/project-tools.js +133 -0
- package/dist/main/services/module.d.ts +13 -5
- package/dist/main/services/network-forward/body-cache.d.ts +72 -0
- package/dist/main/services/network-forward/body-cache.js +179 -0
- package/dist/main/services/network-forward/frontend-dispatch.d.ts +91 -0
- package/dist/main/services/network-forward/frontend-dispatch.js +148 -0
- package/dist/main/services/network-forward/global-body-gate.d.ts +46 -0
- package/dist/main/services/network-forward/global-body-gate.js +93 -0
- package/dist/main/services/network-forward/global-mirror-test-fixtures.d.ts +48 -0
- package/dist/main/services/network-forward/global-mirror-test-fixtures.js +96 -0
- package/dist/main/services/network-forward/http.d.ts +47 -0
- package/dist/main/services/network-forward/http.js +162 -0
- package/dist/main/services/network-forward/index.d.ts +135 -15
- package/dist/main/services/network-forward/index.js +854 -224
- package/dist/main/services/network-forward/request-ids.d.ts +5 -0
- package/dist/main/services/network-forward/request-ids.js +5 -0
- package/dist/main/services/network-forward/user-facing.d.ts +21 -0
- package/dist/main/services/network-forward/user-facing.js +50 -0
- package/dist/main/services/network-forward/websocket.d.ts +36 -0
- package/dist/main/services/network-forward/websocket.js +120 -0
- package/dist/main/services/notifications/renderer-notifier.d.ts +71 -9
- package/dist/main/services/notifications/renderer-notifier.js +45 -8
- package/dist/main/services/projects/create-project-service.js +19 -5
- package/dist/main/services/projects/local-provider.js +8 -4
- package/dist/main/services/projects/project-repository.d.ts +59 -7
- package/dist/main/services/projects/project-repository.js +285 -51
- package/dist/main/services/projects/types.d.ts +44 -34
- package/dist/main/services/render-inspect/index.d.ts +12 -2
- package/dist/main/services/render-inspect/index.js +21 -102
- package/dist/main/services/safe-area/index.d.ts +21 -6
- package/dist/main/services/safe-area/index.js +92 -46
- package/dist/main/services/service-host-pool/pool.d.ts +1 -196
- package/dist/main/services/service-host-pool/pool.js +1 -363
- package/dist/main/services/settings/index.d.ts +7 -1
- package/dist/main/services/settings/index.js +22 -2
- package/dist/main/services/simulator/custom-apis.d.ts +1 -42
- package/dist/main/services/simulator/custom-apis.js +1 -46
- package/dist/main/services/simulator/referer.d.ts +1 -9
- package/dist/main/services/simulator/referer.js +1 -19
- package/dist/main/services/simulator/ui-extensions.d.ts +21 -0
- package/dist/main/services/simulator/ui-extensions.js +176 -0
- package/dist/main/services/simulator-appdata/index.d.ts +6 -0
- package/dist/main/services/simulator-appdata/index.js +21 -2
- package/dist/main/services/simulator-current-page/index.d.ts +5 -3
- package/dist/main/services/simulator-current-page/index.js +8 -1
- package/dist/main/services/simulator-storage/index.d.ts +34 -5
- package/dist/main/services/simulator-storage/index.js +73 -71
- package/dist/main/services/simulator-storage/service-storage-ops.d.ts +1 -39
- package/dist/main/services/simulator-storage/service-storage-ops.js +1 -66
- package/dist/main/services/simulator-storage/window-scope.d.ts +20 -0
- package/dist/main/services/simulator-storage/window-scope.js +20 -0
- package/dist/main/services/simulator-temp-files/disk.d.ts +1 -54
- package/dist/main/services/simulator-temp-files/disk.js +1 -237
- package/dist/main/services/simulator-temp-files/fs-channels.d.ts +1 -68
- package/dist/main/services/simulator-temp-files/fs-channels.js +1 -107
- package/dist/main/services/simulator-temp-files/index.d.ts +1 -32
- package/dist/main/services/simulator-temp-files/index.js +1 -181
- package/dist/main/services/simulator-temp-files/request-handler.d.ts +1 -29
- package/dist/main/services/simulator-temp-files/request-handler.js +1 -177
- package/dist/main/services/simulator-temp-files/resolver.d.ts +1 -21
- package/dist/main/services/simulator-temp-files/resolver.js +1 -21
- package/dist/main/services/simulator-temp-files/store.d.ts +1 -13
- package/dist/main/services/simulator-temp-files/store.js +1 -23
- package/dist/main/services/update/github-release-checker.js +22 -3
- package/dist/main/services/update/update-manager.d.ts +21 -4
- package/dist/main/services/update/update-manager.js +55 -11
- package/dist/main/services/views/clear-console-filter.d.ts +44 -0
- package/dist/main/services/views/clear-console-filter.js +86 -0
- package/dist/main/services/views/console-filter-test-fixtures.d.ts +94 -0
- package/dist/main/services/views/console-filter-test-fixtures.js +82 -0
- package/dist/main/services/views/console-filter.d.ts +94 -0
- package/dist/main/services/views/console-filter.js +190 -0
- package/dist/main/services/views/devtools-tabs.d.ts +24 -4
- package/dist/main/services/views/devtools-tabs.js +40 -21
- package/dist/main/services/views/frontend-bootstrap-gate.d.ts +59 -0
- package/dist/main/services/views/frontend-bootstrap-gate.js +117 -0
- package/dist/main/services/views/host-dialog-port-channel.d.ts +18 -0
- package/dist/main/services/views/host-dialog-port-channel.js +15 -0
- package/dist/main/services/views/host-dialog-session-runtime.d.ts +10 -0
- package/dist/main/services/views/host-dialog-session-runtime.js +17 -0
- package/dist/main/services/views/host-dialog-view.d.ts +95 -0
- package/dist/main/services/views/host-dialog-view.js +147 -0
- package/dist/main/services/views/host-sidebar-port-channel.d.ts +18 -0
- package/dist/main/services/views/host-sidebar-port-channel.js +15 -0
- package/dist/main/services/views/host-sidebar-session-runtime.d.ts +10 -0
- package/dist/main/services/views/host-sidebar-session-runtime.js +17 -0
- package/dist/main/services/views/host-sidebar-view.d.ts +59 -0
- package/dist/main/services/views/host-sidebar-view.js +44 -0
- package/dist/main/services/views/host-slot-port-channel.d.ts +124 -0
- package/dist/main/services/views/host-slot-port-channel.js +289 -0
- package/dist/main/services/views/host-slot-session-runtime.d.ts +40 -0
- package/dist/main/services/views/host-slot-session-runtime.js +50 -0
- package/dist/main/services/views/host-slot-view.d.ts +109 -0
- package/dist/main/services/views/host-slot-view.js +147 -0
- package/dist/main/services/views/host-toolbar-port-channel.d.ts +6 -91
- package/dist/main/services/views/host-toolbar-port-channel.js +10 -243
- package/dist/main/services/views/host-toolbar-session-runtime.d.ts +5 -30
- package/dist/main/services/views/host-toolbar-session-runtime.js +9 -47
- package/dist/main/services/views/host-toolbar-view.d.ts +34 -7
- package/dist/main/services/views/host-toolbar-view.js +30 -237
- package/dist/main/services/views/managed-web-contents-view.d.ts +48 -0
- package/dist/main/services/views/managed-web-contents-view.js +143 -0
- package/dist/main/services/views/miniapp-partition.d.ts +1 -89
- package/dist/main/services/views/miniapp-partition.js +1 -158
- package/dist/main/services/views/native-simulator-devtools-host.js +206 -68
- package/dist/main/services/views/native-simulator-view.d.ts +6 -0
- package/dist/main/services/views/native-simulator-view.js +47 -40
- package/dist/main/services/views/native-view-tree.d.ts +25 -0
- package/dist/main/services/views/native-view-tree.js +69 -0
- package/dist/main/services/views/overlay-panels-view.d.ts +63 -4
- package/dist/main/services/views/overlay-panels-view.js +257 -108
- package/dist/main/services/views/placement-reconciler.d.ts +18 -18
- package/dist/main/services/views/placement-reconciler.js +91 -29
- package/dist/main/services/views/placement-test-driver.d.ts +27 -0
- package/dist/main/services/views/placement-test-driver.js +29 -0
- package/dist/main/services/views/refresh-styles.d.ts +10 -0
- package/dist/main/services/views/refresh-styles.js +57 -0
- package/dist/main/services/views/simulator-session-policy.d.ts +1 -27
- package/dist/main/services/views/simulator-session-policy.js +1 -98
- package/dist/main/services/views/view-manager-devtools-host-test-fixtures.d.ts +76 -0
- package/dist/main/services/views/view-manager-devtools-host-test-fixtures.js +184 -0
- package/dist/main/services/views/view-manager.d.ts +69 -88
- package/dist/main/services/views/view-manager.js +62 -7
- package/dist/main/services/views/workbench-view.d.ts +2 -0
- package/dist/main/services/views/workbench-view.js +104 -17
- package/dist/main/services/window-contexts/context-router.d.ts +36 -0
- package/dist/main/services/window-contexts/context-router.js +55 -0
- package/dist/main/services/workbench-coi-host.d.ts +52 -0
- package/dist/main/services/workbench-coi-host.js +227 -0
- package/dist/main/services/workbench-coi-server.d.ts +11 -0
- package/dist/main/services/workbench-coi-server.js +126 -126
- package/dist/main/services/workbench-coi-shutdown.d.ts +40 -0
- package/dist/main/services/workbench-coi-shutdown.js +69 -0
- package/dist/main/services/workbench-coi-static.d.ts +23 -0
- package/dist/main/services/workbench-coi-static.js +87 -0
- package/dist/main/services/workbench-context.d.ts +88 -8
- package/dist/main/services/workbench-context.js +54 -6
- package/dist/main/services/workspace/compile-log-buffer.d.ts +40 -0
- package/dist/main/services/workspace/compile-log-buffer.js +41 -0
- package/dist/main/services/workspace/compile-mode-adapter.d.ts +18 -0
- package/dist/main/services/workspace/compile-mode-adapter.js +57 -0
- package/dist/main/services/workspace/compile-mode-store.d.ts +25 -0
- package/dist/main/services/workspace/compile-mode-store.js +71 -0
- package/dist/main/services/workspace/open-project-guards.d.ts +16 -0
- package/dist/main/services/workspace/open-project-guards.js +42 -0
- package/dist/main/services/workspace/rebuild-status.d.ts +37 -0
- package/dist/main/services/workspace/rebuild-status.js +36 -0
- package/dist/main/services/workspace/session-status-store.d.ts +47 -0
- package/dist/main/services/workspace/session-status-store.js +73 -0
- package/dist/main/services/workspace/status-tap.d.ts +20 -0
- package/dist/main/services/workspace/status-tap.js +32 -0
- package/dist/main/services/workspace/workspace-compile-modes.d.ts +59 -0
- package/dist/main/services/workspace/workspace-compile-modes.js +93 -0
- package/dist/main/services/workspace/workspace-lifecycle-race.testutil.d.ts +22 -0
- package/dist/main/services/workspace/workspace-lifecycle-race.testutil.js +62 -0
- package/dist/main/services/workspace/workspace-referer.d.ts +17 -0
- package/dist/main/services/workspace/workspace-referer.js +26 -0
- package/dist/main/services/workspace/workspace-service.d.ts +7 -5
- package/dist/main/services/workspace/workspace-service.js +96 -135
- package/dist/main/services/workspace/workspace-thumbnails.d.ts +22 -0
- package/dist/main/services/workspace/workspace-thumbnails.js +67 -0
- package/dist/main/utils/ipc-context-source.d.ts +40 -0
- package/dist/main/utils/ipc-context-source.js +23 -0
- package/dist/main/utils/ipc-registry.d.ts +46 -21
- package/dist/main/utils/ipc-registry.js +166 -76
- package/dist/main/utils/paths.d.ts +18 -0
- package/dist/main/utils/paths.js +18 -0
- package/dist/main/utils/sender-policy.d.ts +10 -1
- package/dist/main/utils/sender-policy.js +42 -4
- package/dist/main/utils/theme.d.ts +18 -8
- package/dist/main/utils/theme.js +19 -9
- package/dist/main/windows/internal-devtools-window/index.d.ts +66 -0
- package/dist/main/windows/internal-devtools-window/index.js +160 -0
- package/dist/main/windows/main-window/create.d.ts +16 -0
- package/dist/main/windows/main-window/create.js +19 -11
- package/dist/main/windows/main-window/events.d.ts +1 -1
- package/dist/main/windows/main-window/events.js +26 -13
- package/dist/main/windows/main-window/index.d.ts +1 -1
- package/dist/main/windows/main-window/index.js +1 -1
- package/dist/main/windows/service-host-window/create.d.ts +1 -92
- package/dist/main/windows/service-host-window/create.js +1 -154
- package/dist/native-host/common/common.js +173 -53
- package/dist/native-host/container/pageFrame.css +1 -1
- package/dist/native-host/render/render.js +8278 -3659
- package/dist/native-host/service/service.js +2 -2
- package/dist/preload/index.d.ts +2 -0
- package/dist/preload/index.js +1 -0
- package/dist/preload/instrumentation/app-data.d.ts +2 -2
- package/dist/preload/instrumentation/app-data.js +1 -1
- package/dist/preload/instrumentation/wxml.js +1 -1
- package/dist/preload/runtime/bridge.d.ts +3 -3
- package/dist/preload/runtime/bridge.js +2 -2
- package/dist/preload/runtime/clipboard.d.ts +6 -0
- package/dist/preload/runtime/clipboard.js +12 -0
- package/dist/preload/runtime/host-dialog-advertiser.d.ts +22 -0
- package/dist/preload/runtime/host-dialog-advertiser.js +37 -0
- package/dist/preload/runtime/host-dialog-port.d.ts +44 -0
- package/dist/preload/runtime/host-dialog-port.js +53 -0
- package/dist/preload/runtime/host-dialog-runtime.d.ts +28 -0
- package/dist/preload/runtime/host-dialog-runtime.js +36 -0
- package/dist/preload/runtime/host-sidebar-advertiser.d.ts +19 -0
- package/dist/preload/runtime/host-sidebar-advertiser.js +35 -0
- package/dist/preload/runtime/host-sidebar-port.d.ts +44 -0
- package/dist/preload/runtime/host-sidebar-port.js +53 -0
- package/dist/preload/runtime/host-sidebar-runtime.d.ts +28 -0
- package/dist/preload/runtime/host-sidebar-runtime.js +36 -0
- package/dist/preload/runtime/host-slot-port-bridge.d.ts +18 -0
- package/dist/preload/runtime/host-slot-port-bridge.js +112 -0
- package/dist/preload/runtime/host-toolbar-advertiser.d.ts +5 -13
- package/dist/preload/runtime/host-toolbar-advertiser.js +18 -38
- package/dist/preload/runtime/host-toolbar-port.d.ts +9 -0
- package/dist/preload/runtime/host-toolbar-port.js +11 -95
- package/dist/preload/runtime/native-host.d.ts +14 -0
- package/dist/preload/runtime/native-host.js +5 -8
- package/dist/preload/runtime/node-bindings.d.ts +18 -0
- package/dist/preload/runtime/node-bindings.js +44 -0
- package/dist/preload/runtime/temp-files.js +9 -2
- package/dist/preload/runtime/wait-for-slot-root.d.ts +23 -0
- package/dist/preload/runtime/wait-for-slot-root.js +80 -0
- package/dist/preload/shared/api-compat.js +63 -41
- package/dist/preload/windows/host-dialog-runtime.cjs +360 -0
- package/dist/preload/windows/host-dialog-runtime.cjs.map +7 -0
- package/dist/preload/windows/host-dialog-runtime.d.ts +2 -0
- package/dist/preload/windows/host-dialog-runtime.js +13 -0
- package/dist/preload/windows/host-sidebar-runtime.cjs +361 -0
- package/dist/preload/windows/host-sidebar-runtime.cjs.map +7 -0
- package/dist/preload/windows/host-sidebar-runtime.d.ts +2 -0
- package/dist/preload/windows/host-sidebar-runtime.js +13 -0
- package/dist/preload/windows/host-toolbar-runtime.cjs +142 -52
- package/dist/preload/windows/host-toolbar-runtime.cjs.map +3 -3
- package/dist/preload/windows/main.cjs +4922 -1246
- package/dist/preload/windows/main.cjs.map +4 -4
- package/dist/preload/windows/main.css +428 -0
- package/dist/preload/windows/main.css.map +7 -0
- package/dist/preload/windows/simulator.cjs +376 -322
- package/dist/preload/windows/simulator.cjs.map +4 -4
- package/dist/preload/windows/simulator.js +376 -322
- package/dist/render-host/pageFrame.html +4 -4
- package/dist/render-host/preload.cjs +30 -0
- package/dist/render-host/render-inspect.js +184 -115
- package/dist/renderer/assets/button-CB2MWjHY.js +2 -0
- package/dist/renderer/assets/constants-CkoGPQTS.js +2 -0
- package/dist/renderer/assets/constants-zQZ2-y21.js +2 -0
- package/dist/renderer/assets/createLucideIcon-cZ9FlZZw.js +2 -0
- package/dist/renderer/assets/devicePicker-H2eIO4e1.js +2 -0
- package/dist/renderer/assets/dialog-pHzEA8Vx.js +46 -0
- package/dist/renderer/assets/dist-B5HADirS.js +2 -0
- package/dist/renderer/assets/dist-DIFlRMKe.js +2 -0
- package/dist/renderer/assets/hostSidebarDefault-DRWh6OCt.js +2 -0
- package/dist/renderer/assets/index-CEL_XFge.js +2 -0
- package/dist/renderer/assets/input-CAObw95L.js +2 -0
- package/dist/renderer/assets/ipc-channels-overlays-gIPUFnqc.js +2 -0
- package/dist/renderer/assets/jsx-runtime-DICEQH_0.css +1 -0
- package/dist/renderer/assets/jsx-runtime-DIw5wnYl.js +9 -0
- package/dist/renderer/assets/plus-BQ9u5EbL.js +2 -0
- package/dist/renderer/assets/popover-Cw7G2Ctp.js +2 -0
- package/dist/renderer/assets/presets-DMZOb9ay.js +2 -0
- package/dist/renderer/assets/project-api-YTOr_Yvo.js +2 -0
- package/dist/renderer/assets/projectCreateDialog-BmLqiYxn.js +2 -0
- package/dist/renderer/assets/search-BMvuYF48.js +2 -0
- package/dist/renderer/assets/select-nFP95TxM.js +2 -0
- package/dist/renderer/assets/settings-CnpVfSWt.js +2 -0
- package/dist/renderer/assets/settings-api-Ccsf-Nsj.js +2 -0
- package/dist/renderer/assets/settings-tab-bar-CAzrv32m.js +2 -0
- package/dist/renderer/assets/smartphone-Bb2GdIKy.js +2 -0
- package/dist/renderer/assets/tabs-CPKN3Mmq.js +2 -0
- package/dist/renderer/assets/tooltip-D6AxXRk5.js +2 -0
- package/dist/renderer/assets/types-Bh0hA7El.js +2 -0
- package/dist/renderer/assets/updateDialog-CwndJ0Bl.js +2 -0
- package/dist/renderer/assets/utils-sEB5OZEQ.js +2 -0
- package/dist/renderer/assets/view-api-B-2zPBR5.js +2 -0
- package/dist/renderer/assets/view-ids-BfaDVV5P.js +2 -0
- package/dist/renderer/assets/workbench-C0Jkdlps.js +5 -0
- package/dist/renderer/assets/workbenchSettings-YD0Ctbm_.js +8 -0
- package/dist/renderer/entries/device-picker/index.html +28 -0
- package/dist/renderer/entries/host-sidebar-default/index.html +22 -0
- package/dist/renderer/entries/main/index.html +16 -7
- package/dist/renderer/entries/popover/index.html +16 -6
- package/dist/renderer/entries/project-create-dialog/index.html +27 -0
- package/dist/renderer/entries/settings/index.html +10 -5
- package/dist/renderer/entries/tooltip/index.html +21 -0
- package/dist/renderer/entries/update-dialog/index.html +25 -0
- package/dist/renderer/entries/workbench/index.html +49 -0
- package/dist/renderer/entries/workbench-settings/index.html +12 -5
- package/dist/service-host/appdata-set-data.cjs +39 -0
- package/dist/service-host/host-env-update.cjs +23 -0
- package/dist/service-host/preload.cjs +54 -48
- package/dist/service-host/service-message-queue.cjs +71 -0
- package/dist/service-host/sync-impls/menu-button-geometry.js +16 -5
- package/dist/service-host/sync-impls/menu-button.js +5 -3
- package/dist/service-host/sync-impls/system-info.js +31 -9
- package/dist/shared/bridge-channels.d.ts +1 -416
- package/dist/shared/bridge-channels.js +1 -89
- package/dist/shared/compile-mode-state.d.ts +73 -0
- package/dist/shared/compile-mode-state.js +100 -0
- package/dist/shared/compile-modes.d.ts +152 -0
- package/dist/shared/compile-modes.js +237 -0
- package/dist/shared/constants.d.ts +22 -0
- package/dist/shared/constants.js +22 -0
- package/dist/shared/dmb-resource-url.d.ts +2 -0
- package/dist/shared/dmb-resource-url.js +2 -0
- package/dist/shared/ipc-channels-overlays.d.ts +162 -0
- package/dist/shared/ipc-channels-overlays.js +203 -0
- package/dist/shared/ipc-channels.d.ts +24 -154
- package/dist/shared/ipc-channels.js +48 -96
- package/dist/shared/ipc-schemas.d.ts +143 -54
- package/dist/shared/ipc-schemas.js +137 -45
- package/dist/shared/node-bindings.d.ts +2 -0
- package/dist/shared/node-bindings.js +2 -0
- package/dist/shared/project-window-types.d.ts +42 -0
- package/dist/shared/project-window-types.js +2 -0
- package/dist/shared/simulator-route.d.ts +8 -0
- package/dist/shared/simulator-route.js +15 -0
- package/dist/shared/simulator-ui.d.ts +61 -0
- package/dist/shared/simulator-ui.js +12 -0
- package/dist/shared/types.d.ts +126 -41
- package/dist/shared/view-ids.d.ts +10 -0
- package/dist/shared/view-ids.js +23 -0
- package/dist/simulator/assets/bridge-channels-B3JAmRfl.js +2 -0
- package/dist/simulator/assets/device-shell-ATEhHV2_.css +1 -0
- package/dist/simulator/assets/device-shell-DucLepkm.js +431 -0
- package/dist/simulator/assets/simulator-B4rbcOVt.js +10 -0
- package/dist/simulator/assets/simulator-mini-app-DFo7fhi5.js +2 -0
- package/dist/simulator/assets/simulator-ui-BupATgKo.css +1 -0
- package/dist/simulator/assets/simulator-ui-i3GCc7YJ.js +2 -0
- package/dist/simulator/simulator.html +4 -3
- package/dist/simulator/temp-files.d.ts +35 -0
- package/dist/simulator/temp-files.js +121 -0
- package/dist/simulator/types.d.ts +50 -0
- package/dist/simulator/types.js +2 -0
- package/dist/vscode-workbench/assets/__vite-browser-external-JIkWewFf.js +1 -0
- package/dist/vscode-workbench/assets/{dist-TpGpmMGi.js → dist-CXG-u1VB.js} +3 -3
- package/dist/vscode-workbench/assets/fs-core-worker-urls-DZ1nod84.js +1 -0
- package/dist/vscode-workbench/assets/fs-core.worker-Bnmpp6fo.js +1 -0
- package/dist/vscode-workbench/assets/fs-query.worker-cZ-7Fjch.js +2 -0
- package/dist/vscode-workbench/assets/{iconv-lite-umd-C9tiCAJa.js → iconv-lite-umd-Dxx9Qyb4.js} +1 -1
- package/dist/vscode-workbench/assets/{index-DJ1HyMZ7.js → index-6VJMsaWj.js} +475 -475
- package/dist/vscode-workbench/assets/{jschardet-DE1jV513.js → jschardet-Ba3D16vt.js} +1 -1
- package/dist/vscode-workbench/index.html +21 -1
- package/package.json +23 -13
- package/dist/main/services/views/destroy-child-view.d.ts +0 -9
- package/dist/main/services/views/destroy-child-view.js +0 -23
- package/dist/preload/instrumentation/wxml-extract.d.ts +0 -11
- package/dist/preload/instrumentation/wxml-extract.js +0 -382
- package/dist/preload/shared/sid-registry.d.ts +0 -11
- package/dist/preload/shared/sid-registry.js +0 -38
- package/dist/renderer/assets/constants-EAMiwL9_.js +0 -2
- package/dist/renderer/assets/index-BMqyDx71.js +0 -49
- package/dist/renderer/assets/input-CDAEwpBO.js +0 -2
- package/dist/renderer/assets/ipc-transport-B7eFOR68.css +0 -1
- package/dist/renderer/assets/ipc-transport-_G1k5V1p.js +0 -9
- package/dist/renderer/assets/popover-DEdjK14m.js +0 -2
- package/dist/renderer/assets/select-DpKPCh3y.js +0 -2
- package/dist/renderer/assets/settings-M5q2elUr.js +0 -2
- package/dist/renderer/assets/settings-api-CDlZoHiO.js +0 -2
- package/dist/renderer/assets/workbenchSettings-CT_H1WhV.js +0 -8
- package/dist/shared/appdata-accumulator.d.ts +0 -95
- package/dist/shared/appdata-accumulator.js +0 -218
- package/dist/shared/request-core.d.ts +0 -84
- package/dist/shared/request-core.js +0 -168
- package/dist/shared/simulator-api-metadata.d.ts +0 -26
- package/dist/shared/simulator-api-metadata.js +0 -59
- package/dist/shared/vpath.d.ts +0 -42
- package/dist/shared/vpath.js +0 -105
- package/dist/simulator/assets/bridge-channels-zhsumfky.js +0 -2
- package/dist/simulator/assets/device-shell-C-wcFq3Z.js +0 -2
- package/dist/simulator/assets/device-shell-CS1rqAQz.css +0 -1
- package/dist/simulator/assets/jsx-runtime-BDTY6fEq.js +0 -2
- package/dist/simulator/assets/simulator-DU3-fS3v.js +0 -10
- package/dist/simulator/assets/simulator-mini-app-DzfMfnVM.js +0 -2
- package/dist/simulator/device-shell/menu-button-geometry.js +0 -8
- package/dist/vscode-workbench/assets/__vite-browser-external-CXi6Kz9W.js +0 -1
|
@@ -15,11 +15,12 @@ import { connectTarget, setCdpPort } from './target-manager.js';
|
|
|
15
15
|
import { recordMcpFailed, recordMcpStarted, recordMcpStopped } from './status.js';
|
|
16
16
|
import { registerCommonTargetTools } from './tool-registry.js';
|
|
17
17
|
import { registerContextTools } from './tools/context-tools.js';
|
|
18
|
+
import { registerProjectTools } from './tools/project-tools.js';
|
|
18
19
|
import { registerSimulatorTools } from './tools/simulator-tools.js';
|
|
19
20
|
import { registerWorkbenchTools } from './tools/workbench-tools.js';
|
|
20
21
|
const require = createRequire(import.meta.url);
|
|
21
22
|
const pkg = require('../../../../package.json');
|
|
22
|
-
function buildServer() {
|
|
23
|
+
function buildServer(projectHost) {
|
|
23
24
|
const server = new McpServer({
|
|
24
25
|
name: '@dimina-kit/devtools',
|
|
25
26
|
version: pkg.version,
|
|
@@ -32,14 +33,15 @@ function buildServer() {
|
|
|
32
33
|
registerWorkbenchTools(server);
|
|
33
34
|
// Cross-target: AI orientation overview
|
|
34
35
|
registerContextTools(server);
|
|
36
|
+
// Project lifecycle (open/close/status/wait/compile logs).
|
|
37
|
+
registerProjectTools(server, projectHost);
|
|
35
38
|
return server;
|
|
36
39
|
}
|
|
37
|
-
export function startMcpServer(resolvedCdpPort, mcpPort) {
|
|
40
|
+
export function startMcpServer(resolvedCdpPort, mcpPort, projectHost) {
|
|
38
41
|
setCdpPort(resolvedCdpPort);
|
|
39
42
|
// Connect to both targets (non-blocking)
|
|
40
43
|
connectTarget('simulator').catch(() => { });
|
|
41
44
|
connectTarget('workbench').catch(() => { });
|
|
42
|
-
const server = buildServer();
|
|
43
45
|
const transports = new Map();
|
|
44
46
|
const httpServer = createServer(async (req, res) => {
|
|
45
47
|
const url = new URL(req.url ?? '/', `http://localhost`);
|
|
@@ -47,7 +49,30 @@ export function startMcpServer(resolvedCdpPort, mcpPort) {
|
|
|
47
49
|
const transport = new SSEServerTransport('/message', res);
|
|
48
50
|
transports.set(transport.sessionId, transport);
|
|
49
51
|
res.on('close', () => transports.delete(transport.sessionId));
|
|
50
|
-
|
|
52
|
+
try {
|
|
53
|
+
// A fresh McpServer PER CONNECTION: the SDK's Protocol is strictly
|
|
54
|
+
// 1:1 with its transport (`connect()` throws "Already connected to a
|
|
55
|
+
// transport" if `this._transport` is already set), so reusing one
|
|
56
|
+
// global server across concurrent SSE clients breaks every
|
|
57
|
+
// connection after the first. Registration only builds tool-call
|
|
58
|
+
// closures over already-shared module-level state (target-manager's
|
|
59
|
+
// CDP connections/listeners) — it has no per-call side effects, so
|
|
60
|
+
// building N servers is cheap and duplicates nothing.
|
|
61
|
+
await buildServer(projectHost).connect(transport);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
transports.delete(transport.sessionId);
|
|
65
|
+
// `connect()` calls `transport.start()` (writes the SSE 200 + headers)
|
|
66
|
+
// BEFORE it can throw, so a post-start failure here has already sent
|
|
67
|
+
// headers — writeHead would itself throw. End the response instead so
|
|
68
|
+
// the client's stream closes cleanly rather than hanging forever with
|
|
69
|
+
// an open connection nothing will ever write to again.
|
|
70
|
+
if (!res.headersSent)
|
|
71
|
+
res.writeHead(500).end('MCP connect failed');
|
|
72
|
+
else
|
|
73
|
+
res.end();
|
|
74
|
+
console.error('[MCP] SSE connect failed:', err);
|
|
75
|
+
}
|
|
51
76
|
}
|
|
52
77
|
else if (req.method === 'POST' && url.pathname === '/message') {
|
|
53
78
|
const sessionId = url.searchParams.get('sessionId') ?? '';
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* - rolling buffers of console log and network request events
|
|
11
11
|
*/
|
|
12
12
|
import CDP from 'chrome-remote-interface';
|
|
13
|
+
import { type TargetIdentityFacts } from './connection-owner.js';
|
|
14
|
+
export { selectSimulatorTarget, selectWorkbenchTarget } from './target-selection.js';
|
|
13
15
|
export type TargetKind = 'simulator' | 'workbench';
|
|
14
16
|
export interface ConsoleLogEntry {
|
|
15
17
|
level: string;
|
|
@@ -38,38 +40,84 @@ export type NativeOverviewProvider = () => Promise<NativeOverview>;
|
|
|
38
40
|
interface TargetState {
|
|
39
41
|
client: CDP.Client | null;
|
|
40
42
|
connected: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The window this live connection ACTUALLY reached — not the one it was
|
|
45
|
+
* aimed at, and null when the target names no project window (the project
|
|
46
|
+
* list). Read on every `getClient`, so a connection left behind by a window
|
|
47
|
+
* switch is refused instead of answering for the wrong project.
|
|
48
|
+
*/
|
|
49
|
+
owner: object | null;
|
|
41
50
|
timer: ReturnType<typeof setTimeout> | null;
|
|
42
51
|
consoleLogs: ConsoleLogEntry[];
|
|
43
52
|
networkRequests: NetworkRequestEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* The owner these buffers were most recently cleared and populated for.
|
|
55
|
+
* Distinct from `owner`, which goes null the instant a target is lost: a
|
|
56
|
+
* reconnect that lands back on the same window (a transient CDP drop) must
|
|
57
|
+
* find its buffers intact, so what decides whether to clear is this record
|
|
58
|
+
* of the last owner they were published for, not the connection's current
|
|
59
|
+
* live/dead state.
|
|
60
|
+
*/
|
|
61
|
+
bufferOwner: object | null;
|
|
44
62
|
}
|
|
45
|
-
export declare function setCdpPort(port: number): void;
|
|
46
|
-
export declare function setNativeHost(enabled: boolean): void;
|
|
47
|
-
/**
|
|
48
|
-
* Update the active-page bridgeId so the `simulator` target follows the
|
|
49
|
-
* currently visible render guest. No-op when unchanged. When native-host is
|
|
50
|
-
* on and the simulator target is already connected, fire-and-forget a
|
|
51
|
-
* reconnect so MCP re-points at the new active page.
|
|
52
|
-
*/
|
|
53
|
-
export declare function setActiveBridgeId(id: string | null): void;
|
|
54
|
-
export declare function setNativeOverviewProvider(provider: NativeOverviewProvider | null): void;
|
|
55
|
-
export declare function getNativeOverviewProvider(): NativeOverviewProvider | null;
|
|
56
63
|
/**
|
|
57
|
-
*
|
|
64
|
+
* What MCP needs to know about ONE project window.
|
|
58
65
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* (pageFrame.html?...bridgeId=<id>), preferring the guest matching
|
|
64
|
-
* `activeBridgeId`, then any pageFrame guest, then degrading to the shell.
|
|
66
|
+
* Every project runs in its own window, so native-host mode, the visible
|
|
67
|
+
* render guest, the cross-process overview provider and the project identity
|
|
68
|
+
* are facts about a single window — never about the process. A window
|
|
69
|
+
* publishes its own record here and drops only that record when it closes.
|
|
65
70
|
*/
|
|
66
|
-
export
|
|
67
|
-
|
|
68
|
-
type?: string;
|
|
69
|
-
}>(targets: T[], opts: {
|
|
71
|
+
export interface McpWindowFacts extends TargetIdentityFacts {
|
|
72
|
+
/** The window runs the native-host runtime (mini-app pages live in nested render guests). */
|
|
70
73
|
nativeHost: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The visible page's bridgeId, pushed from this window's bridge-router
|
|
76
|
+
* render events. `selectSimulatorTarget` prefers the guest matching it so
|
|
77
|
+
* MCP follows the active page across navigation/tab switches.
|
|
78
|
+
*/
|
|
71
79
|
activeBridgeId: string | null;
|
|
72
|
-
|
|
80
|
+
nativeOverviewProvider: NativeOverviewProvider | null;
|
|
81
|
+
/** Absolute path of the project this window opened with; never changes. */
|
|
82
|
+
projectPath: string;
|
|
83
|
+
/** appId of the project open in this window; null before its session exists. */
|
|
84
|
+
getAppId: () => string | null;
|
|
85
|
+
}
|
|
86
|
+
export interface McpWindowRegistration {
|
|
87
|
+
facts: McpWindowFacts;
|
|
88
|
+
dispose: () => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Point MCP at the window the user is working in. Assembled once by the app;
|
|
92
|
+
* `owner` is the opaque token a window registered itself under. Resolving to
|
|
93
|
+
* null means no project window is open, which is the answer MCP reports before
|
|
94
|
+
* the first project is opened.
|
|
95
|
+
*/
|
|
96
|
+
export declare function setActiveMcpWindowResolver(resolve: () => object | null): void;
|
|
97
|
+
export declare function registerMcpWindow(owner: object, facts: McpWindowFacts): McpWindowRegistration;
|
|
98
|
+
/** The facts of the project window MCP currently drives, or null when none is open. */
|
|
99
|
+
export declare function activeMcpWindow(): McpWindowFacts | null;
|
|
100
|
+
/**
|
|
101
|
+
* Record the render guest now visible in `owner`'s window. Re-points the live
|
|
102
|
+
* simulator connection only when that window is the one MCP drives — a
|
|
103
|
+
* navigation in a background project window must not steal the target.
|
|
104
|
+
*/
|
|
105
|
+
export declare function noteActiveBridgeId(owner: object, id: string | null): void;
|
|
106
|
+
/**
|
|
107
|
+
* The active project window changed. A connection that is already established
|
|
108
|
+
* was aimed at whichever window was active when it was made, and nothing
|
|
109
|
+
* re-read that afterwards — so without this the MCP tools keep reporting and
|
|
110
|
+
* driving the project the user has left. Only connections bound to a different
|
|
111
|
+
* window are re-aimed; the rest are left alone.
|
|
112
|
+
*
|
|
113
|
+
* Coalesced on purpose: clicking across windows produces a burst of these, and
|
|
114
|
+
* re-resolving once the burst settles means focus that returns to the window a
|
|
115
|
+
* connection already holds costs nothing.
|
|
116
|
+
*/
|
|
117
|
+
export declare function noteActiveMcpWindowChanged(): void;
|
|
118
|
+
export declare function setCdpPort(port: number): void;
|
|
119
|
+
/** The cross-process overview reader of the window MCP drives, if it has one. */
|
|
120
|
+
export declare function getNativeOverviewProvider(): NativeOverviewProvider | null;
|
|
73
121
|
export declare function getTargetState(kind: TargetKind): TargetState;
|
|
74
122
|
declare function listCdpTargets(): Promise<CDP.Target[]>;
|
|
75
123
|
export { listCdpTargets as listTargets };
|
|
@@ -11,78 +11,108 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import CDP from 'chrome-remote-interface';
|
|
13
13
|
import { DEFAULT_CDP_PORT } from '../../../shared/constants.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
14
|
+
import { connectionOwner } from './connection-owner.js';
|
|
15
|
+
import { selectSimulatorTarget, selectWorkbenchTarget } from './target-selection.js';
|
|
16
|
+
// Re-exported so existing `./target-manager.js` imports keep working — the
|
|
17
|
+
// candidate-ranking rules live in target-selection.ts, but callers reach them
|
|
18
|
+
// through the connection manager that uses them.
|
|
19
|
+
export { selectSimulatorTarget, selectWorkbenchTarget } from './target-selection.js';
|
|
18
20
|
const MAX_BUFFER = 500;
|
|
19
21
|
const RECONNECT_INTERVAL_MS = 3000;
|
|
22
|
+
// How long a burst of focus changes is allowed to settle before the live
|
|
23
|
+
// connections are re-aimed.
|
|
24
|
+
const ACTIVE_WINDOW_SETTLE_MS = 150;
|
|
20
25
|
let cdpPort = DEFAULT_CDP_PORT;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
workbench: { client: null, connected: false, timer: null, consoleLogs: [], networkRequests: [] },
|
|
32
|
-
};
|
|
33
|
-
export function setCdpPort(port) {
|
|
34
|
-
cdpPort = port;
|
|
26
|
+
const windowFacts = new Map();
|
|
27
|
+
let resolveActiveOwner = () => null;
|
|
28
|
+
/**
|
|
29
|
+
* Point MCP at the window the user is working in. Assembled once by the app;
|
|
30
|
+
* `owner` is the opaque token a window registered itself under. Resolving to
|
|
31
|
+
* null means no project window is open, which is the answer MCP reports before
|
|
32
|
+
* the first project is opened.
|
|
33
|
+
*/
|
|
34
|
+
export function setActiveMcpWindowResolver(resolve) {
|
|
35
|
+
resolveActiveOwner = resolve;
|
|
35
36
|
}
|
|
36
|
-
export function
|
|
37
|
-
|
|
37
|
+
export function registerMcpWindow(owner, facts) {
|
|
38
|
+
windowFacts.set(owner, facts);
|
|
39
|
+
return {
|
|
40
|
+
facts,
|
|
41
|
+
dispose: () => {
|
|
42
|
+
// Only this window's record: other project windows may still be open and
|
|
43
|
+
// their native-host state has to survive this teardown.
|
|
44
|
+
if (windowFacts.get(owner) === facts)
|
|
45
|
+
windowFacts.delete(owner);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The facts of the project window MCP currently drives, or null when none is open. */
|
|
50
|
+
export function activeMcpWindow() {
|
|
51
|
+
const owner = resolveActiveOwner();
|
|
52
|
+
return (owner !== null && windowFacts.get(owner)) || null;
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* reconnect so MCP re-points at the new active page.
|
|
55
|
+
* Record the render guest now visible in `owner`'s window. Re-points the live
|
|
56
|
+
* simulator connection only when that window is the one MCP drives — a
|
|
57
|
+
* navigation in a background project window must not steal the target.
|
|
44
58
|
*/
|
|
45
|
-
export function
|
|
46
|
-
|
|
59
|
+
export function noteActiveBridgeId(owner, id) {
|
|
60
|
+
const facts = windowFacts.get(owner);
|
|
61
|
+
if (!facts || facts.activeBridgeId === id)
|
|
47
62
|
return;
|
|
48
|
-
activeBridgeId = id;
|
|
49
|
-
if (
|
|
63
|
+
facts.activeBridgeId = id;
|
|
64
|
+
if (facts.nativeHost && resolveActiveOwner() === owner && targets.simulator.connected) {
|
|
50
65
|
void connectTarget('simulator');
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
|
-
export function setNativeOverviewProvider(provider) {
|
|
54
|
-
nativeOverviewProvider = provider;
|
|
55
|
-
}
|
|
56
|
-
export function getNativeOverviewProvider() {
|
|
57
|
-
return nativeOverviewProvider;
|
|
58
|
-
}
|
|
59
68
|
/**
|
|
60
|
-
*
|
|
69
|
+
* The active project window changed. A connection that is already established
|
|
70
|
+
* was aimed at whichever window was active when it was made, and nothing
|
|
71
|
+
* re-read that afterwards — so without this the MCP tools keep reporting and
|
|
72
|
+
* driving the project the user has left. Only connections bound to a different
|
|
73
|
+
* window are re-aimed; the rest are left alone.
|
|
61
74
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* Native-host path: the active render-host <webview> guest
|
|
66
|
-
* (pageFrame.html?...bridgeId=<id>), preferring the guest matching
|
|
67
|
-
* `activeBridgeId`, then any pageFrame guest, then degrading to the shell.
|
|
75
|
+
* Coalesced on purpose: clicking across windows produces a burst of these, and
|
|
76
|
+
* re-resolving once the burst settles means focus that returns to the window a
|
|
77
|
+
* connection already holds costs nothing.
|
|
68
78
|
*/
|
|
69
|
-
export function
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
export function noteActiveMcpWindowChanged() {
|
|
80
|
+
if (repointTimer)
|
|
81
|
+
return;
|
|
82
|
+
repointTimer = setTimeout(() => {
|
|
83
|
+
repointTimer = null;
|
|
84
|
+
const owner = resolveActiveOwner();
|
|
85
|
+
// A window whose facts are already gone is on its way out: its pages are
|
|
86
|
+
// about to be destroyed, so connecting into them would only produce a
|
|
87
|
+
// client that immediately disconnects. The reconnect timer picks up
|
|
88
|
+
// whichever window replaces it.
|
|
89
|
+
if (owner !== null && !windowFacts.has(owner))
|
|
90
|
+
return;
|
|
91
|
+
for (const kind of Object.keys(targets)) {
|
|
92
|
+
if (!targets[kind].connected || targets[kind].owner === owner)
|
|
93
|
+
continue;
|
|
94
|
+
void connectTarget(kind);
|
|
95
|
+
}
|
|
96
|
+
}, ACTIVE_WINDOW_SETTLE_MS);
|
|
97
|
+
}
|
|
98
|
+
// The two CDP connections are process-wide on purpose: MCP exposes one
|
|
99
|
+
// `simulator` and one `workbench` target with no window argument, so both
|
|
100
|
+
// always mean "the project the user is working in". Which window that is comes
|
|
101
|
+
// from `activeMcpWindow()` on every (re)connect, so the pair follows the
|
|
102
|
+
// active window rather than belonging to any one of them.
|
|
103
|
+
const targets = {
|
|
104
|
+
simulator: { client: null, connected: false, owner: null, timer: null, consoleLogs: [], networkRequests: [], bufferOwner: null },
|
|
105
|
+
workbench: { client: null, connected: false, owner: null, timer: null, consoleLogs: [], networkRequests: [], bufferOwner: null },
|
|
106
|
+
};
|
|
107
|
+
/** Monotonic per target: only the newest connect attempt may publish itself. */
|
|
108
|
+
const connectGeneration = { simulator: 0, workbench: 0 };
|
|
109
|
+
let repointTimer = null;
|
|
110
|
+
export function setCdpPort(port) {
|
|
111
|
+
cdpPort = port;
|
|
112
|
+
}
|
|
113
|
+
/** The cross-process overview reader of the window MCP drives, if it has one. */
|
|
114
|
+
export function getNativeOverviewProvider() {
|
|
115
|
+
return activeMcpWindow()?.nativeOverviewProvider ?? null;
|
|
86
116
|
}
|
|
87
117
|
export function getTargetState(kind) {
|
|
88
118
|
return targets[kind];
|
|
@@ -96,27 +126,150 @@ async function listCdpTargets() {
|
|
|
96
126
|
}
|
|
97
127
|
}
|
|
98
128
|
export { listCdpTargets as listTargets };
|
|
129
|
+
/**
|
|
130
|
+
* `selectWorkbenchTarget` already matches on the active window's exact
|
|
131
|
+
* `projectPath`, so no candidate ranking is blind to ownership there — the
|
|
132
|
+
* match is exact or nothing, with nothing left for a pre-filter to change.
|
|
133
|
+
*/
|
|
134
|
+
function findWorkbenchTarget(allTargets) {
|
|
135
|
+
const active = activeMcpWindow();
|
|
136
|
+
return selectWorkbenchTarget(allTargets, { projectPath: active ? active.projectPath : null });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `selectSimulatorTarget` ranks candidates by a fixed priority order with no
|
|
140
|
+
* idea which window each one belongs to, and its "any guest" tier in
|
|
141
|
+
* particular has no way to tell a stray guest left over from another window
|
|
142
|
+
* apart from a legitimate one.
|
|
143
|
+
*
|
|
144
|
+
* Once the active window has an `activeBridgeId` of its own, it is known to
|
|
145
|
+
* be genuinely on a native page and merely waiting for that specific guest
|
|
146
|
+
* target to show up in the CDP list — connecting to whatever guest IS present
|
|
147
|
+
* and letting the post-connect ownership check below reject a wrong one is a
|
|
148
|
+
* reasonable, existing way to close that timing gap, so ranking stays
|
|
149
|
+
* unfiltered in that case.
|
|
150
|
+
*
|
|
151
|
+
* Before any page is known for this window (`activeBridgeId === null`, which
|
|
152
|
+
* is also always true for non-native windows), though, "any guest present"
|
|
153
|
+
* carries no signal it belongs to THIS window at all — so ranking is
|
|
154
|
+
* restricted to targets `connectionOwner` attributes to the active window,
|
|
155
|
+
* falling back to the raw list only when none of them qualify (the same
|
|
156
|
+
* retry-and-reject cadence as the unfiltered path, for a candidate list that
|
|
157
|
+
* belongs to no window MCP can currently claim).
|
|
158
|
+
*/
|
|
159
|
+
function findSimulatorTarget(allTargets) {
|
|
160
|
+
const active = activeMcpWindow();
|
|
161
|
+
const opts = { nativeHost: active?.nativeHost ?? false, activeBridgeId: active?.activeBridgeId ?? null };
|
|
162
|
+
if (opts.activeBridgeId !== null)
|
|
163
|
+
return selectSimulatorTarget(allTargets, opts);
|
|
164
|
+
const intended = resolveActiveOwner();
|
|
165
|
+
const owned = allTargets.filter((t) => connectionOwner('simulator', t.url, intended, windowFacts).onTarget);
|
|
166
|
+
return selectSimulatorTarget(owned, opts) ?? selectSimulatorTarget(allTargets, opts);
|
|
167
|
+
}
|
|
99
168
|
function findTarget(allTargets, kind) {
|
|
100
|
-
|
|
101
|
-
|
|
169
|
+
return kind === 'simulator' ? findSimulatorTarget(allTargets) : findWorkbenchTarget(allTargets);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Console and network events into this target's ring buffers, which is all
|
|
173
|
+
* these subscriptions do — they hold no view of which window is connected, so
|
|
174
|
+
* they outlive nothing and need no generation check of their own.
|
|
175
|
+
*/
|
|
176
|
+
function subscribeBuffers(client, state) {
|
|
177
|
+
const pending = new Map();
|
|
178
|
+
const pushNetworkRequest = (entry) => {
|
|
179
|
+
state.networkRequests.push(entry);
|
|
180
|
+
if (state.networkRequests.length > MAX_BUFFER)
|
|
181
|
+
state.networkRequests = state.networkRequests.slice(-MAX_BUFFER);
|
|
182
|
+
};
|
|
183
|
+
const pushConsoleLog = (entry) => {
|
|
184
|
+
state.consoleLogs.push(entry);
|
|
185
|
+
if (state.consoleLogs.length > MAX_BUFFER)
|
|
186
|
+
state.consoleLogs = state.consoleLogs.slice(-MAX_BUFFER);
|
|
187
|
+
};
|
|
188
|
+
client.Runtime.on('consoleAPICalled', (params) => {
|
|
189
|
+
pushConsoleLog({
|
|
190
|
+
level: params.type,
|
|
191
|
+
text: params.args.map((a) => String(a.value ?? a.description ?? JSON.stringify(a))).join(' '),
|
|
192
|
+
timestamp: new Date(params.timestamp).toISOString(),
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
client.Console.on('messageAdded', (params) => {
|
|
196
|
+
const msg = params.message;
|
|
197
|
+
pushConsoleLog({ level: msg.level, text: msg.text, timestamp: new Date().toISOString() });
|
|
198
|
+
});
|
|
199
|
+
client.Network.on('requestWillBeSent', (params) => {
|
|
200
|
+
pending.set(params.requestId, { url: params.request.url, method: params.request.method, timestamp: params.timestamp });
|
|
201
|
+
});
|
|
202
|
+
client.Network.on('responseReceived', (params) => {
|
|
203
|
+
const req = pending.get(params.requestId);
|
|
204
|
+
if (!req)
|
|
205
|
+
return;
|
|
206
|
+
pending.delete(params.requestId);
|
|
207
|
+
pushNetworkRequest({
|
|
208
|
+
url: req.url, method: req.method,
|
|
209
|
+
status: params.response.status, mimeType: params.response.mimeType,
|
|
210
|
+
responseSize: params.response.encodedDataLength || 0,
|
|
211
|
+
timing: params.response.timing
|
|
212
|
+
? { requestTime: params.response.timing.requestTime, receiveHeadersEnd: params.response.timing.receiveHeadersEnd }
|
|
213
|
+
: null,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
client.Network.on('loadingFailed', (params) => {
|
|
217
|
+
const req = pending.get(params.requestId);
|
|
218
|
+
if (!req)
|
|
219
|
+
return;
|
|
220
|
+
pending.delete(params.requestId);
|
|
221
|
+
pushNetworkRequest({ url: req.url, method: req.method, status: 0, mimeType: '', responseSize: 0, timing: null });
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** Closing a client is never the reason an attempt fails. */
|
|
225
|
+
async function closeQuietly(client) {
|
|
226
|
+
if (!client)
|
|
227
|
+
return;
|
|
228
|
+
try {
|
|
229
|
+
await client.close();
|
|
230
|
+
}
|
|
231
|
+
catch { }
|
|
232
|
+
}
|
|
233
|
+
/** No usable target right now: publish nothing and keep retrying. */
|
|
234
|
+
function loseTarget(kind) {
|
|
235
|
+
const state = targets[kind];
|
|
236
|
+
state.client = null;
|
|
237
|
+
state.connected = false;
|
|
238
|
+
state.owner = null;
|
|
239
|
+
scheduleReconnect(kind);
|
|
240
|
+
}
|
|
241
|
+
/** Publish a connection that survived the race, on the window it reached. */
|
|
242
|
+
function publishConnection(kind, client, owner) {
|
|
243
|
+
const state = targets[kind];
|
|
244
|
+
state.client = client;
|
|
245
|
+
state.connected = true;
|
|
246
|
+
state.owner = owner;
|
|
247
|
+
if (state.timer) {
|
|
248
|
+
clearTimeout(state.timer);
|
|
249
|
+
state.timer = null;
|
|
102
250
|
}
|
|
103
|
-
// workbench main window: page target whose URL contains index.html (renderer)
|
|
104
|
-
return allTargets.find((t) => t.type === 'page' && t.url?.includes('entries/main/index.html') && !t.url?.includes(SIMULATOR_URL_PATTERN));
|
|
105
251
|
}
|
|
106
252
|
export async function connectTarget(kind) {
|
|
107
253
|
const state = targets[kind];
|
|
254
|
+
// Establishing a connection is a long chain of awaits, and the reason to
|
|
255
|
+
// establish it — which window is active, which page it shows — can change
|
|
256
|
+
// while that chain runs. An attempt overtaken by a newer one must publish
|
|
257
|
+
// nothing, close the client it opened, and schedule no work.
|
|
258
|
+
const generation = (connectGeneration[kind] += 1);
|
|
259
|
+
const superseded = () => connectGeneration[kind] !== generation;
|
|
108
260
|
if (state.client) {
|
|
109
|
-
|
|
110
|
-
await state.client.close();
|
|
111
|
-
}
|
|
112
|
-
catch { }
|
|
261
|
+
const previous = state.client;
|
|
113
262
|
state.client = null;
|
|
263
|
+
await closeQuietly(previous);
|
|
264
|
+
if (superseded())
|
|
265
|
+
return;
|
|
114
266
|
}
|
|
115
267
|
const allTargets = await listCdpTargets();
|
|
116
268
|
const target = findTarget(allTargets, kind);
|
|
269
|
+
if (superseded())
|
|
270
|
+
return;
|
|
117
271
|
if (!target) {
|
|
118
|
-
|
|
119
|
-
scheduleReconnect(kind);
|
|
272
|
+
loseTarget(kind);
|
|
120
273
|
return;
|
|
121
274
|
}
|
|
122
275
|
let client = null;
|
|
@@ -129,83 +282,54 @@ export async function connectTarget(kind) {
|
|
|
129
282
|
client.Network.enable(),
|
|
130
283
|
client.Console.enable(),
|
|
131
284
|
]);
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
client.Console.on('messageAdded', (params) => {
|
|
151
|
-
const msg = params.message;
|
|
152
|
-
state.consoleLogs.push({ level: msg.level, text: msg.text, timestamp: new Date().toISOString() });
|
|
153
|
-
if (state.consoleLogs.length > MAX_BUFFER)
|
|
154
|
-
state.consoleLogs = state.consoleLogs.slice(-MAX_BUFFER);
|
|
155
|
-
});
|
|
156
|
-
client.Network.on('requestWillBeSent', (params) => {
|
|
157
|
-
pending.set(params.requestId, { url: params.request.url, method: params.request.method, timestamp: params.timestamp });
|
|
158
|
-
});
|
|
159
|
-
client.Network.on('responseReceived', (params) => {
|
|
160
|
-
const req = pending.get(params.requestId);
|
|
161
|
-
if (!req)
|
|
162
|
-
return;
|
|
163
|
-
pending.delete(params.requestId);
|
|
164
|
-
pushNetworkRequest({
|
|
165
|
-
url: req.url, method: req.method,
|
|
166
|
-
status: params.response.status, mimeType: params.response.mimeType,
|
|
167
|
-
responseSize: params.response.encodedDataLength || 0,
|
|
168
|
-
timing: params.response.timing
|
|
169
|
-
? { requestTime: params.response.timing.requestTime, receiveHeadersEnd: params.response.timing.receiveHeadersEnd }
|
|
170
|
-
: null,
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
client.Network.on('loadingFailed', (params) => {
|
|
174
|
-
const req = pending.get(params.requestId);
|
|
175
|
-
if (!req)
|
|
285
|
+
// Everything below subscribes or publishes, so an attempt that lost the
|
|
286
|
+
// race stops here and leaves nothing behind but its own closed client.
|
|
287
|
+
if (superseded()) {
|
|
288
|
+
await closeQuietly(client);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
// Which window this target belongs to is resolved here, not when the
|
|
292
|
+
// attempt started: an attempt that outlived a window switch has to be
|
|
293
|
+
// judged against the window the user is in now. MCP exposes ONE client per
|
|
294
|
+
// kind, so a target belonging to another window leaves nothing behind at
|
|
295
|
+
// all — buffers wired to it would mix that window's console and network
|
|
296
|
+
// events into the ones the eventual right connection appends to, and
|
|
297
|
+
// `connected` would hand it out meanwhile. The retry cadence is the only
|
|
298
|
+
// thing that carries over: the exact target may still be loading.
|
|
299
|
+
const binding = connectionOwner(kind, target.url, resolveActiveOwner(), windowFacts);
|
|
300
|
+
if (!binding.onTarget) {
|
|
301
|
+
await closeQuietly(client);
|
|
302
|
+
if (superseded())
|
|
176
303
|
return;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
304
|
+
loseTarget(kind);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
// Buffers are keyed to the owner they were collected for, not to the
|
|
308
|
+
// kind slot: a reconnect landing on the SAME owner (a transient CDP drop)
|
|
309
|
+
// must keep what was already buffered, but re-aiming at a different
|
|
310
|
+
// window must not let that window inherit the previous owner's entries.
|
|
311
|
+
if (state.bufferOwner !== binding.owner) {
|
|
312
|
+
state.consoleLogs = [];
|
|
313
|
+
state.networkRequests = [];
|
|
314
|
+
state.bufferOwner = binding.owner;
|
|
315
|
+
}
|
|
316
|
+
subscribeBuffers(client, state);
|
|
187
317
|
client.on('disconnect', () => {
|
|
318
|
+
// A superseded client is closed on purpose; only the live connection
|
|
319
|
+
// going away means MCP has lost its target.
|
|
320
|
+
if (superseded())
|
|
321
|
+
return;
|
|
188
322
|
state.connected = false;
|
|
189
323
|
state.client = null;
|
|
190
324
|
scheduleReconnect(kind);
|
|
191
325
|
});
|
|
192
|
-
|
|
193
|
-
state.connected = true;
|
|
194
|
-
if (state.timer) {
|
|
195
|
-
clearTimeout(state.timer);
|
|
196
|
-
state.timer = null;
|
|
197
|
-
}
|
|
326
|
+
publishConnection(kind, client, binding.owner);
|
|
198
327
|
}
|
|
199
328
|
catch {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
catch { }
|
|
205
|
-
}
|
|
206
|
-
state.client = null;
|
|
207
|
-
state.connected = false;
|
|
208
|
-
scheduleReconnect(kind);
|
|
329
|
+
await closeQuietly(client);
|
|
330
|
+
if (superseded())
|
|
331
|
+
return;
|
|
332
|
+
loseTarget(kind);
|
|
209
333
|
}
|
|
210
334
|
}
|
|
211
335
|
function scheduleReconnect(kind) {
|
|
@@ -219,10 +343,17 @@ function scheduleReconnect(kind) {
|
|
|
219
343
|
}
|
|
220
344
|
export function getClient(kind) {
|
|
221
345
|
const state = targets[kind];
|
|
346
|
+
const label = kind === 'simulator' ? '模拟器' : '主窗口';
|
|
222
347
|
if (!state.connected || !state.client) {
|
|
223
|
-
const label = kind === 'simulator' ? '模拟器' : '主窗口';
|
|
224
348
|
throw new Error(`未连接到${label}。请确保 dimina-devtools 正在以开发模式运行。`);
|
|
225
349
|
}
|
|
350
|
+
// A focus change re-aims the live connections only once the burst settles,
|
|
351
|
+
// and during that gap the client still belongs to the window the user left.
|
|
352
|
+
// Answering from it would report and drive the wrong project, so the caller
|
|
353
|
+
// waits for the re-aim instead.
|
|
354
|
+
if (state.owner !== resolveActiveOwner()) {
|
|
355
|
+
throw new Error(`${label}连接属于已切换的项目窗口,正在重新连接,请稍后重试。`);
|
|
356
|
+
}
|
|
226
357
|
return state.client;
|
|
227
358
|
}
|
|
228
359
|
//# sourceMappingURL=target-manager.js.map
|