@granite-js/screen 1.0.40 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/ios/ReactNativeHosting/GraniteHostingHelper.swift +1 -0
- package/ios/ReactNativeHosting/GraniteNativeFactoryDelegate.h +24 -0
- package/ios/ReactNativeHosting/GraniteNativeFactoryDelegate.m +29 -0
- package/ios/ReactNativeHosting/GraniteNativeFactoryDelegateImpl.swift +7 -1
- package/ios/ReactNativeHosting/GraniteReactHost.swift +5 -0
- package/ios/ReactNativeHosting/GraniteScreen-Bridging-Header.h +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -40,6 +40,7 @@ public extension GraniteReactHost where Self: UIViewController {
|
|
|
40
40
|
do {
|
|
41
41
|
let item = try await convertToGraniteItem(bundleSource: bundle)
|
|
42
42
|
let delegate = ReactNativeFactoryDelegate(url: item.hostURL)
|
|
43
|
+
delegate.reactHost = self // self is GraniteReactHost
|
|
43
44
|
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
44
45
|
// Use GraniteNativeFactoryWrapper to enable module customization
|
|
45
46
|
let factory = GraniteNativeFactoryImpl(delegate: delegate)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GraniteNativeFactoryDelegate.h
|
|
3
|
+
// GraniteScreen
|
|
4
|
+
//
|
|
5
|
+
// Base factory delegate that exposes the host start callback to Swift
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#if __has_include(<React-RCTAppDelegate/RCTDefaultReactNativeFactoryDelegate.h>)
|
|
9
|
+
#import <React-RCTAppDelegate/RCTDefaultReactNativeFactoryDelegate.h>
|
|
10
|
+
#else
|
|
11
|
+
#import <React_RCTAppDelegate/RCTDefaultReactNativeFactoryDelegate.h>
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
/// Base delegate that republishes `hostDidStart:`, which Swift cannot override
|
|
17
|
+
@interface GraniteNativeFactoryDelegate : RCTDefaultReactNativeFactoryDelegate
|
|
18
|
+
|
|
19
|
+
/// called right after the React Native instance is created, before the JS bundle is evaluated
|
|
20
|
+
- (void)graniteHostDidStart;
|
|
21
|
+
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// GraniteNativeFactoryDelegate.m
|
|
3
|
+
// GraniteScreen
|
|
4
|
+
//
|
|
5
|
+
// Base factory delegate that exposes the host start callback to Swift
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "GraniteNativeFactoryDelegate.h"
|
|
9
|
+
|
|
10
|
+
@class RCTHost;
|
|
11
|
+
|
|
12
|
+
// `RCTReactNativeFactoryDelegate` adopts `RCTHostDelegate` only under
|
|
13
|
+
// `__cplusplus`, so this selector is invisible here. Redeclaring it keeps the
|
|
14
|
+
// file plain Objective-C.
|
|
15
|
+
@interface RCTDefaultReactNativeFactoryDelegate (GraniteHostDidStart)
|
|
16
|
+
- (void)hostDidStart:(RCTHost *)host;
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@implementation GraniteNativeFactoryDelegate
|
|
20
|
+
|
|
21
|
+
- (void)hostDidStart:(RCTHost *)host {
|
|
22
|
+
[super hostDidStart:host];
|
|
23
|
+
[self graniteHostDidStart];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
- (void)graniteHostDidStart {
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -8,9 +8,11 @@ import Foundation
|
|
|
8
8
|
import React
|
|
9
9
|
import React_RCTAppDelegate
|
|
10
10
|
|
|
11
|
-
public class ReactNativeFactoryDelegate:
|
|
11
|
+
public class ReactNativeFactoryDelegate: GraniteNativeFactoryDelegate {
|
|
12
12
|
private let url: URL
|
|
13
13
|
|
|
14
|
+
weak var reactHost: GraniteReactHost?
|
|
15
|
+
|
|
14
16
|
public init(url: URL) {
|
|
15
17
|
self.url = url
|
|
16
18
|
super.init()
|
|
@@ -27,4 +29,8 @@ public class ReactNativeFactoryDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
|
27
29
|
public override func bridgelessEnabled() -> Bool {
|
|
28
30
|
return true
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
public override func graniteHostDidStart() -> Bool {
|
|
34
|
+
reactHost?.graniteHostDidStart()
|
|
35
|
+
}
|
|
30
36
|
}
|
|
@@ -17,6 +17,9 @@ public protocol GraniteReactHost: AnyObject {
|
|
|
17
17
|
/// Return nil to use the default bundle from app
|
|
18
18
|
var bundleLoader: BundleLoadable { get }
|
|
19
19
|
func graniteSetupDidStart()
|
|
20
|
+
/// Called right after the React Native instance is created, before the JS bundle is evaluated
|
|
21
|
+
/// Fires again the host is built, so a reload calls it once more
|
|
22
|
+
func graniteHostDidStart()
|
|
20
23
|
func graniteSetupDidFinish()
|
|
21
24
|
func graniteSetupDidError(didFailWith error: Error)
|
|
22
25
|
/// Module instance creation (same as Objective-C)
|
|
@@ -29,6 +32,8 @@ public protocol GraniteReactHost: AnyObject {
|
|
|
29
32
|
|
|
30
33
|
// Default implementation - returns nil
|
|
31
34
|
extension GraniteReactHost {
|
|
35
|
+
public func graniteHostDidStart() {} // Default does nothing
|
|
36
|
+
|
|
32
37
|
public func getModuleInstance(from moduleClass: AnyClass) -> Any? {
|
|
33
38
|
return nil // Default returns nil
|
|
34
39
|
}
|