Add Resource Loader for iOS

This commit is contained in:
pengfei.zhou
2021-10-25 16:01:44 +08:00
committed by osborn
parent 4bd4f42f52
commit 235549eea4
40 changed files with 979 additions and 242 deletions

View File

@@ -23,6 +23,7 @@
#import <Foundation/Foundation.h>
#import "DoricMonitorProtocol.h"
#import <UIKit/UIKit.h>
#import "DoricResourceLoaderManager.h"
NS_ASSUME_NONNULL_BEGIN
@class DoricLibrary;
@@ -33,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, strong) UIImage *defaultPlaceHolderImage;
@property(nonatomic, strong) UIImage *defaultErrorImage;
@property(nonatomic, strong) id <DoricPerformanceGlobalAnchorHookProtocol> globalPerformanceAnchorHook;
@property(nonatomic, strong) DoricResourceLoaderManager *loaderManager;
- (instancetype)initWithJSEngine:(DoricJSEngine *)jsEngine;

View File

@@ -56,6 +56,10 @@
#import "DoricJSEngine.h"
#import "DoricSingleton.h"
#import "DoricGestureContainerNode.h"
#import "DoricBundleResourceLoader.h"
#import "DoricBase64ResourceLoader.h"
#import "DoricLocalResourceLoader.h"
#import "DoricRemoteResourceLoader.h"
@interface DoricRegistry ()
@@ -83,6 +87,7 @@ - (instancetype)initWithJSEngine:(DoricJSEngine *)jsEngine {
_plugins = [NSMutableDictionary new];
_nodes = [NSMutableDictionary new];
_monitors = [NSMutableSet new];
_loaderManager = [DoricResourceLoaderManager new];
[self innerRegister];
[DoricSingleton.instance.libraries enumerateObjectsUsingBlock:^(DoricLibrary *obj, BOOL *stop) {
[obj load:self];
@@ -127,6 +132,13 @@ - (void)innerRegister {
[self registerViewNode:DoricSwitchNode.class withName:@"Switch"];
[self registerViewNode:DoricFlexNode.class withName:@"FlexLayout"];
[self registerViewNode:DoricGestureContainerNode.class withName:@"GestureContainer"];
[self.loaderManager registerLoader:[[DoricBundleResourceLoader alloc]
initWithResourceType:@"mainBundle"
bundle:[NSBundle mainBundle]]];
[self.loaderManager registerLoader:[DoricLocalResourceLoader new]];
[self.loaderManager registerLoader:[DoricRemoteResourceLoader new]];
[self.loaderManager registerLoader:[DoricBase64ResourceLoader new]];
}
- (void)registerJSBundle:(NSString *)bundle withName:(NSString *)name {

View File

@@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResource.h"
@interface DoricBase64Resource : DoricResource
@end

View File

@@ -0,0 +1,35 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricBase64Resource.h"
@implementation DoricBase64Resource
- (DoricAsyncResult <NSData *> *)fetchRaw {
DoricAsyncResult *result = [DoricAsyncResult new];
NSString *inString = nil;
if ([self.identifier hasPrefix:@"data:image"]) {
inString = [self.identifier componentsSeparatedByString:@","].lastObject;
}
NSData *data = [[NSData alloc] initWithBase64EncodedString:inString
options:NSDataBase64DecodingIgnoreUnknownCharacters];
[result setupResult:data];
return result;
}
@end

View File

@@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResourceLoader.h"
@interface DoricBase64ResourceLoader : NSObject <DoricResourceLoader>
@end

View File

@@ -0,0 +1,31 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricBase64ResourceLoader.h"
#import "DoricBase64Resource.h"
@implementation DoricBase64ResourceLoader
- (NSString *)resourceType {
return @"base64";
}
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
return [[DoricBase64Resource alloc] initWithContext:context identifier:identifier];
}
@end

View File

@@ -0,0 +1,26 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResource.h"
#import "DoricContext.h"
@interface DoricBundleResource : DoricResource
@property(nonatomic, strong) NSBundle *bundle;
@end

View File

@@ -0,0 +1,31 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricBundleResource.h"
@implementation DoricBundleResource
- (DoricAsyncResult <NSData *> *)fetchRaw {
DoricAsyncResult *result = [DoricAsyncResult new];
NSString *path = [self.bundle bundlePath];
NSString *fullPath = [path stringByAppendingPathComponent:self.identifier];
NSData *imgData = [[NSData alloc] initWithContentsOfFile:fullPath];
[result setupResult:imgData];
return result;
}
@end

View File

@@ -0,0 +1,26 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResourceLoader.h"
@interface DoricBundleResourceLoader : NSObject <DoricResourceLoader>
- (instancetype)initWithResourceType:(NSString *)resourceType bundle:(NSBundle *)bundle;
@end

View File

@@ -0,0 +1,45 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <DoricExtensions.h>
#import "DoricBundleResourceLoader.h"
#import "DoricBundleResource.h"
@interface DoricBundleResourceLoader ()
@property(nonatomic, strong) NSBundle *bundle;
@property(nonatomic, copy) NSString *resourceType;
@end
@implementation DoricBundleResourceLoader
- (instancetype)initWithResourceType:(NSString *)resourceType bundle:(NSBundle *)bundle {
if (self = [super init]) {
_resourceType = resourceType;
_bundle = bundle;
}
return self;
}
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
return [[[DoricBundleResource alloc] initWithContext:context identifier:identifier]
also:^(DoricBundleResource *it) {
it.bundle = self.bundle;
}];
}
@end

View File

@@ -0,0 +1,24 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResource.h"
@interface DoricLocalResource : DoricResource
@end

View File

@@ -0,0 +1,30 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricLocalResource.h"
@implementation DoricLocalResource
- (DoricAsyncResult <NSData *> *)fetchRaw {
DoricAsyncResult *result = [DoricAsyncResult new];
NSData *imgData = [[NSData alloc] initWithContentsOfFile:self.identifier];
[result setupResult:imgData];
return result;
}
@end

View File

@@ -0,0 +1,24 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResourceLoader.h"
@interface DoricLocalResourceLoader : NSObject <DoricResourceLoader>
@end

View File

@@ -0,0 +1,32 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricLocalResourceLoader.h"
#import "DoricLocalResource.h"
@implementation DoricLocalResourceLoader
- (NSString *)resourceType {
return @"local";
}
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
return [[DoricLocalResource alloc] initWithContext:context identifier:identifier];
}
@end

View File

@@ -0,0 +1,24 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResource.h"
@interface DoricRemoteResource : DoricResource
@end

View File

@@ -0,0 +1,33 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricRemoteResource.h"
@implementation DoricRemoteResource
- (DoricAsyncResult <NSData *> *)fetchRaw {
DoricAsyncResult *result = [DoricAsyncResult new];
NSURL *url = [NSURL URLWithString:self.identifier];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *urlData = [NSData dataWithContentsOfURL:url];
[result setupResult:urlData];
});
return result;
}
@end

