theta-client-react-native 1.3.1 → 1.4.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.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +81 -0
- package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +55 -19
- package/ios/ConvertUtil.swift +989 -0
- package/ios/ThetaClientReactNative-Bridging-Header.h +3 -0
- package/ios/ThetaClientReactNative.m +201 -0
- package/ios/ThetaClientReactNative.swift +1337 -0
- package/ios/ThetaClientReactNative.xcodeproj/project.pbxproj +15 -57
- package/lib/commonjs/capture/photo-capture.js +19 -1
- package/lib/commonjs/capture/photo-capture.js.map +1 -1
- package/lib/commonjs/capture/time-shift-capture.js +27 -23
- package/lib/commonjs/capture/time-shift-capture.js.map +1 -1
- package/lib/commonjs/capture/video-capture.js +33 -5
- package/lib/commonjs/capture/video-capture.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/theta-repository/notify-controller.js +40 -0
- package/lib/commonjs/theta-repository/notify-controller.js.map +1 -0
- package/lib/commonjs/theta-repository/options/index.js +44 -0
- package/lib/commonjs/theta-repository/options/index.js.map +1 -1
- package/lib/commonjs/theta-repository/options/option-face-detect.js +22 -0
- package/lib/commonjs/theta-repository/options/option-face-detect.js.map +1 -0
- package/lib/commonjs/theta-repository/options/option-function.js +27 -0
- package/lib/commonjs/theta-repository/options/option-function.js.map +1 -0
- package/lib/commonjs/theta-repository/options/option-gain.js +26 -0
- package/lib/commonjs/theta-repository/options/option-gain.js.map +1 -0
- package/lib/commonjs/theta-repository/options/option-image-stitching.js +38 -0
- package/lib/commonjs/theta-repository/options/option-image-stitching.js.map +1 -0
- package/lib/commonjs/theta-repository/options/options.js +8 -0
- package/lib/commonjs/theta-repository/options/options.js.map +1 -1
- package/lib/commonjs/theta-repository/theta-repository.js +2 -3
- package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
- package/lib/commonjs/theta-repository/theta-state.js +1 -13
- package/lib/commonjs/theta-repository/theta-state.js.map +1 -1
- package/lib/module/capture/photo-capture.js +19 -1
- package/lib/module/capture/photo-capture.js.map +1 -1
- package/lib/module/capture/time-shift-capture.js +27 -23
- package/lib/module/capture/time-shift-capture.js.map +1 -1
- package/lib/module/capture/video-capture.js +33 -5
- package/lib/module/capture/video-capture.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/theta-repository/notify-controller.js +33 -0
- package/lib/module/theta-repository/notify-controller.js.map +1 -0
- package/lib/module/theta-repository/options/index.js +4 -0
- package/lib/module/theta-repository/options/index.js.map +1 -1
- package/lib/module/theta-repository/options/option-face-detect.js +15 -0
- package/lib/module/theta-repository/options/option-face-detect.js.map +1 -0
- package/lib/module/theta-repository/options/option-function.js +20 -0
- package/lib/module/theta-repository/options/option-function.js.map +1 -0
- package/lib/module/theta-repository/options/option-gain.js +19 -0
- package/lib/module/theta-repository/options/option-gain.js.map +1 -0
- package/lib/module/theta-repository/options/option-image-stitching.js +31 -0
- package/lib/module/theta-repository/options/option-image-stitching.js.map +1 -0
- package/lib/module/theta-repository/options/options.js +8 -0
- package/lib/module/theta-repository/options/options.js.map +1 -1
- package/lib/module/theta-repository/theta-repository.js +2 -3
- package/lib/module/theta-repository/theta-repository.js.map +1 -1
- package/lib/module/theta-repository/theta-state.js +0 -12
- package/lib/module/theta-repository/theta-state.js.map +1 -1
- package/lib/typescript/capture/photo-capture.d.ts +7 -1
- package/lib/typescript/capture/photo-capture.d.ts.map +1 -1
- package/lib/typescript/capture/time-shift-capture.d.ts +4 -7
- package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -1
- package/lib/typescript/capture/video-capture.d.ts +5 -1
- package/lib/typescript/capture/video-capture.d.ts.map +1 -1
- package/lib/typescript/theta-repository/notify-controller.d.ts +17 -0
- package/lib/typescript/theta-repository/notify-controller.d.ts.map +1 -0
- package/lib/typescript/theta-repository/options/index.d.ts +4 -0
- package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
- package/lib/typescript/theta-repository/options/option-face-detect.d.ts +15 -0
- package/lib/typescript/theta-repository/options/option-face-detect.d.ts.map +1 -0
- package/lib/typescript/theta-repository/options/option-function.d.ts +20 -0
- package/lib/typescript/theta-repository/options/option-function.d.ts.map +1 -0
- package/lib/typescript/theta-repository/options/option-gain.d.ts +19 -0
- package/lib/typescript/theta-repository/options/option-gain.d.ts.map +1 -0
- package/lib/typescript/theta-repository/options/option-image-stitching.d.ts +30 -0
- package/lib/typescript/theta-repository/options/option-image-stitching.d.ts.map +1 -0
- package/lib/typescript/theta-repository/options/options.d.ts +20 -0
- package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
- package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
- package/lib/typescript/theta-repository/theta-state.d.ts +1 -11
- package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -1
- package/package.json +14 -8
- package/src/capture/photo-capture.ts +20 -3
- package/src/capture/time-shift-capture.ts +40 -33
- package/src/capture/video-capture.ts +49 -6
- package/src/theta-repository/notify-controller.ts +50 -0
- package/src/theta-repository/options/index.ts +4 -0
- package/src/theta-repository/options/option-face-detect.ts +16 -0
- package/src/theta-repository/options/option-function.ts +21 -0
- package/src/theta-repository/options/option-gain.ts +19 -0
- package/src/theta-repository/options/option-image-stitching.ts +32 -0
- package/src/theta-repository/options/options.ts +20 -0
- package/src/theta-repository/theta-repository.ts +3 -3
- package/src/theta-repository/theta-state.ts +2 -14
- package/theta-client-react-native.podspec +2 -2
- package/ios/ThetaClientReactNative.h +0 -34
- package/ios/ThetaClientReactNative.mm +0 -4087
- package/lib/commonjs/capture/notify.js +0 -12
- package/lib/commonjs/capture/notify.js.map +0 -1
- package/lib/module/capture/notify.js +0 -6
- package/lib/module/capture/notify.js.map +0 -1
- package/lib/typescript/capture/notify.d.ts +0 -13
- package/lib/typescript/capture/notify.d.ts.map +0 -1
- package/src/capture/notify.ts +0 -27
|
@@ -0,0 +1,1337 @@
|
|
|
1
|
+
import THETAClient
|
|
2
|
+
|
|
3
|
+
let ERROR_CODE_ERROR = "error"
|
|
4
|
+
let MESSAGE_NOT_INIT = "Not initialized."
|
|
5
|
+
let MESSAGE_NO_RESULT = "No result."
|
|
6
|
+
let MESSAGE_NO_ARGUMENT = "No Argument."
|
|
7
|
+
let MESSAGE_NO_PHOTO_CAPTURE = "No photoCapture."
|
|
8
|
+
let MESSAGE_NO_PHOTO_CAPTURE_BUILDER = "no photo capture builder."
|
|
9
|
+
let MESSAGE_NO_TIMESHIFT_CAPTURE = "No timeShiftCapture."
|
|
10
|
+
let MESSAGE_NO_TIMESHIFT_CAPTURE_BUILDER = "no time-shift capture builder."
|
|
11
|
+
let MESSAGE_NO_TIMESHIFT_CAPTURING = "no timeShiftCapturing."
|
|
12
|
+
let MESSAGE_NO_VIDEO_CAPTURE = "No videoCapture."
|
|
13
|
+
let MESSAGE_NO_VIDEO_CAPTURE_BUILDER = "no video capture builder."
|
|
14
|
+
let MESSAGE_NO_VIDEO_CAPTURING = "no videoCapturing."
|
|
15
|
+
|
|
16
|
+
@objc(ThetaClientReactNative)
|
|
17
|
+
class ThetaClientReactNative: RCTEventEmitter {
|
|
18
|
+
var thetaRepository: ThetaRepository?
|
|
19
|
+
var previewing = false
|
|
20
|
+
var photoCaptureBuilder: PhotoCapture.Builder?
|
|
21
|
+
var photoCapture: PhotoCapture?
|
|
22
|
+
var timeShiftCaptureBuilder: TimeShiftCapture.Builder?
|
|
23
|
+
var timeShiftCapture: TimeShiftCapture?
|
|
24
|
+
var timeShiftCapturing: TimeShiftCapturing?
|
|
25
|
+
var videoCaptureBuilder: VideoCapture.Builder?
|
|
26
|
+
var videoCapture: VideoCapture?
|
|
27
|
+
var videoCapturing: VideoCapturing?
|
|
28
|
+
|
|
29
|
+
static let EVENT_FRAME = "ThetaFrameEvent"
|
|
30
|
+
static let EVENT_NOTIFY = "ThetaNotify"
|
|
31
|
+
|
|
32
|
+
static let NOTIFY_TIMESHIFT_PROGRESS = "TIME-SHIFT-PROGRESS"
|
|
33
|
+
static let NOTIFY_VIDEO_CAPTURE_STOP_ERROR = "VIDEO-CAPTURE-STOP-ERROR"
|
|
34
|
+
|
|
35
|
+
@objc
|
|
36
|
+
override func supportedEvents() -> [String]! {
|
|
37
|
+
return [ThetaClientReactNative.EVENT_FRAME, ThetaClientReactNative.EVENT_NOTIFY]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc
|
|
41
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@objc
|
|
46
|
+
override func constantsToExport() -> [AnyHashable: Any]! {
|
|
47
|
+
return [
|
|
48
|
+
"DEFAULT_EVENT_NAME": ThetaClientReactNative.EVENT_FRAME,
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@objc(initialize:withConfig:withTimeout:withResolver:withRejecter:)
|
|
53
|
+
func initialize(
|
|
54
|
+
endPoint: String?,
|
|
55
|
+
config: [AnyHashable: Any]?,
|
|
56
|
+
timeout: [AnyHashable: Any]?,
|
|
57
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
58
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
59
|
+
) {
|
|
60
|
+
thetaRepository = nil
|
|
61
|
+
photoCaptureBuilder = nil
|
|
62
|
+
photoCapture = nil
|
|
63
|
+
timeShiftCaptureBuilder = nil
|
|
64
|
+
timeShiftCapture = nil
|
|
65
|
+
timeShiftCapturing = nil
|
|
66
|
+
videoCaptureBuilder = nil
|
|
67
|
+
videoCapture = nil
|
|
68
|
+
videoCapturing = nil
|
|
69
|
+
previewing = false
|
|
70
|
+
|
|
71
|
+
Task {
|
|
72
|
+
let configParams: ThetaRepository.Config? = {
|
|
73
|
+
if let config = config as? [String: Any] {
|
|
74
|
+
return toConfig(params: config)
|
|
75
|
+
}
|
|
76
|
+
return nil
|
|
77
|
+
}()
|
|
78
|
+
let timeoutParams: ThetaRepository.Timeout? = {
|
|
79
|
+
if let timeout = timeout as? [String: Any] {
|
|
80
|
+
return toTimeout(params: timeout)
|
|
81
|
+
}
|
|
82
|
+
return nil
|
|
83
|
+
}()
|
|
84
|
+
|
|
85
|
+
let endpoint = endPoint ?? "http://192.168.1.1"
|
|
86
|
+
ThetaRepository.Companion.shared.doNewInstance(
|
|
87
|
+
endpoint: endpoint,
|
|
88
|
+
config: configParams,
|
|
89
|
+
timeout: timeoutParams
|
|
90
|
+
) { thetaRepository, error in
|
|
91
|
+
if let error {
|
|
92
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
93
|
+
} else {
|
|
94
|
+
self.thetaRepository = thetaRepository
|
|
95
|
+
resolve(true)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@objc(isInitialized:withRejecter:)
|
|
102
|
+
func isInitialized(
|
|
103
|
+
resolve: RCTPromiseResolveBlock,
|
|
104
|
+
reject _: RCTPromiseRejectBlock
|
|
105
|
+
) {
|
|
106
|
+
resolve(thetaRepository != nil)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@objc(getThetaModel:withRejecter:)
|
|
110
|
+
func getThetaModel(
|
|
111
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
112
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
113
|
+
) {
|
|
114
|
+
guard let thetaRepository else {
|
|
115
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
resolve(thetaRepository.cameraModel?.name)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@objc(getThetaInfo:withRejecter:)
|
|
122
|
+
func getThetaInfo(
|
|
123
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
124
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
125
|
+
) {
|
|
126
|
+
guard let thetaRepository else {
|
|
127
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
thetaRepository.getThetaInfo { response, error in
|
|
131
|
+
if let error {
|
|
132
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
133
|
+
} else if let response {
|
|
134
|
+
var info = convertResult(thetaInfo: response)
|
|
135
|
+
if let cameraModel = thetaRepository.cameraModel {
|
|
136
|
+
info[KEY_THETA_MODEL] = cameraModel.name
|
|
137
|
+
}
|
|
138
|
+
resolve(info)
|
|
139
|
+
} else {
|
|
140
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@objc(getThetaState:withRejecter:)
|
|
146
|
+
func getThetaState(
|
|
147
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
148
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
149
|
+
) {
|
|
150
|
+
guard let thetaRepository else {
|
|
151
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
thetaRepository.getThetaState { response, error in
|
|
155
|
+
if let error {
|
|
156
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
157
|
+
} else if let response {
|
|
158
|
+
let state = convertResult(thetaState: response)
|
|
159
|
+
resolve(state)
|
|
160
|
+
} else {
|
|
161
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@objc(listFiles:withStartPosition:withEntryCount:withStorage:withResolver:withRejecter:)
|
|
167
|
+
func listFiles(
|
|
168
|
+
fileType: String,
|
|
169
|
+
startPosition: Int,
|
|
170
|
+
entryCount: Int,
|
|
171
|
+
storage: String?,
|
|
172
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
173
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
174
|
+
) {
|
|
175
|
+
guard let thetaRepository else {
|
|
176
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
guard
|
|
180
|
+
let fileTypeVal = getEnumValue(
|
|
181
|
+
values: ThetaRepository.FileTypeEnum.values(), name: fileType
|
|
182
|
+
)
|
|
183
|
+
else {
|
|
184
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let storageVal = getEnumValue(
|
|
189
|
+
values: ThetaRepository.StorageEnum.values(), name: storage ?? ""
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
thetaRepository.listFiles(
|
|
193
|
+
fileType: fileTypeVal,
|
|
194
|
+
startPosition: Int32(startPosition),
|
|
195
|
+
entryCount: Int32(entryCount),
|
|
196
|
+
storage: storageVal
|
|
197
|
+
) { files, error in
|
|
198
|
+
if let error {
|
|
199
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
200
|
+
} else if let files {
|
|
201
|
+
let resultList = convertResult(fileInfoList: files.fileList)
|
|
202
|
+
let resultMap = [
|
|
203
|
+
KEY_FILE_LIST: resultList,
|
|
204
|
+
KEY_TOTAL_ENTRIES: files.totalEntries,
|
|
205
|
+
]
|
|
206
|
+
resolve(resultMap)
|
|
207
|
+
} else {
|
|
208
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@objc(deleteFiles:withResolver:withRejecter:)
|
|
214
|
+
func deleteFiles(
|
|
215
|
+
fileUrls: [Any],
|
|
216
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
217
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
218
|
+
) {
|
|
219
|
+
guard let thetaRepository else {
|
|
220
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
guard let urls = fileUrls as? [String] else {
|
|
224
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
225
|
+
return
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
thetaRepository.deleteFiles(fileUrls: urls) { error in
|
|
229
|
+
if let error {
|
|
230
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
231
|
+
} else {
|
|
232
|
+
resolve(true)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@objc(deleteAllFiles:withRejecter:)
|
|
238
|
+
func deleteAllFiles(
|
|
239
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
240
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
241
|
+
) {
|
|
242
|
+
guard let thetaRepository else {
|
|
243
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
thetaRepository.deleteAllFiles { error in
|
|
248
|
+
if let error {
|
|
249
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
250
|
+
} else {
|
|
251
|
+
resolve(true)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@objc(deleteAllImageFiles:withRejecter:)
|
|
257
|
+
func deleteAllImageFiles(
|
|
258
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
259
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
260
|
+
) {
|
|
261
|
+
guard let thetaRepository else {
|
|
262
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
thetaRepository.deleteAllImageFiles { error in
|
|
267
|
+
if let error {
|
|
268
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
269
|
+
} else {
|
|
270
|
+
resolve(true)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@objc(deleteAllVideoFiles:withRejecter:)
|
|
276
|
+
func deleteAllVideoFiles(
|
|
277
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
278
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
279
|
+
) {
|
|
280
|
+
guard let thetaRepository else {
|
|
281
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
thetaRepository.deleteAllVideoFiles { error in
|
|
286
|
+
if let error {
|
|
287
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
288
|
+
} else {
|
|
289
|
+
resolve(true)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@objc(getOptions:withResolver:withRejecter:)
|
|
295
|
+
func getOptions(
|
|
296
|
+
optionNames: [Any],
|
|
297
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
298
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
299
|
+
) {
|
|
300
|
+
guard let thetaRepository else {
|
|
301
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
302
|
+
return
|
|
303
|
+
}
|
|
304
|
+
guard let optionNames = optionNames as? [String] else {
|
|
305
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let params = convertGetOptionsParam(params: optionNames)
|
|
310
|
+
thetaRepository.getOptions(
|
|
311
|
+
optionNames: params
|
|
312
|
+
) { response, error in
|
|
313
|
+
if let error {
|
|
314
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
315
|
+
} else if let response {
|
|
316
|
+
resolve(convertResult(options: response))
|
|
317
|
+
} else {
|
|
318
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@objc(setOptions:withResolver:withRejecter:)
|
|
324
|
+
func setOptions(
|
|
325
|
+
options: [AnyHashable: Any],
|
|
326
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
327
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
328
|
+
) {
|
|
329
|
+
guard let thetaRepository else {
|
|
330
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
guard let options = options as? [String: Any] else {
|
|
334
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
let params = convertSetOptionsParam(params: options)
|
|
338
|
+
|
|
339
|
+
thetaRepository.setOptions(
|
|
340
|
+
options: params
|
|
341
|
+
) { error in
|
|
342
|
+
if let error {
|
|
343
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
344
|
+
} else {
|
|
345
|
+
resolve(true)
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@objc(getLivePreview:withRejecter:)
|
|
351
|
+
func getLivePreview(
|
|
352
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
353
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
354
|
+
) {
|
|
355
|
+
class FrameHandler: KotlinSuspendFunction1 {
|
|
356
|
+
let thetaClientReactNative: ThetaClientReactNative
|
|
357
|
+
static let FrameInterval = CFTimeInterval(1.0 / 10.0)
|
|
358
|
+
var last: CFTimeInterval = 0
|
|
359
|
+
|
|
360
|
+
init(_ thetaClientReactNative: ThetaClientReactNative) {
|
|
361
|
+
self.thetaClientReactNative = thetaClientReactNative
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
func invoke(p1: Any?) async throws -> Any? {
|
|
365
|
+
let now = CACurrentMediaTime()
|
|
366
|
+
if now - last > Self.FrameInterval {
|
|
367
|
+
autoreleasepool {
|
|
368
|
+
if let frameData = p1 as? KotlinPair<KotlinByteArray, KotlinInt> {
|
|
369
|
+
let nsData = PlatformKt.frameFrom(
|
|
370
|
+
packet: frameData
|
|
371
|
+
)
|
|
372
|
+
let encodeString = nsData.base64EncodedString()
|
|
373
|
+
let dataUrl = "data:image/jpeg;base64," + encodeString
|
|
374
|
+
thetaClientReactNative.sendEvent(
|
|
375
|
+
withName: ThetaClientReactNative.EVENT_FRAME,
|
|
376
|
+
body: ["data": dataUrl]
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return thetaClientReactNative.previewing
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
guard let thetaRepository else {
|
|
386
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
387
|
+
return
|
|
388
|
+
}
|
|
389
|
+
let frameHandler = FrameHandler(self)
|
|
390
|
+
previewing = true
|
|
391
|
+
thetaRepository.getLivePreview(frameHandler: frameHandler) { error in
|
|
392
|
+
if let error {
|
|
393
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
394
|
+
} else {
|
|
395
|
+
resolve(true)
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@objc(stopLivePreview:withRejecter:)
|
|
401
|
+
func stopLivePreview(
|
|
402
|
+
resolve: RCTPromiseResolveBlock,
|
|
403
|
+
reject _: RCTPromiseRejectBlock
|
|
404
|
+
) {
|
|
405
|
+
previewing = false
|
|
406
|
+
resolve(nil)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@objc(getPhotoCaptureBuilder:withRejecter:)
|
|
410
|
+
func getPhotoCaptureBuilder(
|
|
411
|
+
resolve: RCTPromiseResolveBlock,
|
|
412
|
+
reject: RCTPromiseRejectBlock
|
|
413
|
+
) {
|
|
414
|
+
guard let thetaRepository else {
|
|
415
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
416
|
+
return
|
|
417
|
+
}
|
|
418
|
+
photoCaptureBuilder = thetaRepository.getPhotoCaptureBuilder()
|
|
419
|
+
resolve(nil)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@objc(buildPhotoCapture:withResolver:withRejecter:)
|
|
423
|
+
func buildPhotoCapture(
|
|
424
|
+
options: [AnyHashable: Any]?,
|
|
425
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
426
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
427
|
+
) {
|
|
428
|
+
guard let _ = thetaRepository else {
|
|
429
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
guard let photoCaptureBuilder else {
|
|
433
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_PHOTO_CAPTURE_BUILDER, nil)
|
|
434
|
+
return
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if let options = options as? [String: Any] {
|
|
438
|
+
setCaptureBuilderParams(params: options, builder: photoCaptureBuilder)
|
|
439
|
+
setPhotoCaptureBuilderParams(params: options, builder: photoCaptureBuilder)
|
|
440
|
+
}
|
|
441
|
+
photoCaptureBuilder.build { capture, error in
|
|
442
|
+
if let error {
|
|
443
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
444
|
+
} else if let capture {
|
|
445
|
+
self.photoCapture = capture
|
|
446
|
+
self.photoCaptureBuilder = nil
|
|
447
|
+
resolve(true)
|
|
448
|
+
} else {
|
|
449
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_PHOTO_CAPTURE, nil)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
@objc(takePicture:withRejecter:)
|
|
455
|
+
func takePicture(
|
|
456
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
457
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
458
|
+
) {
|
|
459
|
+
guard let _ = thetaRepository else {
|
|
460
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
461
|
+
return
|
|
462
|
+
}
|
|
463
|
+
guard let photoCapture else {
|
|
464
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_PHOTO_CAPTURE, nil)
|
|
465
|
+
return
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
class Callback: PhotoCaptureTakePictureCallback {
|
|
469
|
+
let callback: (_ url: String?, _ error: Error?) -> Void
|
|
470
|
+
init(_ callback: @escaping (_ url: String?, _ error: Error?) -> Void) {
|
|
471
|
+
self.callback = callback
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
func onSuccess(fileUrl: String) {
|
|
475
|
+
callback(fileUrl, nil)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
func onProgress(completion _: Float) {}
|
|
479
|
+
|
|
480
|
+
func onError(exception: ThetaRepository.ThetaRepositoryException) {
|
|
481
|
+
callback(nil, exception.asError())
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
photoCapture.takePicture(
|
|
486
|
+
callback: Callback { url, error in
|
|
487
|
+
if let error {
|
|
488
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
489
|
+
} else {
|
|
490
|
+
self.photoCapture = nil
|
|
491
|
+
resolve(url)
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@objc(getTimeShiftCaptureBuilder:withRejecter:)
|
|
497
|
+
func getTimeShiftCaptureBuilder(
|
|
498
|
+
resolve: RCTPromiseResolveBlock,
|
|
499
|
+
reject: RCTPromiseRejectBlock
|
|
500
|
+
) {
|
|
501
|
+
guard let thetaRepository else {
|
|
502
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
503
|
+
return
|
|
504
|
+
}
|
|
505
|
+
timeShiftCaptureBuilder = thetaRepository.getTimeShiftCaptureBuilder()
|
|
506
|
+
resolve(nil)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
@objc(buildTimeShiftCapture:withResolver:withRejecter:)
|
|
510
|
+
func buildTimeShiftCapture(
|
|
511
|
+
options: [AnyHashable: Any]?,
|
|
512
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
513
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
514
|
+
) {
|
|
515
|
+
guard let _ = thetaRepository else {
|
|
516
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
517
|
+
return
|
|
518
|
+
}
|
|
519
|
+
guard let timeShiftCaptureBuilder else {
|
|
520
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_TIMESHIFT_CAPTURE_BUILDER, nil)
|
|
521
|
+
return
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if let options = options as? [String: Any] {
|
|
525
|
+
setCaptureBuilderParams(params: options, builder: timeShiftCaptureBuilder)
|
|
526
|
+
setTimeShiftCaptureBuilderParams(params: options, builder: timeShiftCaptureBuilder)
|
|
527
|
+
}
|
|
528
|
+
timeShiftCaptureBuilder.build { capture, error in
|
|
529
|
+
if let error {
|
|
530
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
531
|
+
} else if let capture {
|
|
532
|
+
self.timeShiftCapture = capture
|
|
533
|
+
self.timeShiftCaptureBuilder = nil
|
|
534
|
+
resolve(true)
|
|
535
|
+
} else {
|
|
536
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_TIMESHIFT_CAPTURE, nil)
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
@objc(startTimeShiftCapture:withRejecter:)
|
|
542
|
+
func startTimeShiftCapture(
|
|
543
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
544
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
545
|
+
) {
|
|
546
|
+
guard let _ = thetaRepository else {
|
|
547
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
548
|
+
return
|
|
549
|
+
}
|
|
550
|
+
guard let timeShiftCapture else {
|
|
551
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_TIMESHIFT_CAPTURE, nil)
|
|
552
|
+
return
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
class Callback: TimeShiftCaptureStartCaptureCallback {
|
|
556
|
+
let callback: (_ url: String?, _ error: Error?) -> Void
|
|
557
|
+
weak var client: ThetaClientReactNative?
|
|
558
|
+
init(
|
|
559
|
+
_ callback: @escaping (_ url: String?, _ error: Error?) -> Void,
|
|
560
|
+
client: ThetaClientReactNative
|
|
561
|
+
) {
|
|
562
|
+
self.callback = callback
|
|
563
|
+
self.client = client
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
func onError(exception: ThetaRepository.ThetaRepositoryException) {
|
|
567
|
+
callback(nil, exception.asError())
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
func onProgress(completion: Float) {
|
|
571
|
+
client?.sendEvent(
|
|
572
|
+
withName: ThetaClientReactNative.EVENT_NOTIFY,
|
|
573
|
+
body: toNotify(
|
|
574
|
+
name: ThetaClientReactNative.NOTIFY_TIMESHIFT_PROGRESS,
|
|
575
|
+
params: toCaptureProgressNotifyParam(value: completion)
|
|
576
|
+
)
|
|
577
|
+
)
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
func onSuccess(fileUrl_ fileUrl: String?) {
|
|
581
|
+
callback(fileUrl, nil)
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
timeShiftCapturing = timeShiftCapture.startCapture(
|
|
586
|
+
callback: Callback(
|
|
587
|
+
{ url, error in
|
|
588
|
+
if let error {
|
|
589
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
590
|
+
} else {
|
|
591
|
+
resolve(url)
|
|
592
|
+
}
|
|
593
|
+
}, client: self
|
|
594
|
+
))
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
@objc(cancelTimeShiftCapture:withRejecter:)
|
|
598
|
+
func cancelTimeShiftCapture(
|
|
599
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
600
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
601
|
+
) {
|
|
602
|
+
guard let _ = thetaRepository else {
|
|
603
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
604
|
+
return
|
|
605
|
+
}
|
|
606
|
+
guard let timeShiftCapturing else {
|
|
607
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_TIMESHIFT_CAPTURING, nil)
|
|
608
|
+
return
|
|
609
|
+
}
|
|
610
|
+
timeShiftCapturing.cancelCapture()
|
|
611
|
+
resolve(nil)
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
@objc(getVideoCaptureBuilder:withRejecter:)
|
|
615
|
+
func getVideoCaptureBuilder(
|
|
616
|
+
resolve: RCTPromiseResolveBlock,
|
|
617
|
+
reject: RCTPromiseRejectBlock
|
|
618
|
+
) {
|
|
619
|
+
guard let thetaRepository else {
|
|
620
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
621
|
+
return
|
|
622
|
+
}
|
|
623
|
+
videoCaptureBuilder = thetaRepository.getVideoCaptureBuilder()
|
|
624
|
+
resolve(nil)
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
@objc(buildVideoCapture:withResolver:withRejecter:)
|
|
628
|
+
func buildVideoCapture(
|
|
629
|
+
options: [AnyHashable: Any]?,
|
|
630
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
631
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
632
|
+
) {
|
|
633
|
+
guard let _ = thetaRepository else {
|
|
634
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
635
|
+
return
|
|
636
|
+
}
|
|
637
|
+
guard let videoCaptureBuilder else {
|
|
638
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_VIDEO_CAPTURE_BUILDER, nil)
|
|
639
|
+
return
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if let options = options as? [String: Any] {
|
|
643
|
+
setCaptureBuilderParams(params: options, builder: videoCaptureBuilder)
|
|
644
|
+
setVideoCaptureBuilderParams(params: options, builder: videoCaptureBuilder)
|
|
645
|
+
}
|
|
646
|
+
videoCaptureBuilder.build { capture, error in
|
|
647
|
+
if let error {
|
|
648
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
649
|
+
} else if let capture {
|
|
650
|
+
self.videoCapture = capture
|
|
651
|
+
self.videoCaptureBuilder = nil
|
|
652
|
+
resolve(true)
|
|
653
|
+
} else {
|
|
654
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_VIDEO_CAPTURE, nil)
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
@objc(startVideoCapture:withRejecter:)
|
|
660
|
+
func startVideoCapture(
|
|
661
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
662
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
663
|
+
) {
|
|
664
|
+
guard let _ = thetaRepository else {
|
|
665
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
666
|
+
return
|
|
667
|
+
}
|
|
668
|
+
guard let videoCapture else {
|
|
669
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_VIDEO_CAPTURE, nil)
|
|
670
|
+
return
|
|
671
|
+
}
|
|
672
|
+
class Callback: VideoCaptureStartCaptureCallback {
|
|
673
|
+
let callback: (_ url: String?, _ error: Error?) -> Void
|
|
674
|
+
weak var client: ThetaClientReactNative?
|
|
675
|
+
init(
|
|
676
|
+
_ callback: @escaping (_ url: String?, _ error: Error?) -> Void,
|
|
677
|
+
client: ThetaClientReactNative
|
|
678
|
+
) {
|
|
679
|
+
self.callback = callback
|
|
680
|
+
self.client = client
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
func onCaptureCompleted(fileUrl: String?) {
|
|
684
|
+
callback(fileUrl, nil)
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
func onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
|
|
688
|
+
callback(nil, exception.asError())
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
func onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
|
|
692
|
+
let error = exception.asError()
|
|
693
|
+
client?.sendEvent(
|
|
694
|
+
withName: ThetaClientReactNative.EVENT_NOTIFY,
|
|
695
|
+
body: toNotify(
|
|
696
|
+
name: ThetaClientReactNative.NOTIFY_VIDEO_CAPTURE_STOP_ERROR,
|
|
697
|
+
params: toMessageNotifyParam(value: error.localizedDescription)
|
|
698
|
+
)
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
videoCapturing = videoCapture.startCapture(
|
|
704
|
+
callback: Callback(
|
|
705
|
+
{ url, error in
|
|
706
|
+
if let error {
|
|
707
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
708
|
+
} else {
|
|
709
|
+
self.videoCapture = nil
|
|
710
|
+
resolve(url)
|
|
711
|
+
}
|
|
712
|
+
}, client: self
|
|
713
|
+
))
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
@objc(stopVideoCapture:withRejecter:)
|
|
717
|
+
func stopVideoCapture(
|
|
718
|
+
resolve: RCTPromiseResolveBlock,
|
|
719
|
+
reject: RCTPromiseRejectBlock
|
|
720
|
+
) {
|
|
721
|
+
guard let _ = thetaRepository else {
|
|
722
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
723
|
+
return
|
|
724
|
+
}
|
|
725
|
+
guard let videoCapturing else {
|
|
726
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_VIDEO_CAPTURING, nil)
|
|
727
|
+
return
|
|
728
|
+
}
|
|
729
|
+
videoCapturing.stopCapture()
|
|
730
|
+
resolve(nil)
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
@objc(getMetadata:withResolver:withRejecter:)
|
|
734
|
+
func getMetadata(
|
|
735
|
+
fileUrl: String,
|
|
736
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
737
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
738
|
+
) {
|
|
739
|
+
guard let thetaRepository else {
|
|
740
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
741
|
+
return
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
thetaRepository.getMetadata(
|
|
745
|
+
fileUrl: fileUrl
|
|
746
|
+
) { response, error in
|
|
747
|
+
if let error {
|
|
748
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
749
|
+
} else if let response {
|
|
750
|
+
resolve(convertResult(metadata: response))
|
|
751
|
+
} else {
|
|
752
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
@objc(reset:withRejecter:)
|
|
758
|
+
func reset(
|
|
759
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
760
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
761
|
+
) {
|
|
762
|
+
guard let thetaRepository else {
|
|
763
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
764
|
+
return
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
thetaRepository.reset { error in
|
|
768
|
+
if let error {
|
|
769
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
770
|
+
} else {
|
|
771
|
+
resolve(true)
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
@objc(restoreSettings:withRejecter:)
|
|
777
|
+
func restoreSettings(
|
|
778
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
779
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
780
|
+
) {
|
|
781
|
+
guard let thetaRepository else {
|
|
782
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
783
|
+
return
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
thetaRepository.restoreSettings { error in
|
|
787
|
+
if let error {
|
|
788
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
789
|
+
} else {
|
|
790
|
+
resolve(true)
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
@objc(stopSelfTimer:withRejecter:)
|
|
796
|
+
func stopSelfTimer(
|
|
797
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
798
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
799
|
+
) {
|
|
800
|
+
guard let thetaRepository else {
|
|
801
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
802
|
+
return
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
thetaRepository.stopSelfTimer { error in
|
|
806
|
+
if let error {
|
|
807
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
808
|
+
} else {
|
|
809
|
+
resolve(true)
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
@objc(
|
|
815
|
+
convertVideoFormats:withToLowResolution:withApplyTopBottomCorrection:withResolver:
|
|
816
|
+
withRejecter:
|
|
817
|
+
)
|
|
818
|
+
func convertVideoFormats(
|
|
819
|
+
fileUrl: String,
|
|
820
|
+
toLowResolution: Bool,
|
|
821
|
+
applyTopBottomCorrection: Bool,
|
|
822
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
823
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
824
|
+
) {
|
|
825
|
+
guard let thetaRepository else {
|
|
826
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
827
|
+
return
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
thetaRepository.convertVideoFormats(
|
|
831
|
+
fileUrl: fileUrl,
|
|
832
|
+
toLowResolution: toLowResolution,
|
|
833
|
+
applyTopBottomCorrection: applyTopBottomCorrection
|
|
834
|
+
) { fileUrl, error in
|
|
835
|
+
if let error {
|
|
836
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
837
|
+
} else if let fileUrl {
|
|
838
|
+
resolve(fileUrl)
|
|
839
|
+
} else {
|
|
840
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
@objc(cancelVideoConvert:withRejecter:)
|
|
846
|
+
func cancelVideoConvert(
|
|
847
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
848
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
849
|
+
) {
|
|
850
|
+
guard let thetaRepository else {
|
|
851
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
852
|
+
return
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
thetaRepository.cancelVideoConvert { error in
|
|
856
|
+
if let error {
|
|
857
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
858
|
+
} else {
|
|
859
|
+
resolve(true)
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
@objc(finishWlan:withRejecter:)
|
|
865
|
+
func finishWlan(
|
|
866
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
867
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
868
|
+
) {
|
|
869
|
+
guard let thetaRepository else {
|
|
870
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
871
|
+
return
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
thetaRepository.finishWlan { error in
|
|
875
|
+
if let error {
|
|
876
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
877
|
+
} else {
|
|
878
|
+
resolve(true)
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
@objc(listAccessPoints:withRejecter:)
|
|
884
|
+
func listAccessPoints(
|
|
885
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
886
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
887
|
+
) {
|
|
888
|
+
guard let thetaRepository else {
|
|
889
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
890
|
+
return
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
thetaRepository.listAccessPoints { response, error in
|
|
894
|
+
if let error {
|
|
895
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
896
|
+
} else if let response {
|
|
897
|
+
var list = convertResult(accessPointList: response)
|
|
898
|
+
resolve(list)
|
|
899
|
+
} else {
|
|
900
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
@objc(
|
|
906
|
+
setAccessPointDynamically:
|
|
907
|
+
withSsidStealth:
|
|
908
|
+
withAuthMode:
|
|
909
|
+
withPassword:
|
|
910
|
+
withConnectionPriority:
|
|
911
|
+
withProxy:
|
|
912
|
+
withResolver:
|
|
913
|
+
withRejecter:
|
|
914
|
+
)
|
|
915
|
+
func setAccessPointDynamically(
|
|
916
|
+
ssid: String,
|
|
917
|
+
ssidStealth: Bool,
|
|
918
|
+
authMode: String,
|
|
919
|
+
password: String,
|
|
920
|
+
connectionPriority: Int,
|
|
921
|
+
proxy: [AnyHashable: Any]?,
|
|
922
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
923
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
924
|
+
) {
|
|
925
|
+
guard let thetaRepository else {
|
|
926
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
927
|
+
return
|
|
928
|
+
}
|
|
929
|
+
guard
|
|
930
|
+
let authMode = getEnumValue(
|
|
931
|
+
values: ThetaRepository.AuthModeEnum.values(), name: authMode
|
|
932
|
+
)
|
|
933
|
+
else {
|
|
934
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
935
|
+
return
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
let proxyParam: ThetaRepository.Proxy? = {
|
|
939
|
+
if let proxy = proxy as? [String: Any] {
|
|
940
|
+
return toProxy(params: proxy)
|
|
941
|
+
}
|
|
942
|
+
return nil
|
|
943
|
+
}()
|
|
944
|
+
thetaRepository.setAccessPointDynamically(
|
|
945
|
+
ssid: ssid,
|
|
946
|
+
ssidStealth: ssidStealth,
|
|
947
|
+
authMode: authMode,
|
|
948
|
+
password: password,
|
|
949
|
+
connectionPriority: Int32(connectionPriority),
|
|
950
|
+
proxy: proxyParam
|
|
951
|
+
) { error in
|
|
952
|
+
if let error {
|
|
953
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
954
|
+
} else {
|
|
955
|
+
resolve(true)
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
@objc(
|
|
961
|
+
setAccessPointStatically:
|
|
962
|
+
withSsidStealth:
|
|
963
|
+
withAuthMode:
|
|
964
|
+
withPassword:
|
|
965
|
+
withConnectionPriority:
|
|
966
|
+
withIpAddress:
|
|
967
|
+
withSubnetMask:
|
|
968
|
+
withDefaultGateway:
|
|
969
|
+
withProxy:
|
|
970
|
+
withResolver:
|
|
971
|
+
withRejecter:
|
|
972
|
+
)
|
|
973
|
+
func setAccessPointStatically(
|
|
974
|
+
ssid: String,
|
|
975
|
+
ssidStealth: Bool,
|
|
976
|
+
authMode: String,
|
|
977
|
+
password: String?,
|
|
978
|
+
connectionPriority: Int,
|
|
979
|
+
ipAddress: String,
|
|
980
|
+
subnetMask: String,
|
|
981
|
+
defaultGateway: String,
|
|
982
|
+
proxy: [AnyHashable: Any]?,
|
|
983
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
984
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
985
|
+
) {
|
|
986
|
+
guard let thetaRepository else {
|
|
987
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
988
|
+
return
|
|
989
|
+
}
|
|
990
|
+
guard
|
|
991
|
+
let authMode = getEnumValue(
|
|
992
|
+
values: ThetaRepository.AuthModeEnum.values(), name: authMode
|
|
993
|
+
)
|
|
994
|
+
else {
|
|
995
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
996
|
+
return
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
let proxyParam: ThetaRepository.Proxy? = {
|
|
1000
|
+
if let proxy = proxy as? [String: Any] {
|
|
1001
|
+
return toProxy(params: proxy)
|
|
1002
|
+
}
|
|
1003
|
+
return nil
|
|
1004
|
+
}()
|
|
1005
|
+
thetaRepository.setAccessPointStatically(
|
|
1006
|
+
ssid: ssid,
|
|
1007
|
+
ssidStealth: ssidStealth,
|
|
1008
|
+
authMode: authMode,
|
|
1009
|
+
password: password,
|
|
1010
|
+
connectionPriority: Int32(connectionPriority),
|
|
1011
|
+
ipAddress: ipAddress,
|
|
1012
|
+
subnetMask: subnetMask,
|
|
1013
|
+
defaultGateway: defaultGateway,
|
|
1014
|
+
proxy: proxyParam
|
|
1015
|
+
) { error in
|
|
1016
|
+
if let error {
|
|
1017
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1018
|
+
} else {
|
|
1019
|
+
resolve(true)
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
@objc(deleteAccessPoint:withResolver:withRejecter:)
|
|
1025
|
+
func deleteAccessPoint(
|
|
1026
|
+
ssid: String,
|
|
1027
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1028
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1029
|
+
) {
|
|
1030
|
+
guard let thetaRepository else {
|
|
1031
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1032
|
+
return
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
thetaRepository.deleteAccessPoint(
|
|
1036
|
+
ssid: ssid
|
|
1037
|
+
) { error in
|
|
1038
|
+
if let error {
|
|
1039
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1040
|
+
} else {
|
|
1041
|
+
resolve(true)
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
@objc(getMySetting:withResolver:withRejecter:)
|
|
1047
|
+
func getMySetting(
|
|
1048
|
+
captureMode: String,
|
|
1049
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1050
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1051
|
+
) {
|
|
1052
|
+
guard let thetaRepository else {
|
|
1053
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1054
|
+
return
|
|
1055
|
+
}
|
|
1056
|
+
guard
|
|
1057
|
+
let captureMode = getEnumValue(
|
|
1058
|
+
values: ThetaRepository.CaptureModeEnum.values(), name: captureMode
|
|
1059
|
+
)
|
|
1060
|
+
else {
|
|
1061
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
1062
|
+
return
|
|
1063
|
+
}
|
|
1064
|
+
thetaRepository.getMySetting(
|
|
1065
|
+
captureMode: captureMode
|
|
1066
|
+
) { response, error in
|
|
1067
|
+
if let error {
|
|
1068
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1069
|
+
} else if let response {
|
|
1070
|
+
resolve(convertResult(options: response))
|
|
1071
|
+
} else {
|
|
1072
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
@objc(getMySettingFromOldModel:withResolver:withRejecter:)
|
|
1078
|
+
func getMySettingFromOldModel(
|
|
1079
|
+
optionNames: [Any],
|
|
1080
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1081
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1082
|
+
) {
|
|
1083
|
+
guard let thetaRepository else {
|
|
1084
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1085
|
+
return
|
|
1086
|
+
}
|
|
1087
|
+
guard let optionNames = optionNames as? [String] else {
|
|
1088
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
1089
|
+
return
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
let params = convertGetOptionsParam(params: optionNames)
|
|
1093
|
+
thetaRepository.getMySetting(
|
|
1094
|
+
optionNames: params
|
|
1095
|
+
) { response, error in
|
|
1096
|
+
if let error {
|
|
1097
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1098
|
+
} else if let response {
|
|
1099
|
+
resolve(convertResult(options: response))
|
|
1100
|
+
} else {
|
|
1101
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
@objc(setMySetting:withOptions:withResolver:withRejecter:)
|
|
1107
|
+
func setMySetting(
|
|
1108
|
+
captureMode: String,
|
|
1109
|
+
options: [AnyHashable: Any],
|
|
1110
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1111
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1112
|
+
) {
|
|
1113
|
+
guard let thetaRepository else {
|
|
1114
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1115
|
+
return
|
|
1116
|
+
}
|
|
1117
|
+
guard let options = options as? [String: Any],
|
|
1118
|
+
let captureMode = getEnumValue(
|
|
1119
|
+
values: ThetaRepository.CaptureModeEnum.values(), name: captureMode
|
|
1120
|
+
)
|
|
1121
|
+
else {
|
|
1122
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
1123
|
+
return
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
let params = convertSetOptionsParam(params: options)
|
|
1127
|
+
thetaRepository.setMySetting(
|
|
1128
|
+
captureMode: captureMode,
|
|
1129
|
+
options: params
|
|
1130
|
+
) { error in
|
|
1131
|
+
if let error {
|
|
1132
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1133
|
+
} else {
|
|
1134
|
+
resolve(true)
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
@objc(deleteMySetting:withResolver:withRejecter:)
|
|
1140
|
+
func deleteMySetting(
|
|
1141
|
+
captureMode: String,
|
|
1142
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1143
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1144
|
+
) {
|
|
1145
|
+
guard let thetaRepository else {
|
|
1146
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1147
|
+
return
|
|
1148
|
+
}
|
|
1149
|
+
guard
|
|
1150
|
+
let captureMode = getEnumValue(
|
|
1151
|
+
values: ThetaRepository.CaptureModeEnum.values(), name: captureMode
|
|
1152
|
+
)
|
|
1153
|
+
else {
|
|
1154
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
1155
|
+
return
|
|
1156
|
+
}
|
|
1157
|
+
thetaRepository.deleteMySetting(
|
|
1158
|
+
captureMode: captureMode
|
|
1159
|
+
) { error in
|
|
1160
|
+
if let error {
|
|
1161
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1162
|
+
} else {
|
|
1163
|
+
resolve(true)
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
@objc(listPlugins:withRejecter:)
|
|
1169
|
+
func listPlugins(
|
|
1170
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1171
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1172
|
+
) {
|
|
1173
|
+
guard let thetaRepository else {
|
|
1174
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1175
|
+
return
|
|
1176
|
+
}
|
|
1177
|
+
thetaRepository.listPlugins { pluginList, error in
|
|
1178
|
+
if let error {
|
|
1179
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1180
|
+
} else if let pluginList {
|
|
1181
|
+
resolve(toPluginInfosResult(pluginInfoList: pluginList))
|
|
1182
|
+
} else {
|
|
1183
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
@objc(setPlugin:withResolver:withRejecter:)
|
|
1189
|
+
func setPlugin(
|
|
1190
|
+
packageName: String,
|
|
1191
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1192
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1193
|
+
) {
|
|
1194
|
+
guard let thetaRepository else {
|
|
1195
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1196
|
+
return
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
thetaRepository.setPlugin(packageName: packageName) { error in
|
|
1200
|
+
if let error {
|
|
1201
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1202
|
+
} else {
|
|
1203
|
+
resolve(true)
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
@objc(startPlugin:withResolver:withRejecter:)
|
|
1209
|
+
func startPlugin(
|
|
1210
|
+
packageName: String,
|
|
1211
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1212
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1213
|
+
) {
|
|
1214
|
+
guard let thetaRepository else {
|
|
1215
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1216
|
+
return
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
thetaRepository.startPlugin(packageName: packageName) { error in
|
|
1220
|
+
if let error {
|
|
1221
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1222
|
+
} else {
|
|
1223
|
+
resolve(true)
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
@objc(stopPlugin:withRejecter:)
|
|
1229
|
+
func stopPlugin(
|
|
1230
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1231
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1232
|
+
) {
|
|
1233
|
+
guard let thetaRepository else {
|
|
1234
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1235
|
+
return
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
thetaRepository.stopPlugin { error in
|
|
1239
|
+
if let error {
|
|
1240
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1241
|
+
} else {
|
|
1242
|
+
resolve(true)
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
@objc(getPluginLicense:withResolver:withRejecter:)
|
|
1248
|
+
func getPluginLicense(
|
|
1249
|
+
packageName: String,
|
|
1250
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1251
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1252
|
+
) {
|
|
1253
|
+
guard let thetaRepository else {
|
|
1254
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1255
|
+
return
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
thetaRepository.getPluginLicense(
|
|
1259
|
+
packageName: packageName
|
|
1260
|
+
) { response, error in
|
|
1261
|
+
if let error {
|
|
1262
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1263
|
+
} else if let response {
|
|
1264
|
+
resolve(response)
|
|
1265
|
+
} else {
|
|
1266
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
@objc(getPluginOrders:withRejecter:)
|
|
1272
|
+
func getPluginOrders(
|
|
1273
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1274
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1275
|
+
) {
|
|
1276
|
+
guard let thetaRepository else {
|
|
1277
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1278
|
+
return
|
|
1279
|
+
}
|
|
1280
|
+
thetaRepository.getPluginOrders { plugins, error in
|
|
1281
|
+
if let error {
|
|
1282
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1283
|
+
} else if let plugins {
|
|
1284
|
+
resolve(plugins)
|
|
1285
|
+
} else {
|
|
1286
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
@objc(setPluginOrders:withResolver:withRejecter:)
|
|
1292
|
+
func setPluginOrders(
|
|
1293
|
+
plugins: [Any],
|
|
1294
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1295
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1296
|
+
) {
|
|
1297
|
+
guard let thetaRepository else {
|
|
1298
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1299
|
+
return
|
|
1300
|
+
}
|
|
1301
|
+
guard let plugins = plugins as? [String] else {
|
|
1302
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_ARGUMENT, nil)
|
|
1303
|
+
return
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
thetaRepository.setPluginOrders(
|
|
1307
|
+
plugins: plugins
|
|
1308
|
+
) { error in
|
|
1309
|
+
if let error {
|
|
1310
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1311
|
+
} else {
|
|
1312
|
+
resolve(true)
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
@objc(setBluetoothDevice:withResolver:withRejecter:)
|
|
1318
|
+
func setBluetoothDevice(
|
|
1319
|
+
uuid: String,
|
|
1320
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
1321
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
1322
|
+
) {
|
|
1323
|
+
guard let thetaRepository else {
|
|
1324
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NOT_INIT, nil)
|
|
1325
|
+
return
|
|
1326
|
+
}
|
|
1327
|
+
thetaRepository.setBluetoothDevice(uuid: uuid) { deviceName, error in
|
|
1328
|
+
if let error {
|
|
1329
|
+
reject(ERROR_CODE_ERROR, error.localizedDescription, error)
|
|
1330
|
+
} else if let deviceName {
|
|
1331
|
+
resolve(deviceName)
|
|
1332
|
+
} else {
|
|
1333
|
+
reject(ERROR_CODE_ERROR, MESSAGE_NO_RESULT, nil)
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|