-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
RCTDevSplitBundleLoader
native module
Reviewed By: ejanzer Differential Revision: D21302418 fbshipit-source-id: a868f6dad3306190c7add26e8f9a976866c16aef
- Loading branch information
1 parent
fc2b538
commit ad879e5
Showing
17 changed files
with
343 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import type {TurboModule} from '../TurboModule/RCTExport'; | ||
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; | ||
|
||
export interface Spec extends TurboModule { | ||
+loadBundle: (bundlePath: string) => Promise<void>; | ||
} | ||
|
||
export default (TurboModuleRegistry.get<Spec>('DevSplitBundleLoader'): ?Spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <React/RCTBridgeModule.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface RCTDevSplitBundleLoader : NSObject <RCTBridgeModule> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <React/RCTDevSplitBundleLoader.h> | ||
|
||
#import <FBReactNativeSpec/FBReactNativeSpec.h> | ||
#import <React/RCTBridge.h> | ||
#import <React/RCTBundleURLProvider.h> | ||
#import <React/RCTConvert.h> | ||
#import <React/RCTDefines.h> | ||
#import <React/RCTUtils.h> | ||
|
||
#import "CoreModulesPlugins.h" | ||
|
||
using namespace facebook::react; | ||
|
||
@interface RCTDevSplitBundleLoader () <NativeDevSplitBundleLoaderSpec> | ||
@end | ||
|
||
#if RCT_DEV_MENU | ||
|
||
@implementation RCTDevSplitBundleLoader { | ||
} | ||
|
||
@synthesize bridge = _bridge; | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
+ (BOOL)requiresMainQueueSetup | ||
{ | ||
return NO; | ||
} | ||
|
||
- (void)setBridge:(RCTBridge *)bridge | ||
{ | ||
_bridge = bridge; | ||
} | ||
|
||
RCT_EXPORT_METHOD(loadBundle | ||
: (NSString *)bundlePath resolve | ||
: (RCTPromiseResolveBlock)resolve reject | ||
: (RCTPromiseRejectBlock)reject) | ||
{ | ||
NSURL *sourceURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForSplitBundleRoot:bundlePath]; | ||
[_bridge loadAndExecuteSplitBundleURL:sourceURL | ||
onError:^(NSError *error) { | ||
reject(@"E_BUNDLE_LOAD_ERROR", [error localizedDescription], error); | ||
} | ||
onComplete:^() { | ||
resolve(@YES); | ||
}]; | ||
} | ||
|
||
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params | ||
{ | ||
return std::make_shared<NativeDevSplitBundleLoaderSpecJSI>(params); | ||
} | ||
|
||
@end | ||
|
||
#else | ||
|
||
@implementation RCTDevSplitBundleLoader | ||
|
||
+ (NSString *)moduleName | ||
{ | ||
return nil; | ||
} | ||
- (void)loadBundle:(NSString *)bundlePath resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject; | ||
{ | ||
} | ||
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params | ||
{ | ||
return std::make_shared<NativeDevSplitBundleLoaderSpecJSI>(params); | ||
} | ||
|
||
@end | ||
|
||
#endif | ||
|
||
Class RCTDevSplitBundleLoaderCls(void) | ||
{ | ||
return RCTDevSplitBundleLoader.class; | ||
} |
Oops, something went wrong.