@kontextso/sdk-react-native 3.1.0-rc.3 → 3.1.0-rc.4
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 +28 -5
- package/dist/index.mjs +28 -5
- package/package.json +2 -2
- package/src/NativeRNKontext.ts +1 -1
- package/src/__tests__/util.test.ts +1 -1
- package/src/formats/Format.tsx +37 -12
- package/src/services/SkOverlay.ts +8 -8
package/dist/index.js
CHANGED
|
@@ -228,22 +228,31 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
228
228
|
};
|
|
229
229
|
const openSkOverlay = async (appStoreId, position, dismissible) => {
|
|
230
230
|
try {
|
|
231
|
-
await presentSKOverlay({ appStoreId, position, dismissible })
|
|
231
|
+
if (!await presentSKOverlay({ appStoreId, position, dismissible })) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
232
234
|
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
233
235
|
open: true
|
|
234
236
|
});
|
|
235
237
|
} catch (e) {
|
|
238
|
+
debug("error-open-skoverlay-iframe", {
|
|
239
|
+
error: e
|
|
240
|
+
});
|
|
236
241
|
console.error("error opening sk overlay", e);
|
|
237
|
-
reset();
|
|
238
242
|
}
|
|
239
243
|
};
|
|
240
244
|
const closeSkOverlay = async () => {
|
|
241
245
|
try {
|
|
242
|
-
await dismissSKOverlay()
|
|
246
|
+
if (!await dismissSKOverlay()) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
243
249
|
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
244
250
|
open: false
|
|
245
251
|
});
|
|
246
252
|
} catch (e) {
|
|
253
|
+
debug("error-dismiss-skoverlay-iframe", {
|
|
254
|
+
error: e
|
|
255
|
+
});
|
|
247
256
|
console.error("error dismissing sk overlay", e);
|
|
248
257
|
}
|
|
249
258
|
};
|
|
@@ -314,7 +323,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
314
323
|
messageStatusRef.current = "message-received" /* MessageReceived */;
|
|
315
324
|
break;
|
|
316
325
|
case "open-skoverlay-iframe":
|
|
317
|
-
openSkOverlay(
|
|
326
|
+
openSkOverlay(
|
|
327
|
+
message.data.appStoreId,
|
|
328
|
+
message.data.position,
|
|
329
|
+
message.data.dismissible
|
|
330
|
+
);
|
|
318
331
|
break;
|
|
319
332
|
case "close-skoverlay-iframe":
|
|
320
333
|
closeSkOverlay();
|
|
@@ -359,6 +372,16 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
359
372
|
resetModal();
|
|
360
373
|
context?.captureError(new Error("Processing modal iframe error"));
|
|
361
374
|
break;
|
|
375
|
+
case "open-skoverlay-iframe":
|
|
376
|
+
openSkOverlay(
|
|
377
|
+
message.data.appStoreId,
|
|
378
|
+
message.data.position,
|
|
379
|
+
message.data.dismissible
|
|
380
|
+
);
|
|
381
|
+
break;
|
|
382
|
+
case "close-skoverlay-iframe":
|
|
383
|
+
closeSkOverlay();
|
|
384
|
+
break;
|
|
362
385
|
case "click-iframe":
|
|
363
386
|
if (message.data.url) {
|
|
364
387
|
import_react_native3.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
@@ -557,7 +580,7 @@ var import_react_native4 = require("react-native");
|
|
|
557
580
|
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
558
581
|
|
|
559
582
|
// package.json
|
|
560
|
-
var version = "3.1.0-rc.
|
|
583
|
+
var version = "3.1.0-rc.4";
|
|
561
584
|
|
|
562
585
|
// src/context/AdsProvider.tsx
|
|
563
586
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
package/dist/index.mjs
CHANGED
|
@@ -197,22 +197,31 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
197
197
|
};
|
|
198
198
|
const openSkOverlay = async (appStoreId, position, dismissible) => {
|
|
199
199
|
try {
|
|
200
|
-
await presentSKOverlay({ appStoreId, position, dismissible })
|
|
200
|
+
if (!await presentSKOverlay({ appStoreId, position, dismissible })) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
201
203
|
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
202
204
|
open: true
|
|
203
205
|
});
|
|
204
206
|
} catch (e) {
|
|
207
|
+
debug("error-open-skoverlay-iframe", {
|
|
208
|
+
error: e
|
|
209
|
+
});
|
|
205
210
|
console.error("error opening sk overlay", e);
|
|
206
|
-
reset();
|
|
207
211
|
}
|
|
208
212
|
};
|
|
209
213
|
const closeSkOverlay = async () => {
|
|
210
214
|
try {
|
|
211
|
-
await dismissSKOverlay()
|
|
215
|
+
if (!await dismissSKOverlay()) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
212
218
|
sendMessage(webViewRef, "update-skoverlay-iframe", code, {
|
|
213
219
|
open: false
|
|
214
220
|
});
|
|
215
221
|
} catch (e) {
|
|
222
|
+
debug("error-dismiss-skoverlay-iframe", {
|
|
223
|
+
error: e
|
|
224
|
+
});
|
|
216
225
|
console.error("error dismissing sk overlay", e);
|
|
217
226
|
}
|
|
218
227
|
};
|
|
@@ -283,7 +292,11 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
283
292
|
messageStatusRef.current = "message-received" /* MessageReceived */;
|
|
284
293
|
break;
|
|
285
294
|
case "open-skoverlay-iframe":
|
|
286
|
-
openSkOverlay(
|
|
295
|
+
openSkOverlay(
|
|
296
|
+
message.data.appStoreId,
|
|
297
|
+
message.data.position,
|
|
298
|
+
message.data.dismissible
|
|
299
|
+
);
|
|
287
300
|
break;
|
|
288
301
|
case "close-skoverlay-iframe":
|
|
289
302
|
closeSkOverlay();
|
|
@@ -328,6 +341,16 @@ var Format = ({ code, messageId, wrapper, onEvent, ...otherParams }) => {
|
|
|
328
341
|
resetModal();
|
|
329
342
|
context?.captureError(new Error("Processing modal iframe error"));
|
|
330
343
|
break;
|
|
344
|
+
case "open-skoverlay-iframe":
|
|
345
|
+
openSkOverlay(
|
|
346
|
+
message.data.appStoreId,
|
|
347
|
+
message.data.position,
|
|
348
|
+
message.data.dismissible
|
|
349
|
+
);
|
|
350
|
+
break;
|
|
351
|
+
case "close-skoverlay-iframe":
|
|
352
|
+
closeSkOverlay();
|
|
353
|
+
break;
|
|
331
354
|
case "click-iframe":
|
|
332
355
|
if (message.data.url) {
|
|
333
356
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
@@ -529,7 +552,7 @@ import { Appearance, Dimensions, PixelRatio, Platform as Platform2 } from "react
|
|
|
529
552
|
import DeviceInfo from "react-native-device-info";
|
|
530
553
|
|
|
531
554
|
// package.json
|
|
532
|
-
var version = "3.1.0-rc.
|
|
555
|
+
var version = "3.1.0-rc.4";
|
|
533
556
|
|
|
534
557
|
// src/context/AdsProvider.tsx
|
|
535
558
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontextso/sdk-react-native",
|
|
3
|
-
"version": "3.1.0-rc.
|
|
3
|
+
"version": "3.1.0-rc.4",
|
|
4
4
|
"description": "Kontext SDK for React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"format": "biome format --write ."
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@kontextso/sdk-common": "^1.0.
|
|
23
|
+
"@kontextso/sdk-common": "^1.0.3",
|
|
24
24
|
"@kontextso/typescript-config": "*",
|
|
25
25
|
"@react-native-community/netinfo": "11.3.1",
|
|
26
26
|
"@testing-library/dom": "^10.4.0",
|
package/src/NativeRNKontext.ts
CHANGED
package/src/formats/Format.tsx
CHANGED
|
@@ -141,23 +141,32 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
141
141
|
|
|
142
142
|
const openSkOverlay = async (appStoreId: string, position: SKOverlayPosition, dismissible: boolean) => {
|
|
143
143
|
try {
|
|
144
|
-
await presentSKOverlay({ appStoreId, position, dismissible })
|
|
144
|
+
if (!(await presentSKOverlay({ appStoreId, position, dismissible }))) {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
145
147
|
sendMessage(webViewRef, 'update-skoverlay-iframe', code, {
|
|
146
|
-
open: true
|
|
148
|
+
open: true,
|
|
147
149
|
})
|
|
148
150
|
} catch (e) {
|
|
151
|
+
debug('error-open-skoverlay-iframe', {
|
|
152
|
+
error: e,
|
|
153
|
+
})
|
|
149
154
|
console.error('error opening sk overlay', e)
|
|
150
|
-
reset()
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
const closeSkOverlay = async () => {
|
|
155
159
|
try {
|
|
156
|
-
await dismissSKOverlay()
|
|
160
|
+
if (!(await dismissSKOverlay())) {
|
|
161
|
+
return
|
|
162
|
+
}
|
|
157
163
|
sendMessage(webViewRef, 'update-skoverlay-iframe', code, {
|
|
158
|
-
open: false
|
|
164
|
+
open: false,
|
|
159
165
|
})
|
|
160
166
|
} catch (e) {
|
|
167
|
+
debug('error-dismiss-skoverlay-iframe', {
|
|
168
|
+
error: e,
|
|
169
|
+
})
|
|
161
170
|
console.error('error dismissing sk overlay', e)
|
|
162
171
|
}
|
|
163
172
|
}
|
|
@@ -244,7 +253,11 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
244
253
|
break
|
|
245
254
|
|
|
246
255
|
case 'open-skoverlay-iframe':
|
|
247
|
-
openSkOverlay(
|
|
256
|
+
openSkOverlay(
|
|
257
|
+
message.data.appStoreId,
|
|
258
|
+
message.data.position as SKOverlayPosition,
|
|
259
|
+
message.data.dismissible
|
|
260
|
+
)
|
|
248
261
|
break
|
|
249
262
|
|
|
250
263
|
case 'close-skoverlay-iframe':
|
|
@@ -299,6 +312,18 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
299
312
|
context?.captureError(new Error('Processing modal iframe error'))
|
|
300
313
|
break
|
|
301
314
|
|
|
315
|
+
case 'open-skoverlay-iframe':
|
|
316
|
+
openSkOverlay(
|
|
317
|
+
message.data.appStoreId,
|
|
318
|
+
message.data.position as SKOverlayPosition,
|
|
319
|
+
message.data.dismissible
|
|
320
|
+
)
|
|
321
|
+
break
|
|
322
|
+
|
|
323
|
+
case 'close-skoverlay-iframe':
|
|
324
|
+
closeSkOverlay()
|
|
325
|
+
break
|
|
326
|
+
|
|
302
327
|
case 'click-iframe':
|
|
303
328
|
if (message.data.url) {
|
|
304
329
|
Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch((err) =>
|
|
@@ -330,12 +355,12 @@ const Format = ({ code, messageId, wrapper, onEvent, ...otherParams }: FormatPro
|
|
|
330
355
|
}
|
|
331
356
|
|
|
332
357
|
/*
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
358
|
+
* Fix for Android issue in Saylo.
|
|
359
|
+
* When the iframe is loaded, the onLoad event is sometimes called two or more times.
|
|
360
|
+
* When these events fire too quickly, the init-iframe response from the server gets discarded.
|
|
361
|
+
* As a result, our SDK doesn’t send the update-iframe event back to the server, and the stream never starts.
|
|
362
|
+
* This fix will send the update-iframe event even if the init-iframe isn’t received.
|
|
363
|
+
*/
|
|
339
364
|
useEffect(() => {
|
|
340
365
|
const interval = setInterval(() => {
|
|
341
366
|
if (messageStatusRef.current === MessageStatus.None) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
|
-
import NativeRNKontext from '../NativeRNKontext'
|
|
2
|
+
import NativeRNKontext from '../NativeRNKontext'
|
|
3
3
|
|
|
4
|
-
export type SKOverlayPosition = 'bottom' | 'bottomRaised'
|
|
4
|
+
export type SKOverlayPosition = 'bottom' | 'bottomRaised'
|
|
5
5
|
|
|
6
6
|
const isValidAppStoreId = (id: unknown): id is string => {
|
|
7
|
-
return typeof id ===
|
|
7
|
+
return typeof id === 'string' && /^\d+$/.test(id)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const isValidPosition = (p: unknown): p is SKOverlayPosition => {
|
|
11
|
-
return p ===
|
|
11
|
+
return p === 'bottom' || p === 'bottomRaised'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export async function presentSKOverlay(params: {
|
|
15
|
-
appStoreId: string
|
|
16
|
-
position: SKOverlayPosition
|
|
17
|
-
dismissible: boolean
|
|
15
|
+
appStoreId: string
|
|
16
|
+
position: SKOverlayPosition
|
|
17
|
+
dismissible: boolean
|
|
18
18
|
}) {
|
|
19
19
|
if (Platform.OS !== 'ios') {
|
|
20
20
|
return false
|
|
@@ -39,4 +39,4 @@ export async function dismissSKOverlay() {
|
|
|
39
39
|
return false
|
|
40
40
|
}
|
|
41
41
|
return NativeRNKontext.dismissSKOverlay()
|
|
42
|
-
}
|
|
42
|
+
}
|