@reticlehq/electron 2.7.0 → 2.8.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/main.cjs +16 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -6,6 +6,10 @@ Everything else Reticle does inside an Electron app is the ordinary browser SDK
6
6
 
7
7
  Both are **dev-only**. Gate each `require` behind your own dev check so neither ships.
8
8
 
9
+ ```bash
10
+ npm i -D @reticlehq/electron
11
+ ```
12
+
9
13
  ## IPC observation — one line at the top of your preload
10
14
 
11
15
  ```js
package/main.cjs CHANGED
@@ -26,6 +26,7 @@ const {
26
26
  RETICLE_CAPTURE_CHANNEL,
27
27
  RETICLE_CAPTURE_FILE_PREFIX,
28
28
  RETICLE_FULL_PAGE_UNSUPPORTED,
29
+ RETICLE_NOT_COMPOSITED,
29
30
  } = require('@reticlehq/core/desktop-contract');
30
31
 
31
32
  let captureSeq = 0;
@@ -128,12 +129,17 @@ function installReticleCapture(win) {
128
129
  // Saying so beats handing back a viewport the caller thinks covers the whole scroll height.
129
130
  if (options && options.fullPage === true) throw new Error(RETICLE_FULL_PAGE_UNSUPPORTED);
130
131
  const contents = usableContents(event.sender);
131
- if (contents === null) return null;
132
+ // Named, not null. Every no-image answer used to be the same bare null, so a dead window, an
133
+ // uncomposited one and a thrown error were one silence — the tool reported `saved:false` with
134
+ // no bytes and no reason, which is unreadable in CI and useless to a user.
135
+ if (contents === null) throw new Error('no usable webContents to capture');
132
136
  try {
133
137
  const image = await contents.capturePage();
134
- // An empty image means the window had nothing to compose yet; report it as no-image rather
135
- // than handing back a 0-byte PNG that a diff would treat as a real, blank baseline.
136
- if (image.isEmpty()) return null;
138
+ // An empty image means the window had nothing to compose yet, which is a fact about TIMING
139
+ // rather than a failure of the capture path — under a headless compositor a window that has
140
+ // not painted returns empty rather than erroring. Still never a 0-byte PNG, which a diff
141
+ // would trust as a real blank baseline; it is now reported by name instead.
142
+ if (image.isEmpty()) throw new Error(RETICLE_NOT_COMPOSITED);
137
143
  // Write to a temp FILE and return its path, rather than base64 over the bridge. The SDK's
138
144
  // transport sanitizer caps every string at 64KB, so a real screenshot came back silently
139
145
  // truncated — an invalid PNG that still reported `saved: true`. The daemon and the app are
@@ -154,8 +160,12 @@ function installReticleCapture(win) {
154
160
  await writeFile(file, image.toPNG(), { flag: 'wx' });
155
161
  await sweepOldCaptures(dir, file);
156
162
  return file;
157
- } catch {
158
- return null;
163
+ } catch (error) {
164
+ // Rethrow rather than swallow. The renderer maps the reasons it recognises onto the closed
165
+ // VisualReason vocabulary and passes anything else through as its own message, so a real
166
+ // failure (EACCES on the capture file, a window closing mid-write) now reaches the caller
167
+ // saying what it was. Swallowing it here is what made all of these indistinguishable.
168
+ throw error instanceof Error ? error : new Error(String(error));
159
169
  }
160
170
  });
161
171
  registered = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/electron",
3
- "version": "2.7.0",
3
+ "version": "2.8.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
  "type": "module",
6
6
  "exports": {
@@ -8,7 +8,7 @@
8
8
  "./main": "./main.cjs"
9
9
  },
10
10
  "dependencies": {
11
- "@reticlehq/core": "2.7.0"
11
+ "@reticlehq/core": "2.8.0"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "electron": ">=22"