@kontextso/sdk-react-native 3.0.6 → 3.0.7-rc.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.
- package/dist/index.js +80 -16
- package/dist/index.mjs +80 -16
- package/package.json +2 -2
- package/src/formats/Format.tsx +79 -14
package/dist/index.js
CHANGED
|
@@ -147,7 +147,9 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
147
147
|
context?.captureError(new Error("Processing iframe error"));
|
|
148
148
|
};
|
|
149
149
|
const resetModal = () => {
|
|
150
|
+
debugModal("Format:resetModal");
|
|
150
151
|
if (modalInitTimeoutRef.current) {
|
|
152
|
+
debugModal("Format:resetModalTimeout");
|
|
151
153
|
clearTimeout(modalInitTimeoutRef.current);
|
|
152
154
|
modalInitTimeoutRef.current = null;
|
|
153
155
|
}
|
|
@@ -184,19 +186,27 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
184
186
|
...data
|
|
185
187
|
});
|
|
186
188
|
};
|
|
187
|
-
debug("
|
|
189
|
+
debug("Format:updateState");
|
|
188
190
|
const onMessage = (event) => {
|
|
189
191
|
try {
|
|
190
192
|
const data = JSON.parse(event.nativeEvent.data);
|
|
191
|
-
debug("
|
|
192
|
-
message: data
|
|
193
|
+
debug("Format:iframeMessage", {
|
|
194
|
+
message: data,
|
|
195
|
+
params: { data }
|
|
193
196
|
});
|
|
194
197
|
const messageHandler = handleIframeMessage(
|
|
195
198
|
(message) => {
|
|
196
199
|
switch (message.type) {
|
|
197
200
|
case "init-iframe":
|
|
198
201
|
setIframeLoaded(true);
|
|
199
|
-
debug("
|
|
202
|
+
debug("Format:iframePostMessage", {
|
|
203
|
+
params: {
|
|
204
|
+
messages: context?.messages,
|
|
205
|
+
sdk: "sdk-react-native",
|
|
206
|
+
otherParams,
|
|
207
|
+
messageId
|
|
208
|
+
}
|
|
209
|
+
});
|
|
200
210
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
201
211
|
messages: context?.messages,
|
|
202
212
|
sdk: "sdk-react-native",
|
|
@@ -256,7 +266,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
256
266
|
);
|
|
257
267
|
messageHandler({ data });
|
|
258
268
|
} catch (e) {
|
|
259
|
-
debug("
|
|
269
|
+
debug("Format:iframeMessageError", {
|
|
270
|
+
params: { error: e },
|
|
260
271
|
error: e
|
|
261
272
|
});
|
|
262
273
|
console.error("error parsing message from webview", e);
|
|
@@ -266,7 +277,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
266
277
|
const onModalMessage = (event) => {
|
|
267
278
|
try {
|
|
268
279
|
const data = JSON.parse(event.nativeEvent.data);
|
|
269
|
-
debugModal("
|
|
280
|
+
debugModal("Format:modalIframeMessage", {
|
|
281
|
+
params: { data },
|
|
270
282
|
message: data
|
|
271
283
|
});
|
|
272
284
|
const messageHandler = handleIframeMessage(
|
|
@@ -309,7 +321,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
309
321
|
);
|
|
310
322
|
messageHandler({ data });
|
|
311
323
|
} catch (e) {
|
|
312
|
-
debugModal("
|
|
324
|
+
debugModal("Format:modalIframeMessageError", {
|
|
325
|
+
params: { error: e },
|
|
313
326
|
error: e
|
|
314
327
|
});
|
|
315
328
|
console.error("error parsing message from webview", e);
|
|
@@ -319,16 +332,36 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
319
332
|
const paramsString = (0, import_sdk_react.convertParamsToString)(otherParams);
|
|
320
333
|
(0, import_react2.useEffect)(() => {
|
|
321
334
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
335
|
+
debug("Format:iframePostMessageNotLoaded", {
|
|
336
|
+
params: {
|
|
337
|
+
iframeLoaded,
|
|
338
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
339
|
+
bid
|
|
340
|
+
}
|
|
341
|
+
});
|
|
322
342
|
return;
|
|
323
343
|
}
|
|
324
|
-
debug("
|
|
344
|
+
debug("Format:iframePostMessage", {
|
|
345
|
+
params: {
|
|
346
|
+
otherParams
|
|
347
|
+
}
|
|
348
|
+
});
|
|
325
349
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
326
350
|
data: { otherParams },
|
|
327
351
|
code
|
|
328
352
|
});
|
|
329
353
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code]);
|
|
330
354
|
const checkIfInViewport = () => {
|
|
331
|
-
if (!containerRef.current)
|
|
355
|
+
if (!containerRef.current) {
|
|
356
|
+
debug("Format:checkIfInViewportNoContainer");
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
debug("Format:checkIfInViewportMeasure", {
|
|
360
|
+
params: {
|
|
361
|
+
windowWidth,
|
|
362
|
+
windowHeight
|
|
363
|
+
}
|
|
364
|
+
});
|
|
332
365
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
333
366
|
sendMessage(webViewRef, "update-dimensions-iframe", code, {
|
|
334
367
|
windowWidth,
|
|
@@ -339,29 +372,60 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
339
372
|
containerY,
|
|
340
373
|
keyboardHeight: keyboardHeightRef.current
|
|
341
374
|
});
|
|
375
|
+
debug("Format:checkIfInViewportMeasureSend", {
|
|
376
|
+
params: {
|
|
377
|
+
windowWidth,
|
|
378
|
+
windowHeight,
|
|
379
|
+
containerWidth,
|
|
380
|
+
containerHeight,
|
|
381
|
+
containerX,
|
|
382
|
+
containerY,
|
|
383
|
+
keyboardHeight: keyboardHeightRef.current
|
|
384
|
+
}
|
|
385
|
+
});
|
|
342
386
|
});
|
|
343
387
|
};
|
|
344
388
|
(0, import_react2.useEffect)(() => {
|
|
345
|
-
if (!isAdViewVisible)
|
|
389
|
+
if (!isAdViewVisible) {
|
|
390
|
+
debug("Format:checkIfInViewportNotVisible");
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
346
393
|
const interval = setInterval(() => {
|
|
347
394
|
checkIfInViewport();
|
|
348
395
|
}, 250);
|
|
349
|
-
return () =>
|
|
396
|
+
return () => {
|
|
397
|
+
clearInterval(interval);
|
|
398
|
+
debug("Format:checkIfInViewportCleanup");
|
|
399
|
+
};
|
|
350
400
|
}, [isAdViewVisible]);
|
|
351
401
|
(0, import_react2.useEffect)(() => {
|
|
352
402
|
const showSubscription = import_react_native.Keyboard.addListener("keyboardDidShow", (e) => {
|
|
403
|
+
debug("Format:keyboardDidShow", {
|
|
404
|
+
params: {
|
|
405
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0
|
|
406
|
+
}
|
|
407
|
+
});
|
|
353
408
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
354
409
|
});
|
|
355
410
|
const hideSubscription = import_react_native.Keyboard.addListener("keyboardDidHide", () => {
|
|
411
|
+
debug("Format:keyboardDidHide");
|
|
356
412
|
keyboardHeightRef.current = 0;
|
|
357
413
|
});
|
|
358
414
|
return () => {
|
|
359
415
|
showSubscription.remove();
|
|
360
416
|
hideSubscription.remove();
|
|
361
417
|
keyboardHeightRef.current = 0;
|
|
418
|
+
debug("Format:keyboardEffectCleanup");
|
|
362
419
|
};
|
|
363
420
|
}, []);
|
|
364
421
|
if (!context || !bid || !iframeUrl) {
|
|
422
|
+
debug("Format:noContextOrBidOrIframeUrl", {
|
|
423
|
+
params: {
|
|
424
|
+
context,
|
|
425
|
+
bid,
|
|
426
|
+
iframeUrl
|
|
427
|
+
}
|
|
428
|
+
});
|
|
365
429
|
return null;
|
|
366
430
|
}
|
|
367
431
|
const inlineContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -378,11 +442,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
378
442
|
...iframeStyles
|
|
379
443
|
},
|
|
380
444
|
onError: () => {
|
|
381
|
-
debug("
|
|
445
|
+
debug("Format:iframeError");
|
|
382
446
|
reset();
|
|
383
447
|
},
|
|
384
448
|
onLoad: () => {
|
|
385
|
-
debug("
|
|
449
|
+
debug("Format:iframeLoad");
|
|
386
450
|
}
|
|
387
451
|
}
|
|
388
452
|
);
|
|
@@ -415,11 +479,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
415
479
|
borderWidth: 0
|
|
416
480
|
},
|
|
417
481
|
onError: () => {
|
|
418
|
-
debug("
|
|
482
|
+
debug("Format:modalError");
|
|
419
483
|
resetModal();
|
|
420
484
|
},
|
|
421
485
|
onLoad: () => {
|
|
422
|
-
debug("
|
|
486
|
+
debug("Format:modalLoad");
|
|
423
487
|
setModalLoaded(true);
|
|
424
488
|
}
|
|
425
489
|
}
|
|
@@ -460,7 +524,7 @@ var import_react_native3 = require("react-native");
|
|
|
460
524
|
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
461
525
|
|
|
462
526
|
// package.json
|
|
463
|
-
var version = "3.0.
|
|
527
|
+
var version = "3.0.7-rc.1";
|
|
464
528
|
|
|
465
529
|
// src/NativeRNKontext.ts
|
|
466
530
|
var import_react_native2 = require("react-native");
|
package/dist/index.mjs
CHANGED
|
@@ -116,7 +116,9 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
116
116
|
context?.captureError(new Error("Processing iframe error"));
|
|
117
117
|
};
|
|
118
118
|
const resetModal = () => {
|
|
119
|
+
debugModal("Format:resetModal");
|
|
119
120
|
if (modalInitTimeoutRef.current) {
|
|
121
|
+
debugModal("Format:resetModalTimeout");
|
|
120
122
|
clearTimeout(modalInitTimeoutRef.current);
|
|
121
123
|
modalInitTimeoutRef.current = null;
|
|
122
124
|
}
|
|
@@ -153,19 +155,27 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
153
155
|
...data
|
|
154
156
|
});
|
|
155
157
|
};
|
|
156
|
-
debug("
|
|
158
|
+
debug("Format:updateState");
|
|
157
159
|
const onMessage = (event) => {
|
|
158
160
|
try {
|
|
159
161
|
const data = JSON.parse(event.nativeEvent.data);
|
|
160
|
-
debug("
|
|
161
|
-
message: data
|
|
162
|
+
debug("Format:iframeMessage", {
|
|
163
|
+
message: data,
|
|
164
|
+
params: { data }
|
|
162
165
|
});
|
|
163
166
|
const messageHandler = handleIframeMessage(
|
|
164
167
|
(message) => {
|
|
165
168
|
switch (message.type) {
|
|
166
169
|
case "init-iframe":
|
|
167
170
|
setIframeLoaded(true);
|
|
168
|
-
debug("
|
|
171
|
+
debug("Format:iframePostMessage", {
|
|
172
|
+
params: {
|
|
173
|
+
messages: context?.messages,
|
|
174
|
+
sdk: "sdk-react-native",
|
|
175
|
+
otherParams,
|
|
176
|
+
messageId
|
|
177
|
+
}
|
|
178
|
+
});
|
|
169
179
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
170
180
|
messages: context?.messages,
|
|
171
181
|
sdk: "sdk-react-native",
|
|
@@ -225,7 +235,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
225
235
|
);
|
|
226
236
|
messageHandler({ data });
|
|
227
237
|
} catch (e) {
|
|
228
|
-
debug("
|
|
238
|
+
debug("Format:iframeMessageError", {
|
|
239
|
+
params: { error: e },
|
|
229
240
|
error: e
|
|
230
241
|
});
|
|
231
242
|
console.error("error parsing message from webview", e);
|
|
@@ -235,7 +246,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
235
246
|
const onModalMessage = (event) => {
|
|
236
247
|
try {
|
|
237
248
|
const data = JSON.parse(event.nativeEvent.data);
|
|
238
|
-
debugModal("
|
|
249
|
+
debugModal("Format:modalIframeMessage", {
|
|
250
|
+
params: { data },
|
|
239
251
|
message: data
|
|
240
252
|
});
|
|
241
253
|
const messageHandler = handleIframeMessage(
|
|
@@ -278,7 +290,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
278
290
|
);
|
|
279
291
|
messageHandler({ data });
|
|
280
292
|
} catch (e) {
|
|
281
|
-
debugModal("
|
|
293
|
+
debugModal("Format:modalIframeMessageError", {
|
|
294
|
+
params: { error: e },
|
|
282
295
|
error: e
|
|
283
296
|
});
|
|
284
297
|
console.error("error parsing message from webview", e);
|
|
@@ -288,16 +301,36 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
288
301
|
const paramsString = convertParamsToString(otherParams);
|
|
289
302
|
useEffect(() => {
|
|
290
303
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
304
|
+
debug("Format:iframePostMessageNotLoaded", {
|
|
305
|
+
params: {
|
|
306
|
+
iframeLoaded,
|
|
307
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
308
|
+
bid
|
|
309
|
+
}
|
|
310
|
+
});
|
|
291
311
|
return;
|
|
292
312
|
}
|
|
293
|
-
debug("
|
|
313
|
+
debug("Format:iframePostMessage", {
|
|
314
|
+
params: {
|
|
315
|
+
otherParams
|
|
316
|
+
}
|
|
317
|
+
});
|
|
294
318
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
295
319
|
data: { otherParams },
|
|
296
320
|
code
|
|
297
321
|
});
|
|
298
322
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code]);
|
|
299
323
|
const checkIfInViewport = () => {
|
|
300
|
-
if (!containerRef.current)
|
|
324
|
+
if (!containerRef.current) {
|
|
325
|
+
debug("Format:checkIfInViewportNoContainer");
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
debug("Format:checkIfInViewportMeasure", {
|
|
329
|
+
params: {
|
|
330
|
+
windowWidth,
|
|
331
|
+
windowHeight
|
|
332
|
+
}
|
|
333
|
+
});
|
|
301
334
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
302
335
|
sendMessage(webViewRef, "update-dimensions-iframe", code, {
|
|
303
336
|
windowWidth,
|
|
@@ -308,29 +341,60 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
308
341
|
containerY,
|
|
309
342
|
keyboardHeight: keyboardHeightRef.current
|
|
310
343
|
});
|
|
344
|
+
debug("Format:checkIfInViewportMeasureSend", {
|
|
345
|
+
params: {
|
|
346
|
+
windowWidth,
|
|
347
|
+
windowHeight,
|
|
348
|
+
containerWidth,
|
|
349
|
+
containerHeight,
|
|
350
|
+
containerX,
|
|
351
|
+
containerY,
|
|
352
|
+
keyboardHeight: keyboardHeightRef.current
|
|
353
|
+
}
|
|
354
|
+
});
|
|
311
355
|
});
|
|
312
356
|
};
|
|
313
357
|
useEffect(() => {
|
|
314
|
-
if (!isAdViewVisible)
|
|
358
|
+
if (!isAdViewVisible) {
|
|
359
|
+
debug("Format:checkIfInViewportNotVisible");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
315
362
|
const interval = setInterval(() => {
|
|
316
363
|
checkIfInViewport();
|
|
317
364
|
}, 250);
|
|
318
|
-
return () =>
|
|
365
|
+
return () => {
|
|
366
|
+
clearInterval(interval);
|
|
367
|
+
debug("Format:checkIfInViewportCleanup");
|
|
368
|
+
};
|
|
319
369
|
}, [isAdViewVisible]);
|
|
320
370
|
useEffect(() => {
|
|
321
371
|
const showSubscription = Keyboard.addListener("keyboardDidShow", (e) => {
|
|
372
|
+
debug("Format:keyboardDidShow", {
|
|
373
|
+
params: {
|
|
374
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0
|
|
375
|
+
}
|
|
376
|
+
});
|
|
322
377
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
323
378
|
});
|
|
324
379
|
const hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
|
|
380
|
+
debug("Format:keyboardDidHide");
|
|
325
381
|
keyboardHeightRef.current = 0;
|
|
326
382
|
});
|
|
327
383
|
return () => {
|
|
328
384
|
showSubscription.remove();
|
|
329
385
|
hideSubscription.remove();
|
|
330
386
|
keyboardHeightRef.current = 0;
|
|
387
|
+
debug("Format:keyboardEffectCleanup");
|
|
331
388
|
};
|
|
332
389
|
}, []);
|
|
333
390
|
if (!context || !bid || !iframeUrl) {
|
|
391
|
+
debug("Format:noContextOrBidOrIframeUrl", {
|
|
392
|
+
params: {
|
|
393
|
+
context,
|
|
394
|
+
bid,
|
|
395
|
+
iframeUrl
|
|
396
|
+
}
|
|
397
|
+
});
|
|
334
398
|
return null;
|
|
335
399
|
}
|
|
336
400
|
const inlineContent = /* @__PURE__ */ jsx2(
|
|
@@ -347,11 +411,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
347
411
|
...iframeStyles
|
|
348
412
|
},
|
|
349
413
|
onError: () => {
|
|
350
|
-
debug("
|
|
414
|
+
debug("Format:iframeError");
|
|
351
415
|
reset();
|
|
352
416
|
},
|
|
353
417
|
onLoad: () => {
|
|
354
|
-
debug("
|
|
418
|
+
debug("Format:iframeLoad");
|
|
355
419
|
}
|
|
356
420
|
}
|
|
357
421
|
);
|
|
@@ -384,11 +448,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
384
448
|
borderWidth: 0
|
|
385
449
|
},
|
|
386
450
|
onError: () => {
|
|
387
|
-
debug("
|
|
451
|
+
debug("Format:modalError");
|
|
388
452
|
resetModal();
|
|
389
453
|
},
|
|
390
454
|
onLoad: () => {
|
|
391
|
-
debug("
|
|
455
|
+
debug("Format:modalLoad");
|
|
392
456
|
setModalLoaded(true);
|
|
393
457
|
}
|
|
394
458
|
}
|
|
@@ -432,7 +496,7 @@ import { Appearance, Dimensions, PixelRatio, Platform } from "react-native";
|
|
|
432
496
|
import DeviceInfo from "react-native-device-info";
|
|
433
497
|
|
|
434
498
|
// package.json
|
|
435
|
-
var version = "3.0.
|
|
499
|
+
var version = "3.0.7-rc.1";
|
|
436
500
|
|
|
437
501
|
// src/NativeRNKontext.ts
|
|
438
502
|
import { TurboModuleRegistry } from "react-native";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontextso/sdk-react-native",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7-rc.1",
|
|
4
4
|
"description": "Kontext SDK for React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"react-native-webview": "^13.10.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@kontextso/sdk-react": "^3.0.
|
|
57
|
+
"@kontextso/sdk-react": "^3.0.7-rc.1"
|
|
58
58
|
},
|
|
59
59
|
"files": [
|
|
60
60
|
"dist/*",
|
package/src/formats/Format.tsx
CHANGED
|
@@ -89,7 +89,9 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const resetModal = () => {
|
|
92
|
+
debugModal('Format:resetModal')
|
|
92
93
|
if (modalInitTimeoutRef.current) {
|
|
94
|
+
debugModal('Format:resetModalTimeout')
|
|
93
95
|
clearTimeout(modalInitTimeoutRef.current)
|
|
94
96
|
modalInitTimeoutRef.current = null
|
|
95
97
|
}
|
|
@@ -130,14 +132,15 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
130
132
|
})
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
debug('
|
|
135
|
+
debug('Format:updateState')
|
|
134
136
|
|
|
135
137
|
const onMessage = (event: WebViewMessageEvent) => {
|
|
136
138
|
try {
|
|
137
139
|
const data = JSON.parse(event.nativeEvent.data) as IframeMessage
|
|
138
140
|
|
|
139
|
-
debug('
|
|
141
|
+
debug('Format:iframeMessage', {
|
|
140
142
|
message: data,
|
|
143
|
+
params: { data }
|
|
141
144
|
})
|
|
142
145
|
|
|
143
146
|
const messageHandler = handleIframeMessage(
|
|
@@ -145,7 +148,14 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
145
148
|
switch (message.type) {
|
|
146
149
|
case 'init-iframe':
|
|
147
150
|
setIframeLoaded(true)
|
|
148
|
-
debug('
|
|
151
|
+
debug('Format:iframePostMessage', {
|
|
152
|
+
params: {
|
|
153
|
+
messages: context?.messages,
|
|
154
|
+
sdk: 'sdk-react-native',
|
|
155
|
+
otherParams,
|
|
156
|
+
messageId,
|
|
157
|
+
}
|
|
158
|
+
})
|
|
149
159
|
sendMessage(webViewRef, 'update-iframe', code, {
|
|
150
160
|
messages: context?.messages,
|
|
151
161
|
sdk: 'sdk-react-native',
|
|
@@ -216,7 +226,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
216
226
|
)
|
|
217
227
|
messageHandler({ data } as IframeMessageEvent)
|
|
218
228
|
} catch (e) {
|
|
219
|
-
debug('
|
|
229
|
+
debug('Format:iframeMessageError', {
|
|
230
|
+
params: { error: e },
|
|
220
231
|
error: e,
|
|
221
232
|
})
|
|
222
233
|
console.error('error parsing message from webview', e)
|
|
@@ -228,7 +239,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
228
239
|
try {
|
|
229
240
|
const data = JSON.parse(event.nativeEvent.data) as IframeMessage
|
|
230
241
|
|
|
231
|
-
debugModal('
|
|
242
|
+
debugModal('Format:modalIframeMessage', {
|
|
243
|
+
params: { data },
|
|
232
244
|
message: data,
|
|
233
245
|
})
|
|
234
246
|
|
|
@@ -279,7 +291,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
279
291
|
)
|
|
280
292
|
messageHandler({ data } as IframeMessageEvent)
|
|
281
293
|
} catch (e) {
|
|
282
|
-
debugModal('
|
|
294
|
+
debugModal('Format:modalIframeMessageError', {
|
|
295
|
+
params: { error: e },
|
|
283
296
|
error: e,
|
|
284
297
|
})
|
|
285
298
|
console.error('error parsing message from webview', e)
|
|
@@ -291,9 +304,20 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
291
304
|
|
|
292
305
|
useEffect(() => {
|
|
293
306
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
307
|
+
debug('Format:iframePostMessageNotLoaded', {
|
|
308
|
+
params: {
|
|
309
|
+
iframeLoaded,
|
|
310
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
311
|
+
bid,
|
|
312
|
+
}
|
|
313
|
+
})
|
|
294
314
|
return
|
|
295
315
|
}
|
|
296
|
-
debug('
|
|
316
|
+
debug('Format:iframePostMessage', {
|
|
317
|
+
params: {
|
|
318
|
+
otherParams
|
|
319
|
+
}
|
|
320
|
+
})
|
|
297
321
|
sendMessage(webViewRef, 'update-iframe', code, {
|
|
298
322
|
data: { otherParams },
|
|
299
323
|
code,
|
|
@@ -302,7 +326,17 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
302
326
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code])
|
|
303
327
|
|
|
304
328
|
const checkIfInViewport = () => {
|
|
305
|
-
if (!containerRef.current)
|
|
329
|
+
if (!containerRef.current) {
|
|
330
|
+
debug('Format:checkIfInViewportNoContainer')
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
debug('Format:checkIfInViewportMeasure', {
|
|
335
|
+
params: {
|
|
336
|
+
windowWidth,
|
|
337
|
+
windowHeight,
|
|
338
|
+
}
|
|
339
|
+
})
|
|
306
340
|
|
|
307
341
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
308
342
|
sendMessage(webViewRef, 'update-dimensions-iframe', code, {
|
|
@@ -314,24 +348,47 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
314
348
|
containerY,
|
|
315
349
|
keyboardHeight: keyboardHeightRef.current,
|
|
316
350
|
})
|
|
351
|
+
debug('Format:checkIfInViewportMeasureSend', {
|
|
352
|
+
params: {
|
|
353
|
+
windowWidth,
|
|
354
|
+
windowHeight,
|
|
355
|
+
containerWidth,
|
|
356
|
+
containerHeight,
|
|
357
|
+
containerX,
|
|
358
|
+
containerY,
|
|
359
|
+
keyboardHeight: keyboardHeightRef.current,
|
|
360
|
+
}
|
|
361
|
+
})
|
|
317
362
|
})
|
|
318
363
|
}
|
|
319
364
|
|
|
320
365
|
useEffect(() => {
|
|
321
|
-
if (!isAdViewVisible)
|
|
366
|
+
if (!isAdViewVisible) {
|
|
367
|
+
debug('Format:checkIfInViewportNotVisible')
|
|
368
|
+
return
|
|
369
|
+
}
|
|
322
370
|
|
|
323
371
|
const interval = setInterval(() => {
|
|
324
372
|
checkIfInViewport()
|
|
325
373
|
}, 250)
|
|
326
374
|
|
|
327
|
-
return () =>
|
|
375
|
+
return () => {
|
|
376
|
+
clearInterval(interval)
|
|
377
|
+
debug('Format:checkIfInViewportCleanup')
|
|
378
|
+
}
|
|
328
379
|
}, [isAdViewVisible])
|
|
329
380
|
|
|
330
381
|
useEffect(() => {
|
|
331
382
|
const showSubscription = Keyboard.addListener('keyboardDidShow', (e) => {
|
|
383
|
+
debug('Format:keyboardDidShow', {
|
|
384
|
+
params: {
|
|
385
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0,
|
|
386
|
+
}
|
|
387
|
+
})
|
|
332
388
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0
|
|
333
389
|
})
|
|
334
390
|
const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {
|
|
391
|
+
debug('Format:keyboardDidHide')
|
|
335
392
|
keyboardHeightRef.current = 0
|
|
336
393
|
})
|
|
337
394
|
|
|
@@ -339,10 +396,18 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
339
396
|
showSubscription.remove()
|
|
340
397
|
hideSubscription.remove()
|
|
341
398
|
keyboardHeightRef.current = 0
|
|
399
|
+
debug('Format:keyboardEffectCleanup')
|
|
342
400
|
}
|
|
343
401
|
}, [])
|
|
344
402
|
|
|
345
403
|
if (!context || !bid || !iframeUrl) {
|
|
404
|
+
debug('Format:noContextOrBidOrIframeUrl', {
|
|
405
|
+
params: {
|
|
406
|
+
context,
|
|
407
|
+
bid,
|
|
408
|
+
iframeUrl,
|
|
409
|
+
}
|
|
410
|
+
})
|
|
346
411
|
return null
|
|
347
412
|
}
|
|
348
413
|
|
|
@@ -359,11 +424,11 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
359
424
|
...iframeStyles,
|
|
360
425
|
}}
|
|
361
426
|
onError={() => {
|
|
362
|
-
debug('
|
|
427
|
+
debug('Format:iframeError')
|
|
363
428
|
reset()
|
|
364
429
|
}}
|
|
365
430
|
onLoad={() => {
|
|
366
|
-
debug('
|
|
431
|
+
debug('Format:iframeLoad')
|
|
367
432
|
}}
|
|
368
433
|
/>
|
|
369
434
|
)
|
|
@@ -394,11 +459,11 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
394
459
|
borderWidth: 0,
|
|
395
460
|
}}
|
|
396
461
|
onError={() => {
|
|
397
|
-
debug('
|
|
462
|
+
debug('Format:modalError')
|
|
398
463
|
resetModal()
|
|
399
464
|
}}
|
|
400
465
|
onLoad={() => {
|
|
401
|
-
debug('
|
|
466
|
+
debug('Format:modalLoad')
|
|
402
467
|
setModalLoaded(true)
|
|
403
468
|
}}
|
|
404
469
|
/>
|