Skip to content

Commit c6a63e5

Browse files
fix(example): add web script and fix benchmark crash on web
- Add `web` script to example package.json - Add .web stub for BenchmarkDemo (placeholder on web) - Add .web stub for frame-metrics module (no-op on web)
1 parent 9f324c7 commit c6a63e5

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export type FrameMetricsResult = {
2+
avgUiThreadTime: number;
3+
p95UiThreadTime: number;
4+
p99UiThreadTime: number;
5+
avgAnimationTime?: number;
6+
avgLayoutTime?: number;
7+
avgDrawTime?: number;
8+
};
9+
10+
export const isAndroid = false;
11+
12+
export function startCollecting(): void {
13+
// no-op on web
14+
}
15+
16+
export function stopCollecting(): FrameMetricsResult {
17+
return {
18+
avgUiThreadTime: 0,
19+
p95UiThreadTime: 0,
20+
p99UiThreadTime: 0,
21+
};
22+
}

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"android": "expo run:android",
88
"ios": "expo run:ios",
99
"start": "expo start",
10+
"web": "expo start --web",
1011
"prebuild": "expo prebuild",
1112
"build:android": "expo prebuild --platform android --clean && cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
1213
"build:ios": "expo prebuild --platform ios --clean && xcodebuild -workspace ios/EaseExample.xcworkspace -scheme EaseExample -configuration Debug -sdk iphonesimulator -arch x86_64 build"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { View, Text, StyleSheet } from 'react-native';
2+
3+
export function BenchmarkDemo() {
4+
return (
5+
<View style={styles.container}>
6+
<Text style={styles.text}>
7+
Benchmark is only available on native platforms.
8+
</Text>
9+
</View>
10+
);
11+
}
12+
13+
const styles = StyleSheet.create({
14+
container: {
15+
padding: 20,
16+
alignItems: 'center',
17+
},
18+
text: {
19+
color: '#8888aa',
20+
fontSize: 14,
21+
},
22+
});

0 commit comments

Comments
 (0)