From 887f00463162ea5d221cf611d342c3d02272c976 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Sep 2021 00:32:15 +0800 Subject: [PATCH 1/5] Revert "[expo] User friendly error message if font lacks automatic scaling" This reverts commit 3801258bebaefbe991f1405a54a430c509fc4b80. --- Libraries/Text/Text/NSTextStorage+FontScaling.m | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Libraries/Text/Text/NSTextStorage+FontScaling.m b/Libraries/Text/Text/NSTextStorage+FontScaling.m index cef9ed632f0a..e4a2c4c05078 100644 --- a/Libraries/Text/Text/NSTextStorage+FontScaling.m +++ b/Libraries/Text/Text/NSTextStorage+FontScaling.m @@ -7,8 +7,6 @@ #import "NSTextStorage+FontScaling.h" -#import - typedef NS_OPTIONS(NSInteger, RCTTextSizeComparisonOptions) { RCTTextSizeComparisonSmaller = 1 << 0, RCTTextSizeComparisonLarger = 1 << 1, @@ -127,14 +125,9 @@ - (void)scaleFontSizeWithRatio:(CGFloat)ratio CGFloat fontSize = MAX(MIN(font.pointSize * ratio, maximumFontSize), minimumFontSize); - UIFont *scaledFont = [font fontWithSize:fontSize]; - if (scaledFont) { - [self addAttribute:NSFontAttributeName - value:scaledFont - range:range]; - } else { - RCTLogError(@"Font \"%@"" doesn't support automatic scaling.", font.familyName); - } + [self addAttribute:NSFontAttributeName + value:[font fontWithSize:fontSize] + range:range]; } ]; From db223ba018d7edaf4039f02e20396767b6b766f1 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Sep 2021 00:32:36 +0800 Subject: [PATCH 2/5] Revert "[appearance] Use listener whenever possible in order to respect userInterfaceStyle of RCTRootView - getColorScheme does not do this by default" This reverts commit a80b16c7a0233a46a1eb82fbe274344489312670. --- Libraries/Utilities/Appearance.js | 60 ++++++++++++------------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index 07cf44a37e2f..314b3eaaad64 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -34,48 +34,11 @@ if (NativeAppearance) { colorScheme == null, "Unrecognized color scheme. Did you mean 'dark' or 'light'?", ); - // Update cached value - preferences.colorScheme = colorScheme; eventEmitter.emit('change', {colorScheme}); }, ); } -function getInitialColorScheme(): ?ColorSchemeName { - if (__DEV__) { - if (isAsyncDebugging) { - // Hard code light theme when using the async debugger as - // sync calls aren't supported - return 'light'; - } - } - - // TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union - const nativeColorScheme: ?string = - NativeAppearance == null ? null : NativeAppearance.getColorScheme() || null; - invariant( - nativeColorScheme === 'dark' || - nativeColorScheme === 'light' || - nativeColorScheme == null, - "Unrecognized color scheme. Did you mean 'dark' or 'light'?", - ); - return nativeColorScheme; -} - -function getColorScheme(): ?ColorSchemeName { - if (!preferences.colorScheme) { - const initialColorScheme = getInitialColorScheme(); - preferences.colorScheme = initialColorScheme; - return preferences.colorScheme; - } - - return preferences.colorScheme; -} - -const preferences = { - colorScheme: null, -}; - module.exports = { /** * Note: Although color scheme is available immediately, it may change at any @@ -87,7 +50,28 @@ module.exports = { * * @returns {?ColorSchemeName} Value for the color scheme preference. */ - getColorScheme, + getColorScheme(): ?ColorSchemeName { + if (__DEV__) { + if (isAsyncDebugging) { + // Hard code light theme when using the async debugger as + // sync calls aren't supported + return 'light'; + } + } + + // TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union + const nativeColorScheme: ?string = + NativeAppearance == null + ? null + : NativeAppearance.getColorScheme() || null; + invariant( + nativeColorScheme === 'dark' || + nativeColorScheme === 'light' || + nativeColorScheme == null, + "Unrecognized color scheme. Did you mean 'dark' or 'light'?", + ); + return nativeColorScheme; + }, /** * Add an event handler that is fired when appearance preferences change. */ From 651e20e079a2b1149ba61fa929529a6c9db596d7 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Sep 2021 00:33:18 +0800 Subject: [PATCH 3/5] Revert "[AppRegistry] Avoid using invariant in runApplication to preserve red screen and provide more useful warning" This reverts commit 625e44d0d622b940b9adada1f3b4a5e808ad2338. --- Libraries/ReactNative/AppRegistry.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index a35322a2c06c..389b2f5240f2 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -190,24 +190,13 @@ const AppRegistry = { () => msg, ); } - - // NOTE(brentvatne): the original error message here, commented out below, - // is not useful to developers in the Expo managed workflow. It also will - // prevent any red box error that has occurred while loading the bundle from - // being visible to the user. So, we instead warn and give a more tailored - // message to help users with debugging the issue. - if (!runnables[appKey] || !runnables[appKey].run) { - console.warn(`Unable to start your application. Please refer to https://expo.fyi/no-registered-application for more information.`); - return; - } - - // invariant( - // runnables[appKey] && runnables[appKey].run, - // `"${appKey}" has not been registered. This can happen if:\n` + - // '* Metro (the local dev server) is run from the wrong folder. ' + - // 'Check if Metro is running, stop it and restart it in the current project.\n' + - // "* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.", - // ); + invariant( + runnables[appKey] && runnables[appKey].run, + `"${appKey}" has not been registered. This can happen if:\n` + + '* Metro (the local dev server) is run from the wrong folder. ' + + 'Check if Metro is running, stop it and restart it in the current project.\n' + + "* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.", + ); SceneTracker.setActiveScene({name: appKey}); runnables[appKey].run(appParameters); From 3ea037df7a4b782df77ad74ad2c2582b988f7c7d Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Sep 2021 00:33:38 +0800 Subject: [PATCH 4/5] Revert "[ExceptionsManager] Exceptions are not handled by LogBox when __DEV__ is false" This reverts commit 42f556cde800d124d03cc9e7c2fa605edf24916c. --- Libraries/Core/ExceptionsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index afb2c68ad8d3..6da6d8a4a302 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -76,7 +76,7 @@ function reportException( e.jsEngine == null ? message : `${message}, js engine: ${e.jsEngine}`; const isHandledByLogBox = - e.forceRedbox !== true && __DEV__ && !global.RN$Bridgeless && !global.RN$Express; + e.forceRedbox !== true && !global.RN$Bridgeless && !global.RN$Express; const data = preprocessException({ message, From 096ae86f32e84da9a18495e318361693fab452e3 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 21 Sep 2021 23:15:49 +0800 Subject: [PATCH 5/5] Revert "Revert "[expo] User friendly error message if font lacks automatic scaling"" This reverts commit 887f00463162ea5d221cf611d342c3d02272c976. --- Libraries/Text/Text/NSTextStorage+FontScaling.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Libraries/Text/Text/NSTextStorage+FontScaling.m b/Libraries/Text/Text/NSTextStorage+FontScaling.m index e4a2c4c05078..cef9ed632f0a 100644 --- a/Libraries/Text/Text/NSTextStorage+FontScaling.m +++ b/Libraries/Text/Text/NSTextStorage+FontScaling.m @@ -7,6 +7,8 @@ #import "NSTextStorage+FontScaling.h" +#import + typedef NS_OPTIONS(NSInteger, RCTTextSizeComparisonOptions) { RCTTextSizeComparisonSmaller = 1 << 0, RCTTextSizeComparisonLarger = 1 << 1, @@ -125,9 +127,14 @@ - (void)scaleFontSizeWithRatio:(CGFloat)ratio CGFloat fontSize = MAX(MIN(font.pointSize * ratio, maximumFontSize), minimumFontSize); - [self addAttribute:NSFontAttributeName - value:[font fontWithSize:fontSize] - range:range]; + UIFont *scaledFont = [font fontWithSize:fontSize]; + if (scaledFont) { + [self addAttribute:NSFontAttributeName + value:scaledFont + range:range]; + } else { + RCTLogError(@"Font \"%@"" doesn't support automatic scaling.", font.familyName); + } } ];