iOS support internal class

This commit is contained in:
pengfei.zhou
2020-09-04 18:51:08 +08:00
committed by osborn
parent 4df7df1327
commit 821cb1823c
11 changed files with 70 additions and 77 deletions

View File

@@ -57,6 +57,28 @@ - (void)addJSLoader:(id <DoricLoaderProtocol>)loader {
- (DoricAsyncResult <NSString *> *)request:(NSString *)source {
__block DoricAsyncResult *ret;
if ([source hasPrefix:@"_internal_://"]) {
ret = [DoricAsyncResult new];
__block NSString *contextId = nil;
__block NSString *className = nil;
NSURLComponents *components = [NSURLComponents componentsWithString:source];
[components.queryItems forEach:^(NSURLQueryItem *obj) {
if ([obj.name isEqualToString:@"class"]) {
className = obj.value;
} else if ([obj.name isEqualToString:@"context"]) {
contextId = obj.value;
}
}];
if (contextId && className) {
[ret setupResult:[NSString stringWithFormat:@"Entry('%@','%@')", contextId, className]];
} else {
[ret setupError:[NSException exceptionWithName:@"LoadingError"
reason:[NSString stringWithFormat:@"Scheme %@ format error", source]
userInfo:nil]];
}
return ret;
}
[self.loaders enumerateObjectsUsingBlock:^(id <DoricLoaderProtocol> obj, BOOL *stop) {
if ([obj filter:source]) {
ret = [obj request:source];