@dimina-kit/devtools 0.3.2-dev.20260601115343 → 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 +49 -59
- package/dist/main/api.d.ts +1 -2
- package/dist/main/api.js +5 -1
- package/dist/main/app/app.d.ts +15 -5
- package/dist/main/app/app.js +242 -122
- 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 +5812 -1729
- 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 +1 -1
- 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 +9 -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 +1 -1
- package/dist/main/ipc/views.js +40 -2
- 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 +22 -0
- package/dist/main/services/layout/index.js +25 -0
- 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/index.d.ts +1 -1
- package/dist/main/services/simulator-temp-files/index.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/toolbar/toolbar-store.d.ts +3 -3
- package/dist/main/services/toolbar/toolbar-store.js +1 -18
- 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 +125 -0
- package/dist/main/services/views/view-manager.js +839 -4
- package/dist/main/services/workbench-context.d.ts +67 -7
- package/dist/main/services/workbench-context.js +6 -1
- package/dist/main/services/workspace/workspace-service.js +7 -13
- package/dist/main/utils/ipc-registry.d.ts +1 -1
- package/dist/main/utils/ipc-registry.js +21 -4
- 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 +30 -12
- 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 +1935 -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 +244 -574
- 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/index-CcJKzatF.js +50 -0
- package/dist/renderer/assets/{input-CCYS8Ave.js → input-QGx6FFX1.js} +2 -2
- package/dist/renderer/assets/ipc-transport-BT4QYQqu.css +1 -0
- package/dist/renderer/assets/{ipc-transport-Bn4KXvhu.js → ipc-transport-DvZvwK-Z.js} +2 -2
- package/dist/renderer/assets/{popover-CH4rwpdt.js → popover-BOH1If1J.js} +2 -2
- package/dist/renderer/assets/select-C7JQ8G5N.js +2 -0
- package/dist/renderer/assets/{settings-CMTB-t0x.js → settings-DpAbTJyF.js} +2 -2
- package/dist/renderer/assets/{settings-api-Csdngf9Z.js → settings-api-RD2IZF53.js} +2 -2
- package/dist/renderer/assets/{workbenchSettings-CODFCzOg.js → workbenchSettings-CNJX4Qna.js} +2 -2
- package/dist/renderer/entries/main/index.html +5 -5
- package/dist/renderer/entries/popover/index.html +5 -5
- package/dist/renderer/entries/settings/index.html +5 -5
- package/dist/renderer/entries/workbench-settings/index.html +4 -4
- 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/ipc-channels.d.ts +84 -1
- package/dist/shared/ipc-channels.js +90 -10
- package/dist/shared/ipc-schemas.d.ts +59 -2
- package/dist/shared/ipc-schemas.js +64 -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 -39
- 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 +8 -9
- package/dist/main/utils/disposable.d.ts +0 -18
- package/dist/main/utils/disposable.js +0 -67
- package/dist/renderer/assets/index-BDMxXUfn.js +0 -50
- package/dist/renderer/assets/ipc-transport-Cu7tubyg.css +0 -1
- package/dist/renderer/assets/select-Ct4-sijm.js +0 -2
- package/dist/simulator/assets/simulator-B4e3c6_O.js +0 -9
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
const MIME_TYPES = {
|
|
6
|
+
'.css': 'text/css; charset=utf-8',
|
|
7
|
+
'.html': 'text/html; charset=utf-8',
|
|
8
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
9
|
+
'.json': 'application/json; charset=utf-8',
|
|
10
|
+
'.map': 'application/json; charset=utf-8',
|
|
11
|
+
'.svg': 'image/svg+xml',
|
|
12
|
+
'.png': 'image/png',
|
|
13
|
+
'.jpg': 'image/jpeg',
|
|
14
|
+
'.jpeg': 'image/jpeg',
|
|
15
|
+
'.gif': 'image/gif',
|
|
16
|
+
'.webp': 'image/webp',
|
|
17
|
+
'.wasm': 'application/wasm',
|
|
18
|
+
};
|
|
19
|
+
export async function startDiminaResourceServer(rootDir) {
|
|
20
|
+
const root = path.resolve(rootDir);
|
|
21
|
+
const server = http.createServer((req, res) => {
|
|
22
|
+
void handleRequest(root, req, res);
|
|
23
|
+
});
|
|
24
|
+
await new Promise((resolve, reject) => {
|
|
25
|
+
server.once('error', reject);
|
|
26
|
+
server.listen(0, '127.0.0.1', () => {
|
|
27
|
+
server.off('error', reject);
|
|
28
|
+
resolve();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const address = server.address();
|
|
32
|
+
return {
|
|
33
|
+
baseUrl: `http://127.0.0.1:${address.port}/`,
|
|
34
|
+
close() {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
server.close((err) => err ? reject(err) : resolve());
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function handleRequest(root, req, res) {
|
|
42
|
+
setCorsHeaders(res);
|
|
43
|
+
if (req.method === 'OPTIONS') {
|
|
44
|
+
res.writeHead(204);
|
|
45
|
+
res.end();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
49
|
+
res.writeHead(405);
|
|
50
|
+
res.end('Method Not Allowed');
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
54
|
+
const filePath = resolveContainedPath(root, decodeURIComponent(url.pathname));
|
|
55
|
+
if (!filePath) {
|
|
56
|
+
res.writeHead(403);
|
|
57
|
+
res.end('Forbidden');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const stat = await fs.promises.stat(filePath);
|
|
62
|
+
if (!stat.isFile()) {
|
|
63
|
+
res.writeHead(404);
|
|
64
|
+
res.end('Not Found');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
res.writeHead(200, {
|
|
68
|
+
'content-type': MIME_TYPES[path.extname(filePath)] ?? 'application/octet-stream',
|
|
69
|
+
'content-length': stat.size,
|
|
70
|
+
'cache-control': 'no-store',
|
|
71
|
+
});
|
|
72
|
+
if (req.method === 'HEAD') {
|
|
73
|
+
res.end();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
fs.createReadStream(filePath).pipe(res);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
res.writeHead(404);
|
|
80
|
+
res.end('Not Found');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function resolveContainedPath(root, pathname) {
|
|
84
|
+
const relative = pathname.replace(/^\/+/, '') || 'index.html';
|
|
85
|
+
const resolved = path.resolve(root, relative);
|
|
86
|
+
if (resolved !== root && !resolved.startsWith(root + path.sep))
|
|
87
|
+
return null;
|
|
88
|
+
return resolved;
|
|
89
|
+
}
|
|
90
|
+
function setCorsHeaders(res) {
|
|
91
|
+
res.setHeader('access-control-allow-origin', '*');
|
|
92
|
+
res.setHeader('access-control-allow-headers', '*');
|
|
93
|
+
res.setHeader('access-control-allow-methods', 'GET,HEAD,OPTIONS');
|
|
94
|
+
res.setHeader('cross-origin-resource-policy', 'cross-origin');
|
|
95
|
+
}
|
|
96
|
+
export function toSourceUrl(filePath) {
|
|
97
|
+
return pathToFileURL(filePath).toString();
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=dimina-resource-server.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { WebContents } from 'electron';
|
|
2
|
+
import type { ConnectionRegistry } from '@dimina-kit/electron-deck/main';
|
|
3
|
+
import type { BridgeRouterHandle } from '../../ipc/bridge-router.js';
|
|
4
|
+
/** Which target a front-end CDP command is routed to. */
|
|
5
|
+
export type CdpRoute = 'render' | 'service';
|
|
6
|
+
/**
|
|
7
|
+
* Decide where a front-end CDP `method` is routed.
|
|
8
|
+
*
|
|
9
|
+
* render → DOM./CSS./Overlay./DOMSnapshot./DOMDebugger. (the Elements tree)
|
|
10
|
+
* service → EVERYTHING ELSE, and in particular:
|
|
11
|
+
* • Emulation.* — RED LINE: routing this to the render guest would let the
|
|
12
|
+
* front-end overwrite the safe-area service's `setSafeAreaInsetsOverride`.
|
|
13
|
+
* It MUST stay on the service-host inspection path (pass-through).
|
|
14
|
+
* • Runtime./Console./Debugger./Network./Page./Target./Input./Profiler./Log.
|
|
15
|
+
* — the service host owns these; leave them on the original channel.
|
|
16
|
+
*
|
|
17
|
+
* Pure (no I/O). The hook script inlines an equivalent prefix test driven by the
|
|
18
|
+
* same `RENDER_DOMAIN_PREFIXES` literal, so the two cannot silently drift.
|
|
19
|
+
*/
|
|
20
|
+
export declare function routeByDomain(method: string): CdpRoute;
|
|
21
|
+
/** True for an event method we re-inject from the render guest into the panel. */
|
|
22
|
+
export declare function isRenderEventMethod(method: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The JS injected into the DevTools front-end realm. Idempotent (sentinel guard).
|
|
25
|
+
* Wraps `InspectorFrontendHost.sendMessageToBackend`: a RENDER-domain command is
|
|
26
|
+
* pushed onto `globalThis.__diminaElementsOutbound` (drained by main) and NOT
|
|
27
|
+
* forwarded to the original embedder channel (main answers it from the render
|
|
28
|
+
* guest); every other command calls through to the original (service-host path).
|
|
29
|
+
*
|
|
30
|
+
* Returns `'installed'` / `'already'` on success, `'partial'` while the embedder
|
|
31
|
+
* global is not yet present (so the caller retries), `'error:…'` on a real fault.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildElementsHookScript(): string;
|
|
34
|
+
export interface ElementsForwardDeps {
|
|
35
|
+
/** The wc hosting the right-panel Chrome DevTools FRONT-END (injection target). */
|
|
36
|
+
devtoolsWc: WebContents;
|
|
37
|
+
/** Router handle — resolves the active render guest + render-event stream. */
|
|
38
|
+
bridge: BridgeRouterHandle;
|
|
39
|
+
/**
|
|
40
|
+
* The app whose active render guest we route to. `undefined` means "the
|
|
41
|
+
* router's current app" (resolved fresh on every use, like the safe-area /
|
|
42
|
+
* devtools-follow paths) — what the wire-up passes.
|
|
43
|
+
*/
|
|
44
|
+
appId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional connection registry. When present, per-webContents teardowns
|
|
47
|
+
* (the devtools front-end wc's `stop`, and each render guest's `onDestroyed`)
|
|
48
|
+
* are routed through `connections.acquire(wc).own(cleanup)` so they fire
|
|
49
|
+
* deterministically on wc destroy / connection reset — replacing the bespoke
|
|
50
|
+
* `wc.once('destroyed', cleanup)` hook. Optional so existing callers compile
|
|
51
|
+
* unchanged; absent → the `once('destroyed')` fallback is used.
|
|
52
|
+
*/
|
|
53
|
+
connections?: ConnectionRegistry;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Install Elements forwarding on a DevTools front-end host wc. Returns a disposer
|
|
57
|
+
* (`stop`) that clears timers, unsubscribes render events, detaches ONLY the
|
|
58
|
+
* debugger sessions this feature attached, and removes every listener it added.
|
|
59
|
+
*
|
|
60
|
+
* Best-effort + defensive throughout: a destroyed wc ends the feature; every
|
|
61
|
+
* executeJavaScript / sendCommand is wrapped so a torn-down guest never throws
|
|
62
|
+
* and an in-flight command always settles (we dispatch an error back rather than
|
|
63
|
+
* leaving the front-end pending).
|
|
64
|
+
*/
|
|
65
|
+
export declare function installElementsForward(deps: ElementsForwardDeps): () => void;
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|