react-native-minimal-webview 1.2.1 → 1.3.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/android/build.gradle +1 -1
- package/android/src/main/java/expo/modules/minimalwebview/Asks.kt +5 -11
- package/android/src/main/java/expo/modules/minimalwebview/Hooks.kt +17 -11
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebView.kt +64 -119
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewClients.kt +16 -31
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewModule.kt +4 -16
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewNavigation.kt +24 -38
- package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewScripts.kt +24 -36
- package/android/src/main/java/expo/modules/minimalwebview/NavigationRules.kt +19 -20
- package/android/src/main/java/expo/modules/minimalwebview/PlatformSettings.kt +25 -37
- package/android/src/main/java/expo/modules/minimalwebview/PullToRefresh.kt +14 -18
- package/android/src/main/java/expo/modules/minimalwebview/requests/Downloads.kt +12 -23
- package/android/src/main/java/expo/modules/minimalwebview/requests/FileUpload.kt +0 -1
- package/android/src/main/java/expo/modules/minimalwebview/requests/FullscreenVideo.kt +1 -4
- package/android/src/main/java/expo/modules/minimalwebview/requests/Permissions.kt +34 -24
- package/build/WebView.d.ts +8 -1
- package/build/WebView.d.ts.map +1 -1
- package/build/WebView.js +22 -68
- package/build/WebView.js.map +1 -1
- package/build/bridge/createBridge.d.ts +1 -5
- package/build/bridge/createBridge.d.ts.map +1 -1
- package/build/bridge/createBridge.js +3 -15
- package/build/bridge/createBridge.js.map +1 -1
- package/build/bridge/endpoint.d.ts +1 -2
- package/build/bridge/endpoint.d.ts.map +1 -1
- package/build/bridge/endpoint.js +5 -6
- package/build/bridge/endpoint.js.map +1 -1
- package/build/bridge/matchesOrigin.d.ts +11 -0
- package/build/bridge/matchesOrigin.d.ts.map +1 -0
- package/build/bridge/matchesOrigin.js +26 -0
- package/build/bridge/matchesOrigin.js.map +1 -0
- package/build/bridge/origins.d.ts +2 -13
- package/build/bridge/origins.d.ts.map +1 -1
- package/build/bridge/origins.js +1 -30
- package/build/bridge/origins.js.map +1 -1
- package/build/bridge/pageClient.generated.d.ts +1 -1
- package/build/bridge/pageClient.generated.d.ts.map +1 -1
- package/build/bridge/pageClient.generated.js +2 -2
- package/build/bridge/pageClient.generated.js.map +1 -1
- package/build/bridge/protocol.d.ts +3 -5
- package/build/bridge/protocol.d.ts.map +1 -1
- package/build/bridge/protocol.js +12 -14
- package/build/bridge/protocol.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/navigationRules.d.ts +0 -5
- package/build/navigationRules.d.ts.map +1 -1
- package/build/navigationRules.js +3 -12
- package/build/navigationRules.js.map +1 -1
- package/build/reactNativeWebViewDefaults.d.ts +0 -4
- package/build/reactNativeWebViewDefaults.d.ts.map +1 -1
- package/build/reactNativeWebViewDefaults.js +0 -4
- package/build/reactNativeWebViewDefaults.js.map +1 -1
- package/build/reactNativeWebViewMessages.d.ts.map +1 -1
- package/build/reactNativeWebViewMessages.js +0 -1
- package/build/reactNativeWebViewMessages.js.map +1 -1
- package/build/refStore.d.ts +0 -2
- package/build/refStore.d.ts.map +1 -1
- package/build/refStore.js +0 -6
- package/build/refStore.js.map +1 -1
- package/build/types.d.ts +25 -12
- package/build/types.d.ts.map +1 -1
- package/ios/Asks.swift +6 -9
- package/ios/DelegateProxy.swift +2 -19
- package/ios/DownloadName.swift +0 -2
- package/ios/Downloads.swift +0 -2
- package/ios/Hooks.swift +4 -6
- package/ios/Loads.swift +37 -19
- package/ios/MinimalWebView+Dialogs.swift +2 -6
- package/ios/MinimalWebView+Navigation.swift +17 -50
- package/ios/MinimalWebView+Scripts.swift +4 -16
- package/ios/MinimalWebView.podspec +1 -2
- package/ios/MinimalWebView.swift +62 -132
- package/ios/MinimalWebViewModule.swift +1 -18
- package/ios/NavigationRules.swift +2 -9
- package/ios/OriginRules.swift +4 -13
- package/ios/PlatformSettings.swift +9 -30
- package/ios/ReadAccess.swift +0 -2
- package/ios/Records.swift +18 -0
- package/ios/Recovery.swift +2 -8
- package/ios/SharedCookies.swift +10 -25
- package/package.json +4 -4
- package/src/WebView.tsx +34 -77
- package/src/bridge/createBridge.ts +5 -20
- package/src/bridge/endpoint.ts +6 -9
- package/src/bridge/matchesOrigin.ts +27 -0
- package/src/bridge/origins.ts +2 -30
- package/src/bridge/pageClient.generated.ts +2 -2
- package/src/bridge/pageClient.ts +1 -7
- package/src/bridge/protocol.ts +16 -18
- package/src/index.ts +1 -1
- package/src/navigationRules.ts +6 -12
- package/src/reactNativeWebViewDefaults.ts +0 -4
- package/src/reactNativeWebViewMessages.ts +0 -1
- package/src/refStore.ts +0 -7
- package/src/types.ts +25 -12
|
@@ -7,9 +7,7 @@ import { type BridgeMessage, parseBridgeMessage } from './protocol';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* What native reports to the bridge: a page's message with its origin as native verified it (`location.origin` form);
|
|
10
|
-
* a new document committed
|
|
11
|
-
* is shown until the next commit; or the platform lacks the WebView features the bridge needs, so calls reject with
|
|
12
|
-
* `unavailable`.
|
|
10
|
+
* a new document committed; the renderer crashed; or the platform lacks the WebView features the bridge needs.
|
|
13
11
|
*/
|
|
14
12
|
export type BridgeEvent =
|
|
15
13
|
| { message: string; origin: string }
|
|
@@ -17,10 +15,8 @@ export type BridgeEvent =
|
|
|
17
15
|
| { crashed: true }
|
|
18
16
|
| { unavailable: true };
|
|
19
17
|
|
|
20
|
-
/** What `<WebView>` needs from a bridge: `Bridge`'s `[CONNECTION]`, a key the package doesn't export. */
|
|
21
18
|
export type BridgeConnection = {
|
|
22
19
|
allowedOrigins: string[];
|
|
23
|
-
/** The page client to inject at document start. */
|
|
24
20
|
script: string;
|
|
25
21
|
attach(post: (message: string) => void): void;
|
|
26
22
|
detach(): void;
|
|
@@ -31,6 +27,8 @@ export const CONNECTION = Symbol('bridgeConnection');
|
|
|
31
27
|
|
|
32
28
|
const MAX_QUEUE = 1000;
|
|
33
29
|
|
|
30
|
+
const throwIfNotJson = (message: BridgeMessage) => void JSON.stringify(message);
|
|
31
|
+
|
|
34
32
|
/**
|
|
35
33
|
* Creates a {@link Bridge} to the pages of `allowedOrigins`, for one WebView's `bridge` prop.
|
|
36
34
|
*
|
|
@@ -52,11 +50,8 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
52
50
|
);
|
|
53
51
|
}
|
|
54
52
|
let post: ((message: string) => void) | null = null;
|
|
55
|
-
// idle: no document shown (none committed since attach, or it crashed). loading: one committed and hasn't said `ready` yet.
|
|
56
53
|
let phase: 'idle' | 'loading' | 'ready' = 'idle';
|
|
57
|
-
// The token of the document that last said `ready` (protocol.ts `doc`).
|
|
58
54
|
let doc: string | undefined;
|
|
59
|
-
// Messages for the next document that says `ready`. Only the latest document's: see `receive`.
|
|
60
55
|
let queue: BridgeMessage[] = [];
|
|
61
56
|
let unavailable = false;
|
|
62
57
|
|
|
@@ -66,8 +61,7 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
66
61
|
(message) => {
|
|
67
62
|
if (post && phase === 'ready') deliver(message);
|
|
68
63
|
else {
|
|
69
|
-
|
|
70
|
-
JSON.stringify(message);
|
|
64
|
+
throwIfNotJson(message);
|
|
71
65
|
queue.push(message);
|
|
72
66
|
const dropped = queue.length > MAX_QUEUE ? queue.shift() : undefined;
|
|
73
67
|
if (dropped?.kind === 'call')
|
|
@@ -82,7 +76,6 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
82
76
|
'n'
|
|
83
77
|
);
|
|
84
78
|
|
|
85
|
-
// A pending call not in the queue was posted to a document.
|
|
86
79
|
const rejectSent = (message: string) => {
|
|
87
80
|
const queued = new Set(
|
|
88
81
|
queue.map((queuedMessage) => queuedMessage.kind === 'call' && queuedMessage.id)
|
|
@@ -100,20 +93,16 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
100
93
|
return;
|
|
101
94
|
}
|
|
102
95
|
if (message.kind !== 'ready') {
|
|
103
|
-
// Answers skip the ready queue: a module script may await one before DOMContentLoaded, and native can deliver
|
|
104
|
-
// it, as the page has posted.
|
|
105
96
|
const reply = (answer: BridgeMessage) =>
|
|
106
97
|
post?.(JSON.stringify({ ...answer, doc: message.doc }));
|
|
107
98
|
void endpoint.receive(message, reply, { origin });
|
|
108
99
|
return;
|
|
109
100
|
}
|
|
110
|
-
// A new document: calls posted to the previous one can no longer be answered. Queued ones are for this one.
|
|
111
101
|
rejectSent('the page navigated');
|
|
112
102
|
phase = 'ready';
|
|
113
103
|
doc = message.doc;
|
|
114
104
|
const flushing = queue;
|
|
115
105
|
queue = [];
|
|
116
|
-
// A queued call that already timed out is not sent: nobody waits for its answer.
|
|
117
106
|
for (const queued of flushing)
|
|
118
107
|
if (queued.kind !== 'call' || endpoint.pending.has(queued.id)) deliver(queued);
|
|
119
108
|
};
|
|
@@ -122,7 +111,6 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
122
111
|
allowedOrigins: options.allowedOrigins,
|
|
123
112
|
script: `${guard ? `if (${guard}) ` : ''}(${PAGE_CLIENT})(window, ${Number(timeoutMs)});`,
|
|
124
113
|
attach(next) {
|
|
125
|
-
// Two WebViews would steal each other's replies, and either one's detach would cut off the other.
|
|
126
114
|
if (post)
|
|
127
115
|
throw new Error(
|
|
128
116
|
'createBridge: this bridge is already attached to a mounted WebView; give each WebView its own bridge'
|
|
@@ -144,13 +132,10 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
144
132
|
endpoint.rejectPending('unavailable', unavailableMessage);
|
|
145
133
|
} else {
|
|
146
134
|
rejectSent('the page navigated');
|
|
147
|
-
// The previous document never said `ready` (a page outside allowedOrigins): what was queued for it does not
|
|
148
|
-
// carry over to an unrelated next one.
|
|
149
135
|
if (phase === 'loading') {
|
|
150
136
|
endpoint.rejectPending('unavailable', 'the page navigated before the bridge was ready');
|
|
151
137
|
queue = [];
|
|
152
138
|
}
|
|
153
|
-
// What is queued after a crash is for the reload.
|
|
154
139
|
phase = 'crashed' in event ? 'idle' : 'loading';
|
|
155
140
|
}
|
|
156
141
|
},
|
|
@@ -166,5 +151,5 @@ export function createBridge<Schema extends SchemaOf<Schema> = BridgeSchema>(
|
|
|
166
151
|
emit: endpoint.emit,
|
|
167
152
|
on: endpoint.on,
|
|
168
153
|
[CONNECTION]: connection,
|
|
169
|
-
}
|
|
154
|
+
} satisfies Bridge as Bridge<Schema>;
|
|
170
155
|
}
|
package/src/bridge/endpoint.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// One side of the bridge, the same in RN (createBridge.ts) and in the page (pageClient.ts): calls with timeouts,
|
|
2
|
-
// handlers and events. The transport, the `ready` handshake and the document tokens are each side's own. The page
|
|
3
|
-
// client is compiled with this file into one script (.github/scripts/build-page-client.mts).
|
|
4
1
|
import type { CodedError, ErrorCode } from '../types';
|
|
5
2
|
import type { BridgeErrorCode, BridgeMessage } from './protocol';
|
|
6
3
|
|
|
@@ -13,9 +10,10 @@ type Pending = {
|
|
|
13
10
|
export const codedError = ({ code, message }: { code: ErrorCode; message: string }): CodedError =>
|
|
14
11
|
Object.assign(new Error(message), { code });
|
|
15
12
|
|
|
13
|
+
const reportUnhandled = (error: unknown) => void Promise.reject(error);
|
|
14
|
+
|
|
16
15
|
/**
|
|
17
|
-
* `send` posts a message to the other side; ids get `idPrefix`, so the two sides' calls never share an id.
|
|
18
|
-
* what handlers and listeners get beside the params: RN's `{ origin }`, nothing in the page.
|
|
16
|
+
* `send` posts a message to the other side; ids get `idPrefix`, so the two sides' calls never share an id.
|
|
19
17
|
*/
|
|
20
18
|
export function createEndpoint<Sender = void>(
|
|
21
19
|
send: (message: BridgeMessage) => void,
|
|
@@ -59,7 +57,7 @@ export function createEndpoint<Sender = void>(
|
|
|
59
57
|
});
|
|
60
58
|
},
|
|
61
59
|
emit(event: string, payload?: unknown) {
|
|
62
|
-
send({ kind: 'event',
|
|
60
|
+
send({ kind: 'event', event, params: payload });
|
|
63
61
|
},
|
|
64
62
|
handle(method: string, handler: (params: unknown, sender: Sender) => unknown) {
|
|
65
63
|
handlers.set(method, handler);
|
|
@@ -96,12 +94,11 @@ export function createEndpoint<Sender = void>(
|
|
|
96
94
|
return;
|
|
97
95
|
}
|
|
98
96
|
case 'event':
|
|
99
|
-
listeners.get(message.
|
|
100
|
-
// An unhandled rejection reports the error without stopping the other listeners.
|
|
97
|
+
listeners.get(message.event)?.forEach((listener) => {
|
|
101
98
|
try {
|
|
102
99
|
listener(message.params, sender);
|
|
103
100
|
} catch (error) {
|
|
104
|
-
|
|
101
|
+
reportUnhandled(error);
|
|
105
102
|
}
|
|
106
103
|
});
|
|
107
104
|
return;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type OriginForms = {
|
|
2
|
+
any: boolean;
|
|
3
|
+
exact: string[];
|
|
4
|
+
wild: [prefix: string, suffix: string][];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function hasAt(text: string, part: string, at: number) {
|
|
8
|
+
for (let k = 0; k < part.length; k++) if (text[at + k] !== part[k]) return false;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Whether `origin`, as `location.origin` serializes it, matches `forms`. Only `===`, indexing and `length`, no
|
|
14
|
+
* built-in method: it runs at document start in frames whose built-ins another same-origin frame may have patched.
|
|
15
|
+
*/
|
|
16
|
+
export function matchesOrigin(forms: OriginForms, origin: string) {
|
|
17
|
+
if (forms.any) return true;
|
|
18
|
+
for (let i = 0; i < forms.exact.length; i++) if (forms.exact[i] === origin) return true;
|
|
19
|
+
for (let i = 0; i < forms.wild.length; i++) {
|
|
20
|
+
const prefix = forms.wild[i]![0];
|
|
21
|
+
const suffix = forms.wild[i]![1];
|
|
22
|
+
const start = origin.length - suffix.length;
|
|
23
|
+
if (start > prefix.length && hasAt(origin, prefix, 0) && hasAt(origin, suffix, start))
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
package/src/bridge/origins.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
// matcher whose text build-page-client.mts cuts out as MATCHES_ORIGIN for that guard.
|
|
1
|
+
import type { OriginForms } from './matchesOrigin';
|
|
3
2
|
import { MATCHES_ORIGIN } from './pageClient.generated';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* An origin rule (`http(s)://host[:port]`, `http(s)://*.host[:port]`) or a `location.origin`, parsed; null for anything
|
|
7
|
-
* else, `*` included.
|
|
6
|
+
* else, `*` included.
|
|
8
7
|
*/
|
|
9
8
|
export const parseOrigin = (text: string) => {
|
|
10
9
|
const m =
|
|
@@ -19,10 +18,6 @@ export const parseOrigin = (text: string) => {
|
|
|
19
18
|
return { scheme, wildcard: !!wildcard, hostPort: `${host}${portSuffix}` };
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
/** Origin rules in `location.origin` form, for `matchesOrigin`: exact origins, and wildcards as prefix and suffix. */
|
|
23
|
-
export type OriginForms = { any: boolean; exact: string[]; wild: [string, string][] };
|
|
24
|
-
|
|
25
|
-
/** `rules` in the form `matchesOrigin` compares; a rule `parseOrigin` rejects is left out, so it matches nothing. */
|
|
26
21
|
export const originForms = (rules: string[]): OriginForms => {
|
|
27
22
|
const forms: OriginForms = { any: rules.includes('*'), exact: [], wild: [] };
|
|
28
23
|
for (const rule of rules) {
|
|
@@ -34,29 +29,6 @@ export const originForms = (rules: string[]): OriginForms => {
|
|
|
34
29
|
return forms;
|
|
35
30
|
};
|
|
36
31
|
|
|
37
|
-
function hasAt(text: string, part: string, at: number) {
|
|
38
|
-
for (let k = 0; k < part.length; k++) if (text[at + k] !== part[k]) return false;
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Whether `origin`, as `location.origin` serializes it, matches `forms`. Only `===`, indexing and `length`, no
|
|
44
|
-
* built-in method: it runs at document start in frames whose built-ins another same-origin frame may have patched.
|
|
45
|
-
*/
|
|
46
|
-
export function matchesOrigin(forms: OriginForms, origin: string) {
|
|
47
|
-
if (forms.any) return true;
|
|
48
|
-
for (let i = 0; i < forms.exact.length; i++) if (forms.exact[i] === origin) return true;
|
|
49
|
-
for (let i = 0; i < forms.wild.length; i++) {
|
|
50
|
-
const prefix = forms.wild[i]![0];
|
|
51
|
-
const suffix = forms.wild[i]![1];
|
|
52
|
-
const start = origin.length - suffix.length;
|
|
53
|
-
// At least one character of subdomain between the two.
|
|
54
|
-
if (start > prefix.length && hasAt(origin, prefix, 0) && hasAt(origin, suffix, start))
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
32
|
/**
|
|
61
33
|
* A page-side expression true where `location.origin` matches `origins`, or null when they include `*`. Throws an
|
|
62
34
|
* `Error` starting with `what` for a rule that is neither `*` nor what `parseOrigin` takes.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Generated by .github/scripts/build-page-client.mts from pageClient.ts, endpoint.ts and
|
|
1
|
+
// Generated by .github/scripts/build-page-client.mts from pageClient.ts, endpoint.ts and matchesOrigin.ts. Do not edit.
|
|
2
2
|
export const PAGE_CLIENT =
|
|
3
|
-
"function (w, timeoutMs) {\nconst codedError = ({ code, message }) => Object.assign(new Error(message), { code });\nfunction createEndpoint(send, timeoutMs, idPrefix) {\n const handlers = new Map();\n const listeners = new Map();\n const pending = new Map();\n let nextId = 0;\n return {\n pending,\n call(method, params, options) {\n const ms = options?.timeoutMs ?? timeoutMs;\n if (!(ms >= 0))\n return Promise.reject(new RangeError(`${method}: timeoutMs must be 0 or more, not ${ms}`));\n const id = `${idPrefix}${++nextId}`;\n return new Promise((resolve, reject) => {\n const timer = ms > 0 && ms < Infinity\n ? setTimeout(() => {\n pending.delete(id);\n reject(codedError({ code: 'timeout', message: `${method} timed out after ${ms} ms` }));\n }, Math.min(ms, 2 ** 31 - 1))\n : undefined;\n pending.set(id, { resolve, reject, timer });\n try {\n send({ id, kind: 'call', method, params });\n }\n catch (error) {\n clearTimeout(timer);\n pending.delete(id);\n throw error;\n }\n });\n },\n emit(event, payload) {\n send({ kind: 'event',
|
|
3
|
+
"function (w, timeoutMs) {\nconst codedError = ({ code, message }) => Object.assign(new Error(message), { code });\nconst reportUnhandled = (error) => void Promise.reject(error);\nfunction createEndpoint(send, timeoutMs, idPrefix) {\n const handlers = new Map();\n const listeners = new Map();\n const pending = new Map();\n let nextId = 0;\n return {\n pending,\n call(method, params, options) {\n const ms = options?.timeoutMs ?? timeoutMs;\n if (!(ms >= 0))\n return Promise.reject(new RangeError(`${method}: timeoutMs must be 0 or more, not ${ms}`));\n const id = `${idPrefix}${++nextId}`;\n return new Promise((resolve, reject) => {\n const timer = ms > 0 && ms < Infinity\n ? setTimeout(() => {\n pending.delete(id);\n reject(codedError({ code: 'timeout', message: `${method} timed out after ${ms} ms` }));\n }, Math.min(ms, 2 ** 31 - 1))\n : undefined;\n pending.set(id, { resolve, reject, timer });\n try {\n send({ id, kind: 'call', method, params });\n }\n catch (error) {\n clearTimeout(timer);\n pending.delete(id);\n throw error;\n }\n });\n },\n emit(event, payload) {\n send({ kind: 'event', event, params: payload });\n },\n handle(method, handler) {\n handlers.set(method, handler);\n return () => {\n if (handlers.get(method) === handler)\n handlers.delete(method);\n };\n },\n on(event, listener) {\n const set = listeners.get(event) ?? new Set();\n listeners.set(event, set.add(listener));\n return () => set.delete(listener);\n },\n rejectPending(code, message, only) {\n for (const [id, call] of pending) {\n if (only && !only(id))\n continue;\n clearTimeout(call.timer);\n call.reject(codedError({ code, message }));\n pending.delete(id);\n }\n },\n async receive(message, reply, sender) {\n switch (message.kind) {\n case 'call': {\n const { id, method } = message;\n const fail = (code, text) => reply({ id, kind: 'error', error: { code, message: text } });\n const handler = handlers.get(method);\n if (!handler)\n return fail('not_found', `no handler for ${method}`);\n try {\n reply({ id, kind: 'result', value: await handler(message.params, sender) });\n }\n catch (error) {\n fail('handler_error', error instanceof Error ? error.message : String(error));\n }\n return;\n }\n case 'event':\n listeners.get(message.event)?.forEach((listener) => {\n try {\n listener(message.params, sender);\n }\n catch (error) {\n reportUnhandled(error);\n }\n });\n return;\n case 'result':\n case 'error': {\n const call = pending.get(message.id);\n if (!call)\n return;\n pending.delete(message.id);\n clearTimeout(call.timer);\n if (message.kind === 'result')\n call.resolve(message.value);\n else\n call.reject(codedError(message.error));\n }\n }\n },\n };\n}\nfunction installPageClient(w, timeoutMs) {\n if (w.nativeBridge || w !== w.top)\n return;\n const doc = Math.random().toString(36).slice(2, 10);\n const ios = w.webkit?.messageHandlers?.nativeBridge;\n const android = w.nativeBridgeTransport;\n const send = (message) => {\n const text = JSON.stringify({ ...message, doc });\n (ios ?? android)?.postMessage(text);\n };\n const endpoint = createEndpoint(send, timeoutMs, 'p');\n const receive = async (text) => {\n const message = JSON.parse(text);\n if (message.doc === doc)\n await endpoint.receive(message, send);\n };\n if (android)\n android.onmessage = (event) => void receive(event.data);\n w.nativeBridge = Object.freeze({\n call: endpoint.call,\n emit: endpoint.emit,\n handle: endpoint.handle,\n on: endpoint.on,\n __receive: receive,\n });\n if (w.document.readyState === 'loading') {\n w.document.addEventListener('DOMContentLoaded', () => send({ kind: 'ready' }), {\n once: true,\n });\n }\n else {\n send({ kind: 'ready' });\n }\n w.addEventListener('pageshow', (event) => {\n if (!event.persisted)\n return;\n endpoint.rejectPending('navigated', 'the page was left before the call was answered');\n send({ kind: 'ready' });\n });\n}\nreturn installPageClient(w, timeoutMs);\n}";
|
|
4
4
|
export const MATCHES_ORIGIN =
|
|
5
5
|
"(() => {\nfunction hasAt(text, part, at) {\n for (let k = 0; k < part.length; k++)\n if (text[at + k] !== part[k])\n return false;\n return true;\n}\nfunction matchesOrigin(forms, origin) {\n if (forms.any)\n return true;\n for (let i = 0; i < forms.exact.length; i++)\n if (forms.exact[i] === origin)\n return true;\n for (let i = 0; i < forms.wild.length; i++) {\n const prefix = forms.wild[i][0];\n const suffix = forms.wild[i][1];\n const start = origin.length - suffix.length;\n if (start > prefix.length && hasAt(origin, prefix, 0) && hasAt(origin, suffix, start))\n return true;\n }\n return false;\n}\nreturn matchesOrigin;\n})()";
|
package/src/bridge/pageClient.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The page side of the bridge: installs `window.nativeBridge`. It runs in the page, compiled into PAGE_CLIENT by
|
|
2
|
-
// .github/scripts/build-page-client.mts. Page -> native: iOS WKScriptMessageHandler, Android addWebMessageListener;
|
|
3
|
-
// native -> page: `__receive` (iOS callAsyncJavaScript) or the transport's `onmessage` (Android).
|
|
4
1
|
import type { PageBridge } from '../types';
|
|
5
2
|
import { createEndpoint } from './endpoint';
|
|
6
3
|
import type { BridgeMessage as Message } from './protocol';
|
|
@@ -19,7 +16,6 @@ type PageWindow = Window & {
|
|
|
19
16
|
export function installPageClient(w: PageWindow, timeoutMs: number) {
|
|
20
17
|
// Main frame only (Android injects into allowed-origin iframes too, but only the main frame's messages are taken).
|
|
21
18
|
if (w.nativeBridge || w !== w.top) return;
|
|
22
|
-
// This document's token (protocol.ts `doc`).
|
|
23
19
|
const doc = Math.random().toString(36).slice(2, 10);
|
|
24
20
|
|
|
25
21
|
const ios = w.webkit?.messageHandlers?.nativeBridge;
|
|
@@ -43,7 +39,6 @@ export function installPageClient(w: PageWindow, timeoutMs: number) {
|
|
|
43
39
|
emit: endpoint.emit,
|
|
44
40
|
handle: endpoint.handle,
|
|
45
41
|
on: endpoint.on,
|
|
46
|
-
/** iOS's entry point, origin-checked there. */
|
|
47
42
|
__receive: receive,
|
|
48
43
|
});
|
|
49
44
|
if (w.document.readyState === 'loading') {
|
|
@@ -53,8 +48,7 @@ export function installPageClient(w: PageWindow, timeoutMs: number) {
|
|
|
53
48
|
} else {
|
|
54
49
|
send({ kind: 'ready' });
|
|
55
50
|
}
|
|
56
|
-
//
|
|
57
|
-
// answers to this page's calls went to the page shown meanwhile. Fail those calls and announce the page again.
|
|
51
|
+
// A page restored from the back-forward cache does not run its scripts again.
|
|
58
52
|
w.addEventListener('pageshow', (event) => {
|
|
59
53
|
if (!event.persisted) return;
|
|
60
54
|
endpoint.rejectPending('navigated', 'the page was left before the call was answered');
|
package/src/bridge/protocol.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// The bridge wire format. The RN side parses with it.
|
|
2
1
|
import type { ErrorCode } from '../types';
|
|
3
2
|
|
|
4
|
-
/** The codes a bridge call rejects with: the page may send only these. */
|
|
5
3
|
const ERROR_CODES = [
|
|
6
4
|
'timeout',
|
|
7
5
|
'not_found',
|
|
@@ -16,20 +14,19 @@ export type BridgeErrorCode = (typeof ERROR_CODES)[number];
|
|
|
16
14
|
* events for the page until then (native can't deliver before the page has posted). A page's own calls and their
|
|
17
15
|
* answers don't wait for it.
|
|
18
16
|
* `call` / `result` / `error`: a request and its answer, matched by `id`.
|
|
19
|
-
* `event`: fire-and-forget
|
|
17
|
+
* `event`: fire-and-forget.
|
|
20
18
|
*
|
|
21
19
|
* `doc` is the page document's random token. Each side puts a token on every message (RN the token of the document it
|
|
22
20
|
* means), and the page drops any message that isn't for it: native delivers to whatever document is current (iOS
|
|
23
21
|
* checks only the origin), so a message posted as a same-origin navigation commits would otherwise reach the new page.
|
|
24
|
-
* It is for correctness, not security: an allowed page can rebind its own client.
|
|
25
|
-
* `send` adds it.
|
|
22
|
+
* It is for correctness, not security: an allowed page can rebind its own client.
|
|
26
23
|
*/
|
|
27
24
|
export type BridgeMessage = { doc?: string } & (
|
|
28
25
|
| { kind: 'ready' }
|
|
29
26
|
| { kind: 'call'; id: string; method: string; params?: unknown }
|
|
30
27
|
| { kind: 'result'; id: string; value?: unknown }
|
|
31
28
|
| { kind: 'error'; id: string; error: { code: BridgeErrorCode; message: string } }
|
|
32
|
-
| { kind: 'event';
|
|
29
|
+
| { kind: 'event'; event: string; params?: unknown }
|
|
33
30
|
);
|
|
34
31
|
|
|
35
32
|
const isObject = (value: unknown): value is Record<string, unknown> =>
|
|
@@ -47,32 +44,33 @@ export function parseBridgeMessage(raw: string): (BridgeMessage & { doc: string
|
|
|
47
44
|
return 'not JSON';
|
|
48
45
|
}
|
|
49
46
|
if (!isObject(value) || typeof value['doc'] !== 'string') return 'missing doc';
|
|
50
|
-
|
|
47
|
+
const problem = kindProblem(value);
|
|
48
|
+
if (problem) return problem;
|
|
49
|
+
const message = value as BridgeMessage & { doc: string };
|
|
50
|
+
return message.kind === 'error' && !ERROR_CODES.includes(message.error.code)
|
|
51
|
+
? { ...message, error: { ...message.error, code: 'handler_error' } }
|
|
52
|
+
: message;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
const isName = (value: unknown) => typeof value === 'string' && value !== '';
|
|
56
|
+
|
|
53
57
|
function kindProblem(value: Record<string, unknown>): string | null {
|
|
54
58
|
const hasId = typeof value['id'] === 'string';
|
|
55
|
-
const hasMethod = typeof value['method'] === 'string' && value['method'] !== '';
|
|
56
59
|
switch (value['kind']) {
|
|
57
60
|
case 'ready':
|
|
58
61
|
return null;
|
|
59
62
|
case 'event':
|
|
60
|
-
return
|
|
63
|
+
return isName(value['event']) ? null : 'missing event';
|
|
61
64
|
case 'call':
|
|
62
|
-
return hasId &&
|
|
65
|
+
return hasId && isName(value['method']) ? null : 'missing id or method';
|
|
63
66
|
case 'result':
|
|
64
67
|
return hasId ? null : 'missing id';
|
|
65
68
|
case 'error':
|
|
66
|
-
return !hasId ? 'missing id' :
|
|
69
|
+
return !hasId ? 'missing id' : isError(value['error']) ? null : 'malformed error';
|
|
67
70
|
default:
|
|
68
71
|
return 'unknown kind';
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!isObject(error) || typeof error['code'] !== 'string' || typeof error['message'] !== 'string')
|
|
75
|
-
return false;
|
|
76
|
-
if (!(ERROR_CODES as readonly string[]).includes(error['code'])) error['code'] = 'handler_error';
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
75
|
+
const isError = (error: unknown) =>
|
|
76
|
+
isObject(error) && typeof error['code'] === 'string' && typeof error['message'] === 'string';
|
package/src/index.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @groupDescription Page requests
|
|
15
15
|
* File pickers, permission prompts and downloads the page starts.
|
|
16
16
|
* @groupDescription Native hooks
|
|
17
|
-
* Turning native hooks on with the `extensions` prop, and what they send to each extension's `onEvent`.
|
|
17
|
+
* Turning native hooks on with the `extensions` prop, and what they send to each extension's `onEvent` and `onAsk`.
|
|
18
18
|
* @groupDescription Platform settings
|
|
19
19
|
* WebKit, UIScrollView and Android WebView settings, set by their platform names through the `ios` and `android` props.
|
|
20
20
|
* @module react-native-minimal-webview
|
package/src/navigationRules.ts
CHANGED
|
@@ -23,7 +23,6 @@ export const defaultNavigationRules: readonly NavigationRule[] = freeze<Navigati
|
|
|
23
23
|
{ mainFrame: true, userInitiated: true, action: 'external' },
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
-
/** Each rule field's kind, from its type, so that a field missing here, or not in the type, fails to compile. */
|
|
27
26
|
const RULE_FIELDS = new Map(
|
|
28
27
|
Object.entries({
|
|
29
28
|
scheme: 'list',
|
|
@@ -49,17 +48,14 @@ const ACTIONS: unknown[] = Object.keys({
|
|
|
49
48
|
ask: 0,
|
|
50
49
|
} satisfies Record<NavigationRule['action'], 0>);
|
|
51
50
|
|
|
52
|
-
/** A value as a warning shows it. */
|
|
53
51
|
const shown = (value: unknown) => {
|
|
54
52
|
try {
|
|
55
53
|
return JSON.stringify(value) ?? String(value);
|
|
56
54
|
} catch {
|
|
57
|
-
// A BigInt, a circular value or a throwing toJSON: the message runs in production too, so it must not throw.
|
|
58
55
|
return typeof value === 'bigint' ? String(value) : Object.prototype.toString.call(value);
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
58
|
|
|
62
|
-
/** What a field of each kind takes, as a warning says it, and the check. */
|
|
63
59
|
const FIELD_KINDS = {
|
|
64
60
|
list: {
|
|
65
61
|
takes: 'an array of strings',
|
|
@@ -70,23 +66,21 @@ const FIELD_KINDS = {
|
|
|
70
66
|
action: { takes: `one of ${shown(ACTIONS)}`, ok: (value: unknown) => ACTIONS.includes(value) },
|
|
71
67
|
};
|
|
72
68
|
|
|
69
|
+
const REQUIRED_FIELDS_UNSET = { action: undefined } satisfies {
|
|
70
|
+
[K in keyof NavigationRule as object extends Pick<NavigationRule, K> ? never : K]: undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
73
|
function ruleProblem(rule: unknown) {
|
|
74
74
|
if (typeof rule !== 'object' || rule === null) return `must be an object, not ${shown(rule)}`;
|
|
75
|
-
|
|
76
|
-
for (const [key, value] of Object.entries({ action: undefined, ...rule })) {
|
|
75
|
+
for (const [key, value] of Object.entries({ ...REQUIRED_FIELDS_UNSET, ...rule })) {
|
|
77
76
|
const kind = RULE_FIELDS.get(key);
|
|
78
77
|
if (!kind) return `unknown key ${shown(key)}`;
|
|
79
|
-
if ((value !== undefined ||
|
|
78
|
+
if ((value !== undefined || key in REQUIRED_FIELDS_UNSET) && !FIELD_KINDS[kind].ok(value))
|
|
80
79
|
return `${key} must be ${FIELD_KINDS[kind].takes}, not ${shown(value)}`;
|
|
81
80
|
}
|
|
82
81
|
return undefined;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
/**
|
|
86
|
-
* The rules as the core gets them, and a warning for each malformed one. The core skips an unknown key and a
|
|
87
|
-
* non-boolean flag, which would widen a rule (`hosts` would match every host), so a malformed rule becomes a `block`
|
|
88
|
-
* one. The same array when none is malformed.
|
|
89
|
-
*/
|
|
90
84
|
export function checkNavigationRules(given: unknown): {
|
|
91
85
|
checked: NavigationRule[];
|
|
92
86
|
warnings: string[];
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { AndroidSettings, IOSSettings } from './types';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* react-native-webview's defaults, so that an app migrated from it behaves as before. An app sets any back through
|
|
5
|
-
* `ios` or `android`.
|
|
6
|
-
*/
|
|
7
3
|
export const REACT_NATIVE_WEBVIEW_DEFAULTS = {
|
|
8
4
|
ios: { scrollView: { directionalLockEnabled: true } },
|
|
9
5
|
android: {
|
|
@@ -16,7 +16,6 @@ import type { InjectedScript } from './types';
|
|
|
16
16
|
* @group Scripts
|
|
17
17
|
*/
|
|
18
18
|
export const reactNativeWebViewMessages: InjectedScript = {
|
|
19
|
-
// Runs after the bridge's own script, so `window.nativeBridge` already exists where the bridge is installed.
|
|
20
19
|
code: `if (window.nativeBridge) {
|
|
21
20
|
window.ReactNativeWebView = { postMessage: (data) => window.nativeBridge.emit('rnw', String(data)) };
|
|
22
21
|
window.nativeBridge.on('rnw', (data) =>
|
package/src/refStore.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import type { NavigationState, WebViewRef, WebViewRefObject } from './types';
|
|
12
12
|
|
|
13
|
-
/** An empty `url`, so a stale URL never looks valid while no WebView is mounted. */
|
|
14
13
|
const INITIAL_STATE: NavigationState = {
|
|
15
14
|
url: '',
|
|
16
15
|
pendingUrl: null,
|
|
@@ -22,7 +21,6 @@ const INITIAL_STATE: NavigationState = {
|
|
|
22
21
|
outcome: null,
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
/** A mounted WebView's hold on its ref: `handle` passes on the WebView's state, and lets go at unmount. */
|
|
26
24
|
type Adapter = {
|
|
27
25
|
nav: WebViewRefObject;
|
|
28
26
|
attach(handle: WebViewRef, state: NavigationState): void;
|
|
@@ -30,7 +28,6 @@ type Adapter = {
|
|
|
30
28
|
detach(handle: WebViewRef): void;
|
|
31
29
|
};
|
|
32
30
|
|
|
33
|
-
/** The navigation object behind each ref object: created by createWebViewRef, or made on first use for a plain ref. */
|
|
34
31
|
const adapters = new WeakMap<object, Adapter>();
|
|
35
32
|
|
|
36
33
|
function adapterFor(ref: object) {
|
|
@@ -59,7 +56,6 @@ function createAdapter(): Adapter {
|
|
|
59
56
|
};
|
|
60
57
|
return {
|
|
61
58
|
nav,
|
|
62
|
-
// Last attached wins, like a React ref; an earlier instance's later updates and detach are ignored.
|
|
63
59
|
attach(handle, initial) {
|
|
64
60
|
if (__DEV__ && attached) {
|
|
65
61
|
console.warn(
|
|
@@ -93,8 +89,6 @@ export function createWebViewRef(): WebViewRefObject {
|
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
/**
|
|
96
|
-
* Attaches `handle` to `ref`. A callback or plain ref gets it through `useImperativeHandle`; a `createWebViewRef` ref
|
|
97
|
-
* serves it as its own `current`. Any ref object also gets the navigation state through its adapter.
|
|
98
92
|
* Returns a function that records a new state, passes it to the attached ref and returns the previous state.
|
|
99
93
|
*/
|
|
100
94
|
export function useAttach(
|
|
@@ -148,7 +142,6 @@ export function useWebViewState<T>(
|
|
|
148
142
|
return useSyncExternalStore(nav.subscribe, getSnapshot);
|
|
149
143
|
}
|
|
150
144
|
|
|
151
|
-
/** `select` of the current state, run again only for another state: a snapshot is the same value until a change. */
|
|
152
145
|
function selectFrom<T>(getState: () => NavigationState, select: (state: NavigationState) => T) {
|
|
153
146
|
let last: { state: NavigationState; selected: T } | undefined;
|
|
154
147
|
return () => {
|
package/src/types.ts
CHANGED
|
@@ -558,8 +558,11 @@ export type Download = {
|
|
|
558
558
|
* - `network`: connecting or reading the response failed, or a redirect was refused.
|
|
559
559
|
* - `http`: the response had an error status (Android only: iOS saves what the server sent).
|
|
560
560
|
* - `data` (the content): a bad `data:` or `blob:` URL, the page not reading its blob, an unsupported scheme, or
|
|
561
|
-
* (Android) a file above 100
|
|
561
|
+
* (Android) a file above 100 MiB or a `blob:` URL the main frame can't read (a cross-origin iframe's, or one already
|
|
562
562
|
* revoked).
|
|
563
|
+
*
|
|
564
|
+
* On Android a disk error while saving, such as a full disk, is `network` for an http(s) download and `data` for a
|
|
565
|
+
* `data:` or `blob:` one.
|
|
563
566
|
* @group Page requests
|
|
564
567
|
*/
|
|
565
568
|
export type DownloadFailure =
|
|
@@ -637,7 +640,9 @@ export type IOSPrivateSettingKeys = {
|
|
|
637
640
|
* `webView.opaque`, is skipped the same way: set it with `call('webView.setOpaque:', [false])`.
|
|
638
641
|
*
|
|
639
642
|
* A root's default keys are the package's, and yours go over them. A key the package doesn't set keeps WebKit's
|
|
640
|
-
* default; a key you remove goes back to the value it had before you first set it.
|
|
643
|
+
* default; a key you remove goes back to the value it had before you first set it. For
|
|
644
|
+
* `webView.underPageBackgroundColor`, which WebKit derives from the page, that value is the color derived then, and it
|
|
645
|
+
* stays: set the key to `null` instead of removing it to go back to WebKit's default.
|
|
641
646
|
*
|
|
642
647
|
* WebKit has no mixed-content setting: it applies its own policy.
|
|
643
648
|
* @ios
|
|
@@ -743,7 +748,8 @@ export type HookEvent<N extends string = string, P = Record<string, unknown>> =
|
|
|
743
748
|
*
|
|
744
749
|
* A package with a native hook exports a function that returns one, so that an app turns the hook on by putting it in
|
|
745
750
|
* `extensions`.
|
|
746
|
-
* @typeParam E - The hook's events, to type `onEvent`: a union of {@link HookEvent}s, which nothing checks
|
|
751
|
+
* @typeParam E - The hook's events, to type `onEvent` and `onAsk`: a union of {@link HookEvent}s, which nothing checks
|
|
752
|
+
* at runtime.
|
|
747
753
|
* @see [Native hooks guide](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/)
|
|
748
754
|
* @group Native hooks
|
|
749
755
|
*/
|
|
@@ -763,14 +769,19 @@ export type HookExtension<E extends HookEvent = HookEvent> = {
|
|
|
763
769
|
*/
|
|
764
770
|
options?: unknown;
|
|
765
771
|
/**
|
|
766
|
-
* Each of the hook's events: it goes to the extension with the hook's key, and one no extension owns is dropped.
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
* no timeout, but one still open when the page goes away is answered null.
|
|
772
|
+
* Each of the hook's events: it goes to the extension with the hook's key, and one no extension owns is dropped. An
|
|
773
|
+
* `ask` goes to {@link HookExtension.onAsk} instead when the extension has one; without it, an `ask` comes here with
|
|
774
|
+
* `signal` set, and the return value is the answer as `onAsk` describes. `signal` is undefined for an `emit`.
|
|
770
775
|
*
|
|
771
|
-
* The latest `onEvent` always
|
|
776
|
+
* The latest `onEvent` and `onAsk` always take the events: a render with new handlers sends the core nothing.
|
|
772
777
|
*/
|
|
773
778
|
onEvent?(event: E, signal?: AbortSignal): unknown;
|
|
779
|
+
/**
|
|
780
|
+
* Each of the hook's asks, in place of {@link HookExtension.onEvent}. The return value (a promise is awaited) is the
|
|
781
|
+
* answer, and `undefined`, or a value JSON can't encode, answers null. `signal` aborts when the core stops waiting
|
|
782
|
+
* for the answer: an ask has no timeout, but one still open when the page goes away is answered null.
|
|
783
|
+
*/
|
|
784
|
+
onAsk?(event: E, signal: AbortSignal): unknown;
|
|
774
785
|
};
|
|
775
786
|
|
|
776
787
|
/**
|
|
@@ -842,7 +853,7 @@ export type CodedError = Error & { code: ErrorCode };
|
|
|
842
853
|
* - `onOpenExternal`: null (the core opens nothing)
|
|
843
854
|
* - `onFileRequest`: cancel
|
|
844
855
|
* - `onPermissionRequest`: deny
|
|
845
|
-
* - an extension's `onEvent`: null
|
|
856
|
+
* - an extension's `onAsk` or `onEvent`: null
|
|
846
857
|
*
|
|
847
858
|
* The `signal` such a callback gets aborts when the core stops waiting for its answer (the page moved on, crashed or
|
|
848
859
|
* unmounted), and a late answer is dropped.
|
|
@@ -974,8 +985,9 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
|
|
|
974
985
|
* A false, null or undefined entry is left out, so `on && extension(…)` switches one on and off; see
|
|
975
986
|
* {@link HookExtension.options} for what off means. A hook attaches when its key first appears, and a later change of
|
|
976
987
|
* its `options` reaches it live, without recreating the WebView. A key turned on after the WebView was created
|
|
977
|
-
* attaches its hook then, unless the hook
|
|
978
|
-
*
|
|
988
|
+
* attaches its hook then, unless the hook attaches only to a WebView mounted with its key on, and a warning says so.
|
|
989
|
+
* The [guide's Lifecycle table](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/#lifecycle)
|
|
990
|
+
* says which hooks do.
|
|
979
991
|
* @see [Native hooks guide](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/)
|
|
980
992
|
*/
|
|
981
993
|
extensions?: readonly (HookExtension | false | null | undefined)[];
|
|
@@ -1102,7 +1114,8 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
|
|
|
1102
1114
|
/**
|
|
1103
1115
|
* The renderer died; see {@link ProcessGoneEvent} for the recovery.
|
|
1104
1116
|
*
|
|
1105
|
-
* Android's WebViews share one renderer, so each of them reports its death.
|
|
1117
|
+
* Android's WebViews share one renderer, so each of them reports its death. On Android it comes before the
|
|
1118
|
+
* {@link WebViewProps.onLoadEnd | onLoadEnd} that fails a load the crash cut off after it committed.
|
|
1106
1119
|
*/
|
|
1107
1120
|
onProcessGone?: (event: ProcessGoneEvent) => void;
|
|
1108
1121
|
/** {@link NavigationState.loading | loading} went true. */
|