@amplitude/session-replay-react-native 0.1.0-beta.0 → 0.1.0-beta.2
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/AmplitudeSessionReplayReactNative.podspec +43 -2
- package/README.md +125 -0
- package/android/build.gradle +145 -5
- package/android/src/androidTest/java/com/amplitude/sessionreplayreactnative/SRMaskViewTest.kt +459 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRDefaultMaskingPrimitive.kt +36 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRMaskingPrimitive.kt +84 -0
- package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +51 -16
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +41 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +7 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskView.kt +174 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewManager.kt +44 -0
- package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewPointerEvents.java +36 -0
- package/android/src/{main → oldarch}/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +2 -1
- package/android/src/oldarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeSpec.kt +20 -0
- package/cpp/SRMaskViewComponentDescriptor.h +20 -0
- package/cpp/SRMaskViewShadowNode.cpp +54 -0
- package/cpp/SRMaskViewShadowNode.h +56 -0
- package/ios/AMPNativeSessionReplay.mm +20 -0
- package/ios/NativeSessionReplay.swift +29 -8
- package/ios/SRDefaultMaskingPrimitive.swift +34 -0
- package/ios/SRMaskingPrimitive.h +26 -0
- package/ios/SRMaskingRegistry.m +105 -0
- package/ios/fabric/SRMaskView.h +10 -0
- package/ios/fabric/SRMaskView.mm +178 -0
- package/lib/commonjs/Mask.types.js +29 -0
- package/lib/commonjs/Mask.types.js.map +1 -0
- package/lib/commonjs/fabric/MaskFabric.js +92 -0
- package/lib/commonjs/fabric/MaskFabric.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mask-fallback.js +53 -0
- package/lib/commonjs/mask-fallback.js.map +1 -0
- package/lib/commonjs/native-module.js +10 -1
- package/lib/commonjs/native-module.js.map +1 -1
- package/lib/commonjs/paper/MaskPaper.js +27 -0
- package/lib/commonjs/paper/MaskPaper.js.map +1 -0
- package/lib/commonjs/specs/NativeAmpSessionReplay.js +22 -0
- package/lib/commonjs/specs/NativeAmpSessionReplay.js.map +1 -0
- package/lib/commonjs/specs/SRMaskViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/SRMaskViewNativeComponent.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/Mask.types.js +23 -0
- package/lib/module/Mask.types.js.map +1 -0
- package/lib/module/fabric/MaskFabric.js +85 -0
- package/lib/module/fabric/MaskFabric.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mask-fallback.js +45 -0
- package/lib/module/mask-fallback.js.map +1 -0
- package/lib/module/native-module.js +10 -2
- package/lib/module/native-module.js.map +1 -1
- package/lib/module/paper/MaskPaper.js +21 -0
- package/lib/module/paper/MaskPaper.js.map +1 -0
- package/lib/module/specs/NativeAmpSessionReplay.js +18 -0
- package/lib/module/specs/NativeAmpSessionReplay.js.map +1 -0
- package/lib/module/specs/SRMaskViewNativeComponent.js +5 -0
- package/lib/module/specs/SRMaskViewNativeComponent.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/Mask.types.d.ts +38 -0
- package/lib/typescript/Mask.types.d.ts.map +1 -0
- package/lib/typescript/fabric/MaskFabric.d.ts +8 -0
- package/lib/typescript/fabric/MaskFabric.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +11 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/mask-fallback.d.ts +27 -0
- package/lib/typescript/mask-fallback.d.ts.map +1 -0
- package/lib/typescript/native-module.d.ts.map +1 -1
- package/lib/typescript/paper/MaskPaper.d.ts +10 -0
- package/lib/typescript/paper/MaskPaper.d.ts.map +1 -0
- package/lib/typescript/specs/NativeAmpSessionReplay.d.ts +15 -0
- package/lib/typescript/specs/NativeAmpSessionReplay.d.ts.map +1 -0
- package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts +11 -0
- package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +19 -6
- package/src/Mask.types.ts +45 -0
- package/src/fabric/MaskFabric.tsx +73 -0
- package/src/index.tsx +18 -0
- package/src/mask-fallback.tsx +60 -0
- package/src/native-module.ts +16 -10
- package/src/paper/MaskPaper.tsx +24 -0
- package/src/specs/NativeAmpSessionReplay.ts +29 -0
- package/src/specs/SRMaskViewNativeComponent.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -16,7 +16,7 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@objc(setup:resolve:reject:)
|
|
19
|
-
func setup(_ config: NSDictionary, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
|
|
19
|
+
func setup(_ config: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
|
|
20
20
|
guard let apiKey = config["apiKey"] as? String,
|
|
21
21
|
let sessionId = config["sessionId"] as? NSNumber,
|
|
22
22
|
let serverZone = config["serverZone"] as? String,
|
|
@@ -62,10 +62,25 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
|
|
|
62
62
|
enableRemoteConfig: enableRemoteConfig
|
|
63
63
|
)
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// Register the primitive, start capture, and resolve in ONE main-thread
|
|
66
|
+
// block: the registry is main-thread-only (setup runs on the RN
|
|
67
|
+
// native-modules queue), and registration must precede start() on the
|
|
68
|
+
// capture (main) thread so an early capture frame can't snapshot
|
|
69
|
+
// SRMaskView children before their masking intents apply.
|
|
70
|
+
// Re-registering on repeated setup() calls is harmless.
|
|
71
|
+
DispatchQueue.main.async {
|
|
72
|
+
// Invalidated (e.g. RN reload) before deferred setup ran — settle
|
|
73
|
+
// the promise so JS init() never hangs.
|
|
74
|
+
guard let sessionReplay = self.sessionReplay else {
|
|
75
|
+
reject("SETUP_ERROR", "Session Replay module was invalidated before setup completed", nil)
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
SRMaskingRegistry.primitive = SRDefaultMaskingPrimitive()
|
|
79
|
+
if (autoStart) {
|
|
80
|
+
sessionReplay.start()
|
|
81
|
+
}
|
|
82
|
+
resolve(nil)
|
|
67
83
|
}
|
|
68
|
-
resolve(nil)
|
|
69
84
|
}
|
|
70
85
|
|
|
71
86
|
@objc(setSessionId:resolve:reject:)
|
|
@@ -127,10 +142,16 @@ class NativeSessionReplay: NSObject, RCTBridgeModule {
|
|
|
127
142
|
|
|
128
143
|
@objc(invalidate)
|
|
129
144
|
func invalidate() {
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
// Serialize teardown with the deferred setup() block on the main queue —
|
|
146
|
+
// a mid-setup invalidate can no longer interleave; stop always runs either
|
|
147
|
+
// before the block (guard rejects) or after start() (normal teardown).
|
|
148
|
+
// Strong self capture is intentional: keep the module alive until teardown runs.
|
|
149
|
+
DispatchQueue.main.async {
|
|
150
|
+
print("invalidate")
|
|
151
|
+
// could be nil here
|
|
152
|
+
self.sessionReplay?.stop()
|
|
153
|
+
self.sessionReplay = nil
|
|
154
|
+
}
|
|
134
155
|
}
|
|
135
156
|
}
|
|
136
157
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AmplitudeSessionReplay
|
|
3
|
+
|
|
4
|
+
/// Default `SRMaskingPrimitive` bridging the masking seam to the Amplitude
|
|
5
|
+
/// Session Replay iOS SDK's existing hook (`UIView.amp_isBlocked`):
|
|
6
|
+
///
|
|
7
|
+
/// - `maskView(_:level:)` — both `"mask"` and `"block"` map to
|
|
8
|
+
/// `amp_isBlocked = true` (the iOS SDK exposes a single blocking hook).
|
|
9
|
+
/// - `unmaskView(_:)` — `amp_isBlocked = false`.
|
|
10
|
+
/// - `resetView(_:)` — `amp_isBlocked = false`. Approximation: the SDK has no
|
|
11
|
+
/// per-view "inherit" reset today; a precise `.none` reset is a documented
|
|
12
|
+
/// fast-follow.
|
|
13
|
+
///
|
|
14
|
+
/// Registered on the main thread at SDK init (`NativeSessionReplay.setup`);
|
|
15
|
+
/// registration replays intents recorded before init, so mount-before-init
|
|
16
|
+
/// masking still applies.
|
|
17
|
+
///
|
|
18
|
+
/// The explicit ObjC name lets the native canaries reach this class via
|
|
19
|
+
/// `NSClassFromString` without new public headers.
|
|
20
|
+
@objc(SRDefaultMaskingPrimitive)
|
|
21
|
+
class SRDefaultMaskingPrimitive: NSObject, SRMaskingPrimitive {
|
|
22
|
+
func maskView(_ view: UIView, level: String) {
|
|
23
|
+
// "mask", "block", and unknown levels all fail safe to blocking.
|
|
24
|
+
view.amp_isBlocked = true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func unmaskView(_ view: UIView) {
|
|
28
|
+
view.amp_isBlocked = false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func resetView(_ view: UIView) {
|
|
32
|
+
view.amp_isBlocked = false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
/// Recorder-agnostic masking primitive. Until a concrete implementation is
|
|
7
|
+
/// registered at SDK init, the registry is inert.
|
|
8
|
+
@protocol SRMaskingPrimitive <NSObject>
|
|
9
|
+
- (void)maskView:(UIView *)view level:(NSString *)level;
|
|
10
|
+
- (void)unmaskView:(UIView *)view;
|
|
11
|
+
/// Return the view to "inherit" — no longer explicitly masked or unmasked.
|
|
12
|
+
- (void)resetView:(UIView *)view;
|
|
13
|
+
@end
|
|
14
|
+
|
|
15
|
+
/// Indirection between the Fabric `SRMaskView` and the concrete masking
|
|
16
|
+
/// primitive. The registry records each live view's masking intent and replays
|
|
17
|
+
/// it when a primitive registers, so views masked before registration are still
|
|
18
|
+
/// applied (without a JS re-render).
|
|
19
|
+
@interface SRMaskingRegistry : NSObject
|
|
20
|
+
@property (class, nonatomic, nullable, strong) id<SRMaskingPrimitive> primitive;
|
|
21
|
+
+ (void)maskView:(UIView *)view level:(NSString *)level;
|
|
22
|
+
+ (void)unmaskView:(UIView *)view;
|
|
23
|
+
+ (void)resetView:(UIView *)view;
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#import "SRMaskingPrimitive.h"
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// A view's recorded masking intent; `level` is only meaningful when `unmask == NO`.
|
|
6
|
+
@interface SRMaskingIntent : NSObject
|
|
7
|
+
@property (nonatomic) BOOL unmask;
|
|
8
|
+
@property (nonatomic, copy, nullable) NSString *level;
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
@implementation SRMaskingIntent
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation SRMaskingRegistry
|
|
15
|
+
|
|
16
|
+
static id<SRMaskingPrimitive> _primitive = nil;
|
|
17
|
+
static BOOL _warnedUnregistered = NO;
|
|
18
|
+
|
|
19
|
+
/// Weak keys let views dealloc naturally. Main-thread-only, so no locking.
|
|
20
|
+
static NSMapTable<UIView *, SRMaskingIntent *> *_intents = nil;
|
|
21
|
+
|
|
22
|
+
+ (NSMapTable<UIView *, SRMaskingIntent *> *)intents
|
|
23
|
+
{
|
|
24
|
+
if (_intents == nil) {
|
|
25
|
+
_intents = [NSMapTable weakToStrongObjectsMapTable];
|
|
26
|
+
}
|
|
27
|
+
return _intents;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (nullable id<SRMaskingPrimitive>)primitive
|
|
31
|
+
{
|
|
32
|
+
return _primitive;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
+ (void)setPrimitive:(nullable id<SRMaskingPrimitive>)primitive
|
|
36
|
+
{
|
|
37
|
+
_primitive = primitive;
|
|
38
|
+
if (primitive == nil) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (UIView *view in [[self intents] keyEnumerator]) {
|
|
42
|
+
SRMaskingIntent *intent = [[self intents] objectForKey:view];
|
|
43
|
+
if (intent == nil) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (intent.unmask) {
|
|
47
|
+
[primitive unmaskView:view];
|
|
48
|
+
} else {
|
|
49
|
+
[primitive maskView:view level:(intent.level ?: @"")];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
+ (void)maskView:(UIView *)view level:(NSString *)level
|
|
55
|
+
{
|
|
56
|
+
SRMaskingIntent *intent = [[SRMaskingIntent alloc] init];
|
|
57
|
+
intent.unmask = NO;
|
|
58
|
+
intent.level = level;
|
|
59
|
+
[[self intents] setObject:intent forKey:view];
|
|
60
|
+
|
|
61
|
+
if (_primitive != nil) {
|
|
62
|
+
[_primitive maskView:view level:level];
|
|
63
|
+
} else {
|
|
64
|
+
[self warnUnregisteredOnce];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
+ (void)unmaskView:(UIView *)view
|
|
69
|
+
{
|
|
70
|
+
SRMaskingIntent *intent = [[SRMaskingIntent alloc] init];
|
|
71
|
+
intent.unmask = YES;
|
|
72
|
+
[[self intents] setObject:intent forKey:view];
|
|
73
|
+
|
|
74
|
+
if (_primitive != nil) {
|
|
75
|
+
[_primitive unmaskView:view];
|
|
76
|
+
} else {
|
|
77
|
+
[self warnUnregisteredOnce];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
+ (void)resetView:(UIView *)view
|
|
82
|
+
{
|
|
83
|
+
[[self intents] removeObjectForKey:view];
|
|
84
|
+
|
|
85
|
+
if (_primitive != nil) {
|
|
86
|
+
[_primitive resetView:view];
|
|
87
|
+
} else {
|
|
88
|
+
[self warnUnregisteredOnce];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
+ (void)warnUnregisteredOnce
|
|
93
|
+
{
|
|
94
|
+
#if DEBUG
|
|
95
|
+
if (!_warnedUnregistered) {
|
|
96
|
+
_warnedUnregistered = YES;
|
|
97
|
+
NSLog(@"[SRMaskingRegistry] No masking primitive registered; masking calls "
|
|
98
|
+
@"are recorded and will replay once a primitive registers.");
|
|
99
|
+
}
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@end
|
|
104
|
+
|
|
105
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#import "SRMaskView.h"
|
|
2
|
+
|
|
3
|
+
#import "../SRMaskingPrimitive.h"
|
|
4
|
+
#import "../../cpp/SRMaskViewComponentDescriptor.h"
|
|
5
|
+
|
|
6
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
7
|
+
|
|
8
|
+
#import <React/RCTComponentViewFactory.h>
|
|
9
|
+
#import <react/renderer/components/AmpSessionReplaySpec/EventEmitters.h>
|
|
10
|
+
#import <react/renderer/components/AmpSessionReplaySpec/Props.h>
|
|
11
|
+
#import <react/renderer/components/AmpSessionReplaySpec/RCTComponentViewHelpers.h>
|
|
12
|
+
|
|
13
|
+
using namespace facebook::react;
|
|
14
|
+
|
|
15
|
+
@interface SRMaskView () <RCTSRMaskViewViewProtocol>
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation SRMaskView {
|
|
19
|
+
BOOL _enabled;
|
|
20
|
+
BOOL _unmask;
|
|
21
|
+
NSString *_maskLevel;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
+ (void)load
|
|
25
|
+
{
|
|
26
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:self];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
30
|
+
{
|
|
31
|
+
if (self = [super initWithFrame:frame]) {
|
|
32
|
+
static const auto defaultProps = std::make_shared<const SRMaskViewProps>();
|
|
33
|
+
_props = defaultProps;
|
|
34
|
+
_enabled = YES;
|
|
35
|
+
_unmask = NO;
|
|
36
|
+
_maskLevel = @"mask";
|
|
37
|
+
self.clipsToBounds = NO;
|
|
38
|
+
}
|
|
39
|
+
return self;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
43
|
+
{
|
|
44
|
+
return concreteComponentDescriptorProvider<SRMaskViewComponentDescriptor>();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
48
|
+
{
|
|
49
|
+
const auto &newViewProps = *std::static_pointer_cast<const SRMaskViewProps>(props);
|
|
50
|
+
|
|
51
|
+
_enabled = newViewProps.enabled;
|
|
52
|
+
_unmask = newViewProps.unmask;
|
|
53
|
+
_maskLevel = [NSString stringWithUTF8String:newViewProps.maskLevel.c_str()];
|
|
54
|
+
|
|
55
|
+
[super updateProps:props oldProps:oldProps];
|
|
56
|
+
[self reapplyMaskingToAllChildren];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
60
|
+
{
|
|
61
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
62
|
+
[self applyMaskingToChild:childComponentView];
|
|
63
|
+
[self expandFrameToChildrenUnion];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
67
|
+
{
|
|
68
|
+
[SRMaskingRegistry resetView:childComponentView];
|
|
69
|
+
[super unmountChildComponentView:childComponentView index:index];
|
|
70
|
+
[self expandFrameToChildrenUnion];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)prepareForRecycle
|
|
74
|
+
{
|
|
75
|
+
for (UIView *subview in self.subviews) {
|
|
76
|
+
[SRMaskingRegistry resetView:subview];
|
|
77
|
+
}
|
|
78
|
+
[super prepareForRecycle];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)reapplyMaskingToAllChildren
|
|
82
|
+
{
|
|
83
|
+
for (UIView *subview in self.subviews) {
|
|
84
|
+
[self applyMaskingToChild:subview];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)applyMaskingToChild:(UIView *)childView
|
|
89
|
+
{
|
|
90
|
+
if (!_enabled) {
|
|
91
|
+
[SRMaskingRegistry resetView:childView];
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (_unmask) {
|
|
96
|
+
[SRMaskingRegistry unmaskView:childView];
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[SRMaskingRegistry maskView:childView level:_maskLevel ?: @"mask"];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#pragma mark - Frame widening (accessibility)
|
|
104
|
+
|
|
105
|
+
// This host is intentionally zero-sized: its Yoga node is display:contents-style
|
|
106
|
+
// layout-transparent, so Fabric assigns it a degenerate (w=0,h=0) frame while the
|
|
107
|
+
// children keep real host-relative frames outside our bounds (clipsToBounds=NO).
|
|
108
|
+
// iOS's accessibility machinery prunes zero-sized views TOGETHER WITH their
|
|
109
|
+
// descendants, which made everything inside <AmpMask>/<AmpUnmask> invisible to
|
|
110
|
+
// VoiceOver/XCUITest/a11y tree dumps. Accessibility-only remedies do not work:
|
|
111
|
+
// overriding -accessibilityFrame and/or -accessibilityElements was verified
|
|
112
|
+
// ineffective on-device — the AX snapshot culls this host by its REAL frame
|
|
113
|
+
// before consulting either API. So mirror the Android fix (SRMaskView.kt
|
|
114
|
+
// expandBoundsToChildrenUnion): widen the host's real frame to enclose its
|
|
115
|
+
// children without ever moving its origin (children are host-relative; moving
|
|
116
|
+
// the origin would shift them on screen). Yoga layout is unaffected (UIKit
|
|
117
|
+
// frames never feed back into Fabric layout), and the widened frame cannot
|
|
118
|
+
// swallow touches because -hitTest:withEvent: below returns nil whenever the
|
|
119
|
+
// host itself would be the target (the iOS analogue of Android's BOX_NONE).
|
|
120
|
+
// Re-widen wherever the degenerate frame can be (re)applied or the children's
|
|
121
|
+
// extent can change: host layout metrics updates, child mount/unmount, and
|
|
122
|
+
// -layoutSubviews (UIKit marks the host as needing layout when a subview's
|
|
123
|
+
// frame changes, which covers child-only Fabric layout transactions).
|
|
124
|
+
- (void)expandFrameToChildrenUnion
|
|
125
|
+
{
|
|
126
|
+
if (self.subviews.count == 0) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
CGFloat maxChildRight = 0;
|
|
131
|
+
CGFloat maxChildBottom = 0;
|
|
132
|
+
for (UIView *child in self.subviews) {
|
|
133
|
+
maxChildRight = MAX(maxChildRight, CGRectGetMaxX(child.frame));
|
|
134
|
+
maxChildBottom = MAX(maxChildBottom, CGRectGetMaxY(child.frame));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Children are host-relative, so the enclosing size is just their max extent.
|
|
138
|
+
// Clamp to a 1pt minimum so a child at fully negative coordinates can never
|
|
139
|
+
// produce a degenerate frame that the accessibility traversal would prune.
|
|
140
|
+
CGSize newSize = CGSizeMake(MAX(maxChildRight, 1), MAX(maxChildBottom, 1));
|
|
141
|
+
CGRect frame = self.frame;
|
|
142
|
+
if (!CGSizeEqualToSize(frame.size, newSize)) {
|
|
143
|
+
frame.size = newSize;
|
|
144
|
+
self.frame = frame;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
149
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
150
|
+
{
|
|
151
|
+
// super re-applies the degenerate Fabric frame; widen right after.
|
|
152
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
153
|
+
[self expandFrameToChildrenUnion];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- (void)layoutSubviews
|
|
157
|
+
{
|
|
158
|
+
[super layoutSubviews];
|
|
159
|
+
[self expandFrameToChildrenUnion];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
163
|
+
{
|
|
164
|
+
UIView *hitView = [super hitTest:point withEvent:event];
|
|
165
|
+
if (hitView == self) {
|
|
166
|
+
return nil;
|
|
167
|
+
}
|
|
168
|
+
return hitView;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@end
|
|
172
|
+
|
|
173
|
+
Class SRMaskViewCls(void)
|
|
174
|
+
{
|
|
175
|
+
return SRMaskView.class;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ampMaskViewMaskProp = ampMaskViewMaskProp;
|
|
7
|
+
/** Masking level for `<AmpMask>`. See {@link MaskProps.maskLevel}. */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Props for `<AmpMask>`, which masks its children in Session Replay
|
|
11
|
+
* recordings without affecting their layout.
|
|
12
|
+
*
|
|
13
|
+
* `style` is not supported: the wrapper is layout-transparent and never
|
|
14
|
+
* carries a layout box of its own, so styles would have no effect.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Props for `<AmpUnmask>`, which exempts its children from masking inside a
|
|
19
|
+
* masked region, without affecting their layout.
|
|
20
|
+
*
|
|
21
|
+
* `style` is not supported: the wrapper is layout-transparent and never
|
|
22
|
+
* carries a layout box of its own, so styles would have no effect.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Maps the public {@link AmpMaskLevel} to the `<AmpMaskView>` `mask` prop value. */
|
|
26
|
+
function ampMaskViewMaskProp(level) {
|
|
27
|
+
return level === 'block' ? 'amp-block' : 'amp-mask';
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Mask.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ampMaskViewMaskProp","level"],"sourceRoot":"../../src","sources":["Mask.types.ts"],"mappings":";;;;;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACO,SAASA,mBAAmBA,CAACC,KAAoB,EAA4B;EAClF,OAAOA,KAAK,KAAK,OAAO,GAAG,WAAW,GAAG,UAAU;AACrD","ignoreList":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AmpUnmask = exports.AmpMask = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _SRMaskViewNativeComponent = _interopRequireDefault(require("../specs/SRMaskViewNativeComponent"));
|
|
10
|
+
var _maskFallback = require("../mask-fallback");
|
|
11
|
+
var _UIManager$hasViewMan, _UIManager$hasViewMan2, _TurboModuleRegistry$;
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
// Three-tier fail-closed probe. We never fall open (unmasked) unless the
|
|
15
|
+
// package's native code is entirely absent — i.e. the recorder itself cannot
|
|
16
|
+
// run and nothing can be captured:
|
|
17
|
+
// 1. SRMaskView registered -> use it directly, layout-transparent.
|
|
18
|
+
// 2. Only the Paper AMPMaskComponentView registered (Fabric sources not
|
|
19
|
+
// built) -> render through <AmpMaskView>: masked, layout-unsafe.
|
|
20
|
+
// 3. Neither registered -> behavior depends on RECORDER_PRESENT below.
|
|
21
|
+
const FABRIC_AVAILABLE = ((_UIManager$hasViewMan = _reactNative.UIManager.hasViewManagerConfig) === null || _UIManager$hasViewMan === void 0 ? void 0 : _UIManager$hasViewMan.call(_reactNative.UIManager, 'SRMaskView')) ?? false;
|
|
22
|
+
const PAPER_MASK_AVAILABLE = ((_UIManager$hasViewMan2 = _reactNative.UIManager.hasViewManagerConfig) === null || _UIManager$hasViewMan2 === void 0 ? void 0 : _UIManager$hasViewMan2.call(_reactNative.UIManager, 'AMPMaskComponentView')) ?? false;
|
|
23
|
+
// Whether the Session Replay native module is linked. Must be resolved the
|
|
24
|
+
// same way src/native-module.ts resolves it (TurboModuleRegistry.get, then the
|
|
25
|
+
// legacy NativeModules interop proxy) so this gate can never disagree with the
|
|
26
|
+
// recorder's actual availability.
|
|
27
|
+
const RECORDER_PRESENT = ((_reactNative.TurboModuleRegistry === null || _reactNative.TurboModuleRegistry === void 0 || (_TurboModuleRegistry$ = _reactNative.TurboModuleRegistry.get) === null || _TurboModuleRegistry$ === void 0 ? void 0 : _TurboModuleRegistry$.call(_reactNative.TurboModuleRegistry, 'AMPNativeSessionReplay')) ?? (_reactNative.NativeModules === null || _reactNative.NativeModules === void 0 ? void 0 : _reactNative.NativeModules.AMPNativeSessionReplay)) != null;
|
|
28
|
+
const contents = {
|
|
29
|
+
display: 'contents'
|
|
30
|
+
}; // zero-box hint; C++ adopt() is authoritative
|
|
31
|
+
|
|
32
|
+
function MaskImpl({
|
|
33
|
+
enabled = true,
|
|
34
|
+
maskLevel = 'mask',
|
|
35
|
+
children,
|
|
36
|
+
...vp
|
|
37
|
+
}) {
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_SRMaskViewNativeComponent.default, _extends({}, vp, {
|
|
39
|
+
enabled: enabled,
|
|
40
|
+
unmask: false,
|
|
41
|
+
maskLevel: maskLevel,
|
|
42
|
+
style: contents
|
|
43
|
+
}), children);
|
|
44
|
+
}
|
|
45
|
+
function UnmaskImpl({
|
|
46
|
+
children,
|
|
47
|
+
...vp
|
|
48
|
+
}) {
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_SRMaskViewNativeComponent.default, _extends({}, vp, {
|
|
50
|
+
enabled: true,
|
|
51
|
+
unmask: true,
|
|
52
|
+
maskLevel: "mask",
|
|
53
|
+
style: contents
|
|
54
|
+
}), children);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Tier 2: masked but not layout-transparent. `enabled` is intentionally
|
|
58
|
+
// ignored (over-mask), matching the Old-Arch prod fallback in MaskPaper.
|
|
59
|
+
const FALLBACK_WARNING = '[AmpMask] New Architecture detected but the native SRMaskView component is unavailable — falling back to <AmpMaskView> (content stays MASKED but layout transparency is lost). Verify the Fabric masking sources were built (new architecture + RN >= 0.77) and codegen ran. Note: Fabric without bridgeless (bridge mode) cannot detect SRMaskView on iOS and always uses this fallback.';
|
|
60
|
+
const FallbackMask = (0, _maskFallback.createAmpMaskViewFallback)({
|
|
61
|
+
mask: 'from-maskLevel',
|
|
62
|
+
warning: FALLBACK_WARNING
|
|
63
|
+
});
|
|
64
|
+
const FallbackUnmask = (0, _maskFallback.createAmpMaskViewFallback)({
|
|
65
|
+
mask: 'amp-unmask',
|
|
66
|
+
warning: FALLBACK_WARNING
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Tier 3: no masking-capable native view exists, so children render directly.
|
|
70
|
+
// Safe only when the recorder is absent too (nothing can be captured); when
|
|
71
|
+
// the recorder IS present this is a build error we must not infer our way
|
|
72
|
+
// past — throw in dev, warn loudly in prod.
|
|
73
|
+
const UNMASKED_WARNING = '[AmpMask] New Architecture detected but the native SRMaskView component is unavailable — <AmpMask>/<AmpUnmask> render children UNMASKED. Verify the Fabric masking sources were built (new architecture + RN >= 0.77) and codegen ran.';
|
|
74
|
+
const UNMASKABLE_MSG = '<AmpMask> cannot mask: the Session Replay native module is present but neither SRMaskView nor AMPMaskComponentView is registered. Fix the build before shipping.';
|
|
75
|
+
const UNMASKABLE_WARNING = '[AmpMask] The Session Replay native module is present but neither SRMaskView nor AMPMaskComponentView is registered — <AmpMask>/<AmpUnmask> render children UNMASKED. This is a build error (not an expected environment) — fix the build before shipping.';
|
|
76
|
+
function createPassthrough(warning, devThrowMessage) {
|
|
77
|
+
return function PassthroughChildren({
|
|
78
|
+
children
|
|
79
|
+
}) {
|
|
80
|
+
if (devThrowMessage !== undefined && __DEV__) {
|
|
81
|
+
throw new Error(devThrowMessage);
|
|
82
|
+
}
|
|
83
|
+
(0, _maskFallback.warnOnce)(warning);
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const Passthrough = createPassthrough(UNMASKED_WARNING);
|
|
88
|
+
const UnmaskableGuard = createPassthrough(UNMASKABLE_WARNING, UNMASKABLE_MSG);
|
|
89
|
+
const NeitherAvailable = RECORDER_PRESENT ? UnmaskableGuard : Passthrough;
|
|
90
|
+
const AmpMask = exports.AmpMask = FABRIC_AVAILABLE ? MaskImpl : PAPER_MASK_AVAILABLE ? FallbackMask : NeitherAvailable;
|
|
91
|
+
const AmpUnmask = exports.AmpUnmask = FABRIC_AVAILABLE ? UnmaskImpl : PAPER_MASK_AVAILABLE ? FallbackUnmask : NeitherAvailable;
|
|
92
|
+
//# sourceMappingURL=MaskFabric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_SRMaskViewNativeComponent","_maskFallback","_UIManager$hasViewMan","_UIManager$hasViewMan2","_TurboModuleRegistry$","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","FABRIC_AVAILABLE","UIManager","hasViewManagerConfig","PAPER_MASK_AVAILABLE","RECORDER_PRESENT","TurboModuleRegistry","get","NativeModules","AMPNativeSessionReplay","contents","display","MaskImpl","enabled","maskLevel","children","vp","createElement","unmask","style","UnmaskImpl","FALLBACK_WARNING","FallbackMask","createAmpMaskViewFallback","mask","warning","FallbackUnmask","UNMASKED_WARNING","UNMASKABLE_MSG","UNMASKABLE_WARNING","createPassthrough","devThrowMessage","PassthroughChildren","undefined","__DEV__","Error","warnOnce","Fragment","Passthrough","UnmaskableGuard","NeitherAvailable","AmpMask","exports","AmpUnmask"],"sourceRoot":"../../../src","sources":["fabric/MaskFabric.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAAuE,IAAAI,qBAAA,EAAAC,sBAAA,EAAAC,qBAAA;AAAA,SAAAP,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,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,QAAW,CAAC;EACxB,CAAC;AACH;AACA,MAAMuB,WAAW,GAAGR,iBAAiB,CAACH,gBAAgB,CAAC;AACvD,MAAMY,eAAe,GAAGT,iBAAiB,CAACD,kBAAkB,EAAED,cAAc,CAAC;AAE7E,MAAMY,gBAAgB,GAAGnC,gBAAgB,GAAGkC,eAAe,GAAGD,WAAW;AAElE,MAAMG,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAGxC,gBAAgB,GAAGW,QAAQ,GAAGR,oBAAoB,GAAGkB,YAAY,GAAGkB,gBAAgB;AACpG,MAAMG,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG1C,gBAAgB,GAAGmB,UAAU,GAAGhB,oBAAoB,GAAGsB,cAAc,GAAGc,gBAAgB","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.AmpMask = void 0;
|
|
6
7
|
Object.defineProperty(exports, "AmpMaskView", {
|
|
7
8
|
enumerable: true,
|
|
8
9
|
get: function () {
|
|
9
10
|
return _ampMaskView.AmpMaskView;
|
|
10
11
|
}
|
|
11
12
|
});
|
|
13
|
+
exports.AmpUnmask = void 0;
|
|
12
14
|
Object.defineProperty(exports, "SessionReplayPlugin", {
|
|
13
15
|
enumerable: true,
|
|
14
16
|
get: function () {
|
|
@@ -66,4 +68,21 @@ Object.defineProperty(exports, "stop", {
|
|
|
66
68
|
var _sessionReplay = require("./session-replay");
|
|
67
69
|
var _pluginSessionReplay = require("./plugin-session-replay");
|
|
68
70
|
var _ampMaskView = require("./amp-mask-view");
|
|
71
|
+
const g = global;
|
|
72
|
+
const isNewArch = g.RN$Bridgeless === true || g.nativeFabricUIManager != null;
|
|
73
|
+
/**
|
|
74
|
+
* Layout-transparent Session Replay masking.
|
|
75
|
+
* `<AmpMask>` masks its children; `<AmpUnmask>` exempts children inside a masked region.
|
|
76
|
+
* Requires the New Architecture (React Native >= 0.77). On the Old Architecture:
|
|
77
|
+
* throws in dev, falls back to `<AmpMaskView>` (masked but layout-unsafe) in prod.
|
|
78
|
+
* @experimental Subject to change while experimental.
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
|
|
81
|
+
const {
|
|
82
|
+
AmpMask,
|
|
83
|
+
AmpUnmask
|
|
84
|
+
} = isNewArch ? require('./fabric/MaskFabric') : require('./paper/MaskPaper');
|
|
85
|
+
// Named AmpMaskLevel because `MaskLevel` is already exported from './session-replay-config'.
|
|
86
|
+
exports.AmpUnmask = AmpUnmask;
|
|
87
|
+
exports.AmpMask = AmpMask;
|
|
69
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_sessionReplay","require","_pluginSessionReplay","_ampMaskView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_sessionReplay","require","_pluginSessionReplay","_ampMaskView","g","global","isNewArch","RN$Bridgeless","nativeFabricUIManager","AmpMask","AmpUnmask","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAYA,IAAAC,oBAAA,GAAAD,OAAA;AAGA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,CAAC,GAAGC,MAAiF;AAC3F,MAAMC,SAAS,GAAGF,CAAC,CAACG,aAAa,KAAK,IAAI,IAAIH,CAAC,CAACI,qBAAqB,IAAI,IAAI;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM;EAAEC,OAAO;EAAEC;AAAwF,CAAC,GAC/GJ,SAAS,GAAGL,OAAO,CAAC,qBAAqB,CAAC,GAAGA,OAAO,CAAC,mBAAmB,CAAC;AAC3E;AAAAU,OAAA,CAAAD,SAAA,GAAAA,SAAA;AAAAC,OAAA,CAAAF,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAmpMaskViewFallback = createAmpMaskViewFallback;
|
|
7
|
+
exports.warnOnce = warnOnce;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _ampMaskView = require("./amp-mask-view");
|
|
10
|
+
var _Mask = require("./Mask.types");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
|
+
let warned = false;
|
|
14
|
+
|
|
15
|
+
/** Logs at most one degraded-masking error per app session, across all fallback paths. */
|
|
16
|
+
function warnOnce(message) {
|
|
17
|
+
if (!warned) {
|
|
18
|
+
warned = true;
|
|
19
|
+
console.error(message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds an `<AmpMask>`/`<AmpUnmask>` stand-in that renders through the Paper
|
|
24
|
+
* `<AmpMaskView>`: privacy-safe (content stays masked) but not
|
|
25
|
+
* layout-transparent. Used when the Fabric `SRMaskView` isn't available —
|
|
26
|
+
* Old-Architecture apps and New-Architecture build misconfigurations.
|
|
27
|
+
*
|
|
28
|
+
* Fail-closed rules, enforced at runtime because untyped callers can spread
|
|
29
|
+
* arbitrary props even though the public types omit them:
|
|
30
|
+
* `style`/`enabled`/`mask` are stripped, and the forced `mask` value is
|
|
31
|
+
* applied after the caller's props so it can never be overridden.
|
|
32
|
+
*/
|
|
33
|
+
function createAmpMaskViewFallback(options) {
|
|
34
|
+
return function AmpMaskViewFallback(props) {
|
|
35
|
+
if (options.devThrowMessage !== undefined && __DEV__) {
|
|
36
|
+
throw new Error(options.devThrowMessage);
|
|
37
|
+
}
|
|
38
|
+
warnOnce(options.warning);
|
|
39
|
+
const {
|
|
40
|
+
children,
|
|
41
|
+
maskLevel,
|
|
42
|
+
style: _style,
|
|
43
|
+
enabled: _enabled,
|
|
44
|
+
mask: _mask,
|
|
45
|
+
...safeProps
|
|
46
|
+
} = props;
|
|
47
|
+
const mask = options.mask === 'amp-unmask' ? 'amp-unmask' : (0, _Mask.ampMaskViewMaskProp)(maskLevel);
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_ampMaskView.AmpMaskView, _extends({}, safeProps, {
|
|
49
|
+
mask: mask
|
|
50
|
+
}), children);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=mask-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_ampMaskView","_Mask","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","warned","warnOnce","message","console","error","createAmpMaskViewFallback","options","AmpMaskViewFallback","props","devThrowMessage","undefined","__DEV__","Error","warning","children","maskLevel","style","_style","enabled","_enabled","mask","_mask","safeProps","ampMaskViewMaskProp","createElement","AmpMaskView"],"sourceRoot":"../../src","sources":["mask-fallback.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAmD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAA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