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
package/build/bridge/origins.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
// The origin rules in RN: parser, the guard that createBridge and injectedScripts put around page code, and the
|
|
2
|
-
// matcher whose text build-page-client.mts cuts out as MATCHES_ORIGIN for that guard.
|
|
3
1
|
import { MATCHES_ORIGIN } from './pageClient.generated';
|
|
4
2
|
/**
|
|
5
3
|
* An origin rule (`http(s)://host[:port]`, `http(s)://*.host[:port]`) or a `location.origin`, parsed; null for anything
|
|
6
|
-
* else, `*` included.
|
|
4
|
+
* else, `*` included.
|
|
7
5
|
*/
|
|
8
6
|
export const parseOrigin = (text) => {
|
|
9
7
|
const m = /^(https?):\/\/(\*\.(?!\[))?([a-z0-9_-]+(?:\.[a-z0-9_-]+)*|\[[0-9a-f:.]+\])(?::(\d{1,5}))?$/.exec(text.toLowerCase());
|
|
@@ -15,7 +13,6 @@ export const parseOrigin = (text) => {
|
|
|
15
13
|
const portSuffix = isDefaultPort ? '' : `:${+port}`;
|
|
16
14
|
return { scheme, wildcard: !!wildcard, hostPort: `${host}${portSuffix}` };
|
|
17
15
|
};
|
|
18
|
-
/** `rules` in the form `matchesOrigin` compares; a rule `parseOrigin` rejects is left out, so it matches nothing. */
|
|
19
16
|
export const originForms = (rules) => {
|
|
20
17
|
const forms = { any: rules.includes('*'), exact: [], wild: [] };
|
|
21
18
|
for (const rule of rules) {
|
|
@@ -29,32 +26,6 @@ export const originForms = (rules) => {
|
|
|
29
26
|
}
|
|
30
27
|
return forms;
|
|
31
28
|
};
|
|
32
|
-
function hasAt(text, part, at) {
|
|
33
|
-
for (let k = 0; k < part.length; k++)
|
|
34
|
-
if (text[at + k] !== part[k])
|
|
35
|
-
return false;
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Whether `origin`, as `location.origin` serializes it, matches `forms`. Only `===`, indexing and `length`, no
|
|
40
|
-
* built-in method: it runs at document start in frames whose built-ins another same-origin frame may have patched.
|
|
41
|
-
*/
|
|
42
|
-
export function matchesOrigin(forms, origin) {
|
|
43
|
-
if (forms.any)
|
|
44
|
-
return true;
|
|
45
|
-
for (let i = 0; i < forms.exact.length; i++)
|
|
46
|
-
if (forms.exact[i] === origin)
|
|
47
|
-
return true;
|
|
48
|
-
for (let i = 0; i < forms.wild.length; i++) {
|
|
49
|
-
const prefix = forms.wild[i][0];
|
|
50
|
-
const suffix = forms.wild[i][1];
|
|
51
|
-
const start = origin.length - suffix.length;
|
|
52
|
-
// At least one character of subdomain between the two.
|
|
53
|
-
if (start > prefix.length && hasAt(origin, prefix, 0) && hasAt(origin, suffix, start))
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
29
|
/**
|
|
59
30
|
* A page-side expression true where `location.origin` matches `origins`, or null when they include `*`. Throws an
|
|
60
31
|
* `Error` starting with `what` for a rule that is neither `*` nor what `parseOrigin` takes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origins.js","sourceRoot":"","sources":["../../src/bridge/origins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"origins.js","sourceRoot":"","sources":["../../src/bridge/origins.ts"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AE,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;;YACjE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAiB;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,8DAA8D,CACjG,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,cAAc,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,oBAAoB,CAAC;AAC7F,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const PAGE_CLIENT = "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',
|
|
1
|
+
export declare const PAGE_CLIENT = "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}";
|
|
2
2
|
export declare const MATCHES_ORIGIN = "(() => {\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})()";
|
|
3
3
|
//# sourceMappingURL=pageClient.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageClient.generated.d.ts","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"pageClient.generated.d.ts","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,s5KAC63K,CAAC;AACt5K,eAAO,MAAM,cAAc,yuBAC6sB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by .github/scripts/build-page-client.mts from pageClient.ts, endpoint.ts and
|
|
2
|
-
export const PAGE_CLIENT = "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',
|
|
1
|
+
// Generated by .github/scripts/build-page-client.mts from pageClient.ts, endpoint.ts and matchesOrigin.ts. Do not edit.
|
|
2
|
+
export const PAGE_CLIENT = "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}";
|
|
3
3
|
export const MATCHES_ORIGIN = "(() => {\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})()";
|
|
4
4
|
//# sourceMappingURL=pageClient.generated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageClient.generated.js","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"pageClient.generated.js","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,MAAM,CAAC,MAAM,WAAW,GACtB,m5KAAm5K,CAAC;AACt5K,MAAM,CAAC,MAAM,cAAc,GACzB,suBAAsuB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** The codes a bridge call rejects with: the page may send only these. */
|
|
2
1
|
declare const ERROR_CODES: readonly ["timeout", "not_found", "handler_error", "navigated", "unavailable"];
|
|
3
2
|
export type BridgeErrorCode = (typeof ERROR_CODES)[number];
|
|
4
3
|
/**
|
|
@@ -6,13 +5,12 @@ export type BridgeErrorCode = (typeof ERROR_CODES)[number];
|
|
|
6
5
|
* events for the page until then (native can't deliver before the page has posted). A page's own calls and their
|
|
7
6
|
* answers don't wait for it.
|
|
8
7
|
* `call` / `result` / `error`: a request and its answer, matched by `id`.
|
|
9
|
-
* `event`: fire-and-forget
|
|
8
|
+
* `event`: fire-and-forget.
|
|
10
9
|
*
|
|
11
10
|
* `doc` is the page document's random token. Each side puts a token on every message (RN the token of the document it
|
|
12
11
|
* means), and the page drops any message that isn't for it: native delivers to whatever document is current (iOS
|
|
13
12
|
* checks only the origin), so a message posted as a same-origin navigation commits would otherwise reach the new page.
|
|
14
|
-
* It is for correctness, not security: an allowed page can rebind its own client.
|
|
15
|
-
* `send` adds it.
|
|
13
|
+
* It is for correctness, not security: an allowed page can rebind its own client.
|
|
16
14
|
*/
|
|
17
15
|
export type BridgeMessage = {
|
|
18
16
|
doc?: string;
|
|
@@ -36,7 +34,7 @@ export type BridgeMessage = {
|
|
|
36
34
|
};
|
|
37
35
|
} | {
|
|
38
36
|
kind: 'event';
|
|
39
|
-
|
|
37
|
+
event: string;
|
|
40
38
|
params?: unknown;
|
|
41
39
|
});
|
|
42
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,gFAMwB,CAAC;AAC1C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,CAC3C;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAChF;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CACrD,CAAC;AAKF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAc1F"}
|
package/build/bridge/protocol.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** The codes a bridge call rejects with: the page may send only these. */
|
|
2
1
|
const ERROR_CODES = [
|
|
3
2
|
'timeout',
|
|
4
3
|
'not_found',
|
|
@@ -21,32 +20,31 @@ export function parseBridgeMessage(raw) {
|
|
|
21
20
|
}
|
|
22
21
|
if (!isObject(value) || typeof value['doc'] !== 'string')
|
|
23
22
|
return 'missing doc';
|
|
24
|
-
|
|
23
|
+
const problem = kindProblem(value);
|
|
24
|
+
if (problem)
|
|
25
|
+
return problem;
|
|
26
|
+
const message = value;
|
|
27
|
+
return message.kind === 'error' && !ERROR_CODES.includes(message.error.code)
|
|
28
|
+
? { ...message, error: { ...message.error, code: 'handler_error' } }
|
|
29
|
+
: message;
|
|
25
30
|
}
|
|
31
|
+
const isName = (value) => typeof value === 'string' && value !== '';
|
|
26
32
|
function kindProblem(value) {
|
|
27
33
|
const hasId = typeof value['id'] === 'string';
|
|
28
|
-
const hasMethod = typeof value['method'] === 'string' && value['method'] !== '';
|
|
29
34
|
switch (value['kind']) {
|
|
30
35
|
case 'ready':
|
|
31
36
|
return null;
|
|
32
37
|
case 'event':
|
|
33
|
-
return
|
|
38
|
+
return isName(value['event']) ? null : 'missing event';
|
|
34
39
|
case 'call':
|
|
35
|
-
return hasId &&
|
|
40
|
+
return hasId && isName(value['method']) ? null : 'missing id or method';
|
|
36
41
|
case 'result':
|
|
37
42
|
return hasId ? null : 'missing id';
|
|
38
43
|
case 'error':
|
|
39
|
-
return !hasId ? 'missing id' :
|
|
44
|
+
return !hasId ? 'missing id' : isError(value['error']) ? null : 'malformed error';
|
|
40
45
|
default:
|
|
41
46
|
return 'unknown kind';
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
function normalizeError(error) {
|
|
46
|
-
if (!isObject(error) || typeof error['code'] !== 'string' || typeof error['message'] !== 'string')
|
|
47
|
-
return false;
|
|
48
|
-
if (!ERROR_CODES.includes(error['code']))
|
|
49
|
-
error['code'] = 'handler_error';
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
49
|
+
const isError = (error) => isObject(error) && typeof error['code'] === 'string' && typeof error['message'] === 'string';
|
|
52
50
|
//# sourceMappingURL=protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG;IAClB,SAAS;IACT,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;CAC0B,CAAC;AAuB1C,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC;IAC/E,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,OAAO,GAAG,KAAwC,CAAC;IACzD,OAAO,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;QAC1E,CAAC,C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package/build/index.d.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/build/index.js
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
|
|
@@ -12,11 +12,6 @@ import type { NavigationRule } from './types';
|
|
|
12
12
|
* @group Navigation
|
|
13
13
|
*/
|
|
14
14
|
export declare const defaultNavigationRules: readonly NavigationRule[];
|
|
15
|
-
/**
|
|
16
|
-
* The rules as the core gets them, and a warning for each malformed one. The core skips an unknown key and a
|
|
17
|
-
* non-boolean flag, which would widen a rule (`hosts` would match every host), so a malformed rule becomes a `block`
|
|
18
|
-
* one. The same array when none is malformed.
|
|
19
|
-
*/
|
|
20
15
|
export declare function checkNavigationRules(given: unknown): {
|
|
21
16
|
checked: NavigationRule[];
|
|
22
17
|
warnings: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationRules.d.ts","sourceRoot":"","sources":["../src/navigationRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,cAAc,EAI1D,CAAC;
|
|
1
|
+
{"version":3,"file":"navigationRules.d.ts","sourceRoot":"","sources":["../src/navigationRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,cAAc,EAI1D,CAAC;AA4DH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG;IACpD,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAkBA"}
|
package/build/navigationRules.js
CHANGED
|
@@ -19,7 +19,6 @@ export const defaultNavigationRules = freeze([
|
|
|
19
19
|
{ scheme: ['http', 'https'], action: 'allow' },
|
|
20
20
|
{ mainFrame: true, userInitiated: true, action: 'external' },
|
|
21
21
|
]);
|
|
22
|
-
/** Each rule field's kind, from its type, so that a field missing here, or not in the type, fails to compile. */
|
|
23
22
|
const RULE_FIELDS = new Map(Object.entries({
|
|
24
23
|
scheme: 'list',
|
|
25
24
|
host: 'list',
|
|
@@ -36,17 +35,14 @@ const ACTIONS = Object.keys({
|
|
|
36
35
|
external: 0,
|
|
37
36
|
ask: 0,
|
|
38
37
|
});
|
|
39
|
-
/** A value as a warning shows it. */
|
|
40
38
|
const shown = (value) => {
|
|
41
39
|
try {
|
|
42
40
|
return JSON.stringify(value) ?? String(value);
|
|
43
41
|
}
|
|
44
42
|
catch {
|
|
45
|
-
// A BigInt, a circular value or a throwing toJSON: the message runs in production too, so it must not throw.
|
|
46
43
|
return typeof value === 'bigint' ? String(value) : Object.prototype.toString.call(value);
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
/** What a field of each kind takes, as a warning says it, and the check. */
|
|
50
46
|
const FIELD_KINDS = {
|
|
51
47
|
list: {
|
|
52
48
|
takes: 'an array of strings',
|
|
@@ -55,24 +51,19 @@ const FIELD_KINDS = {
|
|
|
55
51
|
flag: { takes: 'true or false', ok: (value) => typeof value === 'boolean' },
|
|
56
52
|
action: { takes: `one of ${shown(ACTIONS)}`, ok: (value) => ACTIONS.includes(value) },
|
|
57
53
|
};
|
|
54
|
+
const REQUIRED_FIELDS_UNSET = { action: undefined };
|
|
58
55
|
function ruleProblem(rule) {
|
|
59
56
|
if (typeof rule !== 'object' || rule === null)
|
|
60
57
|
return `must be an object, not ${shown(rule)}`;
|
|
61
|
-
|
|
62
|
-
for (const [key, value] of Object.entries({ action: undefined, ...rule })) {
|
|
58
|
+
for (const [key, value] of Object.entries({ ...REQUIRED_FIELDS_UNSET, ...rule })) {
|
|
63
59
|
const kind = RULE_FIELDS.get(key);
|
|
64
60
|
if (!kind)
|
|
65
61
|
return `unknown key ${shown(key)}`;
|
|
66
|
-
if ((value !== undefined ||
|
|
62
|
+
if ((value !== undefined || key in REQUIRED_FIELDS_UNSET) && !FIELD_KINDS[kind].ok(value))
|
|
67
63
|
return `${key} must be ${FIELD_KINDS[kind].takes}, not ${shown(value)}`;
|
|
68
64
|
}
|
|
69
65
|
return undefined;
|
|
70
66
|
}
|
|
71
|
-
/**
|
|
72
|
-
* The rules as the core gets them, and a warning for each malformed one. The core skips an unknown key and a
|
|
73
|
-
* non-boolean flag, which would widen a rule (`hosts` would match every host), so a malformed rule becomes a `block`
|
|
74
|
-
* one. The same array when none is malformed.
|
|
75
|
-
*/
|
|
76
67
|
export function checkNavigationRules(given) {
|
|
77
68
|
if (!Array.isArray(given))
|
|
78
69
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigationRules.js","sourceRoot":"","sources":["../src/navigationRules.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,CAAmB,KAAQ,EAAK,EAAE;IAC/C,MAAM,CAAC,MAAM,CAAC,KAAK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AC;IAChD,OAAO;QACL,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;YAC9B,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAa,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACrF,CAAC,CAAC,KAAK,CAAqB;QAC9B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACxC,OAAO;YACL,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,OAAO,8CAA8C,CAAC;YACnF,CAAC,CAAC,EAAE,CACP;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeWebViewDefaults.d.ts","sourceRoot":"","sources":["../src/reactNativeWebViewDefaults.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"reactNativeWebViewDefaults.d.ts","sourceRoot":"","sources":["../src/reactNativeWebViewDefaults.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;CAMgB,CAAC"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-native-webview's defaults, so that an app migrated from it behaves as before. An app sets any back through
|
|
3
|
-
* `ios` or `android`.
|
|
4
|
-
*/
|
|
5
1
|
export const REACT_NATIVE_WEBVIEW_DEFAULTS = {
|
|
6
2
|
ios: { scrollView: { directionalLockEnabled: true } },
|
|
7
3
|
android: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeWebViewDefaults.js","sourceRoot":"","sources":["../src/reactNativeWebViewDefaults.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"reactNativeWebViewDefaults.js","sourceRoot":"","sources":["../src/reactNativeWebViewDefaults.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,GAAG,EAAE,EAAE,UAAU,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAE;IACrD,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE;QAC/D,OAAO,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE;KAC3C;CACuD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeWebViewMessages.d.ts","sourceRoot":"","sources":["../src/reactNativeWebViewMessages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,EAAE,
|
|
1
|
+
{"version":3,"file":"reactNativeWebViewMessages.d.ts","sourceRoot":"","sources":["../src/reactNativeWebViewMessages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,EAAE,cAOxC,CAAC"}
|
|
@@ -13,7 +13,6 @@ import { Platform } from 'react-native';
|
|
|
13
13
|
* @group Scripts
|
|
14
14
|
*/
|
|
15
15
|
export const reactNativeWebViewMessages = {
|
|
16
|
-
// Runs after the bridge's own script, so `window.nativeBridge` already exists where the bridge is installed.
|
|
17
16
|
code: `if (window.nativeBridge) {
|
|
18
17
|
window.ReactNativeWebView = { postMessage: (data) => window.nativeBridge.emit('rnw', String(data)) };
|
|
19
18
|
window.nativeBridge.on('rnw', (data) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeWebViewMessages.js","sourceRoot":"","sources":["../src/reactNativeWebViewMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAmB;IACxD,
|
|
1
|
+
{"version":3,"file":"reactNativeWebViewMessages.js","sourceRoot":"","sources":["../src/reactNativeWebViewMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAmB;IACxD,IAAI,EAAE;;;MAGF,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;EACjD;IACA,OAAO,EAAE,CAAC,GAAG,CAAC;CACf,CAAC"}
|
package/build/refStore.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ import type { NavigationState, WebViewRef, WebViewRefObject } from './types';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function createWebViewRef(): WebViewRefObject;
|
|
10
10
|
/**
|
|
11
|
-
* Attaches `handle` to `ref`. A callback or plain ref gets it through `useImperativeHandle`; a `createWebViewRef` ref
|
|
12
|
-
* serves it as its own `current`. Any ref object also gets the navigation state through its adapter.
|
|
13
11
|
* Returns a function that records a new state, passes it to the attached ref and returns the previous state.
|
|
14
12
|
*/
|
|
15
13
|
export declare function useAttach(ref: Ref<WebViewRef> | undefined, handle: WebViewRef): (state: NavigationState) => NavigationState;
|
package/build/refStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refStore.d.ts","sourceRoot":"","sources":["../src/refStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"refStore.d.ts","sourceRoot":"","sources":["../src/refStore.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAoE7E;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAInD;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,SAAS,EAChC,MAAM,EAAE,UAAU,GACjB,CAAC,KAAK,EAAE,eAAe,KAAK,eAAe,CAe7C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,eAAe,CAAC;AACpF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,EACjC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,CAAC,GACpC,CAAC,CAAC"}
|
package/build/refStore.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useImperativeHandle, useLayoutEffect, useMemo, useRef, useSyncExternalStore, } from 'react';
|
|
2
|
-
/** An empty `url`, so a stale URL never looks valid while no WebView is mounted. */
|
|
3
2
|
const INITIAL_STATE = {
|
|
4
3
|
url: '',
|
|
5
4
|
pendingUrl: null,
|
|
@@ -10,7 +9,6 @@ const INITIAL_STATE = {
|
|
|
10
9
|
canGoForward: false,
|
|
11
10
|
outcome: null,
|
|
12
11
|
};
|
|
13
|
-
/** The navigation object behind each ref object: created by createWebViewRef, or made on first use for a plain ref. */
|
|
14
12
|
const adapters = new WeakMap();
|
|
15
13
|
function adapterFor(ref) {
|
|
16
14
|
let adapter = adapters.get(ref);
|
|
@@ -38,7 +36,6 @@ function createAdapter() {
|
|
|
38
36
|
};
|
|
39
37
|
return {
|
|
40
38
|
nav,
|
|
41
|
-
// Last attached wins, like a React ref; an earlier instance's later updates and detach are ignored.
|
|
42
39
|
attach(handle, initial) {
|
|
43
40
|
if (__DEV__ && attached) {
|
|
44
41
|
console.warn('[react-native-minimal-webview] This ref is already attached to a mounted WebView; the new one replaces it. Give each WebView its own ref.');
|
|
@@ -70,8 +67,6 @@ export function createWebViewRef() {
|
|
|
70
67
|
return adapter.nav;
|
|
71
68
|
}
|
|
72
69
|
/**
|
|
73
|
-
* Attaches `handle` to `ref`. A callback or plain ref gets it through `useImperativeHandle`; a `createWebViewRef` ref
|
|
74
|
-
* serves it as its own `current`. Any ref object also gets the navigation state through its adapter.
|
|
75
70
|
* Returns a function that records a new state, passes it to the attached ref and returns the previous state.
|
|
76
71
|
*/
|
|
77
72
|
export function useAttach(ref, handle) {
|
|
@@ -96,7 +91,6 @@ export function useWebViewState(ref, select) {
|
|
|
96
91
|
const getSnapshot = useMemo(() => (select ? selectFrom(nav.getState, select) : nav.getState), [nav, select]);
|
|
97
92
|
return useSyncExternalStore(nav.subscribe, getSnapshot);
|
|
98
93
|
}
|
|
99
|
-
/** `select` of the current state, run again only for another state: a snapshot is the same value until a change. */
|
|
100
94
|
function selectFrom(getState, select) {
|
|
101
95
|
let last;
|
|
102
96
|
return () => {
|
package/build/refStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refStore.js","sourceRoot":"","sources":["../src/refStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAIf,
|
|
1
|
+
{"version":3,"file":"refStore.js","sourceRoot":"","sources":["../src/refStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAIf,MAAM,aAAa,GAAoB;IACrC,GAAG,EAAE,EAAE;IACP,U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;IACtC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC;AAqBD,MAAM,UAAU,eAAe,CAC7B,GAAiC,EACjC,MAAsC;IAEtC,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,OAAO,CACzB,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAChE,CAAC,GAAG,EAAE,MAAM,CAAC,CACd,CAAC;IACF,OAAO,oBAAoB,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,UAAU,CAAI,QAA+B,EAAE,MAAqC;IAC3F,IAAI,IAAyD,CAAC;IAC9D,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QACzB,IAAI,IAAI,EAAE,KAAK,KAAK,KAAK;YAAE,IAAI,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACrE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
package/build/types.d.ts
CHANGED
|
@@ -514,8 +514,11 @@ export type Download = {
|
|
|
514
514
|
* - `network`: connecting or reading the response failed, or a redirect was refused.
|
|
515
515
|
* - `http`: the response had an error status (Android only: iOS saves what the server sent).
|
|
516
516
|
* - `data` (the content): a bad `data:` or `blob:` URL, the page not reading its blob, an unsupported scheme, or
|
|
517
|
-
* (Android) a file above 100
|
|
517
|
+
* (Android) a file above 100 MiB or a `blob:` URL the main frame can't read (a cross-origin iframe's, or one already
|
|
518
518
|
* revoked).
|
|
519
|
+
*
|
|
520
|
+
* On Android a disk error while saving, such as a full disk, is `network` for an http(s) download and `data` for a
|
|
521
|
+
* `data:` or `blob:` one.
|
|
519
522
|
* @group Page requests
|
|
520
523
|
*/
|
|
521
524
|
export type DownloadFailure = {
|
|
@@ -593,7 +596,9 @@ export type IOSPrivateSettingKeys = {
|
|
|
593
596
|
* `webView.opaque`, is skipped the same way: set it with `call('webView.setOpaque:', [false])`.
|
|
594
597
|
*
|
|
595
598
|
* A root's default keys are the package's, and yours go over them. A key the package doesn't set keeps WebKit's
|
|
596
|
-
* default; a key you remove goes back to the value it had before you first set it.
|
|
599
|
+
* default; a key you remove goes back to the value it had before you first set it. For
|
|
600
|
+
* `webView.underPageBackgroundColor`, which WebKit derives from the page, that value is the color derived then, and it
|
|
601
|
+
* stays: set the key to `null` instead of removing it to go back to WebKit's default.
|
|
597
602
|
*
|
|
598
603
|
* WebKit has no mixed-content setting: it applies its own policy.
|
|
599
604
|
* @ios
|
|
@@ -694,7 +699,8 @@ export type HookEvent<N extends string = string, P = Record<string, unknown>> =
|
|
|
694
699
|
*
|
|
695
700
|
* A package with a native hook exports a function that returns one, so that an app turns the hook on by putting it in
|
|
696
701
|
* `extensions`.
|
|
697
|
-
* @typeParam E - The hook's events, to type `onEvent`: a union of {@link HookEvent}s, which nothing checks
|
|
702
|
+
* @typeParam E - The hook's events, to type `onEvent` and `onAsk`: a union of {@link HookEvent}s, which nothing checks
|
|
703
|
+
* at runtime.
|
|
698
704
|
* @see [Native hooks guide](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/)
|
|
699
705
|
* @group Native hooks
|
|
700
706
|
*/
|
|
@@ -714,14 +720,19 @@ export type HookExtension<E extends HookEvent = HookEvent> = {
|
|
|
714
720
|
*/
|
|
715
721
|
options?: unknown;
|
|
716
722
|
/**
|
|
717
|
-
* Each of the hook's events: it goes to the extension with the hook's key, and one no extension owns is dropped.
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
* no timeout, but one still open when the page goes away is answered null.
|
|
723
|
+
* Each of the hook's events: it goes to the extension with the hook's key, and one no extension owns is dropped. An
|
|
724
|
+
* `ask` goes to {@link HookExtension.onAsk} instead when the extension has one; without it, an `ask` comes here with
|
|
725
|
+
* `signal` set, and the return value is the answer as `onAsk` describes. `signal` is undefined for an `emit`.
|
|
721
726
|
*
|
|
722
|
-
* The latest `onEvent` always
|
|
727
|
+
* The latest `onEvent` and `onAsk` always take the events: a render with new handlers sends the core nothing.
|
|
723
728
|
*/
|
|
724
729
|
onEvent?(event: E, signal?: AbortSignal): unknown;
|
|
730
|
+
/**
|
|
731
|
+
* Each of the hook's asks, in place of {@link HookExtension.onEvent}. The return value (a promise is awaited) is the
|
|
732
|
+
* answer, and `undefined`, or a value JSON can't encode, answers null. `signal` aborts when the core stops waiting
|
|
733
|
+
* for the answer: an ask has no timeout, but one still open when the page goes away is answered null.
|
|
734
|
+
*/
|
|
735
|
+
onAsk?(event: E, signal: AbortSignal): unknown;
|
|
725
736
|
};
|
|
726
737
|
/**
|
|
727
738
|
* A fullscreen change, for `onFullscreenChange`.
|
|
@@ -786,7 +797,7 @@ export type CodedError = Error & {
|
|
|
786
797
|
* - `onOpenExternal`: null (the core opens nothing)
|
|
787
798
|
* - `onFileRequest`: cancel
|
|
788
799
|
* - `onPermissionRequest`: deny
|
|
789
|
-
* - an extension's `onEvent`: null
|
|
800
|
+
* - an extension's `onAsk` or `onEvent`: null
|
|
790
801
|
*
|
|
791
802
|
* The `signal` such a callback gets aborts when the core stops waiting for its answer (the page moved on, crashed or
|
|
792
803
|
* unmounted), and a late answer is dropped.
|
|
@@ -912,8 +923,9 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
|
|
|
912
923
|
* A false, null or undefined entry is left out, so `on && extension(…)` switches one on and off; see
|
|
913
924
|
* {@link HookExtension.options} for what off means. A hook attaches when its key first appears, and a later change of
|
|
914
925
|
* its `options` reaches it live, without recreating the WebView. A key turned on after the WebView was created
|
|
915
|
-
* attaches its hook then, unless the hook
|
|
916
|
-
*
|
|
926
|
+
* attaches its hook then, unless the hook attaches only to a WebView mounted with its key on, and a warning says so.
|
|
927
|
+
* The [guide's Lifecycle table](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/#lifecycle)
|
|
928
|
+
* says which hooks do.
|
|
917
929
|
* @see [Native hooks guide](https://rasmuskard.github.io/react-native-minimal-webview/guides/native-hooks/)
|
|
918
930
|
*/
|
|
919
931
|
extensions?: readonly (HookExtension | false | null | undefined)[];
|
|
@@ -1034,7 +1046,8 @@ export interface WebViewProps extends Omit<ViewProps, 'children'> {
|
|
|
1034
1046
|
/**
|
|
1035
1047
|
* The renderer died; see {@link ProcessGoneEvent} for the recovery.
|
|
1036
1048
|
*
|
|
1037
|
-
* Android's WebViews share one renderer, so each of them reports its death.
|
|
1049
|
+
* Android's WebViews share one renderer, so each of them reports its death. On Android it comes before the
|
|
1050
|
+
* {@link WebViewProps.onLoadEnd | onLoadEnd} that fails a load the crash cut off after it committed.
|
|
1038
1051
|
*/
|
|
1039
1052
|
onProcessGone?: (event: ProcessGoneEvent) => void;
|
|
1040
1053
|
/** {@link NavigationState.loading | loading} went true. */
|