@kontextso/sdk-react-native 3.0.6 → 3.0.7-rc.2
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 +170 -16
- package/dist/index.mjs +170 -16
- package/package.json +2 -2
- package/src/formats/Format.tsx +169 -14
package/dist/index.js
CHANGED
|
@@ -147,7 +147,21 @@ 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", {
|
|
151
|
+
params: {
|
|
152
|
+
messageId,
|
|
153
|
+
code,
|
|
154
|
+
otherParams
|
|
155
|
+
}
|
|
156
|
+
});
|
|
150
157
|
if (modalInitTimeoutRef.current) {
|
|
158
|
+
debugModal("Format:resetModalTimeout", {
|
|
159
|
+
params: {
|
|
160
|
+
messageId,
|
|
161
|
+
code,
|
|
162
|
+
otherParams
|
|
163
|
+
}
|
|
164
|
+
});
|
|
151
165
|
clearTimeout(modalInitTimeoutRef.current);
|
|
152
166
|
modalInitTimeoutRef.current = null;
|
|
153
167
|
}
|
|
@@ -184,19 +198,34 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
184
198
|
...data
|
|
185
199
|
});
|
|
186
200
|
};
|
|
187
|
-
debug("
|
|
201
|
+
debug("Format:updateState", {
|
|
202
|
+
params: {
|
|
203
|
+
messageId,
|
|
204
|
+
code,
|
|
205
|
+
otherParams
|
|
206
|
+
}
|
|
207
|
+
});
|
|
188
208
|
const onMessage = (event) => {
|
|
189
209
|
try {
|
|
190
210
|
const data = JSON.parse(event.nativeEvent.data);
|
|
191
|
-
debug("
|
|
192
|
-
message: data
|
|
211
|
+
debug("Format:iframeMessage", {
|
|
212
|
+
message: data,
|
|
213
|
+
params: { data, messageId, code, otherParams }
|
|
193
214
|
});
|
|
194
215
|
const messageHandler = handleIframeMessage(
|
|
195
216
|
(message) => {
|
|
196
217
|
switch (message.type) {
|
|
197
218
|
case "init-iframe":
|
|
198
219
|
setIframeLoaded(true);
|
|
199
|
-
debug("
|
|
220
|
+
debug("Format:iframePostMessage", {
|
|
221
|
+
params: {
|
|
222
|
+
code,
|
|
223
|
+
messages: context?.messages,
|
|
224
|
+
sdk: "sdk-react-native",
|
|
225
|
+
otherParams,
|
|
226
|
+
messageId
|
|
227
|
+
}
|
|
228
|
+
});
|
|
200
229
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
201
230
|
messages: context?.messages,
|
|
202
231
|
sdk: "sdk-react-native",
|
|
@@ -256,7 +285,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
256
285
|
);
|
|
257
286
|
messageHandler({ data });
|
|
258
287
|
} catch (e) {
|
|
259
|
-
debug("
|
|
288
|
+
debug("Format:iframeMessageError", {
|
|
289
|
+
params: { error: e, messageId, code, otherParams },
|
|
260
290
|
error: e
|
|
261
291
|
});
|
|
262
292
|
console.error("error parsing message from webview", e);
|
|
@@ -266,7 +296,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
266
296
|
const onModalMessage = (event) => {
|
|
267
297
|
try {
|
|
268
298
|
const data = JSON.parse(event.nativeEvent.data);
|
|
269
|
-
debugModal("
|
|
299
|
+
debugModal("Format:modalIframeMessage", {
|
|
300
|
+
params: { data, messageId, code, otherParams },
|
|
270
301
|
message: data
|
|
271
302
|
});
|
|
272
303
|
const messageHandler = handleIframeMessage(
|
|
@@ -309,7 +340,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
309
340
|
);
|
|
310
341
|
messageHandler({ data });
|
|
311
342
|
} catch (e) {
|
|
312
|
-
debugModal("
|
|
343
|
+
debugModal("Format:modalIframeMessageError", {
|
|
344
|
+
params: { error: e, messageId, code, otherParams },
|
|
313
345
|
error: e
|
|
314
346
|
});
|
|
315
347
|
console.error("error parsing message from webview", e);
|
|
@@ -319,16 +351,50 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
319
351
|
const paramsString = (0, import_sdk_react.convertParamsToString)(otherParams);
|
|
320
352
|
(0, import_react2.useEffect)(() => {
|
|
321
353
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
354
|
+
debug("Format:iframePostMessageNotLoaded", {
|
|
355
|
+
params: {
|
|
356
|
+
messageId,
|
|
357
|
+
iframeLoaded,
|
|
358
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
359
|
+
bid,
|
|
360
|
+
code,
|
|
361
|
+
otherParams
|
|
362
|
+
}
|
|
363
|
+
});
|
|
322
364
|
return;
|
|
323
365
|
}
|
|
324
|
-
debug("
|
|
366
|
+
debug("Format:iframePostMessage", {
|
|
367
|
+
params: {
|
|
368
|
+
messageId,
|
|
369
|
+
otherParams,
|
|
370
|
+
code
|
|
371
|
+
}
|
|
372
|
+
});
|
|
325
373
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
326
374
|
data: { otherParams },
|
|
327
375
|
code
|
|
328
376
|
});
|
|
329
377
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code]);
|
|
330
378
|
const checkIfInViewport = () => {
|
|
331
|
-
if (!containerRef.current)
|
|
379
|
+
if (!containerRef.current) {
|
|
380
|
+
debug("Format:checkIfInViewportNoContainer", {
|
|
381
|
+
params: {
|
|
382
|
+
messageId,
|
|
383
|
+
code,
|
|
384
|
+
otherParams
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
debug("Format:checkIfInViewportMeasure", {
|
|
390
|
+
params: {
|
|
391
|
+
windowWidth,
|
|
392
|
+
windowHeight,
|
|
393
|
+
messageId,
|
|
394
|
+
code,
|
|
395
|
+
otherParams
|
|
396
|
+
}
|
|
397
|
+
});
|
|
332
398
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
333
399
|
sendMessage(webViewRef, "update-dimensions-iframe", code, {
|
|
334
400
|
windowWidth,
|
|
@@ -339,29 +405,93 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
339
405
|
containerY,
|
|
340
406
|
keyboardHeight: keyboardHeightRef.current
|
|
341
407
|
});
|
|
408
|
+
debug("Format:checkIfInViewportMeasureSend", {
|
|
409
|
+
params: {
|
|
410
|
+
messageId,
|
|
411
|
+
code,
|
|
412
|
+
otherParams,
|
|
413
|
+
windowWidth,
|
|
414
|
+
windowHeight,
|
|
415
|
+
containerWidth,
|
|
416
|
+
containerHeight,
|
|
417
|
+
containerX,
|
|
418
|
+
containerY,
|
|
419
|
+
keyboardHeight: keyboardHeightRef.current
|
|
420
|
+
}
|
|
421
|
+
});
|
|
342
422
|
});
|
|
343
423
|
};
|
|
344
424
|
(0, import_react2.useEffect)(() => {
|
|
345
|
-
if (!isAdViewVisible)
|
|
425
|
+
if (!isAdViewVisible) {
|
|
426
|
+
debug("Format:checkIfInViewportNotVisible", {
|
|
427
|
+
params: {
|
|
428
|
+
messageId,
|
|
429
|
+
code,
|
|
430
|
+
otherParams
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
346
435
|
const interval = setInterval(() => {
|
|
347
436
|
checkIfInViewport();
|
|
348
437
|
}, 250);
|
|
349
|
-
return () =>
|
|
438
|
+
return () => {
|
|
439
|
+
clearInterval(interval);
|
|
440
|
+
debug("Format:checkIfInViewportCleanup", {
|
|
441
|
+
params: {
|
|
442
|
+
messageId,
|
|
443
|
+
code,
|
|
444
|
+
otherParams
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
};
|
|
350
448
|
}, [isAdViewVisible]);
|
|
351
449
|
(0, import_react2.useEffect)(() => {
|
|
352
450
|
const showSubscription = import_react_native.Keyboard.addListener("keyboardDidShow", (e) => {
|
|
451
|
+
debug("Format:keyboardDidShow", {
|
|
452
|
+
params: {
|
|
453
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0,
|
|
454
|
+
messageId,
|
|
455
|
+
code,
|
|
456
|
+
otherParams
|
|
457
|
+
}
|
|
458
|
+
});
|
|
353
459
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
354
460
|
});
|
|
355
461
|
const hideSubscription = import_react_native.Keyboard.addListener("keyboardDidHide", () => {
|
|
462
|
+
debug("Format:keyboardDidHide", {
|
|
463
|
+
params: {
|
|
464
|
+
messageId,
|
|
465
|
+
code,
|
|
466
|
+
otherParams
|
|
467
|
+
}
|
|
468
|
+
});
|
|
356
469
|
keyboardHeightRef.current = 0;
|
|
357
470
|
});
|
|
358
471
|
return () => {
|
|
359
472
|
showSubscription.remove();
|
|
360
473
|
hideSubscription.remove();
|
|
361
474
|
keyboardHeightRef.current = 0;
|
|
475
|
+
debug("Format:keyboardEffectCleanup", {
|
|
476
|
+
params: {
|
|
477
|
+
messageId,
|
|
478
|
+
code,
|
|
479
|
+
otherParams
|
|
480
|
+
}
|
|
481
|
+
});
|
|
362
482
|
};
|
|
363
483
|
}, []);
|
|
364
484
|
if (!context || !bid || !iframeUrl) {
|
|
485
|
+
debug("Format:noContextOrBidOrIframeUrl", {
|
|
486
|
+
params: {
|
|
487
|
+
context,
|
|
488
|
+
bid,
|
|
489
|
+
iframeUrl,
|
|
490
|
+
messageId,
|
|
491
|
+
code,
|
|
492
|
+
otherParams
|
|
493
|
+
}
|
|
494
|
+
});
|
|
365
495
|
return null;
|
|
366
496
|
}
|
|
367
497
|
const inlineContent = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -378,11 +508,23 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
378
508
|
...iframeStyles
|
|
379
509
|
},
|
|
380
510
|
onError: () => {
|
|
381
|
-
debug("
|
|
511
|
+
debug("Format:iframeError", {
|
|
512
|
+
params: {
|
|
513
|
+
messageId,
|
|
514
|
+
code,
|
|
515
|
+
otherParams
|
|
516
|
+
}
|
|
517
|
+
});
|
|
382
518
|
reset();
|
|
383
519
|
},
|
|
384
520
|
onLoad: () => {
|
|
385
|
-
debug("
|
|
521
|
+
debug("Format:iframeLoad", {
|
|
522
|
+
params: {
|
|
523
|
+
messageId,
|
|
524
|
+
code,
|
|
525
|
+
otherParams
|
|
526
|
+
}
|
|
527
|
+
});
|
|
386
528
|
}
|
|
387
529
|
}
|
|
388
530
|
);
|
|
@@ -415,11 +557,23 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
415
557
|
borderWidth: 0
|
|
416
558
|
},
|
|
417
559
|
onError: () => {
|
|
418
|
-
debug("
|
|
560
|
+
debug("Format:modalError", {
|
|
561
|
+
params: {
|
|
562
|
+
messageId,
|
|
563
|
+
code,
|
|
564
|
+
otherParams
|
|
565
|
+
}
|
|
566
|
+
});
|
|
419
567
|
resetModal();
|
|
420
568
|
},
|
|
421
569
|
onLoad: () => {
|
|
422
|
-
debug("
|
|
570
|
+
debug("Format:modalLoad", {
|
|
571
|
+
params: {
|
|
572
|
+
messageId,
|
|
573
|
+
code,
|
|
574
|
+
otherParams
|
|
575
|
+
}
|
|
576
|
+
});
|
|
423
577
|
setModalLoaded(true);
|
|
424
578
|
}
|
|
425
579
|
}
|
|
@@ -460,7 +614,7 @@ var import_react_native3 = require("react-native");
|
|
|
460
614
|
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
461
615
|
|
|
462
616
|
// package.json
|
|
463
|
-
var version = "3.0.
|
|
617
|
+
var version = "3.0.7-rc.2";
|
|
464
618
|
|
|
465
619
|
// src/NativeRNKontext.ts
|
|
466
620
|
var import_react_native2 = require("react-native");
|
package/dist/index.mjs
CHANGED
|
@@ -116,7 +116,21 @@ 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", {
|
|
120
|
+
params: {
|
|
121
|
+
messageId,
|
|
122
|
+
code,
|
|
123
|
+
otherParams
|
|
124
|
+
}
|
|
125
|
+
});
|
|
119
126
|
if (modalInitTimeoutRef.current) {
|
|
127
|
+
debugModal("Format:resetModalTimeout", {
|
|
128
|
+
params: {
|
|
129
|
+
messageId,
|
|
130
|
+
code,
|
|
131
|
+
otherParams
|
|
132
|
+
}
|
|
133
|
+
});
|
|
120
134
|
clearTimeout(modalInitTimeoutRef.current);
|
|
121
135
|
modalInitTimeoutRef.current = null;
|
|
122
136
|
}
|
|
@@ -153,19 +167,34 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
153
167
|
...data
|
|
154
168
|
});
|
|
155
169
|
};
|
|
156
|
-
debug("
|
|
170
|
+
debug("Format:updateState", {
|
|
171
|
+
params: {
|
|
172
|
+
messageId,
|
|
173
|
+
code,
|
|
174
|
+
otherParams
|
|
175
|
+
}
|
|
176
|
+
});
|
|
157
177
|
const onMessage = (event) => {
|
|
158
178
|
try {
|
|
159
179
|
const data = JSON.parse(event.nativeEvent.data);
|
|
160
|
-
debug("
|
|
161
|
-
message: data
|
|
180
|
+
debug("Format:iframeMessage", {
|
|
181
|
+
message: data,
|
|
182
|
+
params: { data, messageId, code, otherParams }
|
|
162
183
|
});
|
|
163
184
|
const messageHandler = handleIframeMessage(
|
|
164
185
|
(message) => {
|
|
165
186
|
switch (message.type) {
|
|
166
187
|
case "init-iframe":
|
|
167
188
|
setIframeLoaded(true);
|
|
168
|
-
debug("
|
|
189
|
+
debug("Format:iframePostMessage", {
|
|
190
|
+
params: {
|
|
191
|
+
code,
|
|
192
|
+
messages: context?.messages,
|
|
193
|
+
sdk: "sdk-react-native",
|
|
194
|
+
otherParams,
|
|
195
|
+
messageId
|
|
196
|
+
}
|
|
197
|
+
});
|
|
169
198
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
170
199
|
messages: context?.messages,
|
|
171
200
|
sdk: "sdk-react-native",
|
|
@@ -225,7 +254,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
225
254
|
);
|
|
226
255
|
messageHandler({ data });
|
|
227
256
|
} catch (e) {
|
|
228
|
-
debug("
|
|
257
|
+
debug("Format:iframeMessageError", {
|
|
258
|
+
params: { error: e, messageId, code, otherParams },
|
|
229
259
|
error: e
|
|
230
260
|
});
|
|
231
261
|
console.error("error parsing message from webview", e);
|
|
@@ -235,7 +265,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
235
265
|
const onModalMessage = (event) => {
|
|
236
266
|
try {
|
|
237
267
|
const data = JSON.parse(event.nativeEvent.data);
|
|
238
|
-
debugModal("
|
|
268
|
+
debugModal("Format:modalIframeMessage", {
|
|
269
|
+
params: { data, messageId, code, otherParams },
|
|
239
270
|
message: data
|
|
240
271
|
});
|
|
241
272
|
const messageHandler = handleIframeMessage(
|
|
@@ -278,7 +309,8 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
278
309
|
);
|
|
279
310
|
messageHandler({ data });
|
|
280
311
|
} catch (e) {
|
|
281
|
-
debugModal("
|
|
312
|
+
debugModal("Format:modalIframeMessageError", {
|
|
313
|
+
params: { error: e, messageId, code, otherParams },
|
|
282
314
|
error: e
|
|
283
315
|
});
|
|
284
316
|
console.error("error parsing message from webview", e);
|
|
@@ -288,16 +320,50 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
288
320
|
const paramsString = convertParamsToString(otherParams);
|
|
289
321
|
useEffect(() => {
|
|
290
322
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
323
|
+
debug("Format:iframePostMessageNotLoaded", {
|
|
324
|
+
params: {
|
|
325
|
+
messageId,
|
|
326
|
+
iframeLoaded,
|
|
327
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
328
|
+
bid,
|
|
329
|
+
code,
|
|
330
|
+
otherParams
|
|
331
|
+
}
|
|
332
|
+
});
|
|
291
333
|
return;
|
|
292
334
|
}
|
|
293
|
-
debug("
|
|
335
|
+
debug("Format:iframePostMessage", {
|
|
336
|
+
params: {
|
|
337
|
+
messageId,
|
|
338
|
+
otherParams,
|
|
339
|
+
code
|
|
340
|
+
}
|
|
341
|
+
});
|
|
294
342
|
sendMessage(webViewRef, "update-iframe", code, {
|
|
295
343
|
data: { otherParams },
|
|
296
344
|
code
|
|
297
345
|
});
|
|
298
346
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code]);
|
|
299
347
|
const checkIfInViewport = () => {
|
|
300
|
-
if (!containerRef.current)
|
|
348
|
+
if (!containerRef.current) {
|
|
349
|
+
debug("Format:checkIfInViewportNoContainer", {
|
|
350
|
+
params: {
|
|
351
|
+
messageId,
|
|
352
|
+
code,
|
|
353
|
+
otherParams
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
debug("Format:checkIfInViewportMeasure", {
|
|
359
|
+
params: {
|
|
360
|
+
windowWidth,
|
|
361
|
+
windowHeight,
|
|
362
|
+
messageId,
|
|
363
|
+
code,
|
|
364
|
+
otherParams
|
|
365
|
+
}
|
|
366
|
+
});
|
|
301
367
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
302
368
|
sendMessage(webViewRef, "update-dimensions-iframe", code, {
|
|
303
369
|
windowWidth,
|
|
@@ -308,29 +374,93 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
308
374
|
containerY,
|
|
309
375
|
keyboardHeight: keyboardHeightRef.current
|
|
310
376
|
});
|
|
377
|
+
debug("Format:checkIfInViewportMeasureSend", {
|
|
378
|
+
params: {
|
|
379
|
+
messageId,
|
|
380
|
+
code,
|
|
381
|
+
otherParams,
|
|
382
|
+
windowWidth,
|
|
383
|
+
windowHeight,
|
|
384
|
+
containerWidth,
|
|
385
|
+
containerHeight,
|
|
386
|
+
containerX,
|
|
387
|
+
containerY,
|
|
388
|
+
keyboardHeight: keyboardHeightRef.current
|
|
389
|
+
}
|
|
390
|
+
});
|
|
311
391
|
});
|
|
312
392
|
};
|
|
313
393
|
useEffect(() => {
|
|
314
|
-
if (!isAdViewVisible)
|
|
394
|
+
if (!isAdViewVisible) {
|
|
395
|
+
debug("Format:checkIfInViewportNotVisible", {
|
|
396
|
+
params: {
|
|
397
|
+
messageId,
|
|
398
|
+
code,
|
|
399
|
+
otherParams
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
315
404
|
const interval = setInterval(() => {
|
|
316
405
|
checkIfInViewport();
|
|
317
406
|
}, 250);
|
|
318
|
-
return () =>
|
|
407
|
+
return () => {
|
|
408
|
+
clearInterval(interval);
|
|
409
|
+
debug("Format:checkIfInViewportCleanup", {
|
|
410
|
+
params: {
|
|
411
|
+
messageId,
|
|
412
|
+
code,
|
|
413
|
+
otherParams
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
};
|
|
319
417
|
}, [isAdViewVisible]);
|
|
320
418
|
useEffect(() => {
|
|
321
419
|
const showSubscription = Keyboard.addListener("keyboardDidShow", (e) => {
|
|
420
|
+
debug("Format:keyboardDidShow", {
|
|
421
|
+
params: {
|
|
422
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0,
|
|
423
|
+
messageId,
|
|
424
|
+
code,
|
|
425
|
+
otherParams
|
|
426
|
+
}
|
|
427
|
+
});
|
|
322
428
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0;
|
|
323
429
|
});
|
|
324
430
|
const hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
|
|
431
|
+
debug("Format:keyboardDidHide", {
|
|
432
|
+
params: {
|
|
433
|
+
messageId,
|
|
434
|
+
code,
|
|
435
|
+
otherParams
|
|
436
|
+
}
|
|
437
|
+
});
|
|
325
438
|
keyboardHeightRef.current = 0;
|
|
326
439
|
});
|
|
327
440
|
return () => {
|
|
328
441
|
showSubscription.remove();
|
|
329
442
|
hideSubscription.remove();
|
|
330
443
|
keyboardHeightRef.current = 0;
|
|
444
|
+
debug("Format:keyboardEffectCleanup", {
|
|
445
|
+
params: {
|
|
446
|
+
messageId,
|
|
447
|
+
code,
|
|
448
|
+
otherParams
|
|
449
|
+
}
|
|
450
|
+
});
|
|
331
451
|
};
|
|
332
452
|
}, []);
|
|
333
453
|
if (!context || !bid || !iframeUrl) {
|
|
454
|
+
debug("Format:noContextOrBidOrIframeUrl", {
|
|
455
|
+
params: {
|
|
456
|
+
context,
|
|
457
|
+
bid,
|
|
458
|
+
iframeUrl,
|
|
459
|
+
messageId,
|
|
460
|
+
code,
|
|
461
|
+
otherParams
|
|
462
|
+
}
|
|
463
|
+
});
|
|
334
464
|
return null;
|
|
335
465
|
}
|
|
336
466
|
const inlineContent = /* @__PURE__ */ jsx2(
|
|
@@ -347,11 +477,23 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
347
477
|
...iframeStyles
|
|
348
478
|
},
|
|
349
479
|
onError: () => {
|
|
350
|
-
debug("
|
|
480
|
+
debug("Format:iframeError", {
|
|
481
|
+
params: {
|
|
482
|
+
messageId,
|
|
483
|
+
code,
|
|
484
|
+
otherParams
|
|
485
|
+
}
|
|
486
|
+
});
|
|
351
487
|
reset();
|
|
352
488
|
},
|
|
353
489
|
onLoad: () => {
|
|
354
|
-
debug("
|
|
490
|
+
debug("Format:iframeLoad", {
|
|
491
|
+
params: {
|
|
492
|
+
messageId,
|
|
493
|
+
code,
|
|
494
|
+
otherParams
|
|
495
|
+
}
|
|
496
|
+
});
|
|
355
497
|
}
|
|
356
498
|
}
|
|
357
499
|
);
|
|
@@ -384,11 +526,23 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
384
526
|
borderWidth: 0
|
|
385
527
|
},
|
|
386
528
|
onError: () => {
|
|
387
|
-
debug("
|
|
529
|
+
debug("Format:modalError", {
|
|
530
|
+
params: {
|
|
531
|
+
messageId,
|
|
532
|
+
code,
|
|
533
|
+
otherParams
|
|
534
|
+
}
|
|
535
|
+
});
|
|
388
536
|
resetModal();
|
|
389
537
|
},
|
|
390
538
|
onLoad: () => {
|
|
391
|
-
debug("
|
|
539
|
+
debug("Format:modalLoad", {
|
|
540
|
+
params: {
|
|
541
|
+
messageId,
|
|
542
|
+
code,
|
|
543
|
+
otherParams
|
|
544
|
+
}
|
|
545
|
+
});
|
|
392
546
|
setModalLoaded(true);
|
|
393
547
|
}
|
|
394
548
|
}
|
|
@@ -432,7 +586,7 @@ import { Appearance, Dimensions, PixelRatio, Platform } from "react-native";
|
|
|
432
586
|
import DeviceInfo from "react-native-device-info";
|
|
433
587
|
|
|
434
588
|
// package.json
|
|
435
|
-
var version = "3.0.
|
|
589
|
+
var version = "3.0.7-rc.2";
|
|
436
590
|
|
|
437
591
|
// src/NativeRNKontext.ts
|
|
438
592
|
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.2",
|
|
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,21 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const resetModal = () => {
|
|
92
|
+
debugModal('Format:resetModal', {
|
|
93
|
+
params: {
|
|
94
|
+
messageId,
|
|
95
|
+
code,
|
|
96
|
+
otherParams,
|
|
97
|
+
}
|
|
98
|
+
})
|
|
92
99
|
if (modalInitTimeoutRef.current) {
|
|
100
|
+
debugModal('Format:resetModalTimeout', {
|
|
101
|
+
params: {
|
|
102
|
+
messageId,
|
|
103
|
+
code,
|
|
104
|
+
otherParams,
|
|
105
|
+
}
|
|
106
|
+
})
|
|
93
107
|
clearTimeout(modalInitTimeoutRef.current)
|
|
94
108
|
modalInitTimeoutRef.current = null
|
|
95
109
|
}
|
|
@@ -130,14 +144,21 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
130
144
|
})
|
|
131
145
|
}
|
|
132
146
|
|
|
133
|
-
debug('
|
|
147
|
+
debug('Format:updateState', {
|
|
148
|
+
params: {
|
|
149
|
+
messageId,
|
|
150
|
+
code,
|
|
151
|
+
otherParams
|
|
152
|
+
}
|
|
153
|
+
})
|
|
134
154
|
|
|
135
155
|
const onMessage = (event: WebViewMessageEvent) => {
|
|
136
156
|
try {
|
|
137
157
|
const data = JSON.parse(event.nativeEvent.data) as IframeMessage
|
|
138
158
|
|
|
139
|
-
debug('
|
|
159
|
+
debug('Format:iframeMessage', {
|
|
140
160
|
message: data,
|
|
161
|
+
params: { data, messageId, code, otherParams }
|
|
141
162
|
})
|
|
142
163
|
|
|
143
164
|
const messageHandler = handleIframeMessage(
|
|
@@ -145,7 +166,15 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
145
166
|
switch (message.type) {
|
|
146
167
|
case 'init-iframe':
|
|
147
168
|
setIframeLoaded(true)
|
|
148
|
-
debug('
|
|
169
|
+
debug('Format:iframePostMessage', {
|
|
170
|
+
params: {
|
|
171
|
+
code,
|
|
172
|
+
messages: context?.messages,
|
|
173
|
+
sdk: 'sdk-react-native',
|
|
174
|
+
otherParams,
|
|
175
|
+
messageId,
|
|
176
|
+
}
|
|
177
|
+
})
|
|
149
178
|
sendMessage(webViewRef, 'update-iframe', code, {
|
|
150
179
|
messages: context?.messages,
|
|
151
180
|
sdk: 'sdk-react-native',
|
|
@@ -216,7 +245,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
216
245
|
)
|
|
217
246
|
messageHandler({ data } as IframeMessageEvent)
|
|
218
247
|
} catch (e) {
|
|
219
|
-
debug('
|
|
248
|
+
debug('Format:iframeMessageError', {
|
|
249
|
+
params: { error: e, messageId, code, otherParams },
|
|
220
250
|
error: e,
|
|
221
251
|
})
|
|
222
252
|
console.error('error parsing message from webview', e)
|
|
@@ -228,7 +258,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
228
258
|
try {
|
|
229
259
|
const data = JSON.parse(event.nativeEvent.data) as IframeMessage
|
|
230
260
|
|
|
231
|
-
debugModal('
|
|
261
|
+
debugModal('Format:modalIframeMessage', {
|
|
262
|
+
params: { data, messageId, code, otherParams },
|
|
232
263
|
message: data,
|
|
233
264
|
})
|
|
234
265
|
|
|
@@ -279,7 +310,8 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
279
310
|
)
|
|
280
311
|
messageHandler({ data } as IframeMessageEvent)
|
|
281
312
|
} catch (e) {
|
|
282
|
-
debugModal('
|
|
313
|
+
debugModal('Format:modalIframeMessageError', {
|
|
314
|
+
params: { error: e, messageId, code, otherParams },
|
|
283
315
|
error: e,
|
|
284
316
|
})
|
|
285
317
|
console.error('error parsing message from webview', e)
|
|
@@ -291,9 +323,25 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
291
323
|
|
|
292
324
|
useEffect(() => {
|
|
293
325
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
326
|
+
debug('Format:iframePostMessageNotLoaded', {
|
|
327
|
+
params: {
|
|
328
|
+
messageId,
|
|
329
|
+
iframeLoaded,
|
|
330
|
+
contextAdServerUrl: context?.adServerUrl,
|
|
331
|
+
bid,
|
|
332
|
+
code,
|
|
333
|
+
otherParams,
|
|
334
|
+
}
|
|
335
|
+
})
|
|
294
336
|
return
|
|
295
337
|
}
|
|
296
|
-
debug('
|
|
338
|
+
debug('Format:iframePostMessage', {
|
|
339
|
+
params: {
|
|
340
|
+
messageId,
|
|
341
|
+
otherParams,
|
|
342
|
+
code,
|
|
343
|
+
}
|
|
344
|
+
})
|
|
297
345
|
sendMessage(webViewRef, 'update-iframe', code, {
|
|
298
346
|
data: { otherParams },
|
|
299
347
|
code,
|
|
@@ -302,7 +350,26 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
302
350
|
}, [paramsString, iframeLoaded, context?.adServerUrl, bid, code])
|
|
303
351
|
|
|
304
352
|
const checkIfInViewport = () => {
|
|
305
|
-
if (!containerRef.current)
|
|
353
|
+
if (!containerRef.current) {
|
|
354
|
+
debug('Format:checkIfInViewportNoContainer', {
|
|
355
|
+
params: {
|
|
356
|
+
messageId,
|
|
357
|
+
code,
|
|
358
|
+
otherParams,
|
|
359
|
+
}
|
|
360
|
+
})
|
|
361
|
+
return
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
debug('Format:checkIfInViewportMeasure', {
|
|
365
|
+
params: {
|
|
366
|
+
windowWidth,
|
|
367
|
+
windowHeight,
|
|
368
|
+
messageId,
|
|
369
|
+
code,
|
|
370
|
+
otherParams,
|
|
371
|
+
}
|
|
372
|
+
})
|
|
306
373
|
|
|
307
374
|
containerRef.current.measureInWindow((containerX, containerY, containerWidth, containerHeight) => {
|
|
308
375
|
sendMessage(webViewRef, 'update-dimensions-iframe', code, {
|
|
@@ -314,24 +381,71 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
314
381
|
containerY,
|
|
315
382
|
keyboardHeight: keyboardHeightRef.current,
|
|
316
383
|
})
|
|
384
|
+
debug('Format:checkIfInViewportMeasureSend', {
|
|
385
|
+
params: {
|
|
386
|
+
messageId,
|
|
387
|
+
code,
|
|
388
|
+
otherParams,
|
|
389
|
+
windowWidth,
|
|
390
|
+
windowHeight,
|
|
391
|
+
containerWidth,
|
|
392
|
+
containerHeight,
|
|
393
|
+
containerX,
|
|
394
|
+
containerY,
|
|
395
|
+
keyboardHeight: keyboardHeightRef.current,
|
|
396
|
+
}
|
|
397
|
+
})
|
|
317
398
|
})
|
|
318
399
|
}
|
|
319
400
|
|
|
320
401
|
useEffect(() => {
|
|
321
|
-
if (!isAdViewVisible)
|
|
402
|
+
if (!isAdViewVisible) {
|
|
403
|
+
debug('Format:checkIfInViewportNotVisible', {
|
|
404
|
+
params: {
|
|
405
|
+
messageId,
|
|
406
|
+
code,
|
|
407
|
+
otherParams,
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
return
|
|
411
|
+
}
|
|
322
412
|
|
|
323
413
|
const interval = setInterval(() => {
|
|
324
414
|
checkIfInViewport()
|
|
325
415
|
}, 250)
|
|
326
416
|
|
|
327
|
-
return () =>
|
|
417
|
+
return () => {
|
|
418
|
+
clearInterval(interval)
|
|
419
|
+
debug('Format:checkIfInViewportCleanup', {
|
|
420
|
+
params: {
|
|
421
|
+
messageId,
|
|
422
|
+
code,
|
|
423
|
+
otherParams,
|
|
424
|
+
}
|
|
425
|
+
})
|
|
426
|
+
}
|
|
328
427
|
}, [isAdViewVisible])
|
|
329
428
|
|
|
330
429
|
useEffect(() => {
|
|
331
430
|
const showSubscription = Keyboard.addListener('keyboardDidShow', (e) => {
|
|
431
|
+
debug('Format:keyboardDidShow', {
|
|
432
|
+
params: {
|
|
433
|
+
keyboardHeight: e?.endCoordinates?.height ?? 0,
|
|
434
|
+
messageId,
|
|
435
|
+
code,
|
|
436
|
+
otherParams,
|
|
437
|
+
}
|
|
438
|
+
})
|
|
332
439
|
keyboardHeightRef.current = e?.endCoordinates?.height ?? 0
|
|
333
440
|
})
|
|
334
441
|
const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {
|
|
442
|
+
debug('Format:keyboardDidHide', {
|
|
443
|
+
params: {
|
|
444
|
+
messageId,
|
|
445
|
+
code,
|
|
446
|
+
otherParams,
|
|
447
|
+
}
|
|
448
|
+
})
|
|
335
449
|
keyboardHeightRef.current = 0
|
|
336
450
|
})
|
|
337
451
|
|
|
@@ -339,10 +453,27 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
339
453
|
showSubscription.remove()
|
|
340
454
|
hideSubscription.remove()
|
|
341
455
|
keyboardHeightRef.current = 0
|
|
456
|
+
debug('Format:keyboardEffectCleanup', {
|
|
457
|
+
params: {
|
|
458
|
+
messageId,
|
|
459
|
+
code,
|
|
460
|
+
otherParams,
|
|
461
|
+
}
|
|
462
|
+
})
|
|
342
463
|
}
|
|
343
464
|
}, [])
|
|
344
465
|
|
|
345
466
|
if (!context || !bid || !iframeUrl) {
|
|
467
|
+
debug('Format:noContextOrBidOrIframeUrl', {
|
|
468
|
+
params: {
|
|
469
|
+
context,
|
|
470
|
+
bid,
|
|
471
|
+
iframeUrl,
|
|
472
|
+
messageId,
|
|
473
|
+
code,
|
|
474
|
+
otherParams,
|
|
475
|
+
}
|
|
476
|
+
})
|
|
346
477
|
return null
|
|
347
478
|
}
|
|
348
479
|
|
|
@@ -359,11 +490,23 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
359
490
|
...iframeStyles,
|
|
360
491
|
}}
|
|
361
492
|
onError={() => {
|
|
362
|
-
debug('
|
|
493
|
+
debug('Format:iframeError', {
|
|
494
|
+
params: {
|
|
495
|
+
messageId,
|
|
496
|
+
code,
|
|
497
|
+
otherParams,
|
|
498
|
+
}
|
|
499
|
+
})
|
|
363
500
|
reset()
|
|
364
501
|
}}
|
|
365
502
|
onLoad={() => {
|
|
366
|
-
debug('
|
|
503
|
+
debug('Format:iframeLoad', {
|
|
504
|
+
params: {
|
|
505
|
+
messageId,
|
|
506
|
+
code,
|
|
507
|
+
otherParams,
|
|
508
|
+
}
|
|
509
|
+
})
|
|
367
510
|
}}
|
|
368
511
|
/>
|
|
369
512
|
)
|
|
@@ -394,11 +537,23 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
394
537
|
borderWidth: 0,
|
|
395
538
|
}}
|
|
396
539
|
onError={() => {
|
|
397
|
-
debug('
|
|
540
|
+
debug('Format:modalError', {
|
|
541
|
+
params: {
|
|
542
|
+
messageId,
|
|
543
|
+
code,
|
|
544
|
+
otherParams,
|
|
545
|
+
}
|
|
546
|
+
})
|
|
398
547
|
resetModal()
|
|
399
548
|
}}
|
|
400
549
|
onLoad={() => {
|
|
401
|
-
debug('
|
|
550
|
+
debug('Format:modalLoad', {
|
|
551
|
+
params: {
|
|
552
|
+
messageId,
|
|
553
|
+
code,
|
|
554
|
+
otherParams,
|
|
555
|
+
}
|
|
556
|
+
})
|
|
402
557
|
setModalLoaded(true)
|
|
403
558
|
}}
|
|
404
559
|
/>
|