@truewatchtech/react-native-session-replay 0.4.1

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.
Files changed (130) hide show
  1. package/FTSessionReplayReactNative.podspec +50 -0
  2. package/README.md +33 -0
  3. package/android/build.gradle +228 -0
  4. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  6. package/android/gradle.properties +4 -0
  7. package/android/gradlew +185 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/settings.gradle +1 -0
  10. package/android/src/main/AndroidManifest.xml +4 -0
  11. package/android/src/main/AndroidManifestNew.xml +3 -0
  12. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/FTSessionReplayImpl.java +119 -0
  13. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/NoopTextPropertiesResolver.java +23 -0
  14. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ReactNativeSessionReplayExtensionSupport.java +57 -0
  15. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/ShadowNodeWrapper.java +84 -0
  16. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/TextPropertiesResolver.java +20 -0
  17. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/extensions/ReactDrawablesExt.java +155 -0
  18. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/DefaultMapper.java +78 -0
  19. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/Pair.java +11 -0
  20. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactEditTextMapper.java +136 -0
  21. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactNativeImageViewMapper.java +117 -0
  22. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactTextMapper.java +57 -0
  23. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewGroupMapper.java +22 -0
  24. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/mappers/ReactViewModalMapper.java +21 -0
  25. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/resources/ReactDrawableCopier.java +35 -0
  26. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ColorUtils.java +24 -0
  27. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/DrawableUtils.java +34 -0
  28. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactNativeUtils.java +18 -0
  29. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/ReflectionUtils.java +43 -0
  30. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/FabricTextViewUtils.java +69 -0
  31. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/LegacyTextViewUtils.java +97 -0
  32. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/utils/text/TextViewUtils.java +184 -0
  33. package/android/src/main/java/com/ft/sdk/reactnative/sessionreplay/views/FTPrivacyView.java +113 -0
  34. package/android/src/newarch/java/com/ft/sdk/reactnative/sessionreplay/FTSessionReplayModule.java +20 -0
  35. package/android/src/newarch/java/com/ft/sdk/reactnative/sessionreplay/views/FTPrivacyViewManager.java +87 -0
  36. package/android/src/oldarch/java/com/ft/sdk/reactnative/sessionreplay/FTSessionReplayModule.java +25 -0
  37. package/android/src/oldarch/java/com/ft/sdk/reactnative/sessionreplay/views/FTPrivacyViewManager.java +70 -0
  38. package/android/src/rn69/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +100 -0
  39. package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +27 -0
  40. package/android/src/rn75/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +116 -0
  41. package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +38 -0
  42. package/android/src/rn76/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +117 -0
  43. package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/extensions/LengthPercentageExt.java +38 -0
  44. package/android/src/rn79/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +132 -0
  45. package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/extensions/ComputedBorderRadiusExt.java +58 -0
  46. package/android/src/rn80/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +190 -0
  47. package/android/src/rnlegacy/java/com/ft/sdk/reactnative/sessionreplay/utils/ReactViewBackgroundDrawableUtils.java +120 -0
  48. package/android/src/rnpost74/java/com/ft/sdk/reactnative/sessionreplay/FTSessionReplayPackage.java +58 -0
  49. package/android/src/rnpre74/java/com/ft/sdk/reactnative/sessionreplay/FTSessionReplayPackage.java +30 -0
  50. package/ios/FTPrivacyViewFabric.h +22 -0
  51. package/ios/FTPrivacyViewFabric.mm +84 -0
  52. package/ios/FTPrivacyViewPaper.h +17 -0
  53. package/ios/FTPrivacyViewPaper.mm +85 -0
  54. package/ios/FTRCTFabricWrapper.h +13 -0
  55. package/ios/FTRCTFabricWrapper.mm +113 -0
  56. package/ios/FTRCTTextPropertiesWrapper.h +24 -0
  57. package/ios/FTRCTTextPropertiesWrapper.mm +28 -0
  58. package/ios/FTRCTTextViewRecorder.h +33 -0
  59. package/ios/FTRCTTextViewRecorder.m +172 -0
  60. package/ios/FTReactNativeSessionReplay.h +13 -0
  61. package/ios/FTReactNativeSessionReplay.mm +85 -0
  62. package/ios/FTSessionReplayReactNative.xcodeproj/project.pbxproj +304 -0
  63. package/lib/commonjs/components/SessionReplayView/HideView.js +19 -0
  64. package/lib/commonjs/components/SessionReplayView/HideView.js.map +1 -0
  65. package/lib/commonjs/components/SessionReplayView/MaskAllView.js +25 -0
  66. package/lib/commonjs/components/SessionReplayView/MaskAllView.js.map +1 -0
  67. package/lib/commonjs/components/SessionReplayView/MaskNoneView.js +23 -0
  68. package/lib/commonjs/components/SessionReplayView/MaskNoneView.js.map +1 -0
  69. package/lib/commonjs/components/SessionReplayView/PrivacyView.js +28 -0
  70. package/lib/commonjs/components/SessionReplayView/PrivacyView.js.map +1 -0
  71. package/lib/commonjs/components/SessionReplayView/index.js +29 -0
  72. package/lib/commonjs/components/SessionReplayView/index.js.map +1 -0
  73. package/lib/commonjs/ft_session_replay.js +69 -0
  74. package/lib/commonjs/ft_session_replay.js.map +1 -0
  75. package/lib/commonjs/index.js +50 -0
  76. package/lib/commonjs/index.js.map +1 -0
  77. package/lib/commonjs/specs/FTPrivacyViewNative.js +29 -0
  78. package/lib/commonjs/specs/FTPrivacyViewNative.js.map +1 -0
  79. package/lib/commonjs/specs/FTPrivacyViewNativeComponent.js +10 -0
  80. package/lib/commonjs/specs/FTPrivacyViewNativeComponent.js.map +1 -0
  81. package/lib/commonjs/specs/NativeFTReactNativeSessionReplay.js +10 -0
  82. package/lib/commonjs/specs/NativeFTReactNativeSessionReplay.js.map +1 -0
  83. package/lib/commonjs/types.js +6 -0
  84. package/lib/commonjs/types.js.map +1 -0
  85. package/lib/module/components/SessionReplayView/HideView.js +12 -0
  86. package/lib/module/components/SessionReplayView/HideView.js.map +1 -0
  87. package/lib/module/components/SessionReplayView/MaskAllView.js +18 -0
  88. package/lib/module/components/SessionReplayView/MaskAllView.js.map +1 -0
  89. package/lib/module/components/SessionReplayView/MaskNoneView.js +16 -0
  90. package/lib/module/components/SessionReplayView/MaskNoneView.js.map +1 -0
  91. package/lib/module/components/SessionReplayView/PrivacyView.js +21 -0
  92. package/lib/module/components/SessionReplayView/PrivacyView.js.map +1 -0
  93. package/lib/module/components/SessionReplayView/index.js +23 -0
  94. package/lib/module/components/SessionReplayView/index.js.map +1 -0
  95. package/lib/module/ft_session_replay.js +67 -0
  96. package/lib/module/ft_session_replay.js.map +1 -0
  97. package/lib/module/index.js +4 -0
  98. package/lib/module/index.js.map +1 -0
  99. package/lib/module/specs/FTPrivacyViewNative.js +24 -0
  100. package/lib/module/specs/FTPrivacyViewNative.js.map +1 -0
  101. package/lib/module/specs/FTPrivacyViewNativeComponent.js +3 -0
  102. package/lib/module/specs/FTPrivacyViewNativeComponent.js.map +1 -0
  103. package/lib/module/specs/NativeFTReactNativeSessionReplay.js +5 -0
  104. package/lib/module/specs/NativeFTReactNativeSessionReplay.js.map +1 -0
  105. package/lib/module/types.js +2 -0
  106. package/lib/module/types.js.map +1 -0
  107. package/lib/typescript/components/SessionReplayView/HideView.d.ts +7 -0
  108. package/lib/typescript/components/SessionReplayView/MaskAllView.d.ts +8 -0
  109. package/lib/typescript/components/SessionReplayView/MaskNoneView.d.ts +7 -0
  110. package/lib/typescript/components/SessionReplayView/PrivacyView.d.ts +12 -0
  111. package/lib/typescript/components/SessionReplayView/index.d.ts +22 -0
  112. package/lib/typescript/ft_session_replay.d.ts +61 -0
  113. package/lib/typescript/index.d.ts +3 -0
  114. package/lib/typescript/specs/FTPrivacyViewNative.d.ts +2 -0
  115. package/lib/typescript/specs/FTPrivacyViewNativeComponent.d.ts +10 -0
  116. package/lib/typescript/specs/NativeFTReactNativeSessionReplay.d.ts +11 -0
  117. package/lib/typescript/types.d.ts +8 -0
  118. package/package.json +97 -0
  119. package/scripts/set-ios-rn-version.js +47 -0
  120. package/src/components/SessionReplayView/HideView.tsx +15 -0
  121. package/src/components/SessionReplayView/MaskAllView.tsx +35 -0
  122. package/src/components/SessionReplayView/MaskNoneView.tsx +26 -0
  123. package/src/components/SessionReplayView/PrivacyView.tsx +40 -0
  124. package/src/components/SessionReplayView/index.ts +26 -0
  125. package/src/ft_session_replay.tsx +78 -0
  126. package/src/index.tsx +19 -0
  127. package/src/specs/FTPrivacyViewNative.ts +32 -0
  128. package/src/specs/FTPrivacyViewNativeComponent.ts +14 -0
  129. package/src/specs/NativeFTReactNativeSessionReplay.ts +13 -0
  130. package/src/types.ts +9 -0
