Skip to content

Commit 14eb997

Browse files
committed
Add version 3.0.0
1 parent 9ea589b commit 14eb997

File tree

8 files changed

+61
-62
lines changed

8 files changed

+61
-62
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [3.0.0]
2+
3+
### Changed
4+
5+
* Changed and aligned the error codes for the modules.
6+
* [react-native-videoeditorsdk] Unlocking the SDK via `VESDK.unlockWithLicense` now returns a `Promise<void>`.
7+
* [react-native-photoeditorsdk] Unlocking the SDK via `PESDK.unlockWithLicense` now returns a `Promise<void>`.
8+
9+
### Fixed
10+
11+
* [react-native-videoeditorsdk] Fixed unused types exports.
12+
113
## [2.17.1]
214

315
### Fixed

android/src/main/java/ly/img/react_native/vesdk/RNVideoEditorSDKModule.kt

+18-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.net.Uri
66
import android.util.Log
77
import androidx.annotation.WorkerThread
88
import com.facebook.react.bridge.*
9+
import ly.img.android.AuthorizationException
910
import ly.img.android.IMGLY
1011
import ly.img.android.VESDK
1112
import ly.img.android.pesdk.VideoEditorSettingsList
@@ -48,16 +49,28 @@ class RNVideoEditorSDKModule(reactContext: ReactApplicationContext) : ReactConte
4849
reactContext.addActivityEventListener(this)
4950
}
5051

52+
/** IMGLY constants for the plugin use. */
53+
object IMGLYConstants {
54+
const val K_ERROR_UNABLE_TO_UNLOCK = "E_UNABLE_TO_UNLOCK"
55+
const val K_ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD"
56+
}
57+
5158
private var currentPromise: Promise? = null
5259
private var currentConfig: Configuration? = null
5360
private var resolveManually: Boolean = false
5461
private var currentEditorUID: String = UUID.randomUUID().toString()
5562
private var settingsLists: MutableMap<String, SettingsList> = mutableMapOf()
5663

5764
@ReactMethod
58-
fun unlockWithLicense(license: String) {
59-
VESDK.initSDKWithLicenseData(license)
60-
IMGLY.authorize()
65+
fun unlockWithLicense(license: String, promise: Promise) {
66+
try {
67+
VESDK.initSDKWithLicenseData(license)
68+
IMGLY.authorize()
69+
promise.resolve(null)
70+
} catch (e: AuthorizationException) {
71+
promise.reject(IMGLYConstants.K_ERROR_UNABLE_TO_UNLOCK, "Unlocking the SDK failed due to: ${e.message}.")
72+
}
73+
6174
}
6275

6376
@ReactMethod
@@ -212,7 +225,7 @@ class RNVideoEditorSDKModule(reactContext: ReactApplicationContext) : ReactConte
212225
if (videoArray.isNotEmpty()) {
213226
if (source == null) {
214227
if (size != null) {
215-
promise.reject("VESDK", "Invalid video size: width and height must be greater than zero.")
228+
promise.reject(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "Invalid video size: width and height must be greater than zero.")
216229
return
217230
}
218231
val video = videoArray.first()
@@ -226,7 +239,7 @@ class RNVideoEditorSDKModule(reactContext: ReactApplicationContext) : ReactConte
226239
}
227240
} else {
228241
if (source == null) {
229-
promise.reject("VESDK", "The editor requires a valid size when initialized without a video.")
242+
promise.reject(IMGLYConstants.K_ERROR_UNABLE_TO_LOAD, "The editor requires a valid size when initialized without a video.")
230243
return
231244
}
232245
}

index.d.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ declare class VESDK {
8484
videoSize?: Size
8585
): Promise<VideoEditorResult | null>;
8686

87-
/**
88-
* Releases the result from the editor and deletes the temporary files.
89-
* @note This function needs to be called in case `configuration.export.video.segments`
90-
* is set to `true`.
91-
*
92-
* @param {string} identifier The identifier of the `VideoEditorResult` to release
93-
* the temporary data of.
94-
*/
95-
static releaseTemporaryData(identifier: string): void;
96-
9787
/**
9888
* Unlock VideoEditor SDK with a license.
9989
*
@@ -104,7 +94,7 @@ declare class VESDK {
10494
* and `vesdk_license.android.json` for the Android license file in order to get automatically
10595
* resolved by the packager.
10696
*/
107-
static unlockWithLicense(license: string | object): void;
97+
static unlockWithLicense(license: string | object): Promise<void>;
10898
}
10999

