@amplitude/session-replay-react-native 0.1.0-beta.2 → 0.1.0-beta.3

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 (84) hide show
  1. package/AmplitudeSessionReplayReactNative.podspec +2 -43
  2. package/README.md +3 -113
  3. package/android/build.gradle +19 -127
  4. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativeModule.kt +5 -35
  5. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/SessionReplayReactNativePackage.kt +4 -2
  6. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/AmpMaskViewManager.kt +48 -0
  7. package/ios/AmpMaskApplier.h +22 -0
  8. package/ios/AmpMaskApplier.m +21 -0
  9. package/ios/NativeSessionReplay.swift +8 -29
  10. package/ios/fabric/AMPMaskComponentView.h +17 -0
  11. package/ios/fabric/AMPMaskComponentView.mm +78 -0
  12. package/lib/commonjs/amp-mask-view.js +9 -2
  13. package/lib/commonjs/amp-mask-view.js.map +1 -1
  14. package/lib/commonjs/index.js +0 -19
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/specs/{SRMaskViewNativeComponent.js → AmpMaskViewNativeComponent.js} +7 -2
  17. package/lib/commonjs/specs/AmpMaskViewNativeComponent.js.map +1 -0
  18. package/lib/commonjs/version.js +1 -1
  19. package/lib/module/amp-mask-view.js +8 -2
  20. package/lib/module/amp-mask-view.js.map +1 -1
  21. package/lib/module/index.js +0 -15
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/specs/AmpMaskViewNativeComponent.js +10 -0
  24. package/lib/module/specs/AmpMaskViewNativeComponent.js.map +1 -0
  25. package/lib/module/version.js +1 -1
  26. package/lib/typescript/amp-mask-view.d.ts +4 -4
  27. package/lib/typescript/amp-mask-view.d.ts.map +1 -1
  28. package/lib/typescript/index.d.ts +1 -12
  29. package/lib/typescript/index.d.ts.map +1 -1
  30. package/lib/typescript/specs/{SRMaskViewNativeComponent.d.ts → AmpMaskViewNativeComponent.d.ts} +2 -4
  31. package/lib/typescript/specs/AmpMaskViewNativeComponent.d.ts.map +1 -0
  32. package/lib/typescript/version.d.ts +1 -1
  33. package/package.json +2 -2
  34. package/src/amp-mask-view.tsx +11 -3
  35. package/src/index.tsx +1 -19
  36. package/src/specs/AmpMaskViewNativeComponent.ts +17 -0
  37. package/src/version.ts +1 -1
  38. package/android/src/androidTest/java/com/amplitude/sessionreplayreactnative/SRMaskViewTest.kt +0 -459
  39. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRDefaultMaskingPrimitive.kt +0 -36
  40. package/android/src/main/java/com/amplitude/sessionreplayreactnative/SRMaskingPrimitive.kt +0 -84
  41. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskView.kt +0 -174
  42. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewManager.kt +0 -44
  43. package/android/src/newarch/java/com/amplitude/sessionreplayreactnative/fabric/SRMaskViewPointerEvents.java +0 -36
  44. package/cpp/SRMaskViewComponentDescriptor.h +0 -20
  45. package/cpp/SRMaskViewShadowNode.cpp +0 -54
  46. package/cpp/SRMaskViewShadowNode.h +0 -56
  47. package/ios/SRDefaultMaskingPrimitive.swift +0 -34
  48. package/ios/SRMaskingPrimitive.h +0 -26
  49. package/ios/SRMaskingRegistry.m +0 -105
  50. package/ios/fabric/SRMaskView.h +0 -10
  51. package/ios/fabric/SRMaskView.mm +0 -178
  52. package/lib/commonjs/Mask.types.js +0 -29
  53. package/lib/commonjs/Mask.types.js.map +0 -1
  54. package/lib/commonjs/fabric/MaskFabric.js +0 -92
  55. package/lib/commonjs/fabric/MaskFabric.js.map +0 -1
  56. package/lib/commonjs/mask-fallback.js +0 -53
  57. package/lib/commonjs/mask-fallback.js.map +0 -1
  58. package/lib/commonjs/paper/MaskPaper.js +0 -27
  59. package/lib/commonjs/paper/MaskPaper.js.map +0 -1
  60. package/lib/commonjs/specs/SRMaskViewNativeComponent.js.map +0 -1
  61. package/lib/module/Mask.types.js +0 -23
  62. package/lib/module/Mask.types.js.map +0 -1
  63. package/lib/module/fabric/MaskFabric.js +0 -85
  64. package/lib/module/fabric/MaskFabric.js.map +0 -1
  65. package/lib/module/mask-fallback.js +0 -45
  66. package/lib/module/mask-fallback.js.map +0 -1
  67. package/lib/module/paper/MaskPaper.js +0 -21
  68. package/lib/module/paper/MaskPaper.js.map +0 -1
  69. package/lib/module/specs/SRMaskViewNativeComponent.js +0 -5
  70. package/lib/module/specs/SRMaskViewNativeComponent.js.map +0 -1
  71. package/lib/typescript/Mask.types.d.ts +0 -38
  72. package/lib/typescript/Mask.types.d.ts.map +0 -1
  73. package/lib/typescript/fabric/MaskFabric.d.ts +0 -8
  74. package/lib/typescript/fabric/MaskFabric.d.ts.map +0 -1
  75. package/lib/typescript/mask-fallback.d.ts +0 -27
  76. package/lib/typescript/mask-fallback.d.ts.map +0 -1
  77. package/lib/typescript/paper/MaskPaper.d.ts +0 -10
  78. package/lib/typescript/paper/MaskPaper.d.ts.map +0 -1
  79. package/lib/typescript/specs/SRMaskViewNativeComponent.d.ts.map +0 -1
  80. package/src/Mask.types.ts +0 -45
  81. package/src/fabric/MaskFabric.tsx +0 -73
  82. package/src/mask-fallback.tsx +0 -60
  83. package/src/paper/MaskPaper.tsx +0 -24
  84. package/src/specs/SRMaskViewNativeComponent.ts +0 -12
