@livx.cc/native-kit 0.45.20 → 0.45.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/native-kit",
3
- "version": "0.45.20",
3
+ "version": "0.45.22",
4
4
  "description": "Isomorphic native-capabilities kit for PWAs — same API in browser and in an appwrap native shell. Zero dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "Elya Livshitz",
@@ -68,6 +68,18 @@ export class WebViewModule {
68
68
  return this.kit.invoke('webview.cookies', { cookies });
69
69
  }
70
70
 
71
+ /** What the overlay shows now as a JPEG about `width` px wide (default 360). Take it while it is shown (before hide/close). */
72
+ snapshot(opts: { width?: number; quality?: number } = {}): Promise<{ jpeg: string; width: number; height: number }> {
73
+ return this.kit.invoke('webview.snapshot', { ...opts });
74
+ }
75
+
76
+ /** Run `js` — an async function body (may `await`; its `return` is the result) — in the overlay's page; resolves the
77
+ * returned value (JSON round-tripped). `world`: a named isolated JS world (iOS; ignored on Android). The app's own
78
+ * origin only: a foreign page in the app WebView can't call it. */
79
+ async eval<T = unknown>(js: string, opts: { world?: string } = {}): Promise<T> {
80
+ return (await this.kit.invoke<{ result: T }>('webview.eval', { js, ...opts }, { timeoutMs: 35_000 })).result; // (native gives up at 30s)
81
+ }
82
+
71
83
  /** Tear the overlay down (fires {@link onClosed}). */
72
84
  close(): Promise<void> {
73
85
  return this.kit.invoke('webview.close', {});