@solidnative-dev/fabric-host 0.0.0-stage → 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +87 -2
- package/dist/fatal-error-handler.d.ts +27 -0
- package/dist/fatal-error-handler.d.ts.map +1 -0
- package/dist/fatal-error-handler.js +106 -0
- package/dist/fatal-error-handler.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/native-binding.d.ts +183 -0
- package/dist/native-binding.d.ts.map +1 -0
- package/dist/native-binding.js +554 -0
- package/dist/native-binding.js.map +1 -0
- package/dist/native-fabric-host.d.ts +32 -0
- package/dist/native-fabric-host.d.ts.map +1 -0
- package/dist/native-fabric-host.js +275 -0
- package/dist/native-fabric-host.js.map +1 -0
- package/dist/native-transaction.d.ts +17 -0
- package/dist/native-transaction.d.ts.map +1 -0
- package/dist/native-transaction.js +124 -0
- package/dist/native-transaction.js.map +1 -0
- package/dist/react-native-0.87.d.ts +61 -0
- package/dist/react-native-0.87.d.ts.map +1 -0
- package/dist/react-native-0.87.js +77 -0
- package/dist/react-native-0.87.js.map +1 -0
- package/dist/react-native-0.88.d.ts +77 -0
- package/dist/react-native-0.88.d.ts.map +1 -0
- package/dist/react-native-0.88.js +79 -0
- package/dist/react-native-0.88.js.map +1 -0
- package/dist/surface-readiness.d.ts +18 -0
- package/dist/surface-readiness.d.ts.map +1 -0
- package/dist/surface-readiness.js +43 -0
- package/dist/surface-readiness.js.map +1 -0
- package/native/README.md +502 -0
- package/native/SolidNativeFabric.podspec +84 -0
- package/native/android/SolidNativeBindingsInstaller.cpp +4218 -0
- package/native/android/SolidNativeBindingsInstaller.h +8 -0
- package/native/android/SolidNativeRuntime.cmake +61 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativeBindingsInstaller.kt +239 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativeDebugModule.kt +191 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativePackage.kt +43 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativePlatformModule.kt +81 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativeStartupFailureView.kt +93 -0
- package/native/android/java/dev/solidnative/runtime/SolidNativeSurface.kt +423 -0
- package/native/android/solid-native.gradle +90 -0
- package/native/apple/SolidNativeDebugRequest.mm +421 -0
- package/native/fabric/SolidNativeDebugRequest.h +12 -0
- package/native/fabric/SolidNativeDirtyNodes.h +26 -0
- package/native/fabric/SolidNativeFabricApi.cpp +224 -0
- package/native/fabric/SolidNativeFabricApi.h +107 -0
- package/native/fabric/SolidNativeFabricApplication.h +32 -0
- package/native/fabric/SolidNativeFabricApplication.mm +373 -0
- package/native/fabric/SolidNativeFabricJSIBinding.h +43 -0
- package/native/fabric/SolidNativeFabricJSIBinding.mm +4491 -0
- package/native/fabric/SolidNativeFabricSmokeApplication.h +26 -0
- package/native/fabric/SolidNativeFabricSmokeApplication.mm +331 -0
- package/native/fabric/SolidNativeFabricSurface.h +63 -0
- package/native/fabric/SolidNativeFabricSurface.mm +549 -0
- package/native/fabric/SolidNativeFabricTransactionCoordinator.cpp +1275 -0
- package/native/fabric/SolidNativeFabricTransactionCoordinator.h +90 -0
- package/native/fabric/SolidNativeFabricTransactionCoordinatorApple.mm +97 -0
- package/native/fabric/SolidNativeRootViewController.h +20 -0
- package/native/fabric/SolidNativeRootViewController.mm +83 -0
- package/native/fabric/SolidNativeStagedNodeMap.h +104 -0
- package/native/fabric/SolidNativeStartupFailureView.h +17 -0
- package/native/fabric/SolidNativeStartupFailureView.mm +77 -0
- package/native/react-native-boundary.json +106 -0
- package/native/worklets/SolidNativeUIWorklet.cpp +1080 -0
- package/native/worklets/SolidNativeUIWorklet.h +245 -0
- package/package.json +41 -3
- package/scripts/verify-react-native-boundary.mjs +282 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <unordered_map>
|
|
6
|
+
|
|
7
|
+
#include <folly/dynamic.h>
|
|
8
|
+
#include <react/renderer/core/ReactPrimitives.h>
|
|
9
|
+
|
|
10
|
+
#include "SolidNativeFabricApi.h"
|
|
11
|
+
|
|
12
|
+
#ifdef __OBJC__
|
|
13
|
+
#import <Foundation/Foundation.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
namespace facebook::react {
|
|
17
|
+
class InstanceHandle;
|
|
18
|
+
class UIManager;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
namespace facebook::jsi {
|
|
22
|
+
class Runtime;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
namespace solid_native::fabric::react_native {
|
|
26
|
+
|
|
27
|
+
struct NodeIdentity final {
|
|
28
|
+
facebook::react::Tag tag;
|
|
29
|
+
std::shared_ptr<const facebook::react::InstanceHandle> instanceHandle;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
using NodeIdentityMap = std::unordered_map<int64_t, NodeIdentity>;
|
|
33
|
+
|
|
34
|
+
struct NodeMeasurement final {
|
|
35
|
+
double x;
|
|
36
|
+
double y;
|
|
37
|
+
double width;
|
|
38
|
+
double height;
|
|
39
|
+
double pageX;
|
|
40
|
+
double pageY;
|
|
41
|
+
int64_t observedSequence;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Applies the versioned Solid Native host transaction envelope to one Fabric
|
|
45
|
+
// surface. The coordinator owns the logical tree, stages only edited records,
|
|
46
|
+
// and publishes them after validation and the Fabric root commit return.
|
|
47
|
+
class TransactionCoordinator final {
|
|
48
|
+
public:
|
|
49
|
+
explicit TransactionCoordinator(int32_t surfaceId);
|
|
50
|
+
~TransactionCoordinator();
|
|
51
|
+
|
|
52
|
+
TransactionCoordinator(const TransactionCoordinator &) = delete;
|
|
53
|
+
TransactionCoordinator &operator=(const TransactionCoordinator &) = delete;
|
|
54
|
+
|
|
55
|
+
int64_t apply(
|
|
56
|
+
facebook::react::UIManager &uiManager,
|
|
57
|
+
const folly::dynamic &transaction);
|
|
58
|
+
int64_t apply(
|
|
59
|
+
facebook::react::UIManager &uiManager,
|
|
60
|
+
const folly::dynamic &transaction,
|
|
61
|
+
facebook::jsi::Runtime &runtime,
|
|
62
|
+
const NodeIdentityMap &nodeIdentities,
|
|
63
|
+
const NativeResourceResolver &resourceResolver);
|
|
64
|
+
#ifdef __OBJC__
|
|
65
|
+
int64_t apply(
|
|
66
|
+
facebook::react::UIManager &uiManager,
|
|
67
|
+
NSDictionary<NSString *, id> *transaction);
|
|
68
|
+
int64_t apply(
|
|
69
|
+
facebook::react::UIManager &uiManager,
|
|
70
|
+
NSDictionary<NSString *, id> *transaction,
|
|
71
|
+
facebook::jsi::Runtime &runtime,
|
|
72
|
+
const NodeIdentityMap &nodeIdentities,
|
|
73
|
+
const NativeResourceResolver &resourceResolver);
|
|
74
|
+
#endif
|
|
75
|
+
NodeMeasurement measure(
|
|
76
|
+
facebook::react::UIManager &uiManager,
|
|
77
|
+
int64_t node,
|
|
78
|
+
int64_t afterSequence);
|
|
79
|
+
static facebook::react::Tag allocateFabricTag();
|
|
80
|
+
bool empty() const;
|
|
81
|
+
int64_t lastFabricRevision() const;
|
|
82
|
+
int64_t lastSequence() const;
|
|
83
|
+
void reset();
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
class Impl;
|
|
87
|
+
std::unique_ptr<Impl> impl_;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
} // namespace solid_native::fabric::react_native
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#include "SolidNativeFabricTransactionCoordinator.h"
|
|
2
|
+
|
|
3
|
+
#import <Foundation/Foundation.h>
|
|
4
|
+
|
|
5
|
+
#include <cmath>
|
|
6
|
+
#include <stdexcept>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
namespace solid_native::fabric::react_native {
|
|
10
|
+
namespace {
|
|
11
|
+
|
|
12
|
+
constexpr double MaximumSafeInteger = 9007199254740991.0;
|
|
13
|
+
|
|
14
|
+
std::string utf8(NSString *value) {
|
|
15
|
+
const char *characters = value.UTF8String;
|
|
16
|
+
if (characters == nullptr) {
|
|
17
|
+
throw std::invalid_argument("A transaction string is not valid UTF-8.");
|
|
18
|
+
}
|
|
19
|
+
return characters;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
std::string pathMessage(NSString *path, NSString *message) {
|
|
23
|
+
return utf8([NSString stringWithFormat:@"%@: %@", path, message]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
folly::dynamic dynamicFromObject(id value, NSString *path) {
|
|
27
|
+
if (value == nil || value == NSNull.null) return nullptr;
|
|
28
|
+
if ([value isKindOfClass:NSString.class]) {
|
|
29
|
+
return utf8((NSString *)value);
|
|
30
|
+
}
|
|
31
|
+
if ([value isKindOfClass:NSNumber.class]) {
|
|
32
|
+
if (CFGetTypeID((__bridge CFTypeRef)value) == CFBooleanGetTypeID()) {
|
|
33
|
+
return [(NSNumber *)value boolValue] == YES;
|
|
34
|
+
}
|
|
35
|
+
const double number = [(NSNumber *)value doubleValue];
|
|
36
|
+
if (!std::isfinite(number)) {
|
|
37
|
+
throw std::invalid_argument(
|
|
38
|
+
pathMessage(path, @"numbers must be finite."));
|
|
39
|
+
}
|
|
40
|
+
if (std::trunc(number) == number &&
|
|
41
|
+
std::abs(number) <= MaximumSafeInteger) {
|
|
42
|
+
return static_cast<int64_t>(number);
|
|
43
|
+
}
|
|
44
|
+
return number;
|
|
45
|
+
}
|
|
46
|
+
if ([value isKindOfClass:NSArray.class]) {
|
|
47
|
+
folly::dynamic result = folly::dynamic::array;
|
|
48
|
+
NSUInteger index = 0;
|
|
49
|
+
for (id child in (NSArray *)value) {
|
|
50
|
+
result.push_back(dynamicFromObject(
|
|
51
|
+
child,
|
|
52
|
+
[path stringByAppendingFormat:@"[%lu]", (unsigned long)index++]));
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
if ([value isKindOfClass:NSDictionary.class]) {
|
|
57
|
+
folly::dynamic result = folly::dynamic::object;
|
|
58
|
+
for (id key in (NSDictionary *)value) {
|
|
59
|
+
if (![key isKindOfClass:NSString.class]) {
|
|
60
|
+
throw std::invalid_argument(
|
|
61
|
+
pathMessage(path, @"object keys must be strings."));
|
|
62
|
+
}
|
|
63
|
+
NSString *name = (NSString *)key;
|
|
64
|
+
result[utf8(name)] = dynamicFromObject(
|
|
65
|
+
[(NSDictionary *)value objectForKey:key],
|
|
66
|
+
[path stringByAppendingFormat:@".%@", name]);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
throw std::invalid_argument(
|
|
71
|
+
pathMessage(path, @"contains a non-transport-safe value."));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} // namespace
|
|
75
|
+
|
|
76
|
+
int64_t TransactionCoordinator::apply(
|
|
77
|
+
facebook::react::UIManager &uiManager,
|
|
78
|
+
NSDictionary<NSString *, id> *transaction) {
|
|
79
|
+
return apply(
|
|
80
|
+
uiManager, dynamicFromObject(transaction, @"transaction"));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
int64_t TransactionCoordinator::apply(
|
|
84
|
+
facebook::react::UIManager &uiManager,
|
|
85
|
+
NSDictionary<NSString *, id> *transaction,
|
|
86
|
+
facebook::jsi::Runtime &runtime,
|
|
87
|
+
const NodeIdentityMap &nodeIdentities,
|
|
88
|
+
const NativeResourceResolver &resourceResolver) {
|
|
89
|
+
return apply(
|
|
90
|
+
uiManager,
|
|
91
|
+
dynamicFromObject(transaction, @"transaction"),
|
|
92
|
+
runtime,
|
|
93
|
+
nodeIdentities,
|
|
94
|
+
resourceResolver);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
} // namespace solid_native::fabric::react_native
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
// Root view controller for Solid Native iOS scenes. Owns view-controller-based
|
|
8
|
+
// status-bar appearance so Solid Native's owner-bound StatusBar component works
|
|
9
|
+
// on iOS 27+ (where legacy UIApplication status-bar APIs are no-ops) as well as
|
|
10
|
+
// earlier iOS releases.
|
|
11
|
+
@interface SolidNativeRootViewController : UIViewController
|
|
12
|
+
|
|
13
|
+
- (void)setSolidNativeStatusBarStyle:(UIStatusBarStyle)style
|
|
14
|
+
animated:(BOOL)animated;
|
|
15
|
+
- (void)setSolidNativeStatusBarHidden:(BOOL)hidden
|
|
16
|
+
animation:(UIStatusBarAnimation)animation;
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#import "SolidNativeRootViewController.h"
|
|
2
|
+
|
|
3
|
+
namespace {
|
|
4
|
+
|
|
5
|
+
constexpr NSTimeInterval StatusBarTransitionDuration = 0.25;
|
|
6
|
+
|
|
7
|
+
} // namespace
|
|
8
|
+
|
|
9
|
+
@implementation SolidNativeRootViewController {
|
|
10
|
+
UIStatusBarStyle _preferredStatusBarStyle;
|
|
11
|
+
BOOL _prefersStatusBarHidden;
|
|
12
|
+
UIStatusBarAnimation _preferredStatusBarUpdateAnimation;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
|
|
16
|
+
bundle:(nullable NSBundle *)nibBundleOrNil {
|
|
17
|
+
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
|
|
18
|
+
_preferredStatusBarStyle = UIStatusBarStyleDefault;
|
|
19
|
+
_prefersStatusBarHidden = NO;
|
|
20
|
+
_preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone;
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (UIStatusBarStyle)preferredStatusBarStyle {
|
|
26
|
+
return _preferredStatusBarStyle;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (BOOL)prefersStatusBarHidden {
|
|
30
|
+
return _prefersStatusBarHidden;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
|
|
34
|
+
return _preferredStatusBarUpdateAnimation;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (nullable UIViewController *)childViewControllerForStatusBarStyle {
|
|
38
|
+
return nil;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (nullable UIViewController *)childViewControllerForStatusBarHidden {
|
|
42
|
+
return nil;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
- (void)setSolidNativeStatusBarStyle:(UIStatusBarStyle)style
|
|
46
|
+
animated:(BOOL)animated {
|
|
47
|
+
NSAssert(
|
|
48
|
+
NSThread.isMainThread,
|
|
49
|
+
@"SolidNativeRootViewController status-bar updates must run on the main thread.");
|
|
50
|
+
if (_preferredStatusBarStyle == style) return;
|
|
51
|
+
_preferredStatusBarStyle = style;
|
|
52
|
+
if (animated) {
|
|
53
|
+
[UIView animateWithDuration:StatusBarTransitionDuration
|
|
54
|
+
animations:^{
|
|
55
|
+
[self setNeedsStatusBarAppearanceUpdate];
|
|
56
|
+
}];
|
|
57
|
+
} else {
|
|
58
|
+
[self setNeedsStatusBarAppearanceUpdate];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)setSolidNativeStatusBarHidden:(BOOL)hidden
|
|
63
|
+
animation:(UIStatusBarAnimation)animation {
|
|
64
|
+
NSAssert(
|
|
65
|
+
NSThread.isMainThread,
|
|
66
|
+
@"SolidNativeRootViewController status-bar updates must run on the main thread.");
|
|
67
|
+
if (_prefersStatusBarHidden == hidden &&
|
|
68
|
+
_preferredStatusBarUpdateAnimation == animation) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
_prefersStatusBarHidden = hidden;
|
|
72
|
+
_preferredStatusBarUpdateAnimation = animation;
|
|
73
|
+
if (animation != UIStatusBarAnimationNone) {
|
|
74
|
+
[UIView animateWithDuration:StatusBarTransitionDuration
|
|
75
|
+
animations:^{
|
|
76
|
+
[self setNeedsStatusBarAppearanceUpdate];
|
|
77
|
+
}];
|
|
78
|
+
} else {
|
|
79
|
+
[self setNeedsStatusBarAppearanceUpdate];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cassert>
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <limits>
|
|
6
|
+
#include <stdexcept>
|
|
7
|
+
#include <unordered_map>
|
|
8
|
+
#include <unordered_set>
|
|
9
|
+
#include <utility>
|
|
10
|
+
|
|
11
|
+
namespace solid_native::fabric::react_native {
|
|
12
|
+
|
|
13
|
+
// A transaction-local overlay. Reads never copy records, edits copy each
|
|
14
|
+
// existing record at most once, and destruction without publish discards all
|
|
15
|
+
// edits. The owner must hold its graph mutex for the overlay's entire lifetime.
|
|
16
|
+
template <typename Record>
|
|
17
|
+
class StagedNodeMap final {
|
|
18
|
+
public:
|
|
19
|
+
using Handle = int64_t;
|
|
20
|
+
using Map = std::unordered_map<Handle, Record>;
|
|
21
|
+
|
|
22
|
+
explicit StagedNodeMap(Map &committed) : committed_(committed) {}
|
|
23
|
+
StagedNodeMap(const StagedNodeMap &) = delete;
|
|
24
|
+
StagedNodeMap &operator=(const StagedNodeMap &) = delete;
|
|
25
|
+
|
|
26
|
+
const Record *get(Handle handle) const {
|
|
27
|
+
const auto changed = changes_.find(handle);
|
|
28
|
+
if (changed != changes_.end()) return &changed->second;
|
|
29
|
+
if (removed_.contains(handle)) return nullptr;
|
|
30
|
+
const auto existing = committed_.find(handle);
|
|
31
|
+
return existing == committed_.end() ? nullptr : &existing->second;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool contains(Handle handle) const { return get(handle) != nullptr; }
|
|
35
|
+
|
|
36
|
+
Record *edit(Handle handle) {
|
|
37
|
+
prepared_ = false;
|
|
38
|
+
const auto changed = changes_.find(handle);
|
|
39
|
+
if (changed != changes_.end()) return &changed->second;
|
|
40
|
+
const auto *existing = get(handle);
|
|
41
|
+
if (existing == nullptr) return nullptr;
|
|
42
|
+
return &changes_.emplace(handle, *existing).first->second;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
bool insert(Handle handle, Record record) {
|
|
46
|
+
prepared_ = false;
|
|
47
|
+
if (contains(handle)) return false;
|
|
48
|
+
changes_.emplace(handle, std::move(record));
|
|
49
|
+
removed_.erase(handle);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
bool erase(Handle handle) {
|
|
54
|
+
prepared_ = false;
|
|
55
|
+
if (!contains(handle)) return false;
|
|
56
|
+
// Allocate the tombstone before discarding a staged edit, so allocation
|
|
57
|
+
// failure cannot expose the old committed value within this overlay.
|
|
58
|
+
if (committed_.contains(handle)) removed_.insert(handle);
|
|
59
|
+
changes_.erase(handle);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Reserve before crossing the native commit boundary. With integer keys,
|
|
64
|
+
// the default nonthrowing hash/equality and equal standard allocators, the
|
|
65
|
+
// subsequent node-handle transfers need no allocation or Record copies.
|
|
66
|
+
// Only growth can rehash the committed map; prop updates never do.
|
|
67
|
+
void preparePublish() {
|
|
68
|
+
size_t additions = 0;
|
|
69
|
+
for (const auto &[handle, record] : changes_) {
|
|
70
|
+
if (!committed_.contains(handle)) ++additions;
|
|
71
|
+
}
|
|
72
|
+
if (additions > committed_.max_size() - committed_.size()) {
|
|
73
|
+
throw std::length_error("The native node map is too large.");
|
|
74
|
+
}
|
|
75
|
+
const auto required = committed_.size() + additions;
|
|
76
|
+
if (additions != 0 &&
|
|
77
|
+
static_cast<double>(required) >
|
|
78
|
+
static_cast<double>(committed_.bucket_count()) *
|
|
79
|
+
committed_.max_load_factor()) {
|
|
80
|
+
committed_.reserve(required);
|
|
81
|
+
}
|
|
82
|
+
prepared_ = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void publish() noexcept {
|
|
86
|
+
assert(prepared_);
|
|
87
|
+
for (const auto handle : removed_) committed_.erase(handle);
|
|
88
|
+
while (!changes_.empty()) {
|
|
89
|
+
auto node = changes_.extract(changes_.begin());
|
|
90
|
+
committed_.erase(node.key());
|
|
91
|
+
committed_.insert(std::move(node));
|
|
92
|
+
}
|
|
93
|
+
removed_.clear();
|
|
94
|
+
prepared_ = false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
Map &committed_;
|
|
99
|
+
Map changes_;
|
|
100
|
+
std::unordered_set<Handle> removed_;
|
|
101
|
+
bool prepared_{false};
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
} // namespace solid_native::fabric::react_native
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
// Renders a dependency-free terminal startup fallback after Fabric cannot own
|
|
8
|
+
// the screen. Release builds never expose the supplied diagnostic.
|
|
9
|
+
@interface SolidNativeStartupFailureView : NSObject
|
|
10
|
+
|
|
11
|
+
+ (void)showInContainerView:(UIView *)containerView
|
|
12
|
+
error:(nullable NSError *)error
|
|
13
|
+
NS_SWIFT_NAME(show(in:error:));
|
|
14
|
+
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#import "SolidNativeStartupFailureView.h"
|
|
2
|
+
|
|
3
|
+
namespace {
|
|
4
|
+
|
|
5
|
+
constexpr NSInteger FailureViewTag = 0x534e46;
|
|
6
|
+
#if DEBUG
|
|
7
|
+
constexpr NSUInteger MaxDiagnosticLength = 2048;
|
|
8
|
+
constexpr NSUInteger MaxDiagnosticNameLength = 128;
|
|
9
|
+
|
|
10
|
+
NSString *sanitizedBoundedString(NSString *value, NSUInteger maximumLength) {
|
|
11
|
+
auto truncated = value.length > maximumLength;
|
|
12
|
+
auto contentLength = truncated ? maximumLength - 1 : maximumLength;
|
|
13
|
+
if (contentLength < value.length && contentLength > 0) {
|
|
14
|
+
auto lastCharacter = [value characterAtIndex:contentLength - 1];
|
|
15
|
+
if (lastCharacter >= 0xd800 && lastCharacter <= 0xdbff) {
|
|
16
|
+
contentLength -= 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
auto bounded = value.length > contentLength
|
|
20
|
+
? [value substringToIndex:contentLength]
|
|
21
|
+
: value;
|
|
22
|
+
auto clean =
|
|
23
|
+
[[bounded componentsSeparatedByCharactersInSet:
|
|
24
|
+
NSCharacterSet.controlCharacterSet]
|
|
25
|
+
componentsJoinedByString:@" "];
|
|
26
|
+
return truncated ? [clean stringByAppendingString:@"…"] : clean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
NSString *boundedDiagnostic(NSError *error) {
|
|
30
|
+
auto rawName = error.domain.length == 0 ? @"Error" : error.domain;
|
|
31
|
+
auto rawMessage = error.localizedDescription.length == 0
|
|
32
|
+
? @"No diagnostic message was provided."
|
|
33
|
+
: error.localizedDescription;
|
|
34
|
+
auto name = sanitizedBoundedString(rawName, MaxDiagnosticNameLength);
|
|
35
|
+
auto maximumMessageLength = MaxDiagnosticLength - name.length - 2;
|
|
36
|
+
auto message = sanitizedBoundedString(rawMessage, maximumMessageLength);
|
|
37
|
+
return [NSString stringWithFormat:@"%@: %@", name, message];
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
} // namespace
|
|
42
|
+
|
|
43
|
+
@implementation SolidNativeStartupFailureView
|
|
44
|
+
|
|
45
|
+
+ (void)showInContainerView:(UIView *)containerView error:(NSError *)error {
|
|
46
|
+
NSAssert(
|
|
47
|
+
NSThread.isMainThread,
|
|
48
|
+
@"SolidNativeStartupFailureView must render on the main thread.");
|
|
49
|
+
[[containerView viewWithTag:FailureViewTag] removeFromSuperview];
|
|
50
|
+
|
|
51
|
+
auto genericMessage = @"Solid Native could not start.";
|
|
52
|
+
NSString *message = genericMessage;
|
|
53
|
+
#if DEBUG
|
|
54
|
+
if (error != nil) {
|
|
55
|
+
message = [NSString
|
|
56
|
+
stringWithFormat:@"%@\n\n%@", genericMessage, boundedDiagnostic(error)];
|
|
57
|
+
}
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
auto label = [[UILabel alloc] initWithFrame:containerView.bounds];
|
|
61
|
+
label.tag = FailureViewTag;
|
|
62
|
+
label.autoresizingMask =
|
|
63
|
+
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
64
|
+
label.backgroundColor = UIColor.systemBackgroundColor;
|
|
65
|
+
label.textColor = UIColor.labelColor;
|
|
66
|
+
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
|
|
67
|
+
label.numberOfLines = 0;
|
|
68
|
+
label.textAlignment = NSTextAlignmentCenter;
|
|
69
|
+
label.text = message;
|
|
70
|
+
label.isAccessibilityElement = YES;
|
|
71
|
+
label.accessibilityLabel = message;
|
|
72
|
+
[containerView addSubview:label];
|
|
73
|
+
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
|
|
74
|
+
label);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"reactNativeVersion": "0.88.1",
|
|
4
|
+
"nativeHeaders": [
|
|
5
|
+
"React/RCTBridge.h",
|
|
6
|
+
"React/RCTConstants.h",
|
|
7
|
+
"React/RCTFabricSurface.h",
|
|
8
|
+
"React/RCTReactNativeFactory.h",
|
|
9
|
+
"React/RCTReloadCommand.h",
|
|
10
|
+
"React/RCTRootViewFactory.h",
|
|
11
|
+
"React/RCTScheduler.h",
|
|
12
|
+
"React/RCTSurfacePresenter.h",
|
|
13
|
+
"React/RCTSurfaceView.h",
|
|
14
|
+
"React/RCTUtils.h",
|
|
15
|
+
"ReactCommon/RCTHost.h",
|
|
16
|
+
"ReactCommon/RCTTurboModule.h",
|
|
17
|
+
"React_RCTAppDelegate/RCTJSRuntimeConfiguratorProtocol.h",
|
|
18
|
+
"cxxreact/ReactNativeVersion.h",
|
|
19
|
+
"fbjni/fbjni.h",
|
|
20
|
+
"folly/dynamic.h",
|
|
21
|
+
"jsi/JSIDynamic.h",
|
|
22
|
+
"jsi/jsi.h",
|
|
23
|
+
"react/renderer/core/EventListener.h",
|
|
24
|
+
"react/renderer/core/InstanceHandle.h",
|
|
25
|
+
"react/renderer/core/RawEvent.h",
|
|
26
|
+
"react/renderer/core/RawProps.h",
|
|
27
|
+
"react/renderer/core/ReactPrimitives.h",
|
|
28
|
+
"react/renderer/core/ShadowNode.h",
|
|
29
|
+
"react/renderer/core/ShadowNodeFamily.h",
|
|
30
|
+
"react/renderer/dom/DOM.h",
|
|
31
|
+
"react/renderer/mounting/MountingCoordinator.h",
|
|
32
|
+
"react/renderer/mounting/ShadowTree.h",
|
|
33
|
+
"react/renderer/runtimescheduler/RuntimeScheduler.h",
|
|
34
|
+
"react/renderer/runtimescheduler/RuntimeSchedulerBinding.h",
|
|
35
|
+
"react/renderer/scheduler/SurfaceHandler.h",
|
|
36
|
+
"react/renderer/uimanager/UIManager.h",
|
|
37
|
+
"react/renderer/uimanager/UIManagerBinding.h",
|
|
38
|
+
"react/renderer/uimanager/UIManagerMountHook.h",
|
|
39
|
+
"react/runtime/JSRuntimeFactoryCAPI.h",
|
|
40
|
+
"react/runtime/jni/JBindingsInstaller.h"
|
|
41
|
+
],
|
|
42
|
+
"generatedCodegenHeaders": [
|
|
43
|
+
"SolidNativeAppSpec/SolidNativeAppSpec.h",
|
|
44
|
+
"SolidNativeE2ESpec/SolidNativeE2ESpec.h"
|
|
45
|
+
],
|
|
46
|
+
"androidImports": [
|
|
47
|
+
"com.facebook.jni.HybridData",
|
|
48
|
+
"com.facebook.jni.annotations.DoNotStrip",
|
|
49
|
+
"com.facebook.react.BaseReactPackage",
|
|
50
|
+
"com.facebook.react.ReactHost",
|
|
51
|
+
"com.facebook.react.bridge.Arguments",
|
|
52
|
+
"com.facebook.react.bridge.NativeModule",
|
|
53
|
+
"com.facebook.react.bridge.Promise",
|
|
54
|
+
"com.facebook.react.bridge.ReactApplicationContext",
|
|
55
|
+
"com.facebook.react.bridge.ReactMethod",
|
|
56
|
+
"com.facebook.react.interfaces.TaskInterface",
|
|
57
|
+
"com.facebook.react.interfaces.fabric.ReactSurface",
|
|
58
|
+
"com.facebook.react.module.annotations.ReactModule",
|
|
59
|
+
"com.facebook.react.module.model.ReactModuleInfo",
|
|
60
|
+
"com.facebook.react.module.model.ReactModuleInfoProvider",
|
|
61
|
+
"com.facebook.react.modules.i18nmanager.I18nUtil",
|
|
62
|
+
"com.facebook.react.runtime.BindingsInstaller",
|
|
63
|
+
"com.facebook.soloader.SoLoader"
|
|
64
|
+
],
|
|
65
|
+
"cocoapods": [
|
|
66
|
+
{
|
|
67
|
+
"name": "RCT-Folly",
|
|
68
|
+
"version": null
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "React-Fabric/core",
|
|
72
|
+
"version": "= 0.88.1"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "React-Fabric/mounting",
|
|
76
|
+
"version": "= 0.88.1"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "React-Fabric/uimanager",
|
|
80
|
+
"version": "= 0.88.1"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "React-RCTFabric",
|
|
84
|
+
"version": "= 0.88.1"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "React-RuntimeApple",
|
|
88
|
+
"version": "= 0.88.1"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "React-jsi",
|
|
92
|
+
"version": "= 0.88.1"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "ReactCodegen",
|
|
96
|
+
"version": null
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"androidCmake": {
|
|
100
|
+
"reactNativeIncludeDirectories": [
|
|
101
|
+
"${REACT_ANDROID_DIR}/../ReactCommon",
|
|
102
|
+
"${REACT_ANDROID_DIR}/src/main/jni"
|
|
103
|
+
],
|
|
104
|
+
"inheritedCompileOptions": ["${folly_FLAGS}"]
|
|
105
|
+
}
|
|
106
|
+
}
|