View File

@@ -0,0 +1,25 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import <Foundation/Foundation.h>
#import "DoricResourceLoader.h"
@interface DoricRemoteResourceLoader : NSObject <DoricResourceLoader>
@end

View File

@@ -0,0 +1,31 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/25.
//
#import "DoricRemoteResourceLoader.h"
#import "DoricRemoteResource.h"
@implementation DoricRemoteResourceLoader
- (NSString *)resourceType {
return @"remote";
}
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context {
return [[DoricRemoteResource alloc] initWithContext:context identifier:identifier];
}
@end

View File

@@ -0,0 +1,32 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/22.
//
#import <Foundation/Foundation.h>
#import "DoricAsyncResult.h"
@class DoricContext;
@interface DoricResource : NSObject
@property(nonatomic, weak) DoricContext *context;
@property(nonatomic, copy) NSString *identifier;
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier;
- (DoricAsyncResult <NSData *> *)fetchRaw;
@end

View File

@@ -0,0 +1,33 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/22.
//
#import "DoricResource.h"
@implementation DoricResource
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier {
if (self = [super init]) {
_context = context;
_identifier = identifier;
}
return self;
}
- (DoricAsyncResult<NSData *> *)fetchRaw {
return nil;
}
@end

View File

@@ -0,0 +1,27 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/22.
//
#import <Foundation/Foundation.h>
#import "DoricResource.h"
@protocol DoricResourceLoader
@property(nonatomic, readonly) NSString *resourceType;
- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context;
@end

