From d1727aee7ea2e869e0b9a578a369b0612a9e79a9 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Thu, 7 Nov 2024 15:28:05 +0100 Subject: [PATCH 1/4] fix: first batch of console errors/warnings --- desktop/main.ts | 8 +++++++ package-lock.json | 22 +++++++++++++++---- package.json | 2 +- ...ntroller+1.14.4+001+disable-android.patch} | 4 ++-- src/CONFIG.ts | 1 + .../index.native.tsx | 7 ++++-- 6 files changed, 35 insertions(+), 9 deletions(-) rename patches/{react-native-keyboard-controller+1.14.1+001+disable-android.patch => react-native-keyboard-controller+1.14.4+001+disable-android.patch} (96%) diff --git a/desktop/main.ts b/desktop/main.ts index 1221b05a8388..fcdd5b913038 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -25,6 +25,14 @@ const {DESKTOP_SHORTCUT_ACCELERATOR, LOCALES} = CONST; // geolocation api (window.navigator.geolocation.getCurrentPosition) to work on desktop. // Source: https://github.com/electron/electron/blob/98cd16d336f512406eee3565be1cead86514db7b/docs/api/environment-variables.md#google_api_key process.env.GOOGLE_API_KEY = CONFIG.GCP_GEOLOCATION_API_KEY; +/** + * Suppresses Content Security Policy (CSP) console warnings related to 'unsafe-eval'. + * This is required because: + * 1. Webpack utilizes eval() for module bundling + * 2. The application requires 'unsafe-eval' in CSP to function properly + * Note: CSP warnings are expected and unavoidable in this context + */ +process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = CONFIG.ELECTRON_DISABLE_SECURITY_WARNINGS; app.setName('New Expensify'); diff --git a/package-lock.json b/package-lock.json index 0497c2e625d1..62b599507242 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,7 +91,7 @@ "react-native-image-picker": "^7.0.3", "react-native-image-size": "git+https://github.com/Expensify/react-native-image-size#cb392140db4953a283590d7cf93b4d0461baa2a9", "react-native-key-command": "^1.0.8", - "react-native-keyboard-controller": "1.14.1", + "react-native-keyboard-controller": "1.14.4", "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", @@ -34696,6 +34696,16 @@ "resolved": "git+ssh://git@github.com/Expensify/react-native-image-size.git#cb392140db4953a283590d7cf93b4d0461baa2a9", "integrity": "sha512-kF/8fGsKoOnjPZceipRUaM9Xg9a/aKXU2Vm5eHYEKHrRt8FP39oCbaELPTb/vUKRTu1HmEGffDFzRT02BcdzYQ==" }, + "node_modules/react-native-is-edge-to-edge": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/react-native-is-edge-to-edge/-/react-native-is-edge-to-edge-1.1.6.tgz", + "integrity": "sha512-1pHnFTlBahins6UAajXUqeCOHew9l9C2C8tErnpGC3IyLJzvxD+TpYAixnCbrVS52f7+NvMttbiSI290XfwN0w==", + "license": "MIT", + "peerDependencies": { + "react": ">=18.2.0", + "react-native": ">=0.73.0" + } + }, "node_modules/react-native-key-command": { "version": "1.0.8", "license": "MIT", @@ -34715,9 +34725,13 @@ "license": "MIT" }, "node_modules/react-native-keyboard-controller": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/react-native-keyboard-controller/-/react-native-keyboard-controller-1.14.1.tgz", - "integrity": "sha512-HUrZTaaDPxm94EVXlguwJB2gm6mc+VRTTzR66luFGZJZnL2SJoxN+dwsNW3twkwUVDrCPPA3U21q9YWUKVmwvg==", + "version": "1.14.4", + "resolved": "https://registry.npmjs.org/react-native-keyboard-controller/-/react-native-keyboard-controller-1.14.4.tgz", + "integrity": "sha512-hVt9KhK2dxBNtk4xHTnKLeO9Jv7v5h2TZlIeCQkbBLMd5NIJa4ll0GxIpbuutjP1ctPdhXUVpCfQzgXXJOYlzw==", + "license": "MIT", + "dependencies": { + "react-native-is-edge-to-edge": "^1.1.6" + }, "peerDependencies": { "react": "*", "react-native": "*", diff --git a/package.json b/package.json index 1b12bab2d1d8..d49ee9116aa0 100644 --- a/package.json +++ b/package.json @@ -148,7 +148,7 @@ "react-native-image-picker": "^7.0.3", "react-native-image-size": "git+https://github.com/Expensify/react-native-image-size#cb392140db4953a283590d7cf93b4d0461baa2a9", "react-native-key-command": "^1.0.8", - "react-native-keyboard-controller": "1.14.1", + "react-native-keyboard-controller": "1.14.4", "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", diff --git a/patches/react-native-keyboard-controller+1.14.1+001+disable-android.patch b/patches/react-native-keyboard-controller+1.14.4+001+disable-android.patch similarity index 96% rename from patches/react-native-keyboard-controller+1.14.1+001+disable-android.patch rename to patches/react-native-keyboard-controller+1.14.4+001+disable-android.patch index 6bb62155a98c..8d2d81aab40a 100644 --- a/patches/react-native-keyboard-controller+1.14.1+001+disable-android.patch +++ b/patches/react-native-keyboard-controller+1.14.4+001+disable-android.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/react-native-keyboard-controller/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt b/node_modules/react-native-keyboard-controller/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt -index 7ef8b36..f4d44ff 100644 +index 93c20d3..df1e846 100644 --- a/node_modules/react-native-keyboard-controller/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt +++ b/node_modules/react-native-keyboard-controller/android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt @@ -74,7 +74,7 @@ class EdgeToEdgeReactViewGroup( @@ -51,7 +51,7 @@ index 7ef8b36..f4d44ff 100644 } // endregion -@@ -219,7 +219,7 @@ class EdgeToEdgeReactViewGroup( +@@ -223,7 +223,7 @@ class EdgeToEdgeReactViewGroup( fun forceStatusBarTranslucent(isStatusBarTranslucent: Boolean) { if (active && this.isStatusBarTranslucent != isStatusBarTranslucent) { this.isStatusBarTranslucent = isStatusBarTranslucent diff --git a/src/CONFIG.ts b/src/CONFIG.ts index 8a30c8bf57c2..e5e9a9d1540a 100644 --- a/src/CONFIG.ts +++ b/src/CONFIG.ts @@ -103,4 +103,5 @@ export default { }, // to read more about StrictMode see: contributingGuides/STRICT_MODE.md USE_REACT_STRICT_MODE_IN_DEV: false, + ELECTRON_DISABLE_SECURITY_WARNINGS: 'true', } as const; diff --git a/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx b/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx index ff050f673951..2450ce800e0e 100644 --- a/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx +++ b/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx @@ -1,11 +1,14 @@ import {CellContainer} from '@shopify/flash-list'; import type {CellContainerProps} from '@shopify/flash-list/dist/native/cell-container/CellContainer'; +import type {ForwardedRef} from 'react'; +import {forwardRef} from 'react'; -function OptionRowRendererComponent(props: CellContainerProps) { +function OptionRowRendererComponent(props: CellContainerProps, ref: ForwardedRef) { return ( ); @@ -13,4 +16,4 @@ function OptionRowRendererComponent(props: CellContainerProps) { OptionRowRendererComponent.displayName = 'OptionRowRendererComponent'; -export default OptionRowRendererComponent; +export default forwardRef(OptionRowRendererComponent); From c5f38477a95b1b48e155e7639320f4f42d068f89 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Fri, 8 Nov 2024 14:31:02 +0100 Subject: [PATCH 2/4] fix: eslint --- desktop/main.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/desktop/main.ts b/desktop/main.ts index fcdd5b913038..ba8eb32b8ea6 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -115,7 +115,7 @@ process.argv.forEach((arg) => { return; } - expectedUpdateVersion = arg.substr(`${EXPECTED_UPDATE_VERSION_FLAG}=`.length); + expectedUpdateVersion = arg.substring(`${EXPECTED_UPDATE_VERSION_FLAG}=`.length); }); // Add the listeners and variables required to ensure that auto-updating @@ -513,9 +513,8 @@ const mainWindow = (): Promise => { // open the default browser instead of a new electron window browserWindow.webContents.setWindowOpenHandler(({url}) => { const denial = {action: 'deny'} as const; - // Make sure local urls stay in electron perimeter - if (url.substr(0, 'file://'.length).toLowerCase() === 'file://') { + if (url.substring(0, 'file://'.length).toLowerCase() === 'file://') { return denial; } From 2c145f09eac8953cb750f6134a162755164e07ea Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Wed, 13 Nov 2024 09:40:53 +0100 Subject: [PATCH 3/4] fix: eslint --- desktop/main.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/desktop/main.ts b/desktop/main.ts index f55d7e3c045a..e7b7e177fb0a 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -5,16 +5,16 @@ import log from 'electron-log'; import type {ElectronLog} from 'electron-log'; import {autoUpdater} from 'electron-updater'; import {machineId} from 'node-machine-id'; +import checkForUpdates from '@libs/checkForUpdates'; +import * as Localize from '@libs/Localize'; +import CONFIG from '@src/CONFIG'; +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; +import type PlatformSpecificUpdater from '@src/setup/platformSetup/types'; +import type {Locale} from '@src/types/onyx'; import type {CreateDownloadQueueModule, DownloadItem} from './createDownloadQueue'; import serve from './electron-serve'; import ELECTRON_EVENTS from './ELECTRON_EVENTS'; -import CONFIG from './src/CONFIG'; -import CONST from './src/CONST'; -import type {TranslationPaths} from './src/languages/types'; -import checkForUpdates from './src/libs/checkForUpdates'; -import * as Localize from './src/libs/Localize'; -import type PlatformSpecificUpdater from './src/setup/platformSetup/types'; -import type {Locale} from './src/types/onyx'; const createDownloadQueue = require('./createDownloadQueue').default; From 58d3ffe1da15c4cbb03404181a8cccd62a42a80b Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Wed, 20 Nov 2024 17:20:09 +0100 Subject: [PATCH 4/4] fix: resolve comments --- desktop/main.ts | 1 + .../LHNOptionsList/OptionRowRendererComponent/index.native.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/main.ts b/desktop/main.ts index e7b7e177fb0a..4f642d90da51 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -515,6 +515,7 @@ const mainWindow = (): Promise => { // open the default browser instead of a new electron window browserWindow.webContents.setWindowOpenHandler(({url}) => { const denial = {action: 'deny'} as const; + // Make sure local urls stay in electron perimeter if (url.slice(0, 'file://'.length).toLowerCase() === 'file://') { return denial; diff --git a/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx b/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx index 2450ce800e0e..a0179145b77c 100644 --- a/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx +++ b/src/components/LHNOptionsList/OptionRowRendererComponent/index.native.tsx @@ -2,8 +2,9 @@ import {CellContainer} from '@shopify/flash-list'; import type {CellContainerProps} from '@shopify/flash-list/dist/native/cell-container/CellContainer'; import type {ForwardedRef} from 'react'; import {forwardRef} from 'react'; +import type {View} from 'react-native'; -function OptionRowRendererComponent(props: CellContainerProps, ref: ForwardedRef) { +function OptionRowRendererComponent(props: CellContainerProps, ref: ForwardedRef) { return (