@dimina-kit/devtools 0.3.2-dev.20260525152421 → 0.3.2-dev.20260610082053
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -40
- package/dist/main/api.d.ts +0 -1
- package/dist/main/api.js +5 -1
- package/dist/main/app/app.d.ts +15 -5
- package/dist/main/app/app.js +247 -110
- package/dist/main/app/bootstrap.d.ts +16 -0
- package/dist/main/app/bootstrap.js +20 -0
- package/dist/main/app/launch.d.ts +8 -4
- package/dist/main/app/launch.js +9 -4
- package/dist/main/index.bundle.js +6607 -2102
- package/dist/main/index.js +9 -1
- package/dist/main/ipc/app.d.ts +1 -1
- package/dist/main/ipc/bridge-router.d.ts +61 -0
- package/dist/main/ipc/bridge-router.js +1300 -0
- package/dist/main/ipc/panels.d.ts +1 -1
- package/dist/main/ipc/panels.js +6 -2
- package/dist/main/ipc/popover.d.ts +1 -1
- package/dist/main/ipc/project-fs.d.ts +57 -0
- package/dist/main/ipc/project-fs.js +448 -0
- package/dist/main/ipc/projects.d.ts +1 -1
- package/dist/main/ipc/session.d.ts +1 -1
- package/dist/main/ipc/settings.d.ts +1 -1
- package/dist/main/ipc/simulator-module.d.ts +6 -0
- package/dist/main/ipc/simulator-module.js +11 -1
- package/dist/main/ipc/simulator.d.ts +2 -2
- package/dist/main/ipc/simulator.js +49 -5
- package/dist/main/ipc/toolbar.d.ts +1 -1
- package/dist/main/ipc/views.d.ts +19 -0
- package/dist/main/ipc/views.js +65 -0
- package/dist/main/runtime/devtools-backend.d.ts +17 -0
- package/dist/main/runtime/devtools-backend.js +49 -0
- package/dist/main/runtime/miniapp-runtime.d.ts +39 -0
- package/dist/main/runtime/miniapp-runtime.js +17 -0
- package/dist/main/services/automation/exec.d.ts +27 -2
- package/dist/main/services/automation/exec.js +37 -3
- package/dist/main/services/automation/handlers/app.js +127 -11
- package/dist/main/services/automation/handlers/page.js +36 -19
- package/dist/main/services/automation/index.js +40 -13
- package/dist/main/services/automation/wait-active-page.d.ts +56 -0
- package/dist/main/services/automation/wait-active-page.js +71 -0
- package/dist/main/services/console-forward/index.d.ts +36 -0
- package/dist/main/services/console-forward/index.js +81 -0
- package/dist/main/services/dimina-resource-server.d.ts +7 -0
- package/dist/main/services/dimina-resource-server.js +99 -0
- package/dist/main/services/elements-forward/index.d.ts +66 -0
- package/dist/main/services/elements-forward/index.js +583 -0
- package/dist/main/services/layout/index.d.ts +23 -1
- package/dist/main/services/layout/index.js +28 -3
- package/dist/main/services/mcp/index.d.ts +1 -0
- package/dist/main/services/mcp/index.js +3 -0
- package/dist/main/services/mcp/server.d.ts +1 -1
- package/dist/main/services/mcp/server.js +1 -1
- package/dist/main/services/mcp/target-manager.d.ts +35 -0
- package/dist/main/services/mcp/target-manager.js +63 -1
- package/dist/main/services/mcp/tools/context-tools.js +15 -1
- package/dist/main/services/module.d.ts +1 -1
- package/dist/main/services/network-forward/index.d.ts +190 -0
- package/dist/main/services/network-forward/index.js +765 -0
- package/dist/main/services/notifications/renderer-notifier.d.ts +11 -0
- package/dist/main/services/notifications/renderer-notifier.js +7 -1
- package/dist/main/services/render-inspect/index.d.ts +41 -0
- package/dist/main/services/render-inspect/index.js +88 -0
- package/dist/main/services/safe-area/index.d.ts +17 -0
- package/dist/main/services/safe-area/index.js +59 -0
- package/dist/main/services/service-host-pool/pool.d.ts +197 -0
- package/dist/main/services/service-host-pool/pool.js +364 -0
- package/dist/main/services/simulator/custom-apis.d.ts +34 -0
- package/dist/main/services/simulator/custom-apis.js +22 -0
- package/dist/main/services/simulator-appdata/index.d.ts +35 -0
- package/dist/main/services/simulator-appdata/index.js +71 -0
- package/dist/main/services/simulator-current-page/index.d.ts +24 -0
- package/dist/main/services/simulator-current-page/index.js +19 -0
- package/dist/main/services/simulator-storage/index.d.ts +37 -2
- package/dist/main/services/simulator-storage/index.js +209 -32
- package/dist/main/services/simulator-storage/service-storage-ops.d.ts +40 -0
- package/dist/main/services/simulator-storage/service-storage-ops.js +67 -0
- package/dist/main/services/simulator-temp-files/fs-channels.js +1 -1
- package/dist/main/services/simulator-temp-files/index.d.ts +1 -1
- package/dist/main/services/simulator-temp-files/index.js +1 -1
- package/dist/main/services/simulator-temp-files/request-handler.js +1 -1
- package/dist/main/services/simulator-wxml/index.d.ts +29 -0
- package/dist/main/services/simulator-wxml/index.js +28 -0
- package/dist/main/services/update/update-manager.d.ts +10 -0
- package/dist/main/services/update/update-manager.js +16 -3
- package/dist/main/services/views/devtools-tabs.d.ts +47 -0
- package/dist/main/services/views/devtools-tabs.js +95 -0
- package/dist/main/services/views/view-manager.d.ts +142 -4
- package/dist/main/services/views/view-manager.js +909 -17
- package/dist/main/services/workbench-context.d.ts +66 -1
- package/dist/main/services/workbench-context.js +6 -1
- package/dist/main/services/workspace/workspace-service.d.ts +8 -0
- package/dist/main/services/workspace/workspace-service.js +12 -0
- package/dist/main/utils/ipc-registry.d.ts +11 -2
- package/dist/main/utils/ipc-registry.js +63 -3
- package/dist/main/utils/paths.d.ts +15 -0
- package/dist/main/utils/paths.js +19 -0
- package/dist/main/utils/sender-policy.d.ts +9 -3
- package/dist/main/utils/sender-policy.js +18 -4
- package/dist/main/utils/theme.d.ts +1 -1
- package/dist/main/utils/theme.js +1 -1
- package/dist/main/windows/main-window/create.d.ts +0 -6
- package/dist/main/windows/main-window/create.js +11 -59
- package/dist/main/windows/main-window/events.d.ts +1 -1
- package/dist/main/windows/main-window/events.js +1 -1
- package/dist/main/windows/service-host-window/create.d.ts +52 -0
- package/dist/main/windows/service-host-window/create.js +112 -0
- package/dist/native-host/common/common.js +368 -0
- package/dist/native-host/container/pageFrame.css +1 -0
- package/dist/native-host/render/render.js +9334 -0
- package/dist/native-host/service/service.js +6 -0
- package/dist/preload/index.d.ts +2 -0
- package/dist/preload/index.js +6 -0
- package/dist/preload/instrumentation/app-data.d.ts +18 -20
- package/dist/preload/instrumentation/app-data.js +23 -160
- package/dist/preload/instrumentation/wxml-extract.d.ts +1 -1
- package/dist/preload/instrumentation/wxml-extract.js +1 -1
- package/dist/preload/runtime/bridge.d.ts +3 -8
- package/dist/preload/runtime/bridge.js +2 -32
- package/dist/preload/runtime/custom-apis.js +20 -17
- package/dist/preload/runtime/host-toolbar-advertiser.d.ts +27 -0
- package/dist/preload/runtime/host-toolbar-advertiser.js +55 -0
- package/dist/preload/runtime/main-api-runner.d.ts +9 -0
- package/dist/preload/runtime/main-api-runner.js +85 -0
- package/dist/preload/runtime/native-host.d.ts +43 -0
- package/dist/preload/runtime/native-host.js +83 -0
- package/dist/preload/shared/expose.d.ts +10 -5
- package/dist/preload/shared/expose.js +29 -11
- package/dist/preload/shared/sid-registry.d.ts +11 -0
- package/dist/preload/shared/sid-registry.js +38 -0
- package/dist/preload/windows/host-toolbar.cjs +161 -0
- package/dist/preload/windows/host-toolbar.cjs.map +7 -0
- package/dist/preload/windows/host-toolbar.d.ts +2 -0
- package/dist/preload/windows/host-toolbar.js +12 -0
- package/dist/preload/windows/main.cjs +1939 -0
- package/dist/preload/windows/main.cjs.map +4 -4
- package/dist/preload/windows/simulator.cjs +925 -0
- package/dist/preload/windows/simulator.cjs.map +7 -0
- package/dist/preload/windows/simulator.js +243 -573
- package/dist/render-host/pageFrame.html +29 -0
- package/dist/render-host/preload.cjs +154 -0
- package/dist/render-host/render-inspect.js +295 -0
- package/dist/renderer/assets/abap-DiwvWnMr.js +2 -0
- package/dist/renderer/assets/apex-CmtZjKlf.js +2 -0
- package/dist/renderer/assets/azcli-DL2My_i-.js +2 -0
- package/dist/renderer/assets/bat-B-nC98wG.js +2 -0
- package/dist/renderer/assets/bicep-Ju5MwOgh.js +3 -0
- package/dist/renderer/assets/cameligo-8Eu1TyBr.js +2 -0
- package/dist/renderer/assets/chunk-DPI0Y_ll.js +1 -0
- package/dist/renderer/assets/clojure-u-RpMkH3.js +2 -0
- package/dist/renderer/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/renderer/assets/coffee-CdA7bbTe.js +2 -0
- package/dist/renderer/assets/constants-CLAQX6VZ.js +2 -0
- package/dist/renderer/assets/cpp-CzNFP8ks.js +2 -0
- package/dist/renderer/assets/csharp-j1LThmcE.js +2 -0
- package/dist/renderer/assets/csp-CLRC61y6.js +2 -0
- package/dist/renderer/assets/css-r6rC_7P2.js +4 -0
- package/dist/renderer/assets/css.worker-DyDu5ynT.js +90 -0
- package/dist/renderer/assets/cssMode-BCBgxrnA.js +2 -0
- package/dist/renderer/assets/cypher-CW08XVUh.js +2 -0
- package/dist/renderer/assets/dart-Cs9aL5T_.js +2 -0
- package/dist/renderer/assets/dockerfile-BWM0M184.js +2 -0
- package/dist/renderer/assets/ecl-MJJuer5P.js +2 -0
- package/dist/renderer/assets/editor-CWI9TnMM.css +1 -0
- package/dist/renderer/assets/editor.api2-BTaYmRq7.js +873 -0
- package/dist/renderer/assets/editor.worker-Dpt_xPrs.js +27 -0
- package/dist/renderer/assets/elixir-D2AIuXqn.js +2 -0
- package/dist/renderer/assets/flow9-B2H24giC.js +2 -0
- package/dist/renderer/assets/freemarker2-DGDGzimW.js +4 -0
- package/dist/renderer/assets/fsharp-CMk2OIJN.js +2 -0
- package/dist/renderer/assets/go-BrMkuJg0.js +2 -0
- package/dist/renderer/assets/graphql-PSR1UKGv.js +2 -0
- package/dist/renderer/assets/handlebars-bOHhw3EG.js +2 -0
- package/dist/renderer/assets/hcl-DAQrbDOW.js +2 -0
- package/dist/renderer/assets/html-BMyuX0_c.js +2 -0
- package/dist/renderer/assets/html.worker-IWNXhnIC.js +503 -0
- package/dist/renderer/assets/htmlMode-DR4kXJ7l.js +2 -0
- package/dist/renderer/assets/index-CcJKzatF.js +50 -0
- package/dist/renderer/assets/ini-0TG5BxW0.js +2 -0
- package/dist/renderer/assets/input-QGx6FFX1.js +2 -0
- package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +1 -0
- package/dist/renderer/assets/{ipc-transport-BzPzxPwf.js → ipc-transport-DvZvwK-Z.js} +5 -5
- package/dist/renderer/assets/java-rgorz17v.js +2 -0
- package/dist/renderer/assets/javascript-Bu-tl1P7.js +2 -0
- package/dist/renderer/assets/json.worker-c4h5s80L.js +59 -0
- package/dist/renderer/assets/jsonMode-MQV_ffLR.js +8 -0
- package/dist/renderer/assets/julia-C8VMdHm8.js +2 -0
- package/dist/renderer/assets/kotlin-AhhC4Qhm.js +2 -0
- package/dist/renderer/assets/less-Cgca25AP.js +3 -0
- package/dist/renderer/assets/lexon-D0GHdBaw.js +2 -0
- package/dist/renderer/assets/liquid-ClkfOvhB.js +2 -0
- package/dist/renderer/assets/lspLanguageFeatures-Bke_4Ie9.js +5 -0
- package/dist/renderer/assets/lua-DmRsNG-P.js +2 -0
- package/dist/renderer/assets/m3-BgL5dNKT.js +2 -0
- package/dist/renderer/assets/markdown-BuJfycGS.js +2 -0
- package/dist/renderer/assets/mdx-RZdUskPu.js +2 -0
- package/dist/renderer/assets/mips-C9m_93PR.js +2 -0
- package/dist/renderer/assets/monaco.contribution-B7rUMaEv.js +3 -0
- package/dist/renderer/assets/msdax-CpFHC9OI.js +2 -0
- package/dist/renderer/assets/mysql-qFvltsqN.js +2 -0
- package/dist/renderer/assets/objective-c-Bnmr858J.js +2 -0
- package/dist/renderer/assets/pascal-WP0_D5AO.js +2 -0
- package/dist/renderer/assets/pascaligo-Blom4Rij.js +2 -0
- package/dist/renderer/assets/perl-B-vk8g64.js +2 -0
- package/dist/renderer/assets/pgsql-Cgvz6v67.js +2 -0
- package/dist/renderer/assets/php-8a3Lrw9m.js +2 -0
- package/dist/renderer/assets/pla-DuFqEZ8V.js +2 -0
- package/dist/renderer/assets/popover-BOH1If1J.js +2 -0
- package/dist/renderer/assets/postiats-DkLtSgkp.js +2 -0
- package/dist/renderer/assets/powerquery-BJ1aNepW.js +2 -0
- package/dist/renderer/assets/powershell-rE98k687.js +2 -0
- package/dist/renderer/assets/protobuf-CUheFacr.js +3 -0
- package/dist/renderer/assets/pug-LDcAMD8w.js +2 -0
- package/dist/renderer/assets/python-Cobrm_-8.js +2 -0
- package/dist/renderer/assets/qsharp-DUKSQoR1.js +2 -0
- package/dist/renderer/assets/r-D-QApv87.js +2 -0
- package/dist/renderer/assets/razor-BEUIQFNJ.js +2 -0
- package/dist/renderer/assets/redis-SXdDyWR9.js +2 -0
- package/dist/renderer/assets/redshift-Y6lsCryn.js +2 -0
- package/dist/renderer/assets/restructuredtext-edObr9a8.js +2 -0
- package/dist/renderer/assets/ruby-CNnUfF-8.js +2 -0
- package/dist/renderer/assets/rust-IHUZWzBr.js +2 -0
- package/dist/renderer/assets/sb-DrUvY44N.js +2 -0
- package/dist/renderer/assets/scala-B4hbXGLM.js +2 -0
- package/dist/renderer/assets/scheme-BGrd12j3.js +2 -0
- package/dist/renderer/assets/scss-x5G1ES4U.js +4 -0
- package/dist/renderer/assets/select-C7JQ8G5N.js +2 -0
- package/dist/renderer/assets/settings-DpAbTJyF.js +2 -0
- package/dist/renderer/assets/{settings-api-BXCw9vOZ.js → settings-api-RD2IZF53.js} +2 -2
- package/dist/renderer/assets/shell-DOehe2Y8.js +2 -0
- package/dist/renderer/assets/solidity-BeRvcwWV.js +2 -0
- package/dist/renderer/assets/sophia-DZbkUNjy.js +2 -0
- package/dist/renderer/assets/sparql-B7_oi5-h.js +2 -0
- package/dist/renderer/assets/sql-CTlsFWVE.js +2 -0
- package/dist/renderer/assets/st-DJVEJdPE.js +2 -0
- package/dist/renderer/assets/swift-CwhT3fYa.js +2 -0
- package/dist/renderer/assets/systemverilog-BQN63pkN.js +2 -0
- package/dist/renderer/assets/tcl-DqwfpskA.js +2 -0
- package/dist/renderer/assets/ts.worker-BwM5Ha3L.js +67720 -0
- package/dist/renderer/assets/tsMode-BHa7dl9v.js +12 -0
- package/dist/renderer/assets/twig-BiyenUgc.js +2 -0
- package/dist/renderer/assets/typescript-15aT0Yj8.js +2 -0
- package/dist/renderer/assets/typespec-CWOJribt.js +2 -0
- package/dist/renderer/assets/vb-Cq5F87m3.js +2 -0
- package/dist/renderer/assets/wgsl-BAvW2lVr.js +299 -0
- package/dist/renderer/assets/workbenchSettings-CNJX4Qna.js +8 -0
- package/dist/renderer/assets/workers-CRBS0W-v.js +2 -0
- package/dist/renderer/assets/xml-bR2Zh-HV.js +2 -0
- package/dist/renderer/assets/yaml-Bdk54Qrb.js +2 -0
- package/dist/renderer/entries/main/index.html +29 -6
- package/dist/renderer/entries/popover/index.html +7 -6
- package/dist/renderer/entries/settings/index.html +6 -5
- package/dist/renderer/entries/workbench-settings/index.html +6 -5
- package/dist/service-host/preload.cjs +254 -0
- package/dist/service-host/service.html +10 -0
- package/dist/service-host/sourcemap-rewrite.cjs +58 -0
- package/dist/service-host/sync-api-patch.js +20 -0
- package/dist/service-host/sync-impls/menu-button.js +16 -0
- package/dist/service-host/sync-impls/storage.js +50 -0
- package/dist/service-host/sync-impls/system-info.js +54 -0
- package/dist/shared/appdata-accumulator.d.ts +95 -0
- package/dist/shared/appdata-accumulator.js +213 -0
- package/dist/shared/bridge-channels.d.ts +364 -0
- package/dist/shared/bridge-channels.js +54 -0
- package/dist/shared/constants.d.ts +0 -4
- package/dist/shared/constants.js +0 -4
- package/dist/shared/ipc-channels.d.ts +108 -1
- package/dist/shared/ipc-channels.js +127 -10
- package/dist/shared/ipc-schemas.d.ts +65 -2
- package/dist/shared/ipc-schemas.js +79 -3
- package/dist/shared/open-in-editor.d.ts +71 -0
- package/dist/shared/open-in-editor.js +138 -0
- package/dist/shared/simulator-api-metadata.d.ts +21 -0
- package/dist/shared/simulator-api-metadata.js +23 -0
- package/dist/shared/types.d.ts +2 -2
- package/dist/shared/vpath.d.ts +42 -0
- package/dist/shared/vpath.js +105 -0
- package/dist/simulator/assets/device-shell-DsdcNEkt.css +1 -0
- package/dist/simulator/assets/device-shell-vwYSOVrh.js +2 -0
- package/dist/simulator/assets/jsx-runtime-P6ZegaOf.js +2 -0
- package/dist/simulator/assets/simulator-DddliUL5.js +10 -0
- package/dist/simulator/assets/simulator-mini-app-BDNu5n26.js +2 -0
- package/dist/simulator/device-shell/menu-button-geometry.js +8 -0
- package/dist/simulator/simulator.html +2 -112
- package/package.json +9 -9
- package/dist/main/utils/disposable.d.ts +0 -18
- package/dist/main/utils/disposable.js +0 -67
- package/dist/renderer/assets/constants-DI382mTP.js +0 -2
- package/dist/renderer/assets/index-4lkyF644.js +0 -46
- package/dist/renderer/assets/input-D4byFOLS.js +0 -2
- package/dist/renderer/assets/ipc-transport-DqbRdZNO.css +0 -1
- package/dist/renderer/assets/popover-cxKrg_os.js +0 -2
- package/dist/renderer/assets/select-BgSkkdHW.js +0 -2
- package/dist/renderer/assets/settings-oD2K1jdT.js +0 -2
- package/dist/renderer/assets/workbenchSettings-CTNBpTft.js +0 -8
- package/dist/simulator/assets/simulator-CVOFTpSj.js +0 -9
|
@@ -13,4 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { startMcpServer } from './server.js';
|
|
15
15
|
export { getMcpStatus } from './status.js';
|
|
16
|
+
// Native-host: let app.ts point the `simulator` CDP target at the active
|
|
17
|
+
// render-host guest as the visible page changes.
|
|
18
|
+
export { setNativeHost, setActiveBridgeId, setNativeOverviewProvider, getNativeOverviewProvider, } from './target-manager.js';
|
|
16
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
* Tool registration lives in `./tool-registry` and `./tools/*`; this file
|
|
7
7
|
* only wires up transports and lifecycle.
|
|
8
8
|
*/
|
|
9
|
-
import { type Disposable } from '
|
|
9
|
+
import { type Disposable } from '@dimina-kit/electron-deck/main';
|
|
10
10
|
export declare function startMcpServer(resolvedCdpPort: number, mcpPort: number): Disposable;
|
|
11
11
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -10,7 +10,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
10
10
|
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
11
11
|
import { createServer } from 'http';
|
|
12
12
|
import { createRequire } from 'node:module';
|
|
13
|
-
import { toDisposable } from '
|
|
13
|
+
import { toDisposable } from '@dimina-kit/electron-deck/main';
|
|
14
14
|
import { connectTarget, setCdpPort } from './target-manager.js';
|
|
15
15
|
import { recordMcpFailed, recordMcpStarted, recordMcpStopped } from './status.js';
|
|
16
16
|
import { registerCommonTargetTools } from './tool-registry.js';
|
|
@@ -27,6 +27,14 @@ export interface NetworkRequestEntry {
|
|
|
27
27
|
receiveHeadersEnd: number;
|
|
28
28
|
} | null;
|
|
29
29
|
}
|
|
30
|
+
export interface NativeOverview {
|
|
31
|
+
currentRoute: string | null;
|
|
32
|
+
pageStackDepth: number;
|
|
33
|
+
storageKeys: string[];
|
|
34
|
+
storageCount: number;
|
|
35
|
+
appDataKeys: string[];
|
|
36
|
+
}
|
|
37
|
+
export type NativeOverviewProvider = () => Promise<NativeOverview>;
|
|
30
38
|
interface TargetState {
|
|
31
39
|
client: any;
|
|
32
40
|
connected: boolean;
|
|
@@ -35,6 +43,33 @@ interface TargetState {
|
|
|
35
43
|
networkRequests: NetworkRequestEntry[];
|
|
36
44
|
}
|
|
37
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
|
+
/**
|
|
57
|
+
* Resolve which CDP target the `simulator` MCP tools should drive.
|
|
58
|
+
*
|
|
59
|
+
* Default (non-native) path: the localhost:7788 simulator shell — identical
|
|
60
|
+
* to the original behavior; `activeBridgeId` is ignored.
|
|
61
|
+
*
|
|
62
|
+
* Native-host path: the active render-host <webview> guest
|
|
63
|
+
* (pageFrame.html?...bridgeId=<id>), preferring the guest matching
|
|
64
|
+
* `activeBridgeId`, then any pageFrame guest, then degrading to the shell.
|
|
65
|
+
*/
|
|
66
|
+
export declare function selectSimulatorTarget<T extends {
|
|
67
|
+
url?: string;
|
|
68
|
+
type?: string;
|
|
69
|
+
}>(targets: T[], opts: {
|
|
70
|
+
nativeHost: boolean;
|
|
71
|
+
activeBridgeId: string | null;
|
|
72
|
+
}): T | undefined;
|
|
38
73
|
export declare function getTargetState(kind: TargetKind): TargetState;
|
|
39
74
|
declare function listCdpTargets(): Promise<CDP.Target[]>;
|
|
40
75
|
export { listCdpTargets as listTargets };
|
|
@@ -12,9 +12,20 @@
|
|
|
12
12
|
import CDP from 'chrome-remote-interface';
|
|
13
13
|
import { DEFAULT_CDP_PORT } from '../../../shared/constants.js';
|
|
14
14
|
const SIMULATOR_URL_PATTERN = 'localhost:7788';
|
|
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
|
+
const RENDER_GUEST_PATTERN = 'pageFrame.html';
|
|
15
18
|
const MAX_BUFFER = 500;
|
|
16
19
|
const RECONNECT_INTERVAL_MS = 3000;
|
|
17
20
|
let cdpPort = DEFAULT_CDP_PORT;
|
|
21
|
+
// Native-host mode: the simulator target is the active render-host <webview>
|
|
22
|
+
// guest (pageFrame.html?...bridgeId=<id>) rather than the localhost:7788 shell.
|
|
23
|
+
let nativeHostMode = false;
|
|
24
|
+
// The visible page's bridgeId, pushed from the bridge-router render events.
|
|
25
|
+
// `selectSimulatorTarget` prefers the guest matching this id so MCP follows
|
|
26
|
+
// the active page across navigation/tab switches.
|
|
27
|
+
let activeBridgeId = null;
|
|
28
|
+
let nativeOverviewProvider = null;
|
|
18
29
|
const targets = {
|
|
19
30
|
simulator: { client: null, connected: false, timer: null, consoleLogs: [], networkRequests: [] },
|
|
20
31
|
workbench: { client: null, connected: false, timer: null, consoleLogs: [], networkRequests: [] },
|
|
@@ -22,6 +33,57 @@ const targets = {
|
|
|
22
33
|
export function setCdpPort(port) {
|
|
23
34
|
cdpPort = port;
|
|
24
35
|
}
|
|
36
|
+
export function setNativeHost(enabled) {
|
|
37
|
+
nativeHostMode = enabled;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Update the active-page bridgeId so the `simulator` target follows the
|
|
41
|
+
* currently visible render guest. No-op when unchanged. When native-host is
|
|
42
|
+
* on and the simulator target is already connected, fire-and-forget a
|
|
43
|
+
* reconnect so MCP re-points at the new active page.
|
|
44
|
+
*/
|
|
45
|
+
export function setActiveBridgeId(id) {
|
|
46
|
+
if (id === activeBridgeId)
|
|
47
|
+
return;
|
|
48
|
+
activeBridgeId = id;
|
|
49
|
+
if (nativeHostMode && targets.simulator.connected) {
|
|
50
|
+
void connectTarget('simulator');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function setNativeOverviewProvider(provider) {
|
|
54
|
+
nativeOverviewProvider = provider;
|
|
55
|
+
}
|
|
56
|
+
export function getNativeOverviewProvider() {
|
|
57
|
+
return nativeOverviewProvider;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve which CDP target the `simulator` MCP tools should drive.
|
|
61
|
+
*
|
|
62
|
+
* Default (non-native) path: the localhost:7788 simulator shell — identical
|
|
63
|
+
* to the original behavior; `activeBridgeId` is ignored.
|
|
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.
|
|
68
|
+
*/
|
|
69
|
+
export function selectSimulatorTarget(targets, opts) {
|
|
70
|
+
if (!opts.nativeHost) {
|
|
71
|
+
return targets.find((t) => t.url?.includes(SIMULATOR_URL_PATTERN));
|
|
72
|
+
}
|
|
73
|
+
// 1) Active-bridge guest takes priority over list order.
|
|
74
|
+
if (opts.activeBridgeId !== null) {
|
|
75
|
+
const bridgeMatch = `bridgeId=${opts.activeBridgeId}`;
|
|
76
|
+
const active = targets.find((t) => t.url?.includes(RENDER_GUEST_PATTERN) && t.url.includes(bridgeMatch));
|
|
77
|
+
if (active)
|
|
78
|
+
return active;
|
|
79
|
+
}
|
|
80
|
+
// 2) Any render guest (no active match / no active bridge).
|
|
81
|
+
const anyGuest = targets.find((t) => t.url?.includes(RENDER_GUEST_PATTERN));
|
|
82
|
+
if (anyGuest)
|
|
83
|
+
return anyGuest;
|
|
84
|
+
// 3) Degrade to the localhost:7788 shell when no render guest exists yet.
|
|
85
|
+
return targets.find((t) => t.url?.includes(SIMULATOR_URL_PATTERN));
|
|
86
|
+
}
|
|
25
87
|
export function getTargetState(kind) {
|
|
26
88
|
return targets[kind];
|
|
27
89
|
}
|
|
@@ -36,7 +98,7 @@ async function listCdpTargets() {
|
|
|
36
98
|
export { listCdpTargets as listTargets };
|
|
37
99
|
function findTarget(allTargets, kind) {
|
|
38
100
|
if (kind === 'simulator') {
|
|
39
|
-
return allTargets
|
|
101
|
+
return selectSimulatorTarget(allTargets, { nativeHost: nativeHostMode, activeBridgeId });
|
|
40
102
|
}
|
|
41
103
|
// workbench main window: page target whose URL contains index.html (renderer)
|
|
42
104
|
return allTargets.find((t) => t.type === 'page' && t.url?.includes('entries/main/index.html') && !t.url?.includes(SIMULATOR_URL_PATTERN));
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* reliably than they read resources, and this keeps the surface consistent
|
|
11
11
|
* with sibling `*_get_page_info` / `*_connection_status` tools.
|
|
12
12
|
*/
|
|
13
|
-
import { getClient, getTargetState } from '../target-manager.js';
|
|
13
|
+
import { getClient, getNativeOverviewProvider, getTargetState, } from '../target-manager.js';
|
|
14
14
|
// Truncation thresholds: keep the overview compact — orientation, not data dump.
|
|
15
15
|
const MAX_KEYS = 50;
|
|
16
16
|
const MAX_HINT_TEXT = 200;
|
|
@@ -160,6 +160,20 @@ export function registerContextTools(server) {
|
|
|
160
160
|
isError: true,
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
+
const nativeOverviewProvider = getNativeOverviewProvider();
|
|
164
|
+
if (nativeOverviewProvider) {
|
|
165
|
+
try {
|
|
166
|
+
const nativeOverview = await nativeOverviewProvider();
|
|
167
|
+
probe.pageStackDepth = nativeOverview.pageStackDepth;
|
|
168
|
+
probe.currentRoute = nativeOverview.currentRoute;
|
|
169
|
+
probe.storageKeys = nativeOverview.storageKeys;
|
|
170
|
+
probe.storageCount = nativeOverview.storageCount;
|
|
171
|
+
probe.appDataKeys = nativeOverview.appDataKeys;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
// Best effort: keep the CDP probe values if the native provider fails.
|
|
175
|
+
}
|
|
176
|
+
}
|
|
163
177
|
if (!probe.simulatorDataPresent)
|
|
164
178
|
hints.push('simulator bridge not ready (window.__simulatorData missing)');
|
|
165
179
|
else if (!probe.bridgeReady)
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native-host network forwarder.
|
|
3
|
+
*
|
|
4
|
+
* ── Why this exists ─────────────────────────────────────────────────────────
|
|
5
|
+
* The right-panel "Network" view is the embedded Chrome DevTools front-end. In
|
|
6
|
+
* native-host that front-end is attached to the SERVICE HOST webContents (see
|
|
7
|
+
* view-manager `pointNativeDevtoolsAtServiceWc`), so its Network tab only ever
|
|
8
|
+
* shows the service host's own network activity.
|
|
9
|
+
*
|
|
10
|
+
* But the mini-app's `wx.request` / `dd.request` / `downloadFile` / `uploadFile`
|
|
11
|
+
* do NOT run in the service host. bridge-router forwards every `invokeAPI` that
|
|
12
|
+
* isn't registered host-side to the SIMULATOR WebContentsView via `E.API_CALL`,
|
|
13
|
+
* and DeviceShell runs the handler there (`device-shell.tsx` → `runApiAsync` →
|
|
14
|
+
* `direct-request.ts`/`simulator-api-network.ts`, which call `fetch()` /
|
|
15
|
+
* `XMLHttpRequest`). Those requests therefore go through the simulator WCV's
|
|
16
|
+
* network stack — a DIFFERENT webContents than the one the DevTools front-end
|
|
17
|
+
* inspects — so they were invisible in the Network panel after the native-host
|
|
18
|
+
* refactor. THAT is the regression this service closes.
|
|
19
|
+
*
|
|
20
|
+
* ── How it surfaces them (primary sink: native Network tab) ─────────────────
|
|
21
|
+
* We attach the CDP `webContents.debugger` to the simulator WCV, `Network.enable`,
|
|
22
|
+
* and listen for the Network.* lifecycle events. Rather than reformat them, we
|
|
23
|
+
* forward the RAW CDP messages straight into the WebContents that HOSTS the
|
|
24
|
+
* DevTools front-end (the right-panel `simulatorView.webContents`), via
|
|
25
|
+
* `window.DevToolsAPI.dispatchMessage(json)`. The bundled Chrome DevTools then
|
|
26
|
+
* renders them natively in its own Network tab — same protocol path it would
|
|
27
|
+
* use for its own inspected target.
|
|
28
|
+
*
|
|
29
|
+
* Because the front-end is inspecting the service host (a DIFFERENT target than
|
|
30
|
+
* the simulator the events came from), the simulator's `requestId`s could
|
|
31
|
+
* collide with the service host's own. We therefore rewrite every requestId
|
|
32
|
+
* into a namespaced virtual id (`dimina:sim:<epoch>:<rawId>`) before dispatch,
|
|
33
|
+
* keeping a raw→virtual map so redirects / extra-info / completion events on the
|
|
34
|
+
* same request stay correlated. We inject on the MAIN session (no `sessionId`),
|
|
35
|
+
* i.e. the events appear as activity on the currently-inspected target. This is
|
|
36
|
+
* the one-shot approach the Codex review settled on; child-target routing
|
|
37
|
+
* (`Target.attachedToTarget` + hooking outbound CDP) is explicitly deferred.
|
|
38
|
+
*
|
|
39
|
+
* ── Fallback sink (console line) ────────────────────────────────────────────
|
|
40
|
+
* If the DevTools host wc is unavailable, or `window.DevToolsAPI.dispatchMessage`
|
|
41
|
+
* never appears (front-end not bootstrapped), or a dispatch throws, we degrade
|
|
42
|
+
* to the legacy behaviour: re-emit each COMPLETED request as one `[网络]`-prefixed
|
|
43
|
+
* line into the SERVICE HOST's own console (where the DevTools is attached). That
|
|
44
|
+
* keeps the requests visible in the panel the user already watches even when the
|
|
45
|
+
* protocol path can't be used. The fallback never duplicates the native path —
|
|
46
|
+
* it is chosen per completed-request, only when the native dispatch is known
|
|
47
|
+
* unusable.
|
|
48
|
+
*
|
|
49
|
+
* ── Coverage (one-shot scope) ───────────────────────────────────────────────
|
|
50
|
+
* ✅ Forwarded to the native Network tab: requestWillBeSent, responseReceived,
|
|
51
|
+
* loadingFinished, loadingFailed (+ requestWillBeSentExtraInfo /
|
|
52
|
+
* responseReceivedExtraInfo when present, for accurate headers/status).
|
|
53
|
+
* ⏳ TODO (二期): `dataReceived` per-chunk forwarding (skipped to avoid an
|
|
54
|
+
* executeJavaScript per chunk), and response body / preview (needs hooking
|
|
55
|
+
* `InspectorFrontendHost.sendMessageToBackend` + a prefetched body cache so
|
|
56
|
+
* the front-end's `Network.getResponseBody` round-trip resolves).
|
|
57
|
+
* ⚠️ NOT captured here: requests issued from inside a render-host `<webview>`
|
|
58
|
+
* guest (page-level resource loads / page `fetch`). The safe-area service
|
|
59
|
+
* already owns each guest's `wc.debugger`, and `debugger.attach` is
|
|
60
|
+
* single-owner — bringing those in needs a shared CDP broker. `source:'render'`
|
|
61
|
+
* is reserved for when that's added (later).
|
|
62
|
+
* ⚠️ NOT observable by any `webContents.debugger`: a request a host module issues
|
|
63
|
+
* directly from the MAIN process. Those need an explicit `report()` call
|
|
64
|
+
* (exposed below; it uses the console fallback path).
|
|
65
|
+
*/
|
|
66
|
+
import type { WebContents } from 'electron';
|
|
67
|
+
import { type ConnectionRegistry, type Disposable } from '@dimina-kit/electron-deck/main';
|
|
68
|
+
/** Which layer a captured request came from (tags the fallback log line). */
|
|
69
|
+
export type NetworkSource = 'service' | 'render';
|
|
70
|
+
/** A normalized completed network request, used only by the console fallback. */
|
|
71
|
+
export interface NetworkRequestRecord {
|
|
72
|
+
source: NetworkSource;
|
|
73
|
+
url: string;
|
|
74
|
+
method: string;
|
|
75
|
+
/** HTTP status, or 0 when the request failed before a response. */
|
|
76
|
+
status: number;
|
|
77
|
+
/** Failure text for `loadingFailed`, else undefined. */
|
|
78
|
+
errorText?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolvers the forwarder consults each time it needs a target wc. Both are
|
|
82
|
+
* re-read on every use so a pre-warm-pool swap (service) or a DevTools-host
|
|
83
|
+
* re-create (devtools) is tolerated without re-wiring.
|
|
84
|
+
*/
|
|
85
|
+
export interface NetworkForwarderBridge {
|
|
86
|
+
/** The SERVICE HOST wc — fallback console sink target. */
|
|
87
|
+
getServiceWc(appId?: string): WebContents | null;
|
|
88
|
+
/**
|
|
89
|
+
* The wc hosting the right-panel Chrome DevTools FRONT-END (the one we inject
|
|
90
|
+
* `window.DevToolsAPI.dispatchMessage` into). Set by the ViewManager via
|
|
91
|
+
* `setDevtoolsHost`. Null until the DevTools host view exists.
|
|
92
|
+
*/
|
|
93
|
+
getDevtoolsWc?(): WebContents | null;
|
|
94
|
+
/**
|
|
95
|
+
* Optional connection-layer registry (`@dimina-kit/electron-deck/main`). When
|
|
96
|
+
* present, per-webContents teardowns route through `acquire(wc).own(d)` so the
|
|
97
|
+
* Connection disposes them deterministically on wc destroy / reset (replacing
|
|
98
|
+
* the bespoke `wc.once('destroyed', cleanup)`). Omitted → the legacy
|
|
99
|
+
* `once('destroyed')` fallback is used, so existing callers compile unchanged.
|
|
100
|
+
*/
|
|
101
|
+
connections?: ConnectionRegistry;
|
|
102
|
+
}
|
|
103
|
+
export interface NetworkForwarder extends Disposable {
|
|
104
|
+
/**
|
|
105
|
+
* Attach the CDP debugger to the simulator WCV and start forwarding its
|
|
106
|
+
* Network events. Idempotent for the same wc; re-pointing to a new wc (a
|
|
107
|
+
* relaunch / pool swap) detaches the previous one first. No-op if the wc is
|
|
108
|
+
* destroyed or its debugger is already claimed (DevTools / another client).
|
|
109
|
+
*/
|
|
110
|
+
attachSimulator(wc: WebContents): void;
|
|
111
|
+
/** Detach from the current simulator WCV (without disposing the forwarder). */
|
|
112
|
+
detachSimulator(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Point the forwarder at the WebContents hosting the DevTools FRONT-END (the
|
|
115
|
+
* primary, native-Network-tab sink). Pass null when that view is torn down so
|
|
116
|
+
* we fall back to the console line. Re-callable across DevTools re-creates.
|
|
117
|
+
*/
|
|
118
|
+
setDevtoolsHost(wc: WebContents | null): void;
|
|
119
|
+
/**
|
|
120
|
+
* Manually surface a request that no `webContents.debugger` can observe
|
|
121
|
+
* (e.g. a main-process direct send). Uses the console fallback sink.
|
|
122
|
+
*/
|
|
123
|
+
report(record: NetworkRequestRecord): void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* CDP events whose `params.requestId` we rewrite into the virtual namespace.
|
|
127
|
+
* Anything carrying a requestId must be namespaced consistently — even methods
|
|
128
|
+
* we don't (yet) forward — so the raw→virtual map stays coherent if forwarding
|
|
129
|
+
* is widened later. `requestServedFromCache` and `resourceChangedPriority` are
|
|
130
|
+
* included for that reason (MINOR: rewrite-only today, not forwarded).
|
|
131
|
+
*/
|
|
132
|
+
export declare const REWRITE_REQUEST_ID_METHODS: ReadonlySet<string>;
|
|
133
|
+
/** The Network.* methods this one-shot pass forwards to the front-end. */
|
|
134
|
+
export declare const FORWARDED_METHODS: ReadonlySet<string>;
|
|
135
|
+
/**
|
|
136
|
+
* Bounded, TTL'd raw→virtual requestId map with an active/retired split.
|
|
137
|
+
*
|
|
138
|
+
* An ACTIVE request (seen `requestWillBeSent`/ExtraInfo, not yet terminal) must
|
|
139
|
+
* NEVER lose its mapping — otherwise a later `responseReceived`/`loadingFinished`
|
|
140
|
+
* would mint a fresh virtual id and the front-end would see an orphaned event.
|
|
141
|
+
* So active entries are exempt from both TTL and the LRU cap.
|
|
142
|
+
*
|
|
143
|
+
* Only once a request goes terminal (`loadingFinished`/`loadingFailed`) is it
|
|
144
|
+
* RETIRED: its mapping is kept a while longer so genuinely-late events (an
|
|
145
|
+
* extra-info after completion) still correlate, but it now ages out by TTL and
|
|
146
|
+
* by an LRU cap so a long session never grows unbounded. Eviction only ever
|
|
147
|
+
* touches the retired pool.
|
|
148
|
+
*/
|
|
149
|
+
export declare class RequestIdNamespace {
|
|
150
|
+
private readonly epoch;
|
|
151
|
+
private readonly ttlMs;
|
|
152
|
+
private readonly max;
|
|
153
|
+
private readonly now;
|
|
154
|
+
private readonly map;
|
|
155
|
+
private seq;
|
|
156
|
+
constructor(epoch: string, ttlMs?: number, max?: number, now?: () => number);
|
|
157
|
+
/**
|
|
158
|
+
* Resolve (lazily creating) the virtual id for a raw id. Lazy creation lets an
|
|
159
|
+
* ExtraInfo event that arrives BEFORE its `requestWillBeSent` still get a
|
|
160
|
+
* stable id that the later events reuse — a redirect chain reuses the same raw
|
|
161
|
+
* id and therefore the same virtual id (we never mint a new one per redirect).
|
|
162
|
+
*
|
|
163
|
+
* A freshly-resolved (or any non-retired) entry is ACTIVE and thus immune to
|
|
164
|
+
* eviction. We only TTL-expire entries that have already been retired; an
|
|
165
|
+
* active entry never "expires" no matter how long it stays in flight.
|
|
166
|
+
*/
|
|
167
|
+
resolve(rawId: string): string;
|
|
168
|
+
/**
|
|
169
|
+
* Mark a request terminal: it leaves the active set and enters the retired
|
|
170
|
+
* pool with a fresh TTL, where it becomes eligible for TTL/LRU eviction.
|
|
171
|
+
*/
|
|
172
|
+
retire(rawId: string): void;
|
|
173
|
+
private evict;
|
|
174
|
+
/** Total entries (active + retired). */
|
|
175
|
+
get size(): number;
|
|
176
|
+
/** Entries still in flight (resolved, not yet retired). */
|
|
177
|
+
get activeSize(): number;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Rewrite a single CDP message's `requestId` into the namespace, returning a new
|
|
181
|
+
* `{ method, params }` (never mutating the input). Returns the message unchanged
|
|
182
|
+
* when the method carries no requestId we track or params is malformed. Pure
|
|
183
|
+
* aside from the namespace map it threads through.
|
|
184
|
+
*/
|
|
185
|
+
export declare function rewriteRequestId(method: string, params: unknown, ns: RequestIdNamespace): {
|
|
186
|
+
method: string;
|
|
187
|
+
params: unknown;
|
|
188
|
+
};
|
|
189
|
+
export declare function createNetworkForwarder(bridge: NetworkForwarderBridge): NetworkForwarder;
|
|
190
|
+
//# sourceMappingURL=index.d.ts.map
|