@kontextso/sdk-react-native 3.3.0-rc.6 → 3.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/src/main/java/so/kontext/react/RNKontextModuleImpl.kt +12 -9
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +529 -534
- package/dist/index.mjs +507 -472
- package/package.json +2 -2
- package/src/NativeRNKontext.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,90 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create
|
|
3
|
-
var __defProp = Object.defineProperty
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
}
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
14
|
for (let key of __getOwnPropNames(from))
|
|
14
15
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
18
|
-
})
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
17
|
}
|
|
20
|
-
return to
|
|
21
|
-
}
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod)
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
29
|
|
|
35
30
|
// src/index.ts
|
|
36
|
-
var index_exports = {}
|
|
31
|
+
var index_exports = {};
|
|
37
32
|
__export(index_exports, {
|
|
38
33
|
AdsProvider: () => AdsProvider,
|
|
39
|
-
InlineAd: () => InlineAd_default
|
|
40
|
-
})
|
|
41
|
-
module.exports = __toCommonJS(index_exports)
|
|
34
|
+
InlineAd: () => InlineAd_default
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
37
|
|
|
43
38
|
// ../sdk-common/dist/index.mjs
|
|
44
39
|
function makeIframeMessage(type, opts) {
|
|
45
|
-
const { data, code, component } = opts
|
|
46
|
-
const message = { type, data: { ...
|
|
47
|
-
return message
|
|
40
|
+
const { data, code, component } = opts;
|
|
41
|
+
const message = { type, data: { ...data || {}, code, component } };
|
|
42
|
+
return message;
|
|
48
43
|
}
|
|
49
44
|
function handleIframeMessage(handler, opts) {
|
|
50
|
-
const { origin, code, component } = opts
|
|
45
|
+
const { origin, code, component } = opts;
|
|
51
46
|
return (event) => {
|
|
52
|
-
var _a, _b
|
|
53
|
-
if (origin && event.origin !== origin) return
|
|
54
|
-
const eventCode = (_a = event.data.data) == null ? void 0 : _a.code
|
|
55
|
-
if (eventCode && code && eventCode !== code) return
|
|
56
|
-
const eventComponent = (_b = event.data.data) == null ? void 0 : _b.component
|
|
57
|
-
if (eventComponent && component && eventComponent !== component) return
|
|
58
|
-
handler(event.data)
|
|
59
|
-
}
|
|
47
|
+
var _a, _b;
|
|
48
|
+
if (origin && event.origin !== origin) return;
|
|
49
|
+
const eventCode = (_a = event.data.data) == null ? void 0 : _a.code;
|
|
50
|
+
if (eventCode && code && eventCode !== code) return;
|
|
51
|
+
const eventComponent = (_b = event.data.data) == null ? void 0 : _b.component;
|
|
52
|
+
if (eventComponent && component && eventComponent !== component) return;
|
|
53
|
+
handler(event.data);
|
|
54
|
+
};
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
// src/formats/Format.tsx
|
|
63
|
-
var import_sdk_react = require(
|
|
64
|
-
var import_react2 = require(
|
|
65
|
-
var import_react_native4 = require(
|
|
58
|
+
var import_sdk_react = require("@kontextso/sdk-react");
|
|
59
|
+
var import_react2 = require("react");
|
|
60
|
+
var import_react_native4 = require("react-native");
|
|
66
61
|
|
|
67
62
|
// src/frame-webview.tsx
|
|
68
|
-
var import_react = require(
|
|
69
|
-
var import_react_native_webview = require(
|
|
70
|
-
var import_jsx_runtime = require(
|
|
71
|
-
var FrameWebView = (0, import_react.forwardRef)(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
var import_react = require("react");
|
|
64
|
+
var import_react_native_webview = require("react-native-webview");
|
|
65
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
66
|
+
var FrameWebView = (0, import_react.forwardRef)(
|
|
67
|
+
({ iframeUrl, onMessage, style, onError, onLoad }, forwardedRef) => {
|
|
68
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
import_react_native_webview.WebView,
|
|
70
|
+
{
|
|
71
|
+
ref: forwardedRef,
|
|
72
|
+
source: {
|
|
73
|
+
uri: iframeUrl
|
|
74
|
+
},
|
|
75
|
+
onMessage,
|
|
76
|
+
style,
|
|
77
|
+
allowsInlineMediaPlayback: true,
|
|
78
|
+
mediaPlaybackRequiresUserAction: false,
|
|
79
|
+
javaScriptEnabled: true,
|
|
80
|
+
domStorageEnabled: true,
|
|
81
|
+
allowsFullscreenVideo: false,
|
|
82
|
+
originWhitelist: ["*"],
|
|
83
|
+
sharedCookiesEnabled: true,
|
|
84
|
+
thirdPartyCookiesEnabled: true,
|
|
85
|
+
injectedJavaScript: `
|
|
88
86
|
window.addEventListener("message", function(event) {
|
|
89
87
|
if (window.ReactNativeWebView && event.data) {
|
|
90
88
|
// ReactNativeWebView.postMessage only supports string data
|
|
@@ -92,140 +90,135 @@ var FrameWebView = (0, import_react.forwardRef)(({ iframeUrl, onMessage, style,
|
|
|
92
90
|
}
|
|
93
91
|
}, false);
|
|
94
92
|
`,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
onError,
|
|
94
|
+
onLoad
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
var frame_webview_default = FrameWebView;
|
|
100
100
|
|
|
101
101
|
// src/services/SkOverlay.ts
|
|
102
|
-
var import_react_native2 = require(
|
|
102
|
+
var import_react_native2 = require("react-native");
|
|
103
103
|
|
|
104
104
|
// src/NativeRNKontext.ts
|
|
105
|
-
var import_react_native = require(
|
|
106
|
-
var NativeRNKontext_default = import_react_native.TurboModuleRegistry.getEnforcing(
|
|
105
|
+
var import_react_native = require("react-native");
|
|
106
|
+
var NativeRNKontext_default = import_react_native.TurboModuleRegistry.getEnforcing("RNKontext");
|
|
107
107
|
|
|
108
108
|
// src/services/utils.ts
|
|
109
109
|
var isValidAppStoreId = (id) => {
|
|
110
|
-
return typeof id ===
|
|
111
|
-
}
|
|
110
|
+
return typeof id === "string" && /^\d+$/.test(id);
|
|
111
|
+
};
|
|
112
112
|
|
|
113
113
|
// src/services/SkOverlay.ts
|
|
114
114
|
var isValidPosition = (p) => {
|
|
115
|
-
return p ===
|
|
116
|
-
}
|
|
115
|
+
return p === "bottom" || p === "bottomRaised";
|
|
116
|
+
};
|
|
117
117
|
async function presentSKOverlay(params) {
|
|
118
|
-
if (import_react_native2.Platform.OS !==
|
|
119
|
-
return false
|
|
118
|
+
if (import_react_native2.Platform.OS !== "ios") {
|
|
119
|
+
return false;
|
|
120
120
|
}
|
|
121
|
-
let { appStoreId, position, dismissible } = params
|
|
121
|
+
let { appStoreId, position, dismissible } = params;
|
|
122
122
|
if (!isValidAppStoreId(appStoreId)) {
|
|
123
|
-
return false
|
|
123
|
+
return false;
|
|
124
124
|
}
|
|
125
125
|
if (!isValidPosition(position)) {
|
|
126
|
-
position =
|
|
126
|
+
position = "bottom";
|
|
127
127
|
}
|
|
128
|
-
if (typeof dismissible !==
|
|
129
|
-
dismissible = Boolean(dismissible)
|
|
128
|
+
if (typeof dismissible !== "boolean") {
|
|
129
|
+
dismissible = Boolean(dismissible);
|
|
130
130
|
}
|
|
131
|
-
return NativeRNKontext_default.presentSKOverlay(appStoreId, position, dismissible)
|
|
131
|
+
return NativeRNKontext_default.presentSKOverlay(appStoreId, position, dismissible);
|
|
132
132
|
}
|
|
133
133
|
async function dismissSKOverlay() {
|
|
134
|
-
if (import_react_native2.Platform.OS !==
|
|
135
|
-
return false
|
|
134
|
+
if (import_react_native2.Platform.OS !== "ios") {
|
|
135
|
+
return false;
|
|
136
136
|
}
|
|
137
|
-
return NativeRNKontext_default.dismissSKOverlay()
|
|
137
|
+
return NativeRNKontext_default.dismissSKOverlay();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// src/services/SkStoreProduct.ts
|
|
141
|
-
var import_react_native3 = require(
|
|
141
|
+
var import_react_native3 = require("react-native");
|
|
142
142
|
async function presentSKStoreProduct(appStoreId) {
|
|
143
|
-
if (import_react_native3.Platform.OS !==
|
|
144
|
-
return false
|
|
143
|
+
if (import_react_native3.Platform.OS !== "ios") {
|
|
144
|
+
return false;
|
|
145
145
|
}
|
|
146
146
|
if (!isValidAppStoreId(appStoreId)) {
|
|
147
|
-
return false
|
|
147
|
+
return false;
|
|
148
148
|
}
|
|
149
|
-
return NativeRNKontext_default.presentSKStoreProduct(appStoreId)
|
|
149
|
+
return NativeRNKontext_default.presentSKStoreProduct(appStoreId);
|
|
150
150
|
}
|
|
151
151
|
async function dismissSKStoreProduct() {
|
|
152
|
-
if (import_react_native3.Platform.OS !==
|
|
153
|
-
return false
|
|
152
|
+
if (import_react_native3.Platform.OS !== "ios") {
|
|
153
|
+
return false;
|
|
154
154
|
}
|
|
155
|
-
return NativeRNKontext_default.dismissSKStoreProduct()
|
|
155
|
+
return NativeRNKontext_default.dismissSKStoreProduct();
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// src/formats/Format.tsx
|
|
159
|
-
var import_jsx_runtime2 = require(
|
|
159
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
160
160
|
var sendMessage = (webViewRef, type, code, data) => {
|
|
161
161
|
const message = makeIframeMessage(type, {
|
|
162
162
|
data,
|
|
163
|
-
code
|
|
164
|
-
})
|
|
163
|
+
code
|
|
164
|
+
});
|
|
165
165
|
webViewRef.current?.injectJavaScript(`
|
|
166
166
|
window.dispatchEvent(new MessageEvent('message', {
|
|
167
167
|
data: ${JSON.stringify(message)}
|
|
168
168
|
}));
|
|
169
|
-
`)
|
|
170
|
-
}
|
|
169
|
+
`);
|
|
170
|
+
};
|
|
171
171
|
var getCachedContent = (context, bidId) => {
|
|
172
172
|
if (!bidId) {
|
|
173
|
-
return null
|
|
173
|
+
return null;
|
|
174
174
|
}
|
|
175
|
-
return context?.cachedContentRef?.current?.get(bidId) ?? null
|
|
176
|
-
}
|
|
175
|
+
return context?.cachedContentRef?.current?.get(bidId) ?? null;
|
|
176
|
+
};
|
|
177
177
|
var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
178
|
-
const context = (0, import_react2.useContext)(import_sdk_react.AdsContext)
|
|
179
|
-
const bid = (0, import_sdk_react.useBid)({ code, messageId })
|
|
180
|
-
const [height, setHeight] = (0, import_react2.useState)(0)
|
|
181
|
-
const cachedContent = getCachedContent(context, bid?.bidId)
|
|
182
|
-
const iframeUrl = (0, import_sdk_react.useIframeUrl)(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
const modalWebViewRef = (0, import_react2.useRef)(null)
|
|
201
|
-
const messageStatusRef = (0, import_react2.useRef)('none' /* None */)
|
|
202
|
-
const modalInitTimeoutRef = (0, import_react2.useRef)(null)
|
|
203
|
-
const isModalInitRef = (0, import_react2.useRef)(false)
|
|
204
|
-
const { height: windowHeight, width: windowWidth } = (0, import_react_native4.useWindowDimensions)()
|
|
205
|
-
const keyboardHeightRef = (0, import_react2.useRef)(0)
|
|
206
|
-
const isAdViewVisible = showIframe && iframeLoaded
|
|
178
|
+
const context = (0, import_react2.useContext)(import_sdk_react.AdsContext);
|
|
179
|
+
const bid = (0, import_sdk_react.useBid)({ code, messageId });
|
|
180
|
+
const [height, setHeight] = (0, import_react2.useState)(0);
|
|
181
|
+
const cachedContent = getCachedContent(context, bid?.bidId);
|
|
182
|
+
const iframeUrl = (0, import_sdk_react.useIframeUrl)(bid, code, messageId, "sdk-react-native", otherParams.theme, cachedContent);
|
|
183
|
+
const modalUrl = iframeUrl.replace("/api/frame/", "/api/modal/");
|
|
184
|
+
const [showIframe, setShowIframe] = (0, import_react2.useState)(false);
|
|
185
|
+
const [iframeLoaded, setIframeLoaded] = (0, import_react2.useState)(false);
|
|
186
|
+
const [modalOpen, setModalOpen] = (0, import_react2.useState)(false);
|
|
187
|
+
const [modalShown, setModalShown] = (0, import_react2.useState)(false);
|
|
188
|
+
const [modalLoaded, setModalLoaded] = (0, import_react2.useState)(false);
|
|
189
|
+
const [containerStyles, setContainerStyles] = (0, import_react2.useState)({});
|
|
190
|
+
const [iframeStyles, setIframeStyles] = (0, import_react2.useState)({});
|
|
191
|
+
const containerRef = (0, import_react2.useRef)(null);
|
|
192
|
+
const webViewRef = (0, import_react2.useRef)(null);
|
|
193
|
+
const modalWebViewRef = (0, import_react2.useRef)(null);
|
|
194
|
+
const messageStatusRef = (0, import_react2.useRef)("none" /* None */);
|
|
195
|
+
const modalInitTimeoutRef = (0, import_react2.useRef)(null);
|
|
196
|
+
const isModalInitRef = (0, import_react2.useRef)(false);
|
|
197
|
+
const { height: windowHeight, width: windowWidth } = (0, import_react_native4.useWindowDimensions)();
|
|
198
|
+
const keyboardHeightRef = (0, import_react2.useRef)(0);
|
|
199
|
+
const isAdViewVisible = showIframe && iframeLoaded;
|
|
207
200
|
const reset = () => {
|
|
208
|
-
setHeight(0)
|
|
209
|
-
setShowIframe(false)
|
|
210
|
-
setContainerStyles({})
|
|
211
|
-
setIframeStyles({})
|
|
212
|
-
setIframeLoaded(false)
|
|
213
|
-
resetModal()
|
|
214
|
-
context?.resetAll()
|
|
215
|
-
context?.captureError(new Error(
|
|
216
|
-
}
|
|
201
|
+
setHeight(0);
|
|
202
|
+
setShowIframe(false);
|
|
203
|
+
setContainerStyles({});
|
|
204
|
+
setIframeStyles({});
|
|
205
|
+
setIframeLoaded(false);
|
|
206
|
+
resetModal();
|
|
207
|
+
context?.resetAll();
|
|
208
|
+
context?.captureError(new Error("Processing iframe error"));
|
|
209
|
+
};
|
|
217
210
|
const resetModal = () => {
|
|
218
211
|
if (modalInitTimeoutRef.current) {
|
|
219
|
-
clearTimeout(modalInitTimeoutRef.current)
|
|
220
|
-
modalInitTimeoutRef.current = null
|
|
212
|
+
clearTimeout(modalInitTimeoutRef.current);
|
|
213
|
+
modalInitTimeoutRef.current = null;
|
|
221
214
|
}
|
|
222
|
-
isModalInitRef.current = false
|
|
223
|
-
closeSkOverlay()
|
|
224
|
-
closeSkStoreProduct()
|
|
225
|
-
setModalOpen(false)
|
|
226
|
-
setModalLoaded(false)
|
|
227
|
-
setModalShown(false)
|
|
228
|
-
}
|
|
215
|
+
isModalInitRef.current = false;
|
|
216
|
+
closeSkOverlay();
|
|
217
|
+
closeSkStoreProduct();
|
|
218
|
+
setModalOpen(false);
|
|
219
|
+
setModalLoaded(false);
|
|
220
|
+
setModalShown(false);
|
|
221
|
+
};
|
|
229
222
|
const debug = (name, data = {}) => {
|
|
230
223
|
context?.onDebugEventInternal?.(name, {
|
|
231
224
|
code,
|
|
@@ -238,9 +231,9 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
238
231
|
height,
|
|
239
232
|
containerStyles,
|
|
240
233
|
iframeStyles,
|
|
241
|
-
...data
|
|
242
|
-
})
|
|
243
|
-
}
|
|
234
|
+
...data
|
|
235
|
+
});
|
|
236
|
+
};
|
|
244
237
|
const debugModal = (name, data = {}) => {
|
|
245
238
|
context?.onDebugEventInternal?.(name, {
|
|
246
239
|
code,
|
|
@@ -251,542 +244,544 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
251
244
|
modalOpen,
|
|
252
245
|
modalShown,
|
|
253
246
|
modalLoaded,
|
|
254
|
-
...data
|
|
255
|
-
})
|
|
256
|
-
}
|
|
247
|
+
...data
|
|
248
|
+
});
|
|
249
|
+
};
|
|
257
250
|
const openSkOverlay = async (appStoreId, position, dismissible) => {
|
|
258
251
|
try {
|
|
259
|
-
if (!
|
|
260
|
-
return
|
|
252
|
+
if (!await presentSKOverlay({ appStoreId, position, dismissible })) {
|
|
253
|
+
return;
|
|
261
254
|
}
|
|
262
|
-
sendMessage(webViewRef,
|
|
263
|
-
open: true
|
|
264
|
-
})
|
|
255
|
+
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
256
|
+
open: true
|
|
257
|
+
});
|
|
265
258
|
} catch (e) {
|
|
266
|
-
debug(
|
|
267
|
-
error: e
|
|
268
|
-
})
|
|
269
|
-
console.error(
|
|
259
|
+
debug("error-open-skoverlay-iframe", {
|
|
260
|
+
error: e
|
|
261
|
+
});
|
|
262
|
+
console.error("error opening sk overlay", e);
|
|
270
263
|
}
|
|
271
|
-
}
|
|
264
|
+
};
|
|
272
265
|
const closeSkOverlay = async () => {
|
|
273
266
|
try {
|
|
274
|
-
if (!
|
|
275
|
-
return
|
|
267
|
+
if (!await dismissSKOverlay()) {
|
|
268
|
+
return;
|
|
276
269
|
}
|
|
277
|
-
sendMessage(webViewRef,
|
|
278
|
-
open: false
|
|
279
|
-
})
|
|
270
|
+
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
271
|
+
open: false
|
|
272
|
+
});
|
|
280
273
|
} catch (e) {
|
|
281
|
-
debug(
|
|
282
|
-
error: e
|
|
283
|
-
})
|
|
284
|
-
console.error(
|
|
274
|
+
debug("error-dismiss-skoverlay-iframe", {
|
|
275
|
+
error: e
|
|
276
|
+
});
|
|
277
|
+
console.error("error dismissing sk overlay", e);
|
|
285
278
|
}
|
|
286
|
-
}
|
|
279
|
+
};
|
|
287
280
|
const openSkStoreProduct = async (appStoreId) => {
|
|
288
281
|
try {
|
|
289
|
-
if (!
|
|
290
|
-
return false
|
|
282
|
+
if (!await presentSKStoreProduct(appStoreId)) {
|
|
283
|
+
return false;
|
|
291
284
|
}
|
|
292
|
-
sendMessage(webViewRef,
|
|
293
|
-
open: true
|
|
294
|
-
})
|
|
295
|
-
return true
|
|
285
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
286
|
+
open: true
|
|
287
|
+
});
|
|
288
|
+
return true;
|
|
296
289
|
} catch (e) {
|
|
297
|
-
debug(
|
|
298
|
-
error: e
|
|
299
|
-
})
|
|
300
|
-
console.error(
|
|
301
|
-
return false
|
|
290
|
+
debug("error-open-skstoreproduct-iframe", {
|
|
291
|
+
error: e
|
|
292
|
+
});
|
|
293
|
+
console.error("error opening sk store product", e);
|
|
294
|
+
return false;
|
|
302
295
|
}
|
|
303
|
-
}
|
|
296
|
+
};
|
|
304
297
|
const closeSkStoreProduct = async () => {
|
|
305
298
|
try {
|
|
306
|
-
if (!
|
|
307
|
-
return false
|
|
299
|
+
if (!await dismissSKStoreProduct()) {
|
|
300
|
+
return false;
|
|
308
301
|
}
|
|
309
|
-
sendMessage(webViewRef,
|
|
310
|
-
open: false
|
|
311
|
-
})
|
|
312
|
-
return true
|
|
302
|
+
sendMessage(webViewRef, "update-skstoreproduct-iframe", code, {
|
|
303
|
+
open: false
|
|
304
|
+
});
|
|
305
|
+
return true;
|
|
313
306
|
} catch (e) {
|
|
314
|
-
debug(
|
|
315
|
-
error: e
|
|
316
|
-
})
|
|
317
|
-
console.error(
|
|
318
|
-
return false
|
|
307
|
+
debug("error-close-skstoreproduct-iframe", {
|
|
308
|
+
error: e
|
|
309
|
+
});
|
|
310
|
+
console.error("error closing sk store product", e);
|
|
311
|
+
return false;
|
|
319
312
|
}
|
|
320
|
-
}
|
|
313
|
+
};
|
|
321
314
|
const openUrl = async (message) => {
|
|
322
315
|
if (!message.data.url) {
|
|
323
|
-
return
|
|
316
|
+
return;
|
|
324
317
|
}
|
|
325
318
|
try {
|
|
326
|
-
await import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`)
|
|
319
|
+
await import_react_native4.Linking.openURL(`${context?.adServerUrl}${message.data.url}`);
|
|
327
320
|
} catch (e) {
|
|
328
|
-
console.error(
|
|
321
|
+
console.error("error opening url", e);
|
|
329
322
|
}
|
|
330
|
-
}
|
|
323
|
+
};
|
|
331
324
|
const handleClick = async (message) => {
|
|
332
325
|
if (message.data.appStoreId) {
|
|
333
326
|
try {
|
|
334
|
-
if (!
|
|
335
|
-
await openUrl(message)
|
|
327
|
+
if (!await openSkStoreProduct(message.data.appStoreId)) {
|
|
328
|
+
await openUrl(message);
|
|
336
329
|
}
|
|
337
330
|
} catch (e) {
|
|
338
|
-
console.error(
|
|
339
|
-
await openUrl(message)
|
|
331
|
+
console.error("error opening sk store product", e);
|
|
332
|
+
await openUrl(message);
|
|
340
333
|
}
|
|
341
334
|
} else {
|
|
342
|
-
await openUrl(message)
|
|
335
|
+
await openUrl(message);
|
|
343
336
|
}
|
|
344
|
-
context?.onAdClickInternal(message.data)
|
|
345
|
-
}
|
|
346
|
-
debug(
|
|
337
|
+
context?.onAdClickInternal(message.data);
|
|
338
|
+
};
|
|
339
|
+
debug("format-update-state");
|
|
347
340
|
const onMessage = (event) => {
|
|
348
341
|
try {
|
|
349
|
-
const data = JSON.parse(event.nativeEvent.data)
|
|
350
|
-
debug(
|
|
351
|
-
message: data
|
|
352
|
-
})
|
|
342
|
+
const data = JSON.parse(event.nativeEvent.data);
|
|
343
|
+
debug("iframe-message", {
|
|
344
|
+
message: data
|
|
345
|
+
});
|
|
353
346
|
const messageHandler = handleIframeMessage(
|
|
354
347
|
(message) => {
|
|
355
348
|
switch (message.type) {
|
|
356
|
-
case
|
|
357
|
-
setIframeLoaded(true)
|
|
358
|
-
debug(
|
|
359
|
-
messageStatusRef.current =
|
|
360
|
-
sendMessage(webViewRef,
|
|
349
|
+
case "init-iframe":
|
|
350
|
+
setIframeLoaded(true);
|
|
351
|
+
debug("iframe-post-message");
|
|
352
|
+
messageStatusRef.current = "message-received" /* MessageReceived */;
|
|
353
|
+
sendMessage(webViewRef, "update-iframe", code, {
|
|
361
354
|
messages: context?.messages,
|
|
362
|
-
sdk:
|
|
355
|
+
sdk: "sdk-react-native",
|
|
363
356
|
otherParams,
|
|
364
|
-
messageId
|
|
365
|
-
})
|
|
366
|
-
break
|
|
367
|
-
case
|
|
368
|
-
reset()
|
|
369
|
-
break
|
|
370
|
-
case
|
|
371
|
-
setHeight(message.data.height)
|
|
372
|
-
break
|
|
373
|
-
case
|
|
374
|
-
handleClick(message)
|
|
375
|
-
break
|
|
376
|
-
case
|
|
377
|
-
context?.onAdViewInternal(message.data)
|
|
378
|
-
break
|
|
379
|
-
case
|
|
357
|
+
messageId
|
|
358
|
+
});
|
|
359
|
+
break;
|
|
360
|
+
case "error-iframe":
|
|
361
|
+
reset();
|
|
362
|
+
break;
|
|
363
|
+
case "resize-iframe":
|
|
364
|
+
setHeight(message.data.height);
|
|
365
|
+
break;
|
|
366
|
+
case "click-iframe":
|
|
367
|
+
handleClick(message);
|
|
368
|
+
break;
|
|
369
|
+
case "view-iframe":
|
|
370
|
+
context?.onAdViewInternal(message.data);
|
|
371
|
+
break;
|
|
372
|
+
case "ad-done-iframe":
|
|
380
373
|
if (bid?.bidId && message.data.cachedContent) {
|
|
381
|
-
context?.cachedContentRef?.current?.set(bid.bidId, message.data.cachedContent)
|
|
374
|
+
context?.cachedContentRef?.current?.set(bid.bidId, message.data.cachedContent);
|
|
382
375
|
}
|
|
383
|
-
break
|
|
384
|
-
case
|
|
385
|
-
setShowIframe(true)
|
|
386
|
-
break
|
|
387
|
-
case
|
|
388
|
-
setShowIframe(false)
|
|
389
|
-
break
|
|
390
|
-
case
|
|
391
|
-
setContainerStyles(message.data.containerStyles)
|
|
392
|
-
setIframeStyles(message.data.iframeStyles)
|
|
393
|
-
break
|
|
394
|
-
case
|
|
395
|
-
setModalOpen(true)
|
|
376
|
+
break;
|
|
377
|
+
case "show-iframe":
|
|
378
|
+
setShowIframe(true);
|
|
379
|
+
break;
|
|
380
|
+
case "hide-iframe":
|
|
381
|
+
setShowIframe(false);
|
|
382
|
+
break;
|
|
383
|
+
case "set-styles-iframe":
|
|
384
|
+
setContainerStyles(message.data.containerStyles);
|
|
385
|
+
setIframeStyles(message.data.iframeStyles);
|
|
386
|
+
break;
|
|
387
|
+
case "open-component-iframe":
|
|
388
|
+
setModalOpen(true);
|
|
396
389
|
modalInitTimeoutRef.current = setTimeout(() => {
|
|
397
390
|
if (!isModalInitRef.current) {
|
|
398
|
-
resetModal()
|
|
391
|
+
resetModal();
|
|
399
392
|
}
|
|
400
|
-
}, message.data.timeout ?? 5e3)
|
|
401
|
-
break
|
|
402
|
-
case
|
|
403
|
-
onEvent?.(message.data)
|
|
404
|
-
context?.onAdEventInternal(message.data)
|
|
405
|
-
messageStatusRef.current =
|
|
406
|
-
break
|
|
407
|
-
case
|
|
408
|
-
openSkOverlay(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
393
|
+
}, message.data.timeout ?? 5e3);
|
|
394
|
+
break;
|
|
395
|
+
case "event-iframe":
|
|
396
|
+
onEvent?.(message.data);
|
|
397
|
+
context?.onAdEventInternal(message.data);
|
|
398
|
+
messageStatusRef.current = "message-received" /* MessageReceived */;
|
|
399
|
+
break;
|
|
400
|
+
case "open-skoverlay-iframe":
|
|
401
|
+
openSkOverlay(
|
|
402
|
+
message.data.appStoreId,
|
|
403
|
+
message.data.position,
|
|
404
|
+
message.data.dismissible
|
|
405
|
+
);
|
|
406
|
+
break;
|
|
407
|
+
case "close-skoverlay-iframe":
|
|
408
|
+
closeSkOverlay();
|
|
409
|
+
break;
|
|
410
|
+
case "open-skstoreproduct-iframe":
|
|
411
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
412
|
+
break;
|
|
413
|
+
case "close-skstoreproduct-iframe":
|
|
414
|
+
closeSkStoreProduct();
|
|
415
|
+
break;
|
|
419
416
|
}
|
|
420
417
|
},
|
|
421
418
|
{
|
|
422
|
-
code
|
|
419
|
+
code
|
|
423
420
|
}
|
|
424
|
-
)
|
|
425
|
-
messageHandler({ data })
|
|
421
|
+
);
|
|
422
|
+
messageHandler({ data });
|
|
426
423
|
} catch (e) {
|
|
427
|
-
debug(
|
|
428
|
-
error: e
|
|
429
|
-
})
|
|
430
|
-
console.error(
|
|
431
|
-
reset()
|
|
424
|
+
debug("iframe-message-error", {
|
|
425
|
+
error: e
|
|
426
|
+
});
|
|
427
|
+
console.error("error parsing message from webview", e);
|
|
428
|
+
reset();
|
|
432
429
|
}
|
|
433
|
-
}
|
|
430
|
+
};
|
|
434
431
|
const onModalMessage = (event) => {
|
|
435
432
|
try {
|
|
436
|
-
const data = JSON.parse(event.nativeEvent.data)
|
|
437
|
-
debugModal(
|
|
438
|
-
message: data
|
|
439
|
-
})
|
|
433
|
+
const data = JSON.parse(event.nativeEvent.data);
|
|
434
|
+
debugModal("modal-iframe-message", {
|
|
435
|
+
message: data
|
|
436
|
+
});
|
|
440
437
|
const messageHandler = handleIframeMessage(
|
|
441
438
|
(message) => {
|
|
442
439
|
switch (message.type) {
|
|
443
|
-
case
|
|
444
|
-
resetModal()
|
|
445
|
-
break
|
|
446
|
-
case
|
|
447
|
-
isModalInitRef.current = true
|
|
440
|
+
case "close-component-iframe":
|
|
441
|
+
resetModal();
|
|
442
|
+
break;
|
|
443
|
+
case "init-component-iframe":
|
|
444
|
+
isModalInitRef.current = true;
|
|
448
445
|
if (modalInitTimeoutRef.current) {
|
|
449
|
-
clearTimeout(modalInitTimeoutRef.current)
|
|
450
|
-
modalInitTimeoutRef.current = null
|
|
446
|
+
clearTimeout(modalInitTimeoutRef.current);
|
|
447
|
+
modalInitTimeoutRef.current = null;
|
|
451
448
|
}
|
|
452
|
-
setModalShown(true)
|
|
453
|
-
break
|
|
454
|
-
case
|
|
455
|
-
case
|
|
456
|
-
resetModal()
|
|
457
|
-
context?.captureError(new Error(
|
|
458
|
-
break
|
|
459
|
-
case
|
|
460
|
-
openSkOverlay(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
break
|
|
472
|
-
case
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
449
|
+
setModalShown(true);
|
|
450
|
+
break;
|
|
451
|
+
case "error-component-iframe":
|
|
452
|
+
case "error-iframe":
|
|
453
|
+
resetModal();
|
|
454
|
+
context?.captureError(new Error("Processing modal iframe error"));
|
|
455
|
+
break;
|
|
456
|
+
case "open-skoverlay-iframe":
|
|
457
|
+
openSkOverlay(
|
|
458
|
+
message.data.appStoreId,
|
|
459
|
+
message.data.position,
|
|
460
|
+
message.data.dismissible
|
|
461
|
+
);
|
|
462
|
+
break;
|
|
463
|
+
case "close-skoverlay-iframe":
|
|
464
|
+
closeSkOverlay();
|
|
465
|
+
break;
|
|
466
|
+
case "click-iframe":
|
|
467
|
+
handleClick(message);
|
|
468
|
+
break;
|
|
469
|
+
case "event-iframe":
|
|
470
|
+
onEvent?.(message.data);
|
|
471
|
+
context?.onAdEventInternal(message.data);
|
|
472
|
+
break;
|
|
473
|
+
case "open-skstoreproduct-iframe":
|
|
474
|
+
openSkStoreProduct(message.data.appStoreId);
|
|
475
|
+
break;
|
|
476
|
+
case "close-skstoreproduct-iframe":
|
|
477
|
+
closeSkStoreProduct();
|
|
478
|
+
break;
|
|
478
479
|
}
|
|
479
480
|
},
|
|
480
481
|
{
|
|
481
482
|
code,
|
|
482
|
-
component:
|
|
483
|
+
component: "modal"
|
|
483
484
|
}
|
|
484
|
-
)
|
|
485
|
-
messageHandler({ data })
|
|
485
|
+
);
|
|
486
|
+
messageHandler({ data });
|
|
486
487
|
} catch (e) {
|
|
487
|
-
debugModal(
|
|
488
|
-
error: e
|
|
489
|
-
})
|
|
490
|
-
console.error(
|
|
491
|
-
resetModal()
|
|
488
|
+
debugModal("modal-iframe-message-error", {
|
|
489
|
+
error: e
|
|
490
|
+
});
|
|
491
|
+
console.error("error parsing message from webview", e);
|
|
492
|
+
resetModal();
|
|
492
493
|
}
|
|
493
|
-
}
|
|
494
|
-
|
|
494
|
+
};
|
|
495
|
+
(0, import_react2.useEffect)(() => {
|
|
495
496
|
const interval = setInterval(() => {
|
|
496
|
-
if (messageStatusRef.current ===
|
|
497
|
-
return
|
|
497
|
+
if (messageStatusRef.current === "none" /* None */) {
|
|
498
|
+
return;
|
|
498
499
|
}
|
|
499
|
-
if (messageStatusRef.current ===
|
|
500
|
-
clearInterval(interval)
|
|
501
|
-
return
|
|
500
|
+
if (messageStatusRef.current === "message-received" /* MessageReceived */) {
|
|
501
|
+
clearInterval(interval);
|
|
502
|
+
return;
|
|
502
503
|
}
|
|
503
|
-
debug(
|
|
504
|
-
setIframeLoaded(true)
|
|
505
|
-
sendMessage(webViewRef,
|
|
504
|
+
debug("iframe-post-message-use-effect");
|
|
505
|
+
setIframeLoaded(true);
|
|
506
|
+
sendMessage(webViewRef, "update-iframe", code, {
|
|
506
507
|
messages: context?.messages,
|
|
507
|
-
sdk:
|
|
508
|
+
sdk: "sdk-react-native",
|
|
508
509
|
otherParams: {
|
|
509
510
|
...otherParams,
|
|
510
|
-
_useEffect: true
|
|
511
|
+
_useEffect: true
|
|
511
512
|
},
|
|
512
|
-
messageId
|
|
513
|
-
})
|
|
514
|
-
}, 500)
|
|
513
|
+
messageId
|
|
514
|
+
});
|
|
515
|
+
}, 500);
|
|
515
516
|
return () => {
|
|
516
|
-
clearInterval(interval)
|
|
517
|
-
}
|
|
518
|
-
}, [])
|
|
519
|
-
const paramsString = (0, import_sdk_react.convertParamsToString)(otherParams)
|
|
520
|
-
|
|
517
|
+
clearInterval(interval);
|
|
518
|
+
};
|
|
519
|
+
}, []);
|
|
520
|
+
const paramsString = (0, import_sdk_react.convertParamsToString)(otherParams);
|
|
521
|
+
(0, import_react2.useEffect)(() => {
|
|
521
522
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
522
|
-
return
|
|
523
|
+
return;
|
|
523
524
|
}
|
|
524
|
-
debug(
|
|
525
|
-
sendMessage(webViewRef,
|
|
525
|
+
debug("iframe-post-message");
|
|
526
|
+
sendMessage(webViewRef, "update-iframe", code, {
|
|
526
527
|
data: { otherParams },
|
|
527
|
-
code
|
|
528
|
-
})
|
|
529
|
-
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code])
|
|
528
|
+
code
|
|
529
|
+
});
|
|
530
|
+
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code]);
|
|
530
531
|
const checkIfInViewport = () => {
|
|
531
|
-
if (!containerRef.current) return
|
|
532
|
+
if (!containerRef.current) return;
|
|
532
533
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
533
|
-
sendMessage(webViewRef,
|
|
534
|
+
sendMessage(webViewRef, "update-dimensions-iframe", code, {
|
|
534
535
|
windowWidth,
|
|
535
536
|
windowHeight,
|
|
536
537
|
containerWidth,
|
|
537
538
|
containerHeight,
|
|
538
539
|
containerX,
|
|
539
540
|
containerY,
|
|
540
|
-
keyboardHeight: keyboardHeightRef.current
|
|
541
|
-
})
|
|
542
|
-
})
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
if (!isAdViewVisible) return
|
|
541
|
+
keyboardHeight: keyboardHeightRef.current
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
(0, import_react2.useEffect)(() => {
|
|
546
|
+
if (!isAdViewVisible) return;
|
|
546
547
|
const interval = setInterval(() => {
|
|
547
|
-
checkIfInViewport()
|
|
548
|
-
}, 250)
|
|
549
|
-
return () => clearInterval(interval)
|
|
550
|
-
}, [isAdViewVisible])
|
|
551
|
-
|
|
552
|
-
const showSubscription = import_react_native4.Keyboard.addListener(
|
|
553
|
-
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0
|
|
554
|
-
})
|
|
555
|
-
const hideSubscription = import_react_native4.Keyboard.addListener(
|
|
556
|
-
keyboardHeightRef.current = 0
|
|
557
|
-
})
|
|
548
|
+
checkIfInViewport();
|
|
549
|
+
}, 250);
|
|
550
|
+
return () => clearInterval(interval);
|
|
551
|
+
}, [isAdViewVisible]);
|
|
552
|
+
(0, import_react2.useEffect)(() => {
|
|
553
|
+
const showSubscription = import_react_native4.Keyboard.addListener("keyboardDidShow", (e) => {
|
|
554
|
+
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
555
|
+
});
|
|
556
|
+
const hideSubscription = import_react_native4.Keyboard.addListener("keyboardDidHide", () => {
|
|
557
|
+
keyboardHeightRef.current = 0;
|
|
558
|
+
});
|
|
558
559
|
return () => {
|
|
559
|
-
showSubscription.remove()
|
|
560
|
-
hideSubscription.remove()
|
|
561
|
-
keyboardHeightRef.current = 0
|
|
562
|
-
}
|
|
563
|
-
}, [])
|
|
560
|
+
showSubscription.remove();
|
|
561
|
+
hideSubscription.remove();
|
|
562
|
+
keyboardHeightRef.current = 0;
|
|
563
|
+
};
|
|
564
|
+
}, []);
|
|
564
565
|
if (!context || !bid || !iframeUrl) {
|
|
565
|
-
return null
|
|
566
|
+
return null;
|
|
566
567
|
}
|
|
567
|
-
const inlineContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
width: '100%',
|
|
574
|
-
backgroundColor: 'transparent',
|
|
575
|
-
borderWidth: 0,
|
|
576
|
-
...iframeStyles,
|
|
577
|
-
},
|
|
578
|
-
onError: () => {
|
|
579
|
-
debug('iframe-error')
|
|
580
|
-
reset()
|
|
581
|
-
},
|
|
582
|
-
onLoad: () => {
|
|
583
|
-
debug('iframe-load')
|
|
584
|
-
messageStatusRef.current = 'initialized' /* Initialized */
|
|
585
|
-
},
|
|
586
|
-
})
|
|
587
|
-
const interstitialContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.Modal, {
|
|
588
|
-
visible: modalOpen,
|
|
589
|
-
transparent: true,
|
|
590
|
-
onRequestClose: resetModal,
|
|
591
|
-
animationType: 'slide',
|
|
592
|
-
statusBarTranslucent: true,
|
|
593
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.View, {
|
|
568
|
+
const inlineContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
569
|
+
frame_webview_default,
|
|
570
|
+
{
|
|
571
|
+
ref: webViewRef,
|
|
572
|
+
iframeUrl,
|
|
573
|
+
onMessage,
|
|
594
574
|
style: {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
575
|
+
height,
|
|
576
|
+
width: "100%",
|
|
577
|
+
backgroundColor: "transparent",
|
|
578
|
+
borderWidth: 0,
|
|
579
|
+
...iframeStyles
|
|
598
580
|
},
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
581
|
+
onError: () => {
|
|
582
|
+
debug("iframe-error");
|
|
583
|
+
reset();
|
|
584
|
+
},
|
|
585
|
+
onLoad: () => {
|
|
586
|
+
debug("iframe-load");
|
|
587
|
+
messageStatusRef.current = "initialized" /* Initialized */;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
);
|
|
591
|
+
const interstitialContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
592
|
+
import_react_native4.Modal,
|
|
593
|
+
{
|
|
594
|
+
visible: modalOpen,
|
|
595
|
+
transparent: true,
|
|
596
|
+
onRequestClose: resetModal,
|
|
597
|
+
animationType: "slide",
|
|
598
|
+
statusBarTranslucent: true,
|
|
599
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
600
|
+
import_react_native4.View,
|
|
601
|
+
{
|
|
602
|
+
style: {
|
|
603
|
+
flex: 1,
|
|
604
|
+
// Don't show the modal until the modal page is loaded and sends 'init-component-iframe' message back to SDK
|
|
605
|
+
...modalShown ? { opacity: 1, pointerEvents: "auto" } : { opacity: 0, pointerEvents: "none" }
|
|
606
|
+
},
|
|
607
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
608
|
+
frame_webview_default,
|
|
609
|
+
{
|
|
610
|
+
ref: modalWebViewRef,
|
|
611
|
+
iframeUrl: modalUrl,
|
|
612
|
+
onMessage: onModalMessage,
|
|
613
|
+
style: {
|
|
614
|
+
backgroundColor: "transparent",
|
|
615
|
+
height: "100%",
|
|
616
|
+
width: "100%",
|
|
617
|
+
borderWidth: 0
|
|
618
|
+
},
|
|
619
|
+
onError: () => {
|
|
620
|
+
debug("modal-error");
|
|
621
|
+
resetModal();
|
|
622
|
+
},
|
|
623
|
+
onLoad: () => {
|
|
624
|
+
debug("modal-load");
|
|
625
|
+
setModalLoaded(true);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
}
|
|
630
|
+
)
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
635
|
+
import_react_native4.View,
|
|
636
|
+
{
|
|
637
|
+
style: isAdViewVisible ? containerStyles : {
|
|
638
|
+
height: 0,
|
|
639
|
+
overflow: "hidden"
|
|
616
640
|
},
|
|
617
|
-
}),
|
|
618
|
-
}),
|
|
619
|
-
})
|
|
620
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, {
|
|
621
|
-
children: [
|
|
622
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native4.View, {
|
|
623
|
-
style: isAdViewVisible
|
|
624
|
-
? containerStyles
|
|
625
|
-
: {
|
|
626
|
-
height: 0,
|
|
627
|
-
overflow: 'hidden',
|
|
628
|
-
},
|
|
629
641
|
ref: containerRef,
|
|
630
|
-
children: wrapper ? wrapper(inlineContent) : inlineContent
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
})
|
|
635
|
-
}
|
|
636
|
-
var FormatWithErrorBoundary = (props) =>
|
|
637
|
-
|
|
638
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Format, { ...props }),
|
|
639
|
-
})
|
|
640
|
-
var Format_default = FormatWithErrorBoundary
|
|
642
|
+
children: wrapper ? wrapper(inlineContent) : inlineContent
|
|
643
|
+
}
|
|
644
|
+
),
|
|
645
|
+
interstitialContent
|
|
646
|
+
] });
|
|
647
|
+
};
|
|
648
|
+
var FormatWithErrorBoundary = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_sdk_react.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Format, { ...props }) });
|
|
649
|
+
var Format_default = FormatWithErrorBoundary;
|
|
641
650
|
|
|
642
651
|
// src/formats/InlineAd.tsx
|
|
643
|
-
var import_jsx_runtime3 = require(
|
|
652
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
644
653
|
var InlineAd = ({ code, messageId, wrapper, ...props }) => {
|
|
645
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Format_default, { code, messageId, wrapper, ...props })
|
|
646
|
-
}
|
|
647
|
-
var InlineAd_default = InlineAd
|
|
654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Format_default, { code, messageId, wrapper, ...props });
|
|
655
|
+
};
|
|
656
|
+
var InlineAd_default = InlineAd;
|
|
648
657
|
|
|
649
658
|
// src/context/AdsProvider.tsx
|
|
650
|
-
var import_sdk_react2 = require(
|
|
651
|
-
var import_netinfo = require(
|
|
652
|
-
var import_react_native5 = require(
|
|
653
|
-
var import_react_native_device_info = __toESM(require(
|
|
659
|
+
var import_sdk_react2 = require("@kontextso/sdk-react");
|
|
660
|
+
var import_netinfo = require("@react-native-community/netinfo");
|
|
661
|
+
var import_react_native5 = require("react-native");
|
|
662
|
+
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
654
663
|
|
|
655
664
|
// package.json
|
|
656
|
-
var version =
|
|
665
|
+
var version = "3.3.0";
|
|
657
666
|
|
|
658
667
|
// src/context/AdsProvider.tsx
|
|
659
|
-
var import_jsx_runtime4 = require(
|
|
668
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
660
669
|
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
661
670
|
if (!isFatal) {
|
|
662
|
-
import_sdk_react2.log.warn(error)
|
|
671
|
+
import_sdk_react2.log.warn(error);
|
|
663
672
|
} else {
|
|
664
|
-
import_sdk_react2.log.error(error)
|
|
673
|
+
import_sdk_react2.log.error(error);
|
|
665
674
|
}
|
|
666
|
-
})
|
|
675
|
+
});
|
|
667
676
|
var batteryLevelToPercent = (level) => {
|
|
668
|
-
if (typeof level !==
|
|
669
|
-
if (level < 0) return void 0
|
|
670
|
-
return Math.max(0, Math.min(100, Math.round(level * 100)))
|
|
671
|
-
}
|
|
677
|
+
if (typeof level !== "number" || !isFinite(level)) return void 0;
|
|
678
|
+
if (level < 0) return void 0;
|
|
679
|
+
return Math.max(0, Math.min(100, Math.round(level * 100)));
|
|
680
|
+
};
|
|
672
681
|
var getDevice = async () => {
|
|
673
682
|
try {
|
|
674
|
-
const powerState = await import_react_native_device_info.default.getPowerState()
|
|
675
|
-
const deviceType = import_react_native_device_info.default.getDeviceType()
|
|
676
|
-
const soundOn = await NativeRNKontext_default.isSoundOn()
|
|
677
|
-
const screen = import_react_native5.Dimensions.get(
|
|
678
|
-
const networkInfo = await (0, import_netinfo.fetch)()
|
|
683
|
+
const powerState = await import_react_native_device_info.default.getPowerState();
|
|
684
|
+
const deviceType = import_react_native_device_info.default.getDeviceType();
|
|
685
|
+
const soundOn = await NativeRNKontext_default.isSoundOn();
|
|
686
|
+
const screen = import_react_native5.Dimensions.get("screen");
|
|
687
|
+
const networkInfo = await (0, import_netinfo.fetch)();
|
|
679
688
|
const mapDeviceTypeToHardwareType = () => {
|
|
680
689
|
switch (deviceType) {
|
|
681
|
-
case
|
|
682
|
-
return
|
|
683
|
-
case
|
|
684
|
-
return
|
|
685
|
-
case
|
|
686
|
-
return
|
|
687
|
-
case
|
|
688
|
-
return
|
|
690
|
+
case "Handset":
|
|
691
|
+
return "handset";
|
|
692
|
+
case "Tablet":
|
|
693
|
+
return "tablet";
|
|
694
|
+
case "Tv":
|
|
695
|
+
return "tv";
|
|
696
|
+
case "Desktop":
|
|
697
|
+
return "desktop";
|
|
689
698
|
default:
|
|
690
|
-
return
|
|
699
|
+
return "other";
|
|
691
700
|
}
|
|
692
|
-
}
|
|
701
|
+
};
|
|
693
702
|
return {
|
|
694
703
|
hardware: {
|
|
695
704
|
brand: import_react_native_device_info.default.getBrand(),
|
|
696
705
|
model: import_react_native_device_info.default.getDeviceId(),
|
|
697
|
-
type: mapDeviceTypeToHardwareType()
|
|
706
|
+
type: mapDeviceTypeToHardwareType()
|
|
698
707
|
// bootTime: Not available without native module
|
|
699
708
|
// sdCardAvailable: Not available without native module
|
|
700
709
|
},
|
|
701
710
|
audio: {
|
|
702
|
-
muted: soundOn
|
|
711
|
+
muted: soundOn
|
|
703
712
|
// volume: Requires react-native-volume-manager
|
|
704
713
|
// outputPluggedIn: Not available without native module
|
|
705
714
|
// outputType: Not available without native module
|
|
706
715
|
},
|
|
707
716
|
network: {
|
|
708
|
-
carrier:
|
|
709
|
-
(networkInfo.type === import_netinfo.NetInfoStateType.cellular && networkInfo.details.carrier) || void 0,
|
|
717
|
+
carrier: networkInfo.type === import_netinfo.NetInfoStateType.cellular && networkInfo.details.carrier || void 0,
|
|
710
718
|
userAgent: await import_react_native_device_info.default.getUserAgent(),
|
|
711
|
-
type: [
|
|
712
|
-
|
|
713
|
-
import_netinfo.NetInfoStateType.cellular,
|
|
714
|
-
import_netinfo.NetInfoStateType.ethernet,
|
|
715
|
-
].includes(networkInfo.type)
|
|
716
|
-
? networkInfo.type
|
|
717
|
-
: import_netinfo.NetInfoStateType.other,
|
|
718
|
-
detail:
|
|
719
|
-
(networkInfo.type === import_netinfo.NetInfoStateType.cellular && networkInfo.details.cellularGeneration) ||
|
|
720
|
-
void 0,
|
|
719
|
+
type: [import_netinfo.NetInfoStateType.wifi, import_netinfo.NetInfoStateType.cellular, import_netinfo.NetInfoStateType.ethernet].includes(networkInfo.type) ? networkInfo.type : import_netinfo.NetInfoStateType.other,
|
|
720
|
+
detail: networkInfo.type === import_netinfo.NetInfoStateType.cellular && networkInfo.details.cellularGeneration || void 0
|
|
721
721
|
},
|
|
722
722
|
os: {
|
|
723
723
|
name: import_react_native5.Platform.OS,
|
|
724
724
|
version: import_react_native_device_info.default.getSystemVersion(),
|
|
725
725
|
locale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
726
|
-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
726
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
727
727
|
},
|
|
728
728
|
screen: {
|
|
729
|
-
darkMode: import_react_native5.Appearance.getColorScheme() ===
|
|
729
|
+
darkMode: import_react_native5.Appearance.getColorScheme() === "dark",
|
|
730
730
|
dpr: import_react_native5.PixelRatio.get(),
|
|
731
731
|
height: screen.height,
|
|
732
732
|
width: screen.width,
|
|
733
|
-
orientation: screen.width > screen.height ?
|
|
733
|
+
orientation: screen.width > screen.height ? "landscape" : "portrait"
|
|
734
734
|
},
|
|
735
735
|
power: {
|
|
736
736
|
batteryLevel: batteryLevelToPercent(powerState.batteryLevel),
|
|
737
737
|
batteryState: powerState.batteryState,
|
|
738
|
-
lowPowerMode: powerState.lowPowerMode
|
|
739
|
-
}
|
|
740
|
-
}
|
|
738
|
+
lowPowerMode: powerState.lowPowerMode
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
741
|
} catch (error) {
|
|
742
|
-
console.error(error)
|
|
743
|
-
return {}
|
|
742
|
+
console.error(error);
|
|
743
|
+
return {};
|
|
744
744
|
}
|
|
745
|
-
}
|
|
745
|
+
};
|
|
746
746
|
var getApp = async () => {
|
|
747
747
|
try {
|
|
748
748
|
return {
|
|
749
749
|
bundleId: import_react_native_device_info.default.getBundleId(),
|
|
750
750
|
firstInstallTime: await import_react_native_device_info.default.getFirstInstallTime(),
|
|
751
751
|
lastUpdateTime: await import_react_native_device_info.default.getLastUpdateTime(),
|
|
752
|
-
version: import_react_native_device_info.default.getVersion()
|
|
752
|
+
version: import_react_native_device_info.default.getVersion()
|
|
753
753
|
// Not supported in react-native-device-info v10
|
|
754
754
|
// startTime: await DeviceInfo.getStartupTime(),
|
|
755
|
-
}
|
|
755
|
+
};
|
|
756
756
|
} catch (error) {
|
|
757
|
-
console.error(error)
|
|
758
|
-
return {}
|
|
757
|
+
console.error(error);
|
|
758
|
+
return {};
|
|
759
759
|
}
|
|
760
|
-
}
|
|
760
|
+
};
|
|
761
761
|
var getSdk = async () => ({
|
|
762
|
-
name:
|
|
763
|
-
platform: import_react_native5.Platform.OS ===
|
|
764
|
-
version
|
|
765
|
-
})
|
|
762
|
+
name: "sdk-react-native",
|
|
763
|
+
platform: import_react_native5.Platform.OS === "ios" ? "ios" : "android",
|
|
764
|
+
version
|
|
765
|
+
});
|
|
766
766
|
var getTcf = async () => {
|
|
767
767
|
try {
|
|
768
|
-
const tcfData = await NativeRNKontext_default.getTcfData()
|
|
768
|
+
const tcfData = await NativeRNKontext_default.getTcfData();
|
|
769
|
+
const gdpr = tcfData.gdprApplies === 0 || tcfData.gdprApplies === 1 ? tcfData.gdprApplies : void 0;
|
|
770
|
+
const gdprConsent = typeof tcfData.tcString === "string" && tcfData.tcString.length > 0 ? tcfData.tcString : void 0;
|
|
769
771
|
return {
|
|
770
|
-
gdpr:
|
|
771
|
-
gdprConsent:
|
|
772
|
-
}
|
|
772
|
+
...gdpr !== void 0 ? { gdpr } : {},
|
|
773
|
+
...gdprConsent !== void 0 ? { gdprConsent } : {}
|
|
774
|
+
};
|
|
773
775
|
} catch (error) {
|
|
774
|
-
console.error(error)
|
|
775
|
-
return {}
|
|
776
|
+
console.error(error);
|
|
777
|
+
return {};
|
|
776
778
|
}
|
|
777
|
-
}
|
|
779
|
+
};
|
|
778
780
|
var AdsProvider = (props) => {
|
|
779
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_sdk_react2.AdsProviderInternal, {
|
|
780
|
-
|
|
781
|
-
getDevice,
|
|
782
|
-
getSdk,
|
|
783
|
-
getApp,
|
|
784
|
-
getTcf,
|
|
785
|
-
})
|
|
786
|
-
}
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_sdk_react2.AdsProviderInternal, { ...props, getDevice, getSdk, getApp, getTcf });
|
|
782
|
+
};
|
|
787
783
|
// Annotate the CommonJS export names for ESM import in node:
|
|
788
|
-
0 &&
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
})
|
|
784
|
+
0 && (module.exports = {
|
|
785
|
+
AdsProvider,
|
|
786
|
+
InlineAd
|
|
787
|
+
});
|