View File

@@ -0,0 +1,31 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/22.
//
#import <Foundation/Foundation.h>
#import "DoricResourceLoader.h"
@interface DoricResourceLoaderManager : NSObject
- (void)registerLoader:(id <DoricResourceLoader>)loader;
- (void)unRegisterLoader:(id <DoricResourceLoader>)loader;
- (__kindof DoricResource *)load:(NSString *)identifier
withResourceType:(NSString *)resourceType
withContext:(DoricContext *)context;
@end

View File

@@ -0,0 +1,49 @@
/*
* Copyright [2021] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// Created by pengfei.zhou on 2021/10/22.
//
#import "DoricResourceLoaderManager.h"
@interface DoricResourceLoaderManager ()
@property(nonatomic, strong) NSMutableDictionary <NSString *, id <DoricResourceLoader>> *loaders;
@end
@implementation DoricResourceLoaderManager
- (instancetype)init {
if (self = [super init]) {
_loaders = [NSMutableDictionary new];
}
return self;
}
- (void)registerLoader:(id <DoricResourceLoader>)loader {
self.loaders[loader.resourceType] = loader;
}
- (void)unRegisterLoader:(id <DoricResourceLoader>)loader {
[self.loaders removeObjectForKey:loader.resourceType];
}
- (__kindof DoricResource *)load:(NSString *)identifier
withResourceType:(NSString *)resourceType
withContext:(DoricContext *)context {
id <DoricResourceLoader> loader = self.loaders[resourceType];
return [loader load:identifier withContext:context];
}
@end

View File

@@ -233,7 +233,57 @@ - (UIImage *)currentErrorImage {
}
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"imageUrl" isEqualToString:name]) {
if ([@"image" isEqualToString:name]) {
NSString *type = prop[@"type"];
NSString *identifier = prop[@"identifier"];
DoricAsyncResult <NSData *> *asyncResult = [[self.doricContext.driver.registry.loaderManager
load:identifier withResourceType:type withContext:self.doricContext] fetchRaw];
[asyncResult setResultCallback:^(NSData *imageData) {
[self.doricContext dispatchToMainQueue:^{
#if DORIC_USE_YYWEBIMAGE
YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale];
#elif DORIC_USE_SDWEBIMAGE
UIImage *image = [SDAnimatedImage imageWithData:imageData scale:self.imageScale];
if (!image) {
image = [UIImage imageWithData:imageData scale:self.imageScale];
}
#else
UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale];
#endif
view.image = image;
DoricSuperNode *node = self.superNode;
while (node.superNode != nil) {
node = node.superNode;
}
[node requestLayout];
if (self.loadCallbackId.length > 0) {
if (image) {
[self callJSResponse:self.loadCallbackId,
@{
@"width": @(image.size.width),
@"height": @(image.size.height),
#if DORIC_USE_YYWEBIMAGE
@"animated": (image.animatedImageData != nil) ? @(YES) : @(NO),
#elif DORIC_USE_SDWEBIMAGE
@"animated": ([image isKindOfClass:SDAnimatedImage.class]
&& ((SDAnimatedImage *) image).animatedImageFrameCount > 0)
? @(YES)
: @(NO),
#else
@"animated": @(NO),
#endif
},
nil];
} else {
[self callJSResponse:self.loadCallbackId, nil];
}
}
}];
}];
[asyncResult setExceptionCallback:^(NSException *e) {
DoricLog(@"Cannot load resource type = %@, identifier = %@, %@", type, identifier, e.reason);
}];
} else if ([@"imageUrl" isEqualToString:name]) {
__weak typeof(self) _self = self;
__block BOOL async = NO;
view.doricLayout.undefined = YES;