@reticlehq/electron 3.4.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/main.cjs +15 -1
- package/main.d.cts +5 -1
- package/package.json +2 -2
- package/preload.cjs +12 -0
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ installReticleCapture(win);
|
|
|
39
39
|
|
|
40
40
|
`reticle_screenshot` and `reticle_visual_diff` now work. It uses `webContents.capturePage()`, which reads the window's own backing store — correct while the window is behind your editor, correct while backgrounded, and needing no screen-recording permission. Capturing a screen region was deliberately not used: it photographs whatever is on top, which would bank a picture of your editor as a visual baseline.
|
|
41
41
|
|
|
42
|
-
Safe to call for several windows; the handler registers once and answers for whichever window asked.
|
|
42
|
+
Safe to call for several windows; the handler registers once and answers for whichever window asked. Give each a name with `installReticleCapture(win, { label: 'settings' })` and the session list shows `window: "settings"`, the way a Tauri window's label appears. Without one, windows are told apart by url and title.
|
|
43
43
|
|
|
44
44
|
`{ fullPage: true }` is **refused**, not silently downgraded — `capturePage()` composites the viewport, and handing back a viewport image for a full-page request would bank a baseline that says nothing about the content below the fold.
|
|
45
45
|
|
package/main.cjs
CHANGED
|
@@ -24,6 +24,7 @@ const { join } = require('node:path');
|
|
|
24
24
|
// daemon agree by construction rather than by three people copying the same string.
|
|
25
25
|
const {
|
|
26
26
|
RETICLE_CAPTURE_CHANNEL,
|
|
27
|
+
RETICLE_WINDOW_CHANNEL,
|
|
27
28
|
RETICLE_CAPTURE_FILE_PREFIX,
|
|
28
29
|
RETICLE_FULL_PAGE_UNSUPPORTED,
|
|
29
30
|
RETICLE_NOT_COMPOSITED,
|
|
@@ -34,6 +35,11 @@ let captureSeq = 0;
|
|
|
34
35
|
let registered = false;
|
|
35
36
|
/** Windows this app registered, so a capture survives its requester being destroyed. */
|
|
36
37
|
const windows = new Set();
|
|
38
|
+
/**
|
|
39
|
+
* The name each window was registered under, keyed by its webContents (what an IPC `sender` is).
|
|
40
|
+
* Electron windows have no name of their own, and two of one app often share a url.
|
|
41
|
+
*/
|
|
42
|
+
const labels = new WeakMap();
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* The webContents to photograph: the requester if it is alive, else the ONE remaining window.
|
|
@@ -115,9 +121,15 @@ async function sweepOldCaptures(dir, keepFile) {
|
|
|
115
121
|
/**
|
|
116
122
|
* Let Reticle screenshot this window. Safe to call for several windows; the handler is registered
|
|
117
123
|
* once and answers for whichever window asked, so a multi-window app needs no extra wiring.
|
|
124
|
+
*
|
|
125
|
+
* `{ label }` names the window in `reticle_session { action: "list" }` (`window: "settings"`), the
|
|
126
|
+
* way a Tauri window's label does. Without it the window is listed by url and title alone.
|
|
118
127
|
*/
|
|
119
|
-
function installReticleCapture(win) {
|
|
128
|
+
function installReticleCapture(win, options) {
|
|
120
129
|
if (win === null || win === undefined) return;
|
|
130
|
+
const label = options && typeof options.label === 'string' ? options.label : undefined;
|
|
131
|
+
if (label !== undefined && label.length > 0 && win.webContents)
|
|
132
|
+
labels.set(win.webContents, label);
|
|
121
133
|
// Remembered so a capture can still resolve if the requesting webContents has gone (a window
|
|
122
134
|
// closing mid-command), rather than returning null and reporting an unexplained capture failure.
|
|
123
135
|
windows.add(win);
|
|
@@ -167,6 +179,8 @@ function installReticleCapture(win) {
|
|
|
167
179
|
throw error instanceof Error ? error : new Error(String(error));
|
|
168
180
|
}
|
|
169
181
|
});
|
|
182
|
+
// Null, never a guess, for a window the app did not name.
|
|
183
|
+
ipcMain.handle(RETICLE_WINDOW_CHANNEL, (event) => labels.get(event.sender) ?? null);
|
|
170
184
|
registered = true;
|
|
171
185
|
}
|
|
172
186
|
}
|
package/main.d.cts
CHANGED
|
@@ -30,4 +30,8 @@ export type ReticleCapturableWindow = object;
|
|
|
30
30
|
* rather than throwing — a renderer that never opened is not an error worth crashing a main process
|
|
31
31
|
* over.
|
|
32
32
|
*/
|
|
33
|
-
export function installReticleCapture(
|
|
33
|
+
export function installReticleCapture(
|
|
34
|
+
win: ReticleCapturableWindow | null | undefined,
|
|
35
|
+
/** `label` names the window in Reticle's session list, as a Tauri window label does. */
|
|
36
|
+
options?: { label?: string },
|
|
37
|
+
): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reticlehq/electron",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Reticle adapter for Electron: makes main-process IPC observable and the window screenshottable, from the two places the renderer cannot reach.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.0.0"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@reticlehq/core": "3.
|
|
21
|
+
"@reticlehq/core": "3.6.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"electron": ">=22"
|
package/preload.cjs
CHANGED
|
@@ -26,6 +26,7 @@ const { contextBridge, ipcRenderer } = require('electron');
|
|
|
26
26
|
const {
|
|
27
27
|
RETICLE_IPC_GLOBAL,
|
|
28
28
|
RETICLE_CAPTURE_CHANNEL,
|
|
29
|
+
RETICLE_WINDOW_CHANNEL,
|
|
29
30
|
RETICLE_FULL_PAGE_UNSUPPORTED,
|
|
30
31
|
} = require('@reticlehq/core/desktop-contract');
|
|
31
32
|
|
|
@@ -252,6 +253,17 @@ contextBridge.exposeInMainWorld(RETICLE_IPC_GLOBAL, {
|
|
|
252
253
|
* Uses the ORIGINAL invoke: this is Reticle's own plumbing, and recording it as an app IPC call
|
|
253
254
|
* would put `ipc://__reticle:capture` in the agent's own network evidence.
|
|
254
255
|
*/
|
|
256
|
+
/**
|
|
257
|
+
* The label the app registered this window under (`installReticleCapture(win, { label })`), or
|
|
258
|
+
* undefined. Original invoke for the same reason as `capture`; an older main helper has no handler,
|
|
259
|
+
* and that is "unnamed", not an error.
|
|
260
|
+
*/
|
|
261
|
+
windowLabel() {
|
|
262
|
+
return originalInvoke(RETICLE_WINDOW_CHANNEL).then(
|
|
263
|
+
(label) => (typeof label === 'string' && label.length > 0 ? label : undefined),
|
|
264
|
+
() => undefined,
|
|
265
|
+
);
|
|
266
|
+
},
|
|
255
267
|
capture(fullPage) {
|
|
256
268
|
return originalInvoke(RETICLE_CAPTURE_CHANNEL, { fullPage: fullPage === true }).catch(
|
|
257
269
|
(error) => {
|