@applicaster/quick-brick-native-apple 5.17.0 → 5.20.0
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.
|
|
3
|
+
"version": "5.20.0",
|
|
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.
|
|
19
|
+
"tag": "@@applicaster/quick-brick-native-apple/5.20.0"
|
|
20
20
|
},
|
|
21
21
|
"requires_arc": true,
|
|
22
22
|
"source_files": "universal/**/*.{m,swift}",
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AnalyticsBridge.swift
|
|
3
|
+
// QuickBrickApple
|
|
4
|
+
//
|
|
5
|
+
// Created by Avi Levin on 09/5/2022.
|
|
6
|
+
// Copyright © 2018 Applicaster LTD. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import React
|
|
11
|
+
import ZappCore
|
|
12
|
+
|
|
13
|
+
@objc(AppLoaderBridge)
|
|
14
|
+
class AppLoaderBridge: NSObject, RCTBridgeModule {
|
|
15
|
+
static func moduleName() -> String! {
|
|
16
|
+
"AppLoaderBridge"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/// prefered thread on which to run this native module
|
|
20
|
+
@objc public var methodQueue: DispatchQueue {
|
|
21
|
+
DispatchQueue.main
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public class func requiresMainQueueSetup() -> Bool {
|
|
25
|
+
true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
enum Errors {
|
|
29
|
+
static let canNotAccessAppData = "Can not access application data"
|
|
30
|
+
static let parameterDoesNotExist = "The type parameter does not exist/supported"
|
|
31
|
+
static let noIdentifierBody = "FacadeConnector can't delegate applicationData"
|
|
32
|
+
static let noCharacters = "Layout id without charaters"
|
|
33
|
+
static let urlCreationMessage = "There was a problem to create the new layout URLs"
|
|
34
|
+
static let switchToNewLayoutMessage = "There was a problem to switch to new layout URLs"
|
|
35
|
+
static let canNotGetPluginsContent = "Can not get the plugins content"
|
|
36
|
+
static let canNotGetPipesEndpointContent = "Can not get the pipes endpoint content"
|
|
37
|
+
static let canNotGetCellStylesContent = "Can not get the cell style content"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
enum ContentType: String {
|
|
41
|
+
case remoteConfigurations
|
|
42
|
+
case pluginConfigurations
|
|
43
|
+
case layout
|
|
44
|
+
case styles
|
|
45
|
+
case cellStyles
|
|
46
|
+
case pipesEndpoints
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
enum Consts {
|
|
50
|
+
static let currentLayoutId = "currentLayoutId"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// MARK: - Bridge Methods
|
|
54
|
+
|
|
55
|
+
@objc public func getFile(_ type: String,
|
|
56
|
+
options _: [String: Any]?,
|
|
57
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
58
|
+
rejecter: @escaping RCTPromiseRejectBlock)
|
|
59
|
+
{
|
|
60
|
+
guard let applicationData = FacadeConnector.connector?.applicationData else {
|
|
61
|
+
rejecter("2", Errors.canNotAccessAppData, nil)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
guard let contentType = ContentType(rawValue: type) else {
|
|
66
|
+
rejecter("1", Errors.parameterDoesNotExist, nil)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
switch contentType {
|
|
71
|
+
case .remoteConfigurations:
|
|
72
|
+
guard let remoteConfig = applicationData.remoteConfigurationUrlContent() else {
|
|
73
|
+
rejecter("2", Errors.canNotAccessAppData, nil)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
let remoteConfigJsonString = remoteConfig.getJsonString()
|
|
77
|
+
resolver(remoteConfigJsonString)
|
|
78
|
+
case .pluginConfigurations:
|
|
79
|
+
guard let pluginsContent = applicationData.pluginsUrlContent() else {
|
|
80
|
+
rejecter("7", Errors.canNotGetPluginsContent, nil)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let jsonString = JsonHelper.convertObjectToJsonString(object: pluginsContent, options: [])
|
|
85
|
+
resolver(jsonString)
|
|
86
|
+
case .layout:
|
|
87
|
+
guard let layoutId = getLayoutId() else {
|
|
88
|
+
resolver(applicationData.layoutUrlContent()?.getJsonString())
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
applicationData.layoutUrlContent(for: layoutId) { layoutUrlContent in
|
|
93
|
+
guard let layoutUrlContent = layoutUrlContent else {
|
|
94
|
+
rejecter("4", Errors.switchToNewLayoutMessage, nil)
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
resolver(layoutUrlContent.getJsonString())
|
|
99
|
+
}
|
|
100
|
+
case .styles:
|
|
101
|
+
guard let layoutId = getLayoutId() else {
|
|
102
|
+
resolver(applicationData.stylesUrlContent()?.getJsonString())
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
applicationData.cellStylesUrlContent(for: layoutId) { cellStylesUrlContent in
|
|
107
|
+
guard let cellStylesUrlContent = cellStylesUrlContent else {
|
|
108
|
+
rejecter("4", Errors.switchToNewLayoutMessage, nil)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resolver(cellStylesUrlContent.getJsonString())
|
|
113
|
+
}
|
|
114
|
+
case .cellStyles:
|
|
115
|
+
guard let cellStylesData = applicationData.cellStylesUrlContent() else {
|
|
116
|
+
rejecter("9", Errors.canNotGetCellStylesContent, nil)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
resolver(cellStylesData.getJsonString())
|
|
120
|
+
case .pipesEndpoints:
|
|
121
|
+
guard let pipesEndpointContent = applicationData.pipesEndpointContent() else {
|
|
122
|
+
rejecter("8", Errors.canNotGetPipesEndpointContent, nil)
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
resolver(pipesEndpointContent.getJsonString())
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@objc public func switchLayout(layoutId: String,
|
|
130
|
+
options _: [String: Any]?,
|
|
131
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
132
|
+
rejecter: @escaping RCTPromiseRejectBlock)
|
|
133
|
+
{
|
|
134
|
+
// Construct the layout and cell_style URLS
|
|
135
|
+
guard let applicationData = FacadeConnector.connector?.applicationData else {
|
|
136
|
+
rejecter("2", Errors.canNotAccessAppData, nil)
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
applicationData.layoutUrlContent(for: layoutId) { layoutUrlContent in
|
|
141
|
+
guard let _ = layoutUrlContent else {
|
|
142
|
+
rejecter("4", Errors.switchToNewLayoutMessage, nil)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
applicationData.cellStylesUrlContent(for: layoutId) { cellStylesUrlContent in
|
|
147
|
+
guard let _ = cellStylesUrlContent,
|
|
148
|
+
self.saveLayoutId(id: layoutId)
|
|
149
|
+
else {
|
|
150
|
+
rejecter("4", Errors.switchToNewLayoutMessage, nil)
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
resolver(true)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// get the current layout id
|
|
160
|
+
@objc public func getCurrentLayoutId(_ resolve: @escaping RCTPromiseResolveBlock,
|
|
161
|
+
rejecter: @escaping RCTPromiseRejectBlock)
|
|
162
|
+
{
|
|
163
|
+
guard let layoutId = getLayoutId() else {
|
|
164
|
+
getDefaultLayoutId(resolve, rejecter: rejecter)
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
resolve(layoutId)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// get the defualt layout id
|
|
172
|
+
@objc public func getDefaultLayoutId(_ resolve: @escaping RCTPromiseResolveBlock,
|
|
173
|
+
rejecter: @escaping RCTPromiseRejectBlock)
|
|
174
|
+
{
|
|
175
|
+
guard let applicationData = FacadeConnector.connector?.applicationData else {
|
|
176
|
+
rejecter("2", Errors.canNotAccessAppData, nil)
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let layoutId = applicationData.layoutId()
|
|
181
|
+
guard layoutId.isEmpty == false else {
|
|
182
|
+
rejecter("3", Errors.parameterDoesNotExist, nil)
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
resolve(layoutId)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// MARK: - Private Methods
|
|
189
|
+
|
|
190
|
+
private func saveLayoutId(id: String) -> Bool {
|
|
191
|
+
FacadeConnector.connector?.storage?.sessionStorageSetValue(for: Consts.currentLayoutId,
|
|
192
|
+
value: id,
|
|
193
|
+
namespace: nil) ?? false
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private func getLayoutId() -> String? {
|
|
197
|
+
FacadeConnector.connector?.storage?.sessionStorageValue(for: Consts.currentLayoutId,
|
|
198
|
+
namespace: nil)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -128,3 +128,21 @@ RCT_EXTERN_METHOD(delete:(NSString *)path
|
|
|
128
128
|
RCT_EXTERN_METHOD(getFilesDirectory:(RCTPromiseResolveBlock)resolve
|
|
129
129
|
rejecter:(RCTPromiseRejectBlock)reject);
|
|
130
130
|
@end
|
|
131
|
+
|
|
132
|
+
@interface RCT_EXTERN_MODULE (AppLoaderBridge, NSObject)
|
|
133
|
+
RCT_EXTERN_METHOD(getFile:(NSString *)type
|
|
134
|
+
options:(NSDictionary *)options
|
|
135
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
136
|
+
rejecter:(RCTPromiseRejectBlock)reject);
|
|
137
|
+
|
|
138
|
+
RCT_EXTERN_METHOD(switchLayout:(NSString *)layoutId
|
|
139
|
+
options:(NSDictionary *)options
|
|
140
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
141
|
+
rejecter:(RCTPromiseRejectBlock)reject);
|
|
142
|
+
|
|
143
|
+
RCT_EXTERN_METHOD(getCurrentLayoutId:(RCTPromiseResolveBlock)resolve
|
|
144
|
+
rejecter:(RCTPromiseRejectBlock)reject);
|
|
145
|
+
|
|
146
|
+
RCT_EXTERN_METHOD(getDefaultLayoutId:(RCTPromiseResolveBlock)resolve
|
|
147
|
+
rejecter:(RCTPromiseRejectBlock)reject);
|
|
148
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-native-apple",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0",
|
|
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"
|