feat(rn) add polyfill for the performance API

Implements: https://developer.mozilla.org/en-US/docs/Web/API/Performance
Ref: https://github.com/oblador/react-native-performance
This commit is contained in:
Saúl Ibarra Corretgé 2021-09-07 16:38:44 +02:00 committed by Saúl Ibarra Corretgé
parent 2008c90359
commit 49be96799a
8 changed files with 37 additions and 1 deletions

View File

@ -71,6 +71,7 @@ dependencies {
implementation project(':react-native-default-preference')
implementation project(':react-native-immersive')
implementation project(':react-native-keep-awake')
implementation project(':react-native-performance')
implementation project(':react-native-slider')
implementation project(':react-native-sound')
implementation project(':react-native-splash-screen')

View File

@ -184,6 +184,7 @@ class ReactInstanceManagerHolder {
new com.horcrux.svg.SvgPackage(),
new com.kevinresol.react_native_default_preference.RNDefaultPreferencePackage(),
new com.learnium.RNDeviceInfo.RNDeviceInfo(),
new com.oblador.performance.PerformancePackage(),
new com.ocetnik.timer.BackgroundTimerPackage(),
new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
new com.reactnativecommunity.netinfo.NetInfoPackage(),

View File

@ -21,6 +21,8 @@ include ':react-native-immersive'
project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
include ':react-native-keep-awake'
project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
include ':react-native-performance'
project(':react-native-performance').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-performance/android')
include ':react-native-slider'
project(':react-native-slider').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/slider/android')
include ':react-native-sound'

View File

@ -59,6 +59,7 @@ target 'JitsiMeetSDK' do
pod 'react-native-calendar-events', :path => '../node_modules/react-native-calendar-events'
pod 'react-native-keep-awake', :path => '../node_modules/react-native-keep-awake'
pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
pod 'react-native-performance', :path => '../node_modules/react-native-performance/ios'
pod 'react-native-slider', :path => '../node_modules/@react-native-community/slider'
pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
pod 'react-native-video', :path => '../node_modules/react-native-video/react-native-video.podspec'

View File

@ -288,6 +288,8 @@ PODS:
- React
- react-native-netinfo (4.1.5):
- React
- react-native-performance (2.0.0):
- React-Core
- react-native-slider (3.0.3):
- React
- react-native-splash-screen (3.2.0):
@ -402,6 +404,7 @@ DEPENDENCIES:
- react-native-calendar-events (from `../node_modules/react-native-calendar-events`)
- react-native-keep-awake (from `../node_modules/react-native-keep-awake`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-performance (from `../node_modules/react-native-performance/ios`)
- "react-native-slider (from `../node_modules/@react-native-community/slider`)"
- react-native-splash-screen (from `../node_modules/react-native-splash-screen`)
- react-native-video (from `../node_modules/react-native-video/react-native-video.podspec`)
@ -488,6 +491,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-keep-awake"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-performance:
:path: "../node_modules/react-native-performance/ios"
react-native-slider:
:path: "../node_modules/@react-native-community/slider"
react-native-splash-screen:
@ -575,6 +580,7 @@ SPEC CHECKSUMS:
react-native-calendar-events: 1442fad71a00388f933cfa25512588fec300fcf8
react-native-keep-awake: eba3137546b10003361b37c761f6c429b59814ae
react-native-netinfo: 8d8db463bcc5db66a8ac5c48a7d86beb3b92f61a
react-native-performance: 8edfa2bbc9a2af4a02f01d342118e413a95145e0
react-native-slider: b733e17fdd31186707146debf1f04b5d94aa1a93
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
react-native-video: 1574074179ecaf6a9dd067116c8f31bf9fec15c8
@ -599,6 +605,6 @@ SPEC CHECKSUMS:
RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3
Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c
PODFILE CHECKSUM: 6f4485ed41286517917d47d2170b0de97d32bbfb
PODFILE CHECKSUM: e830b1b5a46d340e22689b146b55dcf24664c6f1
COCOAPODS: 1.10.1

5
package-lock.json generated
View File

@ -15075,6 +15075,11 @@
"react-native-iphone-x-helper": "^1.3.1"
}
},
"react-native-performance": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/react-native-performance/-/react-native-performance-2.0.0.tgz",
"integrity": "sha512-jKM9Qg0SkL9D9ad377nxb1VV+OXJSyYyIrBHKmM6CABNxfrLVA5xkQMEibjmZQde7b0ndJOZoQAiObgJjjc4VQ=="
},
"react-native-sound": {
"version": "github:jitsi/react-native-sound#3fe5480fce935e888d5089d94a191c7c7e3aa190",
"from": "github:jitsi/react-native-sound#3fe5480fce935e888d5089d94a191c7c7e3aa190"

View File

@ -83,6 +83,7 @@
"react-native-immersive": "2.0.0",
"react-native-keep-awake": "4.0.0",
"react-native-paper": "4.8.1",
"react-native-performance": "2.0.0",
"react-native-sound": "github:jitsi/react-native-sound#3fe5480fce935e888d5089d94a191c7c7e3aa190",
"react-native-splash-screen": "3.2.0",
"react-native-svg": "12.1.0",

View File

@ -383,6 +383,25 @@ function _visitNode(node, callback) {
// WebRTC
require('./webrtc');
// Performance API
// RN 0.61 does not provide performance.now(), and react-native-performance
// requires it.
const now = () => Date.now();
if (!global.performance) {
global.performance = {};
}
if (!global.performance.now) {
global.performance.now = now;
}
const perf = require('react-native-performance');
global.performance = perf;
global.PerformanceObserver = perf.PerformanceObserver;
// CallStats
//
// Required by: