Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {HostInstance} from 'react-native';

import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement';
import {getRawNativeDOMForTests} from '../../../../src/private/webapis/dom/nodes/specs/NativeDOM';
import TextInputState from '../../../Components/TextInput/TextInputState';
import View from '../../../Components/View/View';
import ReactFabricHostComponent from '../ReactFabricHostComponent';
Expand Down Expand Up @@ -349,58 +348,5 @@ describe('ReactFabricPublicInstance', () => {
.toJSX(),
).toEqual(<rn-view testID={'second test id'} />);
});

// TODO: delete when NativeDOM.setNativeProps is NOT nullable.
// This logic is to ensure compatibility with old app versions without the native module method.
if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) {
let RawNativeDOM;
let originalSetNativeProps;

beforeAll(() => {
RawNativeDOM = nullthrows(getRawNativeDOMForTests());
originalSetNativeProps = RawNativeDOM.setNativeProps;
});

beforeEach(() => {
// $FlowExpectedError[cannot-write]
RawNativeDOM.setNativeProps = originalSetNativeProps;
});

it('should propagate changes to the host component (when NativeDOM.setNativeProps is not available)', () => {
// $FlowExpectedError[cannot-write]
RawNativeDOM.setNativeProps = null;

expect(RawNativeDOM.setNativeProps).toBeNull();

const root = Fantom.createRoot();
const nodeRef = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(<View ref={nodeRef} testID="first test id" />);
});

expect(
root
.getRenderedOutput({
props: ['testID'],
})
.toJSX(),
).toEqual(<rn-view testID={'first test id'} />);

const element = nullthrows(nodeRef.current);

Fantom.runTask(() => {
element.setNativeProps({testID: 'second test id'});
});

expect(
root
.getRenderedOutput({
props: ['testID'],
})
.toJSX(),
).toEqual(<rn-view testID={'second test id'} />);
});
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {Node as ShadowNode} from '../../../../../../Libraries/Renderer/shim
import type {TurboModule} from '../../../../../../Libraries/TurboModule/RCTExport';
import type {InstanceHandle} from '../internals/NodeInternals';

import {getFabricUIManager} from '../../../../../../Libraries/ReactNative/FabricUIManager';
import * as TurboModuleRegistry from '../../../../../../Libraries/TurboModule/TurboModuleRegistry';
import nullthrows from 'nullthrows';

Expand Down Expand Up @@ -165,7 +164,7 @@ export interface Spec extends TurboModule {
* Legacy direct manipulation APIs (for `ReactNativeElement`).
*/

+setNativeProps?: (
+setNativeProps: (
nativeElementReference: mixed,
updatePayload: mixed,
) => void;
Expand Down Expand Up @@ -623,16 +622,10 @@ const NativeDOM: RefinedSpec = {
* Legacy direct manipulation APIs
*/
setNativeProps(nativeNodeReference, updatePayload) {
// TODO: remove when RawNativeDOM.setNativeProps is NOT nullable.
if (RawNativeDOM?.setNativeProps == null) {
nullthrows(getFabricUIManager()).setNativeProps(
nativeNodeReference,
updatePayload,
);
return;
}

return RawNativeDOM.setNativeProps(nativeNodeReference, updatePayload);
return nullthrows(RawNativeDOM).setNativeProps(
nativeNodeReference,
updatePayload,
);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import {
performanceEntryTypeToRaw,
rawToPerformanceEntry,
} from './internals/RawPerformanceEntry';
import {
getCurrentTimeStamp,
warnNoNativePerformance,
} from './internals/Utilities';
import {getCurrentTimeStamp} from './internals/Utilities';
import MemoryInfo from './MemoryInfo';
import ReactNativeStartupTiming from './ReactNativeStartupTiming';
import MaybeNativePerformance from './specs/NativePerformance';
Expand Down Expand Up @@ -78,18 +75,16 @@ const MEASURE_OPTIONS_REUSABLE_OBJECT: {...PerformanceMeasureInit} = {
detail: undefined,
};

const getMarkTimeForMeasure = cachedGetMarkTime
? (markName: string): number => {
const markTime = cachedGetMarkTime(markName);
if (markTime == null) {
throw new DOMException(
`Failed to execute 'measure' on 'Performance': The mark '${markName}' does not exist.`,
'SyntaxError',
);
}
return markTime;
}
: undefined;
const getMarkTimeForMeasure = (markName: string): number => {
const markTime = cachedGetMarkTime(markName);
if (markTime == null) {
throw new DOMException(
`Failed to execute 'measure' on 'Performance': The mark '${markName}' does not exist.`,
'SyntaxError',
);
}
return markTime;
};

/**
* Partial implementation of the Performance interface for RN,
Expand Down Expand Up @@ -151,11 +146,6 @@ export default class Performance {
// Please run the benchmarks in `Performance-benchmarks-itest` to ensure
// changes do not regress performance.

if (cachedReportMark === undefined) {
warnNoNativePerformance();
return new PerformanceMark(markName, {startTime: 0});
}

if (markName === undefined) {
throw new TypeError(
`Failed to execute 'mark' on 'Performance': 1 argument required, but only 0 present.`,
Expand Down Expand Up @@ -225,14 +215,6 @@ export default class Performance {
// Please run the benchmarks in `Performance-benchmarks-itest` to ensure
// changes do not regress performance.

if (
getMarkTimeForMeasure === undefined ||
cachedReportMeasure === undefined
) {
warnNoNativePerformance();
return new PerformanceMeasure(measureName, {startTime: 0, duration: 0});
}

let resolvedMeasureName: string;
let resolvedStartTime: number;
let resolvedDuration: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export type PerformanceObserverInit = {

export interface Spec extends TurboModule {
+now: () => number;
+reportMark?: (name: string, startTime: number, entry: mixed) => void;
+reportMeasure?: (
+reportMark: (name: string, startTime: number, entry: mixed) => void;
+reportMeasure: (
name: string,
startTime: number,
duration: number,
entry: mixed,
) => void;
+getMarkTime?: (name: string) => ?number;
+getMarkTime: (name: string) => ?number;
+clearMarks: (entryName?: string) => void;
+clearMeasures: (entryName?: string) => void;
+getEntries: () => $ReadOnlyArray<RawPerformanceEntry>;
Expand Down Expand Up @@ -93,7 +93,7 @@ export interface Spec extends TurboModule {

+getSupportedPerformanceEntryTypes: () => $ReadOnlyArray<RawPerformanceEntryType>;

+clearEventCountsForTesting?: () => void;
+clearEventCountsForTesting: () => void;
}

export default (TurboModuleRegistry.get<Spec>('NativePerformanceCxx'): ?Spec);
Loading