@screeb/react-native 2.1.3 → 2.1.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/ios/ScreebModule.swift +17 -3
- package/lib/commonjs/index.js +4 -5
- package/lib/module/index.js +4 -5
- package/package.json +1 -1
- package/src/index.tsx +2 -1
package/ios/ScreebModule.swift
CHANGED
|
@@ -23,7 +23,14 @@ class ScreebModule: RCTEventEmitter {
|
|
|
23
23
|
if (hook.key == "version") {
|
|
24
24
|
mapHooks![hook.key] = hook.value as? String
|
|
25
25
|
} else {
|
|
26
|
-
mapHooks![hook.key] = {(payload:Any) -> () in
|
|
26
|
+
mapHooks![hook.key] = {(payload:Any) -> () in DispatchQueue.main.async {
|
|
27
|
+
guard let data = try? JSONEncoder().encode(self.toAnyEncodable(payload)) else {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let encoded = String(data: data, encoding: .utf8)!
|
|
32
|
+
self.sendEvent(withName: "ScreebEvent", body: ["hookId": hook.value, "payload": encoded])
|
|
33
|
+
}}
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -90,7 +97,14 @@ class ScreebModule: RCTEventEmitter {
|
|
|
90
97
|
if(hook.key == "version"){
|
|
91
98
|
mapHooks![hook.key] = hook.value as? String
|
|
92
99
|
} else {
|
|
93
|
-
mapHooks![hook.key] = {(payload:Any) -> () in
|
|
100
|
+
mapHooks![hook.key] = {(payload:Any) -> () in DispatchQueue.main.async {
|
|
101
|
+
guard let data = try? JSONEncoder().encode(self.toAnyEncodable(payload)) else {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
let encoded = String(data: data, encoding: .utf8)!
|
|
106
|
+
self.sendEvent(withName: "ScreebEvent", body: ["hookId": hook.value, "payload": encoded])
|
|
107
|
+
}}
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
}
|
|
@@ -140,7 +154,7 @@ class ScreebModule: RCTEventEmitter {
|
|
|
140
154
|
@objc func onHookResult(_ hookId: String, payload: [String: Any]?) {
|
|
141
155
|
DispatchQueue.main.async {
|
|
142
156
|
if payload != nil {
|
|
143
|
-
let encoded = self.toAnyEncodable(payload["result"]
|
|
157
|
+
let encoded = self.toAnyEncodable(payload!["result"])
|
|
144
158
|
Screeb.onHookResult(hookId, encoded)
|
|
145
159
|
}
|
|
146
160
|
}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -104,16 +104,15 @@ function closeSurvey() {
|
|
|
104
104
|
}
|
|
105
105
|
exports.closeSurvey = closeSurvey;
|
|
106
106
|
function handleEvent(event) {
|
|
107
|
-
console.log(event);
|
|
108
107
|
if (event?.hookId != null) {
|
|
109
108
|
let hook = hooksRegistry.get(event.hookId);
|
|
110
109
|
if (hook != null) {
|
|
111
110
|
const result = hook(event.payload);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const originalHookId = event?.payload?.hook_id;
|
|
111
|
+
const parsedPayload = JSON.parse(event.payload);
|
|
112
|
+
const originalHookId = parsedPayload?.hook_id;
|
|
115
113
|
if (originalHookId) {
|
|
116
|
-
|
|
114
|
+
// result must be a map to fit with react native allowed types
|
|
115
|
+
ScreebModule.onHookResult(originalHookId, { result });
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
}
|
package/lib/module/index.js
CHANGED
|
@@ -88,16 +88,15 @@ export function closeSurvey() {
|
|
|
88
88
|
return ScreebModule.closeSurvey();
|
|
89
89
|
}
|
|
90
90
|
function handleEvent(event) {
|
|
91
|
-
console.log(event);
|
|
92
91
|
if (event?.hookId != null) {
|
|
93
92
|
let hook = hooksRegistry.get(event.hookId);
|
|
94
93
|
if (hook != null) {
|
|
95
94
|
const result = hook(event.payload);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const originalHookId = event?.payload?.hook_id;
|
|
95
|
+
const parsedPayload = JSON.parse(event.payload);
|
|
96
|
+
const originalHookId = parsedPayload?.hook_id;
|
|
99
97
|
if (originalHookId) {
|
|
100
|
-
|
|
98
|
+
// result must be a map to fit with react native allowed types
|
|
99
|
+
ScreebModule.onHookResult(originalHookId, { result });
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -143,7 +143,8 @@ function handleEvent(event: any) {
|
|
|
143
143
|
let hook = hooksRegistry.get(event.hookId);
|
|
144
144
|
if (hook != null) {
|
|
145
145
|
const result = hook(event.payload);
|
|
146
|
-
const
|
|
146
|
+
const parsedPayload = JSON.parse(event.payload);
|
|
147
|
+
const originalHookId = parsedPayload?.hook_id;
|
|
147
148
|
if (originalHookId) {
|
|
148
149
|
// result must be a map to fit with react native allowed types
|
|
149
150
|
ScreebModule.onHookResult(originalHookId, { result });
|