react-native-minimal-webview 0.0.0-stage → 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 (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -2
  3. package/android/build.gradle +26 -0
  4. package/android/consumer-rules.pro +4 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/expo/modules/minimalwebview/Asks.kt +44 -0
  7. package/android/src/main/java/expo/modules/minimalwebview/DocumentEnd.kt +31 -0
  8. package/android/src/main/java/expo/modules/minimalwebview/Hooks.kt +487 -0
  9. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebView.kt +507 -0
  10. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewClients.kt +358 -0
  11. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewModule.kt +245 -0
  12. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewNavigation.kt +199 -0
  13. package/android/src/main/java/expo/modules/minimalwebview/MinimalWebViewScripts.kt +197 -0
  14. package/android/src/main/java/expo/modules/minimalwebview/NavigationRules.kt +113 -0
  15. package/android/src/main/java/expo/modules/minimalwebview/PlatformSettings.kt +303 -0
  16. package/android/src/main/java/expo/modules/minimalwebview/PullToRefresh.kt +76 -0
  17. package/android/src/main/java/expo/modules/minimalwebview/requests/Downloads.kt +259 -0
  18. package/android/src/main/java/expo/modules/minimalwebview/requests/FileUpload.kt +44 -0
  19. package/android/src/main/java/expo/modules/minimalwebview/requests/FullscreenVideo.kt +87 -0
  20. package/android/src/main/java/expo/modules/minimalwebview/requests/Permissions.kt +77 -0
  21. package/build/WebView.d.ts +96 -0
  22. package/build/WebView.d.ts.map +1 -0
  23. package/build/WebView.js +453 -0
  24. package/build/WebView.js.map +1 -0
  25. package/build/bridge/createBridge.d.ts +32 -0
  26. package/build/bridge/createBridge.d.ts.map +1 -0
  27. package/build/bridge/createBridge.js +137 -0
  28. package/build/bridge/createBridge.js.map +1 -0
  29. package/build/bridge/endpoint.d.ts +33 -0
  30. package/build/bridge/endpoint.d.ts.map +1 -0
  31. package/build/bridge/endpoint.js +105 -0
  32. package/build/bridge/endpoint.js.map +1 -0
  33. package/build/bridge/origins.d.ts +25 -0
  34. package/build/bridge/origins.d.ts.map +1 -0
  35. package/build/bridge/origins.js +59 -0
  36. package/build/bridge/origins.js.map +1 -0
  37. package/build/bridge/pageClient.generated.d.ts +3 -0
  38. package/build/bridge/pageClient.generated.d.ts.map +1 -0
  39. package/build/bridge/pageClient.generated.js +4 -0
  40. package/build/bridge/pageClient.generated.js.map +1 -0
  41. package/build/bridge/protocol.d.ts +50 -0
  42. package/build/bridge/protocol.d.ts.map +1 -0
  43. package/build/bridge/protocol.js +52 -0
  44. package/build/bridge/protocol.js.map +1 -0
  45. package/build/defaultNavigationRules.d.ts +15 -0
  46. package/build/defaultNavigationRules.d.ts.map +1 -0
  47. package/build/defaultNavigationRules.js +22 -0
  48. package/build/defaultNavigationRules.js.map +1 -0
  49. package/build/index.d.ts +31 -0
  50. package/build/index.d.ts.map +1 -0
  51. package/build/index.js +30 -0
  52. package/build/index.js.map +1 -0
  53. package/build/platform.generated.d.ts +701 -0
  54. package/build/platform.generated.d.ts.map +1 -0
  55. package/build/platform.generated.js +201 -0
  56. package/build/platform.generated.js.map +1 -0
  57. package/build/reactNativeWebViewDefaults.d.ts +21 -0
  58. package/build/reactNativeWebViewDefaults.d.ts.map +1 -0
  59. package/build/reactNativeWebViewDefaults.js +12 -0
  60. package/build/reactNativeWebViewDefaults.js.map +1 -0
  61. package/build/reactNativeWebViewMessages.d.ts +16 -0
  62. package/build/reactNativeWebViewMessages.d.ts.map +1 -0
  63. package/build/reactNativeWebViewMessages.js +24 -0
  64. package/build/reactNativeWebViewMessages.js.map +1 -0
  65. package/build/refStore.d.ts +32 -0
  66. package/build/refStore.d.ts.map +1 -0
  67. package/build/refStore.js +115 -0
  68. package/build/refStore.js.map +1 -0
  69. package/build/types.d.ts +1173 -0
  70. package/build/types.d.ts.map +1 -0
  71. package/build/types.defaults.d.ts +8 -0
  72. package/build/types.defaults.d.ts.map +1 -0
  73. package/build/types.defaults.js +17 -0
  74. package/build/types.defaults.js.map +1 -0
  75. package/build/types.js +2 -0
  76. package/build/types.js.map +1 -0
  77. package/expo-module.config.json +9 -0
  78. package/ios/Asks.swift +45 -0
  79. package/ios/DelegateProxy.swift +158 -0
  80. package/ios/DocumentEnd.swift +22 -0
  81. package/ios/DownloadName.swift +10 -0
  82. package/ios/Downloads.swift +51 -0
  83. package/ios/Hooks.swift +310 -0
  84. package/ios/Loads.swift +44 -0
  85. package/ios/MRWExceptions.h +9 -0
  86. package/ios/MRWExceptions.m +10 -0
  87. package/ios/MRWInvoke.h +38 -0
  88. package/ios/MRWInvoke.m +187 -0
  89. package/ios/MinimalWebView+Dialogs.swift +96 -0
  90. package/ios/MinimalWebView+Navigation.swift +243 -0
  91. package/ios/MinimalWebView+Scripts.swift +92 -0
  92. package/ios/MinimalWebView.docc/MinimalWebView.md +13 -0
  93. package/ios/MinimalWebView.podspec +32 -0
  94. package/ios/MinimalWebView.swift +513 -0
  95. package/ios/MinimalWebViewModule.swift +110 -0
  96. package/ios/NavigationRules.swift +123 -0
  97. package/ios/OriginRules.swift +36 -0
  98. package/ios/PlatformCompletions.generated.swift +39 -0
  99. package/ios/PlatformSettings.swift +252 -0
  100. package/ios/ReadAccess.swift +19 -0
  101. package/ios/Recovery.swift +25 -0
  102. package/ios/SharedCookies.swift +59 -0
  103. package/package.json +99 -4
  104. package/src/WebView.tsx +626 -0
  105. package/src/bridge/createBridge.ts +178 -0
  106. package/src/bridge/endpoint.ts +123 -0
  107. package/src/bridge/origins.ts +61 -0
  108. package/src/bridge/pageClient.generated.ts +5 -0
  109. package/src/bridge/pageClient.ts +67 -0
  110. package/src/bridge/protocol.ts +78 -0
  111. package/src/defaultNavigationRules.ts +24 -0
  112. package/src/index.ts +37 -0
  113. package/src/platform.generated.ts +693 -0
  114. package/src/reactNativeWebViewDefaults.ts +13 -0
  115. package/src/reactNativeWebViewMessages.ts +26 -0
  116. package/src/refStore.ts +165 -0
  117. package/src/types.defaults.ts +24 -0
  118. package/src/types.ts +1240 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBridge.js","sourceRoot":"","sources":["../../src/bridge/createBridge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAiBpE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAiB;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACxC,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;AAED,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAsB;IAEtB,qFAAqF;IACrF,MAAM,KAAK,GAAG,WAAW,CAAC,sCAAsC,EAAE,OAAO,CAAC,cAAc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AAC;YACX,QAAQ,CAAC,aAAa,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW;YAC9B,IAAI,WAAW;gBACb,OAAO,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC;YAC1F,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,CAAC,UAAU,CAAC,EAAE,UAAU;KACc,CAAC,CAAC,0CAA0C;AACtF,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { ErrorCode } from '../types';
2
+ import type { BridgeErrorCode, BridgeMessage } from './protocol';
3
+ type Pending = {
4
+ resolve(value: unknown): void;
5
+ reject(error: Error): void;
6
+ timer: ReturnType<typeof setTimeout> | undefined;
7
+ /** Posted to a document, not just queued for the next one (RN). */
8
+ sent: boolean;
9
+ };
10
+ /** A `CodedError` (types.ts): what a ref method or bridge call rejects with. */
11
+ export declare const codedError: ({ code, message }: {
12
+ code: ErrorCode;
13
+ message: string;
14
+ }) => Error & {
15
+ code: ErrorCode;
16
+ };
17
+ /**
18
+ * `send` posts a message to the other side; ids get `idPrefix`, so the two sides' calls never share an id. `Sender` is
19
+ * what handlers and listeners get beside the params: RN's `{ origin }`, nothing in the page.
20
+ */
21
+ export declare function createEndpoint<Sender = void>(send: (message: BridgeMessage) => void, timeoutMs: number, idPrefix: string): {
22
+ pending: Map<string, Pending>;
23
+ call(method: string, params?: unknown, options?: {
24
+ timeoutMs?: number;
25
+ }): Promise<unknown>;
26
+ emit(event: string, payload?: unknown): void;
27
+ handle(method: string, handler: (params: unknown, sender: Sender) => unknown): () => void;
28
+ on(event: string, listener: (payload: unknown, sender: Sender) => void): () => boolean;
29
+ rejectPending(code: BridgeErrorCode, message: string, only?: (call: Pending) => boolean): void;
30
+ receive(message: BridgeMessage, reply: (message: BridgeMessage) => void, sender: Sender): Promise<void>;
31
+ };
32
+ export {};
33
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/bridge/endpoint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjE,KAAK,OAAO,GAAG;IACb,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IACjD,mEAAmE;IACnE,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,UAAU,GAAI,mBAAmB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;CACrC,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAG,IAAI,EAC1C,IAAI,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,EACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM;;iBASD,MAAM,WAAW,OAAO,YAAY;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;gBA6B3D,MAAM,YAAY,OAAO;mBAGtB,MAAM,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO;cAMlE,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;wBAKlD,eAAe,WAAW,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO;qBAQhE,aAAa,SAAS,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,UAAU,MAAM;EAqChG"}
@@ -0,0 +1,105 @@
1
+ /** A `CodedError` (types.ts): what a ref method or bridge call rejects with. */
2
+ export const codedError = ({ code, message }) => Object.assign(new Error(message), { code });
3
+ /**
4
+ * `send` posts a message to the other side; ids get `idPrefix`, so the two sides' calls never share an id. `Sender` is
5
+ * what handlers and listeners get beside the params: RN's `{ origin }`, nothing in the page.
6
+ */
7
+ export function createEndpoint(send, timeoutMs, idPrefix) {
8
+ const handlers = new Map();
9
+ const listeners = new Map();
10
+ const pending = new Map();
11
+ let nextId = 0;
12
+ return {
13
+ pending,
14
+ call(method, params, options) {
15
+ const ms = options?.timeoutMs ?? timeoutMs;
16
+ if (!(ms >= 0))
17
+ return Promise.reject(new RangeError(`${method}: timeoutMs must be 0 or more, not ${ms}`));
18
+ const id = `${idPrefix}${++nextId}`;
19
+ return new Promise((resolve, reject) => {
20
+ // Clamped: setTimeout fires at once for a delay above 2^31-1.
21
+ const timer = ms > 0 && ms < Infinity
22
+ ? setTimeout(() => {
23
+ pending.delete(id);
24
+ reject(codedError({ code: 'timeout', message: `${method} timed out after ${ms} ms` }));
25
+ }, Math.min(ms, 2 ** 31 - 1))
26
+ : undefined;
27
+ pending.set(id, { resolve, reject, timer, sent: false });
28
+ try {
29
+ send({ id, kind: 'call', method, params });
30
+ }
31
+ catch (error) {
32
+ clearTimeout(timer);
33
+ pending.delete(id);
34
+ throw error;
35
+ }
36
+ });
37
+ },
38
+ emit(event, payload) {
39
+ send({ kind: 'event', method: event, params: payload });
40
+ },
41
+ handle(method, handler) {
42
+ handlers.set(method, handler);
43
+ return () => {
44
+ if (handlers.get(method) === handler)
45
+ handlers.delete(method);
46
+ };
47
+ },
48
+ on(event, listener) {
49
+ const set = listeners.get(event) ?? new Set();
50
+ listeners.set(event, set.add(listener));
51
+ return () => set.delete(listener);
52
+ },
53
+ rejectPending(code, message, only) {
54
+ for (const [id, call] of pending) {
55
+ if (only && !only(call))
56
+ continue;
57
+ clearTimeout(call.timer);
58
+ call.reject(codedError({ code, message }));
59
+ pending.delete(id);
60
+ }
61
+ },
62
+ async receive(message, reply, sender) {
63
+ switch (message.kind) {
64
+ case 'call': {
65
+ const { id, method } = message;
66
+ const fail = (code, text) => reply({ id, kind: 'error', error: { code, message: text } });
67
+ const handler = handlers.get(method);
68
+ if (!handler)
69
+ return fail('not_found', `no handler for ${method}`);
70
+ try {
71
+ reply({ id, kind: 'result', value: await handler(message.params, sender) });
72
+ }
73
+ catch (error) {
74
+ fail('handler_error', error instanceof Error ? error.message : String(error));
75
+ }
76
+ return;
77
+ }
78
+ case 'event':
79
+ listeners.get(message.method)?.forEach((listener) => {
80
+ // An unhandled rejection reports the error without stopping the other listeners.
81
+ try {
82
+ listener(message.params, sender);
83
+ }
84
+ catch (error) {
85
+ void Promise.reject(error);
86
+ }
87
+ });
88
+ return;
89
+ case 'result':
90
+ case 'error': {
91
+ const call = pending.get(message.id);
92
+ if (!call)
93
+ return;
94
+ pending.delete(message.id);
95
+ clearTimeout(call.timer);
96
+ if (message.kind === 'result')
97
+ call.resolve(message.value);
98
+ else
99
+ call.reject(codedError(message.error));
100
+ }
101
+ }
102
+ },
103
+ };
104
+ }
105
+ //# sourceMappingURL=endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/bridge/endpoint.ts"],"names":[],"mappings":"AAcA,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAwC,EAAE,EAAE,CACpF,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9C;;;GAGG;AAC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AAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;wBAClD,iFAAiF;wBACjF,IAAI,CAAC;4BACH,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;wBACnC,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACf,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC7B,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO;gBACT,KAAK,QAAQ,CAAC;gBACd,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBACrC,IAAI,CAAC,IAAI;wBAAE,OAAO;oBAClB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBAC3B,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACzB,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;wBAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;;wBACtD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * An origin rule (`http(s)://host[:port]`, `http(s)://*.host[:port]`) or a `location.origin`, parsed; null for anything
3
+ * else, `*` included. OriginRules.swift matches the same way: both run src/__tests__/vectors/origin-rules.json.
4
+ */
5
+ export declare const parseOrigin: (text: string) => {
6
+ scheme: string;
7
+ wildcard: boolean;
8
+ hostPort: string;
9
+ } | null;
10
+ /** The rules that are neither `*` nor what `parseOrigin` takes. */
11
+ export declare const invalidOrigins: (rules: string[]) => string[];
12
+ /** Origin rules in `location.origin` form, for `matchesOrigin`: exact origins, and wildcards as prefix and suffix. */
13
+ export type OriginForms = {
14
+ any: boolean;
15
+ exact: string[];
16
+ wild: [string, string][];
17
+ };
18
+ /** `rules` in the form `matchesOrigin` compares; a rule `parseOrigin` rejects is left out, so it matches nothing. */
19
+ export declare const originForms: (rules: string[]) => OriginForms;
20
+ /**
21
+ * Whether `origin`, as `location.origin` serializes it, matches `forms`. Only `===`, indexing and `length`, no
22
+ * built-in method: it runs at document start in frames whose built-ins another same-origin frame may have patched.
23
+ */
24
+ export declare function matchesOrigin(forms: OriginForms, origin: string): boolean;
25
+ //# sourceMappingURL=origins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origins.d.ts","sourceRoot":"","sources":["../../src/bridge/origins.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM;;;;QAWvC,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,aACc,CAAC;AAE7D,sHAAsH;AACtH,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;CAAE,CAAC;AAEtF,qHAAqH;AACrH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,KAAG,WAS7C,CAAC;AAOF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAY/D"}
@@ -0,0 +1,59 @@
1
+ // The origin rules in RN: parser, validator, and the matcher whose text build-page-client.mts cuts out as MATCHES_ORIGIN
2
+ // for the guards that createBridge and injectedScripts put around page code.
3
+ /**
4
+ * An origin rule (`http(s)://host[:port]`, `http(s)://*.host[:port]`) or a `location.origin`, parsed; null for anything
5
+ * else, `*` included. OriginRules.swift matches the same way: both run src/__tests__/vectors/origin-rules.json.
6
+ */
7
+ export const parseOrigin = (text) => {
8
+ const m = /^(https?):\/\/(\*\.(?!\[))?([a-z0-9_-]+(?:\.[a-z0-9_-]+)*|\[[0-9a-f:.]+\])(?::(\d{1,5}))?$/.exec(text.toLowerCase());
9
+ if (!m)
10
+ return null;
11
+ const [, scheme, wildcard, host, port] = m;
12
+ // `location.origin` leaves out the scheme's default port.
13
+ const isDefaultPort = port === undefined || +port === (scheme === 'https' ? 443 : 80);
14
+ const portSuffix = isDefaultPort ? '' : `:${+port}`;
15
+ return { scheme, wildcard: !!wildcard, hostPort: `${host}${portSuffix}` };
16
+ };
17
+ /** The rules that are neither `*` nor what `parseOrigin` takes. */
18
+ export const invalidOrigins = (rules) => rules.filter((rule) => rule !== '*' && !parseOrigin(rule));
19
+ /** `rules` in the form `matchesOrigin` compares; a rule `parseOrigin` rejects is left out, so it matches nothing. */
20
+ export const originForms = (rules) => {
21
+ const forms = { any: rules.includes('*'), exact: [], wild: [] };
22
+ for (const rule of rules) {
23
+ const r = parseOrigin(rule);
24
+ if (!r)
25
+ continue;
26
+ if (r.wildcard)
27
+ forms.wild.push([`${r.scheme}://`, `.${r.hostPort}`]);
28
+ else
29
+ forms.exact.push(`${r.scheme}://${r.hostPort}`);
30
+ }
31
+ return forms;
32
+ };
33
+ function hasAt(text, part, at) {
34
+ for (let k = 0; k < part.length; k++)
35
+ if (text[at + k] !== part[k])
36
+ return false;
37
+ return true;
38
+ }
39
+ /**
40
+ * Whether `origin`, as `location.origin` serializes it, matches `forms`. Only `===`, indexing and `length`, no
41
+ * built-in method: it runs at document start in frames whose built-ins another same-origin frame may have patched.
42
+ */
43
+ export function matchesOrigin(forms, origin) {
44
+ if (forms.any)
45
+ return true;
46
+ for (let i = 0; i < forms.exact.length; i++)
47
+ if (forms.exact[i] === origin)
48
+ 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
+ //# sourceMappingURL=origins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origins.js","sourceRoot":"","sources":["../../src/bridge/origins.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,6EAA6E;AAE7E;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE;IAC1C,MAAM,CAAC,GACL,4FAA4F,CAAC,IAAI,CAC/F,IAAI,CAAC,WAAW,EAAE,CACnB,CAAC;IACJ,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,0DAA0D;IAC1D,MAAM,aAAa,GAAG,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtF,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAK,EAAE,CAAC;IACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,UAAU,EAAE,EAAE,CAAC;AAC5E,CAAC,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAe,EAAE,EAAE,CAChD,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AAK7D,qHAAqH;AACrH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAe,EAAe,EAAE;IAC1D,MAAM,KAAK,GAAgB,EAAE,GAAG,EAAE,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AM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5C,uDAAuD;QACvD,IAAI,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;YACnF,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +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, sent: false });\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', method: 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(call))\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.method)?.forEach((listener) => {\n try {\n listener(message.params, sender);\n }\n catch (error) {\n void Promise.reject(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
+ 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
+ //# sourceMappingURL=pageClient.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageClient.generated.d.ts","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,k3KACy1K,CAAC;AACl3K,eAAO,MAAM,cAAc,yuBAC6sB,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Generated by .github/scripts/build-page-client.mts from pageClient.ts, endpoint.ts and origins.ts. Do not edit.
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, sent: false });\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', method: 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(call))\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.method)?.forEach((listener) => {\n try {\n listener(message.params, sender);\n }\n catch (error) {\n void Promise.reject(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
+ 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
+ //# sourceMappingURL=pageClient.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageClient.generated.js","sourceRoot":"","sources":["../../src/bridge/pageClient.generated.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,MAAM,CAAC,MAAM,WAAW,GACtB,+2KAA+2K,CAAC;AACl3K,MAAM,CAAC,MAAM,cAAc,GACzB,suBAAsuB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /** The codes a bridge call rejects with: the page may send only these. */
2
+ declare const ERROR_CODES: readonly ["timeout", "not_found", "handler_error", "navigated", "unavailable"];
3
+ export type BridgeErrorCode = (typeof ERROR_CODES)[number];
4
+ /**
5
+ * `ready`: the page's DOM is parsed (DOMContentLoaded), so its scripts have registered handlers. RN holds its calls and
6
+ * events for the page until then (native can't deliver before the page has posted). A page's own calls and their
7
+ * answers don't wait for it.
8
+ * `call` / `result` / `error`: a request and its answer, matched by `id`.
9
+ * `event`: fire-and-forget, `method` is the event name.
10
+ *
11
+ * `doc` is the page document's random token. Each side puts a token on every message (RN the token of the document it
12
+ * means), and the page drops any message that isn't for it: native delivers to whatever document is current (iOS
13
+ * 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. Messages are built without it;
15
+ * `send` adds it.
16
+ */
17
+ export type BridgeMessage = {
18
+ doc?: string;
19
+ } & ({
20
+ kind: 'ready';
21
+ } | {
22
+ kind: 'call';
23
+ id: string;
24
+ method: string;
25
+ params?: unknown;
26
+ } | {
27
+ kind: 'result';
28
+ id: string;
29
+ value?: unknown;
30
+ } | {
31
+ kind: 'error';
32
+ id: string;
33
+ error: {
34
+ code: BridgeErrorCode;
35
+ message: string;
36
+ };
37
+ } | {
38
+ kind: 'event';
39
+ method: string;
40
+ params?: unknown;
41
+ });
42
+ /**
43
+ * Parses a message from the page, which always carries `doc`. Returns it, or the reason it was rejected. Never throws.
44
+ * An error `code` that isn't a `BridgeErrorCode` becomes `handler_error`: the page's handler failed somehow.
45
+ */
46
+ export declare function parseBridgeMessage(raw: string): (BridgeMessage & {
47
+ doc: string;
48
+ }) | string;
49
+ export {};
50
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,QAAA,MAAM,WAAW,gFAMwB,CAAC;AAC1C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;;;;;;;GAYG;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,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CACtD,CAAC;AAKF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAS1F"}
@@ -0,0 +1,52 @@
1
+ /** The codes a bridge call rejects with: the page may send only these. */
2
+ const ERROR_CODES = [
3
+ 'timeout',
4
+ 'not_found',
5
+ 'handler_error',
6
+ 'navigated',
7
+ 'unavailable',
8
+ ];
9
+ const isObject = (value) => typeof value === 'object' && value !== null;
10
+ /**
11
+ * Parses a message from the page, which always carries `doc`. Returns it, or the reason it was rejected. Never throws.
12
+ * An error `code` that isn't a `BridgeErrorCode` becomes `handler_error`: the page's handler failed somehow.
13
+ */
14
+ export function parseBridgeMessage(raw) {
15
+ let value;
16
+ try {
17
+ value = JSON.parse(raw);
18
+ }
19
+ catch {
20
+ return 'not JSON';
21
+ }
22
+ if (!isObject(value) || typeof value['doc'] !== 'string')
23
+ return 'missing doc';
24
+ return kindProblem(value) ?? value;
25
+ }
26
+ function kindProblem(value) {
27
+ const hasId = typeof value['id'] === 'string';
28
+ const hasMethod = typeof value['method'] === 'string' && value['method'] !== '';
29
+ switch (value['kind']) {
30
+ case 'ready':
31
+ return null;
32
+ case 'event':
33
+ return hasMethod ? null : 'missing method';
34
+ case 'call':
35
+ return hasId && hasMethod ? null : 'missing id or method';
36
+ case 'result':
37
+ return hasId ? null : 'missing id';
38
+ case 'error':
39
+ return !hasId ? 'missing id' : normalizeError(value['error']) ? null : 'malformed error';
40
+ default:
41
+ return 'unknown kind';
42
+ }
43
+ }
44
+ /** Whether `error` is `{ code, message }`, both strings; an unlisted code is replaced in place. */
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
+ }
52
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/bridge/protocol.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,MAAM,WAAW,GAAG;IAClB,SAAS;IACT,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;CAC0B,CAAC;AAwB1C,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,OAAO,WAAW,CAAC,KAAK,CAAC,IAA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
@@ -0,0 +1,15 @@
1
+ import type { NavigationRule } from './types';
2
+ /**
3
+ * The rules `navigationRules` has when it is unset: `file:` is blocked, http(s) loads in place, and any other scheme
4
+ * opens externally from the main frame when a user gesture started it ({@link NavigationRule.userInitiated}).
5
+ *
6
+ * Anything else, an iframe's or one without a gesture, is blocked, so a page opens an app only right after the user's
7
+ * tap, click or key press, as each platform counts them. On iOS that leaves out the redirect after a form POST, such
8
+ * as an OAuth `myapp://callback`: an `external` rule for its scheme before these opens it.
9
+ *
10
+ * Frozen; spread it after your own rules to keep it.
11
+ * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
12
+ * @group Navigation
13
+ */
14
+ export declare const defaultNavigationRules: readonly NavigationRule[];
15
+ //# sourceMappingURL=defaultNavigationRules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultNavigationRules.d.ts","sourceRoot":"","sources":["../src/defaultNavigationRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,cAAc,EAI1D,CAAC"}
@@ -0,0 +1,22 @@
1
+ const freeze = (value) => {
2
+ Object.values(value).forEach((field) => typeof field === 'object' && freeze(field));
3
+ return Object.freeze(value);
4
+ };
5
+ /**
6
+ * The rules `navigationRules` has when it is unset: `file:` is blocked, http(s) loads in place, and any other scheme
7
+ * opens externally from the main frame when a user gesture started it ({@link NavigationRule.userInitiated}).
8
+ *
9
+ * Anything else, an iframe's or one without a gesture, is blocked, so a page opens an app only right after the user's
10
+ * tap, click or key press, as each platform counts them. On iOS that leaves out the redirect after a form POST, such
11
+ * as an OAuth `myapp://callback`: an `external` rule for its scheme before these opens it.
12
+ *
13
+ * Frozen; spread it after your own rules to keep it.
14
+ * @see [Navigation rules example](https://rasmuskard.github.io/react-native-minimal-webview/guides/examples/#navigation-rules)
15
+ * @group Navigation
16
+ */
17
+ export const defaultNavigationRules = freeze([
18
+ { scheme: ['file'], action: 'block' },
19
+ { scheme: ['http', 'https'], action: 'allow' },
20
+ { mainFrame: true, userInitiated: true, action: 'external' },
21
+ ]);
22
+ //# sourceMappingURL=defaultNavigationRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultNavigationRules.js","sourceRoot":"","sources":["../src/defaultNavigationRules.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,CAAmB,KAAQ,EAAK,EAAE;IAC/C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAe,CAAC,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA8B,MAAM,CAAmB;IACxF,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;IACrC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE;IAC9C,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE;CAC7D,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The WebView component, with navigation rules, a bridge to the page and native hooks.
3
+ *
4
+ * @groupDescription WebView
5
+ * The component, its props and its ref.
6
+ * @groupDescription Navigation
7
+ * The navigation state, and the rules that decide what each navigation does.
8
+ * @groupDescription Events
9
+ * What `onError`, `onProcessGone` and `onFullscreenChange` receive.
10
+ * @groupDescription Bridge
11
+ * Calls and events between React Native and the page's `window.nativeBridge`.
12
+ * @groupDescription Scripts
13
+ * Scripts for `injectedScripts`, which run at document start.
14
+ * @groupDescription Page requests
15
+ * File pickers, permission prompts and downloads the page starts.
16
+ * @groupDescription Native hooks
17
+ * Turning native hooks on with the `extensions` prop, and what they send to each extension's `onEvent`.
18
+ * @groupDescription Platform settings
19
+ * WebKit, UIScrollView and Android WebView settings, set by their platform names through the `ios` and `android` props.
20
+ * @module react-native-minimal-webview
21
+ * @packageDocumentation
22
+ */
23
+ export { AndroidWebView, WebView } from './WebView';
24
+ export { createWebViewRef, useWebViewState } from './refStore';
25
+ export { createBridge } from './bridge/createBridge';
26
+ export { defaultNavigationRules } from './defaultNavigationRules';
27
+ export { reactNativeWebViewMessages } from './reactNativeWebViewMessages';
28
+ export { AndroidConstants, IOSConstants } from './platform.generated';
29
+ export type { AndroidSettingKeys, CGPoint, CGRect, CGSize, IOSSettingKeys, UIEdgeInsets, } from './platform.generated';
30
+ export * from './types';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EACV,kBAAkB,EAClB,OAAO,EACP,MAAM,EACN,MAAM,EACN,cAAc,EACd,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,cAAc,SAAS,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The WebView component, with navigation rules, a bridge to the page and native hooks.
3
+ *
4
+ * @groupDescription WebView
5
+ * The component, its props and its ref.
6
+ * @groupDescription Navigation
7
+ * The navigation state, and the rules that decide what each navigation does.
8
+ * @groupDescription Events
9
+ * What `onError`, `onProcessGone` and `onFullscreenChange` receive.
10
+ * @groupDescription Bridge
11
+ * Calls and events between React Native and the page's `window.nativeBridge`.
12
+ * @groupDescription Scripts
13
+ * Scripts for `injectedScripts`, which run at document start.
14
+ * @groupDescription Page requests
15
+ * File pickers, permission prompts and downloads the page starts.
16
+ * @groupDescription Native hooks
17
+ * Turning native hooks on with the `extensions` prop, and what they send to each extension's `onEvent`.
18
+ * @groupDescription Platform settings
19
+ * WebKit, UIScrollView and Android WebView settings, set by their platform names through the `ios` and `android` props.
20
+ * @module react-native-minimal-webview
21
+ * @packageDocumentation
22
+ */
23
+ export { AndroidWebView, WebView } from './WebView';
24
+ export { createWebViewRef, useWebViewState } from './refStore';
25
+ export { createBridge } from './bridge/createBridge';
26
+ export { defaultNavigationRules } from './defaultNavigationRules';
27
+ export { reactNativeWebViewMessages } from './reactNativeWebViewMessages';
28
+ export { AndroidConstants, IOSConstants } from './platform.generated';
29
+ export * from './types';
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAStE,cAAc,SAAS,CAAC"}