110100
/**

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ class VESDK {
204204
*/
205205
static unlockWithLicense(license) {
206206
if (Platform.OS == 'android') {
207-
RNVideoEditorSDK.unlockWithLicense(JSON.stringify(license));
207+
return RNVideoEditorSDK.unlockWithLicense(JSON.stringify(license));
208208
} else {
209-
RNVideoEditorSDK.unlockWithLicense(license);
209+
return RNVideoEditorSDK.unlockWithLicense(license);
210210
}
211211
}
212212
}

ios/RNImglyKit.m

+13-28
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ - (void)present:(nonnull IMGLYMediaEditViewControllerBlock)createMediaEditViewCo
6363
}
6464

6565
dispatch_async(dispatch_get_main_queue(), ^{
66-
if (self.licenseError != nil) {
67-
reject(RN_IMGLY.kErrorUnableToUnlock, [NSString RN_IMGLY_string:@"Unable to unlock with license." withError:self.licenseError], self.licenseError);
68-
return;
69-
}
70-
7166
PESDKAssetCatalog *assetCatalog = PESDKAssetCatalog.defaultItems;
7267
PESDKConfiguration *configuration = [[PESDKConfiguration alloc] initWithBuilder:^(PESDKConfigurationBuilder * _Nonnull builder) {
7368
builder.assetCatalog = assetCatalog;
@@ -169,34 +164,24 @@ - (void)dismiss:(nullable PESDKMediaEditViewController *)mediaEditViewController
169164
});
170165
}
171166

172-
- (void)handleLicenseError:(nullable NSError *)error
167+
- (void)handleLicenseError:(nullable NSError *)error resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject
173168
{
174-
self.licenseError = nil;
175169
if (error != nil) {
176-
if ([error.domain isEqualToString:@"ImglyKit.IMGLY.Error"]) {
177-
switch (error.code) {
178-
case 3:
179-
RCTLogWarn(@"%@: %@", NSStringFromClass(self.class), error.localizedDescription);
180-
break;
181-
default:
182-
self.licenseError = error;
183-
RCTLogError(@"%@: %@", NSStringFromClass(self.class), error.localizedDescription);
184-
break;
185-
}
186-
} else {
187-
self.licenseError = error;
188-
RCTLogError(@"Error while unlocking with license: %@", error);
189-
}
170+
reject(RN_IMGLY.kErrorUnableToUnlock, [NSString RN_IMGLY_string:@"Unable to unlock with license." withError:error], error);
171+
return;
172+
} else {
173+
resolve(nil);
174+
return;
190175
}
191176
}
192177

193-
- (void)unlockWithLicenseURL:(nonnull NSURL *)url {}
178+
- (void)unlockWithLicenseURL:(nonnull NSURL *)url resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {}
194179

195-
- (void)unlockWithLicenseString:(nonnull NSString *)string {}
180+
- (void)unlockWithLicenseString:(nonnull NSString *)string resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {}
196181

197-
- (void)unlockWithLicenseObject:(nonnull NSDictionary *)dictionary {}
182+
- (void)unlockWithLicenseObject:(nonnull NSDictionary *)dictionary resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {}
198183

199-
- (void)unlockWithLicense:(nonnull id)json
184+
- (void)unlockWithLicense:(nonnull id)json resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject
200185
{
201186
NSString *string = nil;
202187
NSURL *url = nil;
@@ -222,14 +207,14 @@ - (void)unlockWithLicense:(nonnull id)json
222207
}
223208

224209
if (url != nil) {
225-
[self unlockWithLicenseURL:url];
210+
[self unlockWithLicenseURL:url resolve:resolve reject:reject];
226211
}
227212
else if (string != nil) {
228-
[self unlockWithLicenseString:string];
213+
[self unlockWithLicenseString:string resolve:resolve reject:reject];
229214
}
230215
else if ([json isKindOfClass:[NSDictionary class]]) {
231216
NSDictionary *dictionary = json;
232-
[self unlockWithLicenseObject:dictionary];
217+
[self unlockWithLicenseObject:dictionary resolve:resolve reject:reject];
233218
}
234219
else if (json) {
235220
RCTLogConvertError(json, @"a valid license format");

ios/RNImglyKitSubclass.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ typedef void (^IMGLYCompletionBlock)(void);
5050

5151
@property (class, strong, atomic, nullable) IMGLYConfigurationBlock configureWithBuilder;
5252

53-
@property (strong, atomic, nullable) NSError* licenseError;
5453
@property (strong, atomic, nullable) NSString* exportType;
5554
@property (strong, atomic, nullable) NSURL* exportFile;
5655
@property (atomic) BOOL serializationEnabled;
@@ -68,11 +67,11 @@ typedef void (^IMGLYCompletionBlock)(void);
6867
resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
6968

7069
- (void)dismiss:(nullable PESDKMediaEditViewController *)mediaEditViewController animated:(BOOL)animated completion:(nullable IMGLYCompletionBlock)completion;
71-
- (void)handleLicenseError:(nullable NSError *)error;
72-
- (void)unlockWithLicenseURL:(nonnull NSURL *)url;
73-
- (void)unlockWithLicenseString:(nonnull NSString *)string;
74-
- (void)unlockWithLicenseObject:(nonnull NSDictionary *)dictionary;
75-
- (void)unlockWithLicense:(nonnull id)json;
70+
- (void)handleLicenseError:(nullable NSError *)error resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
71+
- (void)unlockWithLicenseURL:(nonnull NSURL *)url resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
72+
- (void)unlockWithLicenseString:(nonnull NSString *)string resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
73+
- (void)unlockWithLicenseObject:(nonnull NSDictionary *)dictionary resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
74+
- (void)unlockWithLicense:(nonnull id)json resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject;
7675

7776
extern const struct RN_IMGLY_Constants
7877
{

ios/RNVideoEditorSDK.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -65,36 +65,36 @@ - (void)present:(nonnull PESDKVideo *)video withConfiguration:(nullable NSDictio
6565
} configuration:dictionary serialization:state resolve:resolve reject:reject];
6666
}
6767

68-
RCT_EXPORT_METHOD(unlockWithLicenseURL:(nonnull NSURL *)url)
68+
RCT_EXPORT_METHOD(unlockWithLicenseURL:(nonnull NSURL *)url resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject)
6969
{
7070
dispatch_async(dispatch_get_main_queue(), ^{
7171
NSError *error = nil;
7272
[VESDK unlockWithLicenseFromURL:url error:&error];
73-
[self handleLicenseError:error];
73+
[self handleLicenseError:error resolve:resolve reject:reject];
7474
});
7575
}
7676

77-
RCT_EXPORT_METHOD(unlockWithLicenseString:(nonnull NSString *)string)
77+
RCT_EXPORT_METHOD(unlockWithLicenseString:(nonnull NSString *)string resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject)
7878
{
7979
dispatch_async(dispatch_get_main_queue(), ^{
8080
NSError *error = nil;
8181
[VESDK unlockWithLicenseFromString:string error:&error];
82-
[self handleLicenseError:error];
82+
[self handleLicenseError:error resolve:resolve reject:reject];
8383
});
8484
}
8585

86-
RCT_EXPORT_METHOD(unlockWithLicenseObject:(nonnull NSDictionary *)dictionary)
86+
RCT_EXPORT_METHOD(unlockWithLicenseObject:(nonnull NSDictionary *)dictionary resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject)
8787
{
8888
dispatch_async(dispatch_get_main_queue(), ^{
8989
NSError *error = nil;
9090
[VESDK unlockWithLicenseFromDictionary:dictionary error:&error];
91-
[self handleLicenseError:error];
91+
[self handleLicenseError:error resolve:resolve reject:reject];
9292
});
9393
}
9494

95-
RCT_EXPORT_METHOD(unlockWithLicense:(nonnull id)json)
95+
RCT_EXPORT_METHOD(unlockWithLicense:(nonnull id)json resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject)
9696
{
97-
[super unlockWithLicense:json];
97+
[super unlockWithLicense:json resolve:resolve reject:reject];
9898
}
9999

100100
RCT_EXPORT_METHOD(present:(nonnull NSURLRequest *)request

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-videoeditorsdk",
33
"title": "React Native module for VideoEditor SDK",
4-
"version": "2.17.1",
4+
"version": "3.0.0",
55
"description": "A React Native module for VideoEditor SDK. Integrate the video editor into your own HTML5, iOS or Android app - in minutes!",
66
"main": "index.js",
77
"typings": "index.d.ts",
@@ -35,6 +35,6 @@
3535
"react-native": ">=0.60.0 <1.0.x"
3636
},
3737
"dependencies": {
38-
"react-native-imglysdk": "2.17.1"
38+
"react-native-imglysdk": "3.0.0"
3939
}
4040
}

0 commit comments

Comments
 (0)