@@ -1,38 +0,0 @@
1
- import type { ViewProps } from 'react-native';
2
- import type { ReactNode } from 'react';
3
- /** Masking level for `<AmpMask>`. See {@link MaskProps.maskLevel}. */
4
- export type AmpMaskLevel = 'mask' | 'block';
5
- /**
6
- * Props for `<AmpMask>`, which masks its children in Session Replay
7
- * recordings without affecting their layout.
8
- *
9
- * `style` is not supported: the wrapper is layout-transparent and never
10
- * carries a layout box of its own, so styles would have no effect.
11
- */
12
- export interface MaskProps extends Omit<ViewProps, 'style'> {
13
- /**
14
- * When false, children are rendered without masking.
15
- * @default true
16
- */
17
- enabled?: boolean;
18
- /**
19
- * Masking level applied to children. On iOS, 'mask' and 'block' currently
20
- * behave identically (both fully block).
21
- * @default 'mask'
22
- */
23
- maskLevel?: AmpMaskLevel;
24
- children?: ReactNode;
25
- }
26
- /**
27
- * Props for `<AmpUnmask>`, which exempts its children from masking inside a
28
- * masked region, without affecting their layout.
29
- *
30
- * `style` is not supported: the wrapper is layout-transparent and never
31
- * carries a layout box of its own, so styles would have no effect.
32
- */
33
- export interface UnmaskProps extends Omit<ViewProps, 'style'> {
34
- children?: ReactNode;
35
- }
36
- /** Maps the public {@link AmpMaskLevel} to the `<AmpMaskView>` `mask` prop value. */
37
- export declare function ampMaskViewMaskProp(level?: AmpMaskLevel): 'amp-mask' | 'amp-block';
38
- //# sourceMappingURL=Mask.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Mask.types.d.ts","sourceRoot":"","sources":["../../src/Mask.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IACzD;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IAEzB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IAC3D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,WAAW,CAElF"}
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import type { MaskProps, UnmaskProps } from '../Mask.types';
3
- declare function MaskImpl({ enabled, maskLevel, children, ...vp }: MaskProps): React.JSX.Element;
4
- declare function UnmaskImpl({ children, ...vp }: UnmaskProps): React.JSX.Element;
5
- export declare const AmpMask: typeof MaskImpl;
6
- export declare const AmpUnmask: typeof UnmaskImpl;
7
- export {};
8
- //# sourceMappingURL=MaskFabric.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MaskFabric.d.ts","sourceRoot":"","sources":["../../../src/fabric/MaskFabric.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAoB5D,iBAAS,QAAQ,CAAC,EAAE,OAAc,EAAE,SAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,qBAMnF;AACD,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,WAAW,qBAMnD;AAkCD,eAAO,MAAM,OAAO,iBAAuF,CAAC;AAC5G,eAAO,MAAM,SAAS,mBAA2F,CAAC"}
@@ -1,27 +0,0 @@
1
- import type { ReactElement, ReactNode } from 'react';
2
- /** Logs at most one degraded-masking error per app session, across all fallback paths. */
3
- export declare function warnOnce(message: string): void;
4
- interface FallbackOptions {
5
- /** `mask` value forced onto `<AmpMaskView>`; 'from-maskLevel' derives it from the caller's `maskLevel` prop. */
6
- mask: 'amp-unmask' | 'from-maskLevel';
7
- /** Passed to {@link warnOnce} on every render. */
8
- warning: string;
9
- /** When set, dev builds throw this instead of rendering the fallback. */
10
- devThrowMessage?: string;
11
- }
12
- /**
13
- * Builds an `<AmpMask>`/`<AmpUnmask>` stand-in that renders through the Paper
14
- * `<AmpMaskView>`: privacy-safe (content stays masked) but not
15
- * layout-transparent. Used when the Fabric `SRMaskView` isn't available —
16
- * Old-Architecture apps and New-Architecture build misconfigurations.
17
- *
18
- * Fail-closed rules, enforced at runtime because untyped callers can spread
19
- * arbitrary props even though the public types omit them:
20
- * `style`/`enabled`/`mask` are stripped, and the forced `mask` value is
21
- * applied after the caller's props so it can never be overridden.
22
- */
23
- export declare function createAmpMaskViewFallback<P extends {
24
- children?: ReactNode;
25
- }>(options: FallbackOptions): (props: P) => ReactElement;
26
- export {};
27
- //# sourceMappingURL=mask-fallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mask-fallback.d.ts","sourceRoot":"","sources":["../../src/mask-fallback.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOrD,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,QAKvC;AAED,UAAU,eAAe;IACvB,gHAAgH;IAChH,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAAC;IACtC,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAC1E,OAAO,EAAE,eAAe,GACvB,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAqB5B"}
@@ -1,10 +0,0 @@
1
- import type { MaskProps, UnmaskProps } from '../Mask.types';
2
- /**
3
- * Old-Architecture guard: dev builds throw (the developer is using an
4
- * unsupported component); production falls back to `<AmpMaskView>` —
5
- * privacy-safe but layout-unsafe. `enabled` is ignored: the fallback fails
6
- * toward privacy.
7
- */
8
- export declare const AmpMask: (props: MaskProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
9
- export declare const AmpUnmask: (props: UnmaskProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
10
- //# sourceMappingURL=MaskPaper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MaskPaper.d.ts","sourceRoot":"","sources":["../../../src/paper/MaskPaper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAM5D;;;;;GAKG;AACH,eAAO,MAAM,OAAO,8GAIlB,CAAC;AAEH,eAAO,MAAM,SAAS,gHAIpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SRMaskViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/specs/SRMaskViewNativeComponent.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAG7E,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;;AAED,wBAAiE"}
package/src/Mask.types.ts DELETED
@@ -1,45 +0,0 @@
1
- import type { ViewProps } from 'react-native';
2
- import type { ReactNode } from 'react';
3
-
4
- /** Masking level for `<AmpMask>`. See {@link MaskProps.maskLevel}. */
5
- export type AmpMaskLevel = 'mask' | 'block';
6
-
7
- /**
8
- * Props for `<AmpMask>`, which masks its children in Session Replay
9
- * recordings without affecting their layout.
10
- *
11
- * `style` is not supported: the wrapper is layout-transparent and never
12
- * carries a layout box of its own, so styles would have no effect.
13
- */
14
- export interface MaskProps extends Omit<ViewProps, 'style'> {
15
- /**
16
- * When false, children are rendered without masking.
17
- * @default true
18
- */
19
- enabled?: boolean;
20
-
21
- /**
22
- * Masking level applied to children. On iOS, 'mask' and 'block' currently
23
- * behave identically (both fully block).
24
- * @default 'mask'
25
- */
26
- maskLevel?: AmpMaskLevel;
27
-
28
- children?: ReactNode;
29
- }
30
-
31
- /**
32
- * Props for `<AmpUnmask>`, which exempts its children from masking inside a
33
- * masked region, without affecting their layout.
34
- *
35
- * `style` is not supported: the wrapper is layout-transparent and never
36
- * carries a layout box of its own, so styles would have no effect.
37
- */
38
- export interface UnmaskProps extends Omit<ViewProps, 'style'> {
39
- children?: ReactNode;
40
- }
41
-
42
- /** Maps the public {@link AmpMaskLevel} to the `<AmpMaskView>` `mask` prop value. */
43
- export function ampMaskViewMaskProp(level?: AmpMaskLevel): 'amp-mask' | 'amp-block' {
44
- return level === 'block' ? 'amp-block' : 'amp-mask';
45
- }
@@ -1,73 +0,0 @@
1
- import React from 'react';
2
- import { NativeModules, TurboModuleRegistry, UIManager } from 'react-native';
3
- import SRMaskViewNative from '../specs/SRMaskViewNativeComponent';
4
- import { createAmpMaskViewFallback, warnOnce } from '../mask-fallback';
5
- import type { MaskProps, UnmaskProps } from '../Mask.types';
6
-
7
- // Three-tier fail-closed probe. We never fall open (unmasked) unless the
8
- // package's native code is entirely absent — i.e. the recorder itself cannot
9
- // run and nothing can be captured:
10
- // 1. SRMaskView registered -> use it directly, layout-transparent.
11
- // 2. Only the Paper AMPMaskComponentView registered (Fabric sources not
12
- // built) -> render through <AmpMaskView>: masked, layout-unsafe.
13
- // 3. Neither registered -> behavior depends on RECORDER_PRESENT below.
14
- const FABRIC_AVAILABLE = UIManager.hasViewManagerConfig?.('SRMaskView') ?? false;
15
- const PAPER_MASK_AVAILABLE = UIManager.hasViewManagerConfig?.('AMPMaskComponentView') ?? false;
16
- // Whether the Session Replay native module is linked. Must be resolved the
17
- // same way src/native-module.ts resolves it (TurboModuleRegistry.get, then the
18
- // legacy NativeModules interop proxy) so this gate can never disagree with the
19
- // recorder's actual availability.
20
- const RECORDER_PRESENT =
21
- (TurboModuleRegistry?.get?.('AMPNativeSessionReplay') ?? NativeModules?.AMPNativeSessionReplay) != null;
22
-
23
- const contents = { display: 'contents' as unknown as 'flex' }; // zero-box hint; C++ adopt() is authoritative
24
-
25
- function MaskImpl({ enabled = true, maskLevel = 'mask', children, ...vp }: MaskProps) {
26
- return (
27
- <SRMaskViewNative {...vp} enabled={enabled} unmask={false} maskLevel={maskLevel} style={contents}>
28
- {children}
29
- </SRMaskViewNative>
30
- );
31
- }
32
- function UnmaskImpl({ children, ...vp }: UnmaskProps) {
33
- return (
34
- <SRMaskViewNative {...vp} enabled unmask maskLevel="mask" style={contents}>
35
- {children}
36
- </SRMaskViewNative>
37
- );
38
- }
39
-
40
- // Tier 2: masked but not layout-transparent. `enabled` is intentionally
41
- // ignored (over-mask), matching the Old-Arch prod fallback in MaskPaper.
42
- const FALLBACK_WARNING =
43
- '[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.';
44
- const FallbackMask = createAmpMaskViewFallback<MaskProps>({ mask: 'from-maskLevel', warning: FALLBACK_WARNING });
45
- const FallbackUnmask = createAmpMaskViewFallback<UnmaskProps>({ mask: 'amp-unmask', warning: FALLBACK_WARNING });
46
-
47
- // Tier 3: no masking-capable native view exists, so children render directly.
48
- // Safe only when the recorder is absent too (nothing can be captured); when
49
- // the recorder IS present this is a build error we must not infer our way
50
- // past — throw in dev, warn loudly in prod.
51
- const UNMASKED_WARNING =
52
- '[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.';
53
- const UNMASKABLE_MSG =
54
- '<AmpMask> cannot mask: the Session Replay native module is present but neither SRMaskView nor AMPMaskComponentView is registered. Fix the build before shipping.';
55
- const UNMASKABLE_WARNING =
56
- '[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.';
57
-
58
- function createPassthrough(warning: string, devThrowMessage?: string) {
59
- return function PassthroughChildren({ children }: { children?: React.ReactNode }) {
60
- if (devThrowMessage !== undefined && __DEV__) {
61
- throw new Error(devThrowMessage);
62
- }
63
- warnOnce(warning);
64
- return <>{children}</>;
65
- };
66
- }
67
- const Passthrough = createPassthrough(UNMASKED_WARNING);
68
- const UnmaskableGuard = createPassthrough(UNMASKABLE_WARNING, UNMASKABLE_MSG);
69
-
70
- const NeitherAvailable = RECORDER_PRESENT ? UnmaskableGuard : Passthrough;
71
-
72
- export const AmpMask = FABRIC_AVAILABLE ? MaskImpl : PAPER_MASK_AVAILABLE ? FallbackMask : NeitherAvailable;
73
- export const AmpUnmask = FABRIC_AVAILABLE ? UnmaskImpl : PAPER_MASK_AVAILABLE ? FallbackUnmask : NeitherAvailable;
@@ -1,60 +0,0 @@
1
- import React from 'react';
2
- import type { ReactElement, ReactNode } from 'react';
3
- import { AmpMaskView } from './amp-mask-view';
4
- import { ampMaskViewMaskProp } from './Mask.types';
5
- import type { AmpMaskLevel } from './Mask.types';
6
-
7
- let warned = false;
8
-
9
- /** Logs at most one degraded-masking error per app session, across all fallback paths. */
10
- export function warnOnce(message: string) {
11
- if (!warned) {
12
- warned = true;
13
- console.error(message);
14
- }
15
- }
16
-
17
- interface FallbackOptions {
18
- /** `mask` value forced onto `<AmpMaskView>`; 'from-maskLevel' derives it from the caller's `maskLevel` prop. */
19
- mask: 'amp-unmask' | 'from-maskLevel';
20
- /** Passed to {@link warnOnce} on every render. */
21
- warning: string;
22
- /** When set, dev builds throw this instead of rendering the fallback. */
23
- devThrowMessage?: string;
24
- }
25
-
26
- /**
27
- * Builds an `<AmpMask>`/`<AmpUnmask>` stand-in that renders through the Paper
28
- * `<AmpMaskView>`: privacy-safe (content stays masked) but not
29
- * layout-transparent. Used when the Fabric `SRMaskView` isn't available —
30
- * Old-Architecture apps and New-Architecture build misconfigurations.
31
- *
32
- * Fail-closed rules, enforced at runtime because untyped callers can spread
33
- * arbitrary props even though the public types omit them:
34
- * `style`/`enabled`/`mask` are stripped, and the forced `mask` value is
35
- * applied after the caller's props so it can never be overridden.
36
- */
37
- export function createAmpMaskViewFallback<P extends { children?: ReactNode }>(
38
- options: FallbackOptions,
39
- ): (props: P) => ReactElement {
40
- return function AmpMaskViewFallback(props: P) {
41
- if (options.devThrowMessage !== undefined && __DEV__) {
42
- throw new Error(options.devThrowMessage);
43
- }
44
- warnOnce(options.warning);
45
- const {
46
- children,
47
- maskLevel,
48
- style: _style,
49
- enabled: _enabled,
50
- mask: _mask,
51
- ...safeProps
52
- } = props as P & { maskLevel?: AmpMaskLevel; style?: unknown; enabled?: boolean; mask?: unknown };
53
- const mask = options.mask === 'amp-unmask' ? 'amp-unmask' : ampMaskViewMaskProp(maskLevel);
54
- return (
55
- <AmpMaskView {...safeProps} mask={mask}>
56
- {children}
57
- </AmpMaskView>
58
- );
59
- };
60
- }
@@ -1,24 +0,0 @@
1
- import { createAmpMaskViewFallback } from '../mask-fallback';
2
- import type { MaskProps, UnmaskProps } from '../Mask.types';
3
-
4
- const MSG = '<AmpMask> requires the New Architecture. Use <AmpMaskView> on the Old Architecture.';
5
- const WARNING =
6
- '[AmpMask] Old Architecture detected — falling back to AmpMaskView (layout-unsafe). Use <AmpMaskView> on Old Arch.';
7
-
8
- /**
9
- * Old-Architecture guard: dev builds throw (the developer is using an
10
- * unsupported component); production falls back to `<AmpMaskView>` —
11
- * privacy-safe but layout-unsafe. `enabled` is ignored: the fallback fails
12
- * toward privacy.
13
- */
14
- export const AmpMask = createAmpMaskViewFallback<MaskProps>({
15
- mask: 'from-maskLevel',
16
- warning: WARNING,
17
- devThrowMessage: MSG,
18
- });
19
-
20
- export const AmpUnmask = createAmpMaskViewFallback<UnmaskProps>({
21
- mask: 'amp-unmask',
22
- warning: WARNING,
23
- devThrowMessage: MSG,
24
- });
@@ -1,12 +0,0 @@
1
- /* eslint-disable import/namespace, import/default, import/no-named-as-default, import/no-named-as-default-member */
2
- import type { ViewProps } from 'react-native';
3
- import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
4
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
5
-
6
- export interface NativeProps extends ViewProps {
7
- enabled?: WithDefault<boolean, true>;
8
- unmask?: WithDefault<boolean, false>;
9
- maskLevel?: WithDefault<string, 'mask'>;
10
- }
11
-
12
- export default codegenNativeComponent<NativeProps>('SRMaskView');