iOS: move bundle to DoricSingleton

This commit is contained in:
pengfei.zhou 2021-08-24 11:01:11 +08:00 committed by osborn
parent 598bde8442
commit 0ffb14ec72
3 changed files with 4 additions and 4 deletions

View File

@ -58,7 +58,6 @@
@interface DoricRegistry ()
@property(nonatomic, strong) NSMutableDictionary *bundles;
@property(nonatomic, strong) NSMutableDictionary *plugins;
@property(nonatomic, strong) NSMutableDictionary *nodes;
@property(nonatomic, strong) NSMutableSet <id <DoricMonitorProtocol>> *monitors;
@ -80,7 +79,6 @@ + (void)register:(DoricLibrary *)library {
- (instancetype)initWithJSEngine:(DoricJSEngine *)jsEngine {
if (self = [super init]) {
_jsEngine = jsEngine;
_bundles = [NSMutableDictionary new];
_plugins = [NSMutableDictionary new];
_nodes = [NSMutableDictionary new];
_monitors = [NSMutableSet new];
@ -130,11 +128,11 @@ - (void)innerRegister {
}
- (void)registerJSBundle:(NSString *)bundle withName:(NSString *)name {
self.bundles[name] = bundle;
DoricSingleton.instance.bundles[name] = bundle;
}
- (NSString *)acquireJSBundle:(NSString *)name {
return self.bundles[name];
return DoricSingleton.instance.bundles[name];
}
- (void)registerNativePlugin:(Class)pluginClass withName:(NSString *)name {

View File

@ -26,6 +26,7 @@
@class DoricContextManager;
@interface DoricSingleton : NSObject
@property(nonatomic, strong) NSMutableDictionary *bundles;
@property(nonatomic, strong) NSMutableSet <DoricLibrary *> *libraries;
@property(nonatomic, strong) NSHashTable<DoricRegistry *> *registries;
@property(nonatomic, strong) NSMutableDictionary *envDic;

View File

@ -37,6 +37,7 @@ - (instancetype)init {
_storageCaches = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsCopyIn
valueOptions:NSPointerFunctionsWeakMemory
capacity:0];
_bundles = [NSMutableDictionary new];
}
return self;
}