Skip to content

Commit

Permalink
use pnpm patch for react-native-video and react-native-fast-crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Aug 16, 2022
1 parent 6304914 commit fec2759
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 97 deletions.
18 changes: 0 additions & 18 deletions apps/ledger-live-mobile/scripts/patches/RNAnalytics.h.patch

This file was deleted.

13 changes: 0 additions & 13 deletions apps/ledger-live-mobile/scripts/patches/RNFastCrypto.h.patch

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions apps/ledger-live-mobile/scripts/post.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,7 @@ cd(path.join(__dirname, ".."));
const syncFamilies = async () =>
await $`zx ./scripts/sync-families-dispatch.mjs`;

const patchers = async () => {
await $`patch -N -i scripts/patches/RNFastCrypto.h.patch node_modules/react-native-fast-crypto/ios/RNFastCrypto.h 2>/dev/null`;

// patching transitive gradle dependency
await $`patch -N -i ./scripts/patches/react-native-video.2575.patch node_modules/react-native-video/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java 2>/dev/null`;
await $`patch -N -i ./scripts/patches/react-native-video+5.2.0.patch node_modules/react-native-video/android-exoplayer/build.gradle 2>/dev/null`;

// See: https://github.com/expo/expo/issues/15622#issuecomment-997225774
// patch -N -i scripts/patches/RNAnalytics.h.patch node_modules/@segment/analytics-react-native/ios/RNAnalytics/RNAnalytics.h
};

