@dimina-kit/devtools 0.3.2-dev.20260611063505 → 0.3.2-dev.20260611135124
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 +53 -40
- package/dist/main/api.d.ts +4 -2
- package/dist/main/api.js +5 -1
- package/dist/main/app/app.d.ts +1 -5
- package/dist/main/app/app.js +4 -19
- package/dist/main/index.bundle.js +238 -392
- package/dist/main/ipc/app.d.ts +1 -1
- package/dist/main/ipc/app.js +0 -7
- package/dist/main/ipc/index.d.ts +0 -2
- package/dist/main/ipc/index.js +0 -2
- package/dist/main/ipc/settings.d.ts +1 -1
- package/dist/main/ipc/settings.js +1 -13
- package/dist/main/ipc/simulator-module.d.ts +3 -3
- package/dist/main/ipc/simulator-module.js +3 -7
- package/dist/main/ipc/simulator.js +1 -12
- package/dist/main/runtime/miniapp-runtime.d.ts +138 -28
- package/dist/main/runtime/miniapp-runtime.js +6 -11
- package/dist/main/services/layout/index.d.ts +0 -11
- package/dist/main/services/layout/index.js +0 -23
- package/dist/main/services/notifications/renderer-notifier.d.ts +0 -6
- package/dist/main/services/notifications/renderer-notifier.js +1 -10
- package/dist/main/services/service-host-pool/pool.d.ts +5 -4
- package/dist/main/services/views/host-toolbar-port-channel.d.ts +93 -0
- package/dist/main/services/views/host-toolbar-port-channel.js +169 -0
- package/dist/main/services/views/host-toolbar-session-runtime.d.ts +35 -0
- package/dist/main/services/views/host-toolbar-session-runtime.js +55 -0
- package/dist/main/services/views/view-manager.d.ts +68 -39
- package/dist/main/services/views/view-manager.js +143 -182
- package/dist/main/services/workbench-context.d.ts +6 -26
- package/dist/main/services/workbench-context.js +0 -14
- package/dist/main/services/workspace/workspace-service.js +7 -13
- package/dist/main/utils/paths.d.ts +11 -2
- package/dist/main/utils/paths.js +11 -2
- package/dist/preload/index.d.ts +15 -0
- package/dist/preload/index.js +15 -0
- package/dist/preload/runtime/host-toolbar-port.d.ts +44 -0
- package/dist/preload/runtime/host-toolbar-port.js +127 -0
- package/dist/preload/runtime/host-toolbar-runtime.d.ts +41 -0
- package/dist/preload/runtime/host-toolbar-runtime.js +49 -0
- package/dist/preload/windows/{host-toolbar.cjs → host-toolbar-runtime.cjs} +94 -3
- package/dist/preload/windows/host-toolbar-runtime.cjs.map +7 -0
- package/dist/preload/windows/host-toolbar-runtime.d.ts +2 -0
- package/dist/preload/windows/host-toolbar-runtime.js +13 -0
- package/dist/preload/windows/simulator.cjs +0 -2
- package/dist/preload/windows/simulator.cjs.map +2 -2
- package/dist/preload/windows/simulator.js +0 -2
- package/dist/renderer/assets/constants-DI382mTP.js +2 -0
- package/dist/renderer/assets/index-DLzjz1wv.js +50 -0
- package/dist/renderer/assets/{input-CFHmbOgz.js → input-6fpCXV-n.js} +2 -2
- package/dist/renderer/assets/ipc-transport-Bs8Sf1B2.css +1 -0
- package/dist/renderer/assets/{ipc-transport-BkKKww3u.js → ipc-transport-D22e4dv7.js} +6 -6
- package/dist/renderer/assets/popover-CdGdKkkc.js +2 -0
- package/dist/renderer/assets/select-X0sbjwdP.js +2 -0
- package/dist/renderer/assets/{settings-Cl4IcWnG.js → settings-CS4jYaCw.js} +2 -2
- package/dist/renderer/assets/settings-api-CCWTAao_.js +2 -0
- package/dist/renderer/assets/workbenchSettings-Bpzaj3bm.js +8 -0
- package/dist/renderer/entries/main/index.html +7 -6
- package/dist/renderer/entries/popover/index.html +6 -6
- package/dist/renderer/entries/settings/index.html +5 -5
- package/dist/renderer/entries/workbench-settings/index.html +5 -5
- package/dist/shared/constants.d.ts +18 -0
- package/dist/shared/constants.js +18 -0
- package/dist/shared/ipc-channels.d.ts +10 -23
- package/dist/shared/ipc-channels.js +13 -34
- package/dist/shared/ipc-schemas.d.ts +0 -12
- package/dist/shared/ipc-schemas.js +0 -12
- package/dist/shared/types.d.ts +14 -67
- package/package.json +6 -6
- package/dist/main/ipc/panels.d.ts +0 -4
- package/dist/main/ipc/panels.js +0 -46
- package/dist/main/ipc/toolbar.d.ts +0 -4
- package/dist/main/ipc/toolbar.js +0 -21
- package/dist/main/services/toolbar/toolbar-store.d.ts +0 -23
- package/dist/main/services/toolbar/toolbar-store.js +0 -40
- package/dist/preload/windows/host-toolbar.cjs.map +0 -7
- package/dist/preload/windows/host-toolbar.d.ts +0 -2
- package/dist/preload/windows/host-toolbar.js +0 -12
- package/dist/renderer/assets/constants-CLAQX6VZ.js +0 -2
- package/dist/renderer/assets/index-CZQOpCvg.js +0 -50
- package/dist/renderer/assets/ipc-transport-Bv_BVu4T.css +0 -1
- package/dist/renderer/assets/popover-h1M7n3tt.js +0 -2
- package/dist/renderer/assets/select-kj0n1oYf.js +0 -2
- package/dist/renderer/assets/settings-api-CCwo2eOi.js +0 -2
- package/dist/renderer/assets/workbenchSettings-BzlpQnve.js +0 -8
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gated narrow channel between the main process and the host-toolbar
|
|
3
|
+
* WebContentsView's page, over a per-load transferred MessagePort.
|
|
4
|
+
*
|
|
5
|
+
* Why a MessagePort and not plain IPC: the toolbar page is HOST-ARBITRARY
|
|
6
|
+
* content. A dedicated port pair gives it exactly one pipe whose main-side end
|
|
7
|
+
* lives in this module — the page never gains a generic `ipcRenderer` reach
|
|
8
|
+
* into the ~72 internal devtools channels, and main-side inbound traffic is
|
|
9
|
+
* validated at this single waist.
|
|
10
|
+
*
|
|
11
|
+
* Lifecycle (per-load handshake):
|
|
12
|
+
* - On every toolbar-wc `did-finish-load` main builds a fresh
|
|
13
|
+
* `MessageChannelMain`, transfers port2 to the new document via
|
|
14
|
+
* `wc.postMessage(ViewChannel.HostToolbarPort, null, [port2])`, keeps
|
|
15
|
+
* port1 and `start()`s it. The previous port1 (if any) is closed first —
|
|
16
|
+
* its document is gone.
|
|
17
|
+
* - `onMessage` registrations are CONTROL-level (this module's registry), not
|
|
18
|
+
* per-port: they may be made before any view exists and survive page
|
|
19
|
+
* reloads / wc rebuilds, because each new handshake dispatches into the
|
|
20
|
+
* same registry.
|
|
21
|
+
* - `send` is gated and non-queueing: `false` means "not delivered, ever" —
|
|
22
|
+
* no toolbar view is conjured, nothing is buffered for a later handshake.
|
|
23
|
+
* - A port1 `'close'` event (the renderer end died without a re-handshake
|
|
24
|
+
* yet) drops the live-port reference so `send` reports `false` instead of
|
|
25
|
+
* posting into a dead pipe.
|
|
26
|
+
* - NAVIGATION INVALIDATES THE PORT. The port pair belongs to one DOCUMENT,
|
|
27
|
+
* so starting a navigation that replaces that document closes port1 and
|
|
28
|
+
* `send` returns `false` until the new document's `did-finish-load`
|
|
29
|
+
* handshake. Two paths:
|
|
30
|
+
* (a) host-initiated `hostToolbar.loadURL/loadFile` calls `invalidate()`
|
|
31
|
+
* synchronously AT INITIATION (view-manager does this before the
|
|
32
|
+
* `webContents.loadURL/loadFile` await), so a same-tick `send` can
|
|
33
|
+
* never report `true` for an envelope posted into the document the
|
|
34
|
+
* load is about to replace;
|
|
35
|
+
* (b) page-initiated navigation (location.href / reload) is caught by a
|
|
36
|
+
* `did-start-navigation` listener — guarded to the ACTIVE wc,
|
|
37
|
+
* main-frame, cross-document only. Same-document navigations
|
|
38
|
+
* (anchors, pushState, history) and subframe navigations do NOT
|
|
39
|
+
* invalidate: the document the port lives in survives those, and no
|
|
40
|
+
* main-frame `did-finish-load` would follow to ever restore the
|
|
41
|
+
* channel.
|
|
42
|
+
*
|
|
43
|
+
* Envelope both directions: `{ channel: string, payload: unknown }`. Inbound
|
|
44
|
+
* data that is not an object with a string `channel` is DROPPED without
|
|
45
|
+
* throwing (the counterpart is arbitrary host content).
|
|
46
|
+
*/
|
|
47
|
+
import { MessageChannelMain } from 'electron';
|
|
48
|
+
import { ViewChannel } from '../../../shared/ipc-channels.js';
|
|
49
|
+
export function createHostToolbarPortChannel(opts) {
|
|
50
|
+
let activePort = null;
|
|
51
|
+
/** The wc that owns `activePort` (so a stale wc's `destroyed` can't drop a successor's port). */
|
|
52
|
+
let activeWc = null;
|
|
53
|
+
let disposed = false;
|
|
54
|
+
// Array (not Map<channel, Set>) so the same handler function may be
|
|
55
|
+
// registered twice and each registration disposes independently.
|
|
56
|
+
const handlers = [];
|
|
57
|
+
function dispatch(data) {
|
|
58
|
+
// Inbound waist: the toolbar page is host-arbitrary content — anything
|
|
59
|
+
// that is not an object envelope with a string channel is dropped.
|
|
60
|
+
if (typeof data !== 'object' || data === null)
|
|
61
|
+
return;
|
|
62
|
+
const { channel, payload } = data;
|
|
63
|
+
if (typeof channel !== 'string')
|
|
64
|
+
return;
|
|
65
|
+
// Snapshot so a handler that (un)subscribes mid-dispatch can't skew iteration.
|
|
66
|
+
for (const entry of [...handlers]) {
|
|
67
|
+
if (entry.channel === channel)
|
|
68
|
+
entry.handler(payload);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function dropActivePort(close) {
|
|
72
|
+
const port = activePort;
|
|
73
|
+
activePort = null;
|
|
74
|
+
activeWc = null;
|
|
75
|
+
if (close && port) {
|
|
76
|
+
try {
|
|
77
|
+
port.close();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
/* already closed */
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function handshake(wc) {
|
|
85
|
+
if (disposed)
|
|
86
|
+
return;
|
|
87
|
+
if (!opts.isCurrent(wc))
|
|
88
|
+
return;
|
|
89
|
+
// The previous load's document is gone; its port goes with it.
|
|
90
|
+
dropActivePort(true);
|
|
91
|
+
const { port1, port2 } = new MessageChannelMain();
|
|
92
|
+
port1.on('message', (event) => {
|
|
93
|
+
dispatch(event.data);
|
|
94
|
+
});
|
|
95
|
+
// Renderer end died without a re-handshake (page crash / wc close): drop
|
|
96
|
+
// the reference so send() reports false instead of posting into the void.
|
|
97
|
+
port1.on('close', () => {
|
|
98
|
+
if (activePort === port1)
|
|
99
|
+
dropActivePort(false);
|
|
100
|
+
});
|
|
101
|
+
wc.postMessage(ViewChannel.HostToolbarPort, null, [port2]);
|
|
102
|
+
port1.start();
|
|
103
|
+
activePort = port1;
|
|
104
|
+
activeWc = wc;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
attach(wc) {
|
|
108
|
+
wc.on('did-finish-load', () => handshake(wc));
|
|
109
|
+
// Page-initiated navigation (location.href / reload): the document the
|
|
110
|
+
// port lives in is being replaced — invalidate so send() reports false
|
|
111
|
+
// through the navigation window instead of confirming delivery into a
|
|
112
|
+
// document being torn down. TRIPLE guard, because over-invalidating
|
|
113
|
+
// mutes the channel FOREVER (no main-frame did-finish-load follows to
|
|
114
|
+
// re-handshake):
|
|
115
|
+
// - activeWc: a stale wc's late event must not drop a successor's port
|
|
116
|
+
// (same discipline as the 'destroyed' handler below);
|
|
117
|
+
// - cross-document only: anchors/pushState/history keep the document;
|
|
118
|
+
// - main frame only: an <iframe> navigating keeps the main document.
|
|
119
|
+
// Reads the details object (electron >= 12 shape); falls back to the
|
|
120
|
+
// deprecated positional args (`isInPlace` === details.isSameDocument).
|
|
121
|
+
wc.on('did-start-navigation', (details, _url, isInPlace, isMainFramePositional) => {
|
|
122
|
+
if (activeWc !== wc)
|
|
123
|
+
return;
|
|
124
|
+
const isSameDocument = typeof details?.isSameDocument === 'boolean'
|
|
125
|
+
? details.isSameDocument
|
|
126
|
+
: isInPlace;
|
|
127
|
+
const isMainFrame = typeof details?.isMainFrame === 'boolean'
|
|
128
|
+
? details.isMainFrame
|
|
129
|
+
: isMainFramePositional;
|
|
130
|
+
if (isSameDocument || !isMainFrame)
|
|
131
|
+
return;
|
|
132
|
+
dropActivePort(true);
|
|
133
|
+
});
|
|
134
|
+
wc.on('destroyed', () => {
|
|
135
|
+
if (activeWc === wc)
|
|
136
|
+
dropActivePort(true);
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
invalidate() {
|
|
140
|
+
dropActivePort(true);
|
|
141
|
+
},
|
|
142
|
+
onMessage(channel, handler) {
|
|
143
|
+
if (typeof channel !== 'string' || channel === '') {
|
|
144
|
+
throw new TypeError('hostToolbar.onMessage: channel must be a non-empty string');
|
|
145
|
+
}
|
|
146
|
+
const entry = { channel, handler };
|
|
147
|
+
handlers.push(entry);
|
|
148
|
+
return {
|
|
149
|
+
dispose() {
|
|
150
|
+
const i = handlers.indexOf(entry);
|
|
151
|
+
if (i >= 0)
|
|
152
|
+
handlers.splice(i, 1);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
send(channel, payload) {
|
|
157
|
+
if (!activePort)
|
|
158
|
+
return false;
|
|
159
|
+
activePort.postMessage({ channel, payload });
|
|
160
|
+
return true;
|
|
161
|
+
},
|
|
162
|
+
dispose() {
|
|
163
|
+
disposed = true;
|
|
164
|
+
dropActivePort(true);
|
|
165
|
+
handlers.length = 0;
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=host-toolbar-port-channel.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ref-counted registration of the host-toolbar framework runtime on
|
|
3
|
+
* `session.defaultSession`.
|
|
4
|
+
*
|
|
5
|
+
* The toolbar's height advertiser no longer rides the toolbar WCV's
|
|
6
|
+
* `webPreferences.preload` (a host's `setPreloadPath` used to replace it and
|
|
7
|
+
* the strip height collapsed to 0). Instead the runtime bundle
|
|
8
|
+
* (`hostToolbarRuntimePreloadPath`) is registered once per process as a
|
|
9
|
+
* session frame preload; its own guard (`--dimina-host-toolbar` marker +
|
|
10
|
+
* `isMainFrame`) keeps it a zero-footprint no-op in every other defaultSession
|
|
11
|
+
* renderer.
|
|
12
|
+
*
|
|
13
|
+
* Ref-counting (codex condition 3): multiple ViewManagers can coexist in one
|
|
14
|
+
* process and share the ONE defaultSession. Each manager acquires at most one
|
|
15
|
+
* reference (on first toolbar need) and releases it in `disposeAll`. Only the
|
|
16
|
+
* first acquire registers; only the last release unregisters (with the id
|
|
17
|
+
* `registerPreloadScript` returned). After a full release a new acquire
|
|
18
|
+
* re-registers — there is deliberately no "registered once ever" latch, so
|
|
19
|
+
* dispose-everything-then-relaunch flows keep their toolbar runtime.
|
|
20
|
+
*
|
|
21
|
+
* Module-level state; tests reset it via `vi.resetModules()` + re-import.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Take a reference on the shared session registration. Registers the runtime
|
|
25
|
+
* preload on `session.defaultSession` when the count rises from zero. Call at
|
|
26
|
+
* most once per ViewManager (the manager tracks its own acquired-flag).
|
|
27
|
+
*/
|
|
28
|
+
export declare function acquireHostToolbarSessionRuntime(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Release a reference. Unregisters (with the stored registration id) only when
|
|
31
|
+
* the LAST reference is released; a still-alive ViewManager's toolbar keeps
|
|
32
|
+
* its session runtime. Safe to call only by managers that actually acquired.
|
|
33
|
+
*/
|
|
34
|
+
export declare function releaseHostToolbarSessionRuntime(): void;
|
|
35
|
+
//# sourceMappingURL=host-toolbar-session-runtime.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ref-counted registration of the host-toolbar framework runtime on
|
|
3
|
+
* `session.defaultSession`.
|
|
4
|
+
*
|
|
5
|
+
* The toolbar's height advertiser no longer rides the toolbar WCV's
|
|
6
|
+
* `webPreferences.preload` (a host's `setPreloadPath` used to replace it and
|
|
7
|
+
* the strip height collapsed to 0). Instead the runtime bundle
|
|
8
|
+
* (`hostToolbarRuntimePreloadPath`) is registered once per process as a
|
|
9
|
+
* session frame preload; its own guard (`--dimina-host-toolbar` marker +
|
|
10
|
+
* `isMainFrame`) keeps it a zero-footprint no-op in every other defaultSession
|
|
11
|
+
* renderer.
|
|
12
|
+
*
|
|
13
|
+
* Ref-counting (codex condition 3): multiple ViewManagers can coexist in one
|
|
14
|
+
* process and share the ONE defaultSession. Each manager acquires at most one
|
|
15
|
+
* reference (on first toolbar need) and releases it in `disposeAll`. Only the
|
|
16
|
+
* first acquire registers; only the last release unregisters (with the id
|
|
17
|
+
* `registerPreloadScript` returned). After a full release a new acquire
|
|
18
|
+
* re-registers — there is deliberately no "registered once ever" latch, so
|
|
19
|
+
* dispose-everything-then-relaunch flows keep their toolbar runtime.
|
|
20
|
+
*
|
|
21
|
+
* Module-level state; tests reset it via `vi.resetModules()` + re-import.
|
|
22
|
+
*/
|
|
23
|
+
import { session } from 'electron';
|
|
24
|
+
import { hostToolbarRuntimePreloadPath } from '../../utils/paths.js';
|
|
25
|
+
let refCount = 0;
|
|
26
|
+
let registrationId = null;
|
|
27
|
+
/**
|
|
28
|
+
* Take a reference on the shared session registration. Registers the runtime
|
|
29
|
+
* preload on `session.defaultSession` when the count rises from zero. Call at
|
|
30
|
+
* most once per ViewManager (the manager tracks its own acquired-flag).
|
|
31
|
+
*/
|
|
32
|
+
export function acquireHostToolbarSessionRuntime() {
|
|
33
|
+
if (refCount === 0) {
|
|
34
|
+
registrationId = session.defaultSession.registerPreloadScript({
|
|
35
|
+
type: 'frame',
|
|
36
|
+
filePath: hostToolbarRuntimePreloadPath,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
refCount++;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Release a reference. Unregisters (with the stored registration id) only when
|
|
43
|
+
* the LAST reference is released; a still-alive ViewManager's toolbar keeps
|
|
44
|
+
* its session runtime. Safe to call only by managers that actually acquired.
|
|
45
|
+
*/
|
|
46
|
+
export function releaseHostToolbarSessionRuntime() {
|
|
47
|
+
if (refCount === 0)
|
|
48
|
+
return;
|
|
49
|
+
refCount--;
|
|
50
|
+
if (refCount === 0 && registrationId !== null) {
|
|
51
|
+
session.defaultSession.unregisterPreloadScript(registrationId);
|
|
52
|
+
registrationId = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=host-toolbar-session-runtime.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { WebContents } from 'electron';
|
|
2
2
|
import type { NativeDeviceInfo } from '../../../shared/ipc-channels.js';
|
|
3
3
|
import { type WorkbenchContext } from '../workbench-context.js';
|
|
4
|
+
import { type HostToolbarMessageSubscription } from './host-toolbar-port-channel.js';
|
|
4
5
|
/**
|
|
5
6
|
* Context surface used by the ViewManager. We only need a small slice of the
|
|
6
7
|
* full WorkbenchContext here; typing it this way documents the actual dependency.
|
|
@@ -23,12 +24,11 @@ export interface ViewManagerContext {
|
|
|
23
24
|
* frame preload instead. Optional so partial test contexts compile.
|
|
24
25
|
*/
|
|
25
26
|
preloadPath?: string;
|
|
26
|
-
panels: string[];
|
|
27
27
|
notify: WorkbenchContext['notify'];
|
|
28
28
|
bridge?: WorkbenchContext['bridge'];
|
|
29
29
|
/**
|
|
30
30
|
* Native-host network forwarder. `attachNativeSimulator` hands it the freshly
|
|
31
|
-
* created simulator WebContentsView (`attachSimulator`) so it can attach the
|
|
31
|
+
* created simulator WebContentsView (`networkForward.attachSimulator`) so it can attach the
|
|
32
32
|
* CDP debugger, and the DevTools front-end host wc (`setDevtoolsHost`) so it can
|
|
33
33
|
* inject that WCV's Network.* events into the native Network tab (service-host
|
|
34
34
|
* console line is the fallback). Optional so partial test contexts compile.
|
|
@@ -43,12 +43,6 @@ export interface ViewManagerContext {
|
|
|
43
43
|
* Optional so partial test contexts compile.
|
|
44
44
|
*/
|
|
45
45
|
simulatorApis?: WorkbenchContext['simulatorApis'];
|
|
46
|
-
/**
|
|
47
|
-
* Header bar height in px, used to position overlay views below the header.
|
|
48
|
-
* Optional here so partial test contexts compile; `createWorkbenchContext`
|
|
49
|
-
* always supplies it (default 40).
|
|
50
|
-
*/
|
|
51
|
-
headerHeight?: number;
|
|
52
46
|
}
|
|
53
47
|
/**
|
|
54
48
|
* Unified lifecycle manager for Electron WebContentsView overlays.
|
|
@@ -64,23 +58,22 @@ export interface ViewManagerContext {
|
|
|
64
58
|
* window's own renderer is the content root and is not managed here.
|
|
65
59
|
*/
|
|
66
60
|
export interface ViewManager {
|
|
67
|
-
/**
|
|
68
|
-
* Create a DevTools view for the given simulator webContents and add it to
|
|
69
|
-
* the main window contentView (only when the `devtools` tab is the default
|
|
70
|
-
* tab; otherwise the view is created but not added yet).
|
|
71
|
-
*/
|
|
72
|
-
attachSimulator(simWcId: number, simWidth: number): void;
|
|
73
61
|
/**
|
|
74
62
|
* NATIVE-HOST ONLY. Create the simulator itself as a top-level
|
|
75
63
|
* WebContentsView (not a renderer `<webview>` guest) loading `simulatorUrl`,
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
64
|
+
* and treat its webContents as THE simulator webContents (so
|
|
65
|
+
* `getSimulatorWebContents` resolves it and the spawn/SIMULATOR_EVENTS
|
|
66
|
+
* pipeline flows through it). This is required because Electron
|
|
67
|
+
* force-disables the `<webview>` tag inside a webview guest, so a
|
|
68
|
+
* `<webview>`-in-`<webview>` topology can never host DeviceShell's
|
|
81
69
|
* per-page render-host `<webview>`s. A top-level WebContentsView's webContents
|
|
82
70
|
* is NOT a guest and CAN host them. Then wires the DevTools/console view on
|
|
83
|
-
* top of it via `
|
|
71
|
+
* top of it via `attachNativeSimulatorDevtoolsHost`. Neither view is added
|
|
72
|
+
* to the contentView here — both mount only when the renderer's view anchors
|
|
73
|
+
* publish a non-zero rect (`setNativeSimulatorViewBounds` /
|
|
74
|
+
* `setSimulatorDevtoolsBounds`). No-op (logs) when `preloadPath` is unset.
|
|
75
|
+
* `simWidth` rides the wire for schema compatibility but is unused: all
|
|
76
|
+
* geometry is anchor-published.
|
|
84
77
|
*/
|
|
85
78
|
attachNativeSimulator(simulatorUrl: string, simWidth: number): void;
|
|
86
79
|
/**
|
|
@@ -90,10 +83,6 @@ export interface ViewManager {
|
|
|
90
83
|
* `windows/views.ts` module, which every detach call relied on.
|
|
91
84
|
*/
|
|
92
85
|
detachSimulator(): void;
|
|
93
|
-
/** Reveal the existing DevTools view (idempotent). */
|
|
94
|
-
showSimulator(simWidth: number): void;
|
|
95
|
-
/** Remove (but do not destroy) the simulator view from the contentView. */
|
|
96
|
-
hideSimulator(): void;
|
|
97
86
|
/** Lazy-create and show the settings overlay view. */
|
|
98
87
|
showSettings(): Promise<void>;
|
|
99
88
|
/** Remove the settings overlay view (kept around for next open). */
|
|
@@ -110,12 +99,6 @@ export interface ViewManager {
|
|
|
110
99
|
getSimulatorWebContentsId(): number | null;
|
|
111
100
|
/** Return the live webContents of the currently attached simulator, or null. */
|
|
112
101
|
getSimulatorWebContents(): WebContents | null;
|
|
113
|
-
/** Return the last known simulator width. */
|
|
114
|
-
getLastSimWidth(): number;
|
|
115
|
-
/** Whether the simulator overlay is currently added to the contentView. */
|
|
116
|
-
isSimulatorAdded(): boolean;
|
|
117
|
-
/** Whether a DevTools view exists (created but maybe not added). */
|
|
118
|
-
hasSimulatorView(): boolean;
|
|
119
102
|
/** Return the settings overlay's WebContents (for renderer-notifier). */
|
|
120
103
|
getSettingsWebContents(): WebContents | null;
|
|
121
104
|
/** Return the webContents ID of the settings overlay if alive, else null. */
|
|
@@ -151,10 +134,12 @@ export interface ViewManager {
|
|
|
151
134
|
* pick it up automatically when they attach (`did-attach-webview`).
|
|
152
135
|
*/
|
|
153
136
|
reapplySafeArea(device: NativeDeviceInfo | null): void;
|
|
154
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Window-resize entry point. Re-applies the settings overlay's bounds only.
|
|
139
|
+
* Simulator + DevTools overlay geometry is anchor-published (the renderer's
|
|
140
|
+
* ResizeObserver re-measures on the same resize), so no static re-apply here.
|
|
141
|
+
*/
|
|
155
142
|
resize(simWidth: number): void;
|
|
156
|
-
/** Show or hide the simulator overlay based on visibility flag. */
|
|
157
|
-
setVisible(visible: boolean, simWidth: number): void;
|
|
158
143
|
/**
|
|
159
144
|
* Apply a renderer-measured rectangle to the simulator's Chromium
|
|
160
145
|
* DevTools overlay view. `{ width: 0, height: 0 }` is treated as "hide" —
|
|
@@ -185,7 +170,9 @@ export interface ViewManager {
|
|
|
185
170
|
* Reverse size-advertiser sink: the toolbar WCV's own renderer advertises
|
|
186
171
|
* its intrinsic content height (block-axis extent); we store it and push it
|
|
187
172
|
* to the main-window renderer so the placeholder div resizes (closing the
|
|
188
|
-
* dynamic-height loop).
|
|
173
|
+
* dynamic-height loop). Ignored while a `{ fixed }` height mode is pinned
|
|
174
|
+
* via `hostToolbar.setHeightMode` (the session-resident advertiser always
|
|
175
|
+
* runs, so its reports must not fight a host-pinned height).
|
|
189
176
|
*/
|
|
190
177
|
setHostToolbarHeight(extent: number): void;
|
|
191
178
|
/**
|
|
@@ -195,6 +182,14 @@ export interface ViewManager {
|
|
|
195
182
|
*/
|
|
196
183
|
readonly hostToolbar: HostToolbarControl;
|
|
197
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Height mode for the host-toolbar placeholder strip. `'auto'` (default): the
|
|
187
|
+
* session-resident advertiser's reports drive the height. `{ fixed }`: the
|
|
188
|
+
* host pins the height; advertiser reports are ignored until `'auto'` again.
|
|
189
|
+
*/
|
|
190
|
+
export type HostToolbarHeightMode = 'auto' | {
|
|
191
|
+
fixed: number;
|
|
192
|
+
};
|
|
198
193
|
/**
|
|
199
194
|
* The control object the downstream host uses to own the toolbar
|
|
200
195
|
* WebContentsView. Lazily backed by the view-manager's `hostToolbarView`.
|
|
@@ -209,13 +204,47 @@ export interface HostToolbarControl {
|
|
|
209
204
|
/** Remove the toolbar view from the contentView and reset it (kept alive). */
|
|
210
205
|
hide(): void;
|
|
211
206
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* `
|
|
215
|
-
* `
|
|
216
|
-
*
|
|
207
|
+
* The HOST's own `webPreferences.preload` for the toolbar view (purely
|
|
208
|
+
* additive). The framework's height-advertiser runtime does NOT ride
|
|
209
|
+
* `webPreferences.preload` — it is session-resident (registered on
|
|
210
|
+
* `session.defaultSession`, self-guarded by the `--dimina-host-toolbar`
|
|
211
|
+
* marker + `isMainFrame`), so a host preload set here coexists with it and
|
|
212
|
+
* never replaces it. Must be set before the view is (re)created (first
|
|
213
|
+
* `loadURL`/`loadFile`, or the next one after the host closed the
|
|
214
|
+
* webContents); `null` (default) means "no host preload" — it does not and
|
|
215
|
+
* cannot restore any built-in preload.
|
|
217
216
|
*/
|
|
218
217
|
setPreloadPath(path: string | null): void;
|
|
218
|
+
/**
|
|
219
|
+
* Register a host-side handler for messages the toolbar PAGE sends via
|
|
220
|
+
* `window.diminaHostToolbar.send(channel, payload)`. Control-level: may be
|
|
221
|
+
* called before the view exists and survives page reloads / wc rebuilds
|
|
222
|
+
* (each per-load MessagePort handshake re-attaches the registry to the new
|
|
223
|
+
* port). Throws on an empty / non-string channel. `dispose()` detaches
|
|
224
|
+
* (idempotent).
|
|
225
|
+
*/
|
|
226
|
+
onMessage(channel: string, handler: (payload: unknown) => void): HostToolbarMessageSubscription;
|
|
227
|
+
/**
|
|
228
|
+
* Post `{ channel, payload }` to the toolbar page (received via
|
|
229
|
+
* `window.diminaHostToolbar.onMessage(channel, handler)`). Gated and
|
|
230
|
+
* non-queueing: returns false — delivering nothing, creating no view —
|
|
231
|
+
* while there is no live toolbar webContents, the current load's
|
|
232
|
+
* MessagePort handshake hasn't completed, or a document-replacing
|
|
233
|
+
* navigation is in flight (`loadURL`/`loadFile` was issued, or the page
|
|
234
|
+
* itself started a main-frame cross-document navigation, and the new
|
|
235
|
+
* document hasn't handshaked yet); true once the envelope went out.
|
|
236
|
+
* No manual `getHostToolbarWebContentsId` gating needed: the false/true
|
|
237
|
+
* result IS the readiness signal.
|
|
238
|
+
*/
|
|
239
|
+
send(channel: string, payload: unknown): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Pin or unpin the toolbar strip height. `{ fixed }` notifies the renderer
|
|
242
|
+
* placeholder with that height immediately (so a preload-less/static toolbar
|
|
243
|
+
* is visible without any advertiser report) and ignores subsequent advertiser
|
|
244
|
+
* reports. `'auto'` (default) re-enables advertiser-driven height starting
|
|
245
|
+
* from the NEXT report — it does not synthesize/replay a stale height.
|
|
246
|
+
*/
|
|
247
|
+
setHeightMode(mode: HostToolbarHeightMode): void;
|
|
219
248
|
}
|
|
220
249
|
/**
|
|
221
250
|
* Build a ViewManager bound to the given context. The returned object is the
|