webview-preview 1.1.0 → 1.1.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # webview-preview
2
2
 
3
- [![test](https://github.com/n0t4u404/webview-preview/actions/workflows/test.yml/badge.svg)](https://github.com/n0t4u404/webview-preview/actions/workflows/test.yml)
3
+ [![CI](https://github.com/n0t4u404/webview-preview/actions/workflows/ci.yml/badge.svg)](https://github.com/n0t4u404/webview-preview/actions/workflows/ci.yml)
4
4
 
5
5
  See your UI the way your desktop app really renders it. `webview-preview` opens a page in the **same engine your app
6
6
  runs on** — WebKitGTK on Linux, Edge (the WebView2 engine) on Windows, WebKit on macOS — runs a list of steps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webview-preview",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Open your UI in the engine your desktop app really runs on (WebKitGTK, Edge/WebView2, WebKit), drive it with steps and save PNG snapshots.",
5
5
  "license": "MIT",
6
6
  "author": "n0t4u404",
@@ -340,9 +340,21 @@ def main():
340
340
  wait_for(step, GLib.get_monotonic_time())
341
341
  elif kind == "resize":
342
342
  width, height = (int(part) for part in value.split("x"))
343
- window.set_size_request(width, height)
343
+ window.set_size_request(-1, -1)
344
+ window.set_default_size(width, height)
344
345
  window.resize(width, height)
345
- GLib.timeout_add(INPUT_SETTLE_MS, run_step)
346
+ started = GLib.get_monotonic_time()
347
+
348
+ def check_size():
349
+ def on_value(text):
350
+ if text == f"{width}x{height}" or (GLib.get_monotonic_time() - started) / 1000 >= KEY_WAIT_MS:
351
+ GLib.timeout_add(INPUT_SETTLE_MS, run_step)
352
+ else:
353
+ GLib.timeout_add(KEY_POLL_MS, lambda: (check_size(), False)[1])
354
+
355
+ evaluate("innerWidth + 'x' + innerHeight", on_value, lambda _: GLib.timeout_add(INPUT_SETTLE_MS, run_step))
356
+
357
+ check_size()
346
358
  elif kind == "print":
347
359
  evaluate(
348
360
  value,
package/src/index.d.ts CHANGED
@@ -10,6 +10,9 @@ export type Step =
10
10
  | "focusorder"
11
11
  | `focusorder:${number}`
12
12
  | `film:${string}:${number}`
13
+ | `film:${string}:${number}/${number}`
14
+ | `film:${string}:${number}@${string}`
15
+ | `film:${string}:${number}/${number}@${string}`
13
16
  | "offline"
14
17
  | "online"
15
18
  | `latency:${number}`
@@ -1,4 +1,4 @@
1
- import { copyFileSync, existsSync, mkdirSync } from "node:fs";
1
+ import { copyFileSync, existsSync, mkdirSync, rmSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { readPng, writePng } from "#src/snapshots/png.mjs";
4
4
 
@@ -41,6 +41,8 @@ export const compareSnapshots = ({ saved, baselineDir, updateBaseline, tolerance
41
41
  for (const file of saved) {
42
42
  const name = path.basename(file);
43
43
  const baseline = path.join(baselineDir, name);
44
+ const diffFile = file.replace(/\.png$/, ".diff.png");
45
+ rmSync(diffFile, { force: true });
44
46
  if (updateBaseline || !existsSync(baseline)) {
45
47
  copyFileSync(file, baseline);
46
48
  log.info(`compare ${name}: ${updateBaseline ? "baseline updated" : "new baseline"} → ${baseline}`);
@@ -61,7 +63,6 @@ export const compareSnapshots = ({ saved, baselineDir, updateBaseline, tolerance
61
63
  continue;
62
64
  }
63
65
 
64
- const diffFile = file.replace(/\.png$/, ".diff.png");
65
66
  writePng(diffFile, result.diff);
66
67
  const share = ((result.differentPixels / result.total) * 100).toFixed(2);
67
68
  const message = `compare ${name}: ${result.differentPixels} px differ (${share}%) → ${diffFile}`;