Skip to content

Commit

Permalink
fix old RN builds, remove ts from shipped package
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Nov 23, 2024
1 parent 414590c commit eb457fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 7 additions & 1 deletion packages/core/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
!react-native.config.js
!/ios/**/*
!/android/**/*
!src/**/*

# New Architecture Codegen
!src/js/NativeRNSentry.ts
!src/js/RNSentryReplayMaskNativeComponent.ts
!src/js/RNSentryReplayUnmaskNativeComponent.ts

# Scripts
!scripts/collect-modules.sh
!scripts/copy-debugid.js
!scripts/has-sourcemap-debugid.js
Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"typescript": {
"definition": "dist/js/index.d.ts"
},
"react-native": "src/js/index.ts",
"main": "dist/js/index.js",
"scripts": {
"build": "npx run-s build:sdk downlevel build:tools build:plugin",
Expand Down
15 changes: 11 additions & 4 deletions packages/core/src/js/replay/CustomMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import * as React from 'react';
import type { HostComponent, ViewProps } from 'react-native';
import { UIManager, View } from 'react-native';

const NativeComponentRegistry: {
get<T, C extends Record<string, unknown>>(componentName: string, createViewConfig: () => C): HostComponent<T>;
// eslint-disable-next-line @typescript-eslint/no-var-requires
} = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');

const MaskNativeComponentName = 'RNSentryReplayMask';
const UnmaskNativeComponentName = 'RNSentryReplayUnmask';

Expand Down Expand Up @@ -35,8 +40,9 @@ const Mask = ((): HostComponent<ViewProps> | React.ComponentType<ViewProps> => {
return MaskFallback;
}

// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
return require('../RNSentryReplayMaskNativeComponent').default;
return NativeComponentRegistry.get(MaskNativeComponentName, () => ({
uiViewClassName: MaskNativeComponentName,
}));
})()

const Unmask = ((): HostComponent<ViewProps> | React.ComponentType<ViewProps> => {
Expand All @@ -45,8 +51,9 @@ const Unmask = ((): HostComponent<ViewProps> | React.ComponentType<ViewProps> =>
return UnmaskFallback;
}

// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
return require('../RNSentryReplayUnmaskNativeComponent').default;
return NativeComponentRegistry.get(UnmaskNativeComponentName, () => ({
uiViewClassName: UnmaskNativeComponentName,
}));
})();

export { Mask, Unmask, MaskFallback, UnmaskFallback };

0 comments on commit eb457fc

Please sign in to comment.