@kontextso/sdk-react-native 2.1.1-rc.0 → 2.1.1-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/README.md +1 -1
- package/RNKontext.podspec +21 -0
- package/android/build.gradle +88 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/so/kontext/react/RNKontextModuleImpl.kt +21 -0
- package/android/src/newarch/java/so/kontext/react/RNKontextModule.kt +22 -0
- package/android/src/newarch/java/so/kontext/react/RNKontextPackage.kt +32 -0
- package/android/src/oldarch/java/so/kontext/react/RNKontextModule.kt +25 -0
- package/android/src/oldarch/java/so/kontext/react/RNKontextPacakge.kt +16 -0
- package/dist/index.js +69 -193
- package/dist/index.mjs +56 -180
- package/ios/KontextSDK.swift +26 -0
- package/ios/RNKontext.h +13 -0
- package/ios/RNKontext.mm +36 -0
- package/package.json +26 -5
- package/src/NativeRNKontext.ts +8 -0
- package/src/context/AdsProvider.tsx +60 -0
- package/src/formats/Format.tsx +263 -0
- package/src/formats/InlineAd.tsx +8 -0
- package/src/index.ts +5 -0
package/README.md
CHANGED
|
@@ -83,5 +83,5 @@ function MessageList({ messages }: { messages: Message[] }) {
|
|
|
83
83
|
|
|
84
84
|
## Additional Resources
|
|
85
85
|
|
|
86
|
-
* Explore a working [Demo Project featuring SDK integration](https://github.com/kontextso/
|
|
86
|
+
* Explore a working [Demo Project featuring SDK integration](https://github.com/kontextso/sdk-react-native-demo).
|
|
87
87
|
* Full documentation: [Kontext React Native SDK](https://docs.kontext.so/sdk/react-native).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RNKontext"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => ".git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNKontext_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def isNewArchitectureEnabled() {
|
|
25
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrIntegerDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNKontext_" + name]).toInteger()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
android {
|
|
33
|
+
namespace "so.kontext.react"
|
|
34
|
+
|
|
35
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
36
|
+
|
|
37
|
+
defaultConfig {
|
|
38
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
39
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
40
|
+
// Expose the new-arch flag to runtime and build-time Kotlin/Java code
|
|
41
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
buildFeatures {
|
|
45
|
+
buildConfig true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
buildTypes {
|
|
49
|
+
release {
|
|
50
|
+
minifyEnabled false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
lintOptions {
|
|
55
|
+
disable "GradleCompatible"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
compileOptions {
|
|
59
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
60
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
sourceSets {
|
|
64
|
+
main {
|
|
65
|
+
java.srcDirs += [
|
|
66
|
+
"generated/java",
|
|
67
|
+
"generated/jni"
|
|
68
|
+
]
|
|
69
|
+
if (isNewArchitectureEnabled()) {
|
|
70
|
+
java.srcDirs += ['src/newarch/java']
|
|
71
|
+
} else {
|
|
72
|
+
java.srcDirs += ['src/oldarch/java']
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
repositories {
|
|
79
|
+
mavenCentral()
|
|
80
|
+
google()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
84
|
+
|
|
85
|
+
dependencies {
|
|
86
|
+
implementation "com.facebook.react:react-android"
|
|
87
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
88
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package so.kontext.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.media.AudioManager
|
|
7
|
+
|
|
8
|
+
class RNKontextModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
9
|
+
fun isSoundOn(promise: Promise?) {
|
|
10
|
+
val audioManager = reactContext.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
|
11
|
+
val current = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
|
12
|
+
val max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
|
13
|
+
val volume = if (max > 0) current.toFloat() / max.toFloat() else 0f
|
|
14
|
+
|
|
15
|
+
promise?.resolve(volume > MINIMAL_VOLUME_THRESHOLD)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
companion object {
|
|
19
|
+
private const val MINIMAL_VOLUME_THRESHOLD = 0.0f
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package so.kontext.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
|
|
7
|
+
@ReactModule(name = RNKontextModule.NAME)
|
|
8
|
+
class RNKontextModule(reactContext: ReactApplicationContext) :
|
|
9
|
+
NativeRNKontextSpec(reactContext) {
|
|
10
|
+
|
|
11
|
+
private val impl = RNKontextModuleImpl(reactContext)
|
|
12
|
+
|
|
13
|
+
override fun getName(): String = NAME
|
|
14
|
+
|
|
15
|
+
override fun isSoundOn(promise: Promise?) {
|
|
16
|
+
impl.isSoundOn(promise)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
companion object {
|
|
20
|
+
const val NAME = "RNKontext"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package so.kontext.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
|
|
9
|
+
class RNKontextPackage : BaseReactPackage() {
|
|
10
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
11
|
+
return if (name == RNKontextModule.NAME) {
|
|
12
|
+
RNKontextModule(reactContext)
|
|
13
|
+
} else {
|
|
14
|
+
null
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
19
|
+
return ReactModuleInfoProvider {
|
|
20
|
+
mapOf(
|
|
21
|
+
RNKontextModule.NAME to ReactModuleInfo(
|
|
22
|
+
RNKontextModule.NAME,
|
|
23
|
+
RNKontextModule.NAME,
|
|
24
|
+
false, // canOverrideExistingModule
|
|
25
|
+
false, // needsEagerInit
|
|
26
|
+
false, // isCxxModule
|
|
27
|
+
true // isTurboModule
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package so.kontext.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
import android.content.Context
|
|
8
|
+
import android.media.AudioManager
|
|
9
|
+
|
|
10
|
+
class RNKontextModule(reactContext: ReactApplicationContext) :
|
|
11
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
12
|
+
|
|
13
|
+
private val impl = RNKontextModuleImpl(reactContext)
|
|
14
|
+
|
|
15
|
+
override fun getName(): String = NAME
|
|
16
|
+
|
|
17
|
+
@ReactMethod
|
|
18
|
+
fun isSoundOn(promise: Promise?) {
|
|
19
|
+
impl.isSoundOn(promise)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
companion object {
|
|
23
|
+
const val NAME = "RNKontext"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package so.kontext.react
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class RNKontextPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(RNKontextModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -36,8 +36,9 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/formats/Format.tsx
|
|
39
|
-
var
|
|
39
|
+
var import_react = require("react");
|
|
40
40
|
var import_sdk_react = require("@kontextso/sdk-react");
|
|
41
|
+
var import_react_native_webview = require("react-native-webview");
|
|
41
42
|
var import_react_native = require("react-native");
|
|
42
43
|
|
|
43
44
|
// ../sdk-common/dist/index.mjs
|
|
@@ -58,44 +59,8 @@ function handleIframeMessage(handler, opts) {
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
// src/frame-webview.tsx
|
|
62
|
-
var import_react = require("react");
|
|
63
|
-
var import_react_native_webview = require("react-native-webview");
|
|
64
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
-
var FrameWebView = (0, import_react.forwardRef)(
|
|
66
|
-
({ iframeUrl, onMessage, style, onError, onLoad }, forwardedRef) => {
|
|
67
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
-
import_react_native_webview.WebView,
|
|
69
|
-
{
|
|
70
|
-
ref: forwardedRef,
|
|
71
|
-
source: {
|
|
72
|
-
uri: iframeUrl
|
|
73
|
-
},
|
|
74
|
-
onMessage,
|
|
75
|
-
style,
|
|
76
|
-
allowsInlineMediaPlayback: true,
|
|
77
|
-
mediaPlaybackRequiresUserAction: false,
|
|
78
|
-
javaScriptEnabled: true,
|
|
79
|
-
domStorageEnabled: true,
|
|
80
|
-
allowsFullscreenVideo: false,
|
|
81
|
-
injectedJavaScript: `
|
|
82
|
-
window.addEventListener("message", function(event) {
|
|
83
|
-
if (window.ReactNativeWebView && event.data) {
|
|
84
|
-
// ReactNativeWebView.postMessage only supports string data
|
|
85
|
-
window.ReactNativeWebView.postMessage(JSON.stringify(event.data));
|
|
86
|
-
}
|
|
87
|
-
}, false);
|
|
88
|
-
`,
|
|
89
|
-
onError,
|
|
90
|
-
onLoad
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
var frame_webview_default = FrameWebView;
|
|
96
|
-
|
|
97
62
|
// src/formats/Format.tsx
|
|
98
|
-
var
|
|
63
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
99
64
|
var sendMessage = (webViewRef, type, code, data) => {
|
|
100
65
|
const message = makeIframeMessage(type, {
|
|
101
66
|
data,
|
|
@@ -108,22 +73,16 @@ var sendMessage = (webViewRef, type, code, data) => {
|
|
|
108
73
|
`);
|
|
109
74
|
};
|
|
110
75
|
var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
111
|
-
const context = (0,
|
|
76
|
+
const context = (0, import_react.useContext)(import_sdk_react.AdsContext);
|
|
112
77
|
const bid = (0, import_sdk_react.useBid)({ code, messageId });
|
|
113
|
-
const [height, setHeight] = (0,
|
|
114
|
-
const iframeUrl = (0, import_sdk_react.useIframeUrl)(context, bid, code, messageId
|
|
115
|
-
const
|
|
116
|
-
const [
|
|
117
|
-
const [
|
|
118
|
-
const [
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const [containerStyles, setContainerStyles] = (0, import_react2.useState)({});
|
|
122
|
-
const [iframeStyles, setIframeStyles] = (0, import_react2.useState)({});
|
|
123
|
-
const containerRef = (0, import_react2.useRef)(null);
|
|
124
|
-
const webViewRef = (0, import_react2.useRef)(null);
|
|
125
|
-
const modalWebViewRef = (0, import_react2.useRef)(null);
|
|
126
|
-
const modalInitTimeoutRef = (0, import_react2.useRef)(null);
|
|
78
|
+
const [height, setHeight] = (0, import_react.useState)(0);
|
|
79
|
+
const iframeUrl = (0, import_sdk_react.useIframeUrl)(context, bid, code, messageId);
|
|
80
|
+
const [showIframe, setShowIframe] = (0, import_react.useState)(false);
|
|
81
|
+
const [iframeLoaded, setIframeLoaded] = (0, import_react.useState)(false);
|
|
82
|
+
const [containerStyles, setContainerStyles] = (0, import_react.useState)({});
|
|
83
|
+
const [iframeStyles, setIframeStyles] = (0, import_react.useState)({});
|
|
84
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
85
|
+
const webViewRef = (0, import_react.useRef)(null);
|
|
127
86
|
const { height: windowHeight, width: windowWidth } = (0, import_react_native.useWindowDimensions)();
|
|
128
87
|
const reset = () => {
|
|
129
88
|
setHeight(0);
|
|
@@ -131,19 +90,9 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
131
90
|
setContainerStyles({});
|
|
132
91
|
setIframeStyles({});
|
|
133
92
|
setIframeLoaded(false);
|
|
134
|
-
resetModal();
|
|
135
93
|
context?.resetAll();
|
|
136
94
|
context?.captureError(new Error("Processing iframe error"));
|
|
137
95
|
};
|
|
138
|
-
const resetModal = () => {
|
|
139
|
-
if (modalInitTimeoutRef.current) {
|
|
140
|
-
clearTimeout(modalInitTimeoutRef.current);
|
|
141
|
-
modalInitTimeoutRef.current = null;
|
|
142
|
-
}
|
|
143
|
-
setModalOpen(false);
|
|
144
|
-
setModalLoaded(false);
|
|
145
|
-
setModalShown(false);
|
|
146
|
-
};
|
|
147
96
|
const debug = (name, data = {}) => {
|
|
148
97
|
context?.onDebugEventInternal?.(name, {
|
|
149
98
|
code,
|
|
@@ -159,19 +108,6 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
159
108
|
...data
|
|
160
109
|
});
|
|
161
110
|
};
|
|
162
|
-
const debugModal = (name, data = {}) => {
|
|
163
|
-
context?.onDebugEventInternal?.(name, {
|
|
164
|
-
code,
|
|
165
|
-
messageId,
|
|
166
|
-
otherParams,
|
|
167
|
-
bid,
|
|
168
|
-
modalUrl,
|
|
169
|
-
modalOpen,
|
|
170
|
-
modalShown,
|
|
171
|
-
modalLoaded,
|
|
172
|
-
...data
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
111
|
debug("format-update-state");
|
|
176
112
|
const onMessage = (event) => {
|
|
177
113
|
try {
|
|
@@ -219,10 +155,6 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
219
155
|
setContainerStyles(message.data.containerStyles);
|
|
220
156
|
setIframeStyles(message.data.iframeStyles);
|
|
221
157
|
break;
|
|
222
|
-
case "open-component-iframe":
|
|
223
|
-
setModalOpen(true);
|
|
224
|
-
modalInitTimeoutRef.current = setTimeout(resetModal, message.data.timeout ?? 5e3);
|
|
225
|
-
break;
|
|
226
158
|
}
|
|
227
159
|
},
|
|
228
160
|
{
|
|
@@ -238,55 +170,8 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
238
170
|
reset();
|
|
239
171
|
}
|
|
240
172
|
};
|
|
241
|
-
const onModalMessage = (event) => {
|
|
242
|
-
try {
|
|
243
|
-
const data = JSON.parse(event.nativeEvent.data);
|
|
244
|
-
debugModal("modal-iframe-message", {
|
|
245
|
-
message: data
|
|
246
|
-
});
|
|
247
|
-
const messageHandler = handleIframeMessage(
|
|
248
|
-
(message) => {
|
|
249
|
-
switch (message.type) {
|
|
250
|
-
case "close-component-iframe":
|
|
251
|
-
resetModal();
|
|
252
|
-
break;
|
|
253
|
-
case "init-component-iframe":
|
|
254
|
-
if (modalInitTimeoutRef.current) {
|
|
255
|
-
clearTimeout(modalInitTimeoutRef.current);
|
|
256
|
-
modalInitTimeoutRef.current = null;
|
|
257
|
-
}
|
|
258
|
-
setModalShown(true);
|
|
259
|
-
break;
|
|
260
|
-
case "error-component-iframe":
|
|
261
|
-
case "error-iframe":
|
|
262
|
-
resetModal();
|
|
263
|
-
break;
|
|
264
|
-
case "click-iframe":
|
|
265
|
-
if (message.data.url) {
|
|
266
|
-
import_react_native.Linking.openURL(`${context?.adServerUrl}${message.data.url}`).catch(
|
|
267
|
-
(err) => console.error("error opening url", err)
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
context?.onAdClickInternal(message.data);
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
code,
|
|
276
|
-
component: "modal"
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
messageHandler({ data });
|
|
280
|
-
} catch (e) {
|
|
281
|
-
debugModal("modal-iframe-message-error", {
|
|
282
|
-
error: e
|
|
283
|
-
});
|
|
284
|
-
console.error("error parsing message from webview", e);
|
|
285
|
-
resetModal();
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
173
|
const paramsString = (0, import_sdk_react.convertParamsToString)(otherParams);
|
|
289
|
-
(0,
|
|
174
|
+
(0, import_react.useEffect)(() => {
|
|
290
175
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
291
176
|
return;
|
|
292
177
|
}
|
|
@@ -309,7 +194,7 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
309
194
|
});
|
|
310
195
|
});
|
|
311
196
|
};
|
|
312
|
-
(0,
|
|
197
|
+
(0, import_react.useEffect)(() => {
|
|
313
198
|
const interval = setInterval(() => {
|
|
314
199
|
checkIfInViewport();
|
|
315
200
|
}, 250);
|
|
@@ -330,80 +215,71 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
330
215
|
}
|
|
331
216
|
return 0;
|
|
332
217
|
};
|
|
333
|
-
const content = /* @__PURE__ */ (0,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
},
|
|
358
|
-
onLoad: () => {
|
|
359
|
-
debug("modal-load");
|
|
360
|
-
setModalLoaded(true);
|
|
361
|
-
}
|
|
218
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: containerStyles, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
219
|
+
import_react_native_webview.WebView,
|
|
220
|
+
{
|
|
221
|
+
ref: webViewRef,
|
|
222
|
+
source: {
|
|
223
|
+
uri: iframeUrl
|
|
224
|
+
},
|
|
225
|
+
onMessage,
|
|
226
|
+
style: {
|
|
227
|
+
height: getHeight(),
|
|
228
|
+
width: getWidth(),
|
|
229
|
+
...iframeStyles
|
|
230
|
+
},
|
|
231
|
+
allowsInlineMediaPlayback: true,
|
|
232
|
+
mediaPlaybackRequiresUserAction: false,
|
|
233
|
+
javaScriptEnabled: true,
|
|
234
|
+
domStorageEnabled: true,
|
|
235
|
+
allowsFullscreenVideo: false,
|
|
236
|
+
injectedJavaScript: `
|
|
237
|
+
function sendToLog(data) {
|
|
238
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
239
|
+
type: 'log-iframe',
|
|
240
|
+
data: data
|
|
241
|
+
}));
|
|
362
242
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
...iframeStyles
|
|
378
|
-
},
|
|
379
|
-
onError: () => {
|
|
380
|
-
debug("iframe-error");
|
|
381
|
-
reset();
|
|
382
|
-
},
|
|
383
|
-
onLoad: () => {
|
|
384
|
-
debug("iframe-load");
|
|
385
|
-
}
|
|
243
|
+
|
|
244
|
+
window.addEventListener("message", function(event) {
|
|
245
|
+
if (window.ReactNativeWebView && event.data) {
|
|
246
|
+
// ReactNativeWebView.postMessage only supports string data
|
|
247
|
+
window.ReactNativeWebView.postMessage(JSON.stringify(event.data));
|
|
248
|
+
}
|
|
249
|
+
}, false);
|
|
250
|
+
`,
|
|
251
|
+
onError: () => {
|
|
252
|
+
debug("iframe-error");
|
|
253
|
+
reset();
|
|
254
|
+
},
|
|
255
|
+
onLoad: () => {
|
|
256
|
+
debug("iframe-load");
|
|
386
257
|
}
|
|
387
|
-
|
|
388
|
-
|
|
258
|
+
}
|
|
259
|
+
) });
|
|
389
260
|
return wrapper ? wrapper(content) : content;
|
|
390
261
|
};
|
|
391
|
-
var FormatWithErrorBoundary = (props) => /* @__PURE__ */ (0,
|
|
262
|
+
var FormatWithErrorBoundary = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sdk_react.ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Format, { ...props }) });
|
|
392
263
|
var Format_default = FormatWithErrorBoundary;
|
|
393
264
|
|
|
394
265
|
// src/formats/InlineAd.tsx
|
|
395
|
-
var
|
|
266
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
396
267
|
var InlineAd = ({ code, messageId, wrapper, ...props }) => {
|
|
397
|
-
return /* @__PURE__ */ (0,
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Format_default, { code, messageId, wrapper, ...props });
|
|
398
269
|
};
|
|
399
270
|
var InlineAd_default = InlineAd;
|
|
400
271
|
|
|
401
272
|
// src/context/AdsProvider.tsx
|
|
402
273
|
var import_sdk_react2 = require("@kontextso/sdk-react");
|
|
403
|
-
var
|
|
274
|
+
var import_react_native3 = require("react-native");
|
|
404
275
|
var import_react_native_device_info = __toESM(require("react-native-device-info"));
|
|
405
|
-
|
|
406
|
-
|
|
276
|
+
|
|
277
|
+
// src/NativeRNKontext.ts
|
|
278
|
+
var import_react_native2 = require("react-native");
|
|
279
|
+
var NativeRNKontext_default = import_react_native2.TurboModuleRegistry.getEnforcing("RNKontext");
|
|
280
|
+
|
|
281
|
+
// src/context/AdsProvider.tsx
|
|
282
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
407
283
|
ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
408
284
|
if (!isFatal) {
|
|
409
285
|
import_sdk_react2.log.warn(error);
|
|
@@ -413,7 +289,7 @@ ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
|
413
289
|
});
|
|
414
290
|
var getDevice = async () => {
|
|
415
291
|
try {
|
|
416
|
-
const os =
|
|
292
|
+
const os = import_react_native3.Platform.OS;
|
|
417
293
|
const systemVersion = import_react_native_device_info.default.getSystemVersion();
|
|
418
294
|
const model = import_react_native_device_info.default.getModel();
|
|
419
295
|
const brand = import_react_native_device_info.default.getBrand();
|
|
@@ -423,11 +299,11 @@ var getDevice = async () => {
|
|
|
423
299
|
const appVersion = import_react_native_device_info.default.getVersion();
|
|
424
300
|
let soundOn = false;
|
|
425
301
|
try {
|
|
426
|
-
soundOn = await
|
|
302
|
+
soundOn = await NativeRNKontext_default.isSoundOn();
|
|
427
303
|
} catch (error) {
|
|
428
304
|
import_sdk_react2.log.warn("Failed to read output volume", error);
|
|
429
305
|
}
|
|
430
|
-
const rnv =
|
|
306
|
+
const rnv = import_react_native3.Platform.constants.reactNativeVersion;
|
|
431
307
|
const reactNativeVersion = `${rnv.major}.${rnv.minor}.${rnv.patch}`;
|
|
432
308
|
return {
|
|
433
309
|
os,
|
|
@@ -447,7 +323,7 @@ var getDevice = async () => {
|
|
|
447
323
|
return {};
|
|
448
324
|
};
|
|
449
325
|
var AdsProvider = (props) => {
|
|
450
|
-
return /* @__PURE__ */ (0,
|
|
326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_sdk_react2.AdsProviderInternal, { ...props, getDevice });
|
|
451
327
|
};
|
|
452
328
|
// Annotate the CommonJS export names for ESM import in node:
|
|
453
329
|
0 && (module.exports = {
|