@applicaster/quick-brick-native-apple 6.9.6 → 6.9.7
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/apple/QuickBrickApple.podspec.json +2 -2
- package/apple/universal/Models/ReactAnalyticsAgentPlugin/EventEmitter.swift +8 -4
- package/apple/universal/Models/ReactAnalyticsAgentPlugin/ReactAnalyticsAgentPluginEventEmitter.swift +5 -0
- package/apple/universal/ReactNative/ReactNativeManager.swift +11 -4
- package/apple/universal/Utils/Throttler.swift +34 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "QuickBrickApple",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.7",
|
|
4
4
|
"platforms": {
|
|
5
5
|
"ios": "14.0",
|
|
6
6
|
"tvos": "14.0"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"authors": "Applicaster LTD.",
|
|
17
17
|
"source": {
|
|
18
18
|
"git": "https://github.com/applicaster/Zapp-Frameworks.git",
|
|
19
|
-
"tag": "@@applicaster/quick-brick-native-apple/6.9.
|
|
19
|
+
"tag": "@@applicaster/quick-brick-native-apple/6.9.7"
|
|
20
20
|
},
|
|
21
21
|
"requires_arc": true,
|
|
22
22
|
"source_files": "universal/**/*.{m,swift}",
|
|
@@ -17,7 +17,7 @@ open class EventEmitter {
|
|
|
17
17
|
qos: .default,
|
|
18
18
|
attributes: .concurrent)
|
|
19
19
|
|
|
20
|
-
private var _emitter: ReactAnalyticsAgentPluginEventEmitter?
|
|
20
|
+
private weak var _emitter: ReactAnalyticsAgentPluginEventEmitter?
|
|
21
21
|
|
|
22
22
|
private init() {}
|
|
23
23
|
|
|
@@ -36,7 +36,9 @@ open class EventEmitter {
|
|
|
36
36
|
|
|
37
37
|
public func sendEvent(withName name: String,
|
|
38
38
|
body: [String: Any]) {
|
|
39
|
-
queue.
|
|
39
|
+
queue.async { [weak self] in
|
|
40
|
+
guard let self else { return }
|
|
41
|
+
|
|
40
42
|
_emitter?.sendEvent(withName: name,
|
|
41
43
|
body: body)
|
|
42
44
|
}
|
|
@@ -47,13 +49,15 @@ open class EventEmitter {
|
|
|
47
49
|
|
|
48
50
|
extension EventEmitter {
|
|
49
51
|
func addSupportedEvent(event: String) {
|
|
50
|
-
queue.async(flags: .barrier) { [
|
|
52
|
+
queue.async(flags: .barrier) { [weak self] in
|
|
53
|
+
guard let self else { return }
|
|
51
54
|
allEvents.insert(event)
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
func removeSupportedEvent(event: String) {
|
|
56
|
-
queue.async(flags: .barrier) { [
|
|
59
|
+
queue.async(flags: .barrier) { [weak self] in
|
|
60
|
+
guard let self else { return }
|
|
57
61
|
allEvents.remove(event)
|
|
58
62
|
}
|
|
59
63
|
}
|
package/apple/universal/Models/ReactAnalyticsAgentPlugin/ReactAnalyticsAgentPluginEventEmitter.swift
CHANGED
|
@@ -21,6 +21,11 @@ open class ReactAnalyticsAgentPluginEventEmitter: RCTEventEmitter {
|
|
|
21
21
|
EventEmitter.shared.emitter = self
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
override open func invalidate() {
|
|
25
|
+
super.invalidate()
|
|
26
|
+
EventEmitter.shared.emitter = nil
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
@objc override public static func requiresMainQueueSetup() -> Bool {
|
|
25
30
|
true
|
|
26
31
|
}
|
|
@@ -18,6 +18,7 @@ public let suspendApp = "suspend"
|
|
|
18
18
|
/// React Native Manager class for Quick Brick
|
|
19
19
|
open class ReactNativeManager: NSObject, UserInterfaceLayerProtocol, UserInterfaceLayerDelegate {
|
|
20
20
|
lazy var logger = Logger.getLogger(for: ReactNativeManagerLogs.subsystem)
|
|
21
|
+
private lazy var throttler = Throttler(timeInterval: 2)
|
|
21
22
|
|
|
22
23
|
static var applicationData: [String: Any] = [:]
|
|
23
24
|
|
|
@@ -137,9 +138,8 @@ open class ReactNativeManager: NSObject, UserInterfaceLayerProtocol, UserInterfa
|
|
|
137
138
|
moduleName: kQBModuleName,
|
|
138
139
|
initialProperties: nil
|
|
139
140
|
)
|
|
141
|
+
self.reactRootView?.backgroundColor = UIColor.clear
|
|
140
142
|
}
|
|
141
|
-
|
|
142
|
-
reactRootView?.backgroundColor = UIColor.clear
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
public func reactNativeViewController() -> UIViewController {
|
|
@@ -226,11 +226,18 @@ extension ReactNativeManager: QuickBrickManagerDelegate {
|
|
|
226
226
|
UIApplication.shared.isIdleTimerDisabled = disabled
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
private func forceAppReloadForEventWithThrottler(event: EventsBus.Event) {
|
|
230
|
+
throttler.throttle { [weak self] in
|
|
231
|
+
EventsBus.post(event)
|
|
232
|
+
self?.logger?.debugLog(message: "forceAppReloadForEventWithThrottler: App reloaded with event: \(event.type.description)")
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
229
236
|
public func forceAppReload() {
|
|
230
|
-
|
|
237
|
+
forceAppReloadForEventWithThrottler(event: EventsBus.Event(type: EventsBusType(.forceAppReload)))
|
|
231
238
|
}
|
|
232
239
|
|
|
233
240
|
public func forceAppReloadLanguageSwitch() {
|
|
234
|
-
|
|
241
|
+
forceAppReloadForEventWithThrottler(event: EventsBus.Event(type: EventsBusType(.forceAppReloadLanguageSwitch)))
|
|
235
242
|
}
|
|
236
243
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Throttler.swift
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Anton Kononenko on 10/30/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
class Throttler {
|
|
9
|
+
private let queue: DispatchQueue
|
|
10
|
+
private let interval: TimeInterval
|
|
11
|
+
private var lastExecution: Date?
|
|
12
|
+
|
|
13
|
+
init(timeInterval: TimeInterval, queue: DispatchQueue = .main) {
|
|
14
|
+
interval = timeInterval
|
|
15
|
+
self.queue = queue
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func throttle(action: @escaping () -> Void) {
|
|
19
|
+
queue.async { [weak self] in
|
|
20
|
+
guard let self else { return }
|
|
21
|
+
let now = Date()
|
|
22
|
+
if let last = lastExecution {
|
|
23
|
+
let elapsed = now.timeIntervalSince(last)
|
|
24
|
+
if elapsed >= interval {
|
|
25
|
+
lastExecution = now
|
|
26
|
+
action()
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
lastExecution = now
|
|
30
|
+
action()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-native-apple",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.7",
|
|
4
4
|
"description": "iOS and tvOS native code for QuickBrick applications. This package is used to provide native logic for QuickBrick",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|