@applicaster/quick-brick-native-apple 5.21.0 → 5.21.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "QuickBrickApple",
3
- "version": "5.21.0",
3
+ "version": "5.21.1",
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/5.21.0"
19
+ "tag": "@@applicaster/quick-brick-native-apple/5.21.1"
20
20
  },
21
21
  "requires_arc": true,
22
22
  "source_files": "universal/**/*.{m,swift}",
@@ -0,0 +1,60 @@
1
+ //
2
+ // EventEmitter.swift
3
+ // EventEmitter
4
+ //
5
+ // Created by Anton Kononenko on 05/01/2022.
6
+ // Copyright © 2022 Applicaster. All rights reserved.
7
+ //
8
+
9
+ import React
10
+ import ZappCore
11
+
12
+ open class EventEmitter {
13
+ static let shared = EventEmitter()
14
+ private(set) var allEvents: Set<String> = []
15
+
16
+ private let queue = DispatchQueue(label: String(describing: EventEmitter.self),
17
+ qos: .default,
18
+ attributes: .concurrent)
19
+
20
+ private var _emitter: ReactAnalyticsAgentPluginEventEmitter?
21
+
22
+ private init() {}
23
+
24
+ var emitter: ReactAnalyticsAgentPluginEventEmitter? {
25
+ get {
26
+ queue.sync { [unowned self] in
27
+ _emitter
28
+ }
29
+ }
30
+ set {
31
+ queue.async(flags: .barrier) { [unowned self] in
32
+ _emitter = newValue
33
+ }
34
+ }
35
+ }
36
+
37
+ public func sendEvent(withName name: String,
38
+ body: [String: Any]) {
39
+ queue.sync { [unowned self] in
40
+ _emitter?.sendEvent(withName: name,
41
+ body: body)
42
+ }
43
+ }
44
+ }
45
+
46
+ // MARK: Handling Supporting Events
47
+
48
+ extension EventEmitter {
49
+ func addSupportedEvent(event: String) {
50
+ queue.async(flags: .barrier) { [unowned self] in
51
+ allEvents.insert(event)
52
+ }
53
+ }
54
+
55
+ func removeSupportedEvent(event: String) {
56
+ queue.async(flags: .barrier) { [unowned self] in
57
+ allEvents.remove(event)
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,35 @@
1
+ //
2
+ // ReactAnalyticsAgentPlugin+AnalyticsProviderProtocol.swift
3
+ // ReactAnalyticsAgentPlugin+AnalyticsProviderProtocol
4
+ //
5
+ // Created by Anton Kononenko on 05/01/2022.
6
+ // Copyright © 2022 Applicaster. All rights reserved.
7
+ //
8
+
9
+ import ZappCore
10
+
11
+ extension ReactAnalyticsAgentPlugin {
12
+ func parseEventToRnEvent(_ eventName: String,
13
+ parameters: [String: NSObject]) -> [String: Any] {
14
+ [NativeEventKeys.eventName: eventName,
15
+ NativeEventKeys.eventData: parameters]
16
+ }
17
+
18
+ func sendEventToRn(_ eventName: String,
19
+ parameters: [String: NSObject]) {
20
+ EventEmitter.shared.sendEvent(withName: eventKey,
21
+ body: parseEventToRnEvent(eventName,
22
+ parameters: parameters))
23
+ }
24
+
25
+ override public func trackEvent(_ eventName: String,
26
+ parameters: [String: NSObject]) {
27
+ guard isDisabled == false else {
28
+ return
29
+ }
30
+
31
+ // Send
32
+ sendEventToRn(eventName,
33
+ parameters: parameters)
34
+ }
35
+ }
@@ -0,0 +1,45 @@
1
+ //
2
+ // ReactAnalyticsAgentPlugin.swift
3
+ // AnalyticsPluginPlayer
4
+ //
5
+ // Created by Anton Kononenko on 05/01/2022.
6
+ // Copyright © 2022 Applicaster. All rights reserved.
7
+ //
8
+
9
+ import React
10
+ import ZappCore
11
+
12
+ struct NativeEventKeys {
13
+ static let eventName = "event"
14
+ static let eventData = "data"
15
+ }
16
+
17
+ open class ReactAnalyticsAgentPlugin: AnalyticsBaseGenericProvider {
18
+ static let EventKeyTemplate = "analytics:%@:logEvent"
19
+
20
+ let eventKey: String
21
+
22
+ // MARK: - AsyncPluginAdapterProtocol
23
+
24
+ public required init(pluginModel: ZPPluginModel) {
25
+ eventKey = String(format: Self.EventKeyTemplate, pluginModel.identifier)
26
+
27
+ super.init(pluginModel: pluginModel)
28
+
29
+ addEventToEventEmitter(eventKey: eventKey)
30
+ }
31
+
32
+ override open func prepare(_ defaultParams: [String: Any]) async -> Result<Bool, Error> {
33
+ _ = await super.prepare(defaultParams)
34
+ return .success(true)
35
+ }
36
+
37
+ override open func disable() async -> Result<Bool, Error> {
38
+ _ = await super.disable()
39
+ return .success(true)
40
+ }
41
+
42
+ func addEventToEventEmitter(eventKey: String) {
43
+ EventEmitter.shared.addSupportedEvent(event: eventKey)
44
+ }
45
+ }
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <React/RCTBridgeModule.h>
3
+ #import <React/RCTEventEmitter.h>
4
+
5
+ @interface RCT_EXTERN_MODULE(ReactAnalyticsAgentPluginEventEmitter, RCTEventEmitter)
6
+
7
+ RCT_EXTERN_METHOD(supportedEvents)
8
+
9
+ @end
@@ -0,0 +1,44 @@
1
+ //
2
+ // ReactAnalyticsAgentPluginEventEmitter.swift
3
+ // ReactAnalyticsAgentPluginEventEmitter
4
+ //
5
+ // Created by Anton Kononenko on 05/01/2022.
6
+ // Copyright © 2022 Applicaster. All rights reserved.
7
+ //
8
+
9
+ import React
10
+ import ZappCore
11
+
12
+ @objc(ReactAnalyticsAgentPluginEventEmitter)
13
+ open class ReactAnalyticsAgentPluginEventEmitter: RCTEventEmitter {
14
+ private var hasListeners = false
15
+
16
+ override init() {
17
+ super.init()
18
+ EventEmitter.shared.emitter = self
19
+ }
20
+
21
+ @objc override public static func requiresMainQueueSetup() -> Bool {
22
+ true
23
+ }
24
+
25
+ @objc override open func supportedEvents() -> [String] {
26
+ Array(EventEmitter.shared.allEvents)
27
+ }
28
+
29
+ override open func startObserving() {
30
+ hasListeners = true
31
+
32
+ super.startObserving()
33
+ }
34
+
35
+ override open func stopObserving() {
36
+ hasListeners = false
37
+
38
+ super.stopObserving()
39
+ }
40
+
41
+ override open func addListener(_ eventName: String!) {
42
+ super.addListener(eventName)
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-native-apple",
3
- "version": "5.21.0",
3
+ "version": "5.21.1",
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"