@dimina-kit/devtools 0.4.0-dev.20260824071518 → 0.4.0-dev.20260828161241
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/dist/main/api.d.ts +1 -1
- package/dist/main/app/app.js +59 -2
- package/dist/main/index.bundle.js +986 -245
- package/dist/main/ipc/index.d.ts +2 -0
- package/dist/main/ipc/index.js +2 -0
- package/dist/main/ipc/popover.js +1 -1
- package/dist/main/ipc/project-create.d.ts +15 -0
- package/dist/main/ipc/project-create.js +26 -0
- package/dist/main/ipc/projects.d.ts +1 -1
- package/dist/main/ipc/projects.js +36 -1
- package/dist/main/ipc/settings.js +2 -1
- package/dist/main/ipc/simulator-module.d.ts +4 -3
- package/dist/main/ipc/simulator-module.js +4 -5
- package/dist/main/ipc/tooltip.js +1 -1
- package/dist/main/ipc/views.d.ts +15 -1
- package/dist/main/ipc/views.js +61 -4
- package/dist/main/runtime/miniapp-runtime.d.ts +87 -19
- package/dist/main/services/notifications/renderer-notifier.d.ts +30 -1
- package/dist/main/services/notifications/renderer-notifier.js +23 -1
- package/dist/main/services/projects/create-project-service.js +9 -2
- package/dist/main/services/projects/local-provider.js +6 -0
- package/dist/main/services/projects/project-repository.d.ts +29 -1
- package/dist/main/services/projects/project-repository.js +151 -17
- package/dist/main/services/projects/types.d.ts +13 -2
- package/dist/main/services/update/update-manager.d.ts +17 -3
- package/dist/main/services/update/update-manager.js +25 -6
- 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 +107 -0
- package/dist/main/services/views/host-slot-port-channel.js +261 -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 -224
- package/dist/main/services/views/managed-web-contents-view.d.ts +48 -0
- package/dist/main/services/views/managed-web-contents-view.js +123 -0
- package/dist/main/services/views/overlay-panels-view.d.ts +23 -0
- package/dist/main/services/views/overlay-panels-view.js +93 -4
- package/dist/main/services/views/placement-reconciler.d.ts +14 -2
- package/dist/main/services/views/placement-reconciler.js +27 -0
- package/dist/main/services/views/placement-test-driver.d.ts +1 -0
- package/dist/main/services/views/placement-test-driver.js +3 -0
- package/dist/main/services/views/view-manager-devtools-host-test-fixtures.js +3 -1
- package/dist/main/services/views/view-manager.d.ts +10 -78
- package/dist/main/services/views/view-manager.js +34 -3
- package/dist/main/services/workbench-context.d.ts +18 -4
- package/dist/main/services/workbench-context.js +1 -0
- package/dist/main/services/workspace/workspace-service.d.ts +2 -0
- package/dist/main/services/workspace/workspace-service.js +14 -0
- package/dist/main/utils/paths.d.ts +4 -0
- package/dist/main/utils/paths.js +4 -0
- package/dist/main/utils/sender-policy.js +10 -0
- package/dist/native-host/common/common.js +65 -62
- package/dist/native-host/render/render.js +2230 -2052
- package/dist/native-host/service/service.js +2 -2
- 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/wait-for-slot-root.d.ts +20 -0
- package/dist/preload/runtime/wait-for-slot-root.js +52 -0
- package/dist/preload/windows/host-dialog-runtime.cjs +353 -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 +354 -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 +134 -51
- package/dist/preload/windows/host-toolbar-runtime.cjs.map +3 -3
- package/dist/preload/windows/simulator.cjs.map +1 -1
- package/dist/renderer/assets/button-D5Q2wkXq.js +2 -0
- package/dist/renderer/assets/constants-D7DfVqMp.js +2 -0
- package/dist/renderer/assets/constants-D8zsejFq.js +2 -0
- package/dist/renderer/assets/createLucideIcon-Bqi8hpdi.js +2 -0
- package/dist/renderer/assets/dialog-e1TecTOY.js +46 -0
- package/dist/renderer/assets/dist-DKWdE1TK.js +2 -0
- package/dist/renderer/assets/hostSidebarDefault-B3yLfy8j.js +2 -0
- package/dist/renderer/assets/index-CsPD68N_.js +5 -0
- package/dist/renderer/assets/input-Ct3alvkq.js +2 -0
- package/dist/renderer/assets/ipc-channels-overlays-LsDzGAtV.js +2 -0
- package/dist/renderer/assets/jsx-runtime-2vXHouwr.css +1 -0
- package/dist/renderer/assets/jsx-runtime-DGLHmmOq.js +9 -0
- package/dist/renderer/assets/popover-Dix5cm_b.js +2 -0
- package/dist/renderer/assets/project-api-k7Oq9iaq.js +2 -0
- package/dist/renderer/assets/projectCreateDialog-Bbjz75bP.js +2 -0
- package/dist/renderer/assets/select-acGb0AmJ.js +2 -0
- package/dist/renderer/assets/settings-CQrTMr43.js +2 -0
- package/dist/renderer/assets/settings-api-CrUQ9rYV.js +2 -0
- package/dist/renderer/assets/settings-tab-bar-Cw1kVIf2.js +2 -0
- package/dist/renderer/assets/tooltip-B_-_YVbw.js +2 -0
- package/dist/renderer/assets/types-CsEKtFyr.js +2 -0
- package/dist/renderer/assets/updateDialog-NsF8223A.js +2 -0
- package/dist/renderer/assets/utils-kfQov6Pa.js +2 -0
- package/dist/renderer/assets/view-api-CLn3rcQE.js +2 -0
- package/dist/renderer/assets/{workbenchSettings-oq_EyfKf.js → workbenchSettings-CV4LVA9b.js} +3 -3
- package/dist/renderer/entries/host-sidebar-default/index.html +21 -0
- package/dist/renderer/entries/main/index.html +17 -8
- package/dist/renderer/entries/popover/index.html +10 -7
- package/dist/renderer/entries/project-create-dialog/index.html +27 -0
- package/dist/renderer/entries/settings/index.html +10 -7
- package/dist/renderer/entries/tooltip/index.html +5 -4
- package/dist/renderer/entries/update-dialog/index.html +25 -0
- package/dist/renderer/entries/workbench-settings/index.html +11 -7
- package/dist/service-host/preload.cjs +10 -0
- package/dist/shared/constants.d.ts +22 -0
- package/dist/shared/constants.js +22 -0
- package/dist/shared/ipc-channels-overlays.d.ts +156 -0
- package/dist/shared/ipc-channels-overlays.js +186 -0
- package/dist/shared/ipc-channels.d.ts +4 -77
- package/dist/shared/ipc-channels.js +4 -98
- package/dist/shared/ipc-schemas.d.ts +44 -0
- package/dist/shared/ipc-schemas.js +55 -0
- package/dist/shared/types.d.ts +71 -0
- package/dist/shared/view-ids.d.ts +7 -0
- package/dist/shared/view-ids.js +10 -0
- package/package.json +8 -8
- package/dist/renderer/assets/constants-Bdz0LHdy.js +0 -2
- package/dist/renderer/assets/index-CtznrmHR.js +0 -49
- package/dist/renderer/assets/input-Dmm6nob5.js +0 -2
- package/dist/renderer/assets/ipc-transport-BOg0gR9W.js +0 -9
- package/dist/renderer/assets/ipc-transport-DgQhZaE9.css +0 -1
- package/dist/renderer/assets/popover-Cd1FEGOX.js +0 -2
- package/dist/renderer/assets/select-BaYox7If.js +0 -2
- package/dist/renderer/assets/settings-BXvwuFaz.js +0 -2
- package/dist/renderer/assets/settings-api-Bo9GbYqs.js +0 -2
- package/dist/renderer/assets/settings-tab-bar-Beia6lMr.js +0 -2
- package/dist/renderer/assets/tooltip-DfQqK3Sk.js +0 -2
- package/dist/renderer/assets/view-api-nn69je7A.js +0 -2
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { HOST_DIALOG_RUNTIME_MARKER } from '../../../shared/constants.js';
|
|
2
|
+
import { VIEW_ID, VIEW_LAYER } from '../../../shared/view-ids.js';
|
|
3
|
+
import { acquireHostDialogSessionRuntime, releaseHostDialogSessionRuntime, } from './host-dialog-session-runtime.js';
|
|
4
|
+
import { createHostDialogPortChannel } from './host-dialog-port-channel.js';
|
|
5
|
+
import { createManagedWebContentsView } from './managed-web-contents-view.js';
|
|
6
|
+
// Shown immediately on `show()` for whichever axis hasn't been measured yet.
|
|
7
|
+
// The dialog is a by-demand overlay — there is no renderer placeholder to
|
|
8
|
+
// pre-report intrinsic size the way the toolbar/sidebar's forward anchor
|
|
9
|
+
// does, so the first show of a not-yet-measured axis has nothing to center
|
|
10
|
+
// against. Waiting/polling for the report would mask the async race (banned
|
|
11
|
+
// by this repo's timing rules); a conservative default plus a re-center the
|
|
12
|
+
// moment `reportMeasuredExtent` lands is the fail-safe alternative.
|
|
13
|
+
const DEFAULT_WIDTH = 480;
|
|
14
|
+
const DEFAULT_HEIGHT = 320;
|
|
15
|
+
/**
|
|
16
|
+
* Host-dialog factory — its PLACEMENT is deliberately NOT built on
|
|
17
|
+
* `createHostSlotView`. That factory models a persistent, single-axis,
|
|
18
|
+
* renderer-anchored strip (`setBaseDesired`); the dialog is a by-demand,
|
|
19
|
+
* dual-axis, main-centered overlay (`setOverlayDesired` /
|
|
20
|
+
* `deleteOverlayDesired`), closer in shape to the settings/popover/tooltip
|
|
21
|
+
* overlays in `overlay-panels-view.ts` than to the toolbar/sidebar. It still
|
|
22
|
+
* doesn't reuse `createOverlayPanel` from that file: those panels load a
|
|
23
|
+
* FIXED renderer-dir entry and push typed data, whereas the dialog loads
|
|
24
|
+
* ARBITRARY host content and needs the toolbar/sidebar's `loadURL`/`loadFile`
|
|
25
|
+
* + gated port-channel surface. The underlying WebContentsView lazy-create /
|
|
26
|
+
* liveness / load / teardown lifecycle IS shared with the base slots though
|
|
27
|
+
* — see `managed-web-contents-view.ts`.
|
|
28
|
+
*/
|
|
29
|
+
export function createHostDialogView(ctx, reconciler) {
|
|
30
|
+
const port = createHostDialogPortChannel({
|
|
31
|
+
isCurrent: (wc) => managed.liveWebContents()?.id === wc.id,
|
|
32
|
+
});
|
|
33
|
+
let visible = false;
|
|
34
|
+
let width = DEFAULT_WIDTH;
|
|
35
|
+
let height = DEFAULT_HEIGHT;
|
|
36
|
+
const managed = createManagedWebContentsView({
|
|
37
|
+
reconciler,
|
|
38
|
+
viewId: VIEW_ID.hostDialog,
|
|
39
|
+
marker: HOST_DIALOG_RUNTIME_MARKER,
|
|
40
|
+
sessionRuntime: {
|
|
41
|
+
acquire: acquireHostDialogSessionRuntime,
|
|
42
|
+
release: releaseHostDialogSessionRuntime,
|
|
43
|
+
},
|
|
44
|
+
port,
|
|
45
|
+
onBroken: () => {
|
|
46
|
+
// Same "withdraw the stale desired placement" contract as hide(): a
|
|
47
|
+
// crashed dialog must not resurrect as a blank, content-less modal the
|
|
48
|
+
// next time something calls reposition() (e.g. a window resize).
|
|
49
|
+
visible = false;
|
|
50
|
+
reconciler.deleteOverlayDesired(VIEW_ID.hostDialog);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
function computeBounds() {
|
|
54
|
+
const [winW = 0, winH = 0] = ctx.windows.mainWindow.getContentSize();
|
|
55
|
+
// Clamp to the window so a dialog whose advertised/default size exceeds
|
|
56
|
+
// the current content area still gets valid non-negative bounds instead
|
|
57
|
+
// of spilling off-window or going negative.
|
|
58
|
+
const w = Math.min(width, Math.max(1, winW));
|
|
59
|
+
const h = Math.min(height, Math.max(1, winH));
|
|
60
|
+
return {
|
|
61
|
+
x: Math.max(0, Math.round((winW - w) / 2)),
|
|
62
|
+
y: Math.max(0, Math.round((winH - h) / 2)),
|
|
63
|
+
width: w,
|
|
64
|
+
height: h,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function present() {
|
|
68
|
+
reconciler.setOverlayDesired(VIEW_ID.hostDialog, {
|
|
69
|
+
viewId: VIEW_ID.hostDialog,
|
|
70
|
+
placement: { visible: true, bounds: computeBounds() },
|
|
71
|
+
layer: VIEW_LAYER.hostDialog,
|
|
72
|
+
});
|
|
73
|
+
reconciler.reconcileNow();
|
|
74
|
+
}
|
|
75
|
+
function reportMeasuredExtent(axis, extent) {
|
|
76
|
+
if (!Number.isFinite(extent) || extent <= 0)
|
|
77
|
+
return;
|
|
78
|
+
if (axis === 'inline') {
|
|
79
|
+
width = extent;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
height = extent;
|
|
83
|
+
}
|
|
84
|
+
if (visible)
|
|
85
|
+
present();
|
|
86
|
+
}
|
|
87
|
+
// The host swaps content into the SAME dialog view via loadURL/loadFile
|
|
88
|
+
// (e.g. re-purposing one dialog for a different prompt) — width/height are
|
|
89
|
+
// this factory's own closure state, seeded once from the DEFAULT_*
|
|
90
|
+
// constants and only ever mutated by reportMeasuredExtent, so without a
|
|
91
|
+
// reset here a fresh, unmeasured document would inherit the PREVIOUS
|
|
92
|
+
// document's size until it happens to report its own. And while the
|
|
93
|
+
// dialog is currently VISIBLE, resetting the closure state alone doesn't
|
|
94
|
+
// reach the screen — the on-screen bounds only change via `present()` —
|
|
95
|
+
// so without the same `if (visible) present()` `reportMeasuredExtent`
|
|
96
|
+
// already does, the OLD document's bounds would stay displayed
|
|
97
|
+
// indefinitely (forever, if the new document never reports at all, e.g. a
|
|
98
|
+
// fixture missing `[data-host-dialog-root]`) instead of falling back to
|
|
99
|
+
// the default the moment the swap happens.
|
|
100
|
+
function resetMeasuredExtent() {
|
|
101
|
+
width = DEFAULT_WIDTH;
|
|
102
|
+
height = DEFAULT_HEIGHT;
|
|
103
|
+
if (visible)
|
|
104
|
+
present();
|
|
105
|
+
}
|
|
106
|
+
const control = {
|
|
107
|
+
loadURL: (url) => {
|
|
108
|
+
resetMeasuredExtent();
|
|
109
|
+
return managed.loadURL(url);
|
|
110
|
+
},
|
|
111
|
+
loadFile: (filePath) => {
|
|
112
|
+
resetMeasuredExtent();
|
|
113
|
+
return managed.loadFile(filePath);
|
|
114
|
+
},
|
|
115
|
+
get webContents() {
|
|
116
|
+
return managed.liveWebContents();
|
|
117
|
+
},
|
|
118
|
+
setPreloadPath: (path) => managed.setPreloadPath(path),
|
|
119
|
+
onMessage: (channel, handler) => port.onMessage(channel, handler),
|
|
120
|
+
onReady: (handler) => port.onReady(handler),
|
|
121
|
+
send: (channel, payload) => port.send(channel, payload),
|
|
122
|
+
show() {
|
|
123
|
+
managed.ensureView();
|
|
124
|
+
visible = true;
|
|
125
|
+
present();
|
|
126
|
+
},
|
|
127
|
+
hide() {
|
|
128
|
+
visible = false;
|
|
129
|
+
reconciler.deleteOverlayDesired(VIEW_ID.hostDialog);
|
|
130
|
+
reconciler.reconcileNow();
|
|
131
|
+
},
|
|
132
|
+
isVisible: () => visible,
|
|
133
|
+
};
|
|
134
|
+
reconciler.registerView(VIEW_ID.hostDialog, {
|
|
135
|
+
getView: () => managed.getView(),
|
|
136
|
+
ensureView: () => managed.ensureView(),
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
control,
|
|
140
|
+
reportMeasuredExtent,
|
|
141
|
+
getHostDialogWebContentsId: () => managed.liveWebContents()?.id ?? null,
|
|
142
|
+
reposition: () => { if (visible)
|
|
143
|
+
present(); },
|
|
144
|
+
dispose: () => managed.dispose(),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=host-dialog-view.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar-specific instantiation of `createHostSlotPortChannel` (see that
|
|
3
|
+
* module for the full per-load handshake / navigation-invalidation
|
|
4
|
+
* contract).
|
|
5
|
+
*/
|
|
6
|
+
import type { WebContents } from 'electron';
|
|
7
|
+
import { type HostSlotMessageSubscription, type HostSlotPortChannel } from './host-slot-port-channel.js';
|
|
8
|
+
export type HostSidebarMessageSubscription = HostSlotMessageSubscription;
|
|
9
|
+
export type HostSidebarPortChannel = HostSlotPortChannel;
|
|
10
|
+
export declare function createHostSidebarPortChannel(opts: {
|
|
11
|
+
/**
|
|
12
|
+
* Is `wc` still the manager's CURRENT live sidebar webContents? Guards a
|
|
13
|
+
* stale wc's late `did-finish-load` from hijacking the channel after a
|
|
14
|
+
* rebuild swapped the view out underneath it.
|
|
15
|
+
*/
|
|
16
|
+
isCurrent: (wc: WebContents) => boolean;
|
|
17
|
+
}): HostSidebarPortChannel;
|
|
18
|
+
//# sourceMappingURL=host-sidebar-port-channel.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar-specific instantiation of `createHostSlotPortChannel` (see that
|
|
3
|
+
* module for the full per-load handshake / navigation-invalidation
|
|
4
|
+
* contract).
|
|
5
|
+
*/
|
|
6
|
+
import { ViewChannel } from '../../../shared/ipc-channels-overlays.js';
|
|
7
|
+
import { createHostSlotPortChannel, } from './host-slot-port-channel.js';
|
|
8
|
+
export function createHostSidebarPortChannel(opts) {
|
|
9
|
+
return createHostSlotPortChannel({
|
|
10
|
+
isCurrent: opts.isCurrent,
|
|
11
|
+
channel: ViewChannel.HostSidebarPort,
|
|
12
|
+
logPrefix: '[host-sidebar]',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=host-sidebar-port-channel.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar-specific instantiation of `createHostSlotSessionRuntime` (see that
|
|
3
|
+
* module for the full ref-counting contract). Kept as a thin, independently
|
|
4
|
+
* named wrapper — same rationale as `host-toolbar-session-runtime.ts` — so
|
|
5
|
+
* a sidebar-focused test can `vi.resetModules()` this module's state without
|
|
6
|
+
* touching the toolbar's independent ref-count.
|
|
7
|
+
*/
|
|
8
|
+
export declare function acquireHostSidebarSessionRuntime(): void;
|
|
9
|
+
export declare function releaseHostSidebarSessionRuntime(): void;
|
|
10
|
+
//# sourceMappingURL=host-sidebar-session-runtime.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar-specific instantiation of `createHostSlotSessionRuntime` (see that
|
|
3
|
+
* module for the full ref-counting contract). Kept as a thin, independently
|
|
4
|
+
* named wrapper — same rationale as `host-toolbar-session-runtime.ts` — so
|
|
5
|
+
* a sidebar-focused test can `vi.resetModules()` this module's state without
|
|
6
|
+
* touching the toolbar's independent ref-count.
|
|
7
|
+
*/
|
|
8
|
+
import { createHostSlotSessionRuntime } from './host-slot-session-runtime.js';
|
|
9
|
+
import { hostSidebarRuntimePreloadPath } from '../../utils/paths.js';
|
|
10
|
+
const runtime = createHostSlotSessionRuntime(hostSidebarRuntimePreloadPath);
|
|
11
|
+
export function acquireHostSidebarSessionRuntime() {
|
|
12
|
+
runtime.acquire();
|
|
13
|
+
}
|
|
14
|
+
export function releaseHostSidebarSessionRuntime() {
|
|
15
|
+
runtime.release();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=host-sidebar-session-runtime.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { HostSlotControl } from './host-slot-view.js';
|
|
2
|
+
import type { PlacementReconciler } from './placement-reconciler.js';
|
|
3
|
+
import type { ViewManagerContext } from './view-manager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Width mode for the host-sidebar placeholder strip, mirroring
|
|
6
|
+
* `HostToolbarHeightMode` on the inline axis.
|
|
7
|
+
*/
|
|
8
|
+
export type HostSidebarWidthMode = 'auto' | {
|
|
9
|
+
fixed: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The control object the downstream host uses to own the sidebar
|
|
13
|
+
* WebContentsView. Derives the shared members from `HostSlotControl` — see
|
|
14
|
+
* that interface for their contract, which carries over unchanged on the
|
|
15
|
+
* inline axis — and adds only `setWidthMode` in place of the base's
|
|
16
|
+
* `setExtentMode`, mirroring `HostToolbarControl.setHeightMode`.
|
|
17
|
+
*/
|
|
18
|
+
export interface HostSidebarControl extends Omit<HostSlotControl, 'setExtentMode'> {
|
|
19
|
+
/**
|
|
20
|
+
* Pin or unpin the sidebar strip width. Same contract as
|
|
21
|
+
* `HostToolbarControl.setHeightMode` on the inline axis.
|
|
22
|
+
*/
|
|
23
|
+
setWidthMode(mode: HostSidebarWidthMode): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The host-sidebar slice of `ViewManager`'s public surface, split into its
|
|
27
|
+
* own file (mixed in via `extends`) to keep view-manager.ts under the repo's
|
|
28
|
+
* file-length ratchet. Mirrors `hostToolbar`'s members on the inline axis;
|
|
29
|
+
* never coexists with a height-cycle dependency on settings/popover/tooltip.
|
|
30
|
+
*/
|
|
31
|
+
export interface HostSidebarViewManagerMembers {
|
|
32
|
+
/** Return the webContents ID of the host-sidebar overlay if alive, else null. */
|
|
33
|
+
getHostSidebarWebContentsId(): number | null;
|
|
34
|
+
/** Return the last host-sidebar width NOTIFIED to the main-window renderer. */
|
|
35
|
+
getHostSidebarWidth(): number;
|
|
36
|
+
/** Reverse size-advertiser sink for the sidebar strip's inline (width) axis. */
|
|
37
|
+
setHostSidebarWidth(extent: number): void;
|
|
38
|
+
/** Host-facing control surface for the sidebar WebContentsView. */
|
|
39
|
+
readonly hostSidebar: HostSidebarControl;
|
|
40
|
+
}
|
|
41
|
+
export interface HostSidebarView {
|
|
42
|
+
readonly control: HostSidebarControl;
|
|
43
|
+
setHostSidebarWidth(extent: number): void;
|
|
44
|
+
getHostSidebarWidth(): number;
|
|
45
|
+
getHostSidebarWebContentsId(): number | null;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sidebar-specific instantiation of `createHostSlotView` (see that module for
|
|
50
|
+
* the full lazy-create / port-channel / extent-mode contract). Symmetric to
|
|
51
|
+
* `createHostToolbarView` on the inline (width) axis instead of block
|
|
52
|
+
* (height) — the slot itself is axis-agnostic (a single advertised extent
|
|
53
|
+
* number); which CSS dimension it resizes is decided entirely by the host's
|
|
54
|
+
* renderer placeholder layout, not here. The sidebar never coexists with the
|
|
55
|
+
* settings/popover/tooltip overlays, so unlike the toolbar there is no
|
|
56
|
+
* `reapplyPresentOverlays` dependency to thread through.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createHostSidebarView(ctx: ViewManagerContext, reconciler: PlacementReconciler): HostSidebarView;
|
|
59
|
+
//# sourceMappingURL=host-sidebar-view.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HOST_SIDEBAR_RUNTIME_MARKER } from '../../../shared/constants.js';
|
|
2
|
+
import { VIEW_ID, VIEW_LAYER } from '../../../shared/view-ids.js';
|
|
3
|
+
import { acquireHostSidebarSessionRuntime, releaseHostSidebarSessionRuntime, } from './host-sidebar-session-runtime.js';
|
|
4
|
+
import { createHostSidebarPortChannel } from './host-sidebar-port-channel.js';
|
|
5
|
+
import { createHostSlotView, deriveSlotControl } from './host-slot-view.js';
|
|
6
|
+
/**
|
|
7
|
+
* Sidebar-specific instantiation of `createHostSlotView` (see that module for
|
|
8
|
+
* the full lazy-create / port-channel / extent-mode contract). Symmetric to
|
|
9
|
+
* `createHostToolbarView` on the inline (width) axis instead of block
|
|
10
|
+
* (height) — the slot itself is axis-agnostic (a single advertised extent
|
|
11
|
+
* number); which CSS dimension it resizes is decided entirely by the host's
|
|
12
|
+
* renderer placeholder layout, not here. The sidebar never coexists with the
|
|
13
|
+
* settings/popover/tooltip overlays, so unlike the toolbar there is no
|
|
14
|
+
* `reapplyPresentOverlays` dependency to thread through.
|
|
15
|
+
*/
|
|
16
|
+
export function createHostSidebarView(ctx, reconciler) {
|
|
17
|
+
const port = createHostSidebarPortChannel({
|
|
18
|
+
isCurrent: (wc) => slot.getWebContentsId() === wc.id,
|
|
19
|
+
});
|
|
20
|
+
const slot = createHostSlotView(reconciler, {
|
|
21
|
+
viewId: VIEW_ID.hostSidebar,
|
|
22
|
+
layer: VIEW_LAYER.hostSidebar,
|
|
23
|
+
marker: HOST_SIDEBAR_RUNTIME_MARKER,
|
|
24
|
+
sessionRuntime: {
|
|
25
|
+
acquire: acquireHostSidebarSessionRuntime,
|
|
26
|
+
release: releaseHostSidebarSessionRuntime,
|
|
27
|
+
},
|
|
28
|
+
portChannel: port,
|
|
29
|
+
setExtentModeErrorLabel: 'hostSidebar.setWidthMode',
|
|
30
|
+
}, {
|
|
31
|
+
onExtentChanged: (width) => ctx.notify.hostSidebarWidthChanged(width),
|
|
32
|
+
});
|
|
33
|
+
const control = deriveSlotControl(slot.control, {
|
|
34
|
+
setWidthMode: (mode) => slot.control.setExtentMode(mode),
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
control,
|
|
38
|
+
setHostSidebarWidth: (extent) => slot.setExtent(extent),
|
|
39
|
+
getHostSidebarWidth: () => slot.getExtent(),
|
|
40
|
+
getHostSidebarWebContentsId: () => slot.getWebContentsId(),
|
|
41
|
+
dispose: () => slot.dispose(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=host-sidebar-view.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gated narrow channel between the main process and a downstream host-slot
|
|
3
|
+
* WebContentsView's page (host-toolbar / host-sidebar / host-dialog), over a
|
|
4
|
+
* per-load transferred MessagePort.
|
|
5
|
+
*
|
|
6
|
+
* Why a MessagePort and not plain IPC: a slot's page is HOST-ARBITRARY
|
|
7
|
+
* content. A dedicated port pair gives it exactly one pipe whose main-side end
|
|
8
|
+
* lives in this module — the page never gains a generic `ipcRenderer` reach
|
|
9
|
+
* into the internal devtools channels, and main-side inbound traffic is
|
|
10
|
+
* validated at this single waist.
|
|
11
|
+
*
|
|
12
|
+
* Lifecycle (per-load handshake):
|
|
13
|
+
* - On every slot-wc `did-finish-load` main builds a fresh
|
|
14
|
+
* `MessageChannelMain`, transfers port2 to the new document via
|
|
15
|
+
* `wc.postMessage(opts.channel, null, [port2])`, keeps port1 and
|
|
16
|
+
* `start()`s it. The previous port1 (if any) is closed first — its
|
|
17
|
+
* document is gone.
|
|
18
|
+
* - `onMessage` registrations are CONTROL-level (this module's registry), not
|
|
19
|
+
* per-port: they may be made before any view exists and survive page
|
|
20
|
+
* reloads / wc rebuilds, because each new handshake dispatches into the
|
|
21
|
+
* same registry.
|
|
22
|
+
* - `send` is gated and non-queueing: `false` means "not delivered, ever" —
|
|
23
|
+
* no view is conjured, nothing is buffered for a later handshake.
|
|
24
|
+
* - A port1 `'close'` event (the renderer end died without a re-handshake
|
|
25
|
+
* yet) drops the live-port reference so `send` reports `false` instead of
|
|
26
|
+
* posting into a dead pipe.
|
|
27
|
+
* - NAVIGATION INVALIDATES THE PORT. The port pair belongs to one DOCUMENT,
|
|
28
|
+
* so starting a navigation that replaces that document closes port1 and
|
|
29
|
+
* `send` returns `false` until the new document's `did-finish-load`
|
|
30
|
+
* handshake. Two paths:
|
|
31
|
+
* (a) host-initiated `loadURL/loadFile` calls `invalidate()`
|
|
32
|
+
* synchronously AT INITIATION (the slot view does this before the
|
|
33
|
+
* `webContents.loadURL/loadFile` await), so a same-tick `send` can
|
|
34
|
+
* never report `true` for an envelope posted into the document the
|
|
35
|
+
* load is about to replace;
|
|
36
|
+
* (b) page-initiated navigation (location.href / reload) is caught by a
|
|
37
|
+
* `did-start-navigation` listener — guarded to the ACTIVE wc,
|
|
38
|
+
* main-frame, cross-document only. Same-document navigations
|
|
39
|
+
* (anchors, pushState, history) and subframe navigations do NOT
|
|
40
|
+
* invalidate: the document the port lives in survives those, and no
|
|
41
|
+
* main-frame `did-finish-load` would follow to ever restore the
|
|
42
|
+
* channel.
|
|
43
|
+
*
|
|
44
|
+
* Envelope both directions: `{ channel: string, payload: unknown }`. Inbound
|
|
45
|
+
* data that is not an object with a string `channel` is DROPPED without
|
|
46
|
+
* throwing (the counterpart is arbitrary host content).
|
|
47
|
+
*/
|
|
48
|
+
import type { WebContents } from 'electron';
|
|
49
|
+
/** Handle returned by `onMessage`; `dispose()` detaches (idempotent). */
|
|
50
|
+
export interface HostSlotMessageSubscription {
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
export interface HostSlotPortChannel {
|
|
54
|
+
/**
|
|
55
|
+
* Hook a freshly created slot webContents: registers the `did-finish-load`
|
|
56
|
+
* (per-load handshake) and `destroyed` (drop the live port) listeners via
|
|
57
|
+
* `wc.on(...)`. Call exactly once per wc, right after the view is created.
|
|
58
|
+
*/
|
|
59
|
+
attach(wc: WebContents): void;
|
|
60
|
+
/**
|
|
61
|
+
* Drop the live port NOW (close + clear): the document it belongs to is
|
|
62
|
+
* being replaced. Called synchronously when the HOST initiates a
|
|
63
|
+
* `loadURL`/`loadFile` — the host-initiated half of the
|
|
64
|
+
* navigation-invalidates contract (the page-initiated half is the
|
|
65
|
+
* `did-start-navigation` listener `attach` installs). `send` returns false
|
|
66
|
+
* from this call until the next `did-finish-load` handshake. Idempotent.
|
|
67
|
+
*/
|
|
68
|
+
invalidate(): void;
|
|
69
|
+
/** Register a control-level inbound handler for `channel`. */
|
|
70
|
+
onMessage(channel: string, handler: (payload: unknown) => void): HostSlotMessageSubscription;
|
|
71
|
+
/**
|
|
72
|
+
* Observe handshake readiness. Fires `handler` once per load GENERATION,
|
|
73
|
+
* at the moment that generation's handshake completes (`send` flips true).
|
|
74
|
+
* Registering while already `ready` schedules a one-shot catch-up fire on a
|
|
75
|
+
* microtask — never synchronously — and the catch-up RE-CHECKS at fire time
|
|
76
|
+
* that (a) the subscription is still registered and (b) the generation is
|
|
77
|
+
* unchanged / the port is still live, so a same-frame `dispose()` or
|
|
78
|
+
* host-initiated load suppresses it. Inert (never fires) after `dispose()`.
|
|
79
|
+
*/
|
|
80
|
+
onReady(handler: () => void): HostSlotMessageSubscription;
|
|
81
|
+
/**
|
|
82
|
+
* Post `{ channel, payload }` to the slot page over the live port. Returns
|
|
83
|
+
* false (delivering NOTHING, creating NOTHING) when there is no live slot
|
|
84
|
+
* wc, the current load's handshake hasn't completed, or a
|
|
85
|
+
* document-replacing navigation is in flight (see `invalidate`).
|
|
86
|
+
*/
|
|
87
|
+
send(channel: string, payload: unknown): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Teardown (manager `disposeAll`): close the live port, sweep the handler
|
|
90
|
+
* registry, refuse further handshakes. Subsequent `send` returns false;
|
|
91
|
+
* late `dispose()` of an old subscription stays a no-op.
|
|
92
|
+
*/
|
|
93
|
+
dispose(): void;
|
|
94
|
+
}
|
|
95
|
+
export declare function createHostSlotPortChannel(opts: {
|
|
96
|
+
/**
|
|
97
|
+
* Is `wc` still the manager's CURRENT live slot webContents? Guards a
|
|
98
|
+
* stale wc's late `did-finish-load` from hijacking the channel after a
|
|
99
|
+
* rebuild swapped the view out underneath it.
|
|
100
|
+
*/
|
|
101
|
+
isCurrent: (wc: WebContents) => boolean;
|
|
102
|
+
/** The IPC channel name used for the per-load port-transfer postMessage. */
|
|
103
|
+
channel: string;
|
|
104
|
+
/** Log-line prefix identifying which slot this instance belongs to. */
|
|
105
|
+
logPrefix: string;
|
|
106
|
+
}): HostSlotPortChannel;
|
|
107
|
+
//# sourceMappingURL=host-slot-port-channel.d.ts.map
|