Skip to content

Commit fda2c82

Browse files
committed
Merge remote-tracking branch 'react-native-render-html/migrate-render-html-with-history' into chore/migrate-render-html-with-history
2 parents 170da76 + dfa395c commit fda2c82

File tree

750 files changed

+37279
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

750 files changed

+37279
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3+
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4+
}

apps/benchmarking/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
.expo/
3+
npm-debug.*
4+
*.jks
5+
*.p8
6+
*.p12
7+
*.key
8+
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
12+
# macOS
13+
.DS_Store

apps/benchmarking/App.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import { SafeAreaView } from 'react-native-safe-area-context';
3+
import { useKeepAwake } from 'expo-keep-awake';
4+
import html from './source';
5+
import {
6+
TRenderEngineProvider,
7+
RenderHTMLConfigProvider
8+
} from 'react-native-render-html';
9+
10+
import Benchmark from './Benchmark';
11+
12+
const config = {
13+
samples: 50,
14+
ignoredTags: ['svg', 'button', 'input', 'form', 'img', 'ol', 'table']
15+
};
16+
17+
const props = {
18+
renderers: {}
19+
};
20+
21+
export default function App() {
22+
useKeepAwake();
23+
return (
24+
<SafeAreaView style={{ flexGrow: 1 }}>
25+
<TRenderEngineProvider ignoredDomTags={config.ignoredTags}>
26+
<RenderHTMLConfigProvider {...props}>
27+
<Benchmark html={html} {...config} />
28+
</RenderHTMLConfigProvider>
29+
</TRenderEngineProvider>
30+
</SafeAreaView>
31+
);
32+
}

apps/benchmarking/Benchmark.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint-disable no-undef */
2+
import * as React from 'react';
3+
import { ScrollView, StyleSheet, View, Text, Button } from 'react-native';
4+
import { mean } from 'ramda';
5+
import { match } from 'react-states';
6+
import useBenchmark from './useBenchmark';
7+
8+
function Benchmarks({ benchmarks }) {
9+
return (
10+
<View>
11+
<Text>
12+
Average Time to Render:{'\n'}
13+
{benchmarks.map((e) => `${e.name}: ${mean(e.values).toFixed(2)}ms\n`)}
14+
</Text>
15+
</View>
16+
);
17+
}
18+
19+
export default function Benchmark({ samples, html, ignoredTags }) {
20+
const { onLayout, launch, ...state } = useBenchmark({
21+
runs: samples
22+
});
23+
const renderHtml = React.useCallback(
24+
({ runId, profile }) => (
25+
<View key={runId} onLayout={onLayout}>
26+
<profile.component
27+
ignoredTags={ignoredTags}
28+
running={true}
29+
html={html}
30+
{...profile.props}
31+
/>
32+
</View>
33+
),
34+
[html, ignoredTags, onLayout]
35+
);
36+
return (
37+
<View>
38+
<Button
39+
title="Run Benchmark"
40+
onPress={launch}
41+
disabled={state.state !== 'WAIT_BENCH'}
42+
/>
43+
<ScrollView contentContainerStyle={styles.container}>
44+
{match(state, {
45+
WAIT_BENCH: ({ benchmarks }) =>
46+
benchmarks ? (
47+
<Benchmarks benchmarks={benchmarks} />
48+
) : (
49+
<Text>Waiting for benchmark to launch</Text>
50+
),
51+
WAIT_RUN: renderHtml,
52+
RUNNING: renderHtml
53+
})}
54+
</ScrollView>
55+
</View>
56+
);
57+
}
58+
59+
const styles = StyleSheet.create({
60+
container: {
61+
flexGrow: 1
62+
}
63+
});

apps/benchmarking/app.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"expo": {
3+
"name": "benchmarking",
4+
"slug": "benchmarking",
5+
"version": "1.0.0",
6+
"orientation": "portrait",
7+
"icon": "./assets/icon.png",
8+
"splash": {
9+
"image": "./assets/splash.png",
10+
"resizeMode": "contain",
11+
"backgroundColor": "#ffffff"
12+
},
13+
"updates": {
14+
"fallbackToCacheTimeout": 0
15+
},
16+
"assetBundlePatterns": [
17+
"**/*"
18+
],
19+
"ios": {
20+
"supportsTablet": true,
21+
"bundleIdentifier": "org.nativehtml.benchmarking"
22+
},
23+
"android": {
24+
"adaptiveIcon": {
25+
"foregroundImage": "./assets/adaptive-icon.png",
26+
"backgroundColor": "#FFFFFF"
27+
},
28+
"package": "org.nativehtml.benchmarking"
29+
},
30+
"web": {
31+
"favicon": "./assets/favicon.png"
32+
}
33+
}
34+
}
17.1 KB
Loading
1.43 KB
Loading

apps/benchmarking/assets/icon.png

21.9 KB
Loading
47.3 KB
Loading

apps/benchmarking/babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = function(api) {
2+
api.cache(true);
3+
return {
4+
presets: ['babel-preset-expo'],
5+
};
6+
};

0 commit comments

Comments
 (0)