@kontextso/sdk-react-native 1.0.3 → 1.0.5
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 +32 -2
- package/dist/index.mjs +32 -2
- package/package.json +4 -8
package/dist/index.js
CHANGED
|
@@ -79,14 +79,34 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
79
79
|
context?.resetAll();
|
|
80
80
|
context?.captureError(new Error("Processing iframe error"));
|
|
81
81
|
};
|
|
82
|
+
const debug = (name, data = {}) => {
|
|
83
|
+
context?.onDebugEventInternal(name, {
|
|
84
|
+
code,
|
|
85
|
+
messageId,
|
|
86
|
+
otherParams,
|
|
87
|
+
bid,
|
|
88
|
+
iframeUrl,
|
|
89
|
+
iframeLoaded,
|
|
90
|
+
showIframe,
|
|
91
|
+
height,
|
|
92
|
+
containerStyles,
|
|
93
|
+
iframeStyles,
|
|
94
|
+
...data
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
debug("format-update-state");
|
|
82
98
|
const onMessage = (event) => {
|
|
83
99
|
try {
|
|
84
100
|
const data = JSON.parse(event.nativeEvent.data);
|
|
101
|
+
debug("iframe-message", {
|
|
102
|
+
message: data
|
|
103
|
+
});
|
|
85
104
|
const messageHandler = handleIframeMessage(
|
|
86
105
|
(message) => {
|
|
87
106
|
switch (message.type) {
|
|
88
107
|
case "init-iframe":
|
|
89
108
|
setIframeLoaded(true);
|
|
109
|
+
debug("iframe-post-message");
|
|
90
110
|
sendMessage(webViewRef, code, {
|
|
91
111
|
messages: context?.messages,
|
|
92
112
|
sdk: "sdk-react-native",
|
|
@@ -129,6 +149,9 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
129
149
|
);
|
|
130
150
|
messageHandler({ data });
|
|
131
151
|
} catch (e) {
|
|
152
|
+
debug("iframe-message-error", {
|
|
153
|
+
error: e
|
|
154
|
+
});
|
|
132
155
|
console.error("error parsing message from webview", e);
|
|
133
156
|
reset();
|
|
134
157
|
}
|
|
@@ -138,6 +161,7 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
138
161
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
139
162
|
return;
|
|
140
163
|
}
|
|
164
|
+
debug("iframe-post-message");
|
|
141
165
|
sendMessage(webViewRef, code, {
|
|
142
166
|
data: { otherParams },
|
|
143
167
|
code
|
|
@@ -166,7 +190,6 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
166
190
|
import_react_native_webview.WebView,
|
|
167
191
|
{
|
|
168
192
|
ref: webViewRef,
|
|
169
|
-
onError: reset,
|
|
170
193
|
source: {
|
|
171
194
|
uri: iframeUrl
|
|
172
195
|
},
|
|
@@ -183,7 +206,14 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
183
206
|
window.ReactNativeWebView.postMessage(JSON.stringify(event.data));
|
|
184
207
|
}
|
|
185
208
|
}, false);
|
|
186
|
-
|
|
209
|
+
`,
|
|
210
|
+
onError: () => {
|
|
211
|
+
debug("iframe-error");
|
|
212
|
+
reset();
|
|
213
|
+
},
|
|
214
|
+
onLoad: () => {
|
|
215
|
+
debug("iframe-load");
|
|
216
|
+
}
|
|
187
217
|
}
|
|
188
218
|
)
|
|
189
219
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -52,14 +52,34 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
52
52
|
context?.resetAll();
|
|
53
53
|
context?.captureError(new Error("Processing iframe error"));
|
|
54
54
|
};
|
|
55
|
+
const debug = (name, data = {}) => {
|
|
56
|
+
context?.onDebugEventInternal(name, {
|
|
57
|
+
code,
|
|
58
|
+
messageId,
|
|
59
|
+
otherParams,
|
|
60
|
+
bid,
|
|
61
|
+
iframeUrl,
|
|
62
|
+
iframeLoaded,
|
|
63
|
+
showIframe,
|
|
64
|
+
height,
|
|
65
|
+
containerStyles,
|
|
66
|
+
iframeStyles,
|
|
67
|
+
...data
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
debug("format-update-state");
|
|
55
71
|
const onMessage = (event) => {
|
|
56
72
|
try {
|
|
57
73
|
const data = JSON.parse(event.nativeEvent.data);
|
|
74
|
+
debug("iframe-message", {
|
|
75
|
+
message: data
|
|
76
|
+
});
|
|
58
77
|
const messageHandler = handleIframeMessage(
|
|
59
78
|
(message) => {
|
|
60
79
|
switch (message.type) {
|
|
61
80
|
case "init-iframe":
|
|
62
81
|
setIframeLoaded(true);
|
|
82
|
+
debug("iframe-post-message");
|
|
63
83
|
sendMessage(webViewRef, code, {
|
|
64
84
|
messages: context?.messages,
|
|
65
85
|
sdk: "sdk-react-native",
|
|
@@ -102,6 +122,9 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
102
122
|
);
|
|
103
123
|
messageHandler({ data });
|
|
104
124
|
} catch (e) {
|
|
125
|
+
debug("iframe-message-error", {
|
|
126
|
+
error: e
|
|
127
|
+
});
|
|
105
128
|
console.error("error parsing message from webview", e);
|
|
106
129
|
reset();
|
|
107
130
|
}
|
|
@@ -111,6 +134,7 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
111
134
|
if (!iframeLoaded || !context?.adServerUrl || !bid || !webViewRef.current) {
|
|
112
135
|
return;
|
|
113
136
|
}
|
|
137
|
+
debug("iframe-post-message");
|
|
114
138
|
sendMessage(webViewRef, code, {
|
|
115
139
|
data: { otherParams },
|
|
116
140
|
code
|
|
@@ -139,7 +163,6 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
139
163
|
WebView,
|
|
140
164
|
{
|
|
141
165
|
ref: webViewRef,
|
|
142
|
-
onError: reset,
|
|
143
166
|
source: {
|
|
144
167
|
uri: iframeUrl
|
|
145
168
|
},
|
|
@@ -156,7 +179,14 @@ var Format = ({ code, messageId, wrapper, ...otherParams }) => {
|
|
|
156
179
|
window.ReactNativeWebView.postMessage(JSON.stringify(event.data));
|
|
157
180
|
}
|
|
158
181
|
}, false);
|
|
159
|
-
|
|
182
|
+
`,
|
|
183
|
+
onError: () => {
|
|
184
|
+
debug("iframe-error");
|
|
185
|
+
reset();
|
|
186
|
+
},
|
|
187
|
+
onLoad: () => {
|
|
188
|
+
debug("iframe-load");
|
|
189
|
+
}
|
|
160
190
|
}
|
|
161
191
|
)
|
|
162
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontextso/sdk-react-native",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -43,15 +43,11 @@
|
|
|
43
43
|
"vitest": "^2.1.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"react": ">=18.0.0 <20.0.0",
|
|
49
|
-
"react-dom": ">=18.0.0 <20.0.0",
|
|
50
|
-
"react-native": "*"
|
|
46
|
+
"react": ">=18.0.0",
|
|
47
|
+
"react-native": ">=0.73.0"
|
|
51
48
|
},
|
|
52
49
|
"dependencies": {
|
|
53
|
-
"@kontextso/sdk-react": "^1.
|
|
54
|
-
"react-native-fetch-api": "^3.0.0",
|
|
50
|
+
"@kontextso/sdk-react": "^1.2.0",
|
|
55
51
|
"react-native-webview": "^13.15.0"
|
|
56
52
|
},
|
|
57
53
|
"files": [
|