@@ -0,0 +1,120 @@
1
+ package com.ft.sdk.reactnative.sessionreplay.utils;
2
+
3
+ import android.graphics.Color;
4
+ import android.graphics.drawable.Drawable;
5
+ import android.graphics.drawable.InsetDrawable;
6
+ import android.graphics.drawable.LayerDrawable;
7
+
8
+ import com.ft.sdk.reactnative.sessionreplay.mappers.Pair;
9
+ import com.ft.sdk.reactnative.sessionreplay.utils.ColorUtils;
10
+ import com.facebook.react.uimanager.Spacing;
11
+ import com.facebook.react.views.view.ReactViewBackgroundDrawable;
12
+ import com.ft.sdk.sessionreplay.model.ShapeBorder;
13
+ import com.ft.sdk.sessionreplay.model.ShapeStyle;
14
+
15
+ public class ReactViewBackgroundDrawableUtils extends DrawableUtils {
16
+ private static final String COLOR_FIELD_NAME = "mColor";
17
+ private static final String BORDER_RGB_FIELD_NAME = "mBorderRGB";
18
+ private static final String BORDER_ALPHA_FIELD_NAME = "mBorderAlpha";
19
+ private static final int DEFAULT_BORDER_RGB = 0x00FFFFFF & Color.BLACK;
20
+ private static final int DEFAULT_BORDER_ALPHA = -0x1000000 & Color.BLACK;
21
+ private final ReflectionUtils reflectionUtils;
22
+
23
+ public ReactViewBackgroundDrawableUtils() {
24
+ this(new ReflectionUtils());
25
+ }
26
+
27
+ public ReactViewBackgroundDrawableUtils(ReflectionUtils reflectionUtils) {
28
+ this.reflectionUtils = reflectionUtils;
29
+ }
30
+
31
+ @Override
32
+ public Pair<ShapeStyle, ShapeBorder> resolveShapeAndBorder(
33
+ Drawable drawable,
34
+ float opacity,
35
+ float pixelDensity
36
+ ) {
37
+ if (!(drawable instanceof ReactViewBackgroundDrawable)) {
38
+ return new Pair<>(null, null);
39
+ }
40
+ ReactViewBackgroundDrawable bgDrawable = (ReactViewBackgroundDrawable) drawable;
41
+ ShapeBorder borderProps = resolveBorder(bgDrawable, pixelDensity);
42
+ long cornerRadius = (long) (bgDrawable.getFullBorderRadius() / pixelDensity);
43
+ Integer backgroundColor = getBackgroundColor(bgDrawable);
44
+ String colorHexString;
45
+ if (backgroundColor != null) {
46
+ colorHexString = ColorUtils.formatAsRgba(backgroundColor);
47
+ } else {
48
+ return new Pair<>(null, borderProps);
49
+ }
50
+ return new Pair<>(
51
+ new ShapeStyle(
52
+ colorHexString,
53
+ opacity,
54
+ cornerRadius
55
+ ),
56
+ borderProps
57
+ );
58
+ }
59
+
60
+ @Override
61
+ public Drawable getReactBackgroundFromDrawable(Drawable drawable) {
62
+ if (drawable instanceof ReactViewBackgroundDrawable) {
63
+ return drawable;
64
+ } else if (drawable instanceof InsetDrawable) {
65
+ return getReactBackgroundFromDrawable(((InsetDrawable) drawable).getDrawable());
66
+ } else if (drawable instanceof LayerDrawable) {
67
+ return getDrawableFromLayerDrawable((LayerDrawable) drawable);
68
+ } else {
69
+ return null;
70
+ }
71
+ }
72
+
73
+ private Drawable getDrawableFromLayerDrawable(LayerDrawable layerDrawable) {
74
+ for (int layerNumber = 0; layerNumber < layerDrawable.getNumberOfLayers(); layerNumber++) {
75
+ Drawable layer = layerDrawable.getDrawable(layerNumber);
76
+ if (layer instanceof ReactViewBackgroundDrawable) {
77
+ return layer;
78
+ }
79
+ }
80
+ return null;
81
+ }
82
+
83
+ private ShapeBorder resolveBorder(
84
+ ReactViewBackgroundDrawable backgroundDrawable,
85
+ float pixelDensity
86
+ ) {
87
+ long borderWidth = (long) (backgroundDrawable.getFullBorderWidth() / pixelDensity);
88
+ int borderColorInt = getBorderColor(backgroundDrawable);
89
+ String borderColor = ColorUtils.formatAsRgba(borderColorInt);
90
+ return new ShapeBorder(
91
+ borderColor,
92
+ borderWidth
93
+ );
94
+ }
95
+
96
+ private int getBorderColor(ReactViewBackgroundDrawable backgroundDrawable) {
97
+ Spacing borderRgb = (Spacing) reflectionUtils.getDeclaredField(
98
+ backgroundDrawable,
99
+ BORDER_RGB_FIELD_NAME
100
+ );
101
+ Spacing borderAlpha = (Spacing) reflectionUtils.getDeclaredField(
102
+ backgroundDrawable,
103
+ BORDER_ALPHA_FIELD_NAME
104
+ );
105
+ float rgb = borderRgb != null ? borderRgb.get(Spacing.ALL) : DEFAULT_BORDER_RGB;
106
+ float alpha = borderAlpha != null ? borderAlpha.get(Spacing.ALL) : DEFAULT_BORDER_ALPHA;
107
+ int rgbComponent = 0x00FFFFFF & (int) rgb;
108
+ int alphaComponent = -0x1000000 & ((int) alpha << 24);
109
+ return rgbComponent | alphaComponent;
110
+ }
111
+
112
+ private Integer getBackgroundColor(ReactViewBackgroundDrawable backgroundDrawable) {
113
+ Object value = reflectionUtils.getDeclaredField(
114
+ backgroundDrawable,
115
+ COLOR_FIELD_NAME
116
+ );
117
+ return value instanceof Integer ? (Integer) value : null;
118
+ }
119
+
120
+ }
@@ -0,0 +1,58 @@
1
+ package com.ft.sdk.reactnative.sessionreplay;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import com.facebook.react.BaseReactPackage;
7
+ import com.facebook.react.bridge.NativeModule;
8
+ import com.facebook.react.bridge.ReactApplicationContext;
9
+ import com.facebook.react.module.model.ReactModuleInfo;
10
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
11
+ import com.facebook.react.uimanager.ViewManager;
12
+ import com.ft.sdk.reactnative.sessionreplay.views.FTPrivacyViewManager;
13
+
14
+ import java.util.Collections;
15
+ import java.util.HashMap;
16
+ import java.util.List;
17
+ import java.util.Map;
18
+
19
+ public class FTSessionReplayPackage extends BaseReactPackage {
20
+
21
+ @Nullable
22
+ @Override
23
+ public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactApplicationContext) {
24
+ if (FTSessionReplayImpl.NAME.equals(name)) {
25
+ return new FTSessionReplayModule(reactApplicationContext);
26
+ }
27
+ return null;
28
+ }
29
+
30
+ @Override
31
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
32
+ return new ReactModuleInfoProvider() {
33
+ @Override
34
+ public Map<String, ReactModuleInfo> getReactModuleInfos() {
35
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
36
+ Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
37
+ moduleInfos.put(
38
+ FTSessionReplayImpl.NAME,
39
+ new ReactModuleInfo(
40
+ FTSessionReplayImpl.NAME,
41
+ FTSessionReplayImpl.NAME,
42
+ false,
43
+ false,
44
+ false,
45
+ isTurboModule
46
+ )
47
+ );
48
+ return moduleInfos;
49
+ }
50
+ };
51
+ }
52
+
53
+ @NonNull
54
+ @Override
55
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactApplicationContext) {
56
+ return Collections.singletonList(new FTPrivacyViewManager(reactApplicationContext));
57
+ }
58
+ }
@@ -0,0 +1,30 @@
1
+ package com.ft.sdk.reactnative.sessionreplay;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.uimanager.ViewManager;
9
+ import com.ft.sdk.reactnative.sessionreplay.views.FTPrivacyViewManager;
10
+
11
+ import java.util.ArrayList;
12
+ import java.util.List;
13
+
14
+ public class FTSessionReplayPackage implements ReactPackage {
15
+
16
+ @Override
17
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
18
+ List<NativeModule> modules = new ArrayList<>();
19
+ modules.add(new FTSessionReplayModule(reactContext));
20
+ return modules;
21
+ }
22
+
23
+ @NonNull
24
+ @Override
25
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactApplicationContext) {
26
+ List<ViewManager> viewManagers = new ArrayList<>();
27
+ viewManagers.add(new FTPrivacyViewManager(reactApplicationContext));
28
+ return viewManagers;
29
+ }
30
+ }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ #if RCT_NEW_ARCH_ENABLED
8
+ #import <React/RCTViewComponentView.h>
9
+ #import <react/renderer/components/FTSessionReplayReactNative/ComponentDescriptors.h>
10
+ #import <react/renderer/components/FTSessionReplayReactNative/EventEmitters.h>
11
+ #import <react/renderer/components/FTSessionReplayReactNative/Props.h>
12
+ #import <react/renderer/components/FTSessionReplayReactNative/RCTComponentViewHelpers.h>
13
+ #import <React/RCTFabricComponentsPlugins.h>
14
+ NS_ASSUME_NONNULL_BEGIN
15
+
16
+ @interface FTPrivacyViewFabric : RCTViewComponentView
17
+ @property (nonatomic, copy) NSString *nativeID;
18
+
19
+ @end
20
+
21
+ NS_ASSUME_NONNULL_END
22
+ #endif
@@ -0,0 +1,84 @@
1
+ /*
2
+ *
3
+ * * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
4
+ * * This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ * * Copyright 2016-Present Datadog, Inc.
6
+ *
7
+ */
8
+ #if RCT_NEW_ARCH_ENABLED
9
+ #import <react/renderer/components/FTSessionReplayReactNative/ComponentDescriptors.h>
10
+ #import <react/renderer/components/FTSessionReplayReactNative/EventEmitters.h>
11
+ #import <react/renderer/components/FTSessionReplayReactNative/Props.h>
12
+ #import <react/renderer/components/FTSessionReplayReactNative/RCTComponentViewHelpers.h>
13
+ #import <React/RCTFabricComponentsPlugins.h>
14
+
15
+ #import "FTPrivacyViewFabric.h"
16
+ #import <objc/runtime.h>
17
+ #import <FTMobileSDK/FTSessionReplayPrivacyOverrides.h>
18
+ #import <FTMobileSDK/UIView+FTSRPrivacy.h>
19
+ #import <FTMobileSDK/FTSessionReplayPrivacyOverrides+Extension.h>
20
+ using namespace facebook::react;
21
+
22
+ @implementation FTPrivacyViewFabric
23
+
24
+ + (ComponentDescriptorProvider)componentDescriptorProvider
25
+ {
26
+ return concreteComponentDescriptorProvider<FTPrivacyViewComponentDescriptor>();
27
+ }
28
+
29
+ - (instancetype)init {
30
+ if (self = [super init]) {
31
+ static const auto defaultProps = std::make_shared<FTPrivacyViewProps const>();
32
+ _props = defaultProps;
33
+ }
34
+ return self;
35
+ }
36
+
37
+ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps {
38
+ const auto &newProps = *std::static_pointer_cast<FTPrivacyViewProps const>(props);
39
+
40
+ NSString *textAndInputPrivacy = [NSString stringWithUTF8String:newProps.textAndInputPrivacy.c_str()];
41
+ if (textAndInputPrivacy.length > 0) {
42
+ if ([textAndInputPrivacy isEqualToString:@"MASK_SENSITIVE_INPUTS"]) {
43
+ self.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @0;
44
+ } else if ([textAndInputPrivacy isEqualToString:@"MASK_ALL_INPUTS"]) {
45
+ self.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @1;
46
+ } else if ([textAndInputPrivacy isEqualToString:@"MASK_ALL"]) {
47
+ self.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @2;
48
+ }
49
+ }
50
+
51
+
52
+ NSString *imagePrivacy = [NSString stringWithUTF8String:newProps.imagePrivacy.c_str()];
53
+ if (imagePrivacy.length > 0) {
54
+ if ([imagePrivacy isEqualToString:@"MASK_NON_BUNDLED_ONLY"]) {
55
+ self.sessionReplayPrivacyOverrides.nImagePrivacy = @0;
56
+ } else if ([imagePrivacy isEqualToString:@"MASK_ALL"]) {
57
+ self.sessionReplayPrivacyOverrides.nImagePrivacy = @1;
58
+ } else if ([imagePrivacy isEqualToString:@"MASK_NONE"]) {
59
+ self.sessionReplayPrivacyOverrides.nImagePrivacy = @2;
60
+ }
61
+ }
62
+
63
+
64
+ NSString *touchPrivacy = [NSString stringWithUTF8String:newProps.touchPrivacy.c_str()];
65
+ if (touchPrivacy.length > 0) {
66
+ if ([touchPrivacy isEqualToString:@"SHOW"]) {
67
+ self.sessionReplayPrivacyOverrides.nTouchPrivacy = @0;
68
+ } else if ([touchPrivacy isEqualToString:@"HIDE"]) {
69
+ self.sessionReplayPrivacyOverrides.nTouchPrivacy = @1;
70
+ }
71
+ }
72
+
73
+ self.sessionReplayPrivacyOverrides.hide = newProps.hide;
74
+ NSString *nativeID = [NSString stringWithUTF8String:newProps.nativeID.c_str()];
75
+ self.nativeID = nativeID;
76
+ [super updateProps:props oldProps:oldProps];
77
+ }
78
+
79
+ Class<RCTComponentViewProtocol> FTPrivacyViewCls(void)
80
+ {
81
+ return FTPrivacyViewFabric.class;
82
+ }
83
+ @end
84
+ #endif
@@ -0,0 +1,17 @@
1
+ //
2
+ // FTPrivacyViewPaper.h
3
+ // FtMobileAgent
4
+ //
5
+ // Created by hulilei on 2026/4/1.
6
+ // Copyright © 2026 Facebook. All rights reserved.
7
+ //
8
+ #import <React/RCTViewManager.h>
9
+ #import <UIKit/UIKit.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface FTPrivacyViewPaper : RCTViewManager
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,85 @@
1
+ /*
2
+ *
3
+ * * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
4
+ * * This product includes software developed at Datadog (https://www.datadoghq.com/).
5
+ * * Copyright 2016-Present Datadog, Inc.
6
+ *
7
+ */
8
+ #import "FTPrivacyViewPaper.h"
9
+ #import <FTMobileSDK/FTSessionReplayPrivacyOverrides.h>
10
+ #import <FTMobileSDK/UIView+FTSRPrivacy.h>
11
+ #import <FTMobileSDK/FTSessionReplayPrivacyOverrides+Extension.h>
12
+
13
+ @interface FTPrivacyView : UIView
14
+
15
+ @property (nonatomic, copy) NSString *textPrivacy;
16
+ @property (nonatomic, copy) NSString *imagePrivacy;
17
+ @property (nonatomic, copy) NSString *touchPrivacy;
18
+ @property (nonatomic, assign) BOOL hide;
19
+ @property (nonatomic, copy) NSString *nativeID;
20
+ @end
21
+
22
+ @implementation FTPrivacyView
23
+ @end
24
+
25
+ @implementation FTPrivacyViewPaper
26
+
27
+ RCT_EXPORT_MODULE(FTPrivacyView)
28
+
29
+ - (UIView *)view {
30
+ return [[FTPrivacyView alloc] init];
31
+ }
32
+
33
+ RCT_CUSTOM_VIEW_PROPERTY(textAndInputPrivacy, NSString, FTPrivacyView) {
34
+ NSString *value = [RCTConvert NSString:json];
35
+ view.textPrivacy = value;
36
+ if (value.length > 0) {
37
+ if ([value isEqualToString:@"MASK_SENSITIVE_INPUTS"]) {
38
+ view.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @0;
39
+ } else if ([value isEqualToString:@"MASK_ALL_INPUTS"]) {
40
+ view.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @1;
41
+ } else if ([value isEqualToString:@"MASK_ALL"]) {
42
+ view.sessionReplayPrivacyOverrides.nTextAndInputPrivacy = @2;
43
+ }
44
+ }
45
+ }
46
+
47
+ RCT_CUSTOM_VIEW_PROPERTY(imagePrivacy, NSString, FTPrivacyView) {
48
+ NSString *value = [RCTConvert NSString:json];
49
+ view.imagePrivacy = value;
50
+ if (value.length > 0) {
51
+ if ([value isEqualToString:@"MASK_NON_BUNDLED_ONLY"]) {
52
+ view.sessionReplayPrivacyOverrides.nImagePrivacy = @0;
53
+ } else if ([value isEqualToString:@"MASK_ALL"]) {
54
+ view.sessionReplayPrivacyOverrides.nImagePrivacy = @1;
55
+ } else if ([value isEqualToString:@"MASK_NONE"]) {
56
+ view.sessionReplayPrivacyOverrides.nImagePrivacy = @2;
57
+ }
58
+ }
59
+ }
60
+
61
+ RCT_CUSTOM_VIEW_PROPERTY(touchPrivacy, NSString, FTPrivacyView) {
62
+ NSString *value = [RCTConvert NSString:json];
63
+ view.touchPrivacy = value;
64
+ if (value.length > 0) {
65
+ if ([value isEqualToString:@"SHOW"]) {
66
+ view.sessionReplayPrivacyOverrides.nTouchPrivacy = @0;
67
+ } else if ([value isEqualToString:@"HIDE"]) {
68
+ view.sessionReplayPrivacyOverrides.nTouchPrivacy = @1;
69
+ }
70
+ }
71
+ }
72
+
73
+ RCT_CUSTOM_VIEW_PROPERTY(hide, BOOL, FTPrivacyView) {
74
+ if (json) {
75
+ BOOL value = [json boolValue];
76
+ view.hide = value;
77
+ view.sessionReplayPrivacyOverrides.hide = value;
78
+ }
79
+ }
80
+
81
+ RCT_CUSTOM_VIEW_PROPERTY(nativeID, NSString, FTPrivacyView) {
82
+ view.nativeID = [RCTConvert NSString:json];
83
+ }
84
+
85
+ @end
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ #import <Foundation/Foundation.h>
7
+ #import "FTRCTTextPropertiesWrapper.h"
8
+
9
+ @interface FTRCTFabricWrapper : NSObject
10
+
11
+ - (nullable FTRCTTextPropertiesWrapper*)tryToExtractTextPropertiesFromView:(UIView* _Nonnull)view;
12
+
13
+ @end
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ #import "FTRCTFabricWrapper.h"
8
+
9
+ #if RCT_NEW_ARCH_ENABLED
10
+ #import "RCTVersion.h"
11
+ #import "RCTParagraphComponentView.h"
12
+ #import "RCTConversions.h"
13
+ #import "ParagraphProps.h"
14
+
15
+ namespace rct = facebook::react;
16
+ #endif
17
+
18
+ @implementation FTRCTFabricWrapper
19
+ /**
20
+ * Extracts the text properties from the given UIView when the view is of type RCTParagraphComponentView, returns nil otherwise.
21
+ */
22
+ - (nullable FTRCTTextPropertiesWrapper*)tryToExtractTextPropertiesFromView:(UIView *)view {
23
+ #if RCT_NEW_ARCH_ENABLED
24
+ if (![view isKindOfClass:[RCTParagraphComponentView class]]) {
25
+ return nil;
26
+ }
27
+
28
+ // Cast view to RCTParagraphComponentView
29
+ RCTParagraphComponentView* paragraphComponentView = (RCTParagraphComponentView *)view;
30
+ if (paragraphComponentView == nil) {
31
+ return nil;
32
+ }
33
+
34
+ // Retrieve ParagraphProps from shared pointer
35
+ const rct::ParagraphProps* props = (rct::ParagraphProps*)paragraphComponentView.props.get();
36
+ if (props == nil) {
37
+ return nil;
38
+ }
39
+
40
+ // Extract Attributes
41
+ FTRCTTextPropertiesWrapper* textPropertiesWrapper = [[FTRCTTextPropertiesWrapper alloc] init];
42
+ textPropertiesWrapper.text = [FTRCTFabricWrapper getTextFromView:paragraphComponentView];
43
+ textPropertiesWrapper.contentRect = paragraphComponentView.bounds;
44
+
45
+ rct::TextAttributes textAttributes = props->textAttributes;
46
+ textPropertiesWrapper.alignment = [FTRCTFabricWrapper getAlignmentFromAttributes:textAttributes];
47
+ textPropertiesWrapper.foregroundColor = [FTRCTFabricWrapper getForegroundColorFromAttributes:textAttributes];
48
+ textPropertiesWrapper.fontSize = [FTRCTFabricWrapper getFontSizeFromAttributes:textAttributes];
49
+
50
+ return textPropertiesWrapper;
51
+ #else
52
+ return nil;
53
+ #endif
54
+ }
55
+
56
+ #if RCT_NEW_ARCH_ENABLED
57
+ + (NSString* _Nonnull)getTextFromView:(RCTParagraphComponentView*)view {
58
+ if (view == nil || view.attributedText == nil) {
59
+ return RCTTextPropertiesDefaultText;
60
+ }
61
+
62
+ return view.attributedText.string;
63
+ }
64
+
65
+ + (NSTextAlignment)getAlignmentFromAttributes:(rct::TextAttributes)textAttributes {
66
+ const rct::TextAlignment alignment = textAttributes.alignment.has_value() ?
67
+ textAttributes.alignment.value() :
68
+ rct::TextAlignment::Natural;
69
+
70
+ switch (alignment) {
71
+ case rct::TextAlignment::Natural:
72
+ return NSTextAlignmentNatural;
73
+
74
+ case rct::TextAlignment::Left:
75
+ return NSTextAlignmentLeft;
76
+
77
+ case rct::TextAlignment::Center:
78
+ return NSTextAlignmentCenter;
79
+
80
+ case rct::TextAlignment::Right:
81
+ return NSTextAlignmentRight;
82
+
83
+ case rct::TextAlignment::Justified:
84
+ return NSTextAlignmentJustified;
85
+
86
+ default:
87
+ return RCTTextPropertiesDefaultAlignment;
88
+ }
89
+ }
90
+
91
+ + (UIColor* _Nonnull)getForegroundColorFromAttributes:(rct::TextAttributes)textAttributes {
92
+ @try {
93
+ #if RCT_VERSION_MINOR > 73
94
+ rct::Color color = *textAttributes.foregroundColor;
95
+ UIColor* uiColor = (__bridge UIColor*)color.getUIColor().get();
96
+ if (uiColor != nil) {
97
+ return uiColor;
98
+ }
99
+ #else
100
+ return RCTUIColorFromSharedColor(textAttributes.foregroundColor);
101
+ #endif
102
+ } @catch (NSException *exception) {}
103
+
104
+ return RCTTextPropertiesDefaultForegroundColor;
105
+ }
106
+
107
+ + (CGFloat)getFontSizeFromAttributes:(rct::TextAttributes)textAttributes {
108
+ // Float is just an alias for CGFloat, but this could change in the future.
109
+ _Static_assert(sizeof(rct::Float) == sizeof(CGFloat), "Float and CGFloat are expected to have the same size.");
110
+ return isnan(textAttributes.fontSize) ? RCTTextPropertiesDefaultFontSize : (CGFloat)textAttributes.fontSize;
111
+ }
112
+ #endif
113
+ @end
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ NS_ASSUME_NONNULL_BEGIN
7
+ @interface FTRCTTextPropertiesWrapper : NSObject
8
+
9
+ extern NSString* const RCTTextPropertiesDefaultText;
10
+ extern NSTextAlignment const RCTTextPropertiesDefaultAlignment;
11
+ extern UIColor* const RCTTextPropertiesDefaultForegroundColor;
12
+ extern CGFloat const RCTTextPropertiesDefaultFontSize;
13
+ extern CGRect const RCTTextPropertiesDefaultContentRect;
14
+
15
+ @property (nonatomic, strong, nonnull) NSString* text;
16
+ @property (nonatomic, assign) NSTextAlignment alignment;
17
+ @property (nonatomic, strong, nonnull) UIColor* foregroundColor;
18
+ @property (nonatomic, assign) CGFloat fontSize;
19
+ @property (nonatomic, assign) CGRect contentRect;
20
+
21
+ - (instancetype _Nonnull) init;
22
+
23
+ @end
24
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ #import "FTRCTTextPropertiesWrapper.h"
7
+
8
+ @implementation FTRCTTextPropertiesWrapper
9
+
10
+ NSString* const RCTTextPropertiesDefaultText = @"";
11
+ NSTextAlignment const RCTTextPropertiesDefaultAlignment = NSTextAlignmentNatural;
12
+ UIColor* const RCTTextPropertiesDefaultForegroundColor = [UIColor blackColor];
13
+ CGFloat const RCTTextPropertiesDefaultFontSize = 14.0;
14
+ CGRect const RCTTextPropertiesDefaultContentRect = CGRectZero;
15
+
16
+ - (instancetype)init {
17
+ self = [super init];
18
+ if (self) {
19
+ _text = RCTTextPropertiesDefaultText;
20
+ _alignment = RCTTextPropertiesDefaultAlignment;
21
+ _foregroundColor = RCTTextPropertiesDefaultForegroundColor;
22
+ _fontSize = RCTTextPropertiesDefaultFontSize;
23
+ _contentRect = RCTTextPropertiesDefaultContentRect;
24
+ }
25
+ return self;
26
+ }
27
+
28
+ @end
@@ -0,0 +1,33 @@
1
+ //
2
+ // FTRCTTextViewRecorder.h
3
+ // FTMobileReactNativeSDK
4
+ //
5
+ // Created by hulilei on 2024/9/25.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <FTMobileSDK/FTSRNodeWireframesBuilder.h>
10
+ #import <React/RCTUIManager.h>
11
+ @class FTViewAttributes,FTViewTreeRecorder;
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ @interface FTRCTTextViewBuilder : NSObject<FTSRNodeWireframesBuilder>
15
+ @property (nonatomic, strong) FTViewAttributes *attributes;
16
+ @property (nonatomic, assign) CGRect wireframeRect;
17
+ @property (nonatomic, assign) int64_t wireframeID;
18
+ @property (nonatomic, strong) UIColor * backgroundColor;
19
+ @property (nonatomic, assign) NSTextAlignment textAlignment;
20
+ @property (nonatomic, strong) UIColor *textColor;
21
+ @property (nonatomic, assign) CGFloat fontSize;
22
+ @property (nonatomic, assign) CGRect contentRect;
23
+ @property (nonatomic, strong) id<FTSRTextObfuscatingProtocol> textObfuscator;
24
+
25
+ @property (nonatomic, copy) NSString *text;
26
+ @end
27
+
28
+ @interface FTRCTTextViewRecorder : NSObject<FTSRWireframesRecorder>
29
+ @property (nonatomic, copy) NSString *identifier;
30
+ @property (nonatomic,copy) FTTextObfuscator textObfuscator;
31
+ -(instancetype)initWithUIManager:(RCTUIManager *)uiManager;
32
+ @end
33
+ NS_ASSUME_NONNULL_END