react-native-minimal-webview 1.0.0 → 1.0.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.
Files changed (84) hide show
  1. package/README.md +38 -18
  2. package/android/build.gradle +1 -1
  3. package/android/consumer-rules.pro +1 -1
  4. package/android/src/main/java/expo/modules/minimalwebview/DocumentEnd.kt +3 -3
  5. package/android/src/main/java/expo/modules/minimalwebview/Hooks.kt +33 -42
  6. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebView.kt +7 -10
  7. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewClients.kt +5 -6
  8. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewModule.kt +4 -4
  9. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewScripts.kt +14 -8
  10. package/android/src/main/java/expo/modules/minimalwebview/PlatformSettings.kt +13 -16
  11. package/android/src/main/java/expo/modules/minimalwebview/PullToRefresh.kt +1 -1
  12. package/android/src/main/java/expo/modules/minimalwebview/requests/Downloads.kt +6 -5
  13. package/android/src/main/java/expo/modules/minimalwebview/requests/FileUpload.kt +1 -1
  14. package/android/src/main/java/expo/modules/minimalwebview/requests/FullscreenVideo.kt +1 -1
  15. package/android/src/main/java/expo/modules/minimalwebview/requests/Permissions.kt +3 -3
  16. package/build/WebView.d.ts +6 -9
  17. package/build/WebView.d.ts.map +1 -1
  18. package/build/WebView.js +23 -18
  19. package/build/WebView.js.map +1 -1
  20. package/build/bridge/createBridge.d.ts +3 -3
  21. package/build/bridge/createBridge.d.ts.map +1 -1
  22. package/build/bridge/createBridge.js +5 -3
  23. package/build/bridge/createBridge.js.map +1 -1
  24. package/build/bridge/endpoint.d.ts +0 -2
  25. package/build/bridge/endpoint.d.ts.map +1 -1
  26. package/build/bridge/endpoint.js +8 -3
  27. package/build/bridge/endpoint.js.map +1 -1
  28. package/build/bridge/origins.d.ts.map +1 -1
  29. package/build/bridge/origins.js +0 -1
  30. package/build/bridge/origins.js.map +1 -1
  31. package/build/bridge/pageClient.generated.d.ts +1 -1
  32. package/build/bridge/pageClient.generated.d.ts.map +1 -1
  33. package/build/bridge/pageClient.generated.js +1 -1
  34. package/build/bridge/pageClient.generated.js.map +1 -1
  35. package/build/defaultNavigationRules.d.ts +4 -5
  36. package/build/defaultNavigationRules.d.ts.map +1 -1
  37. package/build/defaultNavigationRules.js +4 -5
  38. package/build/defaultNavigationRules.js.map +1 -1
  39. package/build/index.d.ts +1 -1
  40. package/build/index.js +1 -1
  41. package/build/platform.generated.d.ts +14 -15
  42. package/build/platform.generated.d.ts.map +1 -1
  43. package/build/platform.generated.js +5 -3
  44. package/build/platform.generated.js.map +1 -1
  45. package/build/reactNativeWebViewDefaults.d.ts +2 -2
  46. package/build/reactNativeWebViewDefaults.js +2 -2
  47. package/build/reactNativeWebViewMessages.d.ts +8 -14
  48. package/build/reactNativeWebViewMessages.d.ts.map +1 -1
  49. package/build/reactNativeWebViewMessages.js +8 -14
  50. package/build/reactNativeWebViewMessages.js.map +1 -1
  51. package/build/refStore.d.ts +11 -10
  52. package/build/refStore.d.ts.map +1 -1
  53. package/build/refStore.js +7 -5
  54. package/build/refStore.js.map +1 -1
  55. package/build/types.d.ts +328 -282
  56. package/build/types.d.ts.map +1 -1
  57. package/ios/DelegateProxy.swift +2 -6
  58. package/ios/DocumentEnd.swift +7 -8
  59. package/ios/DownloadName.swift +1 -3
  60. package/ios/Hooks.swift +23 -21
  61. package/ios/MRWExceptions.h +1 -1
  62. package/ios/MRWInvoke.h +25 -10
  63. package/ios/MinimalWebView+Dialogs.swift +4 -7
  64. package/ios/MinimalWebView+Navigation.swift +25 -26
  65. package/ios/MinimalWebView+Scripts.swift +3 -3
  66. package/ios/MinimalWebView.swift +12 -11
  67. package/ios/NavigationRules.swift +1 -1
  68. package/ios/OriginRules.swift +3 -2
  69. package/ios/PlatformSettings.swift +14 -9
  70. package/ios/Recovery.swift +3 -3
  71. package/package.json +9 -4
  72. package/src/WebView.tsx +22 -19
  73. package/src/bridge/createBridge.ts +5 -3
  74. package/src/bridge/endpoint.ts +7 -3
  75. package/src/bridge/origins.ts +0 -1
  76. package/src/bridge/pageClient.generated.ts +1 -1
  77. package/src/bridge/pageClient.ts +1 -2
  78. package/src/defaultNavigationRules.ts +4 -5
  79. package/src/index.ts +1 -1
  80. package/src/platform.generated.ts +14 -15
  81. package/src/reactNativeWebViewDefaults.ts +2 -2
  82. package/src/reactNativeWebViewMessages.ts +8 -14
  83. package/src/refStore.ts +12 -11
  84. package/src/types.ts +328 -282
package/build/types.d.ts CHANGED
@@ -4,28 +4,31 @@ import type { BridgeConnection, CONNECTION } from './bridge/createBridge';
4
4
  import type { AndroidSettingKeys, CGPoint, CGRect, CGSize, IOSSettingKeys, UIEdgeInsets } from './platform.generated';
5
5
  /**
6
6
  * What the WebView loads: a URL, or an HTML string.
7
+ * @see [Local files example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#local-files)
7
8
  * @group WebView
8
9
  */