const final = async () => {
rimraf("third-party/glog-0.3.5/test-driver", e => {
if (!!e) echo(chalk.red(e));
});

// Had to remove the following because we already have the AsyncSocket lib as a dependency from Flipper 🐬
// Why would anyone bundle an external lib available on CocoaPods anyway?
// It's been fixed in https://github.com/tradle/react-native-udp/pull/112 but as of today it's not part of any release
// IT SEEMS WE DON'T NEED THIS ANYMORE 👆 AS THE VERSION CONTAINING THE FIX WAS 2.60 AND WE ARE USING ^4.0.0
// await fs.promises.rm("node_modules/react-native-tcp/ios/CocoaAsyncSocket", { force: true, recursive: true });

// issue: https://github.com/WalletConnect/walletconnect-monorepo/issues/595
// manually shim
// sed -i -- 's/require("crypto")/require("react-native-crypto")/g' node_modules/@walletconnect/randombytes/dist/cjs/node/index.js

// Create the dev .env file with APP_NAME if it doesn't exist
const exists = fs.existsSync(".env");
if (!exists) {
Expand All @@ -57,14 +32,6 @@ const final = async () => {
await $`bundle install`;

if (os.platform() === "darwin") {
// (
// cd node_modules/react-native/scripts
// echo "- switch to relative paths in react_native_pods.rb "
// sed -i '' -e "s/File[.]join[(]__dir__, \"[.][.]\"[)]/\"..\/..\/node_modules\/react-native\"/" react_native_pods.rb
// sed -i '' -e "s/#{File[.]join[(]__dir__, \"generate-specs.sh\"[)]}/..\/..\/node_modules\/react-native\/scripts\/generate-specs.sh/" react_native_pods.rb
// sed -i '' -e "s/spec[.]prepare_command = \"#/spec.prepare_command = \"cd ..\/.. \&\& #/" react_native_pods.rb
// )

cd("ios");
try {
await $`bundle exec pod install --deployment --repo-update`;
Expand Down Expand Up @@ -101,5 +68,4 @@ const final = async () => {
};

await syncFamilies();
await patchers();
await final();
4 changes: 2 additions & 2 deletions libs/ledger-live-common/scripts/sync-families-dispatch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ async function genTypesFile(families) {
for (const family of families) {
imprts += `import { Transaction as ${family}Transaction } from "../families/${family}/types";
import { TransactionRaw as ${family}TransactionRaw } from "../families/${family}/types";
import { TransactionStatus as ${family}TransactionStatus } from "../families/${family}/types;
import { TransactionStatusRaw as ${family}TransactionStatusRaw } from "../families/${family}/types;
import { TransactionStatus as ${family}TransactionStatus } from "../families/${family}/types";
import { TransactionStatusRaw as ${family}TransactionStatusRaw } from "../families/${family}/types";
`;
exprtsT += `
| ${family}Transaction`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import algorand from "../families/algorand/deviceTransactionConfig";
import bitcoin from "../families/bitcoin/deviceTransactionConfig";

import cardano from "../families/cardano/deviceTransactionConfig";

import celo from "../families/celo/deviceTransactionConfig";

import cosmos from "../families/cosmos/deviceTransactionConfig";
import crypto_org from "../families/crypto_org/deviceTransactionConfig";
import elrond from "../families/elrond/deviceTransactionConfig";
Expand Down
38 changes: 38 additions & 0 deletions libs/ledger-live-common/src/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,41 @@ export type TransactionRaw =
| stellarTransactionRaw
| tezosTransactionRaw
| tronTransactionRaw;

export type TransactionStatus =
| algorandTransactionStatus
| bitcoinTransactionStatus
| cardanoTransactionStatus
| celoTransactionStatus
| cosmosTransactionStatus
| crypto_orgTransactionStatus
| elrondTransactionStatus
| ethereumTransactionStatus
| filecoinTransactionStatus
| hederaTransactionStatus
| neoTransactionStatus
| polkadotTransactionStatus
| rippleTransactionStatus
| solanaTransactionStatus
| stellarTransactionStatus
| tezosTransactionStatus
| tronTransactionStatus;

export type TransactionStatusRaw =
| algorandTransactionStatusRaw
| bitcoinTransactionStatusRaw
| cardanoTransactionStatusRaw
| celoTransactionStatusRaw
| cosmosTransactionStatusRaw
| crypto_orgTransactionStatusRaw
| elrondTransactionStatusRaw
| ethereumTransactionStatusRaw
| filecoinTransactionStatusRaw
| hederaTransactionStatusRaw
| neoTransactionStatusRaw
| polkadotTransactionStatusRaw
| rippleTransactionStatusRaw
| solanaTransactionStatusRaw
| stellarTransactionStatusRaw
| tezosTransactionStatusRaw
| tronTransactionStatusRaw;
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"metro-transform-worker": "^0.67.0",
"remove-flow-types-loader>flow-remove-types": "^2",
"remove-flow-types-loader>loader-utils": "*"
},
"patchedDependencies": {
"react-native-fast-crypto@2.2.0": "patches/react-native-fast-crypto@2.2.0.patch",
"react-native-video@5.2.0": "patches/react-native-video@5.2.0.patch"
}
}
}
13 changes: 13 additions & 0 deletions patches/react-native-fast-crypto@2.2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/ios/RNFastCrypto.h b/ios/RNFastCrypto.h
index 0a8f93d97e9d873b919d14060575bbd6b3cfb35c..884ca905cc412ba366a852805d25b0ee11e57311 100644
--- a/ios/RNFastCrypto.h
+++ b/ios/RNFastCrypto.h
@@ -2,7 +2,7 @@
#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
-#import <RCTBridgeModule.h>
+#import <React/RCTBridgeModule.h>
#endif

@interface RNFastCrypto : NSObject <RCTBridgeModule>
48 changes: 48 additions & 0 deletions patches/react-native-video@5.2.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/android-exoplayer/build.gradle b/android-exoplayer/build.gradle
index d005a58f293f29c7f87aa9482a42cac25a79c722..6a9922b095d56aaca163d8488f33cc23ae4f40b5 100644
--- a/android-exoplayer/build.gradle
+++ b/android-exoplayer/build.gradle
@@ -28,7 +28,7 @@ android {

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
- implementation('com.google.android.exoplayer:exoplayer:2.13.2') {
+ implementation('com.google.android.exoplayer:exoplayer:2.13.3') {
exclude group: 'com.android.support'
}

@@ -37,7 +37,7 @@ dependencies {
implementation "androidx.core:core:1.1.0"
implementation "androidx.media:media:1.1.0"

- implementation('com.google.android.exoplayer:extension-okhttp:2.13.2') {
+ implementation('com.google.android.exoplayer:extension-okhttp:2.13.3') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation 'com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}'
diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
index fe95fdf416c9499c6fb6970a100f9808d4b9d921..652f9ccb487791b64d9dd4963d67d121f3f3c503 100644
--- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
+++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
@@ -183,10 +183,10 @@ class ReactExoplayerView extends FrameLayout implements
}
}
};
-
+
public double getPositionInFirstPeriodMsForCurrentWindow(long currentPosition) {
Timeline.Window window = new Timeline.Window();
- if(!player.getCurrentTimeline().isEmpty()) {
+ if(!player.getCurrentTimeline().isEmpty()) {
player.getCurrentTimeline().getWindow(player.getCurrentWindowIndex(), window);
}
return window.windowStartTimeMs + currentPosition;
@@ -947,7 +947,7 @@ class ReactExoplayerView extends FrameLayout implements
// Special case for decoder initialization failures.
MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
(MediaCodecRenderer.DecoderInitializationException) cause;
- if (decoderInitializationException.codecInfo.name == null) {
+ if (decoderInitializationException.codecInfo == null || decoderInitializationException.codecInfo.name == null) {
if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
errorString = getResources().getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fec2759

Please sign in to comment.