9
10
  export type WebViewSource = {
10
11
  /**
11
12
  * The URL to load.
12
13
  *
13
- * A `file://` URL reads only within `readAccessRoot` on iOS; Android needs `android.settings.allowFileAccess`,
14
- * which lets a `file:` page read any file the app can.
14
+ * A `file://` URL:
15
+ *
16
+ * - iOS: reads only within `readAccessRoot`.
17
+ * - Android: needs `android.settings.allowFileAccess`, which lets a `file:` page read any file the app can.
15
18
  */
16
19
  uri: string;
17
- /** Sent with the first request only, not on later navigations. */
20
+ /**
21
+ * Sent when the core loads the `source`: its first load, and a reload (`reload()` or pull-to-refresh) or crash
22
+ * recovery that loads the `source` again. The page's later navigations don't send them.
23
+ */
18
24
  headers?: Record<string, string>;
19
25
  /**
20
26
  * Makes the request a POST with this form-urlencoded body.
21
27
  *
22
- * Its `Content-Type` is `application/x-www-form-urlencoded` unless iOS `headers` set one; Android sends no
23
- * `headers`.
28
+ * Its `Content-Type` is `application/x-www-form-urlencoded` unless iOS `headers` set one; Android ignores
29
+ * `headers` for a POST.
30
+ *
24
31
  * `reload()` sends the POST again; {@link ProcessGoneEvent.recovered | crash recovery} doesn't.
25
- * @example
26
- * ```ts
27
- * const source: WebViewSource = { uri: 'https://example.com/form', body: 'a=1&b=2' };
28
- * ```
29
32
  */
30
33
  body?: string;
31
34
  /**
@@ -35,7 +38,6 @@ export type WebViewSource = {
35
38
  */
36
39
  readAccessRoot?: string;
37
40
  } | {
38
- /** The page's HTML. */
39
41
  html: string;
40
42
  /** The page's URL: its relative URLs resolve against it, and it has this origin. Without it, `about:blank`. */
41
43
  baseUrl?: string;
@@ -54,15 +56,7 @@ export type NavigationAction = 'allow' | 'block' | 'external';
54
56
  *
55
57
  * Every field it sets must match; for a list, one matching entry is enough. A field left out matches anything; a flag
56
58
  * set to `false` matches only the requests without it.
57
- * @example
58
- * ```ts
59
- * const navigationRules: NavigationRule[] = [
60
- * { query: ['gad_source', 'utm_term=google'], action: 'block' }, // gad_source with any value, utm_term only =google
61
- * { scheme: ['tel', 'mailto'], action: 'external' },
62
- * { host: ['*.example.com'], path: ['/checkout'], action: 'external' }, // shop.example.com/checkouts too
63
- * { host: ['example.com', '*.example.com'], action: 'allow' }, // *.example.com alone skips example.com
64
- * ];
65
- * ```
59
+ * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
66
60
  * @group Navigation
67
61
  */
68
62
  export type NavigationRule = {
@@ -71,11 +65,12 @@ export type NavigationRule = {
71
65
  /**
72
66
  * Hosts: exact, or a `*.` suffix wildcard that matches subdomains only, not the domain itself.
73
67
  *
74
- * Case, port, userinfo and a trailing dot are ignored.
68
+ * Case, port, userinfo and a trailing dot are ignored. An internationalized domain matches only in its ASCII form:
69
+ * `xn--mnchen-3ya.de`, not `münchen.de`.
75
70
  */
76
71
  host?: string[];
77
72
  /**
78
- * Path prefixes: plain prefixes of the percent-encoded URL path, not whole segments.
73
+ * Prefixes of the percent-encoded URL path, not whole segments.
79
74
  *
80
75
  * A URL without an authority (`myapp:/open`) has the path `/`.
81
76
  */
@@ -97,12 +92,12 @@ export type NavigationRule = {
97
92
  * An allowed one loads in place: there is never a second WebView, so no `window.opener` (a native hook that takes
98
93
  * `createWebViewWith` on iOS or `onCreateWindow` on Android owns real popups).
99
94
  *
100
- * One to `data:`, `blob:`, `javascript:`, `about:` or `file:` is always blocked (on Android, WebView may still run a
101
- * `javascript:` one's script, with the page's origin), and one opened with no URL (`window.open('')`) is decided by
102
- * the URL the page sends it to within 5 s, and dropped otherwise.
103
- *
104
- * One opened without a user gesture reaches the rules only with `javaScriptCanOpenWindowsAutomatically` on
105
- * (`ios.preferences`, `android.settings`; off by default); otherwise WebKit or WebView drops it unreported.
95
+ * - Always blocked: one to `data:`, `blob:`, `javascript:`, `file:` or an `about:` URL other than `about:blank` (on
96
+ * Android, WebView may still run a `javascript:` one's script, with the page's origin).
97
+ * - Opened with no URL (`window.open('')`) or to `about:blank`: decided by the URL the page sends it to within 5 s,
98
+ * and dropped otherwise.
99
+ * - Opened without a user gesture: reaches the rules only with `javaScriptCanOpenWindowsAutomatically` on
100
+ * (`ios.preferences`, `android.settings`; off by default); otherwise WebKit or WebView drops it unreported.
106
101
  */
107
102
  newWindow?: boolean;
108
103
  /**
@@ -112,11 +107,13 @@ export type NavigationRule = {
112
107
  * a tap that doesn't scroll, a click or a key press gives the page for up to 5 s. Any navigation the page starts in
113
108
  * that time is true: a `location.href` change or `window.open` from a click handler, a timer's, a link a script
114
109
  * clicks.
115
- * - iOS: only a link activation (`<a>`, `<area>`, `target=_blank` too) within 1 s after a tap on the WebView that
116
- * scrolls and zooms nothing. WebKit reports a link a script clicks as it does a tapped one, so the core times the
117
- * tap itself. A `location.href` change or `window.open` is false, from a click handler too, as is a link activated
118
- * from a hardware keyboard; a tapped link's redirect is true only within that second. VoiceOver and Switch Control
119
- * activate a link without a touch: while either runs, every link activation is true, a script's too.
110
+ * - iOS: true only for a link activation (`<a>`, `<area>`, `target=_blank` too) within 1 s after a tap on the WebView
111
+ * that scrolls and zooms nothing. A link a script clicks within that second is true too.
112
+ * - False: a `location.href` change or `window.open`, from a click handler too, a link activated from a
113
+ * hardware keyboard, and a form submission, a tapped one and its redirect included.
114
+ * - A tapped link's redirect is true only within that second.
115
+ * - VoiceOver and Switch Control activate a link without a touch: while either runs, every link activation is
116
+ * true, a script's too.
120
117
  *
121
118
  * A redirect of a load the core starts itself (an allowed new window, and on Android an allowed `ask`) is never
122
119
  * user-initiated.
@@ -160,7 +157,7 @@ export type NavigationEvent = NavigationRequest & {
160
157
  rule: number | null;
161
158
  };
162
159
  /**
163
- * A WebView's navigation state, as native reports it: from `useWebViewState` and `onNavigationStateChange`.
160
+ * A WebView's navigation state, as the core reports it: from `useWebViewState` and `onNavigationStateChange`.
164
161
  *
165
162
  * While no WebView is mounted it is the initial state: `url` and `title` empty, `pendingUrl` and `outcome` null,
166
163
  * `loading`, `canGoBack` and `canGoForward` false, `progress` 0.
@@ -177,10 +174,16 @@ export type NavigationState = {
177
174
  /**
178
175
  * A main-frame load in progress, which may still fail or be blocked.
179
176
  *
180
- * Iframes never change it. Always null on Android with a WebView older than 146.
177
+ * Iframes never change it. Always null on Android with an Android System WebView older than 146.
181
178
  */
182
179
  pendingUrl: string | null;
183
180
  title: string;
181
+ /**
182
+ * A main-frame load is in progress.
183
+ *
184
+ * On Android with an Android System WebView older than 146, it goes true only when the load commits (its response
185
+ * arrives), and a load that never commits doesn't change it.
186
+ */
184
187
  loading: boolean;
185
188
  /** From 0 to 1. */
186
189
  progress: number;
@@ -189,13 +192,14 @@ export type NavigationState = {
189
192
  /**
190
193
  * How the last main-frame load ended; null while one is loading, and before the first.
191
194
  *
195
+ * - `finished`: the page arrived, an HTTP error status (404) included: the site's page shows, and `onError` gets an
196
+ * `http` error.
192
197
  * - `failed`: a network or SSL error, or a renderer crash, cut it off.
193
198
  * - `cancelled`: it never showed a page (a stop before the response, a download, a 204, a redirect the rules blocked,
194
199
  * a load a newer one replaced); a stop after the page arrived is `cancelled` on iOS but `finished` on Android, and
195
200
  * a 204 is `finished` on iOS 17.
196
201
  *
197
- * An HTTP error status (404) is `finished`: the site's page shows, and `onError` gets an `http` error. On Android
198
- * with a WebView older than 146, a load that never commits changes nothing here.
202
+ * On Android with an Android System WebView older than 146, a load that never commits changes nothing here.
199
203
  */
200
204
  outcome: 'finished' | 'failed' | 'cancelled' | null;
201
205
  };
@@ -229,28 +233,34 @@ export type ProcessGoneEvent = {
229
233
  */
230
234
  cause: 'crash' | 'memory' | 'unknown';
231
235
  /**
232
- * Whether the core reloads the page: on iOS in place; on Android in a new WebView, once the view's window is visible,
233
- * with the history restored unless the `source` page was on screen, and with the props applied but not what `call`
234
- * set.
236
+ * Whether the core reloads the page after the crash.
235
237
  *
236
- * False while a POST `source` is on screen, which, as in a browser, isn't sent again unasked (`reload()` sends it),
237
- * and after more than 3 crashes in 60 s, counted for the whole app on Android, until the next
238
- * {@link WebViewRef.reload | reload()} (on iOS also a `source` change); pull-to-refresh doesn't lift it.
238
+ * - iOS: in place.
239
+ * - Android: in a new WebView, once the view's window is visible. The history is restored unless the `source` page
240
+ * was on screen. The props are applied again, but not what `call` set.
241
+ *
242
+ * It is false when:
243
+ *
244
+ * - a POST `source` is on screen: as in a browser, it isn't sent again unasked;
245
+ * - more than 3 crashes happened in 60 s (counted for the whole app on Android), until the next
246
+ * {@link WebViewRef.reload | reload()} (on iOS also a `source` change).
247
+ *
248
+ * While false the view is blank. Leave `reload()` to the user, as a retry button: called from `onProcessGone` it
249
+ * sends the POST again, or starts the crash loop over.
250
+ * @see [Loading and error screens example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#loading-and-error-screens)
239
251
  */
240
252
  recovered: boolean;
241
253
  };
242
254
  /**
243
255
  * Runs at document start, before any page script and before the DOM is parsed.
244
- * @example
245
- * ```ts
246
- * const script: InjectedScript = {
247
- * code: "addEventListener('DOMContentLoaded', () => document.body.classList.add('in-app'));",
248
- * origins: ['https://example.com'],
249
- * };
250
- * ```
256
+ * @see [Scripts example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#scripts)
251
257
  * @group Scripts
252
258
  */
253
259
  export type InjectedScript = {
260
+ /**
261
+ * JavaScript source, run as statements; {@link InjectedScript.origins | origins} decides how its top-level names
262
+ * are scoped.
263
+ */
254
264
  code: string;
255
265
  /**
256
266
  * Runs it in every frame, iframes included.
@@ -258,10 +268,11 @@ export type InjectedScript = {
258
268
  */
259
269
  allFrames?: boolean;
260
270
  /**
261
- * The origins whose frames run it, in the syntax of {@link BridgeOptions.allowedOrigins}. Each frame is matched by
262
- * its own `location.origin`, so a listed page's iframes from other origins don't run it; about:blank and srcdoc
263
- * frames have their parent's origin. `'*'` matches every origin, opaque ones (`data:`, sandboxed frames) and
264
- * `file:` included; `[]` matches none.
271
+ * The origins whose frames run it, in the syntax of {@link BridgeOptions.allowedOrigins}.
272
+ *
273
+ * - Each frame is matched by its own `location.origin`, so a listed page's iframes from other origins don't run it.
274
+ * about:blank and srcdoc frames have their parent's origin.
275
+ * - `'*'` matches every origin, opaque ones (`data:`, sandboxed frames) and `file:` included. `[]` matches none.
265
276
  *
266
277
  * Without `'*'` in the list, the code runs inside a function: its top-level `let`, `const`, `class`, `function` and
267
278
  * `var` stay local to it, so put what the page should see on `window`. An invalid rule throws when the WebView
@@ -290,20 +301,20 @@ export type BridgeHandler<Params = unknown, Result = unknown> = (params: Params,
290
301
  * What crosses a bridge, for `createBridge<Schema>`: the methods each side handles, which the other side calls, and the
291
302
  * events.
292
303
  *
293
- * With a schema, `handle` takes only the `reactNative` methods and `call` only the `page` ones, `emit` and `on` only its
294
- * events (another name doesn't compile), and `params` or a payload is required where its type doesn't allow
295
- * `undefined`. A method's `params` and `result` are left out when it has none. Every key is required: `{}` for a side
296
- * that handles nothing. The method and event maps are `type`s or written inline, not `interfaces` (an interface has no
297
- * index signature, so it doesn't satisfy `Record`).
298
- * @example
299
- * ```ts
300
- * type ShopBridge = {
301
- * reactNative: { share: { params: { url: string }; result: boolean } };
302
- * page: { getCartCount: { result: number } };
303
- * events: { themeChanged: 'light' | 'dark' };
304
- * };
305
- * const bridge = createBridge<ShopBridge>({ allowedOrigins: ['https://example.com'] });
306
- * ```
304
+ * With a schema:
305
+ *
306
+ * - `handle` takes only the `reactNative` methods and `call` only the `page` ones. `emit` and `on` take only the
307
+ * schema's events. Another name doesn't compile.
308
+ * - `params` or a payload is required where its type doesn't allow `undefined`.
309
+ * - A method's `params` and `result` are left out when it has none.
310
+ * - Every key is required: `{}` for a side that handles nothing.
311
+ * - The method and event maps are `type`s or written inline, not `interfaces`: an interface has no index signature, so
312
+ * it doesn't satisfy `Record`.
313
+ *
314
+ * Params, results and payloads cross as JSON: a `Date` arrives as its ISO string, a `Map` or `Set` as `{}`, `NaN`
315
+ * as `null`, and `undefined` properties and functions are left out. A handler's result that JSON can't encode (a
316
+ * cycle, a `BigInt`) rejects the call with `handler_error`.
317
+ * @see [Bridge example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#the-bridge)
307
318
  * @group Bridge
308
319
  */
309
320
  export type BridgeSchema = {
@@ -322,13 +333,11 @@ export type BridgeSchema = {
322
333
  };
323
334
  type ParamsOf<Method> = 'params' extends keyof Method ? Method['params' & keyof Method] : undefined;
324
335
  type ResultOf<Method> = 'result' extends keyof Method ? Method['result' & keyof Method] : unknown;
325
- /** `call`'s arguments after the method: `params`, required unless they can be `undefined`, then the options. */
326
336
  type CallArgs<Method> = undefined extends ParamsOf<Method> ? [params?: ParamsOf<Method>, options?: {
327
337
  timeoutMs?: number;
328
338
  }] : [params: ParamsOf<Method>, options?: {
329
339
  timeoutMs?: number;
330
340
  }];
331
- /** `emit`'s argument after the event: the payload, required unless it can be `undefined`. */
332
341
  type PayloadArg<Payload> = undefined extends Payload ? [payload?: Payload] : [payload: Payload];
333
342
  /**
334
343
  * A promise-based RPC channel to `window.nativeBridge` in the page, typed by a {@link BridgeSchema}.
@@ -336,12 +345,15 @@ type PayloadArg<Payload> = undefined extends Payload ? [payload?: Payload] : [pa
336
345
  * Attach it with the `bridge` prop. Handlers and listeners belong to the bridge, not to a WebView: they stay across
337
346
  * unmounts. Messages have no size limit.
338
347
  *
339
- * What it sends waits for the page's `DOMContentLoaded`, so the handlers and listeners of the page's synchronous and
340
- * deferred scripts are in place, and never reaches a later page, even one on the same origin. The page's own calls
341
- * don't wait: one made before React Native has registered its method rejects with `not_found`.
348
+ * Each call or event the bridge sends:
349
+ *
350
+ * - waits for the page's `DOMContentLoaded`, so the handlers and listeners of the page's synchronous and deferred
351
+ * scripts are in place;
352
+ * - never reaches a later page, even one on the same origin;
353
+ * - waits the same way while no WebView is mounted with the bridge. A call's timeout runs meanwhile, and only the
354
+ * latest 1000 are kept: an older call rejects with `unavailable`.
342
355
  *
343
- * A call or event made while no WebView is mounted with the bridge waits the same way. A call's timeout runs
344
- * meanwhile, and only the latest 1000 are kept: an older call rejects with `unavailable`.
356
+ * The page's own calls don't wait: one made before React Native has registered its method rejects with `not_found`.
345
357
  * Unmounting rejects the calls in flight with `navigated`.
346
358
  *
347
359
  * The page's `window.nativeBridge` has the same four methods, from its side: {@link PageBridge}.
@@ -359,7 +371,7 @@ export type Bridge<Schema extends BridgeSchema = BridgeSchema> = {
359
371
  * Calls a method of the schema's `page`, which the page registered with `nativeBridge.handle`.
360
372
  *
361
373
  * Rejects with a {@link CodedError}: `timeout`, `not_found`, `handler_error`, `navigated` or `unavailable`.
362
- * `timeoutMs` overrides the bridge's for this call, and one that isn't 0 or more rejects with a plain `RangeError`.
374
+ * `timeoutMs` overrides the bridge's for this call; a negative or `NaN` one rejects with a plain `RangeError`.
363
375
  */
364
376
  call<M extends keyof Schema['page'] & string>(method: M, ...args: CallArgs<Schema['page'][M]>): Promise<ResultOf<Schema['page'][M]>>;
365
377
  /**
@@ -382,30 +394,28 @@ export type Bridge<Schema extends BridgeSchema = BridgeSchema> = {
382
394
  * from the page's side.
383
395
  *
384
396
  * `handle` takes the schema's `page` methods, and its handler gets the params only (no sender), `call` takes the
385
- * `reactNative` ones, and `emit` and `on` take the `events`. `call` rejects with a {@link CodedError}: `timeout`,
386
- * `not_found`, `handler_error`, or `navigated` when the page comes back from the back-forward cache. Its timeout
387
- * defaults to the bridge's `timeoutMs`, and a `timeoutMs` that isn't 0 or more rejects with a plain `RangeError`.
397
+ * `reactNative` ones, and `emit` and `on` take the `events`.
388
398
  *
389
399
  * `window.nativeBridge` exists only in the main frame of a page on one of the bridge's `allowedOrigins`, so a page
390
400
  * declares it optional. The page's project needs this package as a dev dependency for the type, which is a type-only
391
401
  * import and costs nothing at runtime, and must share or copy the schema type.
392
- * @example
393
- * ```ts
394
- * import type { PageBridge } from 'react-native-minimal-webview';
395
- *
396
- * declare global {
397
- * interface Window {
398
- * nativeBridge?: PageBridge<ShopBridge>;
399
- * }
400
- * }
401
- * ```
402
- * @see [Bridge example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#in-the-page)
402
+ * @see [In the page example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#in-the-page)
403
403
  * @group Bridge
404
404
  */
405
405
  export type PageBridge<Schema extends BridgeSchema = BridgeSchema> = {
406
- /** Answers `bridge.call(method, params)` from React Native. A later handler replaces it. Returns an unsubscribe function. */
406
+ /**
407
+ * Answers `bridge.call(method, params)` from React Native, for a method of the schema's `page`.
408
+ *
409
+ * One handler per method: a later one replaces it. Returns an unsubscribe function, which removes only this handler.
410
+ */
407
411
  handle<M extends keyof Schema['page'] & string>(method: M, handler: (params: ParamsOf<Schema['page'][M]>) => ResultOf<Schema['page'][M]> | Promise<ResultOf<Schema['page'][M]>>): () => void;
408
- /** Calls a method React Native registered with `bridge.handle`: `call(method, params, { timeoutMs })`. */
412
+ /**
413
+ * Calls a method of the schema's `reactNative`, which React Native registered with `bridge.handle`.
414
+ *
415
+ * Rejects with a {@link CodedError}: `timeout`, `not_found`, `handler_error`, or `navigated` when the page comes back
416
+ * from the back-forward cache. `timeoutMs` in the options overrides the bridge's for this call; a negative or `NaN`
417
+ * one rejects with a plain `RangeError`.
418
+ */
409
419
  call<M extends keyof Schema['reactNative'] & string>(method: M, ...args: CallArgs<Schema['reactNative'][M]>): Promise<ResultOf<Schema['reactNative'][M]>>;
410
420
  /** Fires an event React Native listens to with `bridge.on`. */
411
421
  emit<E extends keyof Schema['events'] & string>(event: E, ...payload: PayloadArg<Schema['events'][E]>): void;
@@ -418,15 +428,17 @@ export type PageBridge<Schema extends BridgeSchema = BridgeSchema> = {
418
428
  */
419
429
  export type BridgeOptions = {
420
430
  /**
421
- * The origins whose pages get `window.nativeBridge`, main frame only: an origin, a `*.` wildcard that matches
422
- * subdomains only (not the domain itself), an IP literal, or `'*'` for any origin, opaque ones too.
431
+ * The origins whose pages get `window.nativeBridge`, main frame only.
432
+ *
433
+ * Each is one of:
434
+ *
435
+ * - an origin, `https://example.com`;
436
+ * - a wildcard for subdomains only, not the domain itself, `https://*.example.com`;
437
+ * - an IP literal, `http://[::1]:8080`;
438
+ * - `'*'`, any origin, opaque ones too.
423
439
  *
424
- * Each takes an optional port. http or https, no path, ASCII (punycode) hosts; case is ignored, and a missing port
425
- * means 80 or 443.
426
- * @example
427
- * ```ts
428
- * createBridge({ allowedOrigins: ['https://example.com', 'https://*.example.com', 'http://[::1]:8080'] });
429
- * ```
440
+ * Except `'*'`, a rule is http or https, with an optional port, no path and an ASCII (punycode) host. Case is
441
+ * ignored, and a missing port means 80 or 443.
430
442
  */
431
443
  allowedOrigins: string[];
432
444
  /**
@@ -442,7 +454,7 @@ export type BridgeOptions = {
442
454
  * @group Page requests
443
455
  */
444
456
  export type FileRequest = {
445
- /** Its `accept` list as written: MIME types and extensions (`.pdf`). */
457
+ /** Its `accept` list, lowercased and without invalid entries: MIME types and extensions (`.pdf`). */
446
458
  accept: string[];
447
459
  /** Its `multiple` attribute. */
448
460
  multiple: boolean;
@@ -454,14 +466,13 @@ export type FileRequest = {
454
466
  *
455
467
  * `geolocation` and `protectedMedia` (the device id DRM playback needs, Widevine) are Android only: on iOS, location
456
468
  * always shows WebKit's own prompt, and FairPlay asks nothing.
469
+ *
470
+ * Android never grants another resource (MIDI sysex): a request for only those is denied without asking.
457
471
  * @group Page requests
458
472
  */
459
473
  export type PermissionResource = 'camera' | 'microphone' | 'geolocation' | 'protectedMedia';
460
474
  /**
461
475
  * A page's permission request, for `onPermissionRequest`.
462
- *
463
- * Only the main frame asks (on Android, which doesn't name the frame, any frame of the top page's origin); other
464
- * frames, and a page with an opaque origin (`data:`, a sandboxed frame), are denied without asking.
465
476
  * @group Page requests
466
477
  */
467
478
  export type PermissionRequest = {
@@ -475,10 +486,13 @@ export type PermissionRequest = {
475
486
  */
476
487
  export type Download = {
477
488
  ok: true;
478
- /** A `file://` in the app's cache (iOS: the temporary directory), which the core never deletes. */
489
+ /**
490
+ * A `file://` in the app's cache (iOS: the temporary directory), which the core never deletes but the OS may: move
491
+ * a file the app keeps.
492
+ */
479
493
  uri: string;
480
494
  /**
481
- * A plain file name, no path, but the page chose it, like the content and `mimeType`: don't open the file as
495
+ * A plain file name without a path. The page chose it, like the content and `mimeType`, so don't open the file as
482
496
  * trusted.
483
497
  */
484
498
  filename: string;
@@ -491,7 +505,7 @@ export type Download = {
491
505
  *
492
506
  * - `network`: connecting or reading the response failed, or a redirect was refused.
493
507
  * - `http`: the response had an error status (Android only: iOS saves what the server sent).
494
- * - `data`: the content: a bad `data:` or `blob:` URL, the page not reading its blob, an unsupported scheme, or
508
+ * - `data` (the content): a bad `data:` or `blob:` URL, the page not reading its blob, an unsupported scheme, or
495
509
  * (Android) a file above 100 MB or a `blob:` URL the main frame can't read (a cross-origin iframe's, or one already
496
510
  * revoked).
497
511
  * @group Page requests
@@ -500,6 +514,7 @@ export type DownloadFailure = {
500
514
  /** Tells it from a {@link Download}. */
501
515
  ok: false;
502
516
  kind: 'network' | 'data';
517
+ /** Empty on iOS when the download failed before its response came. */
503
518
  filename: string;
504
519
  /** As in {@link Download}. */
505
520
  url: string | null;
@@ -517,7 +532,7 @@ export type DownloadFailure = {
517
532
  */
518
533
  export type DownloadResult = Download | DownloadFailure;
519
534
  /**
520
- * What a platform setting can take: what its property or setter accepts. An object is one of the iOS structs.
535
+ * A value for a platform setting. It must fit the property's or setter's type.
521
536
  * @group Platform settings
522
537
  */
523
538
  export type SettingValue = boolean | number | string | null | UIEdgeInsets | CGPoint | CGSize | CGRect;
@@ -555,102 +570,101 @@ export type IOSPrivateSettingKeys = {
555
570
  /**
556
571
  * WebKit settings by Objective-C property name.
557
572
  *
558
- * Any public property works, including ones this package has never heard of (under a root's `other`). The keys the SDK
559
- * headers list autocomplete, with their `@since`, as do the {@link IOSPrivateSettingKeys}. A value must fit the
560
- * property's type: enums and option sets by raw value (from {@link IOSConstants}), structs as objects, a `UIColor` as
561
- * `#rrggbb` or `#rrggbbaa`, an `NSURL` as a string, `websiteDataStore` as `'default'` or `'nonPersistent'`.
573
+ * Any public property works, including a newer SDK's (under a root's `other`). Keys the SDK headers list appear in
574
+ * autocomplete, with their `@since`, as do the {@link IOSPrivateSettingKeys}.
575
+ *
576
+ * A value must fit the property's type:
577
+ *
578
+ * - An enum or option set: its raw value, from {@link IOSConstants}.
579
+ * - A struct: an object.
580
+ * - A `UIColor`: `#rrggbb` or `#rrggbbaa`.
581
+ * - An `NSURL`: a string.
582
+ * - `websiteDataStore`: `'default'` or `'nonPersistent'`.
562
583
  *
563
584
  * A key that doesn't fit, a private (`_`) one, or one the device's iOS lacks (its `@since` is newer) is skipped with a
564
- * warning; nothing here can crash the app. So is a property UIKit declares without runtime metadata, such as
565
- * `webView.opaque`: set it with `call('webView.setOpaque:', [false])`.
585
+ * warning; nothing here can crash the app. A property UIKit declares without runtime metadata, such as
586
+ * `webView.opaque`, is skipped the same way: set it with `call('webView.setOpaque:', [false])`.
566
587
  *
567
- * A root's default keys are the package's, and yours go over them; a key the package doesn't set keeps WebKit's
568
- * default, and a key you remove goes back to the value it had before you first set it. The ref's
569
- * {@link WebViewRef.get | get} and {@link WebViewRef.call | call} take these roots, plus `websiteDataStore` and
570
- * `httpCookieStore`.
588
+ * A root's default keys are the package's, and yours go over them. A key the package doesn't set keeps WebKit's
589
+ * default; a key you remove goes back to the value it had before you first set it.
571
590
  *
572
591
  * WebKit has no mixed-content setting: it applies its own policy.
573
- * @example
574
- * ```tsx
575
- * <WebView
576
- * source={{ uri: 'https://example.com' }}
577
- * ios={{
578
- * configuration: { dataDetectorTypes: IOSConstants.DataDetectorTypes.link },
579
- * scrollView: { bounces: false, contentInset: { top: 0, left: 0, bottom: 80, right: 0 } },
580
- * }}
581
- * />
582
- * ```
583
592
  * @ios
584
- * @see [Platform settings example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#platform-settings)
593
+ * @see [Use a platform API](https://rasmuskard.github.io/react-native-minimal-webview/guides/platform-apis/)
585
594
  * @group Platform settings
586
595
  */
587
596
  export type IOSSettings = {
588
597
  /**
589
- * `WKWebViewConfiguration`: read once, when the WKWebView is created; a change recreates the WebView (the page
590
- * reloads and the navigation state starts over). It is a copy, so `call` on it changes nothing.
598
+ * [`WKWebViewConfiguration`](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration): read once,
599
+ * when the WKWebView is created; a change recreates the WebView (the page reloads and the navigation state starts
600
+ * over). It is compared by value, so an inline object with the same keys and values is no change. It is a copy, so
601
+ * `call` on it changes nothing.
591
602
  * @default `{ allowsInlineMediaPlayback: true }`
592
603
  */
593
604
  configuration?: SettingsRoot<IOSSettingKeys['configuration'] & IOSPrivateSettingKeys['configuration']>;
594
- /** `WKPreferences` (`configuration.preferences`), live. */
605
+ /**
606
+ * [`WKPreferences`](https://developer.apple.com/documentation/webkit/wkpreferences) (`configuration.preferences`),
607
+ * live.
608
+ */
595
609
  preferences?: SettingsRoot<IOSSettingKeys['preferences'] & IOSPrivateSettingKeys['preferences']>;
596
- /** `WKWebpagePreferences` (`configuration.defaultWebpagePreferences`), live from the next navigation. */
610
+ /**
611
+ * [`WKWebpagePreferences`](https://developer.apple.com/documentation/webkit/wkwebpagepreferences)
612
+ * (`configuration.defaultWebpagePreferences`), live from the next navigation.
613
+ */
597
614
  webpagePreferences?: SettingsRoot<IOSSettingKeys['webpagePreferences']>;
598
615
  /**
599
- * The `WKWebView`, live.
616
+ * The [`WKWebView`](https://developer.apple.com/documentation/webkit/wkwebview), live.
600
617
  * @default `{ inspectable: __DEV__ }`
618
+ * @see [Debugging the page example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#debugging-the-page)
601
619
  */
602
620
  webView?: SettingsRoot<IOSSettingKeys['webView']>;
603
621
  /**
604
- * Its `UIScrollView`, live.
622
+ * The WKWebView's [`UIScrollView`](https://developer.apple.com/documentation/uikit/uiscrollview), live.
605
623
  *
606
- * `directionalLockEnabled` is on by default, as react-native-webview has it.
624
+ * `directionalLockEnabled` is on by default.
607
625
  */
608
626
  scrollView?: SettingsRoot<IOSSettingKeys['scrollView']>;
609
627
  };
610
628
  /**
611
629
  * Android settings by setter name without `set`.
612
630
  *
613
- * Any public setter works, including ones a newer SDK or androidx.webkit adds (under a root's `other`). The keys the
614
- * SDK lists autocomplete, with their `@since`; the constants are in {@link AndroidConstants}. An `int` setter takes a
631
+ * Any public setter works, including a newer SDK's or androidx.webkit's (under a root's `other`). Keys the SDK lists
632
+ * appear in autocomplete, with their `@since`; the constants are in {@link AndroidConstants}. An `int` setter takes a
615
633
  * number up to `0xFFFFFFFF`, truncated, so an ARGB color such as `0xFF202020` works.
616
634
  *
617
635
  * A key with no public setter for the value's type, or one this device's WebView lacks, is skipped with a warning;
618
- * nothing here can crash the app. A root's default keys are the package's, and yours go over them; a key the package
619
- * doesn't set, such as `overScrollMode`, keeps the platform's default. A key you remove goes back to the value it had
620
- * before you first set it; one with no getter, such as `geolocationEnabled`, keeps its value until the WebView is
621
- * recreated, with a warning.
636
+ * nothing here can crash the app. Each key is set on the current WebView as soon as it changes, and again on a new one
637
+ * after a renderer crash.
638
+ *
639
+ * A root's default keys are the package's, and yours go over them. A key the package doesn't set, such as
640
+ * `overScrollMode`, keeps the platform's default.
622
641
  *
623
- * The ref's {@link WebViewRef.get | get} and {@link WebViewRef.call | call} take these roots, plus `cookieManager` and
624
- * `webStorage`, the WebView profile's (`webView.profile`, the default one unless set); a key is the getter's name
625
- * without `get` or `is`.
626
- * @example
627
- * ```tsx
628
- * <WebView
629
- * source={{ uri: 'https://example.com' }}
630
- * android={{
631
- * settings: { textZoom: 120, cacheMode: AndroidConstants.WebSettings.LOAD_NO_CACHE },
632
- * webView: { overScrollMode: 2 },
633
- * }}
634
- * />
635
- * ```
642
+ * A key you remove goes back to the value it had before you first set it. One with no getter, such as
643
+ * `geolocationEnabled`, keeps its value until the WebView is recreated, with a warning.
636
644
  * @android
637
- * @see [Platform settings example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#platform-settings)
645
+ * @see [Use a platform API](https://rasmuskard.github.io/react-native-minimal-webview/guides/platform-apis/)
638
646
  * @group Platform settings
639
647
  */
640
648
  export type AndroidSettings = {
641
649
  /**
642
- * `WebSettings` setters, then static `WebSettingsCompat` ones.
650
+ * [`WebSettings`](https://developer.android.com/reference/android/webkit/WebSettings) setters, then static
651
+ * [`WebSettingsCompat`](https://developer.android.com/reference/androidx/webkit/WebSettingsCompat) ones.
643
652
  *
644
- * Each new WebView starts with `javaScriptEnabled`, `domStorageEnabled`, `supportMultipleWindows` and
645
- * `builtInZoomControls` on; `allowFileAccess`, `allowContentAccess`, `displayZoomControls` and
646
- * `downloadFaviconsEnabled` off; `mixedContentMode` `MIXED_CONTENT_NEVER_ALLOW`; and, with WebView 146 and newer,
647
- * `backForwardCacheEnabled` on. `useWideViewPort` and `loadWithOverviewMode` are on by default, as
648
- * react-native-webview has them. `userAgentString: null` is WebView's default user agent.
653
+ * Each new WebView starts with:
654
+ *
655
+ * - On: `javaScriptEnabled`, `domStorageEnabled`, `supportMultipleWindows`, `builtInZoomControls`,
656
+ * `useWideViewPort`, `loadWithOverviewMode` and, with Android System WebView 146 and newer,
657
+ * `backForwardCacheEnabled`.
658
+ * - Off: `allowFileAccess`, `allowContentAccess`, `displayZoomControls` and `downloadFaviconsEnabled`.
659
+ * - `mixedContentMode`: `MIXED_CONTENT_NEVER_ALLOW`.
660
+ *
661
+ * `userAgentString: null` is WebView's default user agent.
649
662
  */
650
663
  settings?: SettingsRoot<AndroidSettingKeys['settings']>;
651
664
  /**
652
- * `WebView` setters (static and inherited `View` ones too), then `WebViewCompat` ones, then `CookieManager`'s
653
- * `acceptThirdPartyCookies`.
665
+ * [`WebView`](https://developer.android.com/reference/android/webkit/WebView) setters (static and inherited `View`
666
+ * ones too), then [`WebViewCompat`](https://developer.android.com/reference/androidx/webkit/WebViewCompat) ones,
667
+ * then `CookieManager`'s `acceptThirdPartyCookies`.
654
668
  *
655
669
  * `acceptThirdPartyCookies` is on by default, as react-native-webview has it. `webContentsDebuggingEnabled` is
656
670
  * refused: it is process-wide, set with {@link AndroidWebView.setWebContentsDebuggingEnabled}.
@@ -661,10 +675,6 @@ export type AndroidSettings = {
661
675
  * An event a native hook sent with `emit` or `ask`.
662
676
  * @typeParam N - The event's name, to type one hook's events.
663
677
  * @typeParam P - Its payload.
664
- * @example
665
- * ```ts
666
- * type PageLoaded = HookEvent<'pageLoaded', { count: number }>;
667
- * ```
668
678
  * @group Native hooks
669
679
  */
670
680
  export type HookEvent<N extends string = string, P = Record<string, unknown>> = {
@@ -698,12 +708,12 @@ export type HookExtension<E extends HookEvent = HookEvent> = {
698
708
  */
699
709
  options?: unknown;
700
710
  /**
701
- * Each of the hook's events: it goes to the extension with the hook's key (the later of two with one key), and one no
702
- * extension owns is dropped. For an `ask`, the return value (a promise is awaited) is the answer, and `undefined`, or
703
- * a value JSON can't encode, answers null. `signal` is set only for an `ask`, and aborts when native stops waiting for
704
- * the answer: an ask has no timeout, but one still open when the page goes away is answered null.
711
+ * Each of the hook's events: it goes to the extension with the hook's key, and one no extension owns is dropped. For
712
+ * an `ask`, the return value (a promise is awaited) is the answer, and `undefined`, or a value JSON can't encode,
713
+ * answers null. `signal` is set only for an `ask`, and aborts when the core stops waiting for the answer: an ask has
714
+ * no timeout, but one still open when the page goes away is answered null.
705
715
  *
706
- * The latest `onEvent` always takes the events: a render with new handlers sends native nothing.
716
+ * The latest `onEvent` always takes the events: a render with new handlers sends the core nothing.
707
717
  */
708
718
  onEvent?(event: E, signal?: AbortSignal): unknown;
709
719
  };
@@ -719,20 +729,31 @@ export type FullscreenChangeEvent = {
719
729
  * Why a ref method or a bridge call rejected. Each code means the same on every method that rejects with it.
720
730
  *
721
731
  * - `timeout`: a bridge call got no answer in time.
722
- * - `not_found`: nothing by that name answers: no bridge handler for the method, no attached hook `name` that is on
723
- * and handles `method`, or no such root, key, method (on Android, one that takes these arguments) or selector (on
724
- * this OS or WebView version too; a private `_` key of an iOS `get` too), or a malformed path.
732
+ * - `not_found`: nothing by that name answers.
733
+ * - A bridge call: no handler for the method.
734
+ * - A `hook` call: no attached hook `name` that is on and handles `method`.
735
+ * - `get` and `call`: a malformed path, or no such root, key, method or selector, including one this OS or WebView
736
+ * version lacks. On Android a method that takes these arguments doesn't exist; on iOS a private `_` key of `get`
737
+ * is not found.
725
738
  * - `handler_error`: the handler of a bridge call, on either side, or of a `hook` call failed; the `message` is its
726
739
  * error's.
727
- * - `script_error`: `evaluate`'s script threw, rejected or didn't parse.
728
- * - `native_error`: the platform refused or failed the call: a member the core owns (or a private selector for an iOS
729
- * `call`), a key `get` can't read, wrong arguments (iOS), a completion handler `call` can't await, a native
730
- * exception or `NSError`, or a result JSON can't carry (`NaN`).
740
+ * - `script_error`: `evaluate`'s script threw, rejected or didn't parse, or, on Android, didn't run because the page
741
+ * loaded before the core was ready for it.
742
+ * - `native_error`: the platform refused or failed the call.
743
+ * - A member the core owns, or a private selector for an iOS `call`.
744
+ * - A key `get` can't read.
745
+ * - Wrong arguments (iOS).
746
+ * - A completion handler `call` can't await.
747
+ * - A native exception or `NSError`.
748
+ * - A result JSON can't carry (`NaN`).
731
749
  * - `navigated`: the page or the WebView went away while the call was pending (a navigation, a crash, an unmount), so
732
750
  * it may have run: retry only what is safe to repeat.
733
- * - `unavailable`: the call didn't run: the WebView is gone or not mounted yet, is being rebuilt after its renderer
734
- * died (Android), the bridge's queue was full and dropped it, or lacks the feature (the method's TSDoc names the
735
- * Android System WebView it needs, or a compat method this WebView doesn't support).
751
+ * - `unavailable`: the call didn't run.
752
+ * - The WebView is gone or not mounted yet.
753
+ * - The WebView is being rebuilt after its renderer died (Android).
754
+ * - The bridge's queue was full and dropped the call.
755
+ * - The WebView lacks the feature: the method's API reference entry names the Android System WebView it needs, or
756
+ * a compat method this WebView doesn't support.
736
757
  *
737
758
  * A programming error, such as an argument of the wrong type, can reject with a plain `TypeError` instead.
738
759
  * @group WebView
@@ -752,25 +773,34 @@ export type CodedError = Error & {
752
773
  * events) go to the native view.
753
774
  *
754
775
  * Every `on…` callback is read when its event or request comes, so adding, changing or removing one applies to the
755
- * next, and a request without one gets the default described on its prop. One that answers a request and throws (or
756
- * rejects) is logged with `console.error` and gives the refusing answer: `onNavigationRequest` `block`,
757
- * `onOpenExternal` null (the core opens nothing), `onFileRequest` cancel, `onPermissionRequest` deny, an extension's
758
- * `onEvent` null.
776
+ * next, and a request without one gets the default described on its prop.
777
+ *
778
+ * One that answers a request and throws (or rejects) is logged with `console.error` and gives the refusing answer:
779
+ *
780
+ * - `onNavigationRequest`: `block`
781
+ * - `onOpenExternal`: null (the core opens nothing)
782
+ * - `onFileRequest`: cancel
783
+ * - `onPermissionRequest`: deny
784
+ * - an extension's `onEvent`: null
759
785
  *
760
- * The `signal` such a callback gets aborts when native stops waiting for its answer (the page moved on, crashed or
786
+ * The `signal` such a callback gets aborts when the core stops waiting for its answer (the page moved on, crashed or
761
787
  * unmounted), and a late answer is dropped.
762
788
  *
763
- * JS dialogs (`alert`, `confirm`, `prompt`) and HTTP auth have no prop. iOS shows a `UIAlertController` titled with the
764
- * frame's host, or `JavaScript` for a frame without one (`data:`, sandboxed, `file:`), one at a time (one that comes
765
- * while another shows is cancelled), and Android WebView's own dialogs. An auth challenge is cancelled on Android, and
766
- * gets WebKit's default handling on iOS: without a stored credential, the site's 401 page shows. `dialogs` and
767
- * `basicAuthCredential` of `@react-native-minimal-webview/extensions` take them over, or a native hook does.
789
+ * JS dialogs (`alert`, `confirm`, `prompt`) and HTTP auth have no prop.
790
+ *
791
+ * - iOS dialogs: a `UIAlertController` titled with the frame's host, or `JavaScript` for a frame without one
792
+ * (`data:`, sandboxed, `file:`). One shows at a time; one that comes while another shows is cancelled.
793
+ * - Android dialogs: WebView's own.
794
+ * - HTTP auth: cancelled on Android. On iOS WebKit's default handling applies, so without a stored credential the
795
+ * site's 401 page shows.
796
+ *
797
+ * `dialogs` and `basicAuthCredential` of `@react-native-minimal-webview/extensions` take them over, or a native hook
798
+ * does.
799
+ * @sortStrategy source-order
768
800
  * @group WebView
769
801
  */
770
802
  export interface WebViewProps extends Omit<ViewProps, 'children'> {
771
803
  /**
772
- * What to load.
773
- *
774
804
  * A new `source` loads at once, unless it equals the loaded one field by field: that loads nothing, even after the
775
805
  * page navigated away.
776
806
  */
@@ -799,8 +829,9 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
799
829
  * Scripts to run at document start, before the page's own, in the frames picked by each script's `allFrames` and
800
830
  * `origins`.
801
831
  *
802
- * A change applies from the next navigation. On Android with a WebView older than 101 they don't run (a warning says
803
- * so, once per process).
832
+ * A change applies from the next navigation. On Android with an Android System WebView older than 101 they don't run
833
+ * (a warning says so, once per process).
834
+ * @see [Scripts example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#scripts)
804
835
  */
805
836
  injectedScripts?: InjectedScript[];
806
837
  /**
@@ -808,37 +839,28 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
808
839
  * and with no match the navigation is blocked.
809
840
  *
810
841
  * Unset, the rules are {@link defaultNavigationRules}; `[]` is no rules, so every navigation they decide is blocked.
842
+ * A change applies from the next navigation.
811
843
  *
812
- * A malformed rule, one with an unknown key, a field of the wrong type (a list that isn't an array of strings, a flag
813
- * that isn't a boolean) or no valid `action`, blocks every navigation that reaches it, whatever it was meant to match
814
- * or do: native would otherwise skip the key or flag and match more than intended, and so could allow more than a
815
- * correct rule would. In development a warning names the rule's index and the problem, once. The rules before it
816
- * decide as usual; one that isn't an array is `[]`.
817
- *
818
- * `about:`, `data:` and `javascript:` always load in place. A `blob:` URL is decided as the origin it carries:
819
- * `blob:https://example.com/…` as `https://example.com/`, and one with an opaque origin (`blob:null/…`, made by a
820
- * `data:` or sandboxed frame, or a page from an html `source` without `baseUrl`) is blocked, a download of it too.
844
+ * These skip the rules:
821
845
  *
822
- * The `source` load, reloads and back/forward skip the rules; a redirect of the `source` load doesn't, nor on Android
823
- * a redirect of a reload or back/forward. The rules never see a form POST, on either platform: it loads in place, and
824
- * one to a new window loads in place on iOS, and on Android isn't shown (the request may still reach the server).
846
+ * - the `source` load, reloads and back/forward; a redirect of the `source` load goes to the rules, and on Android so
847
+ * does a redirect of a reload or back/forward;
848
+ * - a form POST, on either platform, an iframe's to the main frame (`target=_top`) included: it loads in place; one
849
+ * to a new window loads in place on iOS and isn't shown on Android (the request may still reach the server);
850
+ * - `about:`, `data:` and `javascript:`, which load in place, except as a new window
851
+ * ({@link NavigationRule.newWindow}).
825
852
  *
826
- * An `external` `intent:` URL (Android) opens only as a browsable intent, without its explicit component or selector;
827
- * when no app handles it, an http(s) `S.browser_fallback_url` goes through the rules (main frame, no user gesture),
828
- * and the `intent:` itself is reported as `block`.
853
+ * A `blob:` URL is decided as the origin it carries: `blob:https://example.com/…` as `https://example.com/`, and one
854
+ * with an opaque origin (`blob:null/…`, made by a `data:` or sandboxed frame, or a page from an html `source`
855
+ * without `baseUrl`) is blocked, a download of it too.
829
856
  *
830
- * A change applies from the next navigation.
857
+ * A malformed rule, one with an unknown key, a field of the wrong type (a list that isn't an array of strings, a flag
858
+ * that isn't a boolean) or no valid `action`, blocks every navigation that reaches it, whatever it was meant to match
859
+ * or do. In development a warning names the rule's index and the problem, once. The rules before it decide as usual;
860
+ * one that isn't an array is `[]`.
831
861
  *
832
862
  * A native hook can take these decisions, defaults included: see `WebViewContext.clients` (Android) and
833
863
  * `navigationDelegates` (iOS).
834
- * @example
835
- * ```tsx
836
- * <WebView
837
- * source={{ uri: 'https://example.com' }}
838
- * // myapp: opens externally even without a user gesture; everything else as by default
839
- * navigationRules={[{ scheme: ['myapp'], action: 'external' }, ...defaultNavigationRules]}
840
- * />
841
- * ```
842
864
  * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
843
865
  */
844
866
  navigationRules?: readonly NavigationRule[];
@@ -848,6 +870,7 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
848
870
  * A late, missing or other answer is `block`, as is one still pending when another page commits; `signal` aborts at
849
871
  * the timeout and at that commit. Without this prop, `ask` is `block`. Until the next commit, a URL it allowed isn't
850
872
  * asked again on a redirect back to it (Android), or when the same kind of frame loads it again (iOS).
873
+ * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
851
874
  */
852
875
  onNavigationRequest?: (request: NavigationRequest, signal: AbortSignal) => NavigationAction | Promise<NavigationAction>;
853
876
  /**
@@ -858,92 +881,109 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
858
881
  * nothing opens it.
859
882
  *
860
883
  * Without this prop, the system browser or app for the URL opens it, without asking `canOpenURL` first, so no
861
- * `LSApplicationQueriesSchemes` (iOS) or `<queries>` (Android) entries are needed.
884
+ * `LSApplicationQueriesSchemes` (iOS) or `<queries>` (Android) entries are needed. An Android `intent:` URL opens
885
+ * only as a browsable intent, without its explicit component or selector; when no app handles it, an http(s)
886
+ * `S.browser_fallback_url` goes through the rules (main frame, no user gesture), and the `intent:` itself is
887
+ * reported as `block`.
862
888
  */
863
889
  onOpenExternal?: (request: NavigationRequest, signal: AbortSignal) => boolean | void | Promise<boolean | void>;
864
890
  /**
865
891
  * The bridge to the page, from `createBridge`, of any schema.
866
892
  *
867
- * Read when the WebView is created: another bridge recreates it (the page reloads and the navigation state starts
868
- * over), so make it once, at module scope or with `useMemo` (in development, a WebView warns the first time another
869
- * bridge replaces its own). A bridge serves one mounted WebView at a time: attaching it to a second throws.
893
+ * Read when the WebView is created: another bridge recreates it, so the page reloads and the navigation state starts
894
+ * over. Make the bridge once, at module scope or with `useMemo`. In development, a WebView warns the first time
895
+ * another bridge replaces its own.
870
896
  *
871
- * On Android with a WebView older than 101 there is no bridge: calls reject with `unavailable`, and a warning says
872
- * so, once per process.
897
+ * A bridge serves one mounted WebView at a time: attaching it to a second throws.
898
+ *
899
+ * On Android with an Android System WebView older than 101 there is no bridge: calls reject with `unavailable`, and a
900
+ * warning says so, once per process.
873
901
  */
874
902
  bridge?: Pick<Bridge, typeof CONNECTION>;
875
903
  /**
876
- * The native hooks to turn on, as {@link HookExtension}s: a package with a native hook exports a function that
877
- * returns one.
904
+ * The native hooks to turn on, as {@link HookExtension}s.
878
905
  *
879
906
  * A false, null or undefined entry is left out, so `on && extension(…)` switches one on and off; see
880
907
  * {@link HookExtension.options} for what off means. A hook attaches when its key first appears, and a later change of
881
908
  * its `options` reaches it live, without recreating the WebView. A key turned on after the WebView was created
882
909
  * attaches its hook then, unless the hook has a `configure` step or its own WebView class (`webViewClass`,
883
- * `webViewFactory`): that one attaches only when the WebView is created, and a warning says so.
910
+ * `webViewFactory`): that one attaches only to a WebView mounted with its key on, and a warning says so.
884
911
  * @see [Native hooks guide](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/)
885
912
  */
886
913
  extensions?: readonly (HookExtension | false | null | undefined)[];
887
914
  /**
888
915
  * Pull down at the top of the page to reload: `UIRefreshControl` on iOS, `SwipeRefreshLayout` on Android, where a
889
- * pull inside a scrolled inner scroller (`overflow: auto`) scrolls it instead.
916
+ * pull inside a scrolled inner scroller (`overflow: auto` or `scroll`) scrolls it instead.
890
917
  *
891
- * It reloads as {@link WebViewRef.reload | reload()} does, a POST `source` included. A change applies at once.
918
+ * It reloads as {@link WebViewRef.reload | reload()} does, a POST `source` included, but leaves the
919
+ * {@link ProcessGoneEvent.recovered | crash recovery} limit in place. A change applies at once.
892
920
  * @default `false`
893
921
  */
894
922
  pullToRefresh?: boolean;
895
923
  /**
896
- * Copies `HTTPCookieStorage` (native requests) into the WebView before each `source` load, which waits for it, and
897
- * the WebView's cookie changes, deletions included, back as they happen.
924
+ * Syncs cookies between `HTTPCookieStorage`, which holds the cookies of native requests, and the WebView:
925
+ *
926
+ * - `HTTPCookieStorage` into the WebView before each `source` load, which waits for it;
927
+ * - the WebView into `HTTPCookieStorage` on every cookie change, deletions included, as it happens.
898
928
  *
899
929
  * Android needs nothing: `CookieManager` is shared app-wide, and flushed when the app goes to the background. A
900
930
  * WebView on another `android.webView.profile` has that profile's cookies instead.
901
931
  * @default `false`
902
932
  * @ios
933
+ * @see [Cookies example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#cookies)
903
934
  */
904
935
  sharedCookies?: boolean;
905
936
  /**
906
937
  * Answers `<input type="file">` with `file://` or `content://` URIs, or null to cancel.
907
938
  *
908
- * Without it, the system file chooser opens, one at a time for the whole app, and ignores `capture`: a request while
909
- * one is open is cancelled, and if the chooser's activity died without returning a result, so is every request until
910
- * the app restarts.
939
+ * Until the answer settles, the page's next file request waits.
911
940
  *
912
- * iOS always shows WebKit's picker, which needs `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription`.
941
+ * Without it, the system file chooser opens and ignores `capture`. It handles one request at a time for the whole
942
+ * app: a request while one is open is cancelled. If the chooser's activity died without returning a result, every
943
+ * request is cancelled until the app restarts.
913
944
  *
914
- * Until the answer settles, the page's next file request waits.
945
+ * iOS always shows WebKit's picker, whose camera option needs `NSCameraUsageDescription`.
915
946
  * @android
947
+ * @see [File inputs example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#file-inputs)
916
948
  */
917
949
  onFileRequest?: (request: FileRequest, signal: AbortSignal) => string[] | null | Promise<string[] | null>;
918
950
  /**
919
951
  * The page entered or left fullscreen (`active`).
920
952
  *
921
953
  * Fullscreen works without it: the page's view covers the window, the system bars hide and back exits. iOS shows
922
- * WebKit's own fullscreen, not reported.
954
+ * WebKit's own fullscreen, not reported; there an element other than a video goes fullscreen only with
955
+ * `ios.preferences.elementFullscreenEnabled`.
923
956
  * @android
957
+ * @see [Fullscreen video example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#fullscreen-video)
924
958
  */
925
959
  onFullscreenChange?: (event: FullscreenChangeEvent) => void;
926
960
  /**
927
- * Camera, microphone and, on Android, location and protected media (DRM) for the main frame.
961
+ * Answers a page's camera, microphone and, on Android, location and protected media (DRM) requests.
928
962
  *
929
- * Answer true to grant, having asked the OS first (expo-camera, expo-location): without OS permission the page's
930
- * request fails anyway. On iOS, true also skips WebKit's own prompt.
963
+ * Only the main frame asks (on Android, which doesn't name the frame, any frame of the top page's origin); other
964
+ * frames, and a page with an opaque origin (`data:`, a sandboxed frame), are denied without asking, with or without
965
+ * this prop.
931
966
  *
932
- * Without this prop, Android denies and iOS shows WebKit's prompt (location always does). iOS needs
933
- * `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`, Android the `CAMERA` and `RECORD_AUDIO` manifest
934
- * permissions. Android keeps a location answer until the page changes.
967
+ * Answer true to grant; anything else denies. Ask the OS first (expo-camera, expo-location): without OS permission
968
+ * the page's request fails anyway. On iOS, true also skips WebKit's own prompt. Android keeps a location answer
969
+ * until the page changes.
935
970
  *
936
- * Anything but true denies. `signal` also aborts when Android withdraws the request. Until the answer settles, the
937
- * page's next request of the same kind waits.
971
+ * Without this prop, Android denies and iOS shows WebKit's prompt. iOS needs `NSCameraUsageDescription` and
972
+ * `NSMicrophoneUsageDescription` (`NSLocationWhenInUseUsageDescription` for location), Android the `CAMERA` and
973
+ * `RECORD_AUDIO` manifest permissions (`ACCESS_COARSE_LOCATION` or `ACCESS_FINE_LOCATION` for location).
974
+ *
975
+ * `signal` also aborts when Android withdraws the request. Until the answer settles, the page's next request of the
976
+ * same kind waits.
977
+ * @see [Permissions example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#permissions)
938
978
  */
939
979
  onPermissionRequest?: (request: PermissionRequest, signal: AbortSignal) => boolean | Promise<boolean>;
940
980
  /**
941
981
  * A download finished ({@link Download}) or failed ({@link DownloadFailure}).
942
982
  *
943
- * With this prop the core saves the file: iOS downloads it in the page's session; Android fetches it again with the
944
- * host's cookies (whatever their SameSite) and the page's user agent. That fetch sends no POST body, `source` headers
945
- * or HTTP auth, so a download that needs them can fail, or save the server's login page as the file, and it fails
946
- * above 100 MB, on a redirect off https, and for `blob:` on a WebView older than 83.
983
+ * With this prop the core saves the file. iOS downloads it in the page's session. Android fetches it again with the
984
+ * host's cookies (whatever their SameSite) and the page's user agent, without the POST body, `source` headers or
985
+ * HTTP auth, so a download that needs them can fail, or save the server's login page as the file. The fetch also
986
+ * fails on a redirect off https, and for `blob:` on an Android System WebView older than 83.
947
987
  *
948
988
  * Without this prop, an http(s) download opens externally (`onOpenExternal` or the system browser, without the page's
949
989
  * session), and a `data:` or `blob:` one is dropped. A PDF is a download on Android; iOS shows it inline.
@@ -952,12 +992,14 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
952
992
  *
953
993
  * On Android a native hook's `WebViewContext.onDownloadStart` is offered each download first, and one it takes
954
994
  * reaches neither this prop nor the external fallback.
995
+ * @see [Downloads example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#downloads)
955
996
  */
956
997
  onDownload?: (result: DownloadResult) => void;
957
998
  /**
958
999
  * Every navigation the rules, or their defaults, decided.
959
1000
  *
960
- * Not reported: the `source` load, reloads, back/forward, and a navigation a native hook decides.
1001
+ * Not reported: the `source` load, reloads, back/forward, a form POST, and a navigation a native hook decides.
1002
+ * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
961
1003
  */
962
1004
  onNavigation?: (event: NavigationEvent) => void;
963
1005
  /**
@@ -971,9 +1013,10 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
971
1013
  * A main-frame load failed, or got an HTTP error status.
972
1014
  *
973
1015
  * After a failed load iOS keeps the page before it on screen, and Android shows WebView's own error page. On Android
974
- * with a WebView older than 146, an SSL error on a back/forward load isn't reported.
1016
+ * with an Android System WebView older than 146, an SSL error on a back/forward load isn't reported.
975
1017
  *
976
1018
  * A renderer crash isn't reported here: it makes the cut-off load's `outcome` `failed` and calls `onProcessGone`.
1019
+ * @see [Loading and error screens example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#loading-and-error-screens)
977
1020
  */
978
1021
  onError?: (event: LoadErrorEvent) => void;
979
1022
  /**
@@ -985,7 +1028,8 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
985
1028
  /**
986
1029
  * `loading` went true.
987
1030
  *
988
- * On Android with a WebView older than 146, a load that never commits fires neither this nor `onLoadEnd`.
1031
+ * On Android with an Android System WebView older than 146, that is when the page commits (its response arrives),
1032
+ * not when the load starts, and a load that never commits fires neither this nor `onLoadEnd`.
989
1033
  */
990
1034
  onLoadStart?: (state: NavigationState) => void;
991
1035
  /** `loading` went false: `state.outcome` says how the load ended. */
@@ -1001,11 +1045,14 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
1001
1045
  /**
1002
1046
  * The methods a WebView's `ref` gets: navigation, scripts, and platform and hook calls.
1003
1047
  *
1004
- * A handle kept after its WebView unmounted is safe to call: the navigation methods do nothing, and `evaluate`, `get`,
1005
- * `call` and `hook` reject with `unavailable`. One still pending when the WebView unmounts rejects with `navigated`.
1048
+ * A handle kept after its WebView unmounted is safe to call. `evaluate`, `get`, `call` and `hook` are the methods that
1049
+ * return a promise:
1006
1050
  *
1007
- * Those four wait up to about a second for a WebView that has just mounted (on Android, a call from the parent's first
1008
- * effect can come before the view exists), then reject with `unavailable`; in the background they don't wait.
1051
+ * - After an unmount: the navigation methods do nothing and the four promise methods reject with `unavailable`.
1052
+ * - Pending when the WebView unmounts: the four reject with `navigated`.
1053
+ * - Just mounted: the four wait up to about a second for the view (on Android, a call from the parent's first effect
1054
+ * can come before the view exists), then reject with `unavailable`. In the background they don't wait.
1055
+ * @sortStrategy source-order
1009
1056
  * @group WebView
1010
1057
  */
1011
1058
  export type WebViewRef = {
@@ -1031,43 +1078,45 @@ export type WebViewRef = {
1031
1078
  * Runs an expression (not statements) in the page's main frame and awaits it.
1032
1079
  *
1033
1080
  * Resolves with its value through JSON: `null` for what JSON can't encode (a function, `NaN`, a cycle), a `Date` as
1034
- * its ISO string. The value is the page's, so treat it as page data. Rejects with a {@link CodedError}:
1035
- * `script_error`, `navigated` or `unavailable`. There is no timeout: a page can hold a call until it navigates. On
1036
- * Android with a WebView older than 83 it rejects with `unavailable`.
1081
+ * its ISO string. The value is the page's, so treat it as page data.
1082
+ *
1083
+ * Rejects with a {@link CodedError}: `script_error`, `navigated` or `unavailable`. There is no timeout: a page can
1084
+ * hold a call until it navigates. On Android with an Android System WebView older than 83 it rejects with
1085
+ * `unavailable`.
1086
+ * @see [Scripts example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#scripts)
1037
1087
  */
1038
1088
  evaluate(script: string): Promise<unknown>;
1039
1089
  /**
1040
1090
  * Reads a platform setting, `root.key`, and resolves with its value through JSON, as {@link WebViewRef.call | call}
1041
1091
  * converts results.
1042
1092
  *
1043
- * The roots and keys are those of {@link IOSSettings} and {@link AndroidSettings}.
1093
+ * The roots are those of {@link IOSSettings} and {@link AndroidSettings}, plus on iOS `websiteDataStore` and
1094
+ * `httpCookieStore`, and on Android `cookieManager` and `webStorage` (the WebView profile's: `webView.profile`, the
1095
+ * default one unless set). A key is the property's name on iOS, and on Android the getter's name without `get` or
1096
+ * `is`.
1044
1097
  *
1045
1098
  * It reads the WebView as it is when the call arrives: a navigation doesn't reject it. Rejects with a
1046
- * {@link CodedError}: `not_found`, `unavailable` (Android) or `native_error`.
1047
- * @example
1048
- * ```ts
1049
- * const bounces = await ref.current?.get('scrollView.bounces'); // iOS
1050
- * const textZoom = await ref.current?.get('settings.textZoom'); // Android
1051
- * ```
1099
+ * {@link CodedError}: `not_found`, `unavailable` or `native_error`.
1100
+ * @see [Reading and calling example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#reading-and-calling)
1052
1101
  */
1053
1102
  get(key: string): Promise<unknown>;
1054
1103
  /**
1055
1104
  * Calls a platform method, `root.method`, and resolves with its result through JSON. It acts on the WebView as it is
1056
1105
  * when the call arrives: a navigation doesn't reject it.
1057
1106
  *
1058
- * The roots are those of {@link IOSSettings} and {@link AndroidSettings}. On Android `method` is a public method of
1059
- * the root's object; on iOS an Objective-C selector.
1107
+ * The roots are those of {@link WebViewRef.get | get}. On Android `method` is a public method of the root's object;
1108
+ * on iOS an Objective-C selector.
1060
1109
  *
1061
- * Rejects with a {@link CodedError}: `not_found`, `unavailable` (Android) or `native_error`.
1110
+ * Rejects with a {@link CodedError}: `not_found`, `unavailable` or `native_error`.
1062
1111
  *
1063
1112
  * The core owns, and so rejects:
1064
1113
  *
1065
1114
  * - iOS: every selector that loads, navigates (`setInteractionState:` too), runs a script, starts a download or sets
1066
1115
  * a delegate, and private (`_`), KVC, `willChange…`, `didChange…`, `performSelector`, `init…`, `copy…`,
1067
1116
  * `mutable…`, `new…` and reference-counting selectors.
1068
- * - Android: the loads, navigations, clients, JavaScript interfaces, web message listeners,
1069
- * document-start scripts, the touch, scroll-change and navigation listeners, `destroy`, `removeAllViews`,
1070
- * `pauseTimers`, `resumeTimers`, `evaluateJavascript` and remote debugging
1117
+ * - Android: the loads, navigations, clients, JavaScript interfaces, web message listeners, document-start scripts,
1118
+ * the download, touch, scroll-change and navigation listeners, `destroy`, `removeAllViews`, `pauseTimers`,
1119
+ * `resumeTimers`, `evaluateJavascript` and remote debugging
1071
1120
  * ({@link AndroidWebView.setWebContentsDebuggingEnabled}).
1072
1121
  *
1073
1122
  * A trailing completion handler (iOS) or `ValueCallback` (Android) is left out of `args`: the call resolves with what
@@ -1083,17 +1132,14 @@ export type WebViewRef = {
1083
1132
  * @param args The method's arguments: booleans, numbers, strings and `null`. On iOS also the structs as objects, and
1084
1133
  * `{ set: [...] }`, `{ date: seconds }`, `{ data: base64 }` or `{ cookie: properties }` for an `NSSet`, `NSDate`,
1085
1134
  * `NSData` or `NSHTTPCookie`; any other string stays an `NSString`. A cookie's properties are `NSHTTPCookie`'s keys:
1086
- * `Name`, `Value`, `Domain` and `Path` are required; `Max-Age` (seconds, as a string), `Secure`, `HttpOnly` and
1135
+ * `Name`, `Value` and `Path` are required, and `Domain` unless `OriginURL` is given; `Max-Age` (seconds, as a string), `Secure`, `HttpOnly` and
1087
1136
  * `SameSite` are some of the optional ones. A tag that can't make its object (`{ data }` that isn't base64, a
1088
1137
  * `{ cookie }` without a required key) rejects with `native_error`.
1089
1138
  * @returns The result: primitives, strings, and collections of them; on iOS also the structs as objects, an `NSURL`
1090
1139
  * as a string, an `NSDate` as seconds, `NSData` as base64, a `UIImage` as a base64 PNG and an `NSHTTPCookie` as its
1091
1140
  * properties (`Expires` in seconds). Any other object is `null`.
1092
- * @example
1093
- * ```ts
1094
- * await ref.current?.call('webView.clearCache', [true]); // Android
1095
- * await ref.current?.call('scrollView.setContentOffset:animated:', [{ x: 0, y: 100 }, true]); // iOS
1096
- * ```
1141
+ * @see [Call a method](https://rasmuskard.github.io/react-native-minimal-webview/guides/platform-apis/#4-call-a-method)
1142
+ * @see [Reading and calling example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#reading-and-calling)
1097
1143
  */
1098
1144
  call(method: string, args?: unknown[]): Promise<unknown>;
1099
1145
  /**
@@ -1101,8 +1147,8 @@ export type WebViewRef = {
1101
1147
  * its reply; both cross as JSON.
1102
1148
  *
1103
1149
  * The reply converts as {@link WebViewRef.call | call}'s results do. Rejects with a {@link CodedError}:
1104
- * `not_found`, `unavailable` (Android), `handler_error` when the handler fails the call (`reply.fail(message)`, or a
1105
- * throw on Android), or `native_error` for a reply JSON can't encode. A navigation or a crash doesn't settle a call
1150
+ * `not_found`, `unavailable`, `handler_error` when the handler fails the call (`reply.fail(message)`, or a throw on
1151
+ * Android), or `native_error` for a non-finite number in the reply. A navigation or a crash doesn't settle a call
1106
1152
  * whose handler hasn't replied; only an unmount does.
1107
1153
  */
1108
1154
  hook(name: string, method: string, args?: unknown[]): Promise<unknown>;