id
int64 0
886
| original_context
stringlengths 648
56.6k
| modified_context
stringlengths 587
47.6k
| omitted_context
sequencelengths 0
19
| omitted_index
sequencelengths 0
19
| metadata
dict |
---|---|---|---|---|---|
500 | diff --git a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
index 1c9da8919e7054..3c03cc3c1169ed 100644
--- a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
+++ b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
@@ -140,4 +140,11 @@ - (Class)getModuleClassFromName:(const char *)name
return nullptr;
}
+- (void)loadSourceForBridge:(RCTBridge *)bridge
+ onProgress:(RCTSourceLoadProgressBlock)onProgress
+ onComplete:(RCTSourceLoadBlock)loadCallback
+{
+ [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback];
+}
+
@end
diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm
index 6ffd371d970c76..857b5e4c87e9eb 100644
--- a/packages/rn-tester/RNTester/AppDelegate.mm
+++ b/packages/rn-tester/RNTester/AppDelegate.mm
@@ -80,13 +80,6 @@ - (BOOL)application:(UIApplication *)app
return [RCTLinkingManager application:app openURL:url options:options];
}
-- (void)loadSourceForBridge:(RCTBridge *)bridge
- onProgress:(RCTSourceLoadProgressBlock)onProgress
- onComplete:(RCTSourceLoadBlock)loadCallback
-{
- [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback];
-}
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
| diff --git a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
index 1c9da8919e7054..3c03cc3c1169ed 100644
--- a/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
+++ b/packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm
@@ -140,4 +140,11 @@ - (Class)getModuleClassFromName:(const char *)name
return nullptr;
+- (void)loadSourceForBridge:(RCTBridge *)bridge
+ onProgress:(RCTSourceLoadProgressBlock)onProgress
+ onComplete:(RCTSourceLoadBlock)loadCallback
+{
+ [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback];
+}
+
@end
diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm
index 6ffd371d970c76..857b5e4c87e9eb 100644
--- a/packages/rn-tester/RNTester/AppDelegate.mm
+++ b/packages/rn-tester/RNTester/AppDelegate.mm
@@ -80,13 +80,6 @@ - (BOOL)application:(UIApplication *)app
return [RCTLinkingManager application:app openURL:url options:options];
-- (void)loadSourceForBridge:(RCTBridge *)bridge
- onProgress:(RCTSourceLoadProgressBlock)onProgress
- onComplete:(RCTSourceLoadBlock)loadCallback
-{
- [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback];
-}
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{ | [] | [] | {
"additions": 7,
"author": "cipolleschi",
"deletions": 7,
"html_url": "https://github.com/facebook/react-native/pull/49930",
"issue_id": 49930,
"merged_at": "2025-03-10T16:41:45Z",
"omission_probability": 0.1,
"pr_number": 49930,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][iOS][OldArch] Add missing loadFromSource method in the DefaultRNFactoryDelegate",
"total_changes": 14
} |
501 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index c4c2b3b3f49640..39c7d3e4a8e400 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0-alpha.2"
},
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
},
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
},
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index bd2235c3c7f585..3a28911c07ba86 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -12,6 +12,8 @@
import type {NextHandleFunction, Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
+
import {logger} from '../../utils/logger';
type MiddlewareReturn = {
@@ -65,11 +67,26 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
- communityMiddlewareFallback.indexPageMiddleware =
- community.indexPageMiddleware;
+ // `@react-native-community/cli` is an optional peer dependency of this
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+ const communityCliPath = require.resolve('@react-native-community/cli');
+
+ // `@react-native-community/cli-server-api` is a dependency of
+ // `@react-native-community/cli`, but is not re-exported by it, so we need
+ // to resolve the former through the latter.
+ const communityCliServerApiPath = require.resolve(
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ );
+ // $FlowIgnore[unsupported-syntax] dynamic import
+ const communityCliServerApi: CLIServerAPI = require(
+ communityCliServerApiPath,
+ );
communityMiddlewareFallback.createDevServerMiddleware =
- community.createDevServerMiddleware;
+ communityCliServerApi.createDevServerMiddleware;
+ communityMiddlewareFallback.indexPageMiddleware =
+ communityCliServerApi.indexPageMiddleware;
} catch {
logger.debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 3b572bb1e9c6d6..60fc2b395ae885 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
- commands.push(bundleCommand, startCommand);
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- e.message.includes('@react-native-community/cli-server-api');
-
- if (!known) {
- throw e;
- }
-
- if (verbose) {
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
- }
-}
+const {
+ bundleCommand,
+ startCommand,
+} = require('@react-native/community-cli-plugin');
+commands.push(bundleCommand, startCommand);
const codegenCommand = {
name: 'codegen',
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index c4c2b3b3f49640..39c7d3e4a8e400 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0-alpha.2"
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index bd2235c3c7f585..3a28911c07ba86 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -12,6 +12,8 @@
import type {NextHandleFunction, Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
import {logger} from '../../utils/logger';
type MiddlewareReturn = {
@@ -65,11 +67,26 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
- communityMiddlewareFallback.indexPageMiddleware =
- community.indexPageMiddleware;
+ // `@react-native-community/cli` is an optional peer dependency of this
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+ // `@react-native-community/cli-server-api` is a dependency of
+ // to resolve the former through the latter.
+ const communityCliServerApiPath = require.resolve(
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ // $FlowIgnore[unsupported-syntax] dynamic import
+ const communityCliServerApi: CLIServerAPI = require(
communityMiddlewareFallback.createDevServerMiddleware =
+ communityCliServerApi.createDevServerMiddleware;
+ communityCliServerApi.indexPageMiddleware;
} catch {
logger.debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 3b572bb1e9c6d6..60fc2b395ae885 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- e.message.includes('@react-native-community/cli-server-api');
- if (!known) {
- throw e;
- if (verbose) {
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
-}
+const {
+ bundleCommand,
+} = require('@react-native/community-cli-plugin');
const codegenCommand = {
name: 'codegen', | [
"+ const communityCliPath = require.resolve('@react-native-community/cli');",
"+ // `@react-native-community/cli`, but is not re-exported by it, so we need",
"+ communityCliServerApiPath,",
"- community.createDevServerMiddleware;",
"+ communityMiddlewareFallback.indexPageMiddleware =",
"- commands.push(bundleCommand, startCommand);",
"+ startCommand,",
"+commands.push(bundleCommand, startCommand);"
] | [
40,
43,
51,
54,
56,
74,
92,
94
] | {
"additions": 28,
"author": "robhogan",
"deletions": 27,
"html_url": "https://github.com/facebook/react-native/pull/50095",
"issue_id": 50095,
"merged_at": "2025-03-24T20:12:52Z",
"omission_probability": 0.1,
"pr_number": 50095,
"repo": "facebook/react-native",
"title": "[0.76] community-cli-plugin: resolve cli-server-api via peer dependency on cli",
"total_changes": 55
} |
502 | diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
index 7105d09d60a53a..cc82e684490a3c 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
@@ -16,6 +16,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.Build
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
+import com.facebook.react.uimanager.PixelUtil.dpToPx
import com.facebook.react.uimanager.style.BorderInsets
import com.facebook.react.uimanager.style.BorderRadiusStyle
@@ -198,17 +199,17 @@ internal class CompositeBackgroundDrawable(
computedBorderRadius?.let {
pathForOutline.addRoundRect(
- RectF(bounds),
- floatArrayOf(
- it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f),
- it.topLeft.vertical + (computedBorderInsets?.top ?: 0f),
- it.topRight.horizontal + (computedBorderInsets?.right ?: 0f),
- it.topRight.vertical + (computedBorderInsets?.top ?: 0f),
- it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f),
- it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f),
- it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f),
- it.bottomLeft.vertical) + (computedBorderInsets?.bottom ?: 0f),
- Path.Direction.CW)
+ RectF(bounds),
+ floatArrayOf(
+ (it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
+ (it.topLeft.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
+ (it.topRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
+ (it.topRight.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
+ (it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
+ (it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx(),
+ (it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
+ (it.bottomLeft.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx()),
+ Path.Direction.CW)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
| diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
index 7105d09d60a53a..cc82e684490a3c 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/CompositeBackgroundDrawable.kt
@@ -16,6 +16,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.Build
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
+import com.facebook.react.uimanager.PixelUtil.dpToPx
import com.facebook.react.uimanager.style.BorderInsets
import com.facebook.react.uimanager.style.BorderRadiusStyle
@@ -198,17 +199,17 @@ internal class CompositeBackgroundDrawable(
computedBorderRadius?.let {
pathForOutline.addRoundRect(
- RectF(bounds),
- floatArrayOf(
- it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f),
- it.topRight.vertical + (computedBorderInsets?.top ?: 0f),
- it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f),
- it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f),
- it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f),
- it.bottomLeft.vertical) + (computedBorderInsets?.bottom ?: 0f),
- Path.Direction.CW)
+ RectF(bounds),
+ floatArrayOf(
+ (it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
+ (it.topLeft.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
+ (it.topRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
+ (it.topRight.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
+ (it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
+ (it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx(),
+ (it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
+ (it.bottomLeft.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx()),
+ Path.Direction.CW)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | [
"- it.topLeft.vertical + (computedBorderInsets?.top ?: 0f),",
"- it.topRight.horizontal + (computedBorderInsets?.right ?: 0f),"
] | [
19,
20
] | {
"additions": 12,
"author": "polovi",
"deletions": 11,
"html_url": "https://github.com/facebook/react-native/pull/49877",
"issue_id": 49877,
"merged_at": "2025-03-07T12:06:05Z",
"omission_probability": 0.1,
"pr_number": 49877,
"repo": "facebook/react-native",
"title": "Fix elevation with border-radius set (#48982)",
"total_changes": 23
} |
503 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 5093ce17adbfb1..e7197f5e925cab 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0"
},
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
},
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
},
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index e49282084b119f..611dfbe3fd7b6f 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -9,6 +9,7 @@
* @oncall react_native
*/
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
import type {Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
@@ -66,9 +67,25 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
+ // `@react-native-community/cli` is an optional peer dependency of this
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+ const communityCliPath = require.resolve('@react-native-community/cli');
+
+ // `@react-native-community/cli-server-api` is a dependency of
+ // `@react-native-community/cli`, but is not re-exported by it, so we need
+ // to resolve the former through the latter.
+ const communityCliServerApiPath = require.resolve(
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ );
+ // $FlowIgnore[unsupported-syntax] dynamic import
+ const communityCliServerApi: CLIServerAPI = require(
+ communityCliServerApiPath,
+ );
+ // $FlowIgnore[unsupported-syntax] dynamic import
communityMiddlewareFallback.createDevServerMiddleware =
- community.createDevServerMiddleware;
+ communityCliServerApi.createDevServerMiddleware;
} catch {
debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 9f2aa66f8c8574..97750587c8dcf4 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
- commands.push(bundleCommand, startCommand);
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- e.message.includes('@react-native-community/cli-server-api');
-
- if (!known) {
- throw e;
- }
-
- if (verbose) {
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
- }
-}
+const {
+ bundleCommand,
+ startCommand,
+} = require('@react-native/community-cli-plugin');
+commands.push(bundleCommand, startCommand);
const codegenCommand = {
name: 'codegen',
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 5093ce17adbfb1..e7197f5e925cab 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0"
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index e49282084b119f..611dfbe3fd7b6f 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -9,6 +9,7 @@
* @oncall react_native
*/
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
import type {Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
@@ -66,9 +67,25 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+ const communityCliPath = require.resolve('@react-native-community/cli');
+
+ // `@react-native-community/cli-server-api` is a dependency of
+ // `@react-native-community/cli`, but is not re-exported by it, so we need
+ // to resolve the former through the latter.
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ const communityCliServerApi: CLIServerAPI = require(
+ communityCliServerApiPath,
communityMiddlewareFallback.createDevServerMiddleware =
- community.createDevServerMiddleware;
+ communityCliServerApi.createDevServerMiddleware;
} catch {
debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 9f2aa66f8c8574..97750587c8dcf4 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
- commands.push(bundleCommand, startCommand);
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- e.message.includes('@react-native-community/cli-server-api');
- if (!known) {
- throw e;
- if (verbose) {
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
-}
+const {
+ bundleCommand,
+ startCommand,
+} = require('@react-native/community-cli-plugin');
+commands.push(bundleCommand, startCommand);
const codegenCommand = {
name: 'codegen', | [
"+ // `@react-native-community/cli` is an optional peer dependency of this",
"+ const communityCliServerApiPath = require.resolve("
] | [
34,
42
] | {
"additions": 26,
"author": "robhogan",
"deletions": 25,
"html_url": "https://github.com/facebook/react-native/pull/50098",
"issue_id": 50098,
"merged_at": "2025-03-18T15:15:48Z",
"omission_probability": 0.1,
"pr_number": 50098,
"repo": "facebook/react-native",
"title": "[0.78] community-cli-plugin: resolve cli-server-api via peer dependency on cli",
"total_changes": 51
} |
504 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 83411b9ce35cb1..fc850654156ecb 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0"
},
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
},
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
},
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index db6b46bad276a6..f727d4e11a1a4f 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -9,6 +9,7 @@
* @oncall react_native
*/
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
import type {NextHandleFunction, Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
@@ -65,11 +66,26 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
- communityMiddlewareFallback.indexPageMiddleware =
- community.indexPageMiddleware;
+ // `@react-native-community/cli` is an optional peer dependency of this
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+ const communityCliPath = require.resolve('@react-native-community/cli');
+
+ // `@react-native-community/cli-server-api` is a dependency of
+ // `@react-native-community/cli`, but is not re-exported by it, so we need
+ // to resolve the former through the latter.
+ const communityCliServerApiPath = require.resolve(
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ );
+ // $FlowIgnore[unsupported-syntax] dynamic import
+ const communityCliServerApi: CLIServerAPI = require(
+ communityCliServerApiPath,
+ );
communityMiddlewareFallback.createDevServerMiddleware =
- community.createDevServerMiddleware;
+ communityCliServerApi.createDevServerMiddleware;
+ communityMiddlewareFallback.indexPageMiddleware =
+ communityCliServerApi.indexPageMiddleware;
} catch {
debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 3b572bb1e9c6d6..60fc2b395ae885 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
- commands.push(bundleCommand, startCommand);
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- e.message.includes('@react-native-community/cli-server-api');
-
- if (!known) {
- throw e;
- }
-
- if (verbose) {
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
- }
-}
+const {
+ bundleCommand,
+ startCommand,
+} = require('@react-native/community-cli-plugin');
+commands.push(bundleCommand, startCommand);
const codegenCommand = {
name: 'codegen',
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 83411b9ce35cb1..fc850654156ecb 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -37,10 +37,10 @@
"metro-resolver": "^0.81.0"
"peerDependencies": {
- "@react-native-community/cli-server-api": "*"
+ "@react-native-community/cli": "*"
"peerDependenciesMeta": {
- "@react-native-community/cli-server-api": {
+ "@react-native-community/cli": {
"optional": true
}
diff --git a/packages/community-cli-plugin/src/commands/start/middleware.js b/packages/community-cli-plugin/src/commands/start/middleware.js
index db6b46bad276a6..f727d4e11a1a4f 100644
--- a/packages/community-cli-plugin/src/commands/start/middleware.js
+++ b/packages/community-cli-plugin/src/commands/start/middleware.js
@@ -9,6 +9,7 @@
* @oncall react_native
*/
+import typeof * as CLIServerAPI from '@react-native-community/cli-server-api';
import type {NextHandleFunction, Server} from 'connect';
import type {TerminalReportableEvent} from 'metro/src/lib/TerminalReporter';
@@ -65,11 +66,26 @@ const communityMiddlewareFallback = {
// Attempt to use the community middleware if it exists, but fallback to
// the stubs if it doesn't.
try {
- const community = require('@react-native-community/cli-server-api');
+ // package, and should be a dev dependency of the host project (via the
+ // community template's package.json).
+
+ // `@react-native-community/cli-server-api` is a dependency of
+ // `@react-native-community/cli`, but is not re-exported by it, so we need
+ // to resolve the former through the latter.
+ const communityCliServerApiPath = require.resolve(
+ '@react-native-community/cli-server-api',
+ {paths: [communityCliPath]},
+ // $FlowIgnore[unsupported-syntax] dynamic import
+ const communityCliServerApi: CLIServerAPI = require(
+ communityCliServerApiPath,
communityMiddlewareFallback.createDevServerMiddleware =
- community.createDevServerMiddleware;
+ communityCliServerApi.createDevServerMiddleware;
+ communityMiddlewareFallback.indexPageMiddleware =
+ communityCliServerApi.indexPageMiddleware;
} catch {
debug(`⚠️ Unable to find @react-native-community/cli-server-api
Starting the server without the community middleware.`);
diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js
index 3b572bb1e9c6d6..60fc2b395ae885 100644
--- a/packages/react-native/react-native.config.js
+++ b/packages/react-native/react-native.config.js
@@ -44,27 +44,11 @@ try {
const commands = [];
-try {
- const {
- bundleCommand,
- startCommand,
- } = require('@react-native/community-cli-plugin');
-} catch (e) {
- const known =
- e.code === 'MODULE_NOT_FOUND' &&
- if (!known) {
- throw e;
- console.warn(
- '@react-native-community/cli-server-api not found, the react-native.config.js may be unusable.',
- );
-}
+const {
+ bundleCommand,
+ startCommand,
+} = require('@react-native/community-cli-plugin');
+commands.push(bundleCommand, startCommand);
const codegenCommand = {
name: 'codegen', | [
"- communityMiddlewareFallback.indexPageMiddleware =",
"- community.indexPageMiddleware;",
"+ // `@react-native-community/cli` is an optional peer dependency of this",
"+ const communityCliPath = require.resolve('@react-native-community/cli');",
"- commands.push(bundleCommand, startCommand);",
"- e.message.includes('@react-native-community/cli-server-api');",
"- if (verbose) {"
] | [
34,
35,
36,
39,
73,
77,
83
] | {
"additions": 27,
"author": "robhogan",
"deletions": 27,
"html_url": "https://github.com/facebook/react-native/pull/50096",
"issue_id": 50096,
"merged_at": "2025-03-18T14:30:44Z",
"omission_probability": 0.1,
"pr_number": 50096,
"repo": "facebook/react-native",
"title": "[0.77] community-cli-plugin: resolve cli-server-api via peer dependency on cli",
"total_changes": 54
} |
505 | diff --git a/packages/react-native/Libraries/Image/Image.android.js b/packages/react-native/Libraries/Image/Image.android.js
index 08fbe9d1faca02..752c339ffeea30 100644
--- a/packages/react-native/Libraries/Image/Image.android.js
+++ b/packages/react-native/Libraries/Image/Image.android.js
@@ -133,6 +133,7 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
width: undefined,
height: undefined,
};
+ const defaultSource = resolveAssetSource(props.defaultSource);
const loadingIndicatorSource = resolveAssetSource(
props.loadingIndicatorSource,
);
@@ -178,6 +179,7 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
* when making Flow check .android.js files. */
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
+ defaultSource: defaultSource ? defaultSource.uri : null,
loadingIndicatorSrc: loadingIndicatorSource
? loadingIndicatorSource.uri
: null,
diff --git a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
index 22ac430c2190ef..a6fa43b27feabd 100644
--- a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
+++ b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
@@ -21,6 +21,7 @@ import type {
} from '../StyleSheet/StyleSheet';
import type {ResolvedAssetSource} from './AssetSourceResolver';
import type {ImageProps} from './ImageProps';
+import type {ImageSource} from './ImageSource';
import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry';
import {ConditionallyIgnoredEventHandlers} from '../NativeComponent/ViewConfigIgnore';
@@ -42,7 +43,7 @@ type Props = $ReadOnly<{
| ?ResolvedAssetSource
| ?$ReadOnlyArray<?$ReadOnly<{uri?: ?string, ...}>>,
headers?: ?{[string]: string},
- defaultSrc?: ?string,
+ defaultSource?: ?ImageSource | ?string,
loadingIndicatorSrc?: ?string,
}>;
@@ -82,9 +83,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
},
validAttributes: {
blurRadius: true,
- defaultSource: {
- process: require('./resolveAssetSource'),
- },
+ defaultSource: true,
internal_analyticTag: true,
resizeMethod: true,
resizeMode: true,
diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
index f134c74246f60d..aee2158ddadd68 100644
--- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
+++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
@@ -5004,7 +5004,7 @@ exports[`public API should not change unintentionally Libraries/Image/ImageViewN
| ?ResolvedAssetSource
| ?$ReadOnlyArray<?$ReadOnly<{ uri?: ?string, ... }>>,
headers?: ?{ [string]: string },
- defaultSrc?: ?string,
+ defaultSource?: ?ImageSource | ?string,
loadingIndicatorSrc?: ?string,
}>;
interface NativeCommands {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
index 5abca56df78ceb..63942f03f6ee54 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
@@ -124,7 +124,7 @@ public constructor(
}
}
- @ReactProp(name = "defaultSource", customType = "ImageSource")
+ @ReactProp(name = "defaultSource")
public fun setDefaultSource(view: ReactImageView, source: String?) {
view.setDefaultSource(source)
}
| diff --git a/packages/react-native/Libraries/Image/Image.android.js b/packages/react-native/Libraries/Image/Image.android.js
index 08fbe9d1faca02..752c339ffeea30 100644
--- a/packages/react-native/Libraries/Image/Image.android.js
+++ b/packages/react-native/Libraries/Image/Image.android.js
@@ -133,6 +133,7 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
width: undefined,
height: undefined,
};
+ const defaultSource = resolveAssetSource(props.defaultSource);
const loadingIndicatorSource = resolveAssetSource(
props.loadingIndicatorSource,
);
@@ -178,6 +179,7 @@ let BaseImage: AbstractImageAndroid = React.forwardRef(
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
* when making Flow check .android.js files. */
headers: (source?.[0]?.headers || source?.headers: ?{[string]: string}),
+ defaultSource: defaultSource ? defaultSource.uri : null,
loadingIndicatorSrc: loadingIndicatorSource
? loadingIndicatorSource.uri
: null,
diff --git a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
index 22ac430c2190ef..a6fa43b27feabd 100644
--- a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
+++ b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js
@@ -21,6 +21,7 @@ import type {
} from '../StyleSheet/StyleSheet';
import type {ResolvedAssetSource} from './AssetSourceResolver';
import type {ImageProps} from './ImageProps';
+import type {ImageSource} from './ImageSource';
import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry';
import {ConditionallyIgnoredEventHandlers} from '../NativeComponent/ViewConfigIgnore';
@@ -42,7 +43,7 @@ type Props = $ReadOnly<{
| ?$ReadOnlyArray<?$ReadOnly<{uri?: ?string, ...}>>,
headers?: ?{[string]: string},
@@ -82,9 +83,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
},
validAttributes: {
blurRadius: true,
- defaultSource: {
- process: require('./resolveAssetSource'),
- },
+ defaultSource: true,
internal_analyticTag: true,
resizeMethod: true,
resizeMode: true,
diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
index f134c74246f60d..aee2158ddadd68 100644
--- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
+++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap
@@ -5004,7 +5004,7 @@ exports[`public API should not change unintentionally Libraries/Image/ImageViewN
| ?$ReadOnlyArray<?$ReadOnly<{ uri?: ?string, ... }>>,
headers?: ?{ [string]: string },
interface NativeCommands {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
index 5abca56df78ceb..63942f03f6ee54 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.kt
@@ -124,7 +124,7 @@ public constructor(
}
public fun setDefaultSource(view: ReactImageView, source: String?) {
view.setDefaultSource(source) | [
"- @ReactProp(name = \"defaultSource\", customType = \"ImageSource\")",
"+ @ReactProp(name = \"defaultSource\")"
] | [
73,
74
] | {
"additions": 7,
"author": "fbp93",
"deletions": 6,
"html_url": "https://github.com/facebook/react-native/pull/49890",
"issue_id": 49890,
"merged_at": "2025-03-10T11:25:12Z",
"omission_probability": 0.1,
"pr_number": 49890,
"repo": "facebook/react-native",
"title": "[0.77] Fix Android Image `defaultSource` runtime error (#49097)",
"total_changes": 13
} |
506 | diff --git a/.github/actions/maestro-android/action.yml b/.github/actions/maestro-android/action.yml
index c8882c023b279f..99a8c0733098af 100644
--- a/.github/actions/maestro-android/action.yml
+++ b/.github/actions/maestro-android/action.yml
@@ -25,6 +25,10 @@ inputs:
required: false
default: "."
description: The directory from which metro should be started
+ architecture:
+ required: false
+ default: "NewArch"
+ description: The react native architecture to test
runs:
using: composite
@@ -52,6 +56,7 @@ runs:
if: ${{ inputs.flavor == 'debug' }}
run: ./packages/react-native-codegen/scripts/oss/build.sh
- name: Run e2e tests
+ id: run-tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 24
@@ -69,16 +74,16 @@ runs:
NORM_APP_ID=$(echo "${{ inputs.app-id }}" | tr '.' '-')
echo "app-id=$NORM_APP_ID" >> $GITHUB_OUTPUT
- name: Store tests result
- uses: actions/upload-artifact@v3
+ uses: actions/[email protected]
if: always()
with:
- name: e2e_android_${{ steps.normalize-app-id.outputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}
+ name: e2e_android_${{ steps.normalize-app-id.outputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}_${{ inputs.architecture }}
path: |
report.xml
screen.mp4
- name: Store Logs
- if: failure() && steps.run-tests.outcome == 'failure'
+ if: steps.run-tests.outcome == 'failure'
uses: actions/[email protected]
with:
- name: maestro-logs-android-${{ steps.normalize-app-id.outputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}
+ name: maestro-logs-android-${{ steps.normalize-app-id.outputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.architecture }}
path: /tmp/MaestroLogs
diff --git a/.github/actions/maestro-ios/action.yml b/.github/actions/maestro-ios/action.yml
index 34586168369690..e5dd927bec32ed 100644
--- a/.github/actions/maestro-ios/action.yml
+++ b/.github/actions/maestro-ios/action.yml
@@ -21,6 +21,10 @@ inputs:
required: false
default: "."
description: The directory from which metro should be started
+ architecture:
+ required: false
+ default: "NewArch"
+ description: The react native architecture to test
runs:
using: composite
@@ -86,8 +90,6 @@ runs:
CURR_ATTEMPT=$((CURR_ATTEMPT+1))
echo "Attempt number $CURR_ATTEMPT"
-
-
echo "Start video record using pid: video_record_${{ inputs.jsengine }}_$CURR_ATTEMPT.pid"
xcrun simctl io booted recordVideo video_record_$CURR_ATTEMPT.mov & echo $! > video_record_${{ inputs.jsengine }}_$CURR_ATTEMPT.pid
@@ -105,7 +107,7 @@ runs:
if: always()
uses: actions/[email protected]
with:
- name: e2e_ios_${{ inputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}
+ name: e2e_ios_${{ inputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}_${{ inputs.architecture }}
path: |
video_record_1.mov
video_record_2.mov
@@ -117,5 +119,5 @@ runs:
if: failure() && steps.run-tests.outcome == 'failure'
uses: actions/[email protected]
with:
- name: maestro-logs-${{ inputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}
+ name: maestro-logs-${{ inputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.architecture }}
path: /tmp/MaestroLogs
diff --git a/.github/workflow-scripts/maestro-android.js b/.github/workflow-scripts/maestro-android.js
index 462ce25ae42007..f6533bd0933cdc 100644
--- a/.github/workflow-scripts/maestro-android.js
+++ b/.github/workflow-scripts/maestro-android.js
@@ -55,6 +55,7 @@ async function main() {
stdio: 'ignore',
detached: true,
});
+ metroProcess.unref();
console.info(`- Metro PID: ${metroProcess.pid}`);
}
@@ -88,15 +89,15 @@ async function main() {
if (IS_DEBUG && metroProcess != null) {
const pid = metroProcess.pid;
console.info(`Kill Metro. PID: ${pid}`);
- process.kill(-pid);
+ process.kill(pid);
console.info(`Metro Killed`);
- process.exit();
}
}
if (error) {
throw error;
}
+ process.exit();
}
function sleep(ms) {
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 6511d7dab53ccc..b10d34c232315a 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -233,6 +233,7 @@ jobs:
matrix:
jsengine: [Hermes, JSC]
flavor: [Debug, Release]
+ architecture: [OldArch, NewArch]
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -277,7 +278,12 @@ jobs:
cd /tmp/RNTestProject/ios
bundle install
- HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH bundle exec pod install
+ NEW_ARCH_ENABLED=1
+ if [[ ${{ matrix.architecture }} == "OldArch" ]]; then
+ echo "Disable the New Architecture"
+ NEW_ARCH_ENABLED=0
+ fi
+ HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install
xcodebuild \
-scheme "RNTestProject" \
@@ -295,6 +301,7 @@ jobs:
maestro-flow: ./scripts/e2e/.maestro/
flavor: ${{ matrix.flavor }}
working-directory: /tmp/RNTestProject
+ architecture: ${{ matrix.architecture }}
test_e2e_android_templateapp:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
@@ -306,6 +313,7 @@ jobs:
matrix:
jsengine: [Hermes, JSC]
flavor: [debug, release]
+ architecture: [OldArch, NewArch]
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -351,6 +359,11 @@ jobs:
cd /tmp/RNTestProject
echo "react.internal.mavenLocalRepo=$MAVEN_LOCAL" >> android/gradle.properties
+ if [[ ${{matrix.architecture}} == "OldArch" ]]; then
+ echo "Disabling the New Architecture"
+ sed -i 's/newArchEnabled=true/newArchEnabled=false/' android/gradle.properties
+ fi
+
# Build
cd android
CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}')
@@ -366,6 +379,7 @@ jobs:
install-java: 'false'
flavor: ${{ matrix.flavor }}
working-directory: /tmp/RNTestProject
+ architecture: ${{ matrix.architecture }}
build_hermesc_linux:
runs-on: ubuntu-latest
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 53dd474502eced..e750e9682ba25a 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -1870,8 +1870,8 @@ EXTERNAL SOURCES:
:path: "../react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
- boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
- DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
+ boost: 1dca942403ed9342f98334bf4c3621f011aa7946
+ DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
FBLazyVector: ec2eda6b55fa0e3d32b9f8bd1e6190e95c3189a4
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
@@ -1948,4 +1948,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 8591f96a513620a2a83a0b9a125ad3fa32ea1369
-COCOAPODS: 1.14.3
+COCOAPODS: 1.15.2
| diff --git a/.github/actions/maestro-android/action.yml b/.github/actions/maestro-android/action.yml
index c8882c023b279f..99a8c0733098af 100644
--- a/.github/actions/maestro-android/action.yml
+++ b/.github/actions/maestro-android/action.yml
@@ -25,6 +25,10 @@ inputs:
@@ -52,6 +56,7 @@ runs:
if: ${{ inputs.flavor == 'debug' }}
run: ./packages/react-native-codegen/scripts/oss/build.sh
- name: Run e2e tests
+ id: run-tests
uses: reactivecircus/android-emulator-runner@v2
api-level: 24
@@ -69,16 +74,16 @@ runs:
NORM_APP_ID=$(echo "${{ inputs.app-id }}" | tr '.' '-')
echo "app-id=$NORM_APP_ID" >> $GITHUB_OUTPUT
- name: Store tests result
- uses: actions/upload-artifact@v3
+ uses: actions/[email protected]
- name: e2e_android_${{ steps.normalize-app-id.outputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}
+ name: e2e_android_${{ steps.normalize-app-id.outputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}_${{ inputs.architecture }}
report.xml
screen.mp4
- name: Store Logs
- if: failure() && steps.run-tests.outcome == 'failure'
+ if: steps.run-tests.outcome == 'failure'
- name: maestro-logs-android-${{ steps.normalize-app-id.outputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}
diff --git a/.github/actions/maestro-ios/action.yml b/.github/actions/maestro-ios/action.yml
index 34586168369690..e5dd927bec32ed 100644
--- a/.github/actions/maestro-ios/action.yml
+++ b/.github/actions/maestro-ios/action.yml
@@ -21,6 +21,10 @@ inputs:
@@ -86,8 +90,6 @@ runs:
CURR_ATTEMPT=$((CURR_ATTEMPT+1))
echo "Attempt number $CURR_ATTEMPT"
echo "Start video record using pid: video_record_${{ inputs.jsengine }}_$CURR_ATTEMPT.pid"
xcrun simctl io booted recordVideo video_record_$CURR_ATTEMPT.mov & echo $! > video_record_${{ inputs.jsengine }}_$CURR_ATTEMPT.pid
@@ -105,7 +107,7 @@ runs:
- name: e2e_ios_${{ inputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}
+ name: e2e_ios_${{ inputs.app-id }}_report_${{ inputs.jsengine }}_${{ inputs.flavor }}_${{ inputs.architecture }}
video_record_1.mov
video_record_2.mov
@@ -117,5 +119,5 @@ runs:
if: failure() && steps.run-tests.outcome == 'failure'
- name: maestro-logs-${{ inputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}
+ name: maestro-logs-${{ inputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.architecture }}
diff --git a/.github/workflow-scripts/maestro-android.js b/.github/workflow-scripts/maestro-android.js
index 462ce25ae42007..f6533bd0933cdc 100644
--- a/.github/workflow-scripts/maestro-android.js
+++ b/.github/workflow-scripts/maestro-android.js
@@ -55,6 +55,7 @@ async function main() {
stdio: 'ignore',
detached: true,
});
+ metroProcess.unref();
console.info(`- Metro PID: ${metroProcess.pid}`);
@@ -88,15 +89,15 @@ async function main() {
if (IS_DEBUG && metroProcess != null) {
const pid = metroProcess.pid;
console.info(`Kill Metro. PID: ${pid}`);
- process.kill(-pid);
+ process.kill(pid);
console.info(`Metro Killed`);
- process.exit();
}
if (error) {
throw error;
+ process.exit();
}
function sleep(ms) {
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 6511d7dab53ccc..b10d34c232315a 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -233,6 +233,7 @@ jobs:
flavor: [Debug, Release]
@@ -277,7 +278,12 @@ jobs:
cd /tmp/RNTestProject/ios
bundle install
- HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH bundle exec pod install
+ NEW_ARCH_ENABLED=1
+ if [[ ${{ matrix.architecture }} == "OldArch" ]]; then
+ NEW_ARCH_ENABLED=0
+ HERMES_ENGINE_TARBALL_PATH=$HERMES_PATH RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install
xcodebuild \
-scheme "RNTestProject" \
@@ -295,6 +301,7 @@ jobs:
maestro-flow: ./scripts/e2e/.maestro/
test_e2e_android_templateapp:
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'stable') || inputs.run-e2e-tests }}
@@ -306,6 +313,7 @@ jobs:
flavor: [debug, release]
@@ -351,6 +359,11 @@ jobs:
cd /tmp/RNTestProject
echo "react.internal.mavenLocalRepo=$MAVEN_LOCAL" >> android/gradle.properties
+ if [[ ${{matrix.architecture}} == "OldArch" ]]; then
+ echo "Disabling the New Architecture"
+ sed -i 's/newArchEnabled=true/newArchEnabled=false/' android/gradle.properties
+
# Build
cd android
CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}')
@@ -366,6 +379,7 @@ jobs:
install-java: 'false'
build_hermesc_linux:
runs-on: ubuntu-latest
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 53dd474502eced..e750e9682ba25a 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -1870,8 +1870,8 @@ EXTERNAL SOURCES:
:path: "../react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
- boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
- DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
+ boost: 1dca942403ed9342f98334bf4c3621f011aa7946
+ DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
FBLazyVector: ec2eda6b55fa0e3d32b9f8bd1e6190e95c3189a4
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
@@ -1948,4 +1948,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 8591f96a513620a2a83a0b9a125ad3fa32ea1369
-COCOAPODS: 1.14.3
+COCOAPODS: 1.15.2 | [
"+ name: maestro-logs-android-${{ steps.normalize-app-id.outputs.app-id }}-${{ inputs.jsengine }}-${{ inputs.flavor }}-${{ inputs.architecture }}",
"+ echo \"Disable the New Architecture\""
] | [
42,
133
] | {
"additions": 36,
"author": "cipolleschi",
"deletions": 14,
"html_url": "https://github.com/facebook/react-native/pull/48045",
"issue_id": 48045,
"merged_at": "2024-12-16T14:24:38Z",
"omission_probability": 0.1,
"pr_number": 48045,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][CI] Add Maestro tests for the Old Arch in Template App",
"total_changes": 50
} |
507 | diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index 0242df6dfa3a69..a4710c41458317 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -19,7 +19,6 @@
const {REPO_ROOT} = require('../consts');
const {initNewProjectFromSource} = require('../e2e/init-template-e2e');
-const updateTemplatePackage = require('../releases/update-template-package');
const {
checkPackagerRunning,
launchPackagerInSeparateWindow,
@@ -245,6 +244,11 @@ async function testRNTestProject(
const buildType = 'dry-run';
const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`;
+ const templateRepoFolder = '/tmp/template';
+ const pathToTemplate = path.join(templateRepoFolder, 'template');
+
+ // Cleanup template clone folder
+ exec(`rm -rf ${templateRepoFolder}`);
const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
const mavenLocalPath =
@@ -282,18 +286,32 @@ async function testRNTestProject(
}
}
- updateTemplatePackage({
- 'react-native': `file://${newLocalNodeTGZ}`,
- });
+ // Cloning the template repo
+ // TODO: handle versioning of the template to make sure that we are downloading the right version of
+ // the template, given a specific React Native version
+ exec(
+ `git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`,
+ );
+
+ // Update template version.
+ const appPackageJsonPath = path.join(pathToTemplate, 'package.json');
+ const appPackageJson = JSON.parse(
+ fs.readFileSync(appPackageJsonPath, 'utf8'),
+ );
+ appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`;
+ fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
pushd('/tmp/');
debug('Creating RNTestProject from template');
+ // Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails
+ exec('rm -rf /tmp/RNTestProject');
+
await initNewProjectFromSource({
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
- templatePath: reactNativePackagePath,
+ templatePath: templateRepoFolder,
});
cd('RNTestProject');
| diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index 0242df6dfa3a69..a4710c41458317 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -19,7 +19,6 @@
const {REPO_ROOT} = require('../consts');
const {initNewProjectFromSource} = require('../e2e/init-template-e2e');
-const updateTemplatePackage = require('../releases/update-template-package');
const {
checkPackagerRunning,
launchPackagerInSeparateWindow,
@@ -245,6 +244,11 @@ async function testRNTestProject(
const buildType = 'dry-run';
const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`;
+ const templateRepoFolder = '/tmp/template';
+ const pathToTemplate = path.join(templateRepoFolder, 'template');
+ // Cleanup template clone folder
+ exec(`rm -rf ${templateRepoFolder}`);
const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
const mavenLocalPath =
@@ -282,18 +286,32 @@ async function testRNTestProject(
}
}
- updateTemplatePackage({
- 'react-native': `file://${newLocalNodeTGZ}`,
+ // Cloning the template repo
+ // TODO: handle versioning of the template to make sure that we are downloading the right version of
+ // the template, given a specific React Native version
+ exec(
+ `git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`,
+ // Update template version.
+ const appPackageJson = JSON.parse(
+ fs.readFileSync(appPackageJsonPath, 'utf8'),
+ appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`;
+ fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
pushd('/tmp/');
debug('Creating RNTestProject from template');
+ // Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails
await initNewProjectFromSource({
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
- templatePath: reactNativePackagePath,
+ templatePath: templateRepoFolder,
});
cd('RNTestProject'); | [
"- });",
"+ const appPackageJsonPath = path.join(pathToTemplate, 'package.json');",
"+ exec('rm -rf /tmp/RNTestProject');"
] | [
30,
39,
51
] | {
"additions": 23,
"author": "cipolleschi",
"deletions": 5,
"html_url": "https://github.com/facebook/react-native/pull/45033",
"issue_id": 45033,
"merged_at": "2024-06-18T15:23:08Z",
"omission_probability": 0.1,
"pr_number": 45033,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][Release Testing] Update the testing script to run with the community template",
"total_changes": 28
} |
508 | diff --git a/.github/actions/create-release/action.yml b/.github/actions/create-release/action.yml
index cce43d9348ba82..34480c73841224 100644
--- a/.github/actions/create-release/action.yml
+++ b/.github/actions/create-release/action.yml
@@ -1,5 +1,19 @@
name: create_release
description: Creates a new React Native release
+inputs:
+ version:
+ description: 'The version of React Native we want to release. For example 0.75.0-rc.0'
+ required: true
+ type: string
+ is_latest_on_npm:
+ description: 'Whether we want to tag this release as latest on NPM'
+ required: true
+ type: boolean
+ default: false
+ dry_run:
+ description: 'Whether the job should be executed in dry-run mode or not'
+ type: boolean
+ default: false
runs:
using: composite
steps:
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 85e14987843cae..7b58ae21e39058 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -46,3 +46,7 @@ jobs:
- name: Execute Prepare Release
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH && !steps.check_if_tag_exists.outputs.TAG_EXISTS }}
uses: ./.github/actions/create-release
+ with:
+ version: ${{ inputs.version }}
+ is_latest_on_npm: ${{ inputs.is_latest_on_npm }}
+ dry_run: ${{ inputs.dry_run }}
| diff --git a/.github/actions/create-release/action.yml b/.github/actions/create-release/action.yml
index cce43d9348ba82..34480c73841224 100644
--- a/.github/actions/create-release/action.yml
+++ b/.github/actions/create-release/action.yml
@@ -1,5 +1,19 @@
name: create_release
description: Creates a new React Native release
+ version:
+ type: string
+ is_latest_on_npm:
+ description: 'Whether we want to tag this release as latest on NPM'
+ dry_run:
+ description: 'Whether the job should be executed in dry-run mode or not'
runs:
using: composite
steps:
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 85e14987843cae..7b58ae21e39058 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -46,3 +46,7 @@ jobs:
- name: Execute Prepare Release
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH && !steps.check_if_tag_exists.outputs.TAG_EXISTS }}
uses: ./.github/actions/create-release
+ with:
+ is_latest_on_npm: ${{ inputs.is_latest_on_npm }}
+ dry_run: ${{ inputs.dry_run }} | [
"+inputs:",
"+ description: 'The version of React Native we want to release. For example 0.75.0-rc.0'",
"+ version: ${{ inputs.version }}"
] | [
7,
9,
33
] | {
"additions": 18,
"author": "cipolleschi",
"deletions": 0,
"html_url": "https://github.com/facebook/react-native/pull/45038",
"issue_id": 45038,
"merged_at": "2024-06-18T15:46:49Z",
"omission_probability": 0.1,
"pr_number": 45038,
"repo": "facebook/react-native",
"title": "[LOCAL][CI][Release] Forward inputs to Create Release composite action",
"total_changes": 18
} |
509 | diff --git a/scripts/__tests__/npm-utils-test.js b/scripts/__tests__/npm-utils-test.js
index 7b4345256d5b05..71f796a6792622 100644
--- a/scripts/__tests__/npm-utils-test.js
+++ b/scripts/__tests__/npm-utils-test.js
@@ -151,6 +151,32 @@ describe('npm-utils', () => {
});
});
+ it('return the expected format for patch-prereleases on GHA', () => {
+ const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
+ isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
+ getCurrentCommitMock.mockImplementation(() => 'abcd1234');
+ // exitIfNotOnGit takes a function as a param and it:
+ // 1. checks if we are on git => if not it exits
+ // 2. run the function passed as a param and return the output to the caller
+ // For the mock, we are assuming we are on github and we are returning `false`
+ // as the `getNpmInfo` function will pass a function that checks if the
+ // current commit is a tagged with 'latest'.
+ // In the Mock, we are assuming that we are on git (it does not exits) and the
+ // checkIfLatest function returns `false`
+ exitIfNotOnGitMock.mockImplementation(() => false);
+
+ process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';
+ process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
+ const returnedValue = getNpmInfo('release');
+ expect(returnedValue).toMatchObject({
+ version: `0.74.1-rc.0`,
+ tag: '--no-tag',
+ });
+ process.env.GITHUB_REF = null;
+ process.env.GITHUB_REF_NAME = null;
+ });
+});
+
describe('getVersionsBySpec', () => {
it('should return array when single version returned', () => {
execMock.mockImplementationOnce(() => ({code: 0, stdout: '"0.72.0" \n'}));
diff --git a/scripts/npm-utils.js b/scripts/npm-utils.js
index 3a973a87f664d5..0a05650bfe2919 100644
--- a/scripts/npm-utils.js
+++ b/scripts/npm-utils.js
@@ -89,14 +89,18 @@ function getNpmInfo(buildType /*: BuildType */) /*: NpmInfo */ {
}
if (buildType === 'release') {
- if (process.env.CIRCLE_TAG == null) {
+ // GITHUB_REF contains the fully qualified ref, for example refs/tags/v0.75.0-rc.0
+ // GITHUB_REF_NAME contains the short name, for example v0.75.0-rc.0
+ if (process.env.CIRCLE_TAG == null || process.env.GITHUB_REF == null || !process.env.GITHUB_REF.includes('/tags/') || process.env.GITHUB_REF_NAME == null) {
throw new Error(
- 'CIRCLE_TAG is not set for release. This should only be run in CircleCI. See https://circleci.com/docs/variables/ for how CIRCLE_TAG is set.',
+ 'No version tag found in CI. It looks like this script is running in release mode, but the CIRCLE_TAG or the GITHUB_REF_NAME are missing.',
);
}
+ const versionTag /*: string*/ = process.env.CIRCLE_TAG != null ? process.env.CIRCLE_TAG : process.env.GITHUB_REF_NAME;
+
const {version, major, minor, patch, prerelease} = parseVersion(
- process.env.CIRCLE_TAG,
+ versionTag,
buildType,
);
| diff --git a/scripts/__tests__/npm-utils-test.js b/scripts/__tests__/npm-utils-test.js
index 7b4345256d5b05..71f796a6792622 100644
--- a/scripts/__tests__/npm-utils-test.js
+++ b/scripts/__tests__/npm-utils-test.js
@@ -151,6 +151,32 @@ describe('npm-utils', () => {
});
});
+ it('return the expected format for patch-prereleases on GHA', () => {
+ const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
+ isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
+ getCurrentCommitMock.mockImplementation(() => 'abcd1234');
+ // exitIfNotOnGit takes a function as a param and it:
+ // 1. checks if we are on git => if not it exits
+ // 2. run the function passed as a param and return the output to the caller
+ // For the mock, we are assuming we are on github and we are returning `false`
+ // as the `getNpmInfo` function will pass a function that checks if the
+ // current commit is a tagged with 'latest'.
+ // In the Mock, we are assuming that we are on git (it does not exits) and the
+ // checkIfLatest function returns `false`
+ exitIfNotOnGitMock.mockImplementation(() => false);
+ process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';
+ process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
+ const returnedValue = getNpmInfo('release');
+ expect(returnedValue).toMatchObject({
+ version: `0.74.1-rc.0`,
+ tag: '--no-tag',
+ });
+ process.env.GITHUB_REF = null;
+ process.env.GITHUB_REF_NAME = null;
+});
describe('getVersionsBySpec', () => {
it('should return array when single version returned', () => {
execMock.mockImplementationOnce(() => ({code: 0, stdout: '"0.72.0" \n'}));
diff --git a/scripts/npm-utils.js b/scripts/npm-utils.js
index 3a973a87f664d5..0a05650bfe2919 100644
--- a/scripts/npm-utils.js
+++ b/scripts/npm-utils.js
@@ -89,14 +89,18 @@ function getNpmInfo(buildType /*: BuildType */) /*: NpmInfo */ {
}
if (buildType === 'release') {
- if (process.env.CIRCLE_TAG == null) {
+ // GITHUB_REF contains the fully qualified ref, for example refs/tags/v0.75.0-rc.0
+ // GITHUB_REF_NAME contains the short name, for example v0.75.0-rc.0
+ if (process.env.CIRCLE_TAG == null || process.env.GITHUB_REF == null || !process.env.GITHUB_REF.includes('/tags/') || process.env.GITHUB_REF_NAME == null) {
throw new Error(
- 'CIRCLE_TAG is not set for release. This should only be run in CircleCI. See https://circleci.com/docs/variables/ for how CIRCLE_TAG is set.',
+ 'No version tag found in CI. It looks like this script is running in release mode, but the CIRCLE_TAG or the GITHUB_REF_NAME are missing.',
);
}
+ const versionTag /*: string*/ = process.env.CIRCLE_TAG != null ? process.env.CIRCLE_TAG : process.env.GITHUB_REF_NAME;
const {version, major, minor, patch, prerelease} = parseVersion(
- process.env.CIRCLE_TAG,
+ versionTag,
buildType,
); | [
"+ });"
] | [
31
] | {
"additions": 33,
"author": "cipolleschi",
"deletions": 3,
"html_url": "https://github.com/facebook/react-native/pull/45057",
"issue_id": 45057,
"merged_at": "2024-06-19T09:32:04Z",
"omission_probability": 0.1,
"pr_number": 45057,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][CI] Fix release scripts to use GITHUB_REF and GITHUB_REF_NAME variables",
"total_changes": 36
} |
510 | diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
index df2d16a57a3a86..486cb66031c604 100644
--- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js
+++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
@@ -152,6 +152,7 @@ function extractLibrariesFromJSON(configFile, dependencyPath) {
const config = configFile.codegenConfig;
return [
{
+ libraryName: configFile.name,
config,
libraryPath: dependencyPath,
},
@@ -251,19 +252,23 @@ function findExternalLibraries(pkgJson, projectRoot) {
});
}
-function findLibrariesFromReactNativeConfig(projectRoot) {
+function readRNConfigJSFile(projectRoot) {
const rnConfigFileName = 'react-native.config.js';
- console.log(
- `\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in ${rnConfigFileName}`,
- );
-
const rnConfigFilePath = path.resolve(projectRoot, rnConfigFileName);
if (!fs.existsSync(rnConfigFilePath)) {
return [];
}
- const rnConfig = require(rnConfigFilePath);
+ return require(rnConfigFilePath);
+}
+
+function findLibrariesFromReactNativeConfig(projectRoot) {
+ console.log(
+ `\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in react-native.config.js`,
+ );
+
+ const rnConfig = readRNConfigJSFile(projectRoot);
if (rnConfig.dependencies == null) {
return [];
@@ -289,6 +294,33 @@ function findLibrariesFromReactNativeConfig(projectRoot) {
});
}
+// Function to look for libraries explicitly unlinked from the app
+// through the react-native.config.js file.
+// If this happens, it might be that the app does not need
+// to generate code for that library as it won't be used by that platform
+// @return { [libraryName: string]: [platform: string] }
+function findNotLinkedLibraries(projectRoot) {
+ const rnConfig = readRNConfigJSFile(projectRoot);
+
+ if (rnConfig.dependencies == null) {
+ return {};
+ }
+
+ let notLinkedLibraries = {};
+
+ Object.keys(rnConfig.dependencies).forEach(name => {
+ const dependency = rnConfig.dependencies[name];
+ let notLinkedPlatforms = [];
+ Object.keys(dependency.platforms).forEach(platform => {
+ if (dependency.platforms[platform] == null) {
+ notLinkedPlatforms.push(platform);
+ }
+ });
+ notLinkedLibraries[name] = notLinkedPlatforms
+ });
+ return notLinkedLibraries;
+}
+
function findProjectRootLibraries(pkgJson, projectRoot) {
console.log('[Codegen] Searching for codegen-enabled libraries in the app.');
@@ -694,6 +726,8 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
let platforms =
targetPlatform === 'all' ? supportedPlatforms : [targetPlatform];
+ const notLinkedLibraries = findNotLinkedLibraries(projectRoot);
+
for (const platform of platforms) {
const outputPath = computeOutputPath(
projectRoot,
@@ -702,7 +736,15 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
platform,
);
- const schemaInfos = generateSchemaInfos(libraries);
+ const schemaInfos = generateSchemaInfos(libraries.filter(library => {
+ const unlinkedPlatforms = notLinkedLibraries[library.libraryName];
+ if (unlinkedPlatforms && unlinkedPlatforms.includes(platform)) {
+ console.log(`[Codegen - ${library.libraryName}] Skipping Codegen on ${platform}`);
+ return false;
+ }
+ return true;
+ }));
+
generateNativeCode(
outputPath,
schemaInfos.filter(schemaInfo =>
| diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
index df2d16a57a3a86..486cb66031c604 100644
--- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js
+++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
@@ -152,6 +152,7 @@ function extractLibrariesFromJSON(configFile, dependencyPath) {
const config = configFile.codegenConfig;
return [
{
+ libraryName: configFile.name,
config,
libraryPath: dependencyPath,
},
@@ -251,19 +252,23 @@ function findExternalLibraries(pkgJson, projectRoot) {
-function findLibrariesFromReactNativeConfig(projectRoot) {
const rnConfigFileName = 'react-native.config.js';
- `\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in ${rnConfigFileName}`,
- );
-
const rnConfigFilePath = path.resolve(projectRoot, rnConfigFileName);
if (!fs.existsSync(rnConfigFilePath)) {
}
- const rnConfig = require(rnConfigFilePath);
+function findLibrariesFromReactNativeConfig(projectRoot) {
+ console.log(
+ `\n\n[Codegen] >>>>> Searching for codegen-enabled libraries in react-native.config.js`,
+ );
if (rnConfig.dependencies == null) {
@@ -289,6 +294,33 @@ function findLibrariesFromReactNativeConfig(projectRoot) {
+// Function to look for libraries explicitly unlinked from the app
+// through the react-native.config.js file.
+// If this happens, it might be that the app does not need
+// to generate code for that library as it won't be used by that platform
+// @return { [libraryName: string]: [platform: string] }
+function findNotLinkedLibraries(projectRoot) {
+ if (rnConfig.dependencies == null) {
+ return {};
+ }
+ let notLinkedLibraries = {};
+ Object.keys(rnConfig.dependencies).forEach(name => {
+ const dependency = rnConfig.dependencies[name];
+ let notLinkedPlatforms = [];
+ Object.keys(dependency.platforms).forEach(platform => {
+ if (dependency.platforms[platform] == null) {
+ notLinkedPlatforms.push(platform);
+ }
+ });
+ notLinkedLibraries[name] = notLinkedPlatforms
+ });
function findProjectRootLibraries(pkgJson, projectRoot) {
console.log('[Codegen] Searching for codegen-enabled libraries in the app.');
@@ -694,6 +726,8 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
let platforms =
targetPlatform === 'all' ? supportedPlatforms : [targetPlatform];
+ const notLinkedLibraries = findNotLinkedLibraries(projectRoot);
for (const platform of platforms) {
const outputPath = computeOutputPath(
projectRoot,
@@ -702,7 +736,15 @@ function execute(projectRoot, targetPlatform, baseOutputPath) {
platform,
);
+ const schemaInfos = generateSchemaInfos(libraries.filter(library => {
+ const unlinkedPlatforms = notLinkedLibraries[library.libraryName];
+ if (unlinkedPlatforms && unlinkedPlatforms.includes(platform)) {
+ console.log(`[Codegen - ${library.libraryName}] Skipping Codegen on ${platform}`);
+ return false;
+ }
+ return true;
+ }));
generateNativeCode(
outputPath,
schemaInfos.filter(schemaInfo => | [
"+function readRNConfigJSFile(projectRoot) {",
"- console.log(",
"+ return require(rnConfigFilePath);",
"+ return notLinkedLibraries;",
"- const schemaInfos = generateSchemaInfos(libraries);"
] | [
17,
20,
30,
70,
89
] | {
"additions": 49,
"author": "cipolleschi",
"deletions": 7,
"html_url": "https://github.com/facebook/react-native/pull/47712",
"issue_id": 47712,
"merged_at": "2024-12-04T17:25:17Z",
"omission_probability": 0.1,
"pr_number": 47712,
"repo": "facebook/react-native",
"title": "[Codegen] Exclude unlinked libs from codegen",
"total_changes": 56
} |
511 | diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
index ad267de81138df..680ca63e1e5a81 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
@@ -337,7 +337,7 @@ T RCTConvertTo(SEL selector, id json)
SEL selector = selectorForType(argumentType);
if ([RCTConvert respondsToSelector:selector]) {
- id objCArg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ id objCArg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
if (objCArgType == @encode(char)) {
char arg = RCTConvertTo<char>(selector, objCArg);
@@ -491,7 +491,7 @@ T RCTConvertTo(SEL selector, id json)
}
RCTResponseSenderBlock arg =
- (RCTResponseSenderBlock)TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ (RCTResponseSenderBlock)TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
if (arg) {
[retainedObjectsForInvocation addObject:arg];
}
@@ -506,7 +506,7 @@ T RCTConvertTo(SEL selector, id json)
}
RCTResponseSenderBlock senderBlock =
- (RCTResponseSenderBlock)TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ (RCTResponseSenderBlock)TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
RCTResponseErrorBlock arg = ^(NSError *error) {
senderBlock(@[ RCTJSErrorFromNSError(error) ]);
};
@@ -536,7 +536,7 @@ T RCTConvertTo(SEL selector, id json)
runtime, errorPrefix + "JavaScript argument must be a plain object. Got " + getType(runtime, jsiArg));
}
- id arg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ id arg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
RCTManagedPointer *(*convert)(id, SEL, id) = (__typeof__(convert))objc_msgSend;
RCTManagedPointer *box = convert([RCTCxxConvert class], selector, arg);
diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
index f54e1751fb9465..7899037ee0b4fe 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
@@ -32,6 +32,7 @@ using EventEmitterCallback = std::function<void(const std::string &, id)>;
namespace TurboModuleConvertUtils {
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker);
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull);
} // namespace TurboModuleConvertUtils
template <>
diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
index 1b4b8762cdfe53..167368828e39eb 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
@@ -112,20 +112,20 @@ static int32_t getUniqueId()
}
static NSArray *
-convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value, std::shared_ptr<CallInvoker> jsInvoker)
+convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
{
size_t size = value.size(runtime);
NSMutableArray *result = [NSMutableArray new];
for (size_t i = 0; i < size; i++) {
// Insert kCFNull when it's `undefined` value to preserve the indices.
- id convertedObject = convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker);
+ id convertedObject = convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker, useNSNull);
[result addObject:convertedObject ? convertedObject : (id)kCFNull];
}
return [result copy];
}
static NSDictionary *
-convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker)
+convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
{
jsi::Array propertyNames = value.getPropertyNames(runtime);
size_t size = propertyNames.size(runtime);
@@ -133,7 +133,7 @@ static int32_t getUniqueId()
for (size_t i = 0; i < size; i++) {
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
NSString *k = convertJSIStringToNSString(runtime, name);
- id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name), jsInvoker);
+ id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name), jsInvoker, useNSNull);
if (v) {
result[k] = v;
}
@@ -159,11 +159,14 @@ static int32_t getUniqueId()
};
}
-id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker)
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
{
- if (value.isUndefined() || value.isNull()) {
+ if (value.isUndefined() || (value.isNull() && !useNSNull)) {
return nil;
}
+ if (value.isNull() && useNSNull) {
+ return [NSNull null];
+ }
if (value.isBool()) {
return @(value.getBool());
}
@@ -176,17 +179,22 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
if (value.isObject()) {
jsi::Object o = value.getObject(runtime);
if (o.isArray(runtime)) {
- return convertJSIArrayToNSArray(runtime, o.getArray(runtime), jsInvoker);
+ return convertJSIArrayToNSArray(runtime, o.getArray(runtime), jsInvoker, useNSNull);
}
if (o.isFunction(runtime)) {
return convertJSIFunctionToCallback(runtime, o.getFunction(runtime), jsInvoker);
}
- return convertJSIObjectToNSDictionary(runtime, o, jsInvoker);
+ return convertJSIObjectToNSDictionary(runtime, o, jsInvoker, useNSNull);
}
throw std::runtime_error("Unsupported jsi::Value kind");
}
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker)
+{
+ return convertJSIValueToObjCObject(runtime, value, jsInvoker, NO);
+}
+
static jsi::Value createJSRuntimeError(jsi::Runtime &runtime, const std::string &message)
{
return runtime.global().getPropertyAsFunction(runtime, "Error").call(runtime, message);
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 03dbf0257f5ced..4d5f3b322908a9 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -1888,12 +1888,12 @@ EXTERNAL SOURCES:
:path: "../react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
- boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
- DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
+ boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
+ DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
FBLazyVector: a2db46e659b982d7193563db43dfc90c9a213074
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
- glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
+ glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
hermes-engine: d152d4b5b123cb9abbd21183ed7783e067314c76
MyNativeView: ba8324184f90f76b5051af6716faa458d4d63b51
NativeCxxModuleExample: ad2c1a2c0def6c6a1bf5f1257e6bc372b806aea5
@@ -1966,4 +1966,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 8591f96a513620a2a83a0b9a125ad3fa32ea1369
-COCOAPODS: 1.15.2
+COCOAPODS: 1.14.3
| diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
index ad267de81138df..680ca63e1e5a81 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm
@@ -337,7 +337,7 @@ T RCTConvertTo(SEL selector, id json)
SEL selector = selectorForType(argumentType);
if ([RCTConvert respondsToSelector:selector]) {
- id objCArg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ id objCArg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
if (objCArgType == @encode(char)) {
char arg = RCTConvertTo<char>(selector, objCArg);
@@ -491,7 +491,7 @@ T RCTConvertTo(SEL selector, id json)
RCTResponseSenderBlock arg =
if (arg) {
[retainedObjectsForInvocation addObject:arg];
@@ -506,7 +506,7 @@ T RCTConvertTo(SEL selector, id json)
RCTResponseSenderBlock senderBlock =
RCTResponseErrorBlock arg = ^(NSError *error) {
senderBlock(@[ RCTJSErrorFromNSError(error) ]);
};
@@ -536,7 +536,7 @@ T RCTConvertTo(SEL selector, id json)
runtime, errorPrefix + "JavaScript argument must be a plain object. Got " + getType(runtime, jsiArg));
- id arg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_);
+ id arg = TurboModuleConvertUtils::convertJSIValueToObjCObject(runtime, jsiArg, jsInvoker_, YES);
RCTManagedPointer *(*convert)(id, SEL, id) = (__typeof__(convert))objc_msgSend;
RCTManagedPointer *box = convert([RCTCxxConvert class], selector, arg);
diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
index f54e1751fb9465..7899037ee0b4fe 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h
@@ -32,6 +32,7 @@ using EventEmitterCallback = std::function<void(const std::string &, id)>;
namespace TurboModuleConvertUtils {
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker);
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull);
} // namespace TurboModuleConvertUtils
template <>
diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
index 1b4b8762cdfe53..167368828e39eb 100644
--- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
+++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm
@@ -112,20 +112,20 @@ static int32_t getUniqueId()
static NSArray *
-convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value, std::shared_ptr<CallInvoker> jsInvoker)
+convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
size_t size = value.size(runtime);
NSMutableArray *result = [NSMutableArray new];
// Insert kCFNull when it's `undefined` value to preserve the indices.
- id convertedObject = convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker);
+ id convertedObject = convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker, useNSNull);
[result addObject:convertedObject ? convertedObject : (id)kCFNull];
return [result copy];
static NSDictionary *
-convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker)
+convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
jsi::Array propertyNames = value.getPropertyNames(runtime);
size_t size = propertyNames.size(runtime);
@@ -133,7 +133,7 @@ static int32_t getUniqueId()
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
NSString *k = convertJSIStringToNSString(runtime, name);
- id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name), jsInvoker);
+ id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name), jsInvoker, useNSNull);
if (v) {
result[k] = v;
@@ -159,11 +159,14 @@ static int32_t getUniqueId()
};
-id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker)
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker, BOOL useNSNull)
- if (value.isUndefined() || value.isNull()) {
+ if (value.isUndefined() || (value.isNull() && !useNSNull)) {
return nil;
+ return [NSNull null];
+ }
if (value.isBool()) {
return @(value.getBool());
@@ -176,17 +179,22 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
if (value.isObject()) {
jsi::Object o = value.getObject(runtime);
if (o.isArray(runtime)) {
- return convertJSIArrayToNSArray(runtime, o.getArray(runtime), jsInvoker);
+ return convertJSIArrayToNSArray(runtime, o.getArray(runtime), jsInvoker, useNSNull);
if (o.isFunction(runtime)) {
return convertJSIFunctionToCallback(runtime, o.getFunction(runtime), jsInvoker);
- return convertJSIObjectToNSDictionary(runtime, o, jsInvoker);
+ return convertJSIObjectToNSDictionary(runtime, o, jsInvoker, useNSNull);
throw std::runtime_error("Unsupported jsi::Value kind");
+id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker)
+{
+
static jsi::Value createJSRuntimeError(jsi::Runtime &runtime, const std::string &message)
return runtime.global().getPropertyAsFunction(runtime, "Error").call(runtime, message);
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 03dbf0257f5ced..4d5f3b322908a9 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -1888,12 +1888,12 @@ EXTERNAL SOURCES:
:path: "../react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
- boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
- DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
+ boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
+ DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
FBLazyVector: a2db46e659b982d7193563db43dfc90c9a213074
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
- glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
hermes-engine: d152d4b5b123cb9abbd21183ed7783e067314c76
MyNativeView: ba8324184f90f76b5051af6716faa458d4d63b51
NativeCxxModuleExample: ad2c1a2c0def6c6a1bf5f1257e6bc372b806aea5
@@ -1966,4 +1966,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 8591f96a513620a2a83a0b9a125ad3fa32ea1369
-COCOAPODS: 1.15.2
+COCOAPODS: 1.14.3 | [
"+ if (value.isNull() && useNSNull) {",
"+ return convertJSIValueToObjCObject(runtime, value, jsInvoker, NO);",
"+}",
"+ glog: 69ef571f3de08433d766d614c73a9838a06bf7eb"
] | [
100,
125,
126,
147
] | {
"additions": 25,
"author": "cipolleschi",
"deletions": 16,
"html_url": "https://github.com/facebook/react-native/pull/49291",
"issue_id": 49291,
"merged_at": "2025-02-10T15:35:30Z",
"omission_probability": 0.1,
"pr_number": 49291,
"repo": "facebook/react-native",
"title": "[RN][iOS][0.77] Properly handle null values in the TMInterop layer",
"total_changes": 41
} |
512 | diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
index 7725250921d86c..9c4448e0dcfdec 100644
--- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js
+++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
@@ -311,12 +311,27 @@ function findNotLinkedLibraries(projectRoot) {
Object.keys(rnConfig.dependencies).forEach(name => {
const dependency = rnConfig.dependencies[name];
let notLinkedPlatforms = [];
- Object.keys(dependency.platforms).forEach(platform => {
+
+ // dependency.platforms might not be defined, as the format
+ // {
+ // "dependencies": {
+ // "dependency-name": {
+ // "root": "path/to/dependency",
+ // }
+ // }
+ // }
+ // is also supported.
+ // In this case, we assume that the library is linked to all platforms.
+ // We don't consider the case were `dependency-name.root` is equal to `null`, because that
+ // means that the library is not linked to the app at all, and in that case the dependency
+ // should be removed by the user.
+ dependency.platforms && Object.keys(dependency.platforms).forEach(platform => {
if (dependency.platforms[platform] == null) {
notLinkedPlatforms.push(platform);
}
});
notLinkedLibraries[name] = notLinkedPlatforms;
+
});
return notLinkedLibraries;
}
| diff --git a/packages/react-native/scripts/codegen/generate-artifacts-executor.js b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
index 7725250921d86c..9c4448e0dcfdec 100644
--- a/packages/react-native/scripts/codegen/generate-artifacts-executor.js
+++ b/packages/react-native/scripts/codegen/generate-artifacts-executor.js
@@ -311,12 +311,27 @@ function findNotLinkedLibraries(projectRoot) {
Object.keys(rnConfig.dependencies).forEach(name => {
const dependency = rnConfig.dependencies[name];
let notLinkedPlatforms = [];
- Object.keys(dependency.platforms).forEach(platform => {
+ // dependency.platforms might not be defined, as the format
+ // {
+ // "dependencies": {
+ // "dependency-name": {
+ // "root": "path/to/dependency",
+ // }
+ // }
+ // }
+ // is also supported.
+ // In this case, we assume that the library is linked to all platforms.
+ // We don't consider the case were `dependency-name.root` is equal to `null`, because that
+ // means that the library is not linked to the app at all, and in that case the dependency
+ dependency.platforms && Object.keys(dependency.platforms).forEach(platform => {
if (dependency.platforms[platform] == null) {
notLinkedPlatforms.push(platform);
}
});
notLinkedLibraries[name] = notLinkedPlatforms;
});
return notLinkedLibraries;
} | [
"+ // should be removed by the user."
] | [
22
] | {
"additions": 16,
"author": "cipolleschi",
"deletions": 1,
"html_url": "https://github.com/facebook/react-native/pull/48183",
"issue_id": 48183,
"merged_at": "2024-12-09T14:39:29Z",
"omission_probability": 0.1,
"pr_number": 48183,
"repo": "facebook/react-native",
"title": "[RN][Codegen] Better support filtering out non linked platforms",
"total_changes": 17
} |
513 | diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 4072fd09925646..0aa04cecf2f2ed 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -1028,9 +1028,6 @@ jobs:
name: Build HermesC for Windows
command: |
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
- choco install --no-progress cmake -y
- if (-not $?) { throw "Failed to install CMake" }
-
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index d9a518749972d7..1ad358019480e7 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -469,9 +469,6 @@ jobs:
- name: Build HermesC for Windows
run: |
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
- choco install --no-progress cmake --version 3.14.7
- if (-not $?) { throw "Failed to install CMake" }
-
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index bacde615c4cf4e..a4dfa14ef53ae2 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -466,9 +466,6 @@ jobs:
- name: Build HermesC for Windows
run: |
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
- choco install --no-progress cmake --version 3.14.7
- if (-not $?) { throw "Failed to install CMake" }
-
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 1e93df9126454b..24720665aad0fd 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -543,9 +543,6 @@ jobs:
- name: Build HermesC for Windows
run: |
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
- choco install --no-progress cmake --version 3.14.7
- if (-not $?) { throw "Failed to install CMake" }
-
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
| diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 4072fd09925646..0aa04cecf2f2ed 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -1028,9 +1028,6 @@ jobs:
name: Build HermesC for Windows
command: |
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
- choco install --no-progress cmake -y
- if (-not $?) { throw "Failed to install CMake" }
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index d9a518749972d7..1ad358019480e7 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -469,9 +469,6 @@ jobs:
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index bacde615c4cf4e..a4dfa14ef53ae2 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -466,9 +466,6 @@ jobs:
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 1e93df9126454b..24720665aad0fd 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -543,9 +543,6 @@ jobs: | [] | [] | {
"additions": 0,
"author": "blakef",
"deletions": 12,
"html_url": "https://github.com/facebook/react-native/pull/48139",
"issue_id": 48139,
"merged_at": "2024-12-06T10:56:08Z",
"omission_probability": 0.1,
"pr_number": 48139,
"repo": "facebook/react-native",
"title": "[LOCAL] fix/0.75 stable windows cmake",
"total_changes": 12
} |
514 | diff --git a/packages/react-native-babel-preset/package.json b/packages/react-native-babel-preset/package.json
index 692806a0ddd176..4976cea51639cc 100644
--- a/packages/react-native-babel-preset/package.json
+++ b/packages/react-native-babel-preset/package.json
@@ -56,7 +56,7 @@
"@babel/plugin-transform-unicode-regex": "^7.24.7",
"@babel/template": "^7.25.0",
"@react-native/babel-plugin-codegen": "0.76.1",
- "babel-plugin-syntax-hermes-parser": "^0.23.1",
+ "babel-plugin-syntax-hermes-parser": "^0.25.1",
"babel-plugin-transform-flow-enums": "^0.0.2",
"react-refresh": "^0.14.0"
},
diff --git a/packages/react-native-babel-preset/src/configs/main.js b/packages/react-native-babel-preset/src/configs/main.js
index c3b7f9d914224a..077e1a68b02287 100644
--- a/packages/react-native-babel-preset/src/configs/main.js
+++ b/packages/react-native-babel-preset/src/configs/main.js
@@ -25,7 +25,7 @@ function isTSXSource(fileName) {
const loose = true;
const defaultPlugins = [
- [require('babel-plugin-syntax-hermes-parser')],
+ [require('babel-plugin-syntax-hermes-parser'), {parseLangTypes: 'flow'}],
[require('babel-plugin-transform-flow-enums')],
[require('@babel/plugin-transform-block-scoping')],
[require('@babel/plugin-transform-class-properties'), {loose}],
diff --git a/yarn.lock b/yarn.lock
index dd8a6e595669fb..0f551a0e4810b7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2851,6 +2851,13 @@ [email protected]:
dependencies:
hermes-parser "0.24.0"
+babel-plugin-syntax-hermes-parser@^0.25.1:
+ version "0.25.1"
+ resolved "https://registry.yarnpkg.com/babel-plugin-syntax-hermes-parser/-/babel-plugin-syntax-hermes-parser-0.25.1.tgz#58b539df973427fcfbb5176a3aec7e5dee793cb0"
+ integrity sha512-IVNpGzboFLfXZUAwkLFcI/bnqVbwky0jP3eBno4HKtqvQJAHBLdgxiG6lQ4to0+Q/YCN3PO0od5NZwIKyY4REQ==
+ dependencies:
+ hermes-parser "0.25.1"
+
babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0:
version "7.0.0-beta.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf"
@@ -4936,6 +4943,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.24.0.tgz#487dc1ddc0bae698c2d79f34153ac9bf62d7b3c0"
integrity sha512-LyoXLB7IFzeZW0EvAbGZacbxBN7t6KKSDqFJPo3Ydow7wDlrDjXwsdiAHV6XOdvEN9MEuWXsSIFN4tzpyrXIHw==
[email protected]:
+ version "0.25.1"
+ resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
+ integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
+
[email protected]:
version "0.23.1"
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.1.tgz#e5de648e664f3b3d84d01b48fc7ab164f4b68205"
@@ -4950,6 +4962,13 @@ [email protected]:
dependencies:
hermes-estree "0.24.0"
[email protected]:
+ version "0.25.1"
+ resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1"
+ integrity sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==
+ dependencies:
+ hermes-estree "0.25.1"
+
[email protected]:
version "0.23.1"
resolved "https://registry.yarnpkg.com/hermes-transform/-/hermes-transform-0.23.1.tgz#ea6d401117db8398de9723dc1cf936a9a3c8477b"
| diff --git a/packages/react-native-babel-preset/package.json b/packages/react-native-babel-preset/package.json
index 692806a0ddd176..4976cea51639cc 100644
--- a/packages/react-native-babel-preset/package.json
+++ b/packages/react-native-babel-preset/package.json
@@ -56,7 +56,7 @@
"@babel/plugin-transform-unicode-regex": "^7.24.7",
"@babel/template": "^7.25.0",
"@react-native/babel-plugin-codegen": "0.76.1",
- "babel-plugin-syntax-hermes-parser": "^0.23.1",
+ "babel-plugin-syntax-hermes-parser": "^0.25.1",
"babel-plugin-transform-flow-enums": "^0.0.2",
"react-refresh": "^0.14.0"
},
diff --git a/packages/react-native-babel-preset/src/configs/main.js b/packages/react-native-babel-preset/src/configs/main.js
index c3b7f9d914224a..077e1a68b02287 100644
--- a/packages/react-native-babel-preset/src/configs/main.js
+++ b/packages/react-native-babel-preset/src/configs/main.js
@@ -25,7 +25,7 @@ function isTSXSource(fileName) {
const loose = true;
const defaultPlugins = [
[require('babel-plugin-transform-flow-enums')],
[require('@babel/plugin-transform-block-scoping')],
[require('@babel/plugin-transform-class-properties'), {loose}],
diff --git a/yarn.lock b/yarn.lock
index dd8a6e595669fb..0f551a0e4810b7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2851,6 +2851,13 @@ [email protected]:
hermes-parser "0.24.0"
+babel-plugin-syntax-hermes-parser@^0.25.1:
+ resolved "https://registry.yarnpkg.com/babel-plugin-syntax-hermes-parser/-/babel-plugin-syntax-hermes-parser-0.25.1.tgz#58b539df973427fcfbb5176a3aec7e5dee793cb0"
+ integrity sha512-IVNpGzboFLfXZUAwkLFcI/bnqVbwky0jP3eBno4HKtqvQJAHBLdgxiG6lQ4to0+Q/YCN3PO0od5NZwIKyY4REQ==
+ hermes-parser "0.25.1"
babel-plugin-syntax-trailing-function-commas@^7.0.0-beta.0:
version "7.0.0-beta.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-7.0.0-beta.0.tgz#aa213c1435e2bffeb6fca842287ef534ad05d5cf"
@@ -4936,6 +4943,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.24.0.tgz#487dc1ddc0bae698c2d79f34153ac9bf62d7b3c0"
integrity sha512-LyoXLB7IFzeZW0EvAbGZacbxBN7t6KKSDqFJPo3Ydow7wDlrDjXwsdiAHV6XOdvEN9MEuWXsSIFN4tzpyrXIHw==
[email protected]:
+ resolved "https://registry.yarnpkg.com/hermes-estree/-/hermes-estree-0.25.1.tgz#6aeec17d1983b4eabf69721f3aa3eb705b17f480"
+ integrity sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==
[email protected]:
resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.23.1.tgz#e5de648e664f3b3d84d01b48fc7ab164f4b68205"
@@ -4950,6 +4962,13 @@ [email protected]:
hermes-estree "0.24.0"
[email protected]:
+ resolved "https://registry.yarnpkg.com/hermes-parser/-/hermes-parser-0.25.1.tgz#5be0e487b2090886c62bd8a11724cd766d5f54d1"
+ integrity sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==
+ hermes-estree "0.25.1"
[email protected]:
resolved "https://registry.yarnpkg.com/hermes-transform/-/hermes-transform-0.23.1.tgz#ea6d401117db8398de9723dc1cf936a9a3c8477b" | [
"- [require('babel-plugin-syntax-hermes-parser')],",
"+ [require('babel-plugin-syntax-hermes-parser'), {parseLangTypes: 'flow'}],"
] | [
21,
22
] | {
"additions": 21,
"author": "huntie",
"deletions": 2,
"html_url": "https://github.com/facebook/react-native/pull/47569",
"issue_id": 47569,
"merged_at": "2024-11-13T12:12:23Z",
"omission_probability": 0.1,
"pr_number": 47569,
"repo": "facebook/react-native",
"title": "[0.76] Skip hermes-parser under Babel for non-Flow JS code",
"total_changes": 23
} |
515 | diff --git a/.circleci/configurations/executors.yml b/.circleci/configurations/executors.yml
index f06f0497773e35..5ffb38877eddc1 100644
--- a/.circleci/configurations/executors.yml
+++ b/.circleci/configurations/executors.yml
@@ -39,7 +39,7 @@ executors:
reactnativeios-lts:
<<: *defaults
macos:
- xcode: '14.3.1'
+ xcode: '15.1'
resource_class: macos.m1.medium.gen1
environment:
- RCT_BUILD_HERMES_FROM_SOURCE: true
diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 942d8396885021..4491cbdf0a8b67 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -786,9 +786,6 @@ jobs:
- HERMES_WS_DIR: *hermes_workspace_root
- HERMES_TARBALL_ARTIFACTS_DIR: *hermes_tarball_artifacts_dir
- HERMES_OSXBIN_ARTIFACTS_DIR: *hermes_osxbin_artifacts_dir
- - IOS_DEPLOYMENT_TARGET: "13.4"
- - XROS_DEPLOYMENT_TARGET: "1.0"
- - MACOSX_DEPLOYMENT_TARGET: "10.15"
steps:
- *attach_hermes_workspace
- stop_job_if_apple_artifacts_are_there:
@@ -824,6 +821,23 @@ jobs:
echo "[HERMES] Building Hermes for iOS: $SLICE"
BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
fi
+
+ if [[ "$SLICE" == "macosx" ]]; then
+ export MACOSX_DEPLOYMENT_TARGET="10.15"
+ echo "[HERMES] Building Hermes for MacOS"
+ BUILD_TYPE="<< parameters.flavor >>" ./utils/build-mac-framework.sh
+ unset MACOSX_DEPLOYMENT_TARGET
+ elif [[ "$SLICE" == "xros" ]] || [[ "$SLICE" == "xrsimulator" ]]; then
+ export XROS_DEPLOYMENT_TARGET="1.0"
+ echo "[HERMES] Building Hermes for XR: $SLICE"
+ BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
+ unset XROS_DEPLOYMENT_TARGET
+ elif [[ "$SLICE" == "iphoneos" ]] || [[ "$SLICE" == "iphonesimulator" ]] || [[ "$SLICE" == "catalyst" ]] ; then
+ export IOS_DEPLOYMENT_TARGET="13.4"
+ echo "[HERMES] Building Hermes for iOS: $SLICE"
+ BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
+ unset IOS_DEPLOYMENT_TARGET
+ fi
unset RELEASE_VERSION
echo "Moving from build_$SLICE to $FINAL_PATH"
@@ -1131,6 +1145,11 @@ jobs:
- run:
name: Creating release commit
command: |
+ # I'm seeing failures in automatically detect the email for the
+ # agent that should push the commit.
+ git config --global user.name "Distiller"
+ git config --global user.email "[email protected]"
+
git commit -a -m "Release << parameters.version >>" -m "#publish-packages-to-npm&<< parameters.tag >>"
git tag -a "v<< parameters.version >>" -m "v<< parameters.version >>"
env GIT_PAGER=cat git show HEAD
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 4ff9d802e8fa19..914870327c5427 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -59,7 +59,7 @@ references:
# Dependency Anchors
# -------------------------
dependency_versions:
- xcode_version: &xcode_version "15.0.1"
+ xcode_version: &xcode_version "15.2"
nodelts_image: &nodelts_image "cimg/node:20.2.0"
nodeprevlts_image: &nodeprevlts_image "cimg/node:18.12.1"
nodelts_browser_image: &nodelts_browser_image "cimg/node:20.2.0-browsers"
| diff --git a/.circleci/configurations/executors.yml b/.circleci/configurations/executors.yml
index f06f0497773e35..5ffb38877eddc1 100644
--- a/.circleci/configurations/executors.yml
+++ b/.circleci/configurations/executors.yml
@@ -39,7 +39,7 @@ executors:
reactnativeios-lts:
<<: *defaults
macos:
+ xcode: '15.1'
resource_class: macos.m1.medium.gen1
environment:
- RCT_BUILD_HERMES_FROM_SOURCE: true
diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 942d8396885021..4491cbdf0a8b67 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -786,9 +786,6 @@ jobs:
- HERMES_WS_DIR: *hermes_workspace_root
- HERMES_TARBALL_ARTIFACTS_DIR: *hermes_tarball_artifacts_dir
- HERMES_OSXBIN_ARTIFACTS_DIR: *hermes_osxbin_artifacts_dir
- - IOS_DEPLOYMENT_TARGET: "13.4"
- - MACOSX_DEPLOYMENT_TARGET: "10.15"
steps:
- *attach_hermes_workspace
- stop_job_if_apple_artifacts_are_there:
@@ -824,6 +821,23 @@ jobs:
echo "[HERMES] Building Hermes for iOS: $SLICE"
BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
fi
+ if [[ "$SLICE" == "macosx" ]]; then
+ export MACOSX_DEPLOYMENT_TARGET="10.15"
+ echo "[HERMES] Building Hermes for MacOS"
+ BUILD_TYPE="<< parameters.flavor >>" ./utils/build-mac-framework.sh
+ unset MACOSX_DEPLOYMENT_TARGET
+ elif [[ "$SLICE" == "xros" ]] || [[ "$SLICE" == "xrsimulator" ]]; then
+ echo "[HERMES] Building Hermes for XR: $SLICE"
+ unset XROS_DEPLOYMENT_TARGET
+ elif [[ "$SLICE" == "iphoneos" ]] || [[ "$SLICE" == "iphonesimulator" ]] || [[ "$SLICE" == "catalyst" ]] ; then
+ export IOS_DEPLOYMENT_TARGET="13.4"
+ echo "[HERMES] Building Hermes for iOS: $SLICE"
+ unset IOS_DEPLOYMENT_TARGET
+ fi
unset RELEASE_VERSION
echo "Moving from build_$SLICE to $FINAL_PATH"
@@ -1131,6 +1145,11 @@ jobs:
- run:
name: Creating release commit
command: |
+ # I'm seeing failures in automatically detect the email for the
+ # agent that should push the commit.
+ git config --global user.name "Distiller"
git commit -a -m "Release << parameters.version >>" -m "#publish-packages-to-npm&<< parameters.tag >>"
git tag -a "v<< parameters.version >>" -m "v<< parameters.version >>"
env GIT_PAGER=cat git show HEAD
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 4ff9d802e8fa19..914870327c5427 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -59,7 +59,7 @@ references:
# Dependency Anchors
# -------------------------
dependency_versions:
nodelts_image: &nodelts_image "cimg/node:20.2.0"
nodeprevlts_image: &nodeprevlts_image "cimg/node:18.12.1"
nodelts_browser_image: &nodelts_browser_image "cimg/node:20.2.0-browsers" | [
"- xcode: '14.3.1'",
"- - XROS_DEPLOYMENT_TARGET: \"1.0\"",
"+ export XROS_DEPLOYMENT_TARGET=\"1.0\"",
"+ git config --global user.email \"[email protected]\"",
"- xcode_version: &xcode_version \"15.0.1\"",
"+ xcode_version: &xcode_version \"15.2\""
] | [
8,
22,
38,
58,
71,
72
] | {
"additions": 24,
"author": "cipolleschi",
"deletions": 5,
"html_url": "https://github.com/facebook/react-native/pull/45580",
"issue_id": 45580,
"merged_at": "2024-07-23T12:06:30Z",
"omission_probability": 0.1,
"pr_number": 45580,
"repo": "facebook/react-native",
"title": "[RN][0.74]Fix XROS build",
"total_changes": 29
} |
516 | diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 4491cbdf0a8b67..aec9b109d8a134 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -816,27 +816,13 @@ jobs:
export RELEASE_VERSION=$(cat /tmp/react-native-version)
if [[ "$SLICE" == "macosx" ]]; then
echo "[HERMES] Building Hermes for MacOS"
- BUILD_TYPE="<< parameters.flavor >>" ./utils/build-mac-framework.sh
- else
- echo "[HERMES] Building Hermes for iOS: $SLICE"
- BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
- fi
-
- if [[ "$SLICE" == "macosx" ]]; then
- export MACOSX_DEPLOYMENT_TARGET="10.15"
- echo "[HERMES] Building Hermes for MacOS"
- BUILD_TYPE="<< parameters.flavor >>" ./utils/build-mac-framework.sh
- unset MACOSX_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" MACOSX_DEPLOYMENT_TARGET=10.15 ./utils/build-mac-framework.sh
elif [[ "$SLICE" == "xros" ]] || [[ "$SLICE" == "xrsimulator" ]]; then
- export XROS_DEPLOYMENT_TARGET="1.0"
echo "[HERMES] Building Hermes for XR: $SLICE"
- BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
- unset XROS_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" XROS_DEPLOYMENT_TARGET=1.0 ./utils/build-ios-framework.sh "$SLICE"
elif [[ "$SLICE" == "iphoneos" ]] || [[ "$SLICE" == "iphonesimulator" ]] || [[ "$SLICE" == "catalyst" ]] ; then
- export IOS_DEPLOYMENT_TARGET="13.4"
echo "[HERMES] Building Hermes for iOS: $SLICE"
- BUILD_TYPE="<< parameters.flavor >>" ./utils/build-ios-framework.sh "$SLICE"
- unset IOS_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" IOS_DEPLOYMENT_TARGET=13.4 ./utils/build-ios-framework.sh "$SLICE"
fi
unset RELEASE_VERSION
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 914870327c5427..d9466370f2640d 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -73,22 +73,22 @@ references:
checkout_cache_key: &checkout_cache_key v1-checkout
gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v3-gradle-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
- yarn_cache_key: &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }}
+ yarn_cache_key: &yarn_cache_key v7-yarn-cache-{{ .Environment.CIRCLE_JOB }}
rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }}
- hermes_workspace_cache_key: &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
- hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_workspace_cache_key: &hermes_workspace_cache_key v8-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Hermes iOS
hermesc_apple_cache_key: &hermesc_apple_cache_key v4-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v8-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v6-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v5-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v13-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v10-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v9-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v5-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v3-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v3-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v3-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v4-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v4-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Cocoapods - RNTester
pods_cache_key: &pods_cache_key v12-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
cocoapods_cache_key: &cocoapods_cache_key v12-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
diff --git a/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh b/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
index c4f37dadd368f2..225cb55b02c79e 100755
--- a/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
+++ b/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
@@ -27,10 +27,8 @@ function get_architecture {
function get_deployment_target {
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
echo "$(get_visionos_deployment_target)"
- return
else
echo "$(get_ios_deployment_target)"
- return
fi
}
| diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 4491cbdf0a8b67..aec9b109d8a134 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -816,27 +816,13 @@ jobs:
export RELEASE_VERSION=$(cat /tmp/react-native-version)
if [[ "$SLICE" == "macosx" ]]; then
echo "[HERMES] Building Hermes for MacOS"
- else
- echo "[HERMES] Building Hermes for iOS: $SLICE"
- fi
-
- if [[ "$SLICE" == "macosx" ]]; then
- export MACOSX_DEPLOYMENT_TARGET="10.15"
- echo "[HERMES] Building Hermes for MacOS"
- unset MACOSX_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" MACOSX_DEPLOYMENT_TARGET=10.15 ./utils/build-mac-framework.sh
elif [[ "$SLICE" == "xros" ]] || [[ "$SLICE" == "xrsimulator" ]]; then
- export XROS_DEPLOYMENT_TARGET="1.0"
echo "[HERMES] Building Hermes for XR: $SLICE"
- unset XROS_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" XROS_DEPLOYMENT_TARGET=1.0 ./utils/build-ios-framework.sh "$SLICE"
elif [[ "$SLICE" == "iphoneos" ]] || [[ "$SLICE" == "iphonesimulator" ]] || [[ "$SLICE" == "catalyst" ]] ; then
- export IOS_DEPLOYMENT_TARGET="13.4"
echo "[HERMES] Building Hermes for iOS: $SLICE"
- unset IOS_DEPLOYMENT_TARGET
+ BUILD_TYPE="<< parameters.flavor >>" IOS_DEPLOYMENT_TARGET=13.4 ./utils/build-ios-framework.sh "$SLICE"
fi
unset RELEASE_VERSION
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 914870327c5427..d9466370f2640d 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -73,22 +73,22 @@ references:
checkout_cache_key: &checkout_cache_key v1-checkout
gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v3-gradle-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
- yarn_cache_key: &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }}
rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }}
- hermes_workspace_cache_key: &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
- hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_workspace_cache_key: &hermes_workspace_cache_key v8-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Hermes iOS
hermesc_apple_cache_key: &hermesc_apple_cache_key v4-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v6-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v5-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v13-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v9-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v5-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v3-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v3-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v3-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v4-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v4-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Cocoapods - RNTester
pods_cache_key: &pods_cache_key v12-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
cocoapods_cache_key: &cocoapods_cache_key v12-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
diff --git a/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh b/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
index c4f37dadd368f2..225cb55b02c79e 100755
--- a/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
+++ b/packages/react-native/sdks/hermes-engine/utils/build-ios-framework.sh
@@ -27,10 +27,8 @@ function get_architecture {
function get_deployment_target {
if [[ $1 == "xros" || $1 == "xrsimulator" ]]; then
echo "$(get_visionos_deployment_target)"
else
echo "$(get_ios_deployment_target)"
fi
} | [
"+ yarn_cache_key: &yarn_cache_key v7-yarn-cache-{{ .Environment.CIRCLE_JOB }}",
"- hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v8-hermes-apple-{{ checksum \"/tmp/hermes/hermesversion\" }}-{{ checksum \"/tmp/react-native-version\" }}-{{ checksum \"packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh\" }}",
"+ hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v10-hermes-tarball-debug-{{ checksum \"/tmp/hermes/hermesversion\" }}-{{ checksum \"/tmp/react-native-version\" }}-{{ checksum \"packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh\" }}"
] | [
44,
56,
60
] | {
"additions": 12,
"author": "cipolleschi",
"deletions": 28,
"html_url": "https://github.com/facebook/react-native/pull/45840",
"issue_id": 45840,
"merged_at": "2024-08-04T23:30:41Z",
"omission_probability": 0.1,
"pr_number": 45840,
"repo": "facebook/react-native",
"title": "[RN][Hermes] Fore Hermes versions for slices through env var",
"total_changes": 40
} |
517 | diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index d4bdc08a66dabb..eb3c02aa31ecac 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -25,12 +25,14 @@ const {parseArgs} = require('@pkgjs/parseargs');
const chalk = require('chalk');
const {execSync} = require('child_process');
const path = require('path');
+const {popd, pushd} = require('shelljs');
const fs = require('fs');
const config = {
options: {
projectName: {type: 'string'},
directory: {type: 'string'},
+ currentBranch: {type: 'string'},
verbose: {type: 'boolean', default: false},
help: {type: 'boolean'},
},
@@ -59,6 +61,7 @@ async function main() {
Options:
--projectName The name of the new React Native project.
+ --currentBranch The current branch to checkout.
--directory The absolute path to the target project directory.
--pathToLocalReactNative The absolute path to the local react-native package.
--verbose Print additional output. Default: false.
@@ -77,9 +80,10 @@ async function initNewProjectFromSource(
{
projectName,
directory,
+ currentBranch,
pathToLocalReactNative = null,
verbose = false,
- } /*: {projectName: string, directory: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
+ } /*: {projectName: string, directory: string, currentBranch: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
) {
console.log('Starting local npm proxy (Verdaccio)');
const verdaccioPid = setupVerdaccio();
@@ -92,12 +96,15 @@ async function initNewProjectFromSource(
});
console.log('\nDone ✅');
- console.log('Publishing packages to local npm proxy\n');
const packages = await getPackages({
includeReactNative: false,
includePrivate: false,
});
+ // packages are updated in a lockstep, let's get the version of the first one
+ const version = packages[Object.keys(packages)[0]].packageJson.version;
+
+ console.log('Publishing packages to local npm proxy\n');
for (const {path: packagePath, packageJson} of Object.values(packages)) {
const desc = `${packageJson.name} (${path.relative(
REPO_ROOT,
@@ -117,11 +124,17 @@ async function initNewProjectFromSource(
}
console.log('\nDone ✅');
+ const pathToTemplate = _prepareTemplate(
+ version,
+ pathToLocalReactNative,
+ currentBranch,
+ );
+
console.log('Running react-native init without install');
execSync(
`npx @react-native-community/cli@next init ${projectName} \
--directory ${directory} \
- --version 0.75.0-rc.2 \
+ --template file://${pathToTemplate} \
--verbose \
--pm npm \
--skip-install`,
@@ -133,9 +146,6 @@ async function initNewProjectFromSource(
);
console.log('\nDone ✅');
- _updateScopedPackages(packages, directory);
- _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory);
-
console.log('Installing project dependencies');
await installProjectUsingProxy(directory);
console.log('Done ✅');
@@ -177,15 +187,12 @@ async function installProjectUsingProxy(cwd /*: string */) {
function _updateScopedPackages(
packages /*: ProjectInfo */,
directory /*: string */,
+ version /*: string */,
) {
console.log(
'Updating the scoped packagesto match the version published in Verdaccio',
);
- // Packages are updated in a lockstep and all with the same version.
- // Pick the version from the first package
- const version = packages[Object.keys(packages)[0]].packageJson.version;
-
// Update scoped packages which starts with @react-native
const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
@@ -208,25 +215,59 @@ function _updateScopedPackages(
console.log('Done ✅');
}
-function _updateReactNativeInTemplateIfNeeded(
- pathToLocalReactNative /*: ?string */,
- directory /*: string */,
+function _prepareTemplate(
+ version /*: string */,
+ pathToLocalReactNative /*: ?string*/,
+ currentBranch /*: string*/,
) {
+ console.log('Prepare template locally');
+
+ const templateCloneBaseFolder = '/tmp/react-native-tmp/template';
+ execSync(`rm -rf ${templateCloneBaseFolder}`);
+
+ const templateCloneFolder = path.join(templateCloneBaseFolder, 'template');
+
+ execSync(
+ `git clone https://github.com/react-native-community/template ${templateCloneBaseFolder}`,
+ );
+
+ pushd(templateCloneBaseFolder);
+
+ execSync(`git checkout ${currentBranch}`);
+
+ pushd('template');
+
+ // read the package.json
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
+
+ // and update the dependencies and devDependencies of packages scoped as @react-native
+ // to the version passed as parameter
+ for (const [key, _] of Object.entries(packageJson.dependencies)) {
+ if (key.startsWith('@react-native')) {
+ packageJson.dependencies[key] = version;
+ }
+ }
+
+ for (const [key, _] of Object.entries(packageJson.devDependencies)) {
+ if (key.startsWith('@react-native')) {
+ packageJson.devDependencies[key] = version;
+ }
+ }
+
if (pathToLocalReactNative != null) {
- console.log('Updating the template version to local react-native');
- // Update template version.
- const appPackageJsonPath = path.join(directory, 'package.json');
- const appPackageJson = JSON.parse(
- fs.readFileSync(appPackageJsonPath, 'utf8'),
- );
- appPackageJson.dependencies['react-native'] =
- `file:${pathToLocalReactNative}`;
- fs.writeFileSync(
- appPackageJsonPath,
- JSON.stringify(appPackageJson, null, 2),
- );
- console.log('Done ✅');
+ packageJson.dependencies['react-native'] = `file:${pathToLocalReactNative}`;
}
+
+ // write the package.json to disk
+ fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
+
+ popd();
+ const templateTgz = execSync(`npm pack`).toString().trim();
+
+ popd();
+
+ console.log('Done ✅');
+ return path.join(templateCloneBaseFolder, templateTgz);
}
module.exports = {
diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index 832be80dd2ad60..c7c07e37f06c71 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -281,9 +281,11 @@ async function testRNTestProject(
}
}
- pushd('/tmp/');
+ const currentBranch = exec(`git rev-parse --abbrev-ref HEAD`)
+ .toString()
+ .trim();
- debug('Creating RNTestProject from template');
+ pushd('/tmp/');
// Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails
exec('rm -rf /tmp/RNTestProject');
@@ -292,6 +294,7 @@ async function testRNTestProject(
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
pathToLocalReactNative: newLocalNodeTGZ,
+ currentBranch,
});
cd('RNTestProject');
| diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index d4bdc08a66dabb..eb3c02aa31ecac 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -25,12 +25,14 @@ const {parseArgs} = require('@pkgjs/parseargs');
const chalk = require('chalk');
const {execSync} = require('child_process');
const path = require('path');
+const {popd, pushd} = require('shelljs');
const fs = require('fs');
const config = {
options: {
projectName: {type: 'string'},
directory: {type: 'string'},
+ currentBranch: {type: 'string'},
verbose: {type: 'boolean', default: false},
help: {type: 'boolean'},
},
@@ -59,6 +61,7 @@ async function main() {
Options:
--projectName The name of the new React Native project.
+ --currentBranch The current branch to checkout.
--directory The absolute path to the target project directory.
--pathToLocalReactNative The absolute path to the local react-native package.
--verbose Print additional output. Default: false.
@@ -77,9 +80,10 @@ async function initNewProjectFromSource(
{
projectName,
directory,
pathToLocalReactNative = null,
verbose = false,
- } /*: {projectName: string, directory: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
+ } /*: {projectName: string, directory: string, currentBranch: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
console.log('Starting local npm proxy (Verdaccio)');
const verdaccioPid = setupVerdaccio();
@@ -92,12 +96,15 @@ async function initNewProjectFromSource(
- console.log('Publishing packages to local npm proxy\n');
const packages = await getPackages({
includeReactNative: false,
includePrivate: false,
+ // packages are updated in a lockstep, let's get the version of the first one
+ const version = packages[Object.keys(packages)[0]].packageJson.version;
+ console.log('Publishing packages to local npm proxy\n');
for (const {path: packagePath, packageJson} of Object.values(packages)) {
const desc = `${packageJson.name} (${path.relative(
REPO_ROOT,
@@ -117,11 +124,17 @@ async function initNewProjectFromSource(
+ const pathToTemplate = _prepareTemplate(
+ version,
+ pathToLocalReactNative,
+ );
console.log('Running react-native init without install');
execSync(
`npx @react-native-community/cli@next init ${projectName} \
--directory ${directory} \
- --version 0.75.0-rc.2 \
+ --template file://${pathToTemplate} \
--verbose \
--pm npm \
--skip-install`,
@@ -133,9 +146,6 @@ async function initNewProjectFromSource(
);
- _updateScopedPackages(packages, directory);
- _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory);
console.log('Installing project dependencies');
await installProjectUsingProxy(directory);
console.log('Done ✅');
@@ -177,15 +187,12 @@ async function installProjectUsingProxy(cwd /*: string */) {
function _updateScopedPackages(
packages /*: ProjectInfo */,
directory /*: string */,
console.log(
'Updating the scoped packagesto match the version published in Verdaccio',
);
- // Pick the version from the first package
// Update scoped packages which starts with @react-native
const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
@@ -208,25 +215,59 @@ function _updateScopedPackages(
console.log('Done ✅');
-function _updateReactNativeInTemplateIfNeeded(
- pathToLocalReactNative /*: ?string */,
- directory /*: string */,
+function _prepareTemplate(
+ pathToLocalReactNative /*: ?string*/,
+ currentBranch /*: string*/,
+ console.log('Prepare template locally');
+ const templateCloneBaseFolder = '/tmp/react-native-tmp/template';
+ execSync(`rm -rf ${templateCloneBaseFolder}`);
+ const templateCloneFolder = path.join(templateCloneBaseFolder, 'template');
+ execSync(
+ `git clone https://github.com/react-native-community/template ${templateCloneBaseFolder}`,
+ );
+ pushd(templateCloneBaseFolder);
+ execSync(`git checkout ${currentBranch}`);
+ pushd('template');
+ // read the package.json
+ // and update the dependencies and devDependencies of packages scoped as @react-native
+ // to the version passed as parameter
+ for (const [key, _] of Object.entries(packageJson.dependencies)) {
+ packageJson.dependencies[key] = version;
+ packageJson.devDependencies[key] = version;
if (pathToLocalReactNative != null) {
- // Update template version.
- const appPackageJsonPath = path.join(directory, 'package.json');
- const appPackageJson = JSON.parse(
- fs.readFileSync(appPackageJsonPath, 'utf8'),
- appPackageJson.dependencies['react-native'] =
- `file:${pathToLocalReactNative}`;
- fs.writeFileSync(
- appPackageJsonPath,
- JSON.stringify(appPackageJson, null, 2),
- console.log('Done ✅');
+ packageJson.dependencies['react-native'] = `file:${pathToLocalReactNative}`;
+ // write the package.json to disk
+ fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
+ const templateTgz = execSync(`npm pack`).toString().trim();
+ console.log('Done ✅');
+ return path.join(templateCloneBaseFolder, templateTgz);
module.exports = {
diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index 832be80dd2ad60..c7c07e37f06c71 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -281,9 +281,11 @@ async function testRNTestProject(
- pushd('/tmp/');
+ const currentBranch = exec(`git rev-parse --abbrev-ref HEAD`)
+ .trim();
- debug('Creating RNTestProject from template');
+ pushd('/tmp/');
// Cleanup RNTestProject folder. This makes it easier to rerun the script when it fails
exec('rm -rf /tmp/RNTestProject');
@@ -292,6 +294,7 @@ async function testRNTestProject(
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
pathToLocalReactNative: newLocalNodeTGZ,
});
cd('RNTestProject'); | [
"+ currentBranch,",
"- // Packages are updated in a lockstep and all with the same version.",
"- const version = packages[Object.keys(packages)[0]].packageJson.version;",
"+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));",
"+ for (const [key, _] of Object.entries(packageJson.devDependencies)) {",
"- console.log('Updating the template version to local react-native');",
"+ .toString()"
] | [
63,
95,
97,
132,
142,
149,
188
] | {
"additions": 72,
"author": "cipolleschi",
"deletions": 28,
"html_url": "https://github.com/facebook/react-native/pull/45201",
"issue_id": 45201,
"merged_at": "2024-07-03T15:11:09Z",
"omission_probability": 0.1,
"pr_number": 45201,
"repo": "facebook/react-native",
"title": "[RN][Testing] Update testing scripts to work with any version of React native",
"total_changes": 100
} |
518 | diff --git a/.github/actions/test_ios_helloworld/action.yml b/.github/actions/test_ios_helloworld/action.yml
index 6a76091c7fcb93..5df716c6a74f56 100644
--- a/.github/actions/test_ios_helloworld/action.yml
+++ b/.github/actions/test_ios_helloworld/action.yml
@@ -46,12 +46,13 @@ runs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Create Hermes folder
+ shell: bash
run: mkdir -p "$HERMES_WS_DIR"
- name: Download Hermes
uses: actions/download-artifact@v4
with:
name: hermes-darwin-bin-${{ inputs.flavor }}
- path: $HERMES_WS_DIR/hermes-runtime-darwin/
+ path: /tmp/hermes/hermes-runtime-darwin/
- name: Print Downloaded hermes
shell: bash
run: ls -lR "$HERMES_WS_DIR"
@@ -80,16 +81,27 @@ runs:
args+=(--jsvm jsc)
yarn bootstrap ios "${args[@]}" | cat
else
+ # Tarball is restored with capital flavors suffix, but somehow the tarball name from JS at line 96 returns as lowercased.
+ # Let's ensure that the tarballs have the right names
+
+ if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" ]]; then
+ mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz"
+ fi
+
+ if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" ]]; then
+ mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz"
+ fi
BUILD_TYPE="${{ inputs.flavor }}"
TARBALL_FILENAME=$(node ../react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")
- HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/hermes-darwin-bin-${{ inputs.flavor }}/$TARBALL_FILENAME"
+ HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME"
HERMES_ENGINE_TARBALL_PATH="$HERMES_PATH" yarn bootstrap ios "${args[@]}" | cat
fi
- name: Build HelloWorld project
shell: bash
run: |
cd packages/helloworld
+
args=()
if [[ ${{ inputs.flavor }} == "Release" ]]; then
args+=(--prod)
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 0f762c271bd886..582b7f3c4f0dc9 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -284,6 +284,8 @@ jobs:
echo "[HERMES] Creating the universal framework"
chmod +x ./utils/build-ios-framework.sh
./utils/build-ios-framework.sh build_framework
+
+ chmod +x ./destroot/bin/hermesc
- name: Package the Hermes Apple frameworks
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -310,7 +312,7 @@ jobs:
cp ./packages/react-native/sdks/hermes/build_macosx/bin/* /tmp/hermes/osx-bin/${{ matrix.flavor }}
ls -lR /tmp/hermes/osx-bin/
- name: Create dSYM archive
- if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
FLAVOR=${{ matrix.flavor }}
WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR"
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 3f0c7e55112c95..4f5565687a9327 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -281,6 +281,8 @@ jobs:
echo "[HERMES] Creating the universal framework"
chmod +x ./utils/build-ios-framework.sh
./utils/build-ios-framework.sh build_framework
+
+ chmod +x ./destroot/bin/hermesc
- name: Package the Hermes Apple frameworks
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -307,7 +309,7 @@ jobs:
cp ./packages/react-native/sdks/hermes/build_macosx/bin/* /tmp/hermes/osx-bin/${{ matrix.flavor }}
ls -lR /tmp/hermes/osx-bin/
- name: Create dSYM archive
- if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
FLAVOR=${{ matrix.flavor }}
WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR"
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index a589f341213707..6daedc97a77316 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -206,7 +206,7 @@ jobs:
- name: Restore Cached Artifacts
uses: actions/cache/[email protected]
with:
- key: v2-hermes-osx-bin-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
@@ -292,6 +292,8 @@ jobs:
echo "[HERMES] Creating the universal framework"
chmod +x ./utils/build-ios-framework.sh
./utils/build-ios-framework.sh build_framework
+
+ chmod +x ./destroot/bin/hermesc
- name: Package the Hermes Apple frameworks
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -318,7 +320,7 @@ jobs:
cp ./packages/react-native/sdks/hermes/build_macosx/bin/* /tmp/hermes/osx-bin/${{ matrix.flavor }}
ls -lR /tmp/hermes/osx-bin/
- name: Create dSYM archive
- if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != true }}
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
FLAVOR=${{ matrix.flavor }}
WORKING_DIR="/tmp/hermes_tmp/dSYM/$FLAVOR"
@@ -364,7 +366,7 @@ jobs:
uses: actions/cache/[email protected]
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
with:
- key: v2-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index 0cc15af58fe5db..8e864e79c169a4 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -11,6 +11,7 @@
'use strict';
+import type {ProjectInfo} from '../utils/monorepo';
const {retry} = require('../circleci/retry');
const {REPO_ROOT} = require('../consts');
const {getPackages} = require('../utils/monorepo');
@@ -172,49 +173,48 @@ async function installProjectUsingProxy(cwd /*: string */) {
}
}
-function _updateScopedPackages(packages, directory) {
- console.log('Updating the scoped packagesto match the version published in Verdaccio');
+function _updateScopedPackages(
+ packages /*: ProjectInfo */,
+ directory /*: string */,
+) {
+ console.log(
+ 'Updating the scoped packagesto match the version published in Verdaccio',
+ );
// Packages are updated in a lockstep and all with the same version.
// Pick the version from the first package
const version = packages[Object.keys(packages)[0]].packageJson.version;
// Update scoped packages which starts with @react-native
- const appPackageJsonPath = path.join(
- directory,
- 'package.json',
- );
+ const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
fs.readFileSync(appPackageJsonPath, 'utf8'),
);
for (const [key, _] of Object.entries(appPackageJson.dependencies)) {
if (key.startsWith('@react-native')) {
- appPackageJson.dependencies[key] = version
+ appPackageJson.dependencies[key] = version;
}
}
for (const [key, _] of Object.entries(appPackageJson.devDependencies)) {
if (key.startsWith('@react-native')) {
- appPackageJson.devDependencies[key] = version
+ appPackageJson.devDependencies[key] = version;
}
}
- fs.writeFileSync(
- appPackageJsonPath,
- JSON.stringify(appPackageJson, null, 2),
- );
+ fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
console.log('Done ✅');
}
-function _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory) {
+function _updateReactNativeInTemplateIfNeeded(
+ pathToLocalReactNative /*: ?string */,
+ directory /*: string */,
+) {
if (pathToLocalReactNative != null) {
console.log('Updating the template version to local react-native');
// Update template version.
- const appPackageJsonPath = path.join(
- directory,
- 'package.json',
- );
+ const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
fs.readFileSync(appPackageJsonPath, 'utf8'),
);
diff --git a/scripts/utils/monorepo.js b/scripts/utils/monorepo.js
index 1c530e89f20a48..cf1c113b7c802e 100644
--- a/scripts/utils/monorepo.js
+++ b/scripts/utils/monorepo.js
@@ -42,7 +42,7 @@ export type PackageInfo = {
packageJson: PackageJson,
};
-type ProjectInfo = {
+export type ProjectInfo = {
[packageName: string]: PackageInfo,
};
*/
| diff --git a/.github/actions/test_ios_helloworld/action.yml b/.github/actions/test_ios_helloworld/action.yml
index 6a76091c7fcb93..5df716c6a74f56 100644
--- a/.github/actions/test_ios_helloworld/action.yml
+++ b/.github/actions/test_ios_helloworld/action.yml
@@ -46,12 +46,13 @@ runs:
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Create Hermes folder
run: mkdir -p "$HERMES_WS_DIR"
- name: Download Hermes
uses: actions/download-artifact@v4
with:
name: hermes-darwin-bin-${{ inputs.flavor }}
- path: $HERMES_WS_DIR/hermes-runtime-darwin/
+ path: /tmp/hermes/hermes-runtime-darwin/
- name: Print Downloaded hermes
run: ls -lR "$HERMES_WS_DIR"
@@ -80,16 +81,27 @@ runs:
args+=(--jsvm jsc)
yarn bootstrap ios "${args[@]}" | cat
else
+ # Tarball is restored with capital flavors suffix, but somehow the tarball name from JS at line 96 returns as lowercased.
+ # Let's ensure that the tarballs have the right names
+ if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" ]]; then
+ mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Debug.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-debug.tar.gz"
+ if [[ -f "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" ]]; then
+ mv "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-Release.tar.gz" "$HERMES_WS_DIR/hermes-runtime-darwin/hermes-ios-release.tar.gz"
BUILD_TYPE="${{ inputs.flavor }}"
TARBALL_FILENAME=$(node ../react-native/scripts/hermes/get-tarball-name.js --buildType "$BUILD_TYPE")
- HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/hermes-darwin-bin-${{ inputs.flavor }}/$TARBALL_FILENAME"
+ HERMES_PATH="$HERMES_WS_DIR/hermes-runtime-darwin/$TARBALL_FILENAME"
HERMES_ENGINE_TARBALL_PATH="$HERMES_PATH" yarn bootstrap ios "${args[@]}" | cat
fi
- name: Build HelloWorld project
run: |
cd packages/helloworld
args=()
if [[ ${{ inputs.flavor }} == "Release" ]]; then
args+=(--prod)
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 0f762c271bd886..582b7f3c4f0dc9 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -284,6 +284,8 @@ jobs:
@@ -310,7 +312,7 @@ jobs:
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 3f0c7e55112c95..4f5565687a9327 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -281,6 +281,8 @@ jobs:
@@ -307,7 +309,7 @@ jobs:
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index a589f341213707..6daedc97a77316 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -206,7 +206,7 @@ jobs:
- name: Restore Cached Artifacts
uses: actions/cache/[email protected]
- key: v2-hermes-osx-bin-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
@@ -292,6 +292,8 @@ jobs:
@@ -318,7 +320,7 @@ jobs:
@@ -364,7 +366,7 @@ jobs:
uses: actions/cache/[email protected]
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
- key: v2-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index 0cc15af58fe5db..8e864e79c169a4 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -11,6 +11,7 @@
'use strict';
+import type {ProjectInfo} from '../utils/monorepo';
const {retry} = require('../circleci/retry');
const {REPO_ROOT} = require('../consts');
const {getPackages} = require('../utils/monorepo');
@@ -172,49 +173,48 @@ async function installProjectUsingProxy(cwd /*: string */) {
- console.log('Updating the scoped packagesto match the version published in Verdaccio');
+function _updateScopedPackages(
+ packages /*: ProjectInfo */,
+ console.log(
+ 'Updating the scoped packagesto match the version published in Verdaccio',
+ );
// Packages are updated in a lockstep and all with the same version.
// Pick the version from the first package
const version = packages[Object.keys(packages)[0]].packageJson.version;
// Update scoped packages which starts with @react-native
- const appPackageJsonPath = path.join(
- 'package.json',
+ const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
fs.readFileSync(appPackageJsonPath, 'utf8'),
);
for (const [key, _] of Object.entries(appPackageJson.dependencies)) {
- appPackageJson.dependencies[key] = version
+ appPackageJson.dependencies[key] = version;
for (const [key, _] of Object.entries(appPackageJson.devDependencies)) {
- appPackageJson.devDependencies[key] = version
+ appPackageJson.devDependencies[key] = version;
- appPackageJsonPath,
- JSON.stringify(appPackageJson, null, 2),
+ fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
console.log('Done ✅');
-function _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory) {
+function _updateReactNativeInTemplateIfNeeded(
+ pathToLocalReactNative /*: ?string */,
if (pathToLocalReactNative != null) {
console.log('Updating the template version to local react-native');
// Update template version.
- const appPackageJsonPath = path.join(
- directory,
- 'package.json',
- );
+ const appPackageJsonPath = path.join(directory, 'package.json');
const appPackageJson = JSON.parse(
fs.readFileSync(appPackageJsonPath, 'utf8'),
);
diff --git a/scripts/utils/monorepo.js b/scripts/utils/monorepo.js
index 1c530e89f20a48..cf1c113b7c802e 100644
--- a/scripts/utils/monorepo.js
+++ b/scripts/utils/monorepo.js
@@ -42,7 +42,7 @@ export type PackageInfo = {
packageJson: PackageJson,
-type ProjectInfo = {
+export type ProjectInfo = {
[packageName: string]: PackageInfo,
*/ | [
"+ shell: bash",
"-function _updateScopedPackages(packages, directory) {",
"- directory,",
"- fs.writeFileSync("
] | [
8,
148,
164,
185
] | {
"additions": 43,
"author": "cipolleschi",
"deletions": 25,
"html_url": "https://github.com/facebook/react-native/pull/45158",
"issue_id": 45158,
"merged_at": "2024-06-26T09:22:02Z",
"omission_probability": 0.1,
"pr_number": 45158,
"repo": "facebook/react-native",
"title": "[LOCAL][CI] Fix Helloworld ios jobs",
"total_changes": 68
} |
519 | diff --git a/.circleci/configurations/commands.yml b/.circleci/configurations/commands.yml
index 1ffde738995d49..bc190b9a5eeac9 100644
--- a/.circleci/configurations/commands.yml
+++ b/.circleci/configurations/commands.yml
@@ -31,7 +31,7 @@ commands:
- restore_cache:
key: *rbenv_cache_key
- run:
- name: Bundle Install
+ name: Install the proper Ruby and run Bundle install
command: |
# Check if rbenv is installed. CircleCI is migrating to rbenv so we may not need to always install it.
@@ -62,8 +62,10 @@ commands:
# Set ruby dependencies
rbenv global << parameters.ruby_version >>
if [[ $(echo << parameters.ruby_version >> | awk -F'.' '{print $1}') == "2" ]]; then
+ rbenv rehash
gem install bundler -v 2.4.22
else
+ rbenv rehash
gem install bundler
fi
bundle check || bundle install --path vendor/bundle --clean
diff --git a/.circleci/configurations/executors.yml b/.circleci/configurations/executors.yml
index 3884b21abfdfc1..eb1fecfaaefd2f 100644
--- a/.circleci/configurations/executors.yml
+++ b/.circleci/configurations/executors.yml
@@ -33,6 +33,6 @@ executors:
<<: *defaults
macos:
xcode: *xcode_version
- resource_class: macos.x86.medium.gen2
+ resource_class: macos.m1.medium.gen1
environment:
- RCT_BUILD_HERMES_FROM_SOURCE: true
diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 7b4559d18fae2c..60e9e827d4318e 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -116,7 +116,7 @@ jobs:
executor: reactnativeios
parameters:
ruby_version:
- default: "2.7.7"
+ default: "2.7.8"
description: The version of ruby that must be used
type: string
steps:
diff --git a/.circleci/configurations/test_workflows/testAll.yml b/.circleci/configurations/test_workflows/testAll.yml
index 145dcbd71ff213..c597ada8ec328a 100644
--- a/.circleci/configurations/test_workflows/testAll.yml
+++ b/.circleci/configurations/test_workflows/testAll.yml
@@ -56,8 +56,8 @@
- test_ios_template:
requires:
- build_npm_package
- name: "Test Template with Ruby 3.2.0"
- ruby_version: "3.2.0"
+ name: "Test Template with Ruby 3.2.2"
+ ruby_version: "3.2.2"
architecture: "NewArch"
flavor: "Debug"
- test_ios_template:
@@ -149,8 +149,8 @@
- test_ios_rntester:
requires:
- build_hermes_macos
- name: "Test RNTester with Ruby 3.2.0"
- ruby_version: "3.2.0"
+ name: "Test RNTester with Ruby 3.2.2"
+ ruby_version: "3.2.2"
architecture: "NewArch"
- test_ios_rntester:
requires:
diff --git a/.circleci/configurations/test_workflows/testE2E.yml b/.circleci/configurations/test_workflows/testE2E.yml
index b161180ee5a5b4..f7578e553c28dd 100644
--- a/.circleci/configurations/test_workflows/testE2E.yml
+++ b/.circleci/configurations/test_workflows/testE2E.yml
@@ -5,6 +5,6 @@
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
jobs:
- test_e2e_ios:
- ruby_version: "2.7.7"
+ ruby_version: "2.7.8"
# This is not stable
# - test_e2e_android
diff --git a/.circleci/configurations/test_workflows/testIOS.yml b/.circleci/configurations/test_workflows/testIOS.yml
index 484ef5a8f2ea27..e3e8ab71c5233b 100644
--- a/.circleci/configurations/test_workflows/testIOS.yml
+++ b/.circleci/configurations/test_workflows/testIOS.yml
@@ -43,12 +43,12 @@
- build_hermes_macos
- build_hermesc_windows
- test_e2e_ios:
- ruby_version: "2.7.7"
+ ruby_version: "2.7.8"
- test_ios_template:
requires:
- build_npm_package
- name: "Test Template with Ruby 3.2.0"
- ruby_version: "3.2.0"
+ name: "Test Template with Ruby 3.2.2"
+ ruby_version: "3.2.2"
architecture: "NewArch"
flavor: "Debug"
- test_ios_template:
@@ -140,8 +140,8 @@
- test_ios_rntester:
requires:
- build_hermes_macos
- name: "Test RNTester with Ruby 3.2.0"
- ruby_version: "3.2.0"
+ name: "Test RNTester with Ruby 3.2.2"
+ ruby_version: "3.2.2"
architecture: "NewArch"
- test_ios_rntester:
requires:
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 6eed67c24e92dc..d13d709f8ad83a 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -71,32 +71,32 @@ references:
cache_keys:
checkout_cache_key: &checkout_cache_key v1-checkout
- gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
+ gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v3-gradle-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
yarn_cache_key: &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }}
- rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ checksum "/tmp/required_ruby" }}
+ rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }}
hermes_workspace_cache_key: &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Hermes iOS
- hermesc_apple_cache_key: &hermesc_apple_cache_key v2-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v2-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v1-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v1-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v1-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v1-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermesc_apple_cache_key: &hermesc_apple_cache_key v3-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v3-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v5-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v4-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v2-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v2-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v2-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v2-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Cocoapods - RNTester
- pods_cache_key: &pods_cache_key v10-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
- cocoapods_cache_key: &cocoapods_cache_key v9-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
- rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v7-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ pods_cache_key: &pods_cache_key v11-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
+ cocoapods_cache_key: &cocoapods_cache_key v10-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v8-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}
# Cocoapods - Template
- template_cocoapods_cache_key: &template_cocoapods_cache_key v4-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
- template_podfile_lock_cache_key: &template_podfile_lock_cache_key v4-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
+ template_cocoapods_cache_key: &template_cocoapods_cache_key v5-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
+ template_podfile_lock_cache_key: &template_podfile_lock_cache_key v5-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
# Windows
windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
| diff --git a/.circleci/configurations/commands.yml b/.circleci/configurations/commands.yml
index 1ffde738995d49..bc190b9a5eeac9 100644
--- a/.circleci/configurations/commands.yml
+++ b/.circleci/configurations/commands.yml
@@ -31,7 +31,7 @@ commands:
- restore_cache:
key: *rbenv_cache_key
- run:
- name: Bundle Install
+ name: Install the proper Ruby and run Bundle install
command: |
# Check if rbenv is installed. CircleCI is migrating to rbenv so we may not need to always install it.
@@ -62,8 +62,10 @@ commands:
# Set ruby dependencies
rbenv global << parameters.ruby_version >>
if [[ $(echo << parameters.ruby_version >> | awk -F'.' '{print $1}') == "2" ]]; then
gem install bundler -v 2.4.22
else
gem install bundler
fi
bundle check || bundle install --path vendor/bundle --clean
diff --git a/.circleci/configurations/executors.yml b/.circleci/configurations/executors.yml
index 3884b21abfdfc1..eb1fecfaaefd2f 100644
--- a/.circleci/configurations/executors.yml
+++ b/.circleci/configurations/executors.yml
@@ -33,6 +33,6 @@ executors:
<<: *defaults
macos:
xcode: *xcode_version
- resource_class: macos.x86.medium.gen2
+ resource_class: macos.m1.medium.gen1
environment:
- RCT_BUILD_HERMES_FROM_SOURCE: true
diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index 7b4559d18fae2c..60e9e827d4318e 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -116,7 +116,7 @@ jobs:
executor: reactnativeios
parameters:
ruby_version:
- default: "2.7.7"
+ default: "2.7.8"
description: The version of ruby that must be used
type: string
steps:
diff --git a/.circleci/configurations/test_workflows/testAll.yml b/.circleci/configurations/test_workflows/testAll.yml
index 145dcbd71ff213..c597ada8ec328a 100644
--- a/.circleci/configurations/test_workflows/testAll.yml
+++ b/.circleci/configurations/test_workflows/testAll.yml
@@ -56,8 +56,8 @@
@@ -149,8 +149,8 @@
diff --git a/.circleci/configurations/test_workflows/testE2E.yml b/.circleci/configurations/test_workflows/testE2E.yml
index b161180ee5a5b4..f7578e553c28dd 100644
--- a/.circleci/configurations/test_workflows/testE2E.yml
+++ b/.circleci/configurations/test_workflows/testE2E.yml
@@ -5,6 +5,6 @@
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
jobs:
# This is not stable
# - test_e2e_android
diff --git a/.circleci/configurations/test_workflows/testIOS.yml b/.circleci/configurations/test_workflows/testIOS.yml
index 484ef5a8f2ea27..e3e8ab71c5233b 100644
--- a/.circleci/configurations/test_workflows/testIOS.yml
+++ b/.circleci/configurations/test_workflows/testIOS.yml
@@ -43,12 +43,12 @@
- build_hermesc_windows
@@ -140,8 +140,8 @@
diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml
index 6eed67c24e92dc..d13d709f8ad83a 100644
--- a/.circleci/configurations/top_level.yml
+++ b/.circleci/configurations/top_level.yml
@@ -71,32 +71,32 @@ references:
cache_keys:
checkout_cache_key: &checkout_cache_key v1-checkout
- gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
+ gems_cache_key: &gems_cache_key v1-gems-{{ arch }}-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v3-gradle-{{ .Environment.CIRCLE_JOB }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "packages/react-native/ReactAndroid/gradle.properties" }}
yarn_cache_key: &yarn_cache_key v6-yarn-cache-{{ .Environment.CIRCLE_JOB }}
- rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ checksum "/tmp/required_ruby" }}
+ rbenv_cache_key: &rbenv_cache_key v1-rbenv-{{ arch }}-{{ checksum "/tmp/required_ruby" }}
hermes_workspace_cache_key: &hermes_workspace_cache_key v5-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Hermes iOS
- hermesc_apple_cache_key: &hermesc_apple_cache_key v2-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v2-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
- hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v1-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v1-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v1-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
- hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v1-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermesc_apple_cache_key: &hermesc_apple_cache_key v3-hermesc-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_apple_slices_cache_key: &hermes_apple_slices_cache_key v3-hermes-apple-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v5-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v4-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}-{{ checksum "packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh" }}
+ hermes_macosx_bin_release_cache_key: &hermes_macosx_bin_release_cache_key v2-hermes-release-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_macosx_bin_debug_cache_key: &hermes_macosx_bin_debug_cache_key v2-hermes-debug-macosx-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_debug_cache_key: &hermes_dsym_debug_cache_key v2-hermes-debug-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
+ hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v2-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
# Cocoapods - RNTester
- pods_cache_key: &pods_cache_key v10-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
- cocoapods_cache_key: &cocoapods_cache_key v9-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
- rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v7-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ pods_cache_key: &pods_cache_key v11-pods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
+ cocoapods_cache_key: &cocoapods_cache_key v10-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}
+ rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v8-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}
# Cocoapods - Template
- template_cocoapods_cache_key: &template_cocoapods_cache_key v4-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
- template_podfile_lock_cache_key: &template_podfile_lock_cache_key v4-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
+ template_cocoapods_cache_key: &template_cocoapods_cache_key v5-cocoapods-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
+ template_podfile_lock_cache_key: &template_podfile_lock_cache_key v5-podfilelock-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }}-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "packages/rn-tester/Podfile.lock }}
# Windows
windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} | [] | [] | {
"additions": 30,
"author": "cipolleschi",
"deletions": 28,
"html_url": "https://github.com/facebook/react-native/pull/45214",
"issue_id": 45214,
"merged_at": "2024-07-09T12:19:29Z",
"omission_probability": 0.1,
"pr_number": 45214,
"repo": "facebook/react-native",
"title": "[CI] Move machines to M1 for 0.73",
"total_changes": 58
} |
520 | diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
index 235028a2b355a4..730da01a697a21 100644
--- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
+++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
@@ -13,8 +13,8 @@
#include <atomic>
#include <condition_variable>
#include <cstdlib>
+#include <deque>
#include <mutex>
-#include <queue>
#include <sstream>
#include <thread>
@@ -51,6 +51,12 @@ class JSCRuntime : public jsi::Runtime {
const std::shared_ptr<const jsi::Buffer>& buffer,
const std::string& sourceURL) override;
+ // If we use this interface to implement microtasks in the host we need to
+ // polyfill `Promise` to use these methods, because JSC doesn't currently
+ // support providing a custom queue for its built-in implementation.
+ // Not doing this would result in a non-compliant behavior, as microtasks
+ // wouldn't execute in the order in which they were queued.
+ void queueMicrotask(const jsi::Function& callback) override;
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
jsi::Object global() override;
@@ -265,6 +271,7 @@ class JSCRuntime : public jsi::Runtime {
std::atomic<bool> ctxInvalid_;
std::string desc_;
JSValueRef nativeStateSymbol_ = nullptr;
+ std::deque<jsi::Function> microtaskQueue_;
#ifndef NDEBUG
mutable std::atomic<intptr_t> objectCounter_;
mutable std::atomic<intptr_t> symbolCounter_;
@@ -380,6 +387,10 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
}
JSCRuntime::~JSCRuntime() {
+ // We need to clear the microtask queue to remove all references to the
+ // callbacks, so objectCounter_ would be 0 below.
+ microtaskQueue_.clear();
+
// On shutting down and cleaning up: when JSC is actually torn down,
// it calls JSC::Heap::lastChanceToFinalize internally which
// finalizes anything left over. But at this point,
@@ -436,7 +447,24 @@ jsi::Value JSCRuntime::evaluateJavaScript(
return createValue(res);
}
-bool JSCRuntime::drainMicrotasks(int maxMicrotasksHint) {
+void JSCRuntime::queueMicrotask(const jsi::Function& callback) {
+ microtaskQueue_.emplace_back(
+ jsi::Value(*this, callback).asObject(*this).asFunction(*this));
+}
+
+bool JSCRuntime::drainMicrotasks(int /*maxMicrotasksHint*/) {
+ // Note that new jobs can be enqueued during the draining.
+ while (!microtaskQueue_.empty()) {
+ jsi::Function callback = std::move(microtaskQueue_.front());
+
+ // We need to pop before calling the callback because that might throw.
+ // When that happens, the host will call `drainMicrotasks` again to execute
+ // the remaining microtasks, and this one shouldn't run again.
+ microtaskQueue_.pop_front();
+
+ callback.call(*this);
+ }
+
return true;
}
diff --git a/packages/react-native/ReactCommon/jsi/jsi/decorator.h b/packages/react-native/ReactCommon/jsi/jsi/decorator.h
index 7bddd1fad80a52..6f4351a420da69 100644
--- a/packages/react-native/ReactCommon/jsi/jsi/decorator.h
+++ b/packages/react-native/ReactCommon/jsi/jsi/decorator.h
@@ -126,6 +126,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
const std::shared_ptr<const PreparedJavaScript>& js) override {
return plain().evaluatePreparedJavaScript(js);
}
+ void queueMicrotask(const jsi::Function& callback) override {
+ return plain().queueMicrotask(callback);
+ }
bool drainMicrotasks(int maxMicrotasksHint) override {
return plain().drainMicrotasks(maxMicrotasksHint);
}
@@ -544,6 +547,10 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
Around around{with_};
return RD::evaluatePreparedJavaScript(js);
}
+ void queueMicrotask(const Function& callback) override {
+ Around around{with_};
+ RD::queueMicrotask(callback);
+ }
bool drainMicrotasks(int maxMicrotasksHint) override {
Around around{with_};
return RD::drainMicrotasks(maxMicrotasksHint);
diff --git a/packages/react-native/ReactCommon/jsi/jsi/jsi.h b/packages/react-native/ReactCommon/jsi/jsi/jsi.h
index 962dae93609423..d77255f61a86c7 100644
--- a/packages/react-native/ReactCommon/jsi/jsi/jsi.h
+++ b/packages/react-native/ReactCommon/jsi/jsi/jsi.h
@@ -209,6 +209,13 @@ class JSI_EXPORT Runtime {
virtual Value evaluatePreparedJavaScript(
const std::shared_ptr<const PreparedJavaScript>& js) = 0;
+ /// Queues a microtask in the JavaScript VM internal Microtask (a.k.a. Job in
+ /// ECMA262) queue, to be executed when the host drains microtasks in
+ /// its event loop implementation.
+ ///
+ /// \param callback a function to be executed as a microtask.
+ virtual void queueMicrotask(const jsi::Function& callback) = 0;
+
/// Drain the JavaScript VM internal Microtask (a.k.a. Job in ECMA262) queue.
///
/// \param maxMicrotasksHint a hint to tell an implementation that it should
diff --git a/packages/react-native/sdks/.hermesversion b/packages/react-native/sdks/.hermesversion
index 038c63a3fd7afc..ffcbbccc462b7c 100644
--- a/packages/react-native/sdks/.hermesversion
+++ b/packages/react-native/sdks/.hermesversion
@@ -1 +1 @@
-hermes-2024-06-03-RNv0.74.2-bb1e74fe1e95c2b5a2f4f9311152da052badc2bc
+hermes-2024-06-28-RNv0.74.3-7bda0c267e76d11b68a585f84cfdd65000babf85
| diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
index 235028a2b355a4..730da01a697a21 100644
--- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
+++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
@@ -13,8 +13,8 @@
#include <atomic>
#include <condition_variable>
#include <cstdlib>
+#include <deque>
#include <mutex>
-#include <queue>
#include <sstream>
#include <thread>
@@ -51,6 +51,12 @@ class JSCRuntime : public jsi::Runtime {
const std::shared_ptr<const jsi::Buffer>& buffer,
const std::string& sourceURL) override;
+ // polyfill `Promise` to use these methods, because JSC doesn't currently
+ // support providing a custom queue for its built-in implementation.
+ // Not doing this would result in a non-compliant behavior, as microtasks
+ // wouldn't execute in the order in which they were queued.
+ void queueMicrotask(const jsi::Function& callback) override;
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
jsi::Object global() override;
@@ -265,6 +271,7 @@ class JSCRuntime : public jsi::Runtime {
std::atomic<bool> ctxInvalid_;
std::string desc_;
JSValueRef nativeStateSymbol_ = nullptr;
+ std::deque<jsi::Function> microtaskQueue_;
#ifndef NDEBUG
mutable std::atomic<intptr_t> objectCounter_;
mutable std::atomic<intptr_t> symbolCounter_;
@@ -380,6 +387,10 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
JSCRuntime::~JSCRuntime() {
+ // We need to clear the microtask queue to remove all references to the
+ // callbacks, so objectCounter_ would be 0 below.
+ microtaskQueue_.clear();
// On shutting down and cleaning up: when JSC is actually torn down,
// it calls JSC::Heap::lastChanceToFinalize internally which
// finalizes anything left over. But at this point,
@@ -436,7 +447,24 @@ jsi::Value JSCRuntime::evaluateJavaScript(
return createValue(res);
-bool JSCRuntime::drainMicrotasks(int maxMicrotasksHint) {
+ microtaskQueue_.emplace_back(
+ jsi::Value(*this, callback).asObject(*this).asFunction(*this));
+}
+bool JSCRuntime::drainMicrotasks(int /*maxMicrotasksHint*/) {
+ // Note that new jobs can be enqueued during the draining.
+ while (!microtaskQueue_.empty()) {
+ jsi::Function callback = std::move(microtaskQueue_.front());
+ // We need to pop before calling the callback because that might throw.
+ // When that happens, the host will call `drainMicrotasks` again to execute
+ // the remaining microtasks, and this one shouldn't run again.
+ microtaskQueue_.pop_front();
+ callback.call(*this);
return true;
diff --git a/packages/react-native/ReactCommon/jsi/jsi/decorator.h b/packages/react-native/ReactCommon/jsi/jsi/decorator.h
index 7bddd1fad80a52..6f4351a420da69 100644
--- a/packages/react-native/ReactCommon/jsi/jsi/decorator.h
+++ b/packages/react-native/ReactCommon/jsi/jsi/decorator.h
@@ -126,6 +126,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
const std::shared_ptr<const PreparedJavaScript>& js) override {
return plain().evaluatePreparedJavaScript(js);
+ void queueMicrotask(const jsi::Function& callback) override {
+ return plain().queueMicrotask(callback);
return plain().drainMicrotasks(maxMicrotasksHint);
@@ -544,6 +547,10 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
return RD::evaluatePreparedJavaScript(js);
+ void queueMicrotask(const Function& callback) override {
+ Around around{with_};
+ RD::queueMicrotask(callback);
return RD::drainMicrotasks(maxMicrotasksHint);
diff --git a/packages/react-native/ReactCommon/jsi/jsi/jsi.h b/packages/react-native/ReactCommon/jsi/jsi/jsi.h
index 962dae93609423..d77255f61a86c7 100644
--- a/packages/react-native/ReactCommon/jsi/jsi/jsi.h
+++ b/packages/react-native/ReactCommon/jsi/jsi/jsi.h
@@ -209,6 +209,13 @@ class JSI_EXPORT Runtime {
virtual Value evaluatePreparedJavaScript(
const std::shared_ptr<const PreparedJavaScript>& js) = 0;
+ /// Queues a microtask in the JavaScript VM internal Microtask (a.k.a. Job in
+ /// ECMA262) queue, to be executed when the host drains microtasks in
+ /// its event loop implementation.
+ ///
+ /// \param callback a function to be executed as a microtask.
+ virtual void queueMicrotask(const jsi::Function& callback) = 0;
/// Drain the JavaScript VM internal Microtask (a.k.a. Job in ECMA262) queue.
///
/// \param maxMicrotasksHint a hint to tell an implementation that it should
diff --git a/packages/react-native/sdks/.hermesversion b/packages/react-native/sdks/.hermesversion
index 038c63a3fd7afc..ffcbbccc462b7c 100644
--- a/packages/react-native/sdks/.hermesversion
+++ b/packages/react-native/sdks/.hermesversion
@@ -1 +1 @@
-hermes-2024-06-03-RNv0.74.2-bb1e74fe1e95c2b5a2f4f9311152da052badc2bc
+hermes-2024-06-28-RNv0.74.3-7bda0c267e76d11b68a585f84cfdd65000babf85 | [
"+ // If we use this interface to implement microtasks in the host we need to",
"+void JSCRuntime::queueMicrotask(const jsi::Function& callback) {"
] | [
18,
51
] | {
"additions": 45,
"author": "cipolleschi",
"deletions": 3,
"html_url": "https://github.com/facebook/react-native/pull/45220",
"issue_id": 45220,
"merged_at": "2024-07-01T09:38:09Z",
"omission_probability": 0.1,
"pr_number": 45220,
"repo": "facebook/react-native",
"title": "[Hermes] Bump Hermes",
"total_changes": 48
} |
521 | diff --git a/packages/react-native-info/package.json b/packages/react-native-info/package.json
index aa496244eae10c..76c6adbcecb2d1 100644
--- a/packages/react-native-info/package.json
+++ b/packages/react-native-info/package.json
@@ -17,10 +17,10 @@
"directory": "packages/react-native-info"
},
"dependencies": {
- "@react-native-community/cli-config": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-apple": "15.0.0-alpha.2",
- "@react-native-community/cli-tools": "15.0.0-alpha.2",
- "@react-native-community/cli-types": "15.0.0-alpha.2",
+ "@react-native-community/cli-config": "15.0.1",
+ "@react-native-community/cli-platform-apple": "15.0.1",
+ "@react-native-community/cli-tools": "15.0.1",
+ "@react-native-community/cli-types": "15.0.1",
"commander": "^12.0.0",
"fs-extra": "^11.2.0",
"yaml": "^2.4.1"
diff --git a/packages/react-native/cli.js b/packages/react-native/cli.js
index 23a9f1779ac60a..6d6751e7a303b6 100755
--- a/packages/react-native/cli.js
+++ b/packages/react-native/cli.js
@@ -204,7 +204,7 @@ async function main() {
const proc = spawn(
'npx',
- ['@react-native-community/cli', ...process.argv.slice(2)],
+ ['@react-native-community/cli@latest', ...process.argv.slice(2)],
{
stdio: 'inherit',
},
diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json
index 6273c2989bba7a..016e942b655c76 100644
--- a/packages/rn-tester/package.json
+++ b/packages/rn-tester/package.json
@@ -42,8 +42,8 @@
}
},
"devDependencies": {
- "@react-native-community/cli": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-android": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-ios": "15.0.0-alpha.2"
+ "@react-native-community/cli": "15.0.1",
+ "@react-native-community/cli-platform-android": "15.0.1",
+ "@react-native-community/cli-platform-ios": "15.0.1"
}
}
diff --git a/yarn.lock b/yarn.lock
index aed1e88186c753..dd8a6e595669fb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1134,7 +1134,20 @@
"@babel/parser" "^7.25.0"
"@babel/types" "^7.25.0"
-"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3", "@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.25.0", "@babel/traverse@^7.25.1", "@babel/traverse@^7.25.2", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.4":
+"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3":
+ version "7.25.6"
+ resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.6.tgz#04fad980e444f182ecf1520504941940a90fea41"
+ integrity sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==
+ dependencies:
+ "@babel/code-frame" "^7.24.7"
+ "@babel/generator" "^7.25.6"
+ "@babel/parser" "^7.25.6"
+ "@babel/template" "^7.25.0"
+ "@babel/types" "^7.25.6"
+ debug "^4.3.1"
+ globals "^11.1.0"
+
+"@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.25.0", "@babel/traverse@^7.25.1", "@babel/traverse@^7.25.2", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.4":
version "7.25.6"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.6.tgz#04fad980e444f182ecf1520504941940a90fea41"
integrity sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==
@@ -1758,45 +1771,55 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-15.0.0-alpha.2.tgz#c6598086cd1432deaa2bed82f6d2833feb112091"
- integrity sha512-QNq5lZpoxGHIneKBB1S8hSpvgFYGST7CP1GWrgrmOaIieNFsh2oWhTePzGyxUgxr0i0qzolmWwuwqqyIPMUSyQ==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-15.0.1.tgz#80ce09ffe0d62bb265447007f24dc8dcbf8fe7d3"
+ integrity sha512-flGTfT005UZvW2LAXVowZ/7ri22oiiZE4pPgMvc8klRxO5uofKIRuohgiHybHtiCo/HNqIz45JmZJvuFrhc4Ow==
+ dependencies:
+ "@react-native-community/cli-tools" "15.0.1"
+ chalk "^4.1.2"
+ execa "^5.0.0"
+ fast-glob "^3.3.2"
+
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config-apple/-/cli-config-apple-15.0.1.tgz#2d845599eada1b479df6716a25dc871c3d202f38"
+ integrity sha512-GEHUx4NRp9W9or6vygn0TgNeFkcJdNjrtko0vQEJAS4gJdWqP/9LqqwJNlUfaW5jHBN7TKALAMlfRmI12Op3sg==
dependencies:
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-tools" "15.0.1"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-15.0.0-alpha.2.tgz#fe535e9174593041ec0c8e6abbb9cb4127195315"
- integrity sha512-gkmVP7s5sR74HOz2unPsRdNTEmwQyzpeEcB2OI3g35WAyccpYO7OpmpE1PlQ0O9qKdQlQJKbL7fq2DhqswVAdg==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-15.0.1.tgz#fe44472757ebca4348fe4861ceaf9d4daff26767"
+ integrity sha512-SL3/9zIyzQQPKWei0+W1gNHxCPurrxqpODUWnVLoP38DNcvYCGtsRayw/4DsXgprZfBC+FsscNpd3IDJrG59XA==
dependencies:
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-tools" "15.0.1"
chalk "^4.1.2"
cosmiconfig "^9.0.0"
deepmerge "^4.3.0"
fast-glob "^3.3.2"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-15.0.0-alpha.2.tgz#8ee14142c270c83fb5072050cad4f97e99ec5e5a"
- integrity sha512-odOFpsOgbCc2si2+D16eyeY4h4u3qu12XssRGV8VqvhKLh0khQ/wA6y01/1ghy1sA0Pus1LyBwFEix6X3epXBw==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-15.0.1.tgz#bed0d7af5ecb05222bdb7d6e74e21326a583bcf1"
+ integrity sha512-xkT2TLS8zg5r7Vl9l/2f7JVUoFECnVBS+B5ivrSu2PNZhKkr9lRmJFxC9aVLFb5lIxQQKNDvEyiIDNfP7wjJiA==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-15.0.0-alpha.2.tgz#d83c4146111c5f3c2e2468d6cdcb4e76ed0e4e37"
- integrity sha512-kcBwSUMmD0AGP+kvlxTkzGlMLxOqCZIJ6pBbpnTPAhSjYrvYzHNZTTYqeggcACR7mlERot0t6tJvXeGHP1s59g==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-15.0.1.tgz#63cc42e7302f2bfa3739b29fea57b68d5d68fa03"
+ integrity sha512-YCu44lZR3zZxJJYVTqYZFz9cT9KBfbKI4q2MnKOvkamt00XY3usooMqfuwBAdvM/yvpx7M5w8kbM/nPyj4YCvQ==
dependencies:
- "@react-native-community/cli-config" "15.0.0-alpha.2"
- "@react-native-community/cli-platform-android" "15.0.0-alpha.2"
- "@react-native-community/cli-platform-apple" "15.0.0-alpha.2"
- "@react-native-community/cli-platform-ios" "15.0.0-alpha.2"
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-config" "15.0.1"
+ "@react-native-community/cli-platform-android" "15.0.1"
+ "@react-native-community/cli-platform-apple" "15.0.1"
+ "@react-native-community/cli-platform-ios" "15.0.1"
+ "@react-native-community/cli-tools" "15.0.1"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -1809,44 +1832,43 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-15.0.0-alpha.2.tgz#479f743086fb3c853d9a8038e26035d25776db7c"
- integrity sha512-cKHbENaYreKCRtF8cSgTX3mn8XeupTVNzF57tWtOq6Prs+9Bd8ZsOylFZEvkyb3wY1S+BFDAXebAGzbL9ZlY3w==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-15.0.1.tgz#9706fe454d0e2af4680c3ea1937830c93041a35f"
+ integrity sha512-QlAMomj6H6TY6pHwjTYMsHDQLP5eLzjAmyW1qb03w/kyS/72elK2bjsklNWJrscFY9TMQLqw7qoAsXf1m5t/dg==
dependencies:
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-tools" "15.0.1"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.4.1"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-15.0.0-alpha.2.tgz#561272ec7bf6cbedf8737cf1b71566b63e9b704b"
- integrity sha512-eXE6KES4mNWQA1c/d+aWQnNsgjD7rdrsMAH4t0xOhXn4XWCw1FF6Y7PjUY8fi784RFIzEYB2xiVMvWQsC6BmAQ==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-15.0.1.tgz#af3c9bc910c96e823a488c21e7d68a9b4a07c8d1"
+ integrity sha512-iQj1Dt2fr/Q7X2CQhyhWnece3eLDCark1osfiwpViksOfTH2WdpNS3lIwlFcIKhsieFU7YYwbNuFqQ3tF9Dlvw==
dependencies:
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-config-apple" "15.0.1"
+ "@react-native-community/cli-tools" "15.0.1"
chalk "^4.1.2"
execa "^5.0.0"
- fast-glob "^3.3.2"
fast-xml-parser "^4.4.1"
- ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-15.0.0-alpha.2.tgz#c237e561d60d3aa463d51327b37e6943910f7bb5"
- integrity sha512-7teqYOMf7SnBmUbSeGklDS2lJCpAa1LKzmy/L8vFiayWImUTJHKzkJyZNzhmiLSImcibFYVH7uaD2DWuFNcrOQ==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-15.0.1.tgz#a1cb78c3d43b9c2bbb411a074ef11364f2a94bbf"
+ integrity sha512-6pKzXEIgGL20eE1uOn8iSsNBlMzO1LG+pQOk+7mvD172EPhKm/lRzUVDX5gO/2jvsGoNw6VUW0JX1FI2firwqA==
dependencies:
- "@react-native-community/cli-platform-apple" "15.0.0-alpha.2"
+ "@react-native-community/cli-platform-apple" "15.0.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-15.0.0-alpha.2.tgz#37dcfe41cc7204e01290c616c9262e5e71f70424"
- integrity sha512-e4bHsl/J006+coMTOpj6i44QPDat/X2s1sc3rqQkFL5vHIduB+Z6IyDI+W9F5uHrJhtQukE5NdajkjcXyjGLVA==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-15.0.1.tgz#e7975e7638343248835fd379803d557c0ae24d75"
+ integrity sha512-f3rb3t1ELLaMSX5/LWO/IykglBIgiP3+pPnyl8GphHnBpf3bdIcp7fHlHLemvHE06YxT2nANRxRPjy1gNskenA==
dependencies:
- "@react-native-community/cli-debugger-ui" "15.0.0-alpha.2"
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
+ "@react-native-community/cli-debugger-ui" "15.0.1"
+ "@react-native-community/cli-tools" "15.0.1"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -1855,10 +1877,10 @@
serve-static "^1.13.1"
ws "^6.2.3"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-15.0.0-alpha.2.tgz#0c02c61a30730814925d6c1e08d43b57ec083f24"
- integrity sha512-XzjIFizlqLtwHqhFJHbYfedFOIebFEt1bdLSsHi2HSiZQlltW8KTwWiHC1VHfoEpePErvP2/jsx/dZtX7wNNSw==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-15.0.1.tgz#3cc5398da72b5d365eb4a30468ebce2bf37fa591"
+ integrity sha512-N79A+u/94roanfmNohVcNGu6Xg+0idh63JHZFLC9OJJuZwTifGMLDfSTHZATpR1J7rebozQ5ClcSUePavErnSg==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
@@ -1867,29 +1889,30 @@
mime "^2.4.1"
open "^6.2.0"
ora "^5.4.1"
+ prompts "^2.4.2"
semver "^7.5.2"
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-15.0.0-alpha.2.tgz#12d62c7e928115758bbb7de6ded3d21a57dbb7b9"
- integrity sha512-5gLZKQLG4ejrMEzdBw0KaGcX7jTTpWoGypxqL+8sQ7Pkenklfsr1RJRFxv+hzO/yX9psMFMgZUXluLajWwuvcg==
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-15.0.1.tgz#ebdb5bc76ade44b2820174fdcb2a3a05999686ec"
+ integrity sha512-sWiJ62kkGu2mgYni2dsPxOMBzpwTjNsDH1ubY4mqcNEI9Zmzs0vRwwDUEhYqwNGys9+KpBKoZRrT2PAlhO84xA==
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "15.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-15.0.0-alpha.2.tgz#e465127a176a9eac3f0c1e4a16bd1830627fbbfb"
- integrity sha512-Yf7kupKmEuytelafCNeNug4ZAC0i7GPgKVyXfRhwVtVp5ykXtWcng2bqPa4YRl4fgWgu5JhoOQhVMEV1cUDzAA==
- dependencies:
- "@react-native-community/cli-clean" "15.0.0-alpha.2"
- "@react-native-community/cli-config" "15.0.0-alpha.2"
- "@react-native-community/cli-debugger-ui" "15.0.0-alpha.2"
- "@react-native-community/cli-doctor" "15.0.0-alpha.2"
- "@react-native-community/cli-server-api" "15.0.0-alpha.2"
- "@react-native-community/cli-tools" "15.0.0-alpha.2"
- "@react-native-community/cli-types" "15.0.0-alpha.2"
+"@react-native-community/[email protected]":
+ version "15.0.1"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-15.0.1.tgz#d703d55cc6540ce3d29fd2fbf3303bea0ffd96f2"
+ integrity sha512-xIGPytx2bj5HxFk0c7S25AVuJowHmEFg5LFC9XosKc0TSOjP1r6zGC6OqC/arQV/pNuqmZN2IFnpgJn0Bn+hhQ==
+ dependencies:
+ "@react-native-community/cli-clean" "15.0.1"
+ "@react-native-community/cli-config" "15.0.1"
+ "@react-native-community/cli-debugger-ui" "15.0.1"
+ "@react-native-community/cli-doctor" "15.0.1"
+ "@react-native-community/cli-server-api" "15.0.1"
+ "@react-native-community/cli-tools" "15.0.1"
+ "@react-native-community/cli-types" "15.0.1"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
| diff --git a/packages/react-native-info/package.json b/packages/react-native-info/package.json
index aa496244eae10c..76c6adbcecb2d1 100644
--- a/packages/react-native-info/package.json
+++ b/packages/react-native-info/package.json
@@ -17,10 +17,10 @@
"directory": "packages/react-native-info"
"dependencies": {
- "@react-native-community/cli-config": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-apple": "15.0.0-alpha.2",
- "@react-native-community/cli-tools": "15.0.0-alpha.2",
- "@react-native-community/cli-types": "15.0.0-alpha.2",
+ "@react-native-community/cli-config": "15.0.1",
+ "@react-native-community/cli-platform-apple": "15.0.1",
+ "@react-native-community/cli-tools": "15.0.1",
+ "@react-native-community/cli-types": "15.0.1",
"commander": "^12.0.0",
"fs-extra": "^11.2.0",
"yaml": "^2.4.1"
diff --git a/packages/react-native/cli.js b/packages/react-native/cli.js
index 23a9f1779ac60a..6d6751e7a303b6 100755
--- a/packages/react-native/cli.js
+++ b/packages/react-native/cli.js
@@ -204,7 +204,7 @@ async function main() {
const proc = spawn(
'npx',
- ['@react-native-community/cli', ...process.argv.slice(2)],
+ ['@react-native-community/cli@latest', ...process.argv.slice(2)],
{
stdio: 'inherit',
},
diff --git a/packages/rn-tester/package.json b/packages/rn-tester/package.json
index 6273c2989bba7a..016e942b655c76 100644
--- a/packages/rn-tester/package.json
+++ b/packages/rn-tester/package.json
@@ -42,8 +42,8 @@
}
"devDependencies": {
- "@react-native-community/cli": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-android": "15.0.0-alpha.2",
- "@react-native-community/cli-platform-ios": "15.0.0-alpha.2"
+ "@react-native-community/cli": "15.0.1",
+ "@react-native-community/cli-platform-android": "15.0.1",
+ "@react-native-community/cli-platform-ios": "15.0.1"
}
}
diff --git a/yarn.lock b/yarn.lock
index aed1e88186c753..dd8a6e595669fb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1134,7 +1134,20 @@
"@babel/parser" "^7.25.0"
"@babel/types" "^7.25.0"
-"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3", "@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.25.0", "@babel/traverse@^7.25.1", "@babel/traverse@^7.25.2", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.4":
+"@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3":
+ version "7.25.6"
+ integrity sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==
+ "@babel/code-frame" "^7.24.7"
+ "@babel/generator" "^7.25.6"
+ "@babel/parser" "^7.25.6"
+ "@babel/template" "^7.25.0"
+ debug "^4.3.1"
+ globals "^11.1.0"
+"@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.25.0", "@babel/traverse@^7.25.1", "@babel/traverse@^7.25.2", "@babel/traverse@^7.25.3", "@babel/traverse@^7.25.4":
version "7.25.6"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.6.tgz#04fad980e444f182ecf1520504941940a90fea41"
integrity sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==
@@ -1758,45 +1771,55 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-15.0.0-alpha.2.tgz#c6598086cd1432deaa2bed82f6d2833feb112091"
- integrity sha512-QNq5lZpoxGHIneKBB1S8hSpvgFYGST7CP1GWrgrmOaIieNFsh2oWhTePzGyxUgxr0i0qzolmWwuwqqyIPMUSyQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-15.0.1.tgz#80ce09ffe0d62bb265447007f24dc8dcbf8fe7d3"
+ integrity sha512-flGTfT005UZvW2LAXVowZ/7ri22oiiZE4pPgMvc8klRxO5uofKIRuohgiHybHtiCo/HNqIz45JmZJvuFrhc4Ow==
+ chalk "^4.1.2"
+ execa "^5.0.0"
+ fast-glob "^3.3.2"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config-apple/-/cli-config-apple-15.0.1.tgz#2d845599eada1b479df6716a25dc871c3d202f38"
+ integrity sha512-GEHUx4NRp9W9or6vygn0TgNeFkcJdNjrtko0vQEJAS4gJdWqP/9LqqwJNlUfaW5jHBN7TKALAMlfRmI12Op3sg==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-15.0.0-alpha.2.tgz#fe535e9174593041ec0c8e6abbb9cb4127195315"
- integrity sha512-gkmVP7s5sR74HOz2unPsRdNTEmwQyzpeEcB2OI3g35WAyccpYO7OpmpE1PlQ0O9qKdQlQJKbL7fq2DhqswVAdg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-15.0.1.tgz#fe44472757ebca4348fe4861ceaf9d4daff26767"
+ integrity sha512-SL3/9zIyzQQPKWei0+W1gNHxCPurrxqpODUWnVLoP38DNcvYCGtsRayw/4DsXgprZfBC+FsscNpd3IDJrG59XA==
cosmiconfig "^9.0.0"
-"@react-native-community/[email protected]":
- integrity sha512-odOFpsOgbCc2si2+D16eyeY4h4u3qu12XssRGV8VqvhKLh0khQ/wA6y01/1ghy1sA0Pus1LyBwFEix6X3epXBw==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-15.0.1.tgz#bed0d7af5ecb05222bdb7d6e74e21326a583bcf1"
+ integrity sha512-xkT2TLS8zg5r7Vl9l/2f7JVUoFECnVBS+B5ivrSu2PNZhKkr9lRmJFxC9aVLFb5lIxQQKNDvEyiIDNfP7wjJiA==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-15.0.0-alpha.2.tgz#d83c4146111c5f3c2e2468d6cdcb4e76ed0e4e37"
- integrity sha512-kcBwSUMmD0AGP+kvlxTkzGlMLxOqCZIJ6pBbpnTPAhSjYrvYzHNZTTYqeggcACR7mlERot0t6tJvXeGHP1s59g==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-15.0.1.tgz#63cc42e7302f2bfa3739b29fea57b68d5d68fa03"
+ integrity sha512-YCu44lZR3zZxJJYVTqYZFz9cT9KBfbKI4q2MnKOvkamt00XY3usooMqfuwBAdvM/yvpx7M5w8kbM/nPyj4YCvQ==
- "@react-native-community/cli-platform-android" "15.0.0-alpha.2"
- "@react-native-community/cli-platform-ios" "15.0.0-alpha.2"
+ "@react-native-community/cli-platform-android" "15.0.1"
+ "@react-native-community/cli-platform-ios" "15.0.1"
command-exists "^1.2.8"
@@ -1809,44 +1832,43 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-15.0.0-alpha.2.tgz#479f743086fb3c853d9a8038e26035d25776db7c"
- integrity sha512-cKHbENaYreKCRtF8cSgTX3mn8XeupTVNzF57tWtOq6Prs+9Bd8ZsOylFZEvkyb3wY1S+BFDAXebAGzbL9ZlY3w==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-15.0.1.tgz#9706fe454d0e2af4680c3ea1937830c93041a35f"
+ integrity sha512-QlAMomj6H6TY6pHwjTYMsHDQLP5eLzjAmyW1qb03w/kyS/72elK2bjsklNWJrscFY9TMQLqw7qoAsXf1m5t/dg==
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-15.0.0-alpha.2.tgz#561272ec7bf6cbedf8737cf1b71566b63e9b704b"
- integrity sha512-eXE6KES4mNWQA1c/d+aWQnNsgjD7rdrsMAH4t0xOhXn4XWCw1FF6Y7PjUY8fi784RFIzEYB2xiVMvWQsC6BmAQ==
+"@react-native-community/[email protected]":
+ integrity sha512-iQj1Dt2fr/Q7X2CQhyhWnece3eLDCark1osfiwpViksOfTH2WdpNS3lIwlFcIKhsieFU7YYwbNuFqQ3tF9Dlvw==
+ "@react-native-community/cli-config-apple" "15.0.1"
- fast-glob "^3.3.2"
- ora "^5.4.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-15.0.0-alpha.2.tgz#c237e561d60d3aa463d51327b37e6943910f7bb5"
- integrity sha512-7teqYOMf7SnBmUbSeGklDS2lJCpAa1LKzmy/L8vFiayWImUTJHKzkJyZNzhmiLSImcibFYVH7uaD2DWuFNcrOQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-15.0.1.tgz#a1cb78c3d43b9c2bbb411a074ef11364f2a94bbf"
+ integrity sha512-6pKzXEIgGL20eE1uOn8iSsNBlMzO1LG+pQOk+7mvD172EPhKm/lRzUVDX5gO/2jvsGoNw6VUW0JX1FI2firwqA==
-"@react-native-community/[email protected]":
- integrity sha512-e4bHsl/J006+coMTOpj6i44QPDat/X2s1sc3rqQkFL5vHIduB+Z6IyDI+W9F5uHrJhtQukE5NdajkjcXyjGLVA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-15.0.1.tgz#e7975e7638343248835fd379803d557c0ae24d75"
+ integrity sha512-f3rb3t1ELLaMSX5/LWO/IykglBIgiP3+pPnyl8GphHnBpf3bdIcp7fHlHLemvHE06YxT2nANRxRPjy1gNskenA==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -1855,10 +1877,10 @@
ws "^6.2.3"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-15.0.0-alpha.2.tgz#0c02c61a30730814925d6c1e08d43b57ec083f24"
- integrity sha512-XzjIFizlqLtwHqhFJHbYfedFOIebFEt1bdLSsHi2HSiZQlltW8KTwWiHC1VHfoEpePErvP2/jsx/dZtX7wNNSw==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-15.0.1.tgz#3cc5398da72b5d365eb4a30468ebce2bf37fa591"
appdirsjs "^1.2.4"
@@ -1867,29 +1889,30 @@
mime "^2.4.1"
open "^6.2.0"
ora "^5.4.1"
+ prompts "^2.4.2"
semver "^7.5.2"
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-15.0.0-alpha.2.tgz#12d62c7e928115758bbb7de6ded3d21a57dbb7b9"
- integrity sha512-5gLZKQLG4ejrMEzdBw0KaGcX7jTTpWoGypxqL+8sQ7Pkenklfsr1RJRFxv+hzO/yX9psMFMgZUXluLajWwuvcg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-15.0.1.tgz#ebdb5bc76ade44b2820174fdcb2a3a05999686ec"
+ integrity sha512-sWiJ62kkGu2mgYni2dsPxOMBzpwTjNsDH1ubY4mqcNEI9Zmzs0vRwwDUEhYqwNGys9+KpBKoZRrT2PAlhO84xA==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-15.0.0-alpha.2.tgz#e465127a176a9eac3f0c1e4a16bd1830627fbbfb"
- integrity sha512-Yf7kupKmEuytelafCNeNug4ZAC0i7GPgKVyXfRhwVtVp5ykXtWcng2bqPa4YRl4fgWgu5JhoOQhVMEV1cUDzAA==
- dependencies:
- "@react-native-community/cli-clean" "15.0.0-alpha.2"
- "@react-native-community/cli-doctor" "15.0.0-alpha.2"
- "@react-native-community/cli-types" "15.0.0-alpha.2"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-15.0.1.tgz#d703d55cc6540ce3d29fd2fbf3303bea0ffd96f2"
+ integrity sha512-xIGPytx2bj5HxFk0c7S25AVuJowHmEFg5LFC9XosKc0TSOjP1r6zGC6OqC/arQV/pNuqmZN2IFnpgJn0Bn+hhQ==
+ "@react-native-community/cli-clean" "15.0.1"
+ "@react-native-community/cli-doctor" "15.0.1"
+ "@react-native-community/cli-server-api" "15.0.1"
commander "^9.4.1" | [
"+ resolved \"https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.25.6.tgz#04fad980e444f182ecf1520504941940a90fea41\"",
"+ \"@babel/types\" \"^7.25.6\"",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-15.0.0-alpha.2.tgz#8ee14142c270c83fb5072050cad4f97e99ec5e5a\"",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-15.0.1.tgz#af3c9bc910c96e823a488c21e7d68a9b4a07c8d1\"",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-15.0.0-alpha.2.tgz#37dcfe41cc7204e01290c616c9262e5e71f70424\"",
"+ integrity sha512-N79A+u/94roanfmNohVcNGu6Xg+0idh63JHZFLC9OJJuZwTifGMLDfSTHZATpR1J7rebozQ5ClcSUePavErnSg==",
"-\"@react-native-community/[email protected]\":",
"- \"@react-native-community/cli-server-api\" \"15.0.0-alpha.2\"",
"+ \"@react-native-community/cli-types\" \"15.0.1\""
] | [
59,
66,
122,
180,
206,
231,
244,
264,
278
] | {
"additions": 98,
"author": "szymonrybczak",
"deletions": 75,
"html_url": "https://github.com/facebook/react-native/pull/47328",
"issue_id": 47328,
"merged_at": "2024-10-31T10:25:02Z",
"omission_probability": 0.1,
"pr_number": 47328,
"repo": "facebook/react-native",
"title": "Bump CLI to 15.0.1",
"total_changes": 173
} |
522 | diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
index 6aab9810556cd2..c0729f86de9566 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
@@ -12,6 +12,7 @@ import androidx.annotation.AnyThread
import androidx.annotation.UiThread
import com.facebook.infer.annotation.ThreadConfined
import com.facebook.react.common.annotations.UnstableReactNativeAPI
+import com.facebook.react.uimanager.events.EventDispatcher
@OptIn(UnstableReactNativeAPI::class)
public interface UIManager : PerformanceCounter {
@@ -78,7 +79,7 @@ public interface UIManager : PerformanceCounter {
public fun dispatchCommand(reactTag: Int, commandId: String, commandArgs: ReadableArray?)
/** @return the [EventDispatcher] object that is used by this class. */
- public fun <T> getEventDispatcher(): T
+ public val eventDispatcher: EventDispatcher
/**
* Used by native animated module to bypass the process of updating the values through the shadow
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
index bd092593672710..c95100594382fe 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
@@ -1021,7 +1021,6 @@ public void onHostResume() {
@Override
@NonNull
- @SuppressWarnings("unchecked")
public EventDispatcher getEventDispatcher() {
return mEventDispatcher;
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
index c68e1bbedb1e78..4285a84fb127e6 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
@@ -92,7 +92,7 @@ class RootViewTest {
val eventEmitterModuleMock = mock(RCTEventEmitter::class.java)
whenever(catalystInstanceMock.getNativeModule(UIManagerModule::class.java))
.thenReturn(uiManager)
- whenever(uiManager.getEventDispatcher()).thenReturn(eventDispatcher)
+ whenever(uiManager.eventDispatcher).thenReturn(eventDispatcher)
// RootView IDs is React Native follow the 11, 21, 31, ... progression.
val rootViewId = 11
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
index 5807188f02af1d..514f817f07d95a 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
@@ -86,7 +86,7 @@ class NativeAnimatedNodeTraversalTest {
uiManagerMock = mock(UIManagerModule::class.java)
eventDispatcherMock = mock(EventDispatcher::class.java)
- whenever(uiManagerMock.getEventDispatcher()).thenAnswer { eventDispatcherMock }
+ whenever(uiManagerMock.eventDispatcher).thenAnswer { eventDispatcherMock }
whenever(uiManagerMock.constants).thenAnswer {
mapOf("customDirectEventTypes" to emptyMap<Any, Any>())
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
index 454982113c346d..4ecd8ef01de480 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
@@ -488,7 +488,7 @@ class TouchEventDispatchTest {
spy(FabricUIManager(reactContext, viewManagerRegistry, batchEventDispatchedListener))
uiManager.initialize()
- eventDispatcher = uiManager.getEventDispatcher()
+ eventDispatcher = uiManager.eventDispatcher
// Ignore scheduled choreographer work
val reactChoreographerMock = mock(ReactChoreographer::class.java)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
index 55f287820a5803..cf36aef91e3b50 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
@@ -17,6 +17,7 @@ import com.facebook.react.bridge.UIManagerListener
import com.facebook.react.bridge.WritableMap
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.fabric.interop.UIBlockViewResolver
+import com.facebook.react.uimanager.events.EventDispatcher
@OptIn(UnstableReactNativeAPI::class)
class FakeUIManager : UIManager, UIBlockViewResolver {
@@ -65,7 +66,10 @@ class FakeUIManager : UIManager, UIBlockViewResolver {
error("Not yet implemented")
}
- override fun <T : Any?> getEventDispatcher(): T {
+ override val eventDispatcher: EventDispatcher
+ get() = TODO("Not yet implemented")
+
+ fun <T : Any?> getEventDispatcher(): T {
error("Not yet implemented")
}
| diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
index 6aab9810556cd2..c0729f86de9566 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt
@@ -12,6 +12,7 @@ import androidx.annotation.AnyThread
import androidx.annotation.UiThread
import com.facebook.infer.annotation.ThreadConfined
public interface UIManager : PerformanceCounter {
@@ -78,7 +79,7 @@ public interface UIManager : PerformanceCounter {
public fun dispatchCommand(reactTag: Int, commandId: String, commandArgs: ReadableArray?)
/** @return the [EventDispatcher] object that is used by this class. */
- public fun <T> getEventDispatcher(): T
+ public val eventDispatcher: EventDispatcher
/**
* Used by native animated module to bypass the process of updating the values through the shadow
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
index bd092593672710..c95100594382fe 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java
@@ -1021,7 +1021,6 @@ public void onHostResume() {
@Override
@NonNull
- @SuppressWarnings("unchecked")
public EventDispatcher getEventDispatcher() {
return mEventDispatcher;
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
index c68e1bbedb1e78..4285a84fb127e6 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt
@@ -92,7 +92,7 @@ class RootViewTest {
val eventEmitterModuleMock = mock(RCTEventEmitter::class.java)
whenever(catalystInstanceMock.getNativeModule(UIManagerModule::class.java))
.thenReturn(uiManager)
- whenever(uiManager.getEventDispatcher()).thenReturn(eventDispatcher)
+ whenever(uiManager.eventDispatcher).thenReturn(eventDispatcher)
// RootView IDs is React Native follow the 11, 21, 31, ... progression.
val rootViewId = 11
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
index 5807188f02af1d..514f817f07d95a 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/animated/NativeAnimatedNodeTraversalTest.kt
@@ -86,7 +86,7 @@ class NativeAnimatedNodeTraversalTest {
uiManagerMock = mock(UIManagerModule::class.java)
eventDispatcherMock = mock(EventDispatcher::class.java)
- whenever(uiManagerMock.getEventDispatcher()).thenAnswer { eventDispatcherMock }
+ whenever(uiManagerMock.eventDispatcher).thenAnswer { eventDispatcherMock }
whenever(uiManagerMock.constants).thenAnswer {
mapOf("customDirectEventTypes" to emptyMap<Any, Any>())
}
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
index 454982113c346d..4ecd8ef01de480 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/fabric/events/TouchEventDispatchTest.kt
@@ -488,7 +488,7 @@ class TouchEventDispatchTest {
spy(FabricUIManager(reactContext, viewManagerRegistry, batchEventDispatchedListener))
uiManager.initialize()
// Ignore scheduled choreographer work
val reactChoreographerMock = mock(ReactChoreographer::class.java)
diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
index 55f287820a5803..cf36aef91e3b50 100644
--- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
+++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt
@@ -17,6 +17,7 @@ import com.facebook.react.bridge.UIManagerListener
import com.facebook.react.bridge.WritableMap
import com.facebook.react.fabric.interop.UIBlockViewResolver
class FakeUIManager : UIManager, UIBlockViewResolver {
@@ -65,7 +66,10 @@ class FakeUIManager : UIManager, UIBlockViewResolver {
- override fun <T : Any?> getEventDispatcher(): T {
+ override val eventDispatcher: EventDispatcher
+ get() = TODO("Not yet implemented")
+
+ fun <T : Any?> getEventDispatcher(): T { | [
"- eventDispatcher = uiManager.getEventDispatcher()",
"+ eventDispatcher = uiManager.eventDispatcher"
] | [
67,
68
] | {
"additions": 10,
"author": "cortinico",
"deletions": 6,
"html_url": "https://github.com/facebook/react-native/pull/47090",
"issue_id": 47090,
"merged_at": "2024-10-17T13:40:04Z",
"omission_probability": 0.1,
"pr_number": 47090,
"repo": "facebook/react-native",
"title": "[0.76] Undo breaking change on UIManager eventDispatcher accessor",
"total_changes": 16
} |
523 | diff --git a/packages/react-native/Libraries/Core/setUpDeveloperTools.js b/packages/react-native/Libraries/Core/setUpDeveloperTools.js
index 5cc39eae9c1274..6dfae179e33582 100644
--- a/packages/react-native/Libraries/Core/setUpDeveloperTools.js
+++ b/packages/react-native/Libraries/Core/setUpDeveloperTools.js
@@ -42,9 +42,13 @@ if (__DEV__) {
if (!Platform.isTesting) {
const HMRClient = require('../Utilities/HMRClient');
+ // [0.76 only] When under React Native DevTools, log "JavaScript logs will
+ // be removed from Metro..." warning, and continue to forward logs.
if (global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__) {
HMRClient.unstable_notifyFuseboxConsoleEnabled();
- } else if (console._isPolyfilled) {
+ }
+
+ if (console._isPolyfilled) {
// We assume full control over the console and send JavaScript logs to Metro.
[
'trace',
diff --git a/packages/react-native/Libraries/Utilities/HMRClient.js b/packages/react-native/Libraries/Utilities/HMRClient.js
index bed704f269c0c3..5651788b2a1226 100644
--- a/packages/react-native/Libraries/Utilities/HMRClient.js
+++ b/packages/react-native/Libraries/Utilities/HMRClient.js
@@ -153,11 +153,12 @@ const HMRClient: HMRClientNativeInterface = {
level: 'info',
data: [
'\n' +
- '\x1b[7m' +
- ' \x1b[1mJavaScript logs have moved!\x1b[22m They will now appear in the debugger console. ' +
- 'Tip: Type \x1b[1mj\x1b[22m in the terminal to open the debugger (requires Google Chrome ' +
- 'or Microsoft Edge).' +
- '\x1b[27m' +
+ '\u001B[7m' +
+ ' \u001B[1m💡 JavaScript logs will be removed from Metro in React ' +
+ 'Native 0.77!\u001B[22m Please use React Native DevTools as your ' +
+ 'default tool. Tip: Type \u001B[1mj\u001B[22m in the terminal to ' +
+ 'open (requires Google Chrome or Microsoft Edge).' +
+ '\u001B[27m' +
'\n',
],
}),
| diff --git a/packages/react-native/Libraries/Core/setUpDeveloperTools.js b/packages/react-native/Libraries/Core/setUpDeveloperTools.js
index 5cc39eae9c1274..6dfae179e33582 100644
--- a/packages/react-native/Libraries/Core/setUpDeveloperTools.js
+++ b/packages/react-native/Libraries/Core/setUpDeveloperTools.js
@@ -42,9 +42,13 @@ if (__DEV__) {
if (!Platform.isTesting) {
const HMRClient = require('../Utilities/HMRClient');
+ // [0.76 only] When under React Native DevTools, log "JavaScript logs will
+ // be removed from Metro..." warning, and continue to forward logs.
if (global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__) {
HMRClient.unstable_notifyFuseboxConsoleEnabled();
- } else if (console._isPolyfilled) {
+ }
+
+ if (console._isPolyfilled) {
// We assume full control over the console and send JavaScript logs to Metro.
[
'trace',
diff --git a/packages/react-native/Libraries/Utilities/HMRClient.js b/packages/react-native/Libraries/Utilities/HMRClient.js
index bed704f269c0c3..5651788b2a1226 100644
--- a/packages/react-native/Libraries/Utilities/HMRClient.js
+++ b/packages/react-native/Libraries/Utilities/HMRClient.js
@@ -153,11 +153,12 @@ const HMRClient: HMRClientNativeInterface = {
level: 'info',
data: [
'\n' +
- '\x1b[7m' +
- ' \x1b[1mJavaScript logs have moved!\x1b[22m They will now appear in the debugger console. ' +
- 'Tip: Type \x1b[1mj\x1b[22m in the terminal to open the debugger (requires Google Chrome ' +
- 'or Microsoft Edge).' +
- '\x1b[27m' +
+ '\u001B[7m' +
+ ' \u001B[1m💡 JavaScript logs will be removed from Metro in React ' +
+ 'Native 0.77!\u001B[22m Please use React Native DevTools as your ' +
+ 'default tool. Tip: Type \u001B[1mj\u001B[22m in the terminal to ' +
+ 'open (requires Google Chrome or Microsoft Edge).' +
+ '\u001B[27m' +
'\n',
],
}), | [] | [] | {
"additions": 11,
"author": "huntie",
"deletions": 6,
"html_url": "https://github.com/facebook/react-native/pull/46815",
"issue_id": 46815,
"merged_at": "2024-10-07T14:41:56Z",
"omission_probability": 0.1,
"pr_number": 46815,
"repo": "facebook/react-native",
"title": "[0.76][Fix] Restore Metro log forwarding, change notice to signal future removal",
"total_changes": 17
} |
524 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 81a8a992773d91..ea913ac24344a7 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -26,6 +26,7 @@
"@react-native/metro-babel-transformer": "0.76.0-rc.2",
"chalk": "^4.0.0",
"execa": "^5.1.1",
+ "invariant": "^2.2.4",
"metro": "^0.81.0-alpha.2",
"metro-config": "^0.81.0-alpha.2",
"metro-core": "^0.81.0-alpha.2",
diff --git a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
index 7b5398d80397a9..c99750d6dacc48 100644
--- a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
+++ b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
@@ -12,11 +12,13 @@
import type {Config} from '@react-native-community/cli-types';
import type TerminalReporter from 'metro/src/lib/TerminalReporter';
-import {KeyPressHandler} from '../../utils/KeyPressHandler';
import {logger} from '../../utils/logger';
import OpenDebuggerKeyboardHandler from './OpenDebuggerKeyboardHandler';
import chalk from 'chalk';
import execa from 'execa';
+import invariant from 'invariant';
+import readline from 'readline';
+import {ReadStream} from 'tty';
const CTRL_C = '\u0003';
const CTRL_D = '\u0004';
@@ -33,6 +35,14 @@ const throttle = (callback: () => void, timeout: number) => {
};
};
+type KeyEvent = {
+ sequence: string,
+ name: string,
+ ctrl: boolean,
+ meta: boolean,
+ shift: boolean,
+};
+
export default function attachKeyHandlers({
cliConfig,
devServerUrl,
@@ -52,6 +62,9 @@ export default function attachKeyHandlers({
return;
}
+ readline.emitKeypressEvents(process.stdin);
+ setRawMode(true);
+
const execaOptions = {
env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'},
};
@@ -66,12 +79,14 @@ export default function attachKeyHandlers({
devServerUrl,
});
- const onPress = async (key: string) => {
- if (openDebuggerKeyboardHandler.maybeHandleTargetSelection(key)) {
+ process.stdin.on('keypress', (str: string, key: KeyEvent) => {
+ logger.debug(`Key pressed: ${key.sequence}`);
+
+ if (openDebuggerKeyboardHandler.maybeHandleTargetSelection(key.name)) {
return;
}
- switch (key.toLowerCase()) {
+ switch (key.sequence) {
case 'r':
reload();
break;
@@ -104,21 +119,19 @@ export default function attachKeyHandlers({
).stdout?.pipe(process.stdout);
break;
case 'j':
- await openDebuggerKeyboardHandler.handleOpenDebugger();
+ // eslint-disable-next-line no-void
+ void openDebuggerKeyboardHandler.handleOpenDebugger();
break;
case CTRL_C:
case CTRL_D:
openDebuggerKeyboardHandler.dismiss();
logger.info('Stopping server');
- keyPressHandler.stopInterceptingKeyStrokes();
+ setRawMode(false);
+ process.stdin.pause();
process.emit('SIGINT');
process.exit();
}
- };
-
- const keyPressHandler = new KeyPressHandler(onPress);
- keyPressHandler.createInteractionListener();
- keyPressHandler.startInterceptingKeyStrokes();
+ });
logger.log(
[
@@ -132,3 +145,11 @@ export default function attachKeyHandlers({
].join('\n'),
);
}
+
+function setRawMode(enable: boolean) {
+ invariant(
+ process.stdin instanceof ReadStream,
+ 'process.stdin must be a readable stream to modify raw mode',
+ );
+ process.stdin.setRawMode(enable);
+}
diff --git a/packages/community-cli-plugin/src/utils/KeyPressHandler.js b/packages/community-cli-plugin/src/utils/KeyPressHandler.js
deleted file mode 100644
index af3609f8da4427..00000000000000
--- a/packages/community-cli-plugin/src/utils/KeyPressHandler.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @flow strict-local
- * @format
- * @oncall react_native
- */
-
-import {CLIError} from './errors';
-import {logger} from './logger';
-
-const CTRL_C = '\u0003';
-
-/** An abstract key stroke interceptor. */
-export class KeyPressHandler {
- _isInterceptingKeyStrokes = false;
- _isHandlingKeyPress = false;
- _onPress: (key: string) => Promise<void>;
-
- constructor(onPress: (key: string) => Promise<void>) {
- this._onPress = onPress;
- }
-
- /** Start observing interaction pause listeners. */
- createInteractionListener(): ({pause: boolean, ...}) => void {
- // Support observing prompts.
- let wasIntercepting = false;
-
- const listener = ({pause}: {pause: boolean, ...}) => {
- if (pause) {
- // Track if we were already intercepting key strokes before pausing, so we can
- // resume after pausing.
- wasIntercepting = this._isInterceptingKeyStrokes;
- this.stopInterceptingKeyStrokes();
- } else if (wasIntercepting) {
- // Only start if we were previously intercepting.
- this.startInterceptingKeyStrokes();
- }
- };
-
- return listener;
- }
-
- _handleKeypress = async (key: string): Promise<CLIError | void> => {
- // Prevent sending another event until the previous event has finished.
- if (this._isHandlingKeyPress && key !== CTRL_C) {
- return;
- }
- this._isHandlingKeyPress = true;
- try {
- logger.debug(`Key pressed: ${key}`);
- await this._onPress(key);
- } catch (error) {
- return new CLIError('There was an error with the key press handler.');
- } finally {
- this._isHandlingKeyPress = false;
- return;
- }
- };
-
- /** Start intercepting all key strokes and passing them to the input `onPress` method. */
- startInterceptingKeyStrokes() {
- if (this._isInterceptingKeyStrokes) {
- return;
- }
- this._isInterceptingKeyStrokes = true;
- const {stdin} = process;
- // $FlowFixMe[prop-missing]
- stdin.setRawMode(true);
- stdin.resume();
- stdin.setEncoding('utf8');
- stdin.on('data', this._handleKeypress);
- }
-
- /** Stop intercepting all key strokes. */
- stopInterceptingKeyStrokes() {
- if (!this._isInterceptingKeyStrokes) {
- return;
- }
- this._isInterceptingKeyStrokes = false;
- const {stdin} = process;
- stdin.removeListener('data', this._handleKeypress);
- // $FlowFixMe[prop-missing]
- stdin.setRawMode(false);
- stdin.resume();
- }
-}
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 81a8a992773d91..ea913ac24344a7 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -26,6 +26,7 @@
"@react-native/metro-babel-transformer": "0.76.0-rc.2",
"chalk": "^4.0.0",
"execa": "^5.1.1",
+ "invariant": "^2.2.4",
"metro": "^0.81.0-alpha.2",
"metro-config": "^0.81.0-alpha.2",
"metro-core": "^0.81.0-alpha.2",
diff --git a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
index 7b5398d80397a9..c99750d6dacc48 100644
--- a/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
+++ b/packages/community-cli-plugin/src/commands/start/attachKeyHandlers.js
@@ -12,11 +12,13 @@
import type {Config} from '@react-native-community/cli-types';
import type TerminalReporter from 'metro/src/lib/TerminalReporter';
import {logger} from '../../utils/logger';
import OpenDebuggerKeyboardHandler from './OpenDebuggerKeyboardHandler';
import chalk from 'chalk';
import execa from 'execa';
+import invariant from 'invariant';
+import readline from 'readline';
+import {ReadStream} from 'tty';
const CTRL_C = '\u0003';
const CTRL_D = '\u0004';
@@ -33,6 +35,14 @@ const throttle = (callback: () => void, timeout: number) => {
};
+type KeyEvent = {
+ sequence: string,
+ name: string,
+ ctrl: boolean,
+ meta: boolean,
+ shift: boolean,
export default function attachKeyHandlers({
cliConfig,
devServerUrl,
@@ -52,6 +62,9 @@ export default function attachKeyHandlers({
return;
}
+ readline.emitKeypressEvents(process.stdin);
+ setRawMode(true);
const execaOptions = {
env: {FORCE_COLOR: chalk.supportsColor ? 'true' : 'false'},
@@ -66,12 +79,14 @@ export default function attachKeyHandlers({
devServerUrl,
});
- const onPress = async (key: string) => {
- if (openDebuggerKeyboardHandler.maybeHandleTargetSelection(key)) {
+ process.stdin.on('keypress', (str: string, key: KeyEvent) => {
+ logger.debug(`Key pressed: ${key.sequence}`);
return;
- switch (key.toLowerCase()) {
+ switch (key.sequence) {
case 'r':
reload();
@@ -104,21 +119,19 @@ export default function attachKeyHandlers({
).stdout?.pipe(process.stdout);
case 'j':
- await openDebuggerKeyboardHandler.handleOpenDebugger();
+ void openDebuggerKeyboardHandler.handleOpenDebugger();
case CTRL_C:
case CTRL_D:
openDebuggerKeyboardHandler.dismiss();
logger.info('Stopping server');
+ setRawMode(false);
+ process.stdin.pause();
process.emit('SIGINT');
process.exit();
- const keyPressHandler = new KeyPressHandler(onPress);
- keyPressHandler.createInteractionListener();
- keyPressHandler.startInterceptingKeyStrokes();
+ });
logger.log(
[
@@ -132,3 +145,11 @@ export default function attachKeyHandlers({
].join('\n'),
);
}
+function setRawMode(enable: boolean) {
+ invariant(
+ process.stdin instanceof ReadStream,
+ 'process.stdin must be a readable stream to modify raw mode',
+ );
+ process.stdin.setRawMode(enable);
+}
diff --git a/packages/community-cli-plugin/src/utils/KeyPressHandler.js b/packages/community-cli-plugin/src/utils/KeyPressHandler.js
deleted file mode 100644
index af3609f8da4427..00000000000000
--- a/packages/community-cli-plugin/src/utils/KeyPressHandler.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- * @flow strict-local
- * @format
- * @oncall react_native
- */
-import {CLIError} from './errors';
-import {logger} from './logger';
-const CTRL_C = '\u0003';
-/** An abstract key stroke interceptor. */
- _isInterceptingKeyStrokes = false;
- _isHandlingKeyPress = false;
- _onPress: (key: string) => Promise<void>;
- constructor(onPress: (key: string) => Promise<void>) {
- this._onPress = onPress;
- /** Start observing interaction pause listeners. */
- createInteractionListener(): ({pause: boolean, ...}) => void {
- // Support observing prompts.
- let wasIntercepting = false;
- if (pause) {
- // Track if we were already intercepting key strokes before pausing, so we can
- // resume after pausing.
- wasIntercepting = this._isInterceptingKeyStrokes;
- this.stopInterceptingKeyStrokes();
- } else if (wasIntercepting) {
- // Only start if we were previously intercepting.
- }
- };
- return listener;
- // Prevent sending another event until the previous event has finished.
- if (this._isHandlingKeyPress && key !== CTRL_C) {
- this._isHandlingKeyPress = true;
- try {
- logger.debug(`Key pressed: ${key}`);
- await this._onPress(key);
- } catch (error) {
- return new CLIError('There was an error with the key press handler.');
- } finally {
- this._isHandlingKeyPress = false;
- if (this._isInterceptingKeyStrokes) {
- this._isInterceptingKeyStrokes = true;
- stdin.setRawMode(true);
- stdin.setEncoding('utf8');
- stdin.on('data', this._handleKeypress);
- /** Stop intercepting all key strokes. */
- stopInterceptingKeyStrokes() {
- if (!this._isInterceptingKeyStrokes) {
- this._isInterceptingKeyStrokes = false;
- stdin.setRawMode(false);
-} | [
"-import {KeyPressHandler} from '../../utils/KeyPressHandler';",
"+};",
"+ if (openDebuggerKeyboardHandler.maybeHandleTargetSelection(key.name)) {",
"+ // eslint-disable-next-line no-void",
"- keyPressHandler.stopInterceptingKeyStrokes();",
"-export class KeyPressHandler {",
"- const listener = ({pause}: {pause: boolean, ...}) => {",
"- this.startInterceptingKeyStrokes();",
"- _handleKeypress = async (key: string): Promise<CLIError | void> => {",
"- /** Start intercepting all key strokes and passing them to the input `onPress` method. */",
"- startInterceptingKeyStrokes() {",
"- stdin.removeListener('data', this._handleKeypress);"
] | [
20,
41,
65,
79,
86,
136,
150,
158,
165,
182,
183,
203
] | {
"additions": 33,
"author": "huntie",
"deletions": 101,
"html_url": "https://github.com/facebook/react-native/pull/46645",
"issue_id": 46645,
"merged_at": "2024-09-30T13:43:01Z",
"omission_probability": 0.1,
"pr_number": 46645,
"repo": "facebook/react-native",
"title": "[0.76] Simplify key handling in start command",
"total_changes": 134
} |
525 | diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
index 66ba98fc91c6df..10aecd00d23251 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
@@ -289,10 +289,7 @@ public void loadApp(String appKey) {
// With Bridgeless enabled, create and start the surface
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (mReactSurface == null) {
- // Create a ReactSurface
mReactSurface = mReactHost.createSurface(mActivity, appKey, mLaunchOptions);
- // Set main Activity's content view
- mActivity.setContentView(mReactSurface.getView());
}
mReactSurface.start();
} else {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
index 12f2d9daba822b..8fe85338a0200b 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
@@ -17,6 +17,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
@@ -69,9 +70,15 @@ public void onCreate(Bundle savedInstanceState) {
if (mainComponentName == null) {
throw new IllegalStateException("Cannot loadApp if component name is null");
}
- mReactDelegate =
- new ReactDelegate(
- getActivity(), getReactNativeHost(), mainComponentName, launchOptions, fabricEnabled);
+ if (ReactFeatureFlags.enableBridgelessArchitecture) {
+ mReactDelegate =
+ new ReactDelegate(
+ getActivity(), getReactHost(), mainComponentName, launchOptions);
+ } else {
+ mReactDelegate =
+ new ReactDelegate(
+ getActivity(), getReactNativeHost(), mainComponentName, launchOptions, fabricEnabled);
+ }
}
/**
@@ -81,8 +88,34 @@ public void onCreate(Bundle savedInstanceState) {
* implement {@code ReactApplication} or you simply have a different mechanism for storing a
* {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
+ @Nullable
protected ReactNativeHost getReactNativeHost() {
- return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();
+ ReactApplication application = ((ReactApplication) getActivity().getApplication());
+ if (application != null) {
+ return application.getReactNativeHost();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the {@link ReactHost} used by this app. By default, assumes {@link
+ * Activity#getApplication()} is an instance of {@link ReactApplication} and calls {@link
+ * ReactApplication#getReactHost()}. Override this method if your application class does not
+ * implement {@code ReactApplication} or you simply have a different mechanism for storing a
+ * {@code ReactHost}, e.g. as a static field somewhere.
+ *
+ * <p>If you're using Old Architecture/Bridge Mode, this method should return null as {@link
+ * ReactHost} is a Bridgeless-only concept.
+ */
+ @Nullable
+ protected ReactHost getReactHost() {
+ ReactApplication application = ((ReactApplication) getActivity().getApplication());
+ if (application != null) {
+ return application.getReactHost();
+ } else {
+ return null;
+ }
}
protected ReactDelegate getReactDelegate() {
| diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
index 66ba98fc91c6df..10aecd00d23251 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java
@@ -289,10 +289,7 @@ public void loadApp(String appKey) {
// With Bridgeless enabled, create and start the surface
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (mReactSurface == null) {
- // Create a ReactSurface
mReactSurface = mReactHost.createSurface(mActivity, appKey, mLaunchOptions);
- // Set main Activity's content view
- mActivity.setContentView(mReactSurface.getView());
}
mReactSurface.start();
} else {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
index 12f2d9daba822b..8fe85338a0200b 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java
@@ -17,6 +17,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
@@ -69,9 +70,15 @@ public void onCreate(Bundle savedInstanceState) {
if (mainComponentName == null) {
throw new IllegalStateException("Cannot loadApp if component name is null");
}
- mReactDelegate =
- new ReactDelegate(
- getActivity(), getReactNativeHost(), mainComponentName, launchOptions, fabricEnabled);
+ if (ReactFeatureFlags.enableBridgelessArchitecture) {
+ getActivity(), getReactHost(), mainComponentName, launchOptions);
+ getActivity(), getReactNativeHost(), mainComponentName, launchOptions, fabricEnabled);
/**
@@ -81,8 +88,34 @@ public void onCreate(Bundle savedInstanceState) {
* implement {@code ReactApplication} or you simply have a different mechanism for storing a
* {@code ReactNativeHost}, e.g. as a static field somewhere.
*/
protected ReactNativeHost getReactNativeHost() {
+ return application.getReactNativeHost();
+ }
+
+ /**
+ * Get the {@link ReactHost} used by this app. By default, assumes {@link
+ * Activity#getApplication()} is an instance of {@link ReactApplication} and calls {@link
+ * ReactApplication#getReactHost()}. Override this method if your application class does not
+ * implement {@code ReactApplication} or you simply have a different mechanism for storing a
+ * {@code ReactHost}, e.g. as a static field somewhere.
+ *
+ * <p>If you're using Old Architecture/Bridge Mode, this method should return null as {@link
+ * ReactHost} is a Bridgeless-only concept.
+ */
+ protected ReactHost getReactHost() {
+ return application.getReactHost();
protected ReactDelegate getReactDelegate() { | [
"- return ((ReactApplication) getActivity().getApplication()).getReactNativeHost();"
] | [
52
] | {
"additions": 37,
"author": "cortinico",
"deletions": 7,
"html_url": "https://github.com/facebook/react-native/pull/46675",
"issue_id": 46675,
"merged_at": "2024-09-30T13:44:22Z",
"omission_probability": 0.1,
"pr_number": 46675,
"repo": "facebook/react-native",
"title": "[0.76] Fix ReactFragment on New Architecture",
"total_changes": 44
} |
526 | diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
index 8528900a50d9b5..d8bcfeda9617d9 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
@@ -7,7 +7,6 @@
import org.gradle.api.internal.classpath.ModuleRegistry
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
-import org.gradle.configurationcache.extensions.serviceOf
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
@@ -52,14 +51,6 @@ dependencies {
testImplementation(libs.junit)
testImplementation(libs.assertj)
testImplementation(project(":shared-testutil"))
-
- testRuntimeOnly(
- files(
- serviceOf<ModuleRegistry>()
- .getModule("gradle-tooling-api-builders")
- .classpath
- .asFiles
- .first()))
}
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
diff --git a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
index 92a44acee9267b..0db9f3e625312f 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
@@ -7,7 +7,6 @@
import org.gradle.api.internal.classpath.ModuleRegistry
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
-import org.gradle.configurationcache.extensions.serviceOf
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
@@ -41,14 +40,6 @@ dependencies {
testImplementation(libs.junit)
testImplementation(project(":shared-testutil"))
-
- testRuntimeOnly(
- files(
- serviceOf<ModuleRegistry>()
- .getModule("gradle-tooling-api-builders")
- .classpath
- .asFiles
- .first()))
}
// We intentionally don't build for Java 17 as users will see a cryptic bytecode version
| diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
index 8528900a50d9b5..d8bcfeda9617d9 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
@@ -52,14 +51,6 @@ dependencies {
testImplementation(libs.assertj)
diff --git a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
index 92a44acee9267b..0db9f3e625312f 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
@@ -41,14 +40,6 @@ dependencies { | [] | [] | {
"additions": 0,
"author": "cortinico",
"deletions": 18,
"html_url": "https://github.com/facebook/react-native/pull/46367",
"issue_id": 46367,
"merged_at": "2024-09-11T09:15:06Z",
"omission_probability": 0.1,
"pr_number": 46367,
"repo": "facebook/react-native",
"title": "[0.75] RGNP - Remove unnecessary dependency on `gradle-tooling-api-builders` - serviceOf failure",
"total_changes": 18
} |
527 | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 582b7f3c4f0dc9..5d1c7610cd273b 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -109,7 +109,7 @@ jobs:
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
- name: Build the Hermes ${{ matrix.slice }} frameworks
run: |
cd ./packages/react-native/sdks/hermes || exit 1
@@ -163,17 +163,21 @@ jobs:
echo "Please try again"
exit 1
fi
+ - name: Compress slices to preserve Symlinks
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }}
- name: Upload Artifact for Slice (${{ matrix.slice }}, ${{ matrix.flavor }}}
uses: actions/[email protected]
with:
name: slice-${{ matrix.slice }}-${{ matrix.flavor }}
- path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz
- name: Save slice cache
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
build_hermes_macos:
runs-on: macos-13
@@ -198,7 +202,7 @@ jobs:
- name: Restore Cached Artifacts
uses: actions/cache/[email protected]
with:
- key: v2-hermes-osx-bin-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
@@ -227,38 +231,49 @@ jobs:
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_macosx_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-macosx-${{ matrix.flavor }}
- name: Slice cache iphoneos
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphoneos_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphoneos-${{ matrix.flavor }}
- name: Slice cache iphonesimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphonesimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphonesimulator-${{ matrix.flavor }}
- name: Slice cache catalyst
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_catalyst_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-catalyst-${{ matrix.flavor }}
- name: Slice cache xros
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xros_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xros-${{ matrix.flavor }}
- name: Slice cache xrsimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xrsimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xrsimulator-${{ matrix.flavor }}
+ - name: Unzip slices
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ ls -l .
+ tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz
- name: Move back build folders
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -358,7 +373,7 @@ jobs:
uses: actions/cache/[email protected]
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
with:
- key: v2-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 06560a2c848cde..18e5f058d33751 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -106,7 +106,7 @@ jobs:
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
- name: Build the Hermes ${{ matrix.slice }} frameworks
run: |
cd ./packages/react-native/sdks/hermes || exit 1
@@ -160,17 +160,21 @@ jobs:
echo "Please try again"
exit 1
fi
+ - name: Compress slices to preserve Symlinks
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }}
- name: Upload Artifact for Slice (${{ matrix.slice }}, ${{ matrix.flavor }}}
uses: actions/[email protected]
with:
name: slice-${{ matrix.slice }}-${{ matrix.flavor }}
- path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz
- name: Save slice cache
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
build_hermes_macos:
runs-on: macos-13
@@ -195,7 +199,7 @@ jobs:
- name: Restore Cached Artifacts
uses: actions/cache/[email protected]
with:
- key: v2-hermes-osx-bin-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
@@ -224,38 +228,49 @@ jobs:
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_macosx_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-macosx-${{ matrix.flavor }}
- name: Slice cache iphoneos
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphoneos_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphoneos-${{ matrix.flavor }}
- name: Slice cache iphonesimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphonesimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphonesimulator-${{ matrix.flavor }}
- name: Slice cache catalyst
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_catalyst_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-catalyst-${{ matrix.flavor }}
- name: Slice cache xros
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xros_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xros-${{ matrix.flavor }}
- name: Slice cache xrsimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xrsimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xrsimulator-${{ matrix.flavor }}
+ - name: Unzip slices
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ ls -l .
+ tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz
- name: Move back build folders
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -355,7 +370,7 @@ jobs:
uses: actions/cache/[email protected]
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
with:
- key: v2-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 6daedc97a77316..33b8485c6e781b 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -117,7 +117,7 @@ jobs:
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
- name: Build the Hermes ${{ matrix.slice }} frameworks
run: |
cd ./packages/react-native/sdks/hermes || exit 1
@@ -171,17 +171,21 @@ jobs:
echo "Please try again"
exit 1
fi
+ - name: Compress slices to preserve Symlinks
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ tar -czv -f build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz build_${{ matrix.slice }}_${{ matrix.flavor }}
- name: Upload Artifact for Slice (${{ matrix.slice }}, ${{ matrix.flavor }}}
uses: actions/[email protected]
with:
name: slice-${{ matrix.slice }}-${{ matrix.flavor }}
- path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}.tar.gz
- name: Save slice cache
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
uses: actions/cache/[email protected]
with:
path: ./packages/react-native/sdks/hermes/build_${{ matrix.slice }}_${{ matrix.flavor }}
- key: v4-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
+ key: v5-hermes-apple-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}-${{ hashfiles('packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh') }}-${{ matrix.slice }}-${{ matrix.flavor }}
build_hermes_macos:
runs-on: macos-13
@@ -206,7 +210,7 @@ jobs:
- name: Restore Cached Artifacts
uses: actions/cache/[email protected]
with:
- key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v4-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
@@ -235,38 +239,50 @@ jobs:
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_macosx_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-macosx-${{ matrix.flavor }}
- name: Slice cache iphoneos
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphoneos_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphoneos-${{ matrix.flavor }}
- name: Slice cache iphonesimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_iphonesimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-iphonesimulator-${{ matrix.flavor }}
- name: Slice cache catalyst
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_catalyst_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-catalyst-${{ matrix.flavor }}
- name: Slice cache xros
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xros_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xros-${{ matrix.flavor }}
- name: Slice cache xrsimulator
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
uses: actions/[email protected]
with:
- path: ./packages/react-native/sdks/hermes/build_xrsimulator_${{ matrix.flavor }}
+ path: ./packages/react-native/sdks/hermes/
name: slice-xrsimulator-${{ matrix.flavor }}
+ - name: Unzip slices
+ if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
+ run: |
+ cd ./packages/react-native/sdks/hermes
+ ls -l .
+
+ tar -xzv -f build_catalyst_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphoneos_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_iphonesimulator_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_macosx_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xros_${{ matrix.flavor }}.tar.gz
+ tar -xzv -f build_xrsimulator_${{ matrix.flavor }}.tar.gz
- name: Move back build folders
if: ${{ steps.check_if_apple_artifacts_are_there.outputs.ARTIFACTS_EXIST != 'true' }}
run: |
@@ -366,7 +382,7 @@ jobs:
uses: actions/cache/[email protected]
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, '-stable') }} # To avoid that the cache explode.
with:
- key: v3-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
+ key: v4-hermes-artifacts-${{ matrix.flavor }}-${{ needs.prepare_hermes_workspace.outputs.hermes-version }}-${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
path: |
/tmp/hermes/osx-bin/${{ matrix.flavor }}
/tmp/hermes/dSYM/${{ matrix.flavor }}
| diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 582b7f3c4f0dc9..5d1c7610cd273b 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -109,7 +109,7 @@ jobs:
@@ -163,17 +163,21 @@ jobs:
@@ -198,7 +202,7 @@ jobs:
@@ -227,38 +231,49 @@ jobs:
@@ -358,7 +373,7 @@ jobs:
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 06560a2c848cde..18e5f058d33751 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -106,7 +106,7 @@ jobs:
@@ -160,17 +160,21 @@ jobs:
@@ -195,7 +199,7 @@ jobs:
@@ -224,38 +228,49 @@ jobs:
@@ -355,7 +370,7 @@ jobs:
diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml
index 6daedc97a77316..33b8485c6e781b 100644
--- a/.github/workflows/test-all.yml
+++ b/.github/workflows/test-all.yml
@@ -117,7 +117,7 @@ jobs:
@@ -171,17 +171,21 @@ jobs:
@@ -206,7 +210,7 @@ jobs:
@@ -235,38 +239,50 @@ jobs:
@@ -366,7 +382,7 @@ jobs: | [
"+"
] | [
315
] | {
"additions": 79,
"author": "cipolleschi",
"deletions": 33,
"html_url": "https://github.com/facebook/react-native/pull/46301",
"issue_id": 46301,
"merged_at": "2024-09-11T09:15:58Z",
"omission_probability": 0.1,
"pr_number": 46301,
"repo": "facebook/react-native",
"title": "[RN][CI] Zip slices to preserve symlinks",
"total_changes": 112
} |
528 | diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index fc15c96f7b8263..4072fd09925646 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -286,7 +286,10 @@ jobs:
- packages/react-native/ReactAndroid/hermes-engine/build/
- packages/react-native/ReactAndroid/src/main/jni/prebuilt/
- packages/react-native-gradle-plugin/.gradle/
- - packages/react-native-gradle-plugin/build/
+ - packages/react-native-gradle-plugin/react-native-gradle-plugin/build/
+ - packages/react-native-gradle-plugin/settings-plugin/build/
+ - packages/react-native-gradle-plugin/shared/build/
+ - packages/react-native-gradle-plugin/shared-testutil/build/
- packages/react-native-codegen/lib/
# -------------------------
diff --git a/packages/react-native-gradle-plugin/.gitignore b/packages/react-native-gradle-plugin/.gitignore
index 7b987dbf0c939a..8d5168254d8020 100644
--- a/packages/react-native-gradle-plugin/.gitignore
+++ b/packages/react-native-gradle-plugin/.gitignore
@@ -2,3 +2,4 @@ build/
app-plugin/build/
settings-plugin/build/
shared/build/
+shared-testutil/build/
\ No newline at end of file
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
index b34e30a678630b..344ac62ef259ff 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
@@ -50,6 +50,7 @@ dependencies {
implementation(libs.javapoet)
testImplementation(libs.junit)
+ testImplementation(project(":shared-testutil"))
testRuntimeOnly(
files(
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
index e00a793ca86d66..a741fde8e43dbd 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
@@ -10,7 +10,7 @@ package com.facebook.react.utils
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
import java.io.File
-internal object Os {
+object Os {
fun isWindows(): Boolean =
System.getProperty("os.name")?.lowercaseCompat()?.contains("windows") ?: false
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
index df99d06e47bc26..7a8c5e2c02426c 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
@@ -7,17 +7,17 @@
package com.facebook.react.utils
-internal fun windowsAwareCommandLine(vararg args: Any): List<Any> =
+fun windowsAwareCommandLine(vararg args: Any): List<Any> =
windowsAwareCommandLine(args.toList())
-internal fun windowsAwareCommandLine(args: List<Any>): List<Any> =
+fun windowsAwareCommandLine(args: List<Any>): List<Any> =
if (Os.isWindows()) {
listOf("cmd", "/c") + args
} else {
args
}
-internal fun windowsAwareBashCommandLine(
+fun windowsAwareBashCommandLine(
vararg args: String,
bashWindowsHome: String? = null
): List<String> =
diff --git a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
index b6687a8a04d6cc..92a44acee9267b 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
@@ -40,6 +40,7 @@ dependencies {
implementation(libs.javapoet)
testImplementation(libs.junit)
+ testImplementation(project(":shared-testutil"))
testRuntimeOnly(
files(
diff --git a/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt b/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
index 6d4f60e6fb48ca..8f2f4476d6dcae 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
+++ b/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
@@ -8,6 +8,7 @@
package com.facebook.react
import com.facebook.react.utils.JsonUtils
+import com.facebook.react.utils.windowsAwareCommandLine
import java.io.File
import java.math.BigInteger
import java.security.MessageDigest
@@ -25,6 +26,11 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
private val outputFolder =
settings.layout.rootDirectory.file("build/generated/autolinking/").asFile
+ private val defaultConfigCommand: List<String> =
+ windowsAwareCommandLine(listOf("npx", "@react-native-community/cli", "config")).map {
+ it.toString()
+ }
+
/**
* Utility function to autolink libraries using an external command as source of truth.
*
@@ -39,7 +45,7 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
*/
@JvmOverloads
public fun autolinkLibrariesFromCommand(
- command: List<String> = listOf("npx", "@react-native-community/cli", "config"),
+ command: List<String> = defaultConfigCommand,
workingDirectory: File? = settings.layout.rootDirectory.dir("../").asFile,
lockFiles: FileCollection =
settings.layout.rootDirectory
diff --git a/packages/react-native-gradle-plugin/settings.gradle.kts b/packages/react-native-gradle-plugin/settings.gradle.kts
index f342618821e50c..565cea4473c630 100644
--- a/packages/react-native-gradle-plugin/settings.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings.gradle.kts
@@ -19,6 +19,7 @@ include(
":react-native-gradle-plugin",
":settings-plugin",
":shared",
+ ":shared-testutil",
)
rootProject.name = "gradle-plugins-root"
diff --git a/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts b/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts
new file mode 100644
index 00000000000000..5f447e83e6a991
--- /dev/null
+++ b/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import org.gradle.api.tasks.testing.logging.TestExceptionFormat
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+plugins { alias(libs.plugins.kotlin.jvm) }
+
+repositories { mavenCentral() }
+
+group = "com.facebook.react"
+
+dependencies { implementation(libs.junit) }
+
+java { targetCompatibility = JavaVersion.VERSION_11 }
+
+kotlin { jvmToolchain(17) }
+
+tasks.withType<KotlinCompile>().configureEach {
+ kotlinOptions {
+ apiVersion = "1.6"
+ jvmTarget = "11"
+ allWarningsAsErrors = true
+ }
+}
+
+tasks.withType<Test>().configureEach {
+ testLogging {
+ exceptionFormat = TestExceptionFormat.FULL
+ showExceptions = true
+ showCauses = true
+ showStackTraces = true
+ }
+}
\ No newline at end of file
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt b/packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt
rename to packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt b/packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt
rename to packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt
diff --git a/packages/react-native-gradle-plugin/shared/build.gradle.kts b/packages/react-native-gradle-plugin/shared/build.gradle.kts
index bccaeb47e853e7..fa76599233ef37 100644
--- a/packages/react-native-gradle-plugin/shared/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/shared/build.gradle.kts
@@ -18,6 +18,7 @@ dependencies {
implementation(libs.gson)
implementation(libs.guava)
testImplementation(libs.junit)
+ testImplementation(project(":shared-testutil"))
}
java { targetCompatibility = JavaVersion.VERSION_11 }
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt b/packages/react-native-gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
rename to packages/react-native-gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt
similarity index 100%
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt
| diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml
index fc15c96f7b8263..4072fd09925646 100644
--- a/.circleci/configurations/jobs.yml
+++ b/.circleci/configurations/jobs.yml
@@ -286,7 +286,10 @@ jobs:
- packages/react-native/ReactAndroid/hermes-engine/build/
- packages/react-native/ReactAndroid/src/main/jni/prebuilt/
- packages/react-native-gradle-plugin/.gradle/
+ - packages/react-native-gradle-plugin/react-native-gradle-plugin/build/
+ - packages/react-native-gradle-plugin/settings-plugin/build/
+ - packages/react-native-gradle-plugin/shared/build/
- packages/react-native-codegen/lib/
# -------------------------
diff --git a/packages/react-native-gradle-plugin/.gitignore b/packages/react-native-gradle-plugin/.gitignore
index 7b987dbf0c939a..8d5168254d8020 100644
--- a/packages/react-native-gradle-plugin/.gitignore
+++ b/packages/react-native-gradle-plugin/.gitignore
@@ -2,3 +2,4 @@ build/
app-plugin/build/
settings-plugin/build/
shared/build/
+shared-testutil/build/
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
index b34e30a678630b..344ac62ef259ff 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/build.gradle.kts
@@ -50,6 +50,7 @@ dependencies {
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
index e00a793ca86d66..a741fde8e43dbd 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/Os.kt
@@ -10,7 +10,7 @@ package com.facebook.react.utils
import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
-internal object Os {
+object Os {
fun isWindows(): Boolean =
System.getProperty("os.name")?.lowercaseCompat()?.contains("windows") ?: false
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
index df99d06e47bc26..7a8c5e2c02426c 100644
--- a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
+++ b/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt
@@ -7,17 +7,17 @@
package com.facebook.react.utils
-internal fun windowsAwareCommandLine(vararg args: Any): List<Any> =
+fun windowsAwareCommandLine(vararg args: Any): List<Any> =
windowsAwareCommandLine(args.toList())
-internal fun windowsAwareCommandLine(args: List<Any>): List<Any> =
+fun windowsAwareCommandLine(args: List<Any>): List<Any> =
if (Os.isWindows()) {
listOf("cmd", "/c") + args
} else {
args
}
+fun windowsAwareBashCommandLine(
vararg args: String,
bashWindowsHome: String? = null
): List<String> =
diff --git a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
index b6687a8a04d6cc..92a44acee9267b 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings-plugin/build.gradle.kts
@@ -40,6 +40,7 @@ dependencies {
diff --git a/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt b/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
index 6d4f60e6fb48ca..8f2f4476d6dcae 100644
--- a/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
+++ b/packages/react-native-gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt
@@ -8,6 +8,7 @@
package com.facebook.react
import com.facebook.react.utils.JsonUtils
+import com.facebook.react.utils.windowsAwareCommandLine
import java.math.BigInteger
import java.security.MessageDigest
@@ -25,6 +26,11 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
private val outputFolder =
settings.layout.rootDirectory.file("build/generated/autolinking/").asFile
+ private val defaultConfigCommand: List<String> =
+ windowsAwareCommandLine(listOf("npx", "@react-native-community/cli", "config")).map {
+ it.toString()
+ }
/**
* Utility function to autolink libraries using an external command as source of truth.
*
@@ -39,7 +45,7 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
*/
@JvmOverloads
public fun autolinkLibrariesFromCommand(
- command: List<String> = listOf("npx", "@react-native-community/cli", "config"),
+ command: List<String> = defaultConfigCommand,
workingDirectory: File? = settings.layout.rootDirectory.dir("../").asFile,
lockFiles: FileCollection =
settings.layout.rootDirectory
diff --git a/packages/react-native-gradle-plugin/settings.gradle.kts b/packages/react-native-gradle-plugin/settings.gradle.kts
index f342618821e50c..565cea4473c630 100644
--- a/packages/react-native-gradle-plugin/settings.gradle.kts
+++ b/packages/react-native-gradle-plugin/settings.gradle.kts
@@ -19,6 +19,7 @@ include(
":react-native-gradle-plugin",
":settings-plugin",
":shared",
+ ":shared-testutil",
)
rootProject.name = "gradle-plugins-root"
diff --git a/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts b/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts
new file mode 100644
index 00000000000000..5f447e83e6a991
--- /dev/null
+++ b/packages/react-native-gradle-plugin/shared-testutil/build.gradle.kts
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+import org.gradle.api.tasks.testing.logging.TestExceptionFormat
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+plugins { alias(libs.plugins.kotlin.jvm) }
+repositories { mavenCentral() }
+group = "com.facebook.react"
+dependencies { implementation(libs.junit) }
+kotlin { jvmToolchain(17) }
+tasks.withType<KotlinCompile>().configureEach {
+ kotlinOptions {
+ apiVersion = "1.6"
+ jvmTarget = "11"
+ allWarningsAsErrors = true
+tasks.withType<Test>().configureEach {
+ exceptionFormat = TestExceptionFormat.FULL
+ showExceptions = true
+ showCauses = true
+ showStackTraces = true
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt b/packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/OsRule.kt
rename to packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/OsRule.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt b/packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tests/WithOs.kt
rename to packages/react-native-gradle-plugin/shared-testutil/src/main/kotlin/com/facebook/react/tests/WithOs.kt
diff --git a/packages/react-native-gradle-plugin/shared/build.gradle.kts b/packages/react-native-gradle-plugin/shared/build.gradle.kts
index bccaeb47e853e7..fa76599233ef37 100644
--- a/packages/react-native-gradle-plugin/shared/build.gradle.kts
+++ b/packages/react-native-gradle-plugin/shared/build.gradle.kts
@@ -18,6 +18,7 @@ dependencies {
implementation(libs.gson)
implementation(libs.guava)
}
java { targetCompatibility = JavaVersion.VERSION_11 }
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt b/packages/react-native-gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
rename to packages/react-native-gradle-plugin/shared/src/main/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtils.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/KotlinStdlibCompatUtilsTest.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/OsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/OsTest.kt
diff --git a/packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt b/packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt
rename from packages/react-native-gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt
rename to packages/react-native-gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt | [
"- - packages/react-native-gradle-plugin/build/",
"+ - packages/react-native-gradle-plugin/shared-testutil/build/",
"-internal fun windowsAwareBashCommandLine(",
"+java { targetCompatibility = JavaVersion.VERSION_11 }",
"+ testLogging {"
] | [
8,
12,
71,
157,
170
] | {
"additions": 58,
"author": "cortinico",
"deletions": 6,
"html_url": "https://github.com/facebook/react-native/pull/45796",
"issue_id": 45796,
"merged_at": "2024-07-29T13:43:00Z",
"omission_probability": 0.1,
"pr_number": 45796,
"repo": "facebook/react-native",
"title": "[0.75] Fix core autolinking not working on Windows",
"total_changes": 64
} |
529 | diff --git a/scripts/release-testing/utils/github-actions-utils.js b/scripts/release-testing/utils/github-actions-utils.js
index 1efd6353852bb8..a5912d3d0da527 100644
--- a/scripts/release-testing/utils/github-actions-utils.js
+++ b/scripts/release-testing/utils/github-actions-utils.js
@@ -60,7 +60,7 @@ const reactNativeRepo = 'https://api.github.com/repos/facebook/react-native/';
const reactNativeActionsURL = `${reactNativeRepo}actions/runs`;
async function _getActionRunsOnBranch() /*: Promise<WorkflowRuns> */ {
- const url = `${reactNativeActionsURL}?branch=${branch}`;
+ const url = `${reactNativeActionsURL}?branch=${branch}&per_page=100`;
const options = {
method: 'GET',
headers: ciHeaders,
@@ -123,7 +123,17 @@ async function initialize(
const testAllWorkflow = (await _getActionRunsOnBranch()).workflow_runs
.filter(w => w.name === 'Test All')
- .sort((a, b) => (a.created_at > b.created_at ? -1 : 1))[0];
+ .sort(
+ (a, b) =>
+ new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
+ )[0];
+
+ console.warn(
+ `\nUsing workflow created at ${testAllWorkflow.created_at} with id ${testAllWorkflow.id}`,
+ );
+ console.warn(
+ `See it at: https://github.com/facebook/react-native/actions/runs/${testAllWorkflow.id}\n`,
+ );
artifacts = await _getArtifacts(testAllWorkflow.id);
}
| diff --git a/scripts/release-testing/utils/github-actions-utils.js b/scripts/release-testing/utils/github-actions-utils.js
index 1efd6353852bb8..a5912d3d0da527 100644
--- a/scripts/release-testing/utils/github-actions-utils.js
+++ b/scripts/release-testing/utils/github-actions-utils.js
@@ -60,7 +60,7 @@ const reactNativeRepo = 'https://api.github.com/repos/facebook/react-native/';
const reactNativeActionsURL = `${reactNativeRepo}actions/runs`;
async function _getActionRunsOnBranch() /*: Promise<WorkflowRuns> */ {
- const url = `${reactNativeActionsURL}?branch=${branch}`;
+ const url = `${reactNativeActionsURL}?branch=${branch}&per_page=100`;
const options = {
method: 'GET',
headers: ciHeaders,
@@ -123,7 +123,17 @@ async function initialize(
const testAllWorkflow = (await _getActionRunsOnBranch()).workflow_runs
.filter(w => w.name === 'Test All')
- .sort((a, b) => (a.created_at > b.created_at ? -1 : 1))[0];
+ .sort(
+ (a, b) =>
+ new Date(b.created_at).getTime() - new Date(a.created_at).getTime(),
+ )[0];
+
+ `\nUsing workflow created at ${testAllWorkflow.created_at} with id ${testAllWorkflow.id}`,
artifacts = await _getArtifacts(testAllWorkflow.id);
} | [
"+ `See it at: https://github.com/facebook/react-native/actions/runs/${testAllWorkflow.id}\\n`,"
] | [
27
] | {
"additions": 12,
"author": "cipolleschi",
"deletions": 2,
"html_url": "https://github.com/facebook/react-native/pull/45532",
"issue_id": 45532,
"merged_at": "2024-07-22T13:32:18Z",
"omission_probability": 0.1,
"pr_number": 45532,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][Release] Add logging to E2E test script",
"total_changes": 14
} |
530 | diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 9a39a695dc9db2..de1fcf17850c81 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -137,7 +137,7 @@
"nullthrows": "^1.1.1",
"pretty-format": "^26.5.2",
"promise": "^8.3.0",
- "react-devtools-core": "5.1.0",
+ "react-devtools-core": "^5.3.1",
"react-refresh": "^0.14.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "0.25.0-rc-fb9a90fa48-20240614",
diff --git a/yarn.lock b/yarn.lock
index e201d460ef7bda..43b898137c6aca 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8580,10 +8580,10 @@ range-parser@~1.2.1:
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
[email protected]:
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-5.1.0.tgz#3396494ac94b21602cac4fd657d600e0b52f4a0b"
- integrity sha512-NRtLBqYVLrIY+lOa2oTpFiAhI7Hru0AUXI0tP9neCyaPPAzlZyeH0i+VZ0shIyRTJbpvyqbD/uCsewA2hpfZHw==
+react-devtools-core@^5.3.1:
+ version "5.3.1"
+ resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-5.3.1.tgz#d57f5b8f74f16e622bd6a7bc270161e4ba162666"
+ integrity sha512-7FSb9meX0btdBQLwdFOwt6bGqvRPabmVMMslv8fgoSPqXyuGpgQe36kx8gR86XPw7aV1yVouTp6fyZ0EH+NfUw==
dependencies:
shell-quote "^1.6.1"
ws "^7"
| diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 9a39a695dc9db2..de1fcf17850c81 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -137,7 +137,7 @@
"nullthrows": "^1.1.1",
"pretty-format": "^26.5.2",
"promise": "^8.3.0",
- "react-devtools-core": "5.1.0",
"react-refresh": "^0.14.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "0.25.0-rc-fb9a90fa48-20240614",
diff --git a/yarn.lock b/yarn.lock
index e201d460ef7bda..43b898137c6aca 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8580,10 +8580,10 @@ range-parser@~1.2.1:
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
[email protected]:
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-5.1.0.tgz#3396494ac94b21602cac4fd657d600e0b52f4a0b"
- integrity sha512-NRtLBqYVLrIY+lOa2oTpFiAhI7Hru0AUXI0tP9neCyaPPAzlZyeH0i+VZ0shIyRTJbpvyqbD/uCsewA2hpfZHw==
+react-devtools-core@^5.3.1:
+ version "5.3.1"
+ resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-5.3.1.tgz#d57f5b8f74f16e622bd6a7bc270161e4ba162666"
+ integrity sha512-7FSb9meX0btdBQLwdFOwt6bGqvRPabmVMMslv8fgoSPqXyuGpgQe36kx8gR86XPw7aV1yVouTp6fyZ0EH+NfUw==
dependencies:
shell-quote "^1.6.1"
ws "^7" | [
"+ \"react-devtools-core\": \"^5.3.1\","
] | [
9
] | {
"additions": 5,
"author": "hoxyq",
"deletions": 5,
"html_url": "https://github.com/facebook/react-native/pull/45288",
"issue_id": 45288,
"merged_at": "2024-07-08T13:17:02Z",
"omission_probability": 0.1,
"pr_number": 45288,
"repo": "facebook/react-native",
"title": "upgrade[react-devtools-core]: ^5.3.1",
"total_changes": 10
} |
531 | diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index 96df007a19ca23..0cc15af58fe5db 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -23,11 +23,11 @@ const {parseArgs} = require('@pkgjs/parseargs');
const chalk = require('chalk');
const {execSync} = require('child_process');
const path = require('path');
+const fs = require('fs');
const config = {
options: {
projectName: {type: 'string'},
- templatePath: {type: 'string'},
directory: {type: 'string'},
verbose: {type: 'boolean', default: false},
help: {type: 'boolean'},
@@ -56,10 +56,10 @@ async function main() {
should not be committed.
Options:
- --projectName The name of the new React Native project.
- --templatePath The absolute path to the folder containing the template.
- --directory The absolute path to the target project directory.
- --verbose Print additional output. Default: false.
+ --projectName The name of the new React Native project.
+ --directory The absolute path to the target project directory.
+ --pathToLocalReactNative The absolute path to the local react-native package.
+ --verbose Print additional output. Default: false.
`);
return;
}
@@ -74,10 +74,10 @@ async function main() {
async function initNewProjectFromSource(
{
projectName,
- templatePath,
directory,
+ pathToLocalReactNative = null,
verbose = false,
- } /*: {projectName: string, templatePath: string, directory: string, verbose?: boolean} */,
+ } /*: {projectName: string, directory: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
) {
console.log('Starting local npm proxy (Verdaccio)');
const verdaccioPid = setupVerdaccio();
@@ -117,9 +117,9 @@ async function initNewProjectFromSource(
console.log('Running react-native init without install');
execSync(
- `node ./packages/react-native/cli.js init ${projectName} \
+ `npx @react-native-community/cli@next init ${projectName} \
--directory ${directory} \
- --template ${templatePath} \
+ --version 0.75.0-rc.1 \
--verbose \
--pm npm \
--skip-install`,
@@ -131,6 +131,9 @@ async function initNewProjectFromSource(
);
console.log('\nDone ✅');
+ _updateScopedPackages(packages, directory);
+ _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory);
+
console.log('Installing project dependencies');
await installProjectUsingProxy(directory);
console.log('Done ✅');
@@ -169,6 +172,62 @@ async function installProjectUsingProxy(cwd /*: string */) {
}
}
+function _updateScopedPackages(packages, directory) {
+ console.log('Updating the scoped packagesto match the version published in Verdaccio');
+
+ // Packages are updated in a lockstep and all with the same version.
+ // Pick the version from the first package
+ const version = packages[Object.keys(packages)[0]].packageJson.version;
+
+ // Update scoped packages which starts with @react-native
+ const appPackageJsonPath = path.join(
+ directory,
+ 'package.json',
+ );
+ const appPackageJson = JSON.parse(
+ fs.readFileSync(appPackageJsonPath, 'utf8'),
+ );
+
+ for (const [key, _] of Object.entries(appPackageJson.dependencies)) {
+ if (key.startsWith('@react-native')) {
+ appPackageJson.dependencies[key] = version
+ }
+ }
+ for (const [key, _] of Object.entries(appPackageJson.devDependencies)) {
+ if (key.startsWith('@react-native')) {
+ appPackageJson.devDependencies[key] = version
+ }
+ }
+
+ fs.writeFileSync(
+ appPackageJsonPath,
+ JSON.stringify(appPackageJson, null, 2),
+ );
+
+ console.log('Done ✅');
+}
+
+function _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory) {
+ if (pathToLocalReactNative != null) {
+ console.log('Updating the template version to local react-native');
+ // Update template version.
+ const appPackageJsonPath = path.join(
+ directory,
+ 'package.json',
+ );
+ const appPackageJson = JSON.parse(
+ fs.readFileSync(appPackageJsonPath, 'utf8'),
+ );
+ appPackageJson.dependencies['react-native'] =
+ `file:${pathToLocalReactNative}`;
+ fs.writeFileSync(
+ appPackageJsonPath,
+ JSON.stringify(appPackageJson, null, 2),
+ );
+ console.log('Done ✅');
+ }
+}
+
module.exports = {
initNewProjectFromSource,
};
diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index a4710c41458317..832be80dd2ad60 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -244,11 +244,6 @@ async function testRNTestProject(
const buildType = 'dry-run';
const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`;
- const templateRepoFolder = '/tmp/template';
- const pathToTemplate = path.join(templateRepoFolder, 'template');
-
- // Cleanup template clone folder
- exec(`rm -rf ${templateRepoFolder}`);
const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
const mavenLocalPath =
@@ -286,21 +281,6 @@ async function testRNTestProject(
}
}
- // Cloning the template repo
- // TODO: handle versioning of the template to make sure that we are downloading the right version of
- // the template, given a specific React Native version
- exec(
- `git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`,
- );
-
- // Update template version.
- const appPackageJsonPath = path.join(pathToTemplate, 'package.json');
- const appPackageJson = JSON.parse(
- fs.readFileSync(appPackageJsonPath, 'utf8'),
- );
- appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`;
- fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
-
pushd('/tmp/');
debug('Creating RNTestProject from template');
@@ -311,7 +291,7 @@ async function testRNTestProject(
await initNewProjectFromSource({
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
- templatePath: templateRepoFolder,
+ pathToLocalReactNative: newLocalNodeTGZ,
});
cd('RNTestProject');
| diff --git a/scripts/e2e/init-template-e2e.js b/scripts/e2e/init-template-e2e.js
index 96df007a19ca23..0cc15af58fe5db 100644
--- a/scripts/e2e/init-template-e2e.js
+++ b/scripts/e2e/init-template-e2e.js
@@ -23,11 +23,11 @@ const {parseArgs} = require('@pkgjs/parseargs');
const chalk = require('chalk');
const {execSync} = require('child_process');
const path = require('path');
+const fs = require('fs');
const config = {
options: {
projectName: {type: 'string'},
- templatePath: {type: 'string'},
directory: {type: 'string'},
verbose: {type: 'boolean', default: false},
help: {type: 'boolean'},
@@ -56,10 +56,10 @@ async function main() {
should not be committed.
Options:
- --projectName The name of the new React Native project.
- --templatePath The absolute path to the folder containing the template.
- --directory The absolute path to the target project directory.
- --verbose Print additional output. Default: false.
+ --projectName The name of the new React Native project.
+ --directory The absolute path to the target project directory.
+ --verbose Print additional output. Default: false.
`);
return;
@@ -74,10 +74,10 @@ async function main() {
async function initNewProjectFromSource(
{
projectName,
- templatePath,
directory,
+ pathToLocalReactNative = null,
verbose = false,
- } /*: {projectName: string, templatePath: string, directory: string, verbose?: boolean} */,
+ } /*: {projectName: string, directory: string, pathToLocalReactNative?: ?string, verbose?: boolean} */,
) {
console.log('Starting local npm proxy (Verdaccio)');
const verdaccioPid = setupVerdaccio();
@@ -117,9 +117,9 @@ async function initNewProjectFromSource(
console.log('Running react-native init without install');
execSync(
+ `npx @react-native-community/cli@next init ${projectName} \
--directory ${directory} \
- --template ${templatePath} \
+ --version 0.75.0-rc.1 \
--verbose \
--pm npm \
--skip-install`,
@@ -131,6 +131,9 @@ async function initNewProjectFromSource(
);
console.log('\nDone ✅');
+ _updateScopedPackages(packages, directory);
console.log('Installing project dependencies');
await installProjectUsingProxy(directory);
console.log('Done ✅');
@@ -169,6 +172,62 @@ async function installProjectUsingProxy(cwd /*: string */) {
}
+function _updateScopedPackages(packages, directory) {
+ console.log('Updating the scoped packagesto match the version published in Verdaccio');
+ // Packages are updated in a lockstep and all with the same version.
+ // Pick the version from the first package
+ const version = packages[Object.keys(packages)[0]].packageJson.version;
+ // Update scoped packages which starts with @react-native
+ const appPackageJsonPath = path.join(
+ directory,
+ 'package.json',
+ const appPackageJson = JSON.parse(
+ for (const [key, _] of Object.entries(appPackageJson.dependencies)) {
+ appPackageJson.dependencies[key] = version
+ for (const [key, _] of Object.entries(appPackageJson.devDependencies)) {
+ appPackageJson.devDependencies[key] = version
+ fs.writeFileSync(
+ appPackageJsonPath,
+ JSON.stringify(appPackageJson, null, 2),
+ console.log('Done ✅');
+function _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory) {
+ if (pathToLocalReactNative != null) {
+ console.log('Updating the template version to local react-native');
+ // Update template version.
+ const appPackageJsonPath = path.join(
+ directory,
+ 'package.json',
+ const appPackageJson = JSON.parse(
+ fs.readFileSync(appPackageJsonPath, 'utf8'),
+ appPackageJson.dependencies['react-native'] =
+ `file:${pathToLocalReactNative}`;
+ fs.writeFileSync(
+ appPackageJsonPath,
+ JSON.stringify(appPackageJson, null, 2),
+ console.log('Done ✅');
module.exports = {
initNewProjectFromSource,
};
diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js
index a4710c41458317..832be80dd2ad60 100644
--- a/scripts/release-testing/test-e2e-local.js
+++ b/scripts/release-testing/test-e2e-local.js
@@ -244,11 +244,6 @@ async function testRNTestProject(
const buildType = 'dry-run';
const reactNativePackagePath = `${REPO_ROOT}/packages/react-native`;
- const templateRepoFolder = '/tmp/template';
- const pathToTemplate = path.join(templateRepoFolder, 'template');
- // Cleanup template clone folder
const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
const mavenLocalPath =
@@ -286,21 +281,6 @@ async function testRNTestProject(
}
- // Cloning the template repo
- // TODO: handle versioning of the template to make sure that we are downloading the right version of
- // the template, given a specific React Native version
- exec(
- `git clone https://github.com/react-native-community/template ${templateRepoFolder} --depth=1`,
- // Update template version.
- const appPackageJsonPath = path.join(pathToTemplate, 'package.json');
- const appPackageJson = JSON.parse(
- fs.readFileSync(appPackageJsonPath, 'utf8'),
- appPackageJson.dependencies['react-native'] = `file:${newLocalNodeTGZ}`;
- fs.writeFileSync(appPackageJsonPath, JSON.stringify(appPackageJson, null, 2));
pushd('/tmp/');
debug('Creating RNTestProject from template');
@@ -311,7 +291,7 @@ async function testRNTestProject(
await initNewProjectFromSource({
projectName: 'RNTestProject',
directory: '/tmp/RNTestProject',
- templatePath: templateRepoFolder,
+ pathToLocalReactNative: newLocalNodeTGZ,
});
cd('RNTestProject'); | [
"+ --pathToLocalReactNative The absolute path to the local react-native package.",
"- `node ./packages/react-native/cli.js init ${projectName} \\",
"+ _updateReactNativeInTemplateIfNeeded(pathToLocalReactNative, directory);",
"+ fs.readFileSync(appPackageJsonPath, 'utf8'),",
"- exec(`rm -rf ${templateRepoFolder}`);"
] | [
27,
49,
62,
84,
142
] | {
"additions": 69,
"author": "cipolleschi",
"deletions": 30,
"html_url": "https://github.com/facebook/react-native/pull/45144",
"issue_id": 45144,
"merged_at": "2024-06-25T12:55:02Z",
"omission_probability": 0.1,
"pr_number": 45144,
"repo": "facebook/react-native",
"title": "[LOCAL][Release-Testing] Update the testing script to use the new template",
"total_changes": 99
} |
532 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index e38257c746ea86..8846abacd544bf 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
- "@react-native-community/cli-server-api": "14.0.0-alpha.2",
- "@react-native-community/cli-tools": "14.0.0-alpha.2",
+ "@react-native-community/cli-server-api": "14.0.0-alpha.9",
+ "@react-native-community/cli-tools": "14.0.0-alpha.9",
"@react-native/dev-middleware": "0.75.0-rc.0",
"@react-native/metro-babel-transformer": "0.75.0-rc.0",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 2359bc1109b56f..e707fb001be672 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -109,9 +109,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "14.0.0-alpha.2",
- "@react-native-community/cli-platform-android": "14.0.0-alpha.2",
- "@react-native-community/cli-platform-ios": "14.0.0-alpha.2",
+ "@react-native-community/cli": "14.0.0-alpha.9",
+ "@react-native-community/cli-platform-android": "14.0.0-alpha.9",
+ "@react-native-community/cli-platform-ios": "14.0.0-alpha.9",
"@react-native/assets-registry": "0.75.0-rc.0",
"@react-native/codegen": "0.75.0-rc.0",
"@react-native/community-cli-plugin": "0.75.0-rc.0",
diff --git a/yarn.lock b/yarn.lock
index 56aa017566dab0..0ece5258bbfaa1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2615,24 +2615,24 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-14.0.0-alpha.2.tgz#f87f1e313652360ad78b3008f91476af9d95e365"
- integrity sha512-QZ8BcrPL+/tWPCk8QH6Z8HMX3gGCLibmJeDdJrCvq/Td/1QSftxxLGLbXowUw4ElukJA9Jkxpc6FyB79E3fDUw==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-14.0.0-alpha.9.tgz#cf4cd3e55a583b40ecaadb343f23b36c70cf7baf"
+ integrity sha512-Cz8nNivB9I06nqiPQiDDb8ZE7yDNCQBtRoSe1hle2rbxBYsvtMoAEC/jdyJIuxm9e0tA72WbrrdUSQqM1eLw3A==
dependencies:
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-14.0.0-alpha.2.tgz#392b0e7d768842b57ec594cb3995f3d4f6fbabe8"
- integrity sha512-UTSkQ9rEQ3WK114Q9zy4XipxPpiAT+Ehgc1bx1HRw8ib4yWD/r53JV40o4OCC2GjWKgj600Lk0PMolCsaGamXA==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-14.0.0-alpha.9.tgz#20878d1984738ef0b14d8e3a5ab03753c9dc3710"
+ integrity sha512-vxhWya2S3yhrlfjXXpSxj/jEB6zKZjoDpDbZaN+aDzdub8Er+z0LEgCNJUA7QgcLtV4MEH9sNA43gZLhNkRW1A==
dependencies:
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
chalk "^4.1.2"
- cosmiconfig "^5.1.0"
+ cosmiconfig "^9.0.0"
deepmerge "^4.3.0"
fast-glob "^3.3.2"
joi "^17.2.1"
@@ -2649,23 +2649,23 @@
fast-glob "^3.3.2"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-14.0.0-alpha.2.tgz#484847fb01eef67ea2c26cd35a88342112c15ff9"
- integrity sha512-HdKmbFF0/7QST00JfC2jexdYPbUelmVaK7VjN9ZnZbZnirseHQU4MsG1lcF5dIuwrQkFH03mt/mF6WSg5ghPeA==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-14.0.0-alpha.9.tgz#233f5fa5ffde9d2b44597bf71890777e4c918de0"
+ integrity sha512-lIKYXKpDJuTvmDqP03aR9G9CLc3WLn9btJ+CldCxoffIs3CpOEZUYC1NRcxRWbGDTZwNSLgra/oTKWXCgVK1gg==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-14.0.0-alpha.2.tgz#0a3e5b7512b930a079e9dacae2cc77073b111f95"
- integrity sha512-qxHiOQX0mKYq5zTJgkBluyYXUH932zauyB4oYEx4pbYMMdITfDskjNIqvXFZDIba3mfv1dsknL+7x05wwZOPtA==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-14.0.0-alpha.9.tgz#f1ee17c67a674ac83d56bed65c45fe02c841f3b6"
+ integrity sha512-pN7t6xna1+GqJDuXb1zTtAgbqc9jyw3T0ySvJ86eA9BLCAW11TSI9rjU6IIPcnKB+JxsxOyD4blmQjrFN2VIzA==
dependencies:
- "@react-native-community/cli-config" "14.0.0-alpha.2"
- "@react-native-community/cli-platform-android" "14.0.0-alpha.2"
- "@react-native-community/cli-platform-apple" "14.0.0-alpha.2"
- "@react-native-community/cli-platform-ios" "14.0.0-alpha.2"
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-config" "14.0.0-alpha.9"
+ "@react-native-community/cli-platform-android" "14.0.0-alpha.9"
+ "@react-native-community/cli-platform-apple" "14.0.0-alpha.9"
+ "@react-native-community/cli-platform-ios" "14.0.0-alpha.9"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -2678,28 +2678,28 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-14.0.0-alpha.2.tgz#a2ce4de0f3003db3cf34fcdbf384f701ae1dc16d"
- integrity sha512-gQoP3WdjzpwGv81kypx2dcu3Cdz4vRuYubEUdfiTe/KV416cFsRAYnhx6L1LFrO36SoRKODwHaYTfo14ZpFp5Q==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-14.0.0-alpha.9.tgz#8fdadf53e3fa0586b5093adb77a52701995768b7"
+ integrity sha512-DjPtKnPnKr8JmyIbSnVeEbRk825NWa0kL0ZL6F461NKawhvKunHQ6oIH1xs+oJbQ4apmWvijjFCUCp2/Ye/1xg==
dependencies:
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-14.0.0-alpha.2.tgz#feaa2770005dd08b6bff380c623ec177a65d2a65"
- integrity sha512-IYdkvodYOKRmK2AuN7tHhisrwVGabI5UW0NABbk4X/ANh/ds27kbhLR/Jc4wC4QeuYtdIiHmv8gxIXbB2p5eWw==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-14.0.0-alpha.9.tgz#d8c2683e9609f52c27939e4c6b604be43145e8c0"
+ integrity sha512-Gs4USDaMhtrnPb46DpjXkC7eq9Bkpc3ENIV2YFBgBdMo2aIFmIsBycvm5+asMSJlKwsyDYnxBJBLo6FOUkwE2w==
dependencies:
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
- fast-xml-parser "^4.0.12"
+ fast-xml-parser "^4.2.4"
ora "^5.4.1"
"@react-native-community/cli-platform-apple@^13.6.4":
@@ -2714,27 +2714,27 @@
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-14.0.0-alpha.2.tgz#6651691421d57d4230ee8d0dcd309af94a8303a7"
- integrity sha512-QugzljDvIQ1UZ8EvaJJ6PyGEMKcRsIGa2afwwKAwexQyGOWxPaN5vAwl1OwNpl+AmnbR4RiAqctUBXm8HhxghA==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-14.0.0-alpha.9.tgz#4f2686ca03efa186aac3bf354cbf15936627d4f8"
+ integrity sha512-7Rb399ErNpVpQvcF7RQolFk9HF6xRsZkdSlAZQGM2lCNQ3Wj4CRX6Bixa59bnGAY+uK3bjE/LeFcUbFXPgzr0Q==
dependencies:
- "@react-native-community/cli-platform-apple" "14.0.0-alpha.2"
+ "@react-native-community/cli-platform-apple" "14.0.0-alpha.9"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-14.0.0-alpha.2.tgz#28ddb885f2fee76b325799f512ff0fbdd02570cd"
- integrity sha512-msL6fzZkUe9GTtG8E/LN1/Uh7x2mE3xr7rjtpk5ADTx+TlJpnPtkHucyODu57e2i19jcLqXzO0u0ImfgOG55WA==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-14.0.0-alpha.9.tgz#f5ac1de8a955dd496617322d659e120e44cdc0a5"
+ integrity sha512-8iEZoFNv0EzqVuTXm2tamUOKzPfq8E3Yjc7kdpqT68gwRD/MBpXM+t7ItEU8EbfhArccUHVADKWjWGdnQ43adw==
dependencies:
- "@react-native-community/cli-debugger-ui" "14.0.0-alpha.2"
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
+ "@react-native-community/cli-debugger-ui" "14.0.0-alpha.9"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
nocache "^3.0.1"
pretty-format "^26.6.2"
serve-static "^1.13.1"
- ws "^7.5.1"
+ ws "^6.2.2"
"@react-native-community/[email protected]", "@react-native-community/cli-tools@^13.6.4":
version "13.6.4"
@@ -2753,27 +2753,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-14.0.0-alpha.2.tgz#fa898083fa48449d9a2a08624fa2d71057a37d2e"
- integrity sha512-GDFwGSPjcTYhdn8bmT+oleL2rFrVHgLAZbKu8LjIq0n4bO7cacSTbRtqe31h3QixolNYMWsVobtDpD/zBtKVxg==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-14.0.0-alpha.9.tgz#1356a21c69bb1982586ea705351d1c1ffd4489f5"
+ integrity sha512-DGDHyJA/acfOwzjqyPK5cm0ZMHzu1IctL4HwK01y48o+bi5gIxUcKhmGUZWA2LwLTNjIto64EE3i3dUT9jRHAA==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
execa "^5.0.0"
find-up "^5.0.0"
mime "^2.4.1"
- node-fetch "^2.6.0"
open "^6.2.0"
ora "^5.4.1"
semver "^7.5.2"
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-14.0.0-alpha.2.tgz#6ebb5d088350901ed6d9870ab9b1e75dd7609ca9"
- integrity sha512-aG6HvmhnmMU5kNnSxLtajX8b75hE2Y0bzJLhVX6eqR+nUhqCcwKvGxiHSIU93K3aPRnp1sXMo8owaBVBDESGYQ==
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-14.0.0-alpha.9.tgz#9a95bf0e3184e8eb44fd6082016ddb1c93b06c24"
+ integrity sha512-XEDwsrgje9JG5hVuUCBWaH8XVV1H3ZcTwXxd/XhmDNemPyOLnDfgeAlitbEMyi+X/SWB04EGQu1SeRwe5vLePA==
dependencies:
joi "^17.2.1"
@@ -2784,18 +2783,18 @@
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "14.0.0-alpha.2"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-14.0.0-alpha.2.tgz#39ca31ebe0ff615398012bacdd3de710229707a1"
- integrity sha512-7y+G2wGHue8leoKSE1MvhGH4CqfSgTc3JWl9MMBeEVBNW7kwS+CGQEUziGZBVea/EVU4t0OEHIJOMK516rYl3A==
- dependencies:
- "@react-native-community/cli-clean" "14.0.0-alpha.2"
- "@react-native-community/cli-config" "14.0.0-alpha.2"
- "@react-native-community/cli-debugger-ui" "14.0.0-alpha.2"
- "@react-native-community/cli-doctor" "14.0.0-alpha.2"
- "@react-native-community/cli-server-api" "14.0.0-alpha.2"
- "@react-native-community/cli-tools" "14.0.0-alpha.2"
- "@react-native-community/cli-types" "14.0.0-alpha.2"
+"@react-native-community/[email protected]":
+ version "14.0.0-alpha.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-14.0.0-alpha.9.tgz#0a00a3f8bcee9edb482ad59018bd4d3a8e7210f7"
+ integrity sha512-1EAs79u+dPxDIBq1TkT2TV3Pa7fw1CakmoFTTSVYA4EHnRVqSnonAQj/kSf8cVuL4ORHDavlnzHcCaSXCB0MRQ==
+ dependencies:
+ "@react-native-community/cli-clean" "14.0.0-alpha.9"
+ "@react-native-community/cli-config" "14.0.0-alpha.9"
+ "@react-native-community/cli-debugger-ui" "14.0.0-alpha.9"
+ "@react-native-community/cli-doctor" "14.0.0-alpha.9"
+ "@react-native-community/cli-server-api" "14.0.0-alpha.9"
+ "@react-native-community/cli-tools" "14.0.0-alpha.9"
+ "@react-native-community/cli-types" "14.0.0-alpha.9"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
@@ -4504,6 +4503,16 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0:
js-yaml "^3.13.0"
parse-json "^4.0.0"
+cosmiconfig@^9.0.0:
+ version "9.0.0"
+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d"
+ integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==
+ dependencies:
+ env-paths "^2.2.1"
+ import-fresh "^3.3.0"
+ js-yaml "^4.1.0"
+ parse-json "^5.2.0"
+
crc-32@^1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"
@@ -4871,6 +4880,11 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.1:
dependencies:
once "^1.4.0"
+env-paths@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
+ integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==
+
envinfo@^7.10.0:
version "7.11.0"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.11.0.tgz#c3793f44284a55ff8c82faf1ffd91bc6478ea01f"
@@ -6144,6 +6158,14 @@ import-fresh@^3.2.1:
parent-module "^1.0.0"
resolve-from "^4.0.0"
+import-fresh@^3.3.0:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
+ integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==
+ dependencies:
+ parent-module "^1.0.0"
+ resolve-from "^4.0.0"
+
import-local@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4"
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index e38257c746ea86..8846abacd544bf 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
- "@react-native-community/cli-server-api": "14.0.0-alpha.2",
- "@react-native-community/cli-tools": "14.0.0-alpha.2",
+ "@react-native-community/cli-server-api": "14.0.0-alpha.9",
+ "@react-native-community/cli-tools": "14.0.0-alpha.9",
"@react-native/dev-middleware": "0.75.0-rc.0",
"@react-native/metro-babel-transformer": "0.75.0-rc.0",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 2359bc1109b56f..e707fb001be672 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -109,9 +109,9 @@
},
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "14.0.0-alpha.2",
- "@react-native-community/cli-platform-android": "14.0.0-alpha.2",
- "@react-native-community/cli-platform-ios": "14.0.0-alpha.2",
+ "@react-native-community/cli": "14.0.0-alpha.9",
+ "@react-native-community/cli-platform-android": "14.0.0-alpha.9",
+ "@react-native-community/cli-platform-ios": "14.0.0-alpha.9",
"@react-native/assets-registry": "0.75.0-rc.0",
"@react-native/codegen": "0.75.0-rc.0",
"@react-native/community-cli-plugin": "0.75.0-rc.0",
diff --git a/yarn.lock b/yarn.lock
index 56aa017566dab0..0ece5258bbfaa1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2615,24 +2615,24 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-14.0.0-alpha.2.tgz#f87f1e313652360ad78b3008f91476af9d95e365"
- integrity sha512-QZ8BcrPL+/tWPCk8QH6Z8HMX3gGCLibmJeDdJrCvq/Td/1QSftxxLGLbXowUw4ElukJA9Jkxpc6FyB79E3fDUw==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-14.0.0-alpha.9.tgz#cf4cd3e55a583b40ecaadb343f23b36c70cf7baf"
+ integrity sha512-Cz8nNivB9I06nqiPQiDDb8ZE7yDNCQBtRoSe1hle2rbxBYsvtMoAEC/jdyJIuxm9e0tA72WbrrdUSQqM1eLw3A==
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-14.0.0-alpha.2.tgz#392b0e7d768842b57ec594cb3995f3d4f6fbabe8"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-14.0.0-alpha.9.tgz#20878d1984738ef0b14d8e3a5ab03753c9dc3710"
+ integrity sha512-vxhWya2S3yhrlfjXXpSxj/jEB6zKZjoDpDbZaN+aDzdub8Er+z0LEgCNJUA7QgcLtV4MEH9sNA43gZLhNkRW1A==
- cosmiconfig "^5.1.0"
+ cosmiconfig "^9.0.0"
@@ -2649,23 +2649,23 @@
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-14.0.0-alpha.2.tgz#484847fb01eef67ea2c26cd35a88342112c15ff9"
- integrity sha512-HdKmbFF0/7QST00JfC2jexdYPbUelmVaK7VjN9ZnZbZnirseHQU4MsG1lcF5dIuwrQkFH03mt/mF6WSg5ghPeA==
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-14.0.0-alpha.9.tgz#233f5fa5ffde9d2b44597bf71890777e4c918de0"
+ integrity sha512-lIKYXKpDJuTvmDqP03aR9G9CLc3WLn9btJ+CldCxoffIs3CpOEZUYC1NRcxRWbGDTZwNSLgra/oTKWXCgVK1gg==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-14.0.0-alpha.2.tgz#0a3e5b7512b930a079e9dacae2cc77073b111f95"
- integrity sha512-qxHiOQX0mKYq5zTJgkBluyYXUH932zauyB4oYEx4pbYMMdITfDskjNIqvXFZDIba3mfv1dsknL+7x05wwZOPtA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-14.0.0-alpha.9.tgz#f1ee17c67a674ac83d56bed65c45fe02c841f3b6"
+ integrity sha512-pN7t6xna1+GqJDuXb1zTtAgbqc9jyw3T0ySvJ86eA9BLCAW11TSI9rjU6IIPcnKB+JxsxOyD4blmQjrFN2VIzA==
- "@react-native-community/cli-platform-android" "14.0.0-alpha.2"
- "@react-native-community/cli-platform-ios" "14.0.0-alpha.2"
+ "@react-native-community/cli-platform-android" "14.0.0-alpha.9"
command-exists "^1.2.8"
@@ -2678,28 +2678,28 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-14.0.0-alpha.2.tgz#a2ce4de0f3003db3cf34fcdbf384f701ae1dc16d"
- integrity sha512-gQoP3WdjzpwGv81kypx2dcu3Cdz4vRuYubEUdfiTe/KV416cFsRAYnhx6L1LFrO36SoRKODwHaYTfo14ZpFp5Q==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-14.0.0-alpha.9.tgz#8fdadf53e3fa0586b5093adb77a52701995768b7"
+ integrity sha512-DjPtKnPnKr8JmyIbSnVeEbRk825NWa0kL0ZL6F461NKawhvKunHQ6oIH1xs+oJbQ4apmWvijjFCUCp2/Ye/1xg==
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-14.0.0-alpha.9.tgz#d8c2683e9609f52c27939e4c6b604be43145e8c0"
+ integrity sha512-Gs4USDaMhtrnPb46DpjXkC7eq9Bkpc3ENIV2YFBgBdMo2aIFmIsBycvm5+asMSJlKwsyDYnxBJBLo6FOUkwE2w==
- fast-xml-parser "^4.0.12"
+ fast-xml-parser "^4.2.4"
"@react-native-community/cli-platform-apple@^13.6.4":
@@ -2714,27 +2714,27 @@
fast-xml-parser "^4.0.12"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-14.0.0-alpha.2.tgz#6651691421d57d4230ee8d0dcd309af94a8303a7"
- integrity sha512-QugzljDvIQ1UZ8EvaJJ6PyGEMKcRsIGa2afwwKAwexQyGOWxPaN5vAwl1OwNpl+AmnbR4RiAqctUBXm8HhxghA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-14.0.0-alpha.9.tgz#4f2686ca03efa186aac3bf354cbf15936627d4f8"
+ integrity sha512-7Rb399ErNpVpQvcF7RQolFk9HF6xRsZkdSlAZQGM2lCNQ3Wj4CRX6Bixa59bnGAY+uK3bjE/LeFcUbFXPgzr0Q==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-14.0.0-alpha.2.tgz#28ddb885f2fee76b325799f512ff0fbdd02570cd"
- integrity sha512-msL6fzZkUe9GTtG8E/LN1/Uh7x2mE3xr7rjtpk5ADTx+TlJpnPtkHucyODu57e2i19jcLqXzO0u0ImfgOG55WA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-14.0.0-alpha.9.tgz#f5ac1de8a955dd496617322d659e120e44cdc0a5"
+ integrity sha512-8iEZoFNv0EzqVuTXm2tamUOKzPfq8E3Yjc7kdpqT68gwRD/MBpXM+t7ItEU8EbfhArccUHVADKWjWGdnQ43adw==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
nocache "^3.0.1"
pretty-format "^26.6.2"
- ws "^7.5.1"
+ ws "^6.2.2"
"@react-native-community/[email protected]", "@react-native-community/cli-tools@^13.6.4":
version "13.6.4"
@@ -2753,27 +2753,26 @@
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-14.0.0-alpha.2.tgz#fa898083fa48449d9a2a08624fa2d71057a37d2e"
- integrity sha512-GDFwGSPjcTYhdn8bmT+oleL2rFrVHgLAZbKu8LjIq0n4bO7cacSTbRtqe31h3QixolNYMWsVobtDpD/zBtKVxg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-14.0.0-alpha.9.tgz#1356a21c69bb1982586ea705351d1c1ffd4489f5"
+ integrity sha512-DGDHyJA/acfOwzjqyPK5cm0ZMHzu1IctL4HwK01y48o+bi5gIxUcKhmGUZWA2LwLTNjIto64EE3i3dUT9jRHAA==
appdirsjs "^1.2.4"
find-up "^5.0.0"
mime "^2.4.1"
- node-fetch "^2.6.0"
open "^6.2.0"
semver "^7.5.2"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-14.0.0-alpha.2.tgz#6ebb5d088350901ed6d9870ab9b1e75dd7609ca9"
- integrity sha512-aG6HvmhnmMU5kNnSxLtajX8b75hE2Y0bzJLhVX6eqR+nUhqCcwKvGxiHSIU93K3aPRnp1sXMo8owaBVBDESGYQ==
+"@react-native-community/[email protected]":
+ integrity sha512-XEDwsrgje9JG5hVuUCBWaH8XVV1H3ZcTwXxd/XhmDNemPyOLnDfgeAlitbEMyi+X/SWB04EGQu1SeRwe5vLePA==
@@ -2784,18 +2783,18 @@
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-14.0.0-alpha.2.tgz#39ca31ebe0ff615398012bacdd3de710229707a1"
- integrity sha512-7y+G2wGHue8leoKSE1MvhGH4CqfSgTc3JWl9MMBeEVBNW7kwS+CGQEUziGZBVea/EVU4t0OEHIJOMK516rYl3A==
- dependencies:
- "@react-native-community/cli-clean" "14.0.0-alpha.2"
- "@react-native-community/cli-doctor" "14.0.0-alpha.2"
- "@react-native-community/cli-server-api" "14.0.0-alpha.2"
- "@react-native-community/cli-types" "14.0.0-alpha.2"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-14.0.0-alpha.9.tgz#0a00a3f8bcee9edb482ad59018bd4d3a8e7210f7"
+ integrity sha512-1EAs79u+dPxDIBq1TkT2TV3Pa7fw1CakmoFTTSVYA4EHnRVqSnonAQj/kSf8cVuL4ORHDavlnzHcCaSXCB0MRQ==
+ "@react-native-community/cli-clean" "14.0.0-alpha.9"
+ "@react-native-community/cli-doctor" "14.0.0-alpha.9"
+ "@react-native-community/cli-types" "14.0.0-alpha.9"
commander "^9.4.1"
@@ -4504,6 +4503,16 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0:
js-yaml "^3.13.0"
parse-json "^4.0.0"
+cosmiconfig@^9.0.0:
+ version "9.0.0"
+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-9.0.0.tgz#34c3fc58287b915f3ae905ab6dc3de258b55ad9d"
+ integrity sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==
+ import-fresh "^3.3.0"
+ js-yaml "^4.1.0"
+ parse-json "^5.2.0"
crc-32@^1.2.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"
@@ -4871,6 +4880,11 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.1:
once "^1.4.0"
+env-paths@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2"
envinfo@^7.10.0:
version "7.11.0"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.11.0.tgz#c3793f44284a55ff8c82faf1ffd91bc6478ea01f"
@@ -6144,6 +6158,14 @@ import-fresh@^3.2.1:
parent-module "^1.0.0"
resolve-from "^4.0.0"
+import-fresh@^3.3.0:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
+ parent-module "^1.0.0"
+ resolve-from "^4.0.0"
import-local@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" | [
"-\"@react-native-community/[email protected]\":",
"- integrity sha512-UTSkQ9rEQ3WK114Q9zy4XipxPpiAT+Ehgc1bx1HRw8ib4yWD/r53JV40o4OCC2GjWKgj600Lk0PMolCsaGamXA==",
"+\"@react-native-community/[email protected]\":",
"+ \"@react-native-community/cli-platform-ios\" \"14.0.0-alpha.9\"",
"-\"@react-native-community/[email protected]\":",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-14.0.0-alpha.2.tgz#feaa2770005dd08b6bff380c623ec177a65d2a65\"",
"- integrity sha512-IYdkvodYOKRmK2AuN7tHhisrwVGabI5UW0NABbk4X/ANh/ds27kbhLR/Jc4wC4QeuYtdIiHmv8gxIXbB2p5eWw==",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-14.0.0-alpha.9.tgz#9a95bf0e3184e8eb44fd6082016ddb1c93b06c24\"",
"+ \"@react-native-community/cli-server-api\" \"14.0.0-alpha.9\"",
"+ env-paths \"^2.2.1\"",
"+ integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
"+ integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw=="
] | [
55,
58,
80,
104,
113,
132,
133,
220,
250,
265,
280,
292
] | {
"additions": 95,
"author": "cipolleschi",
"deletions": 73,
"html_url": "https://github.com/facebook/react-native/pull/45123",
"issue_id": 45123,
"merged_at": "2024-06-24T12:02:41Z",
"omission_probability": 0.1,
"pr_number": 45123,
"repo": "facebook/react-native",
"title": "[RN][CI] Bump react-native CLI dependency to alpha.9",
"total_changes": 168
} |
533 | diff --git a/scripts/__tests__/npm-utils-test.js b/scripts/__tests__/npm-utils-test.js
index a804a968409eb5..86841546dbdec6 100644
--- a/scripts/__tests__/npm-utils-test.js
+++ b/scripts/__tests__/npm-utils-test.js
@@ -115,6 +115,11 @@ describe('npm-utils', () => {
});
describe('getNpmInfo', () => {
+ beforeEach(() => {
+ process.env.CIRCLE_TAG = '';
+ process.env.GITHUB_REF = '';
+ process.env.GITHUB_REF_NAME = '';
+ });
it('return the expected format for prealpha', () => {
const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
@@ -147,33 +152,30 @@ describe('npm-utils', () => {
version: `0.74.1-rc.0`,
tag: '--no-tag',
});
- process.env.CIRCLE_TAG = null;
});
- });
- it('return the expected format for patch-prereleases on GHA', () => {
- const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
- isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
- getCurrentCommitMock.mockImplementation(() => 'abcd1234');
- // exitIfNotOnGit takes a function as a param and it:
- // 1. checks if we are on git => if not it exits
- // 2. run the function passed as a param and return the output to the caller
- // For the mock, we are assuming we are on github and we are returning `false`
- // as the `getNpmInfo` function will pass a function that checks if the
- // current commit is a tagged with 'latest'.
- // In the Mock, we are assuming that we are on git (it does not exits) and the
- // checkIfLatest function returns `false`
- exitIfNotOnGitMock.mockImplementation(() => false);
-
- process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';
- process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
- const returnedValue = getNpmInfo('release');
- expect(returnedValue).toMatchObject({
- version: `0.74.1-rc.0`,
- tag: '--no-tag',
+ it('return the expected format for patch-prereleases on GHA', () => {
+ const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
+ isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
+ getCurrentCommitMock.mockImplementation(() => 'abcd1234');
+ // exitIfNotOnGit takes a function as a param and it:
+ // 1. checks if we are on git => if not it exits
+ // 2. run the function passed as a param and return the output to the caller
+ // For the mock, we are assuming we are on github and we are returning `false`
+ // as the `getNpmInfo` function will pass a function that checks if the
+ // current commit is a tagged with 'latest'.
+ // In the Mock, we are assuming that we are on git (it does not exits) and the
+ // checkIfLatest function returns `false`
+ exitIfNotOnGitMock.mockImplementation(() => false);
+
+ process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';
+ process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
+ const returnedValue = getNpmInfo('release');
+ expect(returnedValue).toMatchObject({
+ version: `0.74.1-rc.0`,
+ tag: '--no-tag',
+ });
});
- process.env.GITHUB_REF = null;
- process.env.GITHUB_REF_NAME = null;
});
describe('getVersionsBySpec', () => {
diff --git a/scripts/npm-utils.js b/scripts/npm-utils.js
index b7f16ae8a1bd7f..2607be95832e7a 100644
--- a/scripts/npm-utils.js
+++ b/scripts/npm-utils.js
@@ -90,12 +90,13 @@ function getNpmInfo(buildType /*: BuildType */) /*: NpmInfo */ {
if (buildType === 'release') {
let versionTag /*: string*/ = '';
- if (process.env.CIRCLE_TAG != null) {
+ if (process.env.CIRCLE_TAG != null && process.env.CIRCLE_TAG !== '') {
versionTag = process.env.CIRCLE_TAG;
} else if (
process.env.GITHUB_REF != null &&
process.env.GITHUB_REF.includes('/tags/') &&
- process.env.GITHUB_REF_NAME != null
+ process.env.GITHUB_REF_NAME != null &&
+ process.env.GITHUB_REF_NAME !== ''
) {
// GITHUB_REF contains the fully qualified ref, for example refs/tags/v0.75.0-rc.0
// GITHUB_REF_NAME contains the short name, for example v0.75.0-rc.0
| diff --git a/scripts/__tests__/npm-utils-test.js b/scripts/__tests__/npm-utils-test.js
index a804a968409eb5..86841546dbdec6 100644
--- a/scripts/__tests__/npm-utils-test.js
+++ b/scripts/__tests__/npm-utils-test.js
@@ -115,6 +115,11 @@ describe('npm-utils', () => {
describe('getNpmInfo', () => {
+ beforeEach(() => {
+ process.env.CIRCLE_TAG = '';
+ process.env.GITHUB_REF_NAME = '';
it('return the expected format for prealpha', () => {
const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
@@ -147,33 +152,30 @@ describe('npm-utils', () => {
version: `0.74.1-rc.0`,
tag: '--no-tag',
});
- process.env.CIRCLE_TAG = null;
- });
- it('return the expected format for patch-prereleases on GHA', () => {
- const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
- isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
- getCurrentCommitMock.mockImplementation(() => 'abcd1234');
- // exitIfNotOnGit takes a function as a param and it:
- // 1. checks if we are on git => if not it exits
- // 2. run the function passed as a param and return the output to the caller
- // For the mock, we are assuming we are on github and we are returning `false`
- // as the `getNpmInfo` function will pass a function that checks if the
- // In the Mock, we are assuming that we are on git (it does not exits) and the
- // checkIfLatest function returns `false`
- exitIfNotOnGitMock.mockImplementation(() => false);
-
- process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';
- process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
- const returnedValue = getNpmInfo('release');
- version: `0.74.1-rc.0`,
- tag: '--no-tag',
+ it('return the expected format for patch-prereleases on GHA', () => {
+ const isoStringSpy = jest.spyOn(Date.prototype, 'toISOString');
+ isoStringSpy.mockReturnValue('2023-10-04T15:43:55.123Z');
+ getCurrentCommitMock.mockImplementation(() => 'abcd1234');
+ // exitIfNotOnGit takes a function as a param and it:
+ // 1. checks if we are on git => if not it exits
+ // 2. run the function passed as a param and return the output to the caller
+ // For the mock, we are assuming we are on github and we are returning `false`
+ // as the `getNpmInfo` function will pass a function that checks if the
+ // current commit is a tagged with 'latest'.
+ // In the Mock, we are assuming that we are on git (it does not exits) and the
+ // checkIfLatest function returns `false`
+ exitIfNotOnGitMock.mockImplementation(() => false);
+ process.env.GITHUB_REF_NAME = 'v0.74.1-rc.0';
+ const returnedValue = getNpmInfo('release');
+ expect(returnedValue).toMatchObject({
+ version: `0.74.1-rc.0`,
+ tag: '--no-tag',
+ });
- process.env.GITHUB_REF = null;
- process.env.GITHUB_REF_NAME = null;
describe('getVersionsBySpec', () => {
diff --git a/scripts/npm-utils.js b/scripts/npm-utils.js
index b7f16ae8a1bd7f..2607be95832e7a 100644
--- a/scripts/npm-utils.js
+++ b/scripts/npm-utils.js
@@ -90,12 +90,13 @@ function getNpmInfo(buildType /*: BuildType */) /*: NpmInfo */ {
if (buildType === 'release') {
let versionTag /*: string*/ = '';
- if (process.env.CIRCLE_TAG != null) {
versionTag = process.env.CIRCLE_TAG;
} else if (
process.env.GITHUB_REF != null &&
process.env.GITHUB_REF.includes('/tags/') &&
+ process.env.GITHUB_REF_NAME != null &&
+ process.env.GITHUB_REF_NAME !== ''
) {
// GITHUB_REF contains the fully qualified ref, for example refs/tags/v0.75.0-rc.0
// GITHUB_REF_NAME contains the short name, for example v0.75.0-rc.0 | [
"+ process.env.GITHUB_REF = '';",
"+ });",
"- // current commit is a tagged with 'latest'.",
"- expect(returnedValue).toMatchObject({",
"+",
"+ process.env.GITHUB_REF = 'refs/tags/v0.74.1-rc.0';",
"+ if (process.env.CIRCLE_TAG != null && process.env.CIRCLE_TAG !== '') {",
"- process.env.GITHUB_REF_NAME != null"
] | [
10,
12,
33,
41,
57,
58,
80,
85
] | {
"additions": 29,
"author": "cipolleschi",
"deletions": 26,
"html_url": "https://github.com/facebook/react-native/pull/45062",
"issue_id": 45062,
"merged_at": "2024-06-19T13:37:48Z",
"omission_probability": 0.1,
"pr_number": 45062,
"repo": "facebook/react-native",
"title": "[LOCAL][RN][Tests] Fix JS tests for release",
"total_changes": 55
} |
534 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 7a4f219798c9a2..1697aa95ff4ed7 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
- "@react-native-community/cli-server-api": "13.6.8",
- "@react-native-community/cli-tools": "13.6.8",
+ "@react-native-community/cli-server-api": "13.6.9",
+ "@react-native-community/cli-tools": "13.6.9",
"@react-native/dev-middleware": "0.74.84",
"@react-native/metro-babel-transformer": "0.74.84",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 1d1a0b15989ecd..aae8bc3f91dfb1 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.8",
- "@react-native-community/cli-platform-android": "13.6.8",
- "@react-native-community/cli-platform-ios": "13.6.8",
+ "@react-native-community/cli": "13.6.9",
+ "@react-native-community/cli-platform-android": "13.6.9",
+ "@react-native-community/cli-platform-ios": "13.6.9",
"@react-native/assets-registry": "0.74.84",
"@react-native/codegen": "0.74.84",
"@react-native/community-cli-plugin": "0.74.84",
diff --git a/yarn.lock b/yarn.lock
index c90cace18330ef..b4415f08c5af53 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474"
- integrity sha512-B1uxlm1N4BQuWFvBL3yRl3LVvydjswsdbTi7tMrHMtSxfRio1p9HjcmDzlzKco09Y+8qBGgakm3jcMZGLbhXQQ==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.9.tgz#b6754f39c2b877c9d730feb848945150e1d52209"
+ integrity sha512-7Dj5+4p9JggxuVNOjPbduZBAP1SUgNhLKVw5noBUzT/3ZpUZkDM+RCSwyoyg8xKWoE4OrdUAXwAFlMcFDPKykA==
dependencies:
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.8.tgz#6829ea7cdc237776c300be06f84c222bf17cf4c5"
- integrity sha512-RabCkIsWdP4Ex/sf1uSP9qxc30utm+0uIJAjrZkNQynm7T4Lyqn/kT3LKm4yM6M0Qk61YxGguiaXF4601vAduw==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.9.tgz#d609a64d40a173c89bd7d24e31807bb7dcba69f9"
+ integrity sha512-rFfVBcNojcMm+KKHE/xqpqXg8HoKl4EC7bFHUrahMJ+y/tZll55+oX/PGG37rzB8QzP2UbMQ19DYQKC1G7kXeg==
dependencies:
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
cosmiconfig "^5.1.0"
deepmerge "^4.3.0"
fast-glob "^3.3.2"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.8.tgz#d52fccd4b3e0860d96d75ff5b0ebb128bdc93dfd"
- integrity sha512-2cS+MX/Su6sVSjqpDftFOXbK7EuPg98xzsPkdPhkQnkZwvXqodK9CAMuDMbx3lBHHtrPrpMbBCpFmPN8iVOnlA==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.9.tgz#bc5727c51964206a00d417e5148b46331a81d5a5"
+ integrity sha512-TkN7IdFmGPPvTpAo3nCAH9uwGCPxWBEAwpqEZDrq0NWllI7Tdie8vDpGdrcuCcKalmhq6OYnkXzeBah7O1Ztpw==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.8.tgz#05f696d94e975e4dcf7f9a1fde32fb43e4bb8a5f"
- integrity sha512-/3Vdy9J3hyiu0y3nd/CU3kBqPlTRxnLXg7V6jrA1jbTOlZAMyV9imEkrqEaGK0SMOyMhh9Pipf98Ozhk0Nl4QA==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.9.tgz#f1d4eeff427ddc8a9d19851042621c10939c35cb"
+ integrity sha512-5quFaLdWFQB+677GXh5dGU9I5eg2z6Vg4jOX9vKnc9IffwyIFAyJfCZHrxLSRPDGNXD7biDQUdoezXYGwb6P/A==
dependencies:
- "@react-native-community/cli-config" "13.6.8"
- "@react-native-community/cli-platform-android" "13.6.8"
- "@react-native-community/cli-platform-apple" "13.6.8"
- "@react-native-community/cli-platform-ios" "13.6.8"
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-config" "13.6.9"
+ "@react-native-community/cli-platform-android" "13.6.9"
+ "@react-native-community/cli-platform-apple" "13.6.9"
+ "@react-native-community/cli-platform-ios" "13.6.9"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -2436,54 +2436,54 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.8.tgz#85f10f663bc79f299146e749c48c06ebc4da9e29"
- integrity sha512-lZi/OBFuZUj5cLK94oEgtrtmxGoqeYVRcnHXl/R5c4put9PDl+qH2bEMlGZkFiw57ae3UZKr3TMk+1s4jh3FYQ==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.9.tgz#88c8dfe936a0d4272efc54429eda9ccc3fca3ad8"
+ integrity sha512-GvwiwgvFw4Ws+krg2+gYj8sR3g05evmNjAHkKIKMkDTJjZ8EdyxbkifRUs1ZCq3TMZy2oeblZBXCJVOH4W7ZbA==
dependencies:
- "@react-native-community/cli-platform-android" "13.6.8"
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-platform-android" "13.6.9"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.8.tgz#a3672512a9b844f93d6050537c59dd58e1b12f17"
- integrity sha512-vWrqeLRRTwp2kO33nbrAgbYn8HR2c2CpIfyVJY9Ckk7HGUSwDyxdcSu7YBvt2ShdfLZH0HctWFNXsgGrfg6BDw==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.9.tgz#b175b9b11334fc90da3f395432678bd53c30fae4"
+ integrity sha512-9KsYGdr08QhdvT3Ht7e8phQB3gDX9Fs427NJe0xnoBh+PDPTI2BD5ks5ttsH8CzEw8/P6H8tJCHq6hf2nxd9cw==
dependencies:
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.8.tgz#4d46a2d6678a7b3264768f97393f082ed9afb264"
- integrity sha512-1JPohnlXPqU44zns3ALEzIbH2cKRw6JtEDJERgLuEUbs2r2NeJgqDbKyZ7fTTO8o+pegDnn6+Rr7qGVVOuUzzg==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.9.tgz#02fb5dc47d62acd85f4d7a852e93216927a772fa"
+ integrity sha512-KoeIHfhxMhKXZPXmhQdl6EE+jGKWwoO9jUVWgBvibpVmsNjo7woaG/tfJMEWfWF3najX1EkQAoJWpCDBMYWtlA==
dependencies:
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.9"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.8.tgz#2de1bd8529825781108c1cbba4f5b25cb062581c"
- integrity sha512-/IIcIRM8qaoD7iZqsvtf6Qq1AwtChWYfB9sTn3mTiolZ5Zd5bXH37g+6liPfAICRkj2Ptq3iXmjrDVUQAxrOXw==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.9.tgz#f37ceab41c2302e8f0d4bcbd3bf58b3353db4306"
+ integrity sha512-CiUcHlGs8vE0CAB4oi1f+dzniqfGuhWPNrDvae2nm8dewlahTBwIcK5CawyGezjcJoeQhjBflh9vloska+nlnw==
dependencies:
- "@react-native-community/cli-platform-apple" "13.6.8"
+ "@react-native-community/cli-platform-apple" "13.6.9"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63"
- integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.9.tgz#269e666bc26e9d0b2f42c7f6099559b5f9259e9d"
+ integrity sha512-W8FSlCPWymO+tlQfM3E0JmM8Oei5HZsIk5S0COOl0MRi8h0NmHI4WSTF2GCfbFZkcr2VI/fRsocoN8Au4EZAug==
dependencies:
- "@react-native-community/cli-debugger-ui" "13.6.8"
- "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-debugger-ui" "13.6.9"
+ "@react-native-community/cli-tools" "13.6.9"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2492,10 +2492,10 @@
serve-static "^1.13.1"
ws "^6.2.2"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142"
- integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.9.tgz#2baee279358ba1a863e737b2fa9f45659ad91929"
+ integrity sha512-OXaSjoN0mZVw3nrAwcY1PC0uMfyTd9fz7Cy06dh+EJc+h0wikABsVRzV8cIOPrVV+PPEEXE0DBrH20T2puZzgQ==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436"
- integrity sha512-C4mVByy0i+/NPuPhdMLBR7ubEVkjVS1VwoQu/BoG1crJFNE+167QXAzH01eFbXndsjZaMWmD4Gerx7TYc6lHfA==
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.9.tgz#08bfb796eacf0daeb31e2de516e81e78a36a1a55"
+ integrity sha512-RLxDppvRxXfs3hxceW/mShi+6o5yS+kFPnPqZTaMKKR5aSg7LwDpLQW4K2D22irEG8e6RKDkZUeH9aL3vO2O0w==
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.8"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.8.tgz#d52c22620242e161bddcd2e0b6dbacd8743ca09b"
- integrity sha512-0lRdgLNaXixWY4BfFRl1J6Ao9Lapo2z+++iE7TD4GAbuxOWJSyFi+KUA8XNfSDyML4jFO02MZgyBPxAWdaminQ==
- dependencies:
- "@react-native-community/cli-clean" "13.6.8"
- "@react-native-community/cli-config" "13.6.8"
- "@react-native-community/cli-debugger-ui" "13.6.8"
- "@react-native-community/cli-doctor" "13.6.8"
- "@react-native-community/cli-hermes" "13.6.8"
- "@react-native-community/cli-server-api" "13.6.8"
- "@react-native-community/cli-tools" "13.6.8"
- "@react-native-community/cli-types" "13.6.8"
+"@react-native-community/[email protected]":
+ version "13.6.9"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.9.tgz#ba6360b94e0aba9c4001bda256cf7e57e2ecb02c"
+ integrity sha512-hFJL4cgLPxncJJd/epQ4dHnMg5Jy/7Q56jFvA3MHViuKpzzfTCJCB+pGY54maZbtym53UJON9WTGpM3S81UfjQ==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.9"
+ "@react-native-community/cli-config" "13.6.9"
+ "@react-native-community/cli-debugger-ui" "13.6.9"
+ "@react-native-community/cli-doctor" "13.6.9"
+ "@react-native-community/cli-hermes" "13.6.9"
+ "@react-native-community/cli-server-api" "13.6.9"
+ "@react-native-community/cli-tools" "13.6.9"
+ "@react-native-community/cli-types" "13.6.9"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 7a4f219798c9a2..1697aa95ff4ed7 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
- "@react-native-community/cli-server-api": "13.6.8",
- "@react-native-community/cli-tools": "13.6.8",
+ "@react-native-community/cli-tools": "13.6.9",
"@react-native/dev-middleware": "0.74.84",
"@react-native/metro-babel-transformer": "0.74.84",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 1d1a0b15989ecd..aae8bc3f91dfb1 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.8",
- "@react-native-community/cli-platform-android": "13.6.8",
+ "@react-native-community/cli": "13.6.9",
+ "@react-native-community/cli-platform-android": "13.6.9",
+ "@react-native-community/cli-platform-ios": "13.6.9",
"@react-native/assets-registry": "0.74.84",
"@react-native/codegen": "0.74.84",
"@react-native/community-cli-plugin": "0.74.84",
diff --git a/yarn.lock b/yarn.lock
index c90cace18330ef..b4415f08c5af53 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474"
- integrity sha512-B1uxlm1N4BQuWFvBL3yRl3LVvydjswsdbTi7tMrHMtSxfRio1p9HjcmDzlzKco09Y+8qBGgakm3jcMZGLbhXQQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.9.tgz#b6754f39c2b877c9d730feb848945150e1d52209"
+ integrity sha512-7Dj5+4p9JggxuVNOjPbduZBAP1SUgNhLKVw5noBUzT/3ZpUZkDM+RCSwyoyg8xKWoE4OrdUAXwAFlMcFDPKykA==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.8.tgz#6829ea7cdc237776c300be06f84c222bf17cf4c5"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.9.tgz#d609a64d40a173c89bd7d24e31807bb7dcba69f9"
+ integrity sha512-rFfVBcNojcMm+KKHE/xqpqXg8HoKl4EC7bFHUrahMJ+y/tZll55+oX/PGG37rzB8QzP2UbMQ19DYQKC1G7kXeg==
cosmiconfig "^5.1.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.8.tgz#d52fccd4b3e0860d96d75ff5b0ebb128bdc93dfd"
- integrity sha512-2cS+MX/Su6sVSjqpDftFOXbK7EuPg98xzsPkdPhkQnkZwvXqodK9CAMuDMbx3lBHHtrPrpMbBCpFmPN8iVOnlA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.9.tgz#bc5727c51964206a00d417e5148b46331a81d5a5"
+ integrity sha512-TkN7IdFmGPPvTpAo3nCAH9uwGCPxWBEAwpqEZDrq0NWllI7Tdie8vDpGdrcuCcKalmhq6OYnkXzeBah7O1Ztpw==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.8.tgz#05f696d94e975e4dcf7f9a1fde32fb43e4bb8a5f"
- integrity sha512-/3Vdy9J3hyiu0y3nd/CU3kBqPlTRxnLXg7V6jrA1jbTOlZAMyV9imEkrqEaGK0SMOyMhh9Pipf98Ozhk0Nl4QA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.9.tgz#f1d4eeff427ddc8a9d19851042621c10939c35cb"
+ integrity sha512-5quFaLdWFQB+677GXh5dGU9I5eg2z6Vg4jOX9vKnc9IffwyIFAyJfCZHrxLSRPDGNXD7biDQUdoezXYGwb6P/A==
- "@react-native-community/cli-platform-ios" "13.6.8"
+ "@react-native-community/cli-platform-ios" "13.6.9"
command-exists "^1.2.8"
@@ -2436,54 +2436,54 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.8.tgz#85f10f663bc79f299146e749c48c06ebc4da9e29"
- integrity sha512-lZi/OBFuZUj5cLK94oEgtrtmxGoqeYVRcnHXl/R5c4put9PDl+qH2bEMlGZkFiw57ae3UZKr3TMk+1s4jh3FYQ==
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.9.tgz#88c8dfe936a0d4272efc54429eda9ccc3fca3ad8"
+ integrity sha512-GvwiwgvFw4Ws+krg2+gYj8sR3g05evmNjAHkKIKMkDTJjZ8EdyxbkifRUs1ZCq3TMZy2oeblZBXCJVOH4W7ZbA==
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.8.tgz#a3672512a9b844f93d6050537c59dd58e1b12f17"
- integrity sha512-vWrqeLRRTwp2kO33nbrAgbYn8HR2c2CpIfyVJY9Ckk7HGUSwDyxdcSu7YBvt2ShdfLZH0HctWFNXsgGrfg6BDw==
+"@react-native-community/[email protected]":
+ integrity sha512-9KsYGdr08QhdvT3Ht7e8phQB3gDX9Fs427NJe0xnoBh+PDPTI2BD5ks5ttsH8CzEw8/P6H8tJCHq6hf2nxd9cw==
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.8.tgz#4d46a2d6678a7b3264768f97393f082ed9afb264"
- integrity sha512-1JPohnlXPqU44zns3ALEzIbH2cKRw6JtEDJERgLuEUbs2r2NeJgqDbKyZ7fTTO8o+pegDnn6+Rr7qGVVOuUzzg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.9.tgz#02fb5dc47d62acd85f4d7a852e93216927a772fa"
+ integrity sha512-KoeIHfhxMhKXZPXmhQdl6EE+jGKWwoO9jUVWgBvibpVmsNjo7woaG/tfJMEWfWF3najX1EkQAoJWpCDBMYWtlA==
fast-xml-parser "^4.0.12"
ora "^5.4.1"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.8.tgz#2de1bd8529825781108c1cbba4f5b25cb062581c"
+"@react-native-community/[email protected]":
+ integrity sha512-CiUcHlGs8vE0CAB4oi1f+dzniqfGuhWPNrDvae2nm8dewlahTBwIcK5CawyGezjcJoeQhjBflh9vloska+nlnw==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63"
- integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg==
+"@react-native-community/[email protected]":
+ integrity sha512-W8FSlCPWymO+tlQfM3E0JmM8Oei5HZsIk5S0COOl0MRi8h0NmHI4WSTF2GCfbFZkcr2VI/fRsocoN8Au4EZAug==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2492,10 +2492,10 @@
ws "^6.2.2"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142"
- integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.9.tgz#2baee279358ba1a863e737b2fa9f45659ad91929"
+ integrity sha512-OXaSjoN0mZVw3nrAwcY1PC0uMfyTd9fz7Cy06dh+EJc+h0wikABsVRzV8cIOPrVV+PPEEXE0DBrH20T2puZzgQ==
appdirsjs "^1.2.4"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.9.tgz#08bfb796eacf0daeb31e2de516e81e78a36a1a55"
+ integrity sha512-RLxDppvRxXfs3hxceW/mShi+6o5yS+kFPnPqZTaMKKR5aSg7LwDpLQW4K2D22irEG8e6RKDkZUeH9aL3vO2O0w==
-"@react-native-community/[email protected]":
- integrity sha512-0lRdgLNaXixWY4BfFRl1J6Ao9Lapo2z+++iE7TD4GAbuxOWJSyFi+KUA8XNfSDyML4jFO02MZgyBPxAWdaminQ==
- dependencies:
- "@react-native-community/cli-doctor" "13.6.8"
- "@react-native-community/cli-hermes" "13.6.8"
- "@react-native-community/cli-server-api" "13.6.8"
- "@react-native-community/cli-types" "13.6.8"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.9.tgz#ba6360b94e0aba9c4001bda256cf7e57e2ecb02c"
+ integrity sha512-hFJL4cgLPxncJJd/epQ4dHnMg5Jy/7Q56jFvA3MHViuKpzzfTCJCB+pGY54maZbtym53UJON9WTGpM3S81UfjQ==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.9"
+ "@react-native-community/cli-doctor" "13.6.9"
+ "@react-native-community/cli-hermes" "13.6.9"
+ "@react-native-community/cli-types" "13.6.9"
commander "^9.4.1" | [
"+ \"@react-native-community/cli-server-api\": \"13.6.9\",",
"- \"@react-native-community/cli-platform-ios\": \"13.6.8\",",
"- integrity sha512-RabCkIsWdP4Ex/sf1uSP9qxc30utm+0uIJAjrZkNQynm7T4Lyqn/kT3LKm4yM6M0Qk61YxGguiaXF4601vAduw==",
"+\"@react-native-community/[email protected]\":",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.9.tgz#b175b9b11334fc90da3f395432678bd53c30fae4\"",
"-\"@react-native-community/[email protected]\":",
"-\"@react-native-community/[email protected]\":",
"- integrity sha512-/IIcIRM8qaoD7iZqsvtf6Qq1AwtChWYfB9sTn3mTiolZ5Zd5bXH37g+6liPfAICRkj2Ptq3iXmjrDVUQAxrOXw==",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.9.tgz#f37ceab41c2302e8f0d4bcbd3bf58b3353db4306\"",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.9.tgz#269e666bc26e9d0b2f42c7f6099559b5f9259e9d\"",
"- integrity sha512-C4mVByy0i+/NPuPhdMLBR7ubEVkjVS1VwoQu/BoG1crJFNE+167QXAzH01eFbXndsjZaMWmD4Gerx7TYc6lHfA==",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.8.tgz#d52c22620242e161bddcd2e0b6dbacd8743ca09b\"",
"- \"@react-native-community/cli-clean\" \"13.6.8\"",
"+ \"@react-native-community/cli-server-api\" \"13.6.9\""
] | [
10,
25,
58,
113,
131,
142,
159,
162,
165,
177,
209,
219,
222,
240
] | {
"additions": 76,
"author": "szymonrybczak",
"deletions": 76,
"html_url": "https://github.com/facebook/react-native/pull/44793",
"issue_id": 44793,
"merged_at": "2024-06-19T13:15:13Z",
"omission_probability": 0.1,
"pr_number": 44793,
"repo": "facebook/react-native",
"title": "feat: update CLI to 13.6.9",
"total_changes": 152
} |
535 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 4519eb32174359..dd652ef5f71953 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -23,8 +23,8 @@
],
"dependencies": {
"@react-native/dev-middleware": "0.73.8",
- "@react-native-community/cli-server-api": "12.3.6",
- "@react-native-community/cli-tools": "12.3.6",
+ "@react-native-community/cli-server-api": "12.3.7",
+ "@react-native-community/cli-tools": "12.3.7",
"@react-native/metro-babel-transformer": "0.73.15",
"chalk": "^4.0.0",
"execa": "^5.1.1",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index f4bb75fd387ddb..c8d731270756d5 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -93,9 +93,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "12.3.6",
- "@react-native-community/cli-platform-android": "12.3.6",
- "@react-native-community/cli-platform-ios": "12.3.6",
+ "@react-native-community/cli": "12.3.7",
+ "@react-native-community/cli-platform-android": "12.3.7",
+ "@react-native-community/cli-platform-ios": "12.3.7",
"@react-native/assets-registry": "0.73.1",
"@react-native/community-cli-plugin": "0.73.17",
"@react-native/codegen": "0.73.3",
diff --git a/yarn.lock b/yarn.lock
index a60ae476b6bca0..045ba7a249ae8e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2366,43 +2366,43 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.6.tgz#e8a7910bebc97266fd5068649013a03958021fc4"
- integrity sha512-gUU29ep8xM0BbnZjwz9MyID74KKwutq9x5iv4BCr2im6nly4UMf1B1D+V225wR7VcDGzbgWjaezsJShLLhC5ig==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.7.tgz#303ddf1c930918a8bdc4cc58fe0ac2dd05603cd5"
+ integrity sha512-BCYW77QqyxfhiMEBOoHyciJRNV6Rhz1RvclReIKnCA9wAwmoJBeu4Mu+AwiECA2bUITX16fvPt3NwDsSd1jwfQ==
dependencies:
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
execa "^5.0.0"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-12.3.6.tgz#5f0be68270217908a739c32e3155a0e354773251"
- integrity sha512-JGWSYQ9EAK6m2v0abXwFLEfsqJ1zkhzZ4CV261QZF9MoUNB6h57a274h1MLQR9mG6Tsh38wBUuNfEPUvS1vYew==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-12.3.7.tgz#feb8b93e8ccd6116ac1df0f1d8a0f06872388e51"
+ integrity sha512-IU2UhO9yj1rEBNhHWGzIXpPDzha4hizLP/PUOrhR4BUf6RVPUWEp+e1PXNGR0qjIf6esu7OC7t6mLOhH0NUJEw==
dependencies:
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
cosmiconfig "^5.1.0"
deepmerge "^4.3.0"
glob "^7.1.3"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-12.3.6.tgz#418027a1ae76850079684d309a732eb378c7f690"
- integrity sha512-SjUKKsx5FmcK9G6Pb6UBFT0s9JexVStK5WInmANw75Hm7YokVvHEgtprQDz2Uvy5znX5g2ujzrkIU//T15KQzA==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-12.3.7.tgz#522aa11c7b4ff4a2ec86492fabee0366d5428b4c"
+ integrity sha512-UHUFrRdcjWSCdWG9KIp2QjuRIahBQnb9epnQI7JCq6NFbFHYfEI4rI7msjMn+gG8/tSwKTV2PTPuPmZ5wWlE7Q==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-12.3.6.tgz#f68b51bbc6554ff4837269d98e9e405044e6f1b9"
- integrity sha512-fvBDv2lTthfw4WOQKkdTop2PlE9GtfrlNnpjB818MhcdEnPjfQw5YaTUcnNEGsvGomdCs1MVRMgYXXwPSN6OvQ==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-12.3.7.tgz#31e4784182d6bbfe62f2e728dca87ee23efe0564"
+ integrity sha512-gCamZztRoAyhciuQPqdz4Xe4t3gOdNsaADNd+rva+Rx8W2PoPeNv60i7/et06wlsn6B6Sh0/hMiAftJbiHDFkg==
dependencies:
- "@react-native-community/cli-config" "12.3.6"
- "@react-native-community/cli-platform-android" "12.3.6"
- "@react-native-community/cli-platform-ios" "12.3.6"
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-config" "12.3.7"
+ "@react-native-community/cli-platform-android" "12.3.7"
+ "@react-native-community/cli-platform-ios" "12.3.7"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -2416,52 +2416,52 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-12.3.6.tgz#5ac2c9ee26c69e1ce6b5047ba0f399984a6dea16"
- integrity sha512-sNGwfOCl8OAIjWCkwuLpP8NZbuO0dhDI/2W7NeOGDzIBsf4/c4MptTrULWtGIH9okVPLSPX0NnRyGQ+mSwWyuQ==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-12.3.7.tgz#4a284e0091469f6cce8caad2fefcf6b45c0cf229"
+ integrity sha512-ezzeiSKjRXK2+i1AAe7NhhN9CEHrgtRmTn2MAdBpE++N8fH5EQZgxFcGgGdwGvns2fm9ivyyeVnI5eAYwvM+jg==
dependencies:
- "@react-native-community/cli-platform-android" "12.3.6"
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-platform-android" "12.3.7"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-12.3.6.tgz#e1103692c659ff0b72ee6f00b7c72578db7376ec"
- integrity sha512-DeDDAB8lHpuGIAPXeeD9Qu2+/wDTFPo99c8uSW49L0hkmZJixzvvvffbGQAYk32H0TmaI7rzvzH+qzu7z3891g==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-12.3.7.tgz#4826f5126f950e29d7ef1ac779c4eed56d251f98"
+ integrity sha512-mOltF3cpjNdJb3WSFwEHc1GH4ibCcnOvQ34OdWyblKy9ijuvG5SjNTlYR/UW/CURaDi3OUKAhxQMTY5d27bzGQ==
dependencies:
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
execa "^5.0.0"
fast-xml-parser "^4.2.4"
glob "^7.1.3"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-12.3.6.tgz#e7decb5ee764f5fdc7a6ad1ba5e15de8929d54a5"
- integrity sha512-3eZ0jMCkKUO58wzPWlvAPRqezVKm9EPZyaPyHbRPWU8qw7JqkvnRlWIaYDGpjCJgVW4k2hKsEursLtYKb188tg==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-12.3.7.tgz#ef90e5c4d9ff5f15071b18179b17cf16699a70e5"
+ integrity sha512-2WnVsMH4ORZIhBm/5nCms1NeeKG4KarNC7PMLmrXWXB/bibDcaNsjrJiqnmCUcpTEvTQTokRfoO7Aj6NM0Cqow==
dependencies:
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-tools" "12.3.7"
chalk "^4.1.2"
execa "^5.0.0"
fast-xml-parser "^4.0.12"
glob "^7.1.3"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-plugin-metro/-/cli-plugin-metro-12.3.6.tgz#ae62de18e998478db60a3fe10dc746162c272dbd"
- integrity sha512-3jxSBQt4fkS+KtHCPSyB5auIT+KKIrPCv9Dk14FbvOaEh9erUWEm/5PZWmtboW1z7CYeNbFMeXm9fM2xwtVOpg==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-plugin-metro/-/cli-plugin-metro-12.3.7.tgz#f9be724721a52d800a20f641a2241a7b4e6a9477"
+ integrity sha512-ahEw0Vfnv2Nv/jdZ2QDuGjQ9l2SczO4lXjb3ubu5vEYNLyTw3jYsLMK6iES7YQ/ApQmKdG476HU1O9uZdpaYPg==
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-12.3.6.tgz#cd78122954a02d22c7821c365938635b51ddd1bd"
- integrity sha512-80NIMzo8b2W+PL0Jd7NjiJW9mgaT8Y8wsIT/lh6mAvYH7mK0ecDJUYUTAAv79Tbo1iCGPAr3T295DlVtS8s4yQ==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-12.3.7.tgz#81e2a067c120391242740598010abb8d5d36a739"
+ integrity sha512-LYETs3CCjrLn1ZU0kYv44TywiIl5IPFHZGeXhAh2TtgOk4mo3kvXxECDil9CdO3bmDra6qyiG61KHvzr8IrHdg==
dependencies:
- "@react-native-community/cli-debugger-ui" "12.3.6"
- "@react-native-community/cli-tools" "12.3.6"
+ "@react-native-community/cli-debugger-ui" "12.3.7"
+ "@react-native-community/cli-tools" "12.3.7"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2470,10 +2470,10 @@
serve-static "^1.13.1"
ws "^7.5.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-12.3.6.tgz#c39965982347635dfaf1daa7b3c0133b3bd45e64"
- integrity sha512-FPEvZn19UTMMXUp/piwKZSh8cMEfO8G3KDtOwo53O347GTcwNrKjgZGtLSPELBX2gr+YlzEft3CoRv2Qmo83fQ==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-12.3.7.tgz#65cf1c81d13662a1b0396c753e6ff916e3e92083"
+ integrity sha512-7NL/1/i+wzd4fBr/FSr3ypR05tiU/Kv9l/M1sL1c6jfcDtWXAL90R161gQkQFK7shIQ8Idp0dQX1rq49tSyfQw==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
@@ -2486,27 +2486,27 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-12.3.6.tgz#239de348800fe1ffba3eb1fe0edbeb9306981e57"
- integrity sha512-xPqTgcUtZowQ8WKOkI9TLGBwH2bGggOC4d2FFaIRST3gTcjrEeGRNeR5aXCzJFIgItIft8sd7p2oKEdy90+01Q==
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-12.3.7.tgz#6f55becdc41bb5ebf1a8f6fd27ad0d198831169d"
+ integrity sha512-NFtUMyIrNfi3A5C1cjVKDVvYHvvOF7MnOMwdD8jm2NQKewQJrehKBh1eMuykKdqhWyZmuemD4KKhL8f4FxgG0w==
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "12.3.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-12.3.6.tgz#7a323b78725b959bb8a31cca1145918263ff3c8d"
- integrity sha512-647OSi6xBb8FbwFqX9zsJxOzu685AWtrOUWHfOkbKD+5LOpGORw+GQo0F9rWZnB68rLQyfKUZWJeaD00pGv5fw==
- dependencies:
- "@react-native-community/cli-clean" "12.3.6"
- "@react-native-community/cli-config" "12.3.6"
- "@react-native-community/cli-debugger-ui" "12.3.6"
- "@react-native-community/cli-doctor" "12.3.6"
- "@react-native-community/cli-hermes" "12.3.6"
- "@react-native-community/cli-plugin-metro" "12.3.6"
- "@react-native-community/cli-server-api" "12.3.6"
- "@react-native-community/cli-tools" "12.3.6"
- "@react-native-community/cli-types" "12.3.6"
+"@react-native-community/[email protected]":
+ version "12.3.7"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-12.3.7.tgz#8f53ec9310367a0204d859005e9cd137f9888382"
+ integrity sha512-7+mOhk+3+X3BjSJZZvYrDJynA00gPYTlvT28ZjiLlbuVGfqfNiBKaxuF7rty+gjjpch4iKGvLhIhSN5cuOsdHQ==
+ dependencies:
+ "@react-native-community/cli-clean" "12.3.7"
+ "@react-native-community/cli-config" "12.3.7"
+ "@react-native-community/cli-debugger-ui" "12.3.7"
+ "@react-native-community/cli-doctor" "12.3.7"
+ "@react-native-community/cli-hermes" "12.3.7"
+ "@react-native-community/cli-plugin-metro" "12.3.7"
+ "@react-native-community/cli-server-api" "12.3.7"
+ "@react-native-community/cli-tools" "12.3.7"
+ "@react-native-community/cli-types" "12.3.7"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 4519eb32174359..dd652ef5f71953 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -23,8 +23,8 @@
],
"@react-native/dev-middleware": "0.73.8",
- "@react-native-community/cli-server-api": "12.3.6",
- "@react-native-community/cli-tools": "12.3.6",
+ "@react-native-community/cli-server-api": "12.3.7",
+ "@react-native-community/cli-tools": "12.3.7",
"@react-native/metro-babel-transformer": "0.73.15",
"chalk": "^4.0.0",
"execa": "^5.1.1",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index f4bb75fd387ddb..c8d731270756d5 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -93,9 +93,9 @@
},
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "12.3.6",
- "@react-native-community/cli-platform-android": "12.3.6",
- "@react-native-community/cli-platform-ios": "12.3.6",
+ "@react-native-community/cli-platform-ios": "12.3.7",
"@react-native/assets-registry": "0.73.1",
"@react-native/community-cli-plugin": "0.73.17",
"@react-native/codegen": "0.73.3",
diff --git a/yarn.lock b/yarn.lock
index a60ae476b6bca0..045ba7a249ae8e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2366,43 +2366,43 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.6.tgz#e8a7910bebc97266fd5068649013a03958021fc4"
- integrity sha512-gUU29ep8xM0BbnZjwz9MyID74KKwutq9x5iv4BCr2im6nly4UMf1B1D+V225wR7VcDGzbgWjaezsJShLLhC5ig==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.7.tgz#303ddf1c930918a8bdc4cc58fe0ac2dd05603cd5"
+ integrity sha512-BCYW77QqyxfhiMEBOoHyciJRNV6Rhz1RvclReIKnCA9wAwmoJBeu4Mu+AwiECA2bUITX16fvPt3NwDsSd1jwfQ==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-12.3.6.tgz#5f0be68270217908a739c32e3155a0e354773251"
- integrity sha512-JGWSYQ9EAK6m2v0abXwFLEfsqJ1zkhzZ4CV261QZF9MoUNB6h57a274h1MLQR9mG6Tsh38wBUuNfEPUvS1vYew==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-12.3.7.tgz#feb8b93e8ccd6116ac1df0f1d8a0f06872388e51"
cosmiconfig "^5.1.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-12.3.6.tgz#418027a1ae76850079684d309a732eb378c7f690"
- integrity sha512-SjUKKsx5FmcK9G6Pb6UBFT0s9JexVStK5WInmANw75Hm7YokVvHEgtprQDz2Uvy5znX5g2ujzrkIU//T15KQzA==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-12.3.7.tgz#522aa11c7b4ff4a2ec86492fabee0366d5428b4c"
+ integrity sha512-UHUFrRdcjWSCdWG9KIp2QjuRIahBQnb9epnQI7JCq6NFbFHYfEI4rI7msjMn+gG8/tSwKTV2PTPuPmZ5wWlE7Q==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-12.3.6.tgz#f68b51bbc6554ff4837269d98e9e405044e6f1b9"
- integrity sha512-fvBDv2lTthfw4WOQKkdTop2PlE9GtfrlNnpjB818MhcdEnPjfQw5YaTUcnNEGsvGomdCs1MVRMgYXXwPSN6OvQ==
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-12.3.7.tgz#31e4784182d6bbfe62f2e728dca87ee23efe0564"
+ integrity sha512-gCamZztRoAyhciuQPqdz4Xe4t3gOdNsaADNd+rva+Rx8W2PoPeNv60i7/et06wlsn6B6Sh0/hMiAftJbiHDFkg==
- "@react-native-community/cli-platform-ios" "12.3.6"
+ "@react-native-community/cli-platform-ios" "12.3.7"
command-exists "^1.2.8"
@@ -2416,52 +2416,52 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-12.3.6.tgz#5ac2c9ee26c69e1ce6b5047ba0f399984a6dea16"
- integrity sha512-sNGwfOCl8OAIjWCkwuLpP8NZbuO0dhDI/2W7NeOGDzIBsf4/c4MptTrULWtGIH9okVPLSPX0NnRyGQ+mSwWyuQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-12.3.7.tgz#4a284e0091469f6cce8caad2fefcf6b45c0cf229"
+ integrity sha512-ezzeiSKjRXK2+i1AAe7NhhN9CEHrgtRmTn2MAdBpE++N8fH5EQZgxFcGgGdwGvns2fm9ivyyeVnI5eAYwvM+jg==
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-12.3.6.tgz#e1103692c659ff0b72ee6f00b7c72578db7376ec"
- integrity sha512-DeDDAB8lHpuGIAPXeeD9Qu2+/wDTFPo99c8uSW49L0hkmZJixzvvvffbGQAYk32H0TmaI7rzvzH+qzu7z3891g==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-12.3.7.tgz#4826f5126f950e29d7ef1ac779c4eed56d251f98"
+ integrity sha512-mOltF3cpjNdJb3WSFwEHc1GH4ibCcnOvQ34OdWyblKy9ijuvG5SjNTlYR/UW/CURaDi3OUKAhxQMTY5d27bzGQ==
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-12.3.6.tgz#e7decb5ee764f5fdc7a6ad1ba5e15de8929d54a5"
- integrity sha512-3eZ0jMCkKUO58wzPWlvAPRqezVKm9EPZyaPyHbRPWU8qw7JqkvnRlWIaYDGpjCJgVW4k2hKsEursLtYKb188tg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-12.3.7.tgz#ef90e5c4d9ff5f15071b18179b17cf16699a70e5"
+ integrity sha512-2WnVsMH4ORZIhBm/5nCms1NeeKG4KarNC7PMLmrXWXB/bibDcaNsjrJiqnmCUcpTEvTQTokRfoO7Aj6NM0Cqow==
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-plugin-metro/-/cli-plugin-metro-12.3.6.tgz#ae62de18e998478db60a3fe10dc746162c272dbd"
- integrity sha512-3jxSBQt4fkS+KtHCPSyB5auIT+KKIrPCv9Dk14FbvOaEh9erUWEm/5PZWmtboW1z7CYeNbFMeXm9fM2xwtVOpg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-plugin-metro/-/cli-plugin-metro-12.3.7.tgz#f9be724721a52d800a20f641a2241a7b4e6a9477"
+ integrity sha512-ahEw0Vfnv2Nv/jdZ2QDuGjQ9l2SczO4lXjb3ubu5vEYNLyTw3jYsLMK6iES7YQ/ApQmKdG476HU1O9uZdpaYPg==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-12.3.6.tgz#cd78122954a02d22c7821c365938635b51ddd1bd"
- integrity sha512-80NIMzo8b2W+PL0Jd7NjiJW9mgaT8Y8wsIT/lh6mAvYH7mK0ecDJUYUTAAv79Tbo1iCGPAr3T295DlVtS8s4yQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-12.3.7.tgz#81e2a067c120391242740598010abb8d5d36a739"
+ integrity sha512-LYETs3CCjrLn1ZU0kYv44TywiIl5IPFHZGeXhAh2TtgOk4mo3kvXxECDil9CdO3bmDra6qyiG61KHvzr8IrHdg==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2470,10 +2470,10 @@
ws "^7.5.1"
-"@react-native-community/[email protected]":
- integrity sha512-FPEvZn19UTMMXUp/piwKZSh8cMEfO8G3KDtOwo53O347GTcwNrKjgZGtLSPELBX2gr+YlzEft3CoRv2Qmo83fQ==
+"@react-native-community/[email protected]":
+ integrity sha512-7NL/1/i+wzd4fBr/FSr3ypR05tiU/Kv9l/M1sL1c6jfcDtWXAL90R161gQkQFK7shIQ8Idp0dQX1rq49tSyfQw==
appdirsjs "^1.2.4"
@@ -2486,27 +2486,27 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-12.3.6.tgz#239de348800fe1ffba3eb1fe0edbeb9306981e57"
- integrity sha512-xPqTgcUtZowQ8WKOkI9TLGBwH2bGggOC4d2FFaIRST3gTcjrEeGRNeR5aXCzJFIgItIft8sd7p2oKEdy90+01Q==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-12.3.7.tgz#6f55becdc41bb5ebf1a8f6fd27ad0d198831169d"
+ integrity sha512-NFtUMyIrNfi3A5C1cjVKDVvYHvvOF7MnOMwdD8jm2NQKewQJrehKBh1eMuykKdqhWyZmuemD4KKhL8f4FxgG0w==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-12.3.6.tgz#7a323b78725b959bb8a31cca1145918263ff3c8d"
- dependencies:
- "@react-native-community/cli-clean" "12.3.6"
- "@react-native-community/cli-doctor" "12.3.6"
- "@react-native-community/cli-hermes" "12.3.6"
- "@react-native-community/cli-plugin-metro" "12.3.6"
- "@react-native-community/cli-server-api" "12.3.6"
- "@react-native-community/cli-types" "12.3.6"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-12.3.7.tgz#8f53ec9310367a0204d859005e9cd137f9888382"
+ integrity sha512-7+mOhk+3+X3BjSJZZvYrDJynA00gPYTlvT28ZjiLlbuVGfqfNiBKaxuF7rty+gjjpch4iKGvLhIhSN5cuOsdHQ==
+ dependencies:
+ "@react-native-community/cli-clean" "12.3.7"
+ "@react-native-community/cli-doctor" "12.3.7"
+ "@react-native-community/cli-hermes" "12.3.7"
+ "@react-native-community/cli-plugin-metro" "12.3.7"
+ "@react-native-community/cli-server-api" "12.3.7"
+ "@react-native-community/cli-types" "12.3.7"
commander "^9.4.1" | [
"+ \"@react-native-community/cli\": \"12.3.7\",",
"+ \"@react-native-community/cli-platform-android\": \"12.3.7\",",
"+ integrity sha512-IU2UhO9yj1rEBNhHWGzIXpPDzha4hizLP/PUOrhR4BUf6RVPUWEp+e1PXNGR0qjIf6esu7OC7t6mLOhH0NUJEw==",
"+\"@react-native-community/[email protected]\":",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-12.3.6.tgz#c39965982347635dfaf1daa7b3c0133b3bd45e64\"",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-12.3.7.tgz#65cf1c81d13662a1b0396c753e6ff916e3e92083\"",
"-\"@react-native-community/[email protected]\":",
"- integrity sha512-647OSi6xBb8FbwFqX9zsJxOzu685AWtrOUWHfOkbKD+5LOpGORw+GQo0F9rWZnB68rLQyfKUZWJeaD00pGv5fw=="
] | [
26,
27,
61,
86,
187,
191,
200,
214
] | {
"additions": 75,
"author": "szymonrybczak",
"deletions": 75,
"html_url": "https://github.com/facebook/react-native/pull/44794",
"issue_id": 44794,
"merged_at": "2024-06-19T13:14:59Z",
"omission_probability": 0.1,
"pr_number": 44794,
"repo": "facebook/react-native",
"title": "feat: update CLI to 12.3.7",
"total_changes": 150
} |
536 | diff --git a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
index 2ad587963337f0..8a8f96bc8b144a 100644
--- a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
+++ b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
@@ -12,6 +12,7 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
+ 6132EF182BDFF13200BBE14D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */; };
7699B88040F8A987B510C191 /* libPods-HelloWorld-HelloWorldTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-HelloWorld-HelloWorldTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
@@ -41,6 +42,7 @@
5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.release.xcconfig"; sourceTree = "<group>"; };
5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -116,6 +118,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
+ 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */,
13B07FAE1A68108700A75B9A /* HelloWorld */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* HelloWorldTests */,
@@ -242,6 +245,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 6132EF182BDFF13200BBE14D /* PrivacyInfo.xcprivacy in Resources */,
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
);
diff --git a/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy
new file mode 100644
index 00000000000000..ef1896e70c88da
--- /dev/null
+++ b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrivacyCollectedDataTypes</key>
+ <array>
+ </array>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <array>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>C617.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>CA92.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>35F9.1</string>
+ </array>
+ </dict>
+ </array>
+ <key>NSPrivacyTracking</key>
+ <false/>
+</dict>
+</plist>
| diff --git a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
index 2ad587963337f0..8a8f96bc8b144a 100644
--- a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
+++ b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj
@@ -12,6 +12,7 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
+ 6132EF182BDFF13200BBE14D /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */; };
7699B88040F8A987B510C191 /* libPods-HelloWorld-HelloWorldTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-HelloWorld-HelloWorldTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */
@@ -41,6 +42,7 @@
5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.release.xcconfig"; sourceTree = "<group>"; };
5B7EB9410499542E8C5724F5 /* Pods-HelloWorld-HelloWorldTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -116,6 +118,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
+ 6132EF172BDFF13200BBE14D /* PrivacyInfo.xcprivacy */,
13B07FAE1A68108700A75B9A /* HelloWorld */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* HelloWorldTests */,
@@ -242,6 +245,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 6132EF182BDFF13200BBE14D /* PrivacyInfo.xcprivacy in Resources */,
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
);
diff --git a/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy
new file mode 100644
index 00000000000000..ef1896e70c88da
--- /dev/null
+++ b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrivacyCollectedDataTypes</key>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <string>C617.1</string>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <string>CA92.1</string>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <string>35F9.1</string>
+ <key>NSPrivacyTracking</key>
+ <false/>
+</dict>
+</plist> | [] | [] | {
"additions": 42,
"author": "hurali97",
"deletions": 0,
"html_url": "https://github.com/facebook/react-native/pull/44317",
"issue_id": 44317,
"merged_at": "2024-04-29T15:25:55Z",
"omission_probability": 0.1,
"pr_number": 44317,
"repo": "facebook/react-native",
"title": "add privacy manifest to hello world template",
"total_changes": 42
} |
537 | diff --git a/package.json b/package.json
index ac636ec82e7843..a9d5f19dc93d1c 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
"@react-native/metro-config": "0.74.83",
"@tsconfig/node18": "1.0.1",
"@types/react": "^18.2.6",
- "@typescript-eslint/parser": "^6.7.4",
+ "@typescript-eslint/parser": "^7.1.1",
"ansi-styles": "^4.2.1",
"async": "^3.2.2",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
@@ -77,7 +77,7 @@
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-ft-flow": "^2.0.1",
- "eslint-plugin-jest": "^26.5.3",
+ "eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-lint": "^1.0.0",
"eslint-plugin-prettier": "^4.2.1",
diff --git a/packages/eslint-config-react-native/package.json b/packages/eslint-config-react-native/package.json
index d99d257ef7e6e3..139658f767539e 100644
--- a/packages/eslint-config-react-native/package.json
+++ b/packages/eslint-config-react-native/package.json
@@ -23,12 +23,12 @@
"@babel/core": "^7.20.0",
"@babel/eslint-parser": "^7.20.0",
"@react-native/eslint-plugin": "0.74.83",
- "@typescript-eslint/eslint-plugin": "^6.7.4",
- "@typescript-eslint/parser": "^6.7.4",
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
+ "@typescript-eslint/parser": "^7.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-ft-flow": "^2.0.1",
- "eslint-plugin-jest": "^26.5.3",
+ "eslint-plugin-jest": "^27.9.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
diff --git a/yarn.lock b/yarn.lock
index c48cc70f458293..c90cace18330ef 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2876,16 +2876,16 @@
semver "^7.3.7"
tsutils "^3.21.0"
-"@typescript-eslint/eslint-plugin@^6.7.4":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz#057338df21b6062c2f2fc5999fbea8af9973ac6d"
- integrity sha512-DAbgDXwtX+pDkAHwiGhqP3zWUGpW49B7eqmgpPtg+BKJXwdct79ut9+ifqOFPJGClGKSHXn2PTBatCnldJRUoA==
+"@typescript-eslint/eslint-plugin@^7.1.1":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.1.1.tgz#dd71fc5c7ecec745ca26ece506d84d203a205c0e"
+ integrity sha512-zioDz623d0RHNhvx0eesUmGfIjzrk18nSBC8xewepKXbBvN/7c1qImV7Hg8TI1URTxKax7/zxfxj3Uph8Chcuw==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
- "@typescript-eslint/scope-manager" "6.7.4"
- "@typescript-eslint/type-utils" "6.7.4"
- "@typescript-eslint/utils" "6.7.4"
- "@typescript-eslint/visitor-keys" "6.7.4"
+ "@typescript-eslint/scope-manager" "7.1.1"
+ "@typescript-eslint/type-utils" "7.1.1"
+ "@typescript-eslint/utils" "7.1.1"
+ "@typescript-eslint/visitor-keys" "7.1.1"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
@@ -2903,15 +2903,15 @@
"@typescript-eslint/typescript-estree" "5.59.5"
debug "^4.3.4"
-"@typescript-eslint/parser@^6.7.4":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.7.4.tgz#23d1dd4fe5d295c7fa2ab651f5406cd9ad0bd435"
- integrity sha512-I5zVZFY+cw4IMZUeNCU7Sh2PO5O57F7Lr0uyhgCJmhN/BuTlnc55KxPonR4+EM3GBdfiCyGZye6DgMjtubQkmA==
+"@typescript-eslint/parser@^7.1.1":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.1.1.tgz#6a9d0a5c9ccdf5dbd3cb8c949728c64e24e07d1f"
+ integrity sha512-ZWUFyL0z04R1nAEgr9e79YtV5LbafdOtN7yapNbn1ansMyaegl2D4bL7vHoJ4HPSc4CaLwuCVas8CVuneKzplQ==
dependencies:
- "@typescript-eslint/scope-manager" "6.7.4"
- "@typescript-eslint/types" "6.7.4"
- "@typescript-eslint/typescript-estree" "6.7.4"
- "@typescript-eslint/visitor-keys" "6.7.4"
+ "@typescript-eslint/scope-manager" "7.1.1"
+ "@typescript-eslint/types" "7.1.1"
+ "@typescript-eslint/typescript-estree" "7.1.1"
+ "@typescript-eslint/visitor-keys" "7.1.1"
debug "^4.3.4"
"@typescript-eslint/[email protected]":
@@ -2922,13 +2922,13 @@
"@typescript-eslint/types" "5.59.5"
"@typescript-eslint/visitor-keys" "5.59.5"
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.7.4.tgz#a484a17aa219e96044db40813429eb7214d7b386"
- integrity sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.1.1.tgz#9e301803ff8e21a74f50c6f89a4baccad9a48f93"
+ integrity sha512-cirZpA8bJMRb4WZ+rO6+mnOJrGFDd38WoXCEI57+CYBqta8Yc8aJym2i7vyqLL1vVYljgw0X27axkUXz32T8TA==
dependencies:
- "@typescript-eslint/types" "6.7.4"
- "@typescript-eslint/visitor-keys" "6.7.4"
+ "@typescript-eslint/types" "7.1.1"
+ "@typescript-eslint/visitor-keys" "7.1.1"
"@typescript-eslint/[email protected]":
version "5.59.5"
@@ -2940,13 +2940,13 @@
debug "^4.3.4"
tsutils "^3.21.0"
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.7.4.tgz#847cd3b59baf948984499be3e0a12ff07373e321"
- integrity sha512-n+g3zi1QzpcAdHFP9KQF+rEFxMb2KxtnJGID3teA/nxKHOVi3ylKovaqEzGBbVY2pBttU6z85gp0D00ufLzViQ==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.1.1.tgz#aee820d5bedd39b83c18585a526cc520ddb7a226"
+ integrity sha512-5r4RKze6XHEEhlZnJtR3GYeCh1IueUHdbrukV2KSlLXaTjuSfeVF8mZUVPLovidCuZfbVjfhi4c0DNSa/Rdg5g==
dependencies:
- "@typescript-eslint/typescript-estree" "6.7.4"
- "@typescript-eslint/utils" "6.7.4"
+ "@typescript-eslint/typescript-estree" "7.1.1"
+ "@typescript-eslint/utils" "7.1.1"
debug "^4.3.4"
ts-api-utils "^1.0.1"
@@ -2960,10 +2960,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.7.4.tgz#5d358484d2be986980c039de68e9f1eb62ea7897"
- integrity sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.1.1.tgz#ca33ba7cf58224fb46a84fea62593c2c53cd795f"
+ integrity sha512-KhewzrlRMrgeKm1U9bh2z5aoL4s7K3tK5DwHDn8MHv0yQfWFz/0ZR6trrIHHa5CsF83j/GgHqzdbzCXJ3crx0Q==
"@typescript-eslint/[email protected]":
version "5.59.5"
@@ -2978,16 +2978,17 @@
semver "^7.3.7"
tsutils "^3.21.0"
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.4.tgz#f2baece09f7bb1df9296e32638b2e1130014ef1a"
- integrity sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.1.1.tgz#09c54af0151a1b05d0875c0fc7fe2ec7a2476ece"
+ integrity sha512-9ZOncVSfr+sMXVxxca2OJOPagRwT0u/UHikM2Rd6L/aB+kL/QAuTnsv6MeXtjzCJYb8PzrXarypSGIPx3Jemxw==
dependencies:
- "@typescript-eslint/types" "6.7.4"
- "@typescript-eslint/visitor-keys" "6.7.4"
+ "@typescript-eslint/types" "7.1.1"
+ "@typescript-eslint/visitor-keys" "7.1.1"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
+ minimatch "9.0.3"
semver "^7.5.4"
ts-api-utils "^1.0.1"
@@ -3005,17 +3006,17 @@
eslint-scope "^5.1.1"
semver "^7.3.7"
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.7.4.tgz#2236f72b10e38277ee05ef06142522e1de470ff2"
- integrity sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.1.1.tgz#bdeeb789eee4af5d3fb5400a69566d4dbf97ff3b"
+ integrity sha512-thOXM89xA03xAE0lW7alstvnyoBUbBX38YtY+zAUcpRPcq9EIhXPuJ0YTv948MbzmKh6e1AUszn5cBFK49Umqg==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
- "@typescript-eslint/scope-manager" "6.7.4"
- "@typescript-eslint/types" "6.7.4"
- "@typescript-eslint/typescript-estree" "6.7.4"
+ "@typescript-eslint/scope-manager" "7.1.1"
+ "@typescript-eslint/types" "7.1.1"
+ "@typescript-eslint/typescript-estree" "7.1.1"
semver "^7.5.4"
"@typescript-eslint/[email protected]":
@@ -3026,12 +3027,12 @@
"@typescript-eslint/types" "5.59.5"
eslint-visitor-keys "^3.3.0"
-"@typescript-eslint/[email protected]":
- version "6.7.4"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.4.tgz#80dfecf820fc67574012375859085f91a4dff043"
- integrity sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA==
+"@typescript-eslint/[email protected]":
+ version "7.1.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.1.1.tgz#e6538a58c9b157f03bcbb29e3b6a92fe39a6ab0d"
+ integrity sha512-yTdHDQxY7cSoCcAtiBzVzxleJhkGB9NncSIyMYe2+OGON1ZsP9zOPws/Pqgopa65jvknOjlk/w7ulPlZ78PiLQ==
dependencies:
- "@typescript-eslint/types" "6.7.4"
+ "@typescript-eslint/types" "7.1.1"
eslint-visitor-keys "^3.4.1"
"@typescript-eslint/visitor-keys@^5.42.0":
@@ -4605,10 +4606,10 @@ eslint-plugin-ft-flow@^2.0.1:
lodash "^4.17.21"
string-natural-compare "^3.0.1"
-eslint-plugin-jest@^26.5.3:
- version "26.5.3"
- resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.5.3.tgz#a3ceeaf4a757878342b8b00eca92379b246e5505"
- integrity sha512-sICclUqJQnR1bFRZGLN2jnSVsYOsmPYYnroGCIMVSvTS3y8XR3yjzy1EcTQmk6typ5pRgyIWzbjqxK6cZHEZuQ==
+eslint-plugin-jest@^27.9.0:
+ version "27.9.0"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz#7c98a33605e1d8b8442ace092b60e9919730000b"
+ integrity sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==
dependencies:
"@typescript-eslint/utils" "^5.10.0"
@@ -7303,6 +7304,13 @@ mimic-response@^3.1.0:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==
[email protected]:
+ version "9.0.3"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825"
+ integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
| diff --git a/package.json b/package.json
index ac636ec82e7843..a9d5f19dc93d1c 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
"@react-native/metro-config": "0.74.83",
"@tsconfig/node18": "1.0.1",
"@types/react": "^18.2.6",
"ansi-styles": "^4.2.1",
"async": "^3.2.2",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
@@ -77,7 +77,7 @@
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-lint": "^1.0.0",
diff --git a/packages/eslint-config-react-native/package.json b/packages/eslint-config-react-native/package.json
index d99d257ef7e6e3..139658f767539e 100644
--- a/packages/eslint-config-react-native/package.json
+++ b/packages/eslint-config-react-native/package.json
@@ -23,12 +23,12 @@
"@babel/core": "^7.20.0",
"@babel/eslint-parser": "^7.20.0",
"@react-native/eslint-plugin": "0.74.83",
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
diff --git a/yarn.lock b/yarn.lock
index c48cc70f458293..c90cace18330ef 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2876,16 +2876,16 @@
-"@typescript-eslint/eslint-plugin@^6.7.4":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz#057338df21b6062c2f2fc5999fbea8af9973ac6d"
- integrity sha512-DAbgDXwtX+pDkAHwiGhqP3zWUGpW49B7eqmgpPtg+BKJXwdct79ut9+ifqOFPJGClGKSHXn2PTBatCnldJRUoA==
+"@typescript-eslint/eslint-plugin@^7.1.1":
+ integrity sha512-zioDz623d0RHNhvx0eesUmGfIjzrk18nSBC8xewepKXbBvN/7c1qImV7Hg8TI1URTxKax7/zxfxj3Uph8Chcuw==
"@eslint-community/regexpp" "^4.5.1"
+ "@typescript-eslint/type-utils" "7.1.1"
graphemer "^1.4.0"
ignore "^5.2.4"
@@ -2903,15 +2903,15 @@
"@typescript-eslint/typescript-estree" "5.59.5"
-"@typescript-eslint/parser@^6.7.4":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.7.4.tgz#23d1dd4fe5d295c7fa2ab651f5406cd9ad0bd435"
- integrity sha512-I5zVZFY+cw4IMZUeNCU7Sh2PO5O57F7Lr0uyhgCJmhN/BuTlnc55KxPonR4+EM3GBdfiCyGZye6DgMjtubQkmA==
+"@typescript-eslint/parser@^7.1.1":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-7.1.1.tgz#6a9d0a5c9ccdf5dbd3cb8c949728c64e24e07d1f"
+ integrity sha512-ZWUFyL0z04R1nAEgr9e79YtV5LbafdOtN7yapNbn1ansMyaegl2D4bL7vHoJ4HPSc4CaLwuCVas8CVuneKzplQ==
"@typescript-eslint/[email protected]":
@@ -2922,13 +2922,13 @@
"@typescript-eslint/visitor-keys" "5.59.5"
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.7.4.tgz#a484a17aa219e96044db40813429eb7214d7b386"
- integrity sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-7.1.1.tgz#9e301803ff8e21a74f50c6f89a4baccad9a48f93"
+ integrity sha512-cirZpA8bJMRb4WZ+rO6+mnOJrGFDd38WoXCEI57+CYBqta8Yc8aJym2i7vyqLL1vVYljgw0X27axkUXz32T8TA==
"@typescript-eslint/[email protected]":
@@ -2940,13 +2940,13 @@
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.7.4.tgz#847cd3b59baf948984499be3e0a12ff07373e321"
- integrity sha512-n+g3zi1QzpcAdHFP9KQF+rEFxMb2KxtnJGID3teA/nxKHOVi3ylKovaqEzGBbVY2pBttU6z85gp0D00ufLzViQ==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-7.1.1.tgz#aee820d5bedd39b83c18585a526cc520ddb7a226"
+ integrity sha512-5r4RKze6XHEEhlZnJtR3GYeCh1IueUHdbrukV2KSlLXaTjuSfeVF8mZUVPLovidCuZfbVjfhi4c0DNSa/Rdg5g==
@@ -2960,10 +2960,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f"
integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.7.4.tgz#5d358484d2be986980c039de68e9f1eb62ea7897"
- integrity sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.1.1.tgz#ca33ba7cf58224fb46a84fea62593c2c53cd795f"
+ integrity sha512-KhewzrlRMrgeKm1U9bh2z5aoL4s7K3tK5DwHDn8MHv0yQfWFz/0ZR6trrIHHa5CsF83j/GgHqzdbzCXJ3crx0Q==
"@typescript-eslint/[email protected]":
@@ -2978,16 +2978,17 @@
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.4.tgz#f2baece09f7bb1df9296e32638b2e1130014ef1a"
- integrity sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-7.1.1.tgz#09c54af0151a1b05d0875c0fc7fe2ec7a2476ece"
+ integrity sha512-9ZOncVSfr+sMXVxxca2OJOPagRwT0u/UHikM2Rd6L/aB+kL/QAuTnsv6MeXtjzCJYb8PzrXarypSGIPx3Jemxw==
globby "^11.1.0"
is-glob "^4.0.3"
+ minimatch "9.0.3"
@@ -3005,17 +3006,17 @@
eslint-scope "^5.1.1"
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.7.4.tgz#2236f72b10e38277ee05ef06142522e1de470ff2"
- integrity sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-7.1.1.tgz#bdeeb789eee4af5d3fb5400a69566d4dbf97ff3b"
+ integrity sha512-thOXM89xA03xAE0lW7alstvnyoBUbBX38YtY+zAUcpRPcq9EIhXPuJ0YTv948MbzmKh6e1AUszn5cBFK49Umqg==
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/[email protected]":
@@ -3026,12 +3027,12 @@
eslint-visitor-keys "^3.3.0"
-"@typescript-eslint/[email protected]":
- resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.4.tgz#80dfecf820fc67574012375859085f91a4dff043"
- integrity sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA==
+"@typescript-eslint/[email protected]":
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-7.1.1.tgz#e6538a58c9b157f03bcbb29e3b6a92fe39a6ab0d"
+ integrity sha512-yTdHDQxY7cSoCcAtiBzVzxleJhkGB9NncSIyMYe2+OGON1ZsP9zOPws/Pqgopa65jvknOjlk/w7ulPlZ78PiLQ==
eslint-visitor-keys "^3.4.1"
"@typescript-eslint/visitor-keys@^5.42.0":
@@ -4605,10 +4606,10 @@ eslint-plugin-ft-flow@^2.0.1:
lodash "^4.17.21"
string-natural-compare "^3.0.1"
-eslint-plugin-jest@^26.5.3:
- version "26.5.3"
- resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.5.3.tgz#a3ceeaf4a757878342b8b00eca92379b246e5505"
- integrity sha512-sICclUqJQnR1bFRZGLN2jnSVsYOsmPYYnroGCIMVSvTS3y8XR3yjzy1EcTQmk6typ5pRgyIWzbjqxK6cZHEZuQ==
+eslint-plugin-jest@^27.9.0:
+ version "27.9.0"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.9.0.tgz#7c98a33605e1d8b8442ace092b60e9919730000b"
+ integrity sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==
"@typescript-eslint/utils" "^5.10.0"
@@ -7303,6 +7304,13 @@ mimic-response@^3.1.0:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==
[email protected]:
+ version "9.0.3"
+ resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825"
+ integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==
+ dependencies:
+ brace-expansion "^2.0.1"
+
minimatch@^3.0.2, minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" | [
"- \"@typescript-eslint/eslint-plugin\": \"^6.7.4\",",
"+ resolved \"https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.1.1.tgz#dd71fc5c7ecec745ca26ece506d84d203a205c0e\"",
"- \"@typescript-eslint/type-utils\" \"6.7.4\""
] | [
30,
56,
61
] | {
"additions": 67,
"author": "huntie",
"deletions": 59,
"html_url": "https://github.com/facebook/react-native/pull/44764",
"issue_id": 44764,
"merged_at": "2024-06-04T09:27:56Z",
"omission_probability": 0.1,
"pr_number": 44764,
"repo": "facebook/react-native",
"title": "[0.74] Update `eslint-plugin-jest` to 27.x, `@typescript-eslint` deps to 7.x",
"total_changes": 126
} |
538 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index ea5e45dbcc9dfb..795a00a5b4aff0 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
- "@react-native-community/cli-server-api": "13.6.6",
- "@react-native-community/cli-tools": "13.6.6",
+ "@react-native-community/cli-server-api": "13.6.8",
+ "@react-native-community/cli-tools": "13.6.8",
"@react-native/dev-middleware": "0.74.83",
"@react-native/metro-babel-transformer": "0.74.83",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 80daf766cbbac1..dda4639f07e807 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.6",
- "@react-native-community/cli-platform-android": "13.6.6",
- "@react-native-community/cli-platform-ios": "13.6.6",
+ "@react-native-community/cli": "13.6.8",
+ "@react-native-community/cli-platform-android": "13.6.8",
+ "@react-native-community/cli-platform-ios": "13.6.8",
"@react-native/assets-registry": "0.74.83",
"@react-native/codegen": "0.74.83",
"@react-native/community-cli-plugin": "0.74.83",
diff --git a/yarn.lock b/yarn.lock
index b529b43e471f12..c48cc70f458293 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943"
- integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474"
+ integrity sha512-B1uxlm1N4BQuWFvBL3yRl3LVvydjswsdbTi7tMrHMtSxfRio1p9HjcmDzlzKco09Y+8qBGgakm3jcMZGLbhXQQ==
dependencies:
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd"
- integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.8.tgz#6829ea7cdc237776c300be06f84c222bf17cf4c5"
+ integrity sha512-RabCkIsWdP4Ex/sf1uSP9qxc30utm+0uIJAjrZkNQynm7T4Lyqn/kT3LKm4yM6M0Qk61YxGguiaXF4601vAduw==
dependencies:
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
cosmiconfig "^5.1.0"
deepmerge "^4.3.0"
fast-glob "^3.3.2"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3"
- integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.8.tgz#d52fccd4b3e0860d96d75ff5b0ebb128bdc93dfd"
+ integrity sha512-2cS+MX/Su6sVSjqpDftFOXbK7EuPg98xzsPkdPhkQnkZwvXqodK9CAMuDMbx3lBHHtrPrpMbBCpFmPN8iVOnlA==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5"
- integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.8.tgz#05f696d94e975e4dcf7f9a1fde32fb43e4bb8a5f"
+ integrity sha512-/3Vdy9J3hyiu0y3nd/CU3kBqPlTRxnLXg7V6jrA1jbTOlZAMyV9imEkrqEaGK0SMOyMhh9Pipf98Ozhk0Nl4QA==
dependencies:
- "@react-native-community/cli-config" "13.6.6"
- "@react-native-community/cli-platform-android" "13.6.6"
- "@react-native-community/cli-platform-apple" "13.6.6"
- "@react-native-community/cli-platform-ios" "13.6.6"
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-config" "13.6.8"
+ "@react-native-community/cli-platform-android" "13.6.8"
+ "@react-native-community/cli-platform-apple" "13.6.8"
+ "@react-native-community/cli-platform-ios" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -2436,54 +2436,54 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474"
- integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.8.tgz#85f10f663bc79f299146e749c48c06ebc4da9e29"
+ integrity sha512-lZi/OBFuZUj5cLK94oEgtrtmxGoqeYVRcnHXl/R5c4put9PDl+qH2bEMlGZkFiw57ae3UZKr3TMk+1s4jh3FYQ==
dependencies:
- "@react-native-community/cli-platform-android" "13.6.6"
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-platform-android" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609"
- integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.8.tgz#a3672512a9b844f93d6050537c59dd58e1b12f17"
+ integrity sha512-vWrqeLRRTwp2kO33nbrAgbYn8HR2c2CpIfyVJY9Ckk7HGUSwDyxdcSu7YBvt2ShdfLZH0HctWFNXsgGrfg6BDw==
dependencies:
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790"
- integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.8.tgz#4d46a2d6678a7b3264768f97393f082ed9afb264"
+ integrity sha512-1JPohnlXPqU44zns3ALEzIbH2cKRw6JtEDJERgLuEUbs2r2NeJgqDbKyZ7fTTO8o+pegDnn6+Rr7qGVVOuUzzg==
dependencies:
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.8"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f"
- integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.8.tgz#2de1bd8529825781108c1cbba4f5b25cb062581c"
+ integrity sha512-/IIcIRM8qaoD7iZqsvtf6Qq1AwtChWYfB9sTn3mTiolZ5Zd5bXH37g+6liPfAICRkj2Ptq3iXmjrDVUQAxrOXw==
dependencies:
- "@react-native-community/cli-platform-apple" "13.6.6"
+ "@react-native-community/cli-platform-apple" "13.6.8"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a"
- integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63"
+ integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg==
dependencies:
- "@react-native-community/cli-debugger-ui" "13.6.6"
- "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-debugger-ui" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.8"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2492,10 +2492,10 @@
serve-static "^1.13.1"
ws "^6.2.2"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc"
- integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142"
+ integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9"
- integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug==
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436"
+ integrity sha512-C4mVByy0i+/NPuPhdMLBR7ubEVkjVS1VwoQu/BoG1crJFNE+167QXAzH01eFbXndsjZaMWmD4Gerx7TYc6lHfA==
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.6"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773"
- integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA==
- dependencies:
- "@react-native-community/cli-clean" "13.6.6"
- "@react-native-community/cli-config" "13.6.6"
- "@react-native-community/cli-debugger-ui" "13.6.6"
- "@react-native-community/cli-doctor" "13.6.6"
- "@react-native-community/cli-hermes" "13.6.6"
- "@react-native-community/cli-server-api" "13.6.6"
- "@react-native-community/cli-tools" "13.6.6"
- "@react-native-community/cli-types" "13.6.6"
+"@react-native-community/[email protected]":
+ version "13.6.8"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.8.tgz#d52c22620242e161bddcd2e0b6dbacd8743ca09b"
+ integrity sha512-0lRdgLNaXixWY4BfFRl1J6Ao9Lapo2z+++iE7TD4GAbuxOWJSyFi+KUA8XNfSDyML4jFO02MZgyBPxAWdaminQ==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.8"
+ "@react-native-community/cli-config" "13.6.8"
+ "@react-native-community/cli-debugger-ui" "13.6.8"
+ "@react-native-community/cli-doctor" "13.6.8"
+ "@react-native-community/cli-hermes" "13.6.8"
+ "@react-native-community/cli-server-api" "13.6.8"
+ "@react-native-community/cli-tools" "13.6.8"
+ "@react-native-community/cli-types" "13.6.8"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index ea5e45dbcc9dfb..795a00a5b4aff0 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
- "@react-native-community/cli-server-api": "13.6.6",
- "@react-native-community/cli-tools": "13.6.6",
+ "@react-native-community/cli-server-api": "13.6.8",
+ "@react-native-community/cli-tools": "13.6.8",
"@react-native/dev-middleware": "0.74.83",
"@react-native/metro-babel-transformer": "0.74.83",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index 80daf766cbbac1..dda4639f07e807 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.6",
- "@react-native-community/cli-platform-android": "13.6.6",
- "@react-native-community/cli-platform-ios": "13.6.6",
+ "@react-native-community/cli": "13.6.8",
+ "@react-native-community/cli-platform-android": "13.6.8",
+ "@react-native-community/cli-platform-ios": "13.6.8",
"@react-native/assets-registry": "0.74.83",
"@react-native/codegen": "0.74.83",
"@react-native/community-cli-plugin": "0.74.83",
diff --git a/yarn.lock b/yarn.lock
index b529b43e471f12..c48cc70f458293 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943"
- integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.8.tgz#95ce964047f005152ac100394b6dcd5d2cc2a474"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd"
- integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.8.tgz#6829ea7cdc237776c300be06f84c222bf17cf4c5"
+ integrity sha512-RabCkIsWdP4Ex/sf1uSP9qxc30utm+0uIJAjrZkNQynm7T4Lyqn/kT3LKm4yM6M0Qk61YxGguiaXF4601vAduw==
cosmiconfig "^5.1.0"
-"@react-native-community/[email protected]":
- integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g==
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.8.tgz#d52fccd4b3e0860d96d75ff5b0ebb128bdc93dfd"
+ integrity sha512-2cS+MX/Su6sVSjqpDftFOXbK7EuPg98xzsPkdPhkQnkZwvXqodK9CAMuDMbx3lBHHtrPrpMbBCpFmPN8iVOnlA==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5"
- integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.8.tgz#05f696d94e975e4dcf7f9a1fde32fb43e4bb8a5f"
+ integrity sha512-/3Vdy9J3hyiu0y3nd/CU3kBqPlTRxnLXg7V6jrA1jbTOlZAMyV9imEkrqEaGK0SMOyMhh9Pipf98Ozhk0Nl4QA==
- "@react-native-community/cli-platform-ios" "13.6.6"
+ "@react-native-community/cli-platform-ios" "13.6.8"
command-exists "^1.2.8"
@@ -2436,54 +2436,54 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474"
- integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.8.tgz#85f10f663bc79f299146e749c48c06ebc4da9e29"
+ integrity sha512-lZi/OBFuZUj5cLK94oEgtrtmxGoqeYVRcnHXl/R5c4put9PDl+qH2bEMlGZkFiw57ae3UZKr3TMk+1s4jh3FYQ==
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609"
- integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.8.tgz#a3672512a9b844f93d6050537c59dd58e1b12f17"
+ integrity sha512-vWrqeLRRTwp2kO33nbrAgbYn8HR2c2CpIfyVJY9Ckk7HGUSwDyxdcSu7YBvt2ShdfLZH0HctWFNXsgGrfg6BDw==
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790"
- integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.8.tgz#4d46a2d6678a7b3264768f97393f082ed9afb264"
+ integrity sha512-1JPohnlXPqU44zns3ALEzIbH2cKRw6JtEDJERgLuEUbs2r2NeJgqDbKyZ7fTTO8o+pegDnn6+Rr7qGVVOuUzzg==
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.8.tgz#2de1bd8529825781108c1cbba4f5b25cb062581c"
+ integrity sha512-/IIcIRM8qaoD7iZqsvtf6Qq1AwtChWYfB9sTn3mTiolZ5Zd5bXH37g+6liPfAICRkj2Ptq3iXmjrDVUQAxrOXw==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a"
- integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ==
+"@react-native-community/[email protected]":
+ integrity sha512-Lx664oWTzpVfbKUTy+3GIX7e+Mt5Zn+zdkM4ehllNdik/lbB3tM9Nrg8PSvOfI+tTXs2w55+nIydLfH+0FqJVg==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
@@ -2492,10 +2492,10 @@
ws "^6.2.2"
-"@react-native-community/[email protected]":
- integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.8.tgz#65a9f49ce66f0e639d855e745c8dfa7ae7b6c142"
+ integrity sha512-1MYlae9EkbjC7DBYOGMH5xF9yDoeNYUKgEdDjL6WAUBoF2gtwiZPM6igLKi/+dhb5sCtC7fiLrLi0Oevdf+RmQ==
appdirsjs "^1.2.4"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9"
- integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.8.tgz#1c357d3290a48232e3e639d48e43e31e422ce436"
+ integrity sha512-C4mVByy0i+/NPuPhdMLBR7ubEVkjVS1VwoQu/BoG1crJFNE+167QXAzH01eFbXndsjZaMWmD4Gerx7TYc6lHfA==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773"
- integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA==
- dependencies:
- "@react-native-community/cli-clean" "13.6.6"
- "@react-native-community/cli-doctor" "13.6.6"
- "@react-native-community/cli-hermes" "13.6.6"
- "@react-native-community/cli-server-api" "13.6.6"
- "@react-native-community/cli-types" "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.8.tgz#d52c22620242e161bddcd2e0b6dbacd8743ca09b"
+ integrity sha512-0lRdgLNaXixWY4BfFRl1J6Ao9Lapo2z+++iE7TD4GAbuxOWJSyFi+KUA8XNfSDyML4jFO02MZgyBPxAWdaminQ==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.8"
+ "@react-native-community/cli-doctor" "13.6.8"
+ "@react-native-community/cli-hermes" "13.6.8"
+ "@react-native-community/cli-types" "13.6.8"
commander "^9.4.1" | [
"+ integrity sha512-B1uxlm1N4BQuWFvBL3yRl3LVvydjswsdbTi7tMrHMtSxfRio1p9HjcmDzlzKco09Y+8qBGgakm3jcMZGLbhXQQ==",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3\"",
"+\"@react-native-community/[email protected]\":",
"- integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ==",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.8.tgz#fc654a2990a5f0b6f0b67ef04b25f699bee63f63\"",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc\"",
"+\"@react-native-community/[email protected]\":",
"+ \"@react-native-community/cli-server-api\" \"13.6.8\""
] | [
47,
74,
76,
162,
177,
193,
230,
240
] | {
"additions": 76,
"author": "szymonrybczak",
"deletions": 76,
"html_url": "https://github.com/facebook/react-native/pull/44757",
"issue_id": 44757,
"merged_at": "2024-06-03T14:49:09Z",
"omission_probability": 0.1,
"pr_number": 44757,
"repo": "facebook/react-native",
"title": "feat: upgrade CLI to `13.6.8`",
"total_changes": 152
} |
539 | diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 936eafb666d2f9..694f5f5165e67b 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
"dependencies": {
- "@react-native-community/cli-server-api": "13.6.4",
- "@react-native-community/cli-tools": "13.6.4",
+ "@react-native-community/cli-server-api": "13.6.6",
+ "@react-native-community/cli-tools": "13.6.6",
"@react-native/dev-middleware": "0.74.82",
"@react-native/metro-babel-transformer": "0.74.82",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index f35ac83b48540d..38189b46726a70 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.4",
- "@react-native-community/cli-platform-android": "13.6.4",
- "@react-native-community/cli-platform-ios": "13.6.4",
+ "@react-native-community/cli": "13.6.6",
+ "@react-native-community/cli-platform-android": "13.6.6",
+ "@react-native-community/cli-platform-ios": "13.6.6",
"@react-native/assets-registry": "0.74.82",
"@react-native/codegen": "0.74.82",
"@react-native/community-cli-plugin": "0.74.82",
diff --git a/yarn.lock b/yarn.lock
index 770f43336b1a4e..b529b43e471f12 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.4.tgz#53c07c6f2834a971dc40eab290edcf8ccc5d1e00"
- integrity sha512-nS1BJ+2Z+aLmqePxB4AYgJ+C/bgQt02xAgSYtCUv+lneRBGhL2tHRrK8/Iolp0y+yQoUtHHf4txYi90zGXLVfw==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943"
+ integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ==
dependencies:
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.4.tgz#3004c7bca55cb384b3a99c38c1a48dad24533237"
- integrity sha512-GGK415WoTx1R9FXtfb/cTnan9JIWwSm+a5UCuFd6+suzS0oIt1Md1vCzjNh6W1CK3b43rZC2e+3ZU7Ljd7YtyQ==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd"
+ integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg==
dependencies:
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
cosmiconfig "^5.1.0"
deepmerge "^4.3.0"
fast-glob "^3.3.2"
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.4.tgz#3881b9cfe14e66b3ee827a84f19ca9d0283fd764"
- integrity sha512-9Gs31s6tA1kuEo69ay9qLgM3x2gsN/RI994DCUKnFSW+qSusQJyyrmfllR2mGU3Wl1W09/nYpIg87W9JPf5y4A==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3"
+ integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g==
dependencies:
serve-static "^1.13.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.4.tgz#07e5c2f163807e61ce0ba12901903e591177e3d3"
- integrity sha512-lWOXCISH/cHtLvO0cWTr+IPSzA54FewVOw7MoCMEvWusH+1n7c3hXTAve78mLozGQ7iuUufkHFWwKf3dzOkflQ==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5"
+ integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg==
dependencies:
- "@react-native-community/cli-config" "13.6.4"
- "@react-native-community/cli-platform-android" "13.6.4"
- "@react-native-community/cli-platform-apple" "13.6.4"
- "@react-native-community/cli-platform-ios" "13.6.4"
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-config" "13.6.6"
+ "@react-native-community/cli-platform-android" "13.6.6"
+ "@react-native-community/cli-platform-apple" "13.6.6"
+ "@react-native-community/cli-platform-ios" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
command-exists "^1.2.8"
deepmerge "^4.3.0"
@@ -2436,66 +2436,66 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.4.tgz#6d3e9b5c251461e9bb35b04110544db8a4f5968f"
- integrity sha512-VIAufA/2wTccbMYBT9o+mQs9baOEpTxCiIdWeVdkPWKzIwtKsLpDZJlUqj4r4rI66mwjFyQ60PhwSzEJ2ApFeQ==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474"
+ integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg==
dependencies:
- "@react-native-community/cli-platform-android" "13.6.4"
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-platform-android" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.4.tgz#78ab4c840f4f1f5252ad2fcc5a55f7681ec458cb"
- integrity sha512-WhknYwIobKKCqaGCN3BzZEQHTbaZTDiGvcXzevvN867ldfaGdtbH0DVqNunbPoV1RNzeV9qKoQHFdWBkg83tpg==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609"
+ integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg==
dependencies:
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.4.tgz#4912eaf519800a957745192718822b94655c8119"
- integrity sha512-TLBiotdIz0veLbmvNQIdUv9fkBx7m34ANGYqr5nH7TFxdmey+Z+omoBqG/HGpvyR7d0AY+kZzzV4k+HkYHM/aQ==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790"
+ integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg==
dependencies:
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-tools" "13.6.6"
chalk "^4.1.2"
execa "^5.0.0"
fast-glob "^3.3.2"
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.4.tgz#96ec915c6df23b2b7b7e0d8cb3db7368e448d620"
- integrity sha512-8Dlva8RY+MY5nhWAj6V7voG3+JOEzDTJmD0FHqL+4p0srvr9v7IEVcxfw5lKBDIUNd0OMAHNevGA+cyz1J60jg==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f"
+ integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ==
dependencies:
- "@react-native-community/cli-platform-apple" "13.6.4"
+ "@react-native-community/cli-platform-apple" "13.6.6"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.4.tgz#6bcec7ae387fc3aeb3e78f62561a91962e6fadf7"
- integrity sha512-D2qSuYCFwrrUJUM0SDc9l3lEhU02yjf+9Peri/xhspzAhALnsf6Z/H7BCjddMV42g9/eY33LqiGyN5chr83a+g==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a"
+ integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ==
dependencies:
- "@react-native-community/cli-debugger-ui" "13.6.4"
- "@react-native-community/cli-tools" "13.6.4"
+ "@react-native-community/cli-debugger-ui" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.6"
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
nocache "^3.0.1"
pretty-format "^26.6.2"
serve-static "^1.13.1"
- ws "^7.5.1"
+ ws "^6.2.2"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.4.tgz#ab396604b6dcf215790807fe89656e779b11f0ec"
- integrity sha512-N4oHLLbeTdg8opqJozjClmuTfazo1Mt+oxU7mr7m45VCsFgBqTF70Uwad289TM/3l44PP679NRMAHVYqpIRYtQ==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc"
+ integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw==
dependencies:
appdirsjs "^1.2.4"
chalk "^4.1.2"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.4.tgz#e499a3691ee597aa4b93196ff182a4782fae7afb"
- integrity sha512-NxGCNs4eYtVC8x0wj0jJ/MZLRy8C+B9l8lY8kShuAcvWTv5JXRqmXjg8uK1aA+xikPh0maq4cc/zLw1roroY/A==
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9"
+ integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug==
dependencies:
joi "^17.2.1"
-"@react-native-community/[email protected]":
- version "13.6.4"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.4.tgz#dabe2749470a34533e18aada51d97c94b3568307"
- integrity sha512-V7rt2N5JY7M4dJFgdNfR164r3hZdR/Z7V54dv85TFQHRbdwF4QrkG+GeagAU54qrkK/OU8OH3AF2+mKuiNWpGA==
- dependencies:
- "@react-native-community/cli-clean" "13.6.4"
- "@react-native-community/cli-config" "13.6.4"
- "@react-native-community/cli-debugger-ui" "13.6.4"
- "@react-native-community/cli-doctor" "13.6.4"
- "@react-native-community/cli-hermes" "13.6.4"
- "@react-native-community/cli-server-api" "13.6.4"
- "@react-native-community/cli-tools" "13.6.4"
- "@react-native-community/cli-types" "13.6.4"
+"@react-native-community/[email protected]":
+ version "13.6.6"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773"
+ integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.6"
+ "@react-native-community/cli-config" "13.6.6"
+ "@react-native-community/cli-debugger-ui" "13.6.6"
+ "@react-native-community/cli-doctor" "13.6.6"
+ "@react-native-community/cli-hermes" "13.6.6"
+ "@react-native-community/cli-server-api" "13.6.6"
+ "@react-native-community/cli-tools" "13.6.6"
+ "@react-native-community/cli-types" "13.6.6"
chalk "^4.1.2"
commander "^9.4.1"
deepmerge "^4.3.0"
| diff --git a/packages/community-cli-plugin/package.json b/packages/community-cli-plugin/package.json
index 936eafb666d2f9..694f5f5165e67b 100644
--- a/packages/community-cli-plugin/package.json
+++ b/packages/community-cli-plugin/package.json
@@ -22,8 +22,8 @@
"dist"
],
- "@react-native-community/cli-tools": "13.6.4",
+ "@react-native-community/cli-server-api": "13.6.6",
+ "@react-native-community/cli-tools": "13.6.6",
"@react-native/dev-middleware": "0.74.82",
"@react-native/metro-babel-transformer": "0.74.82",
"chalk": "^4.0.0",
diff --git a/packages/react-native/package.json b/packages/react-native/package.json
index f35ac83b48540d..38189b46726a70 100644
--- a/packages/react-native/package.json
+++ b/packages/react-native/package.json
@@ -107,9 +107,9 @@
},
"@jest/create-cache-key-function": "^29.6.3",
- "@react-native-community/cli": "13.6.4",
- "@react-native-community/cli-platform-android": "13.6.4",
- "@react-native-community/cli-platform-ios": "13.6.4",
+ "@react-native-community/cli-platform-android": "13.6.6",
"@react-native/assets-registry": "0.74.82",
"@react-native/codegen": "0.74.82",
"@react-native/community-cli-plugin": "0.74.82",
diff --git a/yarn.lock b/yarn.lock
index 770f43336b1a4e..b529b43e471f12 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2384,45 +2384,45 @@
optionalDependencies:
npmlog "2 || ^3.1.0 || ^4.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.4.tgz#53c07c6f2834a971dc40eab290edcf8ccc5d1e00"
- integrity sha512-nS1BJ+2Z+aLmqePxB4AYgJ+C/bgQt02xAgSYtCUv+lneRBGhL2tHRrK8/Iolp0y+yQoUtHHf4txYi90zGXLVfw==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-13.6.6.tgz#87c7ad8746c38dab0fe7b3c6ff89d44351d5d943"
+ integrity sha512-cBwJTwl0NyeA4nyMxbhkWZhxtILYkbU3TW3k8AXLg+iGphe0zikYMGB3T+haTvTc6alTyEFwPbimk9bGIqkjAQ==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.4.tgz#3004c7bca55cb384b3a99c38c1a48dad24533237"
- integrity sha512-GGK415WoTx1R9FXtfb/cTnan9JIWwSm+a5UCuFd6+suzS0oIt1Md1vCzjNh6W1CK3b43rZC2e+3ZU7Ljd7YtyQ==
+ integrity sha512-mbG425zCKr8JZhv/j11382arezwS/70juWMsn8j2lmrGTrP1cUdW0MF15CCIFtJsqyK3Qs+FTmqttRpq81QfSg==
cosmiconfig "^5.1.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.4.tgz#3881b9cfe14e66b3ee827a84f19ca9d0283fd764"
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-13.6.6.tgz#ac021ebd795b0fd66fb52a8987d1d41c5a4b8cb3"
+ integrity sha512-Vv9u6eS4vKSDAvdhA0OiQHoA7y39fiPIgJ6biT32tN4avHDtxlc6TWZGiqv7g98SBvDWvoVAmdPLcRf3kU+c8g==
-"@react-native-community/[email protected]":
- integrity sha512-lWOXCISH/cHtLvO0cWTr+IPSzA54FewVOw7MoCMEvWusH+1n7c3hXTAve78mLozGQ7iuUufkHFWwKf3dzOkflQ==
+"@react-native-community/[email protected]":
+ integrity sha512-TWZb5g6EmQe2Ua2TEWNmyaEayvlWH4GmdD9ZC+p8EpKFpB1NpDGMK6sXbpb42TDvwZg5s4TDRplK0PBEA/SVDg==
- "@react-native-community/cli-platform-ios" "13.6.4"
+ "@react-native-community/cli-platform-ios" "13.6.6"
command-exists "^1.2.8"
@@ -2436,66 +2436,66 @@
wcwidth "^1.0.1"
yaml "^2.2.1"
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.4.tgz#6d3e9b5c251461e9bb35b04110544db8a4f5968f"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-hermes/-/cli-hermes-13.6.6.tgz#590f55f151fec23b55498228f92d100a0e71d474"
+ integrity sha512-La5Ie+NGaRl3klei6WxKoOxmCUSGGxpOk6vU5pEGf0/O7ky+Ay0io+zXYUZqlNMi/cGpO7ZUijakBYOB/uyuFg==
hermes-profile-transformer "^0.0.6"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.4.tgz#78ab4c840f4f1f5252ad2fcc5a55f7681ec458cb"
- integrity sha512-WhknYwIobKKCqaGCN3BzZEQHTbaZTDiGvcXzevvN867ldfaGdtbH0DVqNunbPoV1RNzeV9qKoQHFdWBkg83tpg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-android/-/cli-platform-android-13.6.6.tgz#9e3863cb092709021f11848890bff0fc16fc1609"
+ integrity sha512-/tMwkBeNxh84syiSwNlYtmUz/Ppc+HfKtdopL/5RB+fd3SV1/5/NPNjMlyLNgFKnpxvKCInQ7dnl6jGHJjeHjg==
fast-xml-parser "^4.2.4"
logkitty "^0.7.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.4.tgz#4912eaf519800a957745192718822b94655c8119"
- integrity sha512-TLBiotdIz0veLbmvNQIdUv9fkBx7m34ANGYqr5nH7TFxdmey+Z+omoBqG/HGpvyR7d0AY+kZzzV4k+HkYHM/aQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-apple/-/cli-platform-apple-13.6.6.tgz#d445fd6ed02c5ae2f43f9c45501e04fee53a2790"
+ integrity sha512-bOmSSwoqNNT3AmCRZXEMYKz1Jf1l2F86Nhs7qBcXdY/sGiJ+Flng564LOqvdAlVLTbkgz47KjNKCS2pP4Jg0Mg==
fast-xml-parser "^4.0.12"
ora "^5.4.1"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.4.tgz#96ec915c6df23b2b7b7e0d8cb3db7368e448d620"
- integrity sha512-8Dlva8RY+MY5nhWAj6V7voG3+JOEzDTJmD0FHqL+4p0srvr9v7IEVcxfw5lKBDIUNd0OMAHNevGA+cyz1J60jg==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-platform-ios/-/cli-platform-ios-13.6.6.tgz#0cd700f36483ca37dda7ec044377f8a926b1df1f"
+ integrity sha512-vjDnRwhlSN5ryqKTas6/DPkxuouuyFBAqAROH4FR1cspTbn6v78JTZKDmtQy9JMMo7N5vZj1kASU5vbFep9IOQ==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.4.tgz#6bcec7ae387fc3aeb3e78f62561a91962e6fadf7"
+"@react-native-community/[email protected]":
+ integrity sha512-ZtCXxoFlM7oDv3iZ3wsrT3SamhtUJuIkX2WePLPlN5bcbq7zimbPm2lHyicNJtpcGQ5ymsgpUWPCNZsWQhXBqQ==
compression "^1.7.1"
connect "^3.6.5"
errorhandler "^1.5.1"
nocache "^3.0.1"
pretty-format "^26.6.2"
- ws "^7.5.1"
+ ws "^6.2.2"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.4.tgz#ab396604b6dcf215790807fe89656e779b11f0ec"
- integrity sha512-N4oHLLbeTdg8opqJozjClmuTfazo1Mt+oxU7mr7m45VCsFgBqTF70Uwad289TM/3l44PP679NRMAHVYqpIRYtQ==
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-13.6.6.tgz#55c40cbabafbfc56cfb95a4d5fbf73ef60ec3cbc"
+ integrity sha512-ptOnn4AJczY5njvbdK91k4hcYazDnGtEPrqIwEI+k/CTBHNdb27Rsm2OZ7ye6f7otLBqF8gj/hK6QzJs8CEMgw==
appdirsjs "^1.2.4"
@@ -2509,26 +2509,26 @@
shell-quote "^1.7.3"
sudo-prompt "^9.0.0"
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.4.tgz#e499a3691ee597aa4b93196ff182a4782fae7afb"
+"@react-native-community/[email protected]":
+ integrity sha512-733iaYzlmvNK7XYbnWlMjdE+2k0hlTBJW071af/xb6Bs+hbJqBP9c03FZuYH2hFFwDDntwj05bkri/P7VgSxug==
-"@react-native-community/[email protected]":
- resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.4.tgz#dabe2749470a34533e18aada51d97c94b3568307"
- dependencies:
- "@react-native-community/cli-clean" "13.6.4"
- "@react-native-community/cli-doctor" "13.6.4"
- "@react-native-community/cli-hermes" "13.6.4"
- "@react-native-community/cli-types" "13.6.4"
+"@react-native-community/[email protected]":
+ resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-13.6.6.tgz#b929c8668e88344c03a46a3e635cb382dba16773"
+ integrity sha512-IqclB7VQ84ye8Fcs89HOpOscY4284VZg2pojHNl8H0Lzd4DadXJWQoxC7zWm8v2f8eyeX2kdhxp2ETD5tceIgA==
+ dependencies:
+ "@react-native-community/cli-clean" "13.6.6"
+ "@react-native-community/cli-doctor" "13.6.6"
+ "@react-native-community/cli-hermes" "13.6.6"
+ "@react-native-community/cli-server-api" "13.6.6"
+ "@react-native-community/cli-types" "13.6.6"
commander "^9.4.1" | [
"- \"@react-native-community/cli-server-api\": \"13.6.4\",",
"+ \"@react-native-community/cli\": \"13.6.6\",",
"+ \"@react-native-community/cli-platform-ios\": \"13.6.6\",",
"+\"@react-native-community/[email protected]\":",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-13.6.6.tgz#69f590694b3a079c74f781baab3b762db74f5dbd\"",
"- integrity sha512-9Gs31s6tA1kuEo69ay9qLgM3x2gsN/RI994DCUKnFSW+qSusQJyyrmfllR2mGU3Wl1W09/nYpIg87W9JPf5y4A==",
"+\"@react-native-community/[email protected]\":",
"- resolved \"https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.4.tgz#07e5c2f163807e61ce0ba12901903e591177e3d3\"",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-doctor/-/cli-doctor-13.6.6.tgz#ac0febff05601d9b86af3e03460e1a6b0a1d33a5\"",
"-\"@react-native-community/[email protected]\":",
"- integrity sha512-VIAufA/2wTccbMYBT9o+mQs9baOEpTxCiIdWeVdkPWKzIwtKsLpDZJlUqj4r4rI66mwjFyQ60PhwSzEJ2ApFeQ==",
"- integrity sha512-D2qSuYCFwrrUJUM0SDc9l3lEhU02yjf+9Peri/xhspzAhALnsf6Z/H7BCjddMV42g9/eY33LqiGyN5chr83a+g==",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-server-api/-/cli-server-api-13.6.6.tgz#467993006ef82361cdf7a9817999d5a09e85ca6a\"",
"- integrity sha512-NxGCNs4eYtVC8x0wj0jJ/MZLRy8C+B9l8lY8kShuAcvWTv5JXRqmXjg8uK1aA+xikPh0maq4cc/zLw1roroY/A==",
"+ resolved \"https://registry.yarnpkg.com/@react-native-community/cli-types/-/cli-types-13.6.6.tgz#b45af119d61888fea1074a7c32ddb093e3f119a9\"",
"- integrity sha512-V7rt2N5JY7M4dJFgdNfR164r3hZdR/Z7V54dv85TFQHRbdwF4QrkG+GeagAU54qrkK/OU8OH3AF2+mKuiNWpGA==",
"- \"@react-native-community/cli-server-api\" \"13.6.4\""
] | [
8,
26,
28,
59,
61,
75,
76,
85,
89,
109,
112,
174,
177,
211,
214,
222,
229
] | {
"additions": 77,
"author": "szymonrybczak",
"deletions": 77,
"html_url": "https://github.com/facebook/react-native/pull/44253",
"issue_id": 44253,
"merged_at": "2024-05-01T17:31:39Z",
"omission_probability": 0.1,
"pr_number": 44253,
"repo": "facebook/react-native",
"title": "feat: upgrade `@react-native-community/cli` to `13.6.6`",
"total_changes": 154
} |
540 | diff --git a/packages/rn-tester/PrivacyInfo.xcprivacy b/packages/rn-tester/PrivacyInfo.xcprivacy
new file mode 100644
index 00000000000000..41b8317f0652b9
--- /dev/null
+++ b/packages/rn-tester/PrivacyInfo.xcprivacy
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <array>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>C617.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>CA92.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>35F9.1</string>
+ </array>
+ </dict>
+ </array>
+ <key>NSPrivacyCollectedDataTypes</key>
+ <array/>
+ <key>NSPrivacyTracking</key>
+ <false/>
+</dict>
+</plist>
diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
index f3be7d17415467..a9395c5cf54190 100644
--- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
+++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
@@ -58,6 +58,7 @@
E7DB216622B2F3EC005AC45F /* RCTRootViewIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */; };
E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; };
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
+ F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -176,6 +177,7 @@
E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootViewIntegrationTests.m; sourceTree = "<group>"; };
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
EDF27040BB5969AF2B1103C9 /* Pods-RNTesterIntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.debug.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
+ F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -223,6 +225,7 @@
isa = PBXGroup;
children = (
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
+ F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
E771AEEA22B44E3100EA1189 /* Info.plist */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
5C60EB1B226440DB0018C04F /* AppDelegate.mm */,
@@ -509,6 +512,7 @@
files = (
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
+ F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
3D2AFAF51D646CF80089D1A3 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -937,6 +941,17 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
+ );
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@@ -1019,6 +1034,17 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
+ "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
+ "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
+ );
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CPLUSPLUSFLAGS = (
diff --git a/scripts/cocoapods/utils.rb b/scripts/cocoapods/utils.rb
index 198d58f563e899..c2c2be157131b6 100644
--- a/scripts/cocoapods/utils.rb
+++ b/scripts/cocoapods/utils.rb
@@ -144,6 +144,44 @@ def self.apply_mac_catalyst_patches(installer)
end
end
+ def self.get_privacy_manifest_paths_from(user_project)
+ privacy_manifests = user_project
+ .files
+ .select { |p|
+ p.path&.end_with?('PrivacyInfo.xcprivacy')
+ }
+ return privacy_manifests
+ end
+
+ def self.add_privacy_manifest_if_needed(installer)
+ user_project = installer.aggregate_targets
+ .map{ |t| t.user_project }
+ .first
+ privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first
+ if privacy_manifest.nil?
+ file_timestamp_reason = {
+ "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp",
+ "NSPrivacyAccessedAPITypeReasons" => ["C617.1"],
+ }
+ user_defaults_reason = {
+ "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults",
+ "NSPrivacyAccessedAPITypeReasons" => ["CA92.1"],
+ }
+ boot_time_reason = {
+ "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategorySystemBootTime",
+ "NSPrivacyAccessedAPITypeReasons" => ["35F9.1"],
+ }
+ privacy_manifest = {
+ "NSPrivacyCollectedDataTypes" => [],
+ "NSPrivacyTracking" => false,
+ "NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason, boot_time_reason]
+ }
+ path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy")
+ Xcodeproj::Plist.write_to_path(privacy_manifest, path)
+ Pod::UI.puts "Your app does not have a privacy manifest! A template has been generated containing Required Reasons API usage in the core React Native library. Please add the PrivacyInfo.xcprivacy file to your project and complete data use, tracking and any additional required reasons your app is using according to Apple's guidance: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files. Then, you will need to manually add this file to your project in Xcode.".red
+ end
+ end
+
def self.fix_flipper_for_xcode_15_3(installer)
installer.pods_project.targets.each do |target|
if target.name == 'Flipper'
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index 8b86d85e10717c..9cb5dc18015211 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -227,6 +227,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
ReactNativePodsUtils.apply_xcode_15_patch(installer)
ReactNativePodsUtils.updateIphoneOSDeploymentTarget(installer)
ReactNativePodsUtils.fix_flipper_for_xcode_15_3(installer)
+ ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == "1"
diff --git a/template/ios/HelloWorld.xcodeproj/project.pbxproj b/template/ios/HelloWorld.xcodeproj/project.pbxproj
index 2ad587963337f0..3f280e31ba6ac1 100644
--- a/template/ios/HelloWorld.xcodeproj/project.pbxproj
+++ b/template/ios/HelloWorld.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
5DCACB8F33CDC322A6C60F78 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = "<group>"; };
+ CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
@@ -86,6 +87,7 @@
13B07FAE1A68108700A75B9A /* HelloWorld */ = {
isa = PBXGroup;
children = (
+ CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
diff --git a/template/ios/HelloWorld/PrivacyInfo.xcprivacy b/template/ios/HelloWorld/PrivacyInfo.xcprivacy
new file mode 100644
index 00000000000000..ef1896e70c88da
--- /dev/null
+++ b/template/ios/HelloWorld/PrivacyInfo.xcprivacy
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrivacyCollectedDataTypes</key>
+ <array>
+ </array>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <array>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>C617.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>CA92.1</string>
+ </array>
+ </dict>
+ <dict>
+ <key>NSPrivacyAccessedAPIType</key>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <key>NSPrivacyAccessedAPITypeReasons</key>
+ <array>
+ <string>35F9.1</string>
+ </array>
+ </dict>
+ </array>
+ <key>NSPrivacyTracking</key>
+ <false/>
+</dict>
+</plist>
| diff --git a/packages/rn-tester/PrivacyInfo.xcprivacy b/packages/rn-tester/PrivacyInfo.xcprivacy
index 00000000000000..41b8317f0652b9
+++ b/packages/rn-tester/PrivacyInfo.xcprivacy
@@ -0,0 +1,37 @@
+ <key>NSPrivacyAccessedAPITypes</key>
+ <array>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <string>C617.1</string>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <string>CA92.1</string>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <string>35F9.1</string>
+ </array>
+ <array/>
+ <key>NSPrivacyTracking</key>
+ <false/>
diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
index f3be7d17415467..a9395c5cf54190 100644
--- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
+++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
@@ -58,6 +58,7 @@
E7DB216622B2F3EC005AC45F /* RCTRootViewIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */; };
E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; };
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
+ F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -176,6 +177,7 @@
E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootViewIntegrationTests.m; sourceTree = "<group>"; };
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
EDF27040BB5969AF2B1103C9 /* Pods-RNTesterIntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.debug.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
+ F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
/* Begin PBXFrameworksBuildPhase section */
@@ -223,6 +225,7 @@
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
+ F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
E771AEEA22B44E3100EA1189 /* Info.plist */,
5C60EB1B226440DB0018C04F /* AppDelegate.mm */,
@@ -509,6 +512,7 @@
files = (
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
+ F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
3D2AFAF51D646CF80089D1A3 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -937,6 +941,17 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@@ -1019,6 +1034,17 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CPLUSPLUSFLAGS = (
diff --git a/scripts/cocoapods/utils.rb b/scripts/cocoapods/utils.rb
index 198d58f563e899..c2c2be157131b6 100644
--- a/scripts/cocoapods/utils.rb
+++ b/scripts/cocoapods/utils.rb
@@ -144,6 +144,44 @@ def self.apply_mac_catalyst_patches(installer)
end
end
+ def self.get_privacy_manifest_paths_from(user_project)
+ privacy_manifests = user_project
+ .files
+ .select { |p|
+ p.path&.end_with?('PrivacyInfo.xcprivacy')
+ return privacy_manifests
+ def self.add_privacy_manifest_if_needed(installer)
+ user_project = installer.aggregate_targets
+ .map{ |t| t.user_project }
+ .first
+ privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first
+ if privacy_manifest.nil?
+ file_timestamp_reason = {
+ "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp",
+ "NSPrivacyAccessedAPITypeReasons" => ["C617.1"],
+ user_defaults_reason = {
+ "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults",
+ "NSPrivacyAccessedAPITypeReasons" => ["CA92.1"],
+ boot_time_reason = {
+ "NSPrivacyAccessedAPITypeReasons" => ["35F9.1"],
+ privacy_manifest = {
+ "NSPrivacyTracking" => false,
+ "NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason, boot_time_reason]
+ path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy")
+ Xcodeproj::Plist.write_to_path(privacy_manifest, path)
+ Pod::UI.puts "Your app does not have a privacy manifest! A template has been generated containing Required Reasons API usage in the core React Native library. Please add the PrivacyInfo.xcprivacy file to your project and complete data use, tracking and any additional required reasons your app is using according to Apple's guidance: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files. Then, you will need to manually add this file to your project in Xcode.".red
+ end
def self.fix_flipper_for_xcode_15_3(installer)
installer.pods_project.targets.each do |target|
if target.name == 'Flipper'
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index 8b86d85e10717c..9cb5dc18015211 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -227,6 +227,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
ReactNativePodsUtils.apply_xcode_15_patch(installer)
ReactNativePodsUtils.updateIphoneOSDeploymentTarget(installer)
ReactNativePodsUtils.fix_flipper_for_xcode_15_3(installer)
+ ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == "1"
diff --git a/template/ios/HelloWorld.xcodeproj/project.pbxproj b/template/ios/HelloWorld.xcodeproj/project.pbxproj
index 2ad587963337f0..3f280e31ba6ac1 100644
--- a/template/ios/HelloWorld.xcodeproj/project.pbxproj
+++ b/template/ios/HelloWorld.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
5DCACB8F33CDC322A6C60F78 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = "<group>"; };
+ CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -86,6 +87,7 @@
13B07FAE1A68108700A75B9A /* HelloWorld */ = {
+ CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */,
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
diff --git a/template/ios/HelloWorld/PrivacyInfo.xcprivacy b/template/ios/HelloWorld/PrivacyInfo.xcprivacy
index 00000000000000..ef1896e70c88da
+++ b/template/ios/HelloWorld/PrivacyInfo.xcprivacy
@@ -0,0 +1,38 @@
+ <key>NSPrivacyCollectedDataTypes</key>
+ <key>NSPrivacyAccessedAPITypes</key>
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+ <string>C617.1</string>
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+ <string>CA92.1</string>
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
+ <key>NSPrivacyTracking</key>
+ <false/> | [
"+\t<key>NSPrivacyCollectedDataTypes</key>",
"+ \"NSPrivacyAccessedAPIType\" => \"NSPrivacyAccessedAPICategorySystemBootTime\",",
"+ \"NSPrivacyCollectedDataTypes\" => [],",
"+ <string>35F9.1</string>"
] | [
37,
147,
151,
232
] | {
"additions": 142,
"author": "cipolleschi",
"deletions": 0,
"html_url": "https://github.com/facebook/react-native/pull/44281",
"issue_id": 44281,
"merged_at": "2024-04-26T13:27:37Z",
"omission_probability": 0.1,
"pr_number": 44281,
"repo": "facebook/react-native",
"title": "[iOS][Privacy Manifest] Set up privacy manifest for React Native 0.71",
"total_changes": 142
} |
541 | diff --git a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
index fe32e417f58cb..28ae2d0e03a21 100644
--- a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
+++ b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
@@ -373,7 +373,7 @@ index 88e78f1d8050c73ae6a8929f23e636ef7a383404..17b63c5ecdcd8feb17b76a13392595c7
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
-index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3bd8ab9137 100644
+index b17bc9760b97b1e72783ae174ffa0f69ca830462..226b546694524e3848ea849059df74970403690e 100644
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
@@ -4,6 +4,7 @@
@@ -384,7 +384,7 @@ index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3b
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
#include "third_party/blink/renderer/platform/geometry/path.h"
-@@ -241,6 +242,19 @@ PathBuilder& PathBuilder::AddContouredRect(
+@@ -241,6 +242,26 @@ PathBuilder& PathBuilder::AddContouredRect(
AddRoundedRect(target_rect);
return *this;
}
@@ -392,12 +392,19 @@ index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3b
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
+ if (contoured_rect.GetCornerCurvature().IsSmooth()) {
+ const gfx::RectF& box = contoured_rect.Rect();
-+ const FloatRoundedRect::Radii& radii = contoured_rect.GetRadii();
++
++ // Constrain the radii (on a copy) to ensure they do not exceed the box.
++ FloatRoundedRect round_rect_copy = contoured_rect.AsRoundedRect();
++ round_rect_copy.ConstrainRadii();
++ const FloatRoundedRect::Radii& radii = round_rect_copy.GetRadii();
++ float smoothness = std::clamp(
++ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
++
+ builder_.addPath(electron::DrawSmoothRoundRect(
-+ box.x(), box.y(), box.width(), box.height(),
-+ std::min(contoured_rect.GetCornerCurvature().Smoothness(), 1.0f),
++ box.x(), box.y(), box.width(), box.height(), smoothness,
+ radii.TopLeft().width(), radii.TopRight().width(),
+ radii.BottomRight().width(), radii.BottomLeft().width()));
++
+ return *this;
+ }
+
diff --git a/shell/renderer/electron_smooth_round_rect.cc b/shell/renderer/electron_smooth_round_rect.cc
index dcd681387c1f6..e78f7cf0df43b 100644
--- a/shell/renderer/electron_smooth_round_rect.cc
+++ b/shell/renderer/electron_smooth_round_rect.cc
@@ -100,10 +100,23 @@ constexpr CurveGeometry::CurveGeometry(float radius, float smoothness) {
void DrawCorner(SkPath& path,
float radius,
- const CurveGeometry& curve1,
- const CurveGeometry& curve2,
+ float smoothness1,
+ float smoothness2,
const SkPoint& corner,
unsigned int quarter_rotations) {
+ // If the radius is 0 then we can simply draw a line to the corner point.
+ if (radius == 0.0f) {
+ if (quarter_rotations == 0) {
+ path.moveTo(corner);
+ } else {
+ path.lineTo(corner);
+ }
+ return;
+ }
+
+ CurveGeometry curve1(radius, smoothness1);
+ CurveGeometry curve2(radius, smoothness2);
+
// Move/Line to the edge connecting point
{
SkPoint edge_connecting_point =
@@ -160,6 +173,12 @@ constexpr std::pair<float, float> ConstrainSmoothness(float size,
float smoothness,
float radius1,
float radius2) {
+ // If both radii are 0 then we don't need any smoothing. This avoids a
+ // division by zero in the ratio calculation.
+ if (radius1 == 0.0f && radius2 == 0.0f) {
+ return {0.0f, 0.0f};
+ }
+
float edge_consumed1 = LengthForCornerSmoothness(smoothness, radius1);
float edge_consumed2 = LengthForCornerSmoothness(smoothness, radius2);
@@ -269,28 +288,20 @@ SkPath DrawSmoothRoundRect(float x,
SkPath path;
// Top left corner
- DrawCorner(path, top_left_radius,
- CurveGeometry(top_left_radius, left_top_smoothness),
- CurveGeometry(top_left_radius, top_left_smoothness),
+ DrawCorner(path, top_left_radius, left_top_smoothness, top_left_smoothness,
SkPoint::Make(x, y), 0);
// Top right corner
- DrawCorner(path, top_right_radius,
- CurveGeometry(top_right_radius, top_right_smoothness),
- CurveGeometry(top_right_radius, right_top_smoothness),
+ DrawCorner(path, top_right_radius, top_right_smoothness, right_top_smoothness,
SkPoint::Make(x + width, y), 1);
// Bottom right corner
- DrawCorner(path, bottom_right_radius,
- CurveGeometry(bottom_right_radius, right_bottom_smoothness),
- CurveGeometry(bottom_right_radius, bottom_right_smoothness),
- SkPoint::Make(x + width, y + height), 2);
+ DrawCorner(path, bottom_right_radius, right_bottom_smoothness,
+ bottom_right_smoothness, SkPoint::Make(x + width, y + height), 2);
// Bottom left corner
- DrawCorner(path, bottom_left_radius,
- CurveGeometry(bottom_left_radius, bottom_left_smoothness),
- CurveGeometry(bottom_left_radius, left_bottom_smoothness),
- SkPoint::Make(x, y + height), 3);
+ DrawCorner(path, bottom_left_radius, left_bottom_smoothness,
+ bottom_left_smoothness, SkPoint::Make(x, y + height), 3);
path.close();
return path;
diff --git a/spec/api-corner-smoothing-spec.ts b/spec/api-corner-smoothing-spec.ts
index a25a787db7625..2ca9285832a28 100644
--- a/spec/api-corner-smoothing-spec.ts
+++ b/spec/api-corner-smoothing-spec.ts
@@ -6,7 +6,6 @@ import { AssertionError, expect } from 'chai';
import path = require('node:path');
import { createArtifact } from './lib/artifacts';
-import { ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
const FIXTURE_PATH = path.resolve(
@@ -42,7 +41,7 @@ const COMPARISON_TOLERANCE = 2.5;
function compareImages (img1: NativeImage, img2: NativeImage): boolean {
expect(img1.getSize()).to.deep.equal(
img2.getSize(),
- 'Cannot compare images with different sizes'
+ 'Cannot compare images with different sizes. Run tests with --force-device-scale-factor=1'
);
const bitmap1 = img1.toBitmap();
@@ -119,9 +118,7 @@ async function pageCaptureTestRecipe (
}
}
-// FIXME: these tests rely on live rendering results, which are too variable to
-// reproduce outside of CI, primarily due to display scaling.
-ifdescribe(!!process.env.CI)('-electron-corner-smoothing', () => {
+describe('-electron-corner-smoothing', () => {
afterEach(async () => {
await closeAllWindows();
});
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-false.png b/spec/fixtures/api/corner-smoothing/shape/expected-false.png
index 31aea673f8b06..56c135d740af7 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-false.png and b/spec/fixtures/api/corner-smoothing/shape/expected-false.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-true.png b/spec/fixtures/api/corner-smoothing/shape/expected-true.png
index f48bc31e2886b..97280d9369ce2 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-true.png and b/spec/fixtures/api/corner-smoothing/shape/expected-true.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/test.html b/spec/fixtures/api/corner-smoothing/shape/test.html
index 994e1bd76ee2e..d8db2ce0d4956 100644
--- a/spec/fixtures/api/corner-smoothing/shape/test.html
+++ b/spec/fixtures/api/corner-smoothing/shape/test.html
@@ -44,7 +44,7 @@
}
.box {
- --boxes-x: 7;
+ --boxes-x: 8;
--boxes-y: 5;
--box-shadow-offset: 4px;
--box-shadow-spread: 2px;
@@ -84,6 +84,10 @@
background-color: skyblue;
box-shadow: var(--box-shadow-offset) var(--box-shadow-offset) var(--box-shadow-spread) var(--box-shadow-grow) cornflowerblue;
}
+ .box.multiple-radii {
+ background-color: coral;
+ border-radius: 0 0 calc((var(--box-size) / 8) - 2px) calc((var(--box-size) / 2) - 8px);
+ }
</style>
</head>
<body>
@@ -95,6 +99,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-30">
<div class="box"></div>
@@ -104,6 +109,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-60">
<div class="box"></div>
@@ -113,6 +119,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-100">
<div class="box"></div>
@@ -122,6 +129,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-invalid">
<div class="box"></div>
@@ -131,6 +139,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
</body>
</html>
\ No newline at end of file
| diff --git a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
index fe32e417f58cb..28ae2d0e03a21 100644
--- a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
+++ b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
@@ -373,7 +373,7 @@ index 88e78f1d8050c73ae6a8929f23e636ef7a383404..17b63c5ecdcd8feb17b76a13392595c7
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
-index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3bd8ab9137 100644
+index b17bc9760b97b1e72783ae174ffa0f69ca830462..226b546694524e3848ea849059df74970403690e 100644
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
@@ -4,6 +4,7 @@
@@ -384,7 +384,7 @@ index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3b
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
#include "third_party/blink/renderer/platform/geometry/path.h"
-@@ -241,6 +242,19 @@ PathBuilder& PathBuilder::AddContouredRect(
AddRoundedRect(target_rect);
return *this;
}
@@ -392,12 +392,19 @@ index b17bc9760b97b1e72783ae174ffa0f69ca830462..9fcff7b868ca8c29b46d6ed2ddceee3b
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
+ if (contoured_rect.GetCornerCurvature().IsSmooth()) {
+ const gfx::RectF& box = contoured_rect.Rect();
-+ const FloatRoundedRect::Radii& radii = contoured_rect.GetRadii();
++ FloatRoundedRect round_rect_copy = contoured_rect.AsRoundedRect();
++ round_rect_copy.ConstrainRadii();
++ const FloatRoundedRect::Radii& radii = round_rect_copy.GetRadii();
++ float smoothness = std::clamp(
++ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
+ builder_.addPath(electron::DrawSmoothRoundRect(
-+ box.x(), box.y(), box.width(), box.height(),
-+ std::min(contoured_rect.GetCornerCurvature().Smoothness(), 1.0f),
++ box.x(), box.y(), box.width(), box.height(), smoothness,
+ radii.TopLeft().width(), radii.TopRight().width(),
+ radii.BottomRight().width(), radii.BottomLeft().width()));
+ return *this;
+ }
+
diff --git a/shell/renderer/electron_smooth_round_rect.cc b/shell/renderer/electron_smooth_round_rect.cc
index dcd681387c1f6..e78f7cf0df43b 100644
--- a/shell/renderer/electron_smooth_round_rect.cc
+++ b/shell/renderer/electron_smooth_round_rect.cc
@@ -100,10 +100,23 @@ constexpr CurveGeometry::CurveGeometry(float radius, float smoothness) {
void DrawCorner(SkPath& path,
float radius,
- const CurveGeometry& curve2,
+ float smoothness1,
+ float smoothness2,
const SkPoint& corner,
unsigned int quarter_rotations) {
+ // If the radius is 0 then we can simply draw a line to the corner point.
+ if (radius == 0.0f) {
+ if (quarter_rotations == 0) {
+ } else {
+ path.lineTo(corner);
+ }
+ return;
+ CurveGeometry curve1(radius, smoothness1);
+ CurveGeometry curve2(radius, smoothness2);
// Move/Line to the edge connecting point
{
SkPoint edge_connecting_point =
@@ -160,6 +173,12 @@ constexpr std::pair<float, float> ConstrainSmoothness(float size,
float smoothness,
float radius1,
float radius2) {
+ // division by zero in the ratio calculation.
+ if (radius1 == 0.0f && radius2 == 0.0f) {
+ return {0.0f, 0.0f};
float edge_consumed1 = LengthForCornerSmoothness(smoothness, radius1);
float edge_consumed2 = LengthForCornerSmoothness(smoothness, radius2);
@@ -269,28 +288,20 @@ SkPath DrawSmoothRoundRect(float x,
SkPath path;
// Top left corner
- DrawCorner(path, top_left_radius,
- CurveGeometry(top_left_radius, left_top_smoothness),
- CurveGeometry(top_left_radius, top_left_smoothness),
+ DrawCorner(path, top_left_radius, left_top_smoothness, top_left_smoothness,
SkPoint::Make(x, y), 0);
// Top right corner
- DrawCorner(path, top_right_radius,
- CurveGeometry(top_right_radius, top_right_smoothness),
- CurveGeometry(top_right_radius, right_top_smoothness),
+ DrawCorner(path, top_right_radius, top_right_smoothness, right_top_smoothness,
SkPoint::Make(x + width, y), 1);
// Bottom right corner
- DrawCorner(path, bottom_right_radius,
- CurveGeometry(bottom_right_radius, right_bottom_smoothness),
- CurveGeometry(bottom_right_radius, bottom_right_smoothness),
- SkPoint::Make(x + width, y + height), 2);
+ DrawCorner(path, bottom_right_radius, right_bottom_smoothness,
+ bottom_right_smoothness, SkPoint::Make(x + width, y + height), 2);
// Bottom left corner
- DrawCorner(path, bottom_left_radius,
- CurveGeometry(bottom_left_radius, bottom_left_smoothness),
- CurveGeometry(bottom_left_radius, left_bottom_smoothness),
- SkPoint::Make(x, y + height), 3);
+ DrawCorner(path, bottom_left_radius, left_bottom_smoothness,
+ bottom_left_smoothness, SkPoint::Make(x, y + height), 3);
path.close();
return path;
diff --git a/spec/api-corner-smoothing-spec.ts b/spec/api-corner-smoothing-spec.ts
index a25a787db7625..2ca9285832a28 100644
--- a/spec/api-corner-smoothing-spec.ts
+++ b/spec/api-corner-smoothing-spec.ts
@@ -6,7 +6,6 @@ import { AssertionError, expect } from 'chai';
import path = require('node:path');
import { createArtifact } from './lib/artifacts';
-import { ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
const FIXTURE_PATH = path.resolve(
@@ -42,7 +41,7 @@ const COMPARISON_TOLERANCE = 2.5;
function compareImages (img1: NativeImage, img2: NativeImage): boolean {
expect(img1.getSize()).to.deep.equal(
img2.getSize(),
- 'Cannot compare images with different sizes'
+ 'Cannot compare images with different sizes. Run tests with --force-device-scale-factor=1'
);
const bitmap1 = img1.toBitmap();
@@ -119,9 +118,7 @@ async function pageCaptureTestRecipe (
}
}
-// FIXME: these tests rely on live rendering results, which are too variable to
-// reproduce outside of CI, primarily due to display scaling.
-ifdescribe(!!process.env.CI)('-electron-corner-smoothing', () => {
+describe('-electron-corner-smoothing', () => {
afterEach(async () => {
await closeAllWindows();
});
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-false.png b/spec/fixtures/api/corner-smoothing/shape/expected-false.png
index 31aea673f8b06..56c135d740af7 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-false.png and b/spec/fixtures/api/corner-smoothing/shape/expected-false.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-true.png b/spec/fixtures/api/corner-smoothing/shape/expected-true.png
index f48bc31e2886b..97280d9369ce2 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-true.png and b/spec/fixtures/api/corner-smoothing/shape/expected-true.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/test.html b/spec/fixtures/api/corner-smoothing/shape/test.html
index 994e1bd76ee2e..d8db2ce0d4956 100644
--- a/spec/fixtures/api/corner-smoothing/shape/test.html
+++ b/spec/fixtures/api/corner-smoothing/shape/test.html
@@ -44,7 +44,7 @@
.box {
- --boxes-x: 7;
+ --boxes-x: 8;
--boxes-y: 5;
--box-shadow-offset: 4px;
--box-shadow-spread: 2px;
@@ -84,6 +84,10 @@
background-color: skyblue;
box-shadow: var(--box-shadow-offset) var(--box-shadow-offset) var(--box-shadow-spread) var(--box-shadow-grow) cornflowerblue;
+ .box.multiple-radii {
+ border-radius: 0 0 calc((var(--box-size) / 8) - 2px) calc((var(--box-size) / 2) - 8px);
+ }
</style>
</head>
<body>
@@ -95,6 +99,7 @@
<div class="row rounding-30">
@@ -104,6 +109,7 @@
<div class="row rounding-60">
@@ -113,6 +119,7 @@
<div class="row rounding-100">
@@ -122,6 +129,7 @@
<div class="row rounding-invalid">
@@ -131,6 +139,7 @@
</body>
</html>
\ No newline at end of file | [
"+@@ -241,6 +242,26 @@ PathBuilder& PathBuilder::AddContouredRect(",
"++ // Constrain the radii (on a copy) to ensure they do not exceed the box.",
"- const CurveGeometry& curve1,",
"+ path.moveTo(corner);",
"+ // If both radii are 0 then we don't need any smoothing. This avoids a",
"+ background-color: coral;"
] | [
18,
28,
53,
62,
79,
179
] | {
"additions": 51,
"author": "clavin",
"deletions": 27,
"html_url": "https://github.com/electron/electron/pull/46751",
"issue_id": 46751,
"merged_at": "2025-04-25T08:54:05Z",
"omission_probability": 0.1,
"pr_number": 46751,
"repo": "electron/electron",
"title": "fix: corner smoothing with 0 radii",
"total_changes": 78
} |
542 | diff --git a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
index 41283b3c18ae1..c18b4dfd98002 100644
--- a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
+++ b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
@@ -400,7 +400,7 @@ index b147b8d321d865295007516b15d0aaccfc6f7fac..8f54a3a657c660a52fcd4c94865ca219
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
-index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d42368b2e 100644
+index 346cfc0b13b31808fbe1381b3785150810f347bb..ebb2be8cc3bb71c4df6526d743a851121e36c138 100644
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
@@ -4,6 +4,7 @@
@@ -411,7 +411,7 @@ index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
#include "third_party/blink/renderer/platform/geometry/path.h"
-@@ -231,6 +232,19 @@ PathBuilder& PathBuilder::AddContouredRect(
+@@ -231,6 +232,26 @@ PathBuilder& PathBuilder::AddContouredRect(
AddRoundedRect(target_rect);
return *this;
}
@@ -419,12 +419,19 @@ index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
+ if (contoured_rect.GetCornerCurvature().IsSmooth()) {
+ const gfx::RectF& box = contoured_rect.Rect();
-+ const FloatRoundedRect::Radii& radii = contoured_rect.GetRadii();
++
++ // Constrain the radii (on a copy) to ensure they do not exceed the box.
++ FloatRoundedRect round_rect_copy = contoured_rect.AsRoundedRect();
++ round_rect_copy.ConstrainRadii();
++ const FloatRoundedRect::Radii& radii = round_rect_copy.GetRadii();
++ float smoothness = std::clamp(
++ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
++
+ builder_.addPath(electron::DrawSmoothRoundRect(
-+ box.x(), box.y(), box.width(), box.height(),
-+ std::min(contoured_rect.GetCornerCurvature().Smoothness(), 1.0f),
++ box.x(), box.y(), box.width(), box.height(), smoothness,
+ radii.TopLeft().width(), radii.TopRight().width(),
+ radii.BottomRight().width(), radii.BottomLeft().width()));
++
+ return *this;
+ }
+
diff --git a/shell/renderer/electron_smooth_round_rect.cc b/shell/renderer/electron_smooth_round_rect.cc
index dcd681387c1f6..e78f7cf0df43b 100644
--- a/shell/renderer/electron_smooth_round_rect.cc
+++ b/shell/renderer/electron_smooth_round_rect.cc
@@ -100,10 +100,23 @@ constexpr CurveGeometry::CurveGeometry(float radius, float smoothness) {
void DrawCorner(SkPath& path,
float radius,
- const CurveGeometry& curve1,
- const CurveGeometry& curve2,
+ float smoothness1,
+ float smoothness2,
const SkPoint& corner,
unsigned int quarter_rotations) {
+ // If the radius is 0 then we can simply draw a line to the corner point.
+ if (radius == 0.0f) {
+ if (quarter_rotations == 0) {
+ path.moveTo(corner);
+ } else {
+ path.lineTo(corner);
+ }
+ return;
+ }
+
+ CurveGeometry curve1(radius, smoothness1);
+ CurveGeometry curve2(radius, smoothness2);
+
// Move/Line to the edge connecting point
{
SkPoint edge_connecting_point =
@@ -160,6 +173,12 @@ constexpr std::pair<float, float> ConstrainSmoothness(float size,
float smoothness,
float radius1,
float radius2) {
+ // If both radii are 0 then we don't need any smoothing. This avoids a
+ // division by zero in the ratio calculation.
+ if (radius1 == 0.0f && radius2 == 0.0f) {
+ return {0.0f, 0.0f};
+ }
+
float edge_consumed1 = LengthForCornerSmoothness(smoothness, radius1);
float edge_consumed2 = LengthForCornerSmoothness(smoothness, radius2);
@@ -269,28 +288,20 @@ SkPath DrawSmoothRoundRect(float x,
SkPath path;
// Top left corner
- DrawCorner(path, top_left_radius,
- CurveGeometry(top_left_radius, left_top_smoothness),
- CurveGeometry(top_left_radius, top_left_smoothness),
+ DrawCorner(path, top_left_radius, left_top_smoothness, top_left_smoothness,
SkPoint::Make(x, y), 0);
// Top right corner
- DrawCorner(path, top_right_radius,
- CurveGeometry(top_right_radius, top_right_smoothness),
- CurveGeometry(top_right_radius, right_top_smoothness),
+ DrawCorner(path, top_right_radius, top_right_smoothness, right_top_smoothness,
SkPoint::Make(x + width, y), 1);
// Bottom right corner
- DrawCorner(path, bottom_right_radius,
- CurveGeometry(bottom_right_radius, right_bottom_smoothness),
- CurveGeometry(bottom_right_radius, bottom_right_smoothness),
- SkPoint::Make(x + width, y + height), 2);
+ DrawCorner(path, bottom_right_radius, right_bottom_smoothness,
+ bottom_right_smoothness, SkPoint::Make(x + width, y + height), 2);
// Bottom left corner
- DrawCorner(path, bottom_left_radius,
- CurveGeometry(bottom_left_radius, bottom_left_smoothness),
- CurveGeometry(bottom_left_radius, left_bottom_smoothness),
- SkPoint::Make(x, y + height), 3);
+ DrawCorner(path, bottom_left_radius, left_bottom_smoothness,
+ bottom_left_smoothness, SkPoint::Make(x, y + height), 3);
path.close();
return path;
diff --git a/spec/api-corner-smoothing-spec.ts b/spec/api-corner-smoothing-spec.ts
index a25a787db7625..2ca9285832a28 100644
--- a/spec/api-corner-smoothing-spec.ts
+++ b/spec/api-corner-smoothing-spec.ts
@@ -6,7 +6,6 @@ import { AssertionError, expect } from 'chai';
import path = require('node:path');
import { createArtifact } from './lib/artifacts';
-import { ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
const FIXTURE_PATH = path.resolve(
@@ -42,7 +41,7 @@ const COMPARISON_TOLERANCE = 2.5;
function compareImages (img1: NativeImage, img2: NativeImage): boolean {
expect(img1.getSize()).to.deep.equal(
img2.getSize(),
- 'Cannot compare images with different sizes'
+ 'Cannot compare images with different sizes. Run tests with --force-device-scale-factor=1'
);
const bitmap1 = img1.toBitmap();
@@ -119,9 +118,7 @@ async function pageCaptureTestRecipe (
}
}
-// FIXME: these tests rely on live rendering results, which are too variable to
-// reproduce outside of CI, primarily due to display scaling.
-ifdescribe(!!process.env.CI)('-electron-corner-smoothing', () => {
+describe('-electron-corner-smoothing', () => {
afterEach(async () => {
await closeAllWindows();
});
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-false.png b/spec/fixtures/api/corner-smoothing/shape/expected-false.png
index 31aea673f8b06..56c135d740af7 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-false.png and b/spec/fixtures/api/corner-smoothing/shape/expected-false.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-true.png b/spec/fixtures/api/corner-smoothing/shape/expected-true.png
index f48bc31e2886b..97280d9369ce2 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-true.png and b/spec/fixtures/api/corner-smoothing/shape/expected-true.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/test.html b/spec/fixtures/api/corner-smoothing/shape/test.html
index 994e1bd76ee2e..d8db2ce0d4956 100644
--- a/spec/fixtures/api/corner-smoothing/shape/test.html
+++ b/spec/fixtures/api/corner-smoothing/shape/test.html
@@ -44,7 +44,7 @@
}
.box {
- --boxes-x: 7;
+ --boxes-x: 8;
--boxes-y: 5;
--box-shadow-offset: 4px;
--box-shadow-spread: 2px;
@@ -84,6 +84,10 @@
background-color: skyblue;
box-shadow: var(--box-shadow-offset) var(--box-shadow-offset) var(--box-shadow-spread) var(--box-shadow-grow) cornflowerblue;
}
+ .box.multiple-radii {
+ background-color: coral;
+ border-radius: 0 0 calc((var(--box-size) / 8) - 2px) calc((var(--box-size) / 2) - 8px);
+ }
</style>
</head>
<body>
@@ -95,6 +99,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-30">
<div class="box"></div>
@@ -104,6 +109,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-60">
<div class="box"></div>
@@ -113,6 +119,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-100">
<div class="box"></div>
@@ -122,6 +129,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
<div class="row rounding-invalid">
<div class="box"></div>
@@ -131,6 +139,7 @@
<div class="box outline double"></div>
<div class="box outer"><div class="inner"></div></div>
<div class="box shadow"></div>
+ <div class="box multiple-radii"></div>
</div>
</body>
</html>
\ No newline at end of file
| diff --git a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
index 41283b3c18ae1..c18b4dfd98002 100644
--- a/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
+++ b/patches/chromium/feat_corner_smoothing_css_rule_and_blink_painting.patch
@@ -400,7 +400,7 @@ index b147b8d321d865295007516b15d0aaccfc6f7fac..8f54a3a657c660a52fcd4c94865ca219
// A Corner is a axis-aligned quad, with the points ordered (start, outer,
diff --git a/third_party/blink/renderer/platform/geometry/path_builder.cc b/third_party/blink/renderer/platform/geometry/path_builder.cc
-index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d42368b2e 100644
+index 346cfc0b13b31808fbe1381b3785150810f347bb..ebb2be8cc3bb71c4df6526d743a851121e36c138 100644
--- a/third_party/blink/renderer/platform/geometry/path_builder.cc
+++ b/third_party/blink/renderer/platform/geometry/path_builder.cc
@@ -4,6 +4,7 @@
@@ -411,7 +411,7 @@ index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
#include "third_party/blink/renderer/platform/geometry/infinite_int_rect.h"
#include "third_party/blink/renderer/platform/geometry/path.h"
-@@ -231,6 +232,19 @@ PathBuilder& PathBuilder::AddContouredRect(
+@@ -231,6 +232,26 @@ PathBuilder& PathBuilder::AddContouredRect(
AddRoundedRect(target_rect);
return *this;
}
@@ -419,12 +419,19 @@ index 346cfc0b13b31808fbe1381b3785150810f347bb..29a004e6b668d172534cd503f16de57d
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
+ if (contoured_rect.GetCornerCurvature().IsSmooth()) {
+ const gfx::RectF& box = contoured_rect.Rect();
++ FloatRoundedRect round_rect_copy = contoured_rect.AsRoundedRect();
++ round_rect_copy.ConstrainRadii();
++ const FloatRoundedRect::Radii& radii = round_rect_copy.GetRadii();
++ float smoothness = std::clamp(
++ contoured_rect.GetCornerCurvature().Smoothness(), 0.0f, 1.0f);
+ builder_.addPath(electron::DrawSmoothRoundRect(
-+ box.x(), box.y(), box.width(), box.height(),
-+ std::min(contoured_rect.GetCornerCurvature().Smoothness(), 1.0f),
++ box.x(), box.y(), box.width(), box.height(), smoothness,
+ radii.TopLeft().width(), radii.TopRight().width(),
+ radii.BottomRight().width(), radii.BottomLeft().width()));
+ return *this;
+ }
+
diff --git a/shell/renderer/electron_smooth_round_rect.cc b/shell/renderer/electron_smooth_round_rect.cc
index dcd681387c1f6..e78f7cf0df43b 100644
--- a/shell/renderer/electron_smooth_round_rect.cc
+++ b/shell/renderer/electron_smooth_round_rect.cc
@@ -100,10 +100,23 @@ constexpr CurveGeometry::CurveGeometry(float radius, float smoothness) {
void DrawCorner(SkPath& path,
float radius,
- const CurveGeometry& curve1,
- const CurveGeometry& curve2,
+ float smoothness1,
const SkPoint& corner,
unsigned int quarter_rotations) {
+ // If the radius is 0 then we can simply draw a line to the corner point.
+ if (radius == 0.0f) {
+ if (quarter_rotations == 0) {
+ path.moveTo(corner);
+ } else {
+ path.lineTo(corner);
+ }
+ return;
+ CurveGeometry curve1(radius, smoothness1);
+ CurveGeometry curve2(radius, smoothness2);
// Move/Line to the edge connecting point
{
SkPoint edge_connecting_point =
@@ -160,6 +173,12 @@ constexpr std::pair<float, float> ConstrainSmoothness(float size,
float smoothness,
float radius1,
float radius2) {
+ // If both radii are 0 then we don't need any smoothing. This avoids a
+ // division by zero in the ratio calculation.
+ if (radius1 == 0.0f && radius2 == 0.0f) {
float edge_consumed1 = LengthForCornerSmoothness(smoothness, radius1);
float edge_consumed2 = LengthForCornerSmoothness(smoothness, radius2);
@@ -269,28 +288,20 @@ SkPath DrawSmoothRoundRect(float x,
SkPath path;
// Top left corner
- DrawCorner(path, top_left_radius,
- CurveGeometry(top_left_radius, top_left_smoothness),
+ DrawCorner(path, top_left_radius, left_top_smoothness, top_left_smoothness,
SkPoint::Make(x, y), 0);
// Top right corner
- DrawCorner(path, top_right_radius,
- CurveGeometry(top_right_radius, top_right_smoothness),
- CurveGeometry(top_right_radius, right_top_smoothness),
+ DrawCorner(path, top_right_radius, top_right_smoothness, right_top_smoothness,
SkPoint::Make(x + width, y), 1);
// Bottom right corner
- DrawCorner(path, bottom_right_radius,
- CurveGeometry(bottom_right_radius, right_bottom_smoothness),
- CurveGeometry(bottom_right_radius, bottom_right_smoothness),
- SkPoint::Make(x + width, y + height), 2);
+ DrawCorner(path, bottom_right_radius, right_bottom_smoothness,
+ bottom_right_smoothness, SkPoint::Make(x + width, y + height), 2);
// Bottom left corner
- DrawCorner(path, bottom_left_radius,
- CurveGeometry(bottom_left_radius, bottom_left_smoothness),
- SkPoint::Make(x, y + height), 3);
+ DrawCorner(path, bottom_left_radius, left_bottom_smoothness,
+ bottom_left_smoothness, SkPoint::Make(x, y + height), 3);
path.close();
return path;
diff --git a/spec/api-corner-smoothing-spec.ts b/spec/api-corner-smoothing-spec.ts
index a25a787db7625..2ca9285832a28 100644
--- a/spec/api-corner-smoothing-spec.ts
+++ b/spec/api-corner-smoothing-spec.ts
@@ -6,7 +6,6 @@ import { AssertionError, expect } from 'chai';
import path = require('node:path');
import { createArtifact } from './lib/artifacts';
-import { ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
const FIXTURE_PATH = path.resolve(
@@ -42,7 +41,7 @@ const COMPARISON_TOLERANCE = 2.5;
function compareImages (img1: NativeImage, img2: NativeImage): boolean {
expect(img1.getSize()).to.deep.equal(
img2.getSize(),
- 'Cannot compare images with different sizes'
+ 'Cannot compare images with different sizes. Run tests with --force-device-scale-factor=1'
);
const bitmap1 = img1.toBitmap();
@@ -119,9 +118,7 @@ async function pageCaptureTestRecipe (
}
}
-// FIXME: these tests rely on live rendering results, which are too variable to
-// reproduce outside of CI, primarily due to display scaling.
-ifdescribe(!!process.env.CI)('-electron-corner-smoothing', () => {
+describe('-electron-corner-smoothing', () => {
afterEach(async () => {
await closeAllWindows();
});
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-false.png b/spec/fixtures/api/corner-smoothing/shape/expected-false.png
index 31aea673f8b06..56c135d740af7 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-false.png and b/spec/fixtures/api/corner-smoothing/shape/expected-false.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/expected-true.png b/spec/fixtures/api/corner-smoothing/shape/expected-true.png
index f48bc31e2886b..97280d9369ce2 100644
Binary files a/spec/fixtures/api/corner-smoothing/shape/expected-true.png and b/spec/fixtures/api/corner-smoothing/shape/expected-true.png differ
diff --git a/spec/fixtures/api/corner-smoothing/shape/test.html b/spec/fixtures/api/corner-smoothing/shape/test.html
index 994e1bd76ee2e..d8db2ce0d4956 100644
--- a/spec/fixtures/api/corner-smoothing/shape/test.html
+++ b/spec/fixtures/api/corner-smoothing/shape/test.html
@@ -44,7 +44,7 @@
.box {
- --boxes-x: 7;
+ --boxes-x: 8;
--boxes-y: 5;
--box-shadow-offset: 4px;
--box-shadow-spread: 2px;
@@ -84,6 +84,10 @@
background-color: skyblue;
box-shadow: var(--box-shadow-offset) var(--box-shadow-offset) var(--box-shadow-spread) var(--box-shadow-grow) cornflowerblue;
+ .box.multiple-radii {
+ background-color: coral;
+ border-radius: 0 0 calc((var(--box-size) / 8) - 2px) calc((var(--box-size) / 2) - 8px);
+ }
</style>
</head>
<body>
@@ -95,6 +99,7 @@
<div class="row rounding-30">
@@ -104,6 +109,7 @@
<div class="row rounding-60">
@@ -113,6 +119,7 @@
<div class="row rounding-100">
@@ -122,6 +129,7 @@
<div class="row rounding-invalid">
@@ -131,6 +139,7 @@
</body>
</html>
\ No newline at end of file | [
"-+ const FloatRoundedRect::Radii& radii = contoured_rect.GetRadii();",
"++ // Constrain the radii (on a copy) to ensure they do not exceed the box.",
"+ float smoothness2,",
"+ return {0.0f, 0.0f};",
"- CurveGeometry(top_left_radius, left_top_smoothness),",
"- CurveGeometry(bottom_left_radius, left_bottom_smoothness),"
] | [
26,
28,
56,
82,
93,
116
] | {
"additions": 51,
"author": "clavin",
"deletions": 27,
"html_url": "https://github.com/electron/electron/pull/46799",
"issue_id": 46799,
"merged_at": "2025-04-25T23:10:05Z",
"omission_probability": 0.1,
"pr_number": 46799,
"repo": "electron/electron",
"title": "fix: corner smoothing with 0 radii (36-x-y backport)",
"total_changes": 78
} |
543 | diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 4a75e7f95ad06..534831e1a2ed9 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -84,6 +84,24 @@ It has been always returning `true` since Electron 23, which only supports Windo
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
+### Changed: GTK 4 is default when running GNOME
+
+After an [upstream change](https://chromium-review.googlesource.com/c/chromium/src/+/6310469), GTK 4 is now the default when running GNOME.
+
+In rare cases, this may cause some applications or configurations to [error](https://github.com/electron/electron/issues/46538) with the following message:
+
+```stderr
+Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
+```
+
+Affected users can work around this by specifying the `gtk-version` command-line flag:
+
+```shell
+$ electron --gtk-version=3 # or --gtk-version=2
+```
+
+The same can be done with the [`app.commandLine.appendSwitch`](https://www.electronjs.org/docs/latest/api/command-line#commandlineappendswitchswitch-value) function.
+
## Planned Breaking API Changes (35.0)
### Behavior Changed: Dialog API's `defaultPath` option on Linux
| diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 4a75e7f95ad06..534831e1a2ed9 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -84,6 +84,24 @@ It has been always returning `true` since Electron 23, which only supports Windo
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
+### Changed: GTK 4 is default when running GNOME
+After an [upstream change](https://chromium-review.googlesource.com/c/chromium/src/+/6310469), GTK 4 is now the default when running GNOME.
+```stderr
+Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
+Affected users can work around this by specifying the `gtk-version` command-line flag:
+```shell
+$ electron --gtk-version=3 # or --gtk-version=2
+The same can be done with the [`app.commandLine.appendSwitch`](https://www.electronjs.org/docs/latest/api/command-line#commandlineappendswitchswitch-value) function.
## Planned Breaking API Changes (35.0)
### Behavior Changed: Dialog API's `defaultPath` option on Linux | [
"+In rare cases, this may cause some applications or configurations to [error](https://github.com/electron/electron/issues/46538) with the following message:"
] | [
12
] | {
"additions": 18,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46800",
"issue_id": 46800,
"merged_at": "2025-04-25T21:14:47Z",
"omission_probability": 0.1,
"pr_number": 46800,
"repo": "electron/electron",
"title": "docs: call out breaking change for GTK 4 default on GNOME",
"total_changes": 18
} |
544 | diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 5112b29f0fdfc..d8e753eb99e52 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -115,6 +115,24 @@ It has been always returning `true` since Electron 23, which only supports Windo
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
+### Changed: GTK 4 is default when running GNOME
+
+After an [upstream change](https://chromium-review.googlesource.com/c/chromium/src/+/6310469), GTK 4 is now the default when running GNOME.
+
+In rare cases, this may cause some applications or configurations to [error](https://github.com/electron/electron/issues/46538) with the following message:
+
+```stderr
+Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
+```
+
+Affected users can work around this by specifying the `gtk-version` command-line flag:
+
+```shell
+$ electron --gtk-version=3 # or --gtk-version=2
+```
+
+The same can be done with the [`app.commandLine.appendSwitch`](https://www.electronjs.org/docs/latest/api/command-line#commandlineappendswitchswitch-value) function.
+
## Planned Breaking API Changes (35.0)
### Behavior Changed: Dialog API's `defaultPath` option on Linux
| diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 5112b29f0fdfc..d8e753eb99e52 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -115,6 +115,24 @@ It has been always returning `true` since Electron 23, which only supports Windo
https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier
+### Changed: GTK 4 is default when running GNOME
+After an [upstream change](https://chromium-review.googlesource.com/c/chromium/src/+/6310469), GTK 4 is now the default when running GNOME.
+In rare cases, this may cause some applications or configurations to [error](https://github.com/electron/electron/issues/46538) with the following message:
+```stderr
+Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported
+Affected users can work around this by specifying the `gtk-version` command-line flag:
+```shell
+$ electron --gtk-version=3 # or --gtk-version=2
+The same can be done with the [`app.commandLine.appendSwitch`](https://www.electronjs.org/docs/latest/api/command-line#commandlineappendswitchswitch-value) function.
## Planned Breaking API Changes (35.0)
### Behavior Changed: Dialog API's `defaultPath` option on Linux | [] | [] | {
"additions": 18,
"author": "clavin",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46793",
"issue_id": 46793,
"merged_at": "2025-04-25T20:31:28Z",
"omission_probability": 0.1,
"pr_number": 46793,
"repo": "electron/electron",
"title": "docs: call out breaking change for GTK 4 default on GNOME",
"total_changes": 18
} |
545 | diff --git a/shell/browser/electron_autofill_driver_factory.cc b/shell/browser/electron_autofill_driver_factory.cc
index b2a68d4ec036a..84631924d09f7 100644
--- a/shell/browser/electron_autofill_driver_factory.cc
+++ b/shell/browser/electron_autofill_driver_factory.cc
@@ -94,8 +94,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
void AutofillDriverFactory::AddDriverForFrame(
content::RenderFrameHost* render_frame_host,
CreationCallback factory_method) {
- auto insertion_result =
- driver_map_.insert(std::make_pair(render_frame_host, nullptr));
+ auto insertion_result = driver_map_.try_emplace(render_frame_host, nullptr);
// This can be called twice for the key representing the main frame.
if (insertion_result.second) {
insertion_result.first->second = std::move(factory_method).Run();
diff --git a/shell/browser/file_system_access/file_system_access_permission_context.cc b/shell/browser/file_system_access/file_system_access_permission_context.cc
index 865fa06f19bac..833f3992f5814 100644
--- a/shell/browser/file_system_access/file_system_access_permission_context.cc
+++ b/shell/browser/file_system_access/file_system_access_permission_context.cc
@@ -745,7 +745,7 @@ void FileSystemAccessPermissionContext::SetLastPickedDirectory(
base::Value::Dict dict;
dict.Set(GenerateLastPickedDirectoryKey(id), std::move(entry));
MaybeEvictEntries(dict);
- id_pathinfo_map_.insert(std::make_pair(origin, std::move(dict)));
+ id_pathinfo_map_.try_emplace(origin, std::move(dict));
}
}
diff --git a/shell/browser/hid/electron_hid_delegate.cc b/shell/browser/hid/electron_hid_delegate.cc
index 1915d4e489393..3f0f6fd091f7e 100644
--- a/shell/browser/hid/electron_hid_delegate.cc
+++ b/shell/browser/hid/electron_hid_delegate.cc
@@ -243,8 +243,7 @@ HidChooserController* ElectronHidDelegate::AddControllerForFrame(
auto controller = std::make_unique<HidChooserController>(
render_frame_host, std::move(filters), std::move(exclusion_filters),
std::move(callback), web_contents, weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/hid/hid_chooser_context.cc b/shell/browser/hid/hid_chooser_context.cc
index 4869f56eb8def..8c27a729ff580 100644
--- a/shell/browser/hid/hid_chooser_context.cc
+++ b/shell/browser/hid/hid_chooser_context.cc
@@ -310,7 +310,7 @@ void HidChooserContext::SetUpHidManagerConnection(
void HidChooserContext::InitDeviceList(
std::vector<device::mojom::HidDeviceInfoPtr> devices) {
for (auto& device : devices)
- devices_.insert({device->guid, std::move(device)});
+ devices_.try_emplace(device->guid, std::move(device));
is_initialized_ = true;
diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc
index cee7c0f756e42..572e5e4ae6ded 100644
--- a/shell/browser/net/proxying_url_loader_factory.cc
+++ b/shell/browser/net/proxying_url_loader_factory.cc
@@ -883,9 +883,9 @@ void ProxyingURLLoaderFactory::OnLoaderForCorsPreflightCreated(
// sending request headers is very difficult.
const uint64_t web_request_id = ++(*request_id_generator_);
- auto result = requests_.insert(std::make_pair(
+ auto result = requests_.try_emplace(
web_request_id, std::make_unique<InProgressRequest>(
- this, web_request_id, frame_routing_id_, request)));
+ this, web_request_id, frame_routing_id_, request));
result.first->second->OnLoaderCreated(std::move(receiver));
result.first->second->Restart();
diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm
index a90842f096163..2408fbd98cab0 100644
--- a/shell/browser/notifications/mac/cocoa_notification.mm
+++ b/shell/browser/notifications/mac/cocoa_notification.mm
@@ -93,8 +93,8 @@
actionWithIdentifier:actionIdentifier
title:base::SysUTF16ToNSString(action.text)];
[additionalActions addObject:notificationAction];
- additional_action_indices_.insert(
- std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
+ additional_action_indices_.try_emplace(
+ base::SysNSStringToUTF8(actionIdentifier), i);
}
}
i++;
diff --git a/shell/browser/serial/electron_serial_delegate.cc b/shell/browser/serial/electron_serial_delegate.cc
index e7b9e551fe1d5..bd8f5c5a85c6c 100644
--- a/shell/browser/serial/electron_serial_delegate.cc
+++ b/shell/browser/serial/electron_serial_delegate.cc
@@ -116,8 +116,7 @@ SerialChooserController* ElectronSerialDelegate::AddControllerForFrame(
render_frame_host, std::move(filters),
std::move(allowed_bluetooth_service_class_ids), std::move(callback),
web_contents, weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index be387c644e9ad..a857f6464bf7b 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -85,7 +85,7 @@ void SerialChooserContext::GrantPortPermission(
const url::Origin& origin,
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
- port_info_.insert({port.token, port.Clone()});
+ port_info_.try_emplace(port.token, port.Clone());
if (CanStorePersistentEntry(port)) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
@@ -270,7 +270,7 @@ void SerialChooserContext::SetUpPortManagerConnection(
void SerialChooserContext::OnGetDevices(
std::vector<device::mojom::SerialPortInfoPtr> ports) {
for (auto& port : ports)
- port_info_.insert({port->token, std::move(port)});
+ port_info_.try_emplace(port->token, std::move(port));
is_initialized_ = true;
}
diff --git a/shell/browser/usb/electron_usb_delegate.cc b/shell/browser/usb/electron_usb_delegate.cc
index 4e3827d04f74d..535e30e60ba72 100644
--- a/shell/browser/usb/electron_usb_delegate.cc
+++ b/shell/browser/usb/electron_usb_delegate.cc
@@ -301,8 +301,7 @@ UsbChooserController* ElectronUsbDelegate::AddControllerForFrame(
auto controller = std::make_unique<UsbChooserController>(
render_frame_host, std::move(options), std::move(callback), web_contents,
weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index 1273b7dbd41e7..42fd6b2e4284e 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -103,10 +103,8 @@ void UsbChooserContext::InitDeviceList(
std::vector<device::mojom::UsbDeviceInfoPtr> devices) {
for (auto& device_info : devices) {
DCHECK(device_info);
- if (ShouldExposeDevice(*device_info)) {
- devices_.insert(
- std::make_pair(device_info->guid, std::move(device_info)));
- }
+ if (ShouldExposeDevice(*device_info))
+ devices_.try_emplace(device_info->guid, std::move(device_info));
}
is_initialized_ = true;
@@ -285,7 +283,7 @@ void UsbChooserContext::OnDeviceAdded(
DCHECK(!devices_.contains(device_info->guid));
if (!ShouldExposeDevice(*device_info))
return;
- devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
+ devices_.try_emplace(device_info->guid, device_info->Clone());
// Notify all observers.
for (auto& observer : device_observer_list_)
| diff --git a/shell/browser/electron_autofill_driver_factory.cc b/shell/browser/electron_autofill_driver_factory.cc
index b2a68d4ec036a..84631924d09f7 100644
--- a/shell/browser/electron_autofill_driver_factory.cc
+++ b/shell/browser/electron_autofill_driver_factory.cc
@@ -94,8 +94,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
void AutofillDriverFactory::AddDriverForFrame(
content::RenderFrameHost* render_frame_host,
CreationCallback factory_method) {
- auto insertion_result =
- driver_map_.insert(std::make_pair(render_frame_host, nullptr));
+ auto insertion_result = driver_map_.try_emplace(render_frame_host, nullptr);
// This can be called twice for the key representing the main frame.
if (insertion_result.second) {
insertion_result.first->second = std::move(factory_method).Run();
diff --git a/shell/browser/file_system_access/file_system_access_permission_context.cc b/shell/browser/file_system_access/file_system_access_permission_context.cc
index 865fa06f19bac..833f3992f5814 100644
--- a/shell/browser/file_system_access/file_system_access_permission_context.cc
+++ b/shell/browser/file_system_access/file_system_access_permission_context.cc
@@ -745,7 +745,7 @@ void FileSystemAccessPermissionContext::SetLastPickedDirectory(
base::Value::Dict dict;
dict.Set(GenerateLastPickedDirectoryKey(id), std::move(entry));
MaybeEvictEntries(dict);
- id_pathinfo_map_.insert(std::make_pair(origin, std::move(dict)));
+ id_pathinfo_map_.try_emplace(origin, std::move(dict));
diff --git a/shell/browser/hid/electron_hid_delegate.cc b/shell/browser/hid/electron_hid_delegate.cc
index 1915d4e489393..3f0f6fd091f7e 100644
--- a/shell/browser/hid/electron_hid_delegate.cc
+++ b/shell/browser/hid/electron_hid_delegate.cc
@@ -243,8 +243,7 @@ HidChooserController* ElectronHidDelegate::AddControllerForFrame(
auto controller = std::make_unique<HidChooserController>(
render_frame_host, std::move(filters), std::move(exclusion_filters),
std::move(callback), web_contents, weak_factory_.GetWeakPtr());
diff --git a/shell/browser/hid/hid_chooser_context.cc b/shell/browser/hid/hid_chooser_context.cc
index 4869f56eb8def..8c27a729ff580 100644
--- a/shell/browser/hid/hid_chooser_context.cc
+++ b/shell/browser/hid/hid_chooser_context.cc
@@ -310,7 +310,7 @@ void HidChooserContext::SetUpHidManagerConnection(
void HidChooserContext::InitDeviceList(
std::vector<device::mojom::HidDeviceInfoPtr> devices) {
for (auto& device : devices)
- devices_.insert({device->guid, std::move(device)});
+ devices_.try_emplace(device->guid, std::move(device));
diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc
index cee7c0f756e42..572e5e4ae6ded 100644
--- a/shell/browser/net/proxying_url_loader_factory.cc
+++ b/shell/browser/net/proxying_url_loader_factory.cc
@@ -883,9 +883,9 @@ void ProxyingURLLoaderFactory::OnLoaderForCorsPreflightCreated(
// sending request headers is very difficult.
const uint64_t web_request_id = ++(*request_id_generator_);
- auto result = requests_.insert(std::make_pair(
+ auto result = requests_.try_emplace(
web_request_id, std::make_unique<InProgressRequest>(
+ this, web_request_id, frame_routing_id_, request));
result.first->second->OnLoaderCreated(std::move(receiver));
result.first->second->Restart();
diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm
index a90842f096163..2408fbd98cab0 100644
--- a/shell/browser/notifications/mac/cocoa_notification.mm
+++ b/shell/browser/notifications/mac/cocoa_notification.mm
@@ -93,8 +93,8 @@
actionWithIdentifier:actionIdentifier
title:base::SysUTF16ToNSString(action.text)];
[additionalActions addObject:notificationAction];
- additional_action_indices_.insert(
- std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
+ base::SysNSStringToUTF8(actionIdentifier), i);
}
}
i++;
diff --git a/shell/browser/serial/electron_serial_delegate.cc b/shell/browser/serial/electron_serial_delegate.cc
index e7b9e551fe1d5..bd8f5c5a85c6c 100644
--- a/shell/browser/serial/electron_serial_delegate.cc
+++ b/shell/browser/serial/electron_serial_delegate.cc
@@ -116,8 +116,7 @@ SerialChooserController* ElectronSerialDelegate::AddControllerForFrame(
render_frame_host, std::move(filters),
std::move(allowed_bluetooth_service_class_ids), std::move(callback),
web_contents, weak_factory_.GetWeakPtr());
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index be387c644e9ad..a857f6464bf7b 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -85,7 +85,7 @@ void SerialChooserContext::GrantPortPermission(
const url::Origin& origin,
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
- port_info_.insert({port.token, port.Clone()});
+ port_info_.try_emplace(port.token, port.Clone());
if (CanStorePersistentEntry(port)) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
@@ -270,7 +270,7 @@ void SerialChooserContext::SetUpPortManagerConnection(
void SerialChooserContext::OnGetDevices(
std::vector<device::mojom::SerialPortInfoPtr> ports) {
for (auto& port : ports)
- port_info_.insert({port->token, std::move(port)});
+ port_info_.try_emplace(port->token, std::move(port));
diff --git a/shell/browser/usb/electron_usb_delegate.cc b/shell/browser/usb/electron_usb_delegate.cc
index 4e3827d04f74d..535e30e60ba72 100644
--- a/shell/browser/usb/electron_usb_delegate.cc
+++ b/shell/browser/usb/electron_usb_delegate.cc
@@ -301,8 +301,7 @@ UsbChooserController* ElectronUsbDelegate::AddControllerForFrame(
auto controller = std::make_unique<UsbChooserController>(
render_frame_host, std::move(options), std::move(callback), web_contents,
weak_factory_.GetWeakPtr());
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index 1273b7dbd41e7..42fd6b2e4284e 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -103,10 +103,8 @@ void UsbChooserContext::InitDeviceList(
std::vector<device::mojom::UsbDeviceInfoPtr> devices) {
for (auto& device_info : devices) {
DCHECK(device_info);
- if (ShouldExposeDevice(*device_info)) {
- devices_.insert(
- std::make_pair(device_info->guid, std::move(device_info)));
- }
+ if (ShouldExposeDevice(*device_info))
@@ -285,7 +283,7 @@ void UsbChooserContext::OnDeviceAdded(
DCHECK(!devices_.contains(device_info->guid));
if (!ShouldExposeDevice(*device_info))
return;
- devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
+ devices_.try_emplace(device_info->guid, device_info->Clone());
// Notify all observers.
for (auto& observer : device_observer_list_) | [
"- this, web_request_id, frame_routing_id_, request)));",
"+ additional_action_indices_.try_emplace(",
"+ devices_.try_emplace(device_info->guid, std::move(device_info));"
] | [
65,
80,
148
] | {
"additions": 15,
"author": "trop[bot]",
"deletions": 21,
"html_url": "https://github.com/electron/electron/pull/46794",
"issue_id": 46794,
"merged_at": "2025-04-25T20:22:00Z",
"omission_probability": 0.1,
"pr_number": 46794,
"repo": "electron/electron",
"title": "refactor: use `std::map::try_emplace()` over `std::map::insert()`",
"total_changes": 36
} |
546 | diff --git a/shell/browser/electron_autofill_driver_factory.cc b/shell/browser/electron_autofill_driver_factory.cc
index b2a68d4ec036a..84631924d09f7 100644
--- a/shell/browser/electron_autofill_driver_factory.cc
+++ b/shell/browser/electron_autofill_driver_factory.cc
@@ -94,8 +94,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
void AutofillDriverFactory::AddDriverForFrame(
content::RenderFrameHost* render_frame_host,
CreationCallback factory_method) {
- auto insertion_result =
- driver_map_.insert(std::make_pair(render_frame_host, nullptr));
+ auto insertion_result = driver_map_.try_emplace(render_frame_host, nullptr);
// This can be called twice for the key representing the main frame.
if (insertion_result.second) {
insertion_result.first->second = std::move(factory_method).Run();
diff --git a/shell/browser/file_system_access/file_system_access_permission_context.cc b/shell/browser/file_system_access/file_system_access_permission_context.cc
index dad1d9466e6b1..1fb8c1d4a57aa 100644
--- a/shell/browser/file_system_access/file_system_access_permission_context.cc
+++ b/shell/browser/file_system_access/file_system_access_permission_context.cc
@@ -746,7 +746,7 @@ void FileSystemAccessPermissionContext::SetLastPickedDirectory(
base::Value::Dict dict;
dict.Set(GenerateLastPickedDirectoryKey(id), std::move(entry));
MaybeEvictEntries(dict);
- id_pathinfo_map_.insert(std::make_pair(origin, std::move(dict)));
+ id_pathinfo_map_.try_emplace(origin, std::move(dict));
}
}
diff --git a/shell/browser/hid/electron_hid_delegate.cc b/shell/browser/hid/electron_hid_delegate.cc
index d23760d130b92..aea69296dbfa2 100644
--- a/shell/browser/hid/electron_hid_delegate.cc
+++ b/shell/browser/hid/electron_hid_delegate.cc
@@ -241,8 +241,7 @@ HidChooserController* ElectronHidDelegate::AddControllerForFrame(
auto controller = std::make_unique<HidChooserController>(
render_frame_host, std::move(filters), std::move(exclusion_filters),
std::move(callback), web_contents, weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/hid/hid_chooser_context.cc b/shell/browser/hid/hid_chooser_context.cc
index 2fb733cfafdc3..e135dd1c762e5 100644
--- a/shell/browser/hid/hid_chooser_context.cc
+++ b/shell/browser/hid/hid_chooser_context.cc
@@ -307,7 +307,7 @@ void HidChooserContext::SetUpHidManagerConnection(
void HidChooserContext::InitDeviceList(
std::vector<device::mojom::HidDeviceInfoPtr> devices) {
for (auto& device : devices)
- devices_.insert({device->guid, std::move(device)});
+ devices_.try_emplace(device->guid, std::move(device));
is_initialized_ = true;
diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc
index cee7c0f756e42..572e5e4ae6ded 100644
--- a/shell/browser/net/proxying_url_loader_factory.cc
+++ b/shell/browser/net/proxying_url_loader_factory.cc
@@ -883,9 +883,9 @@ void ProxyingURLLoaderFactory::OnLoaderForCorsPreflightCreated(
// sending request headers is very difficult.
const uint64_t web_request_id = ++(*request_id_generator_);
- auto result = requests_.insert(std::make_pair(
+ auto result = requests_.try_emplace(
web_request_id, std::make_unique<InProgressRequest>(
- this, web_request_id, frame_routing_id_, request)));
+ this, web_request_id, frame_routing_id_, request));
result.first->second->OnLoaderCreated(std::move(receiver));
result.first->second->Restart();
diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm
index a90842f096163..2408fbd98cab0 100644
--- a/shell/browser/notifications/mac/cocoa_notification.mm
+++ b/shell/browser/notifications/mac/cocoa_notification.mm
@@ -93,8 +93,8 @@
actionWithIdentifier:actionIdentifier
title:base::SysUTF16ToNSString(action.text)];
[additionalActions addObject:notificationAction];
- additional_action_indices_.insert(
- std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
+ additional_action_indices_.try_emplace(
+ base::SysNSStringToUTF8(actionIdentifier), i);
}
}
i++;
diff --git a/shell/browser/serial/electron_serial_delegate.cc b/shell/browser/serial/electron_serial_delegate.cc
index e7b9e551fe1d5..bd8f5c5a85c6c 100644
--- a/shell/browser/serial/electron_serial_delegate.cc
+++ b/shell/browser/serial/electron_serial_delegate.cc
@@ -116,8 +116,7 @@ SerialChooserController* ElectronSerialDelegate::AddControllerForFrame(
render_frame_host, std::move(filters),
std::move(allowed_bluetooth_service_class_ids), std::move(callback),
web_contents, weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index abf9398da4afc..5d096743d8541 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -87,7 +87,7 @@ void SerialChooserContext::GrantPortPermission(
const url::Origin& origin,
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
- port_info_.insert({port.token, port.Clone()});
+ port_info_.try_emplace(port.token, port.Clone());
if (CanStorePersistentEntry(port)) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
@@ -275,7 +275,7 @@ void SerialChooserContext::SetUpPortManagerConnection(
void SerialChooserContext::OnGetDevices(
std::vector<device::mojom::SerialPortInfoPtr> ports) {
for (auto& port : ports)
- port_info_.insert({port->token, std::move(port)});
+ port_info_.try_emplace(port->token, std::move(port));
is_initialized_ = true;
}
diff --git a/shell/browser/usb/electron_usb_delegate.cc b/shell/browser/usb/electron_usb_delegate.cc
index 3b45ce654d272..1d375a363ed22 100644
--- a/shell/browser/usb/electron_usb_delegate.cc
+++ b/shell/browser/usb/electron_usb_delegate.cc
@@ -299,8 +299,7 @@ UsbChooserController* ElectronUsbDelegate::AddControllerForFrame(
auto controller = std::make_unique<UsbChooserController>(
render_frame_host, std::move(options), std::move(callback), web_contents,
weak_factory_.GetWeakPtr());
- controller_map_.insert(
- std::make_pair(render_frame_host, std::move(controller)));
+ controller_map_.try_emplace(render_frame_host, std::move(controller));
return ControllerForFrame(render_frame_host);
}
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index a40d2c197e6a8..ae4a086f5b3fd 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -105,10 +105,8 @@ void UsbChooserContext::InitDeviceList(
std::vector<device::mojom::UsbDeviceInfoPtr> devices) {
for (auto& device_info : devices) {
DCHECK(device_info);
- if (ShouldExposeDevice(*device_info)) {
- devices_.insert(
- std::make_pair(device_info->guid, std::move(device_info)));
- }
+ if (ShouldExposeDevice(*device_info))
+ devices_.try_emplace(device_info->guid, std::move(device_info));
}
is_initialized_ = true;
@@ -289,7 +287,7 @@ void UsbChooserContext::OnDeviceAdded(
DCHECK(!devices_.contains(device_info->guid));
if (!ShouldExposeDevice(*device_info))
return;
- devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
+ devices_.try_emplace(device_info->guid, device_info->Clone());
// Notify all observers.
for (auto& observer : device_observer_list_)
| diff --git a/shell/browser/electron_autofill_driver_factory.cc b/shell/browser/electron_autofill_driver_factory.cc
index b2a68d4ec036a..84631924d09f7 100644
--- a/shell/browser/electron_autofill_driver_factory.cc
+++ b/shell/browser/electron_autofill_driver_factory.cc
@@ -94,8 +94,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
void AutofillDriverFactory::AddDriverForFrame(
content::RenderFrameHost* render_frame_host,
CreationCallback factory_method) {
- auto insertion_result =
- driver_map_.insert(std::make_pair(render_frame_host, nullptr));
+ auto insertion_result = driver_map_.try_emplace(render_frame_host, nullptr);
// This can be called twice for the key representing the main frame.
if (insertion_result.second) {
insertion_result.first->second = std::move(factory_method).Run();
diff --git a/shell/browser/file_system_access/file_system_access_permission_context.cc b/shell/browser/file_system_access/file_system_access_permission_context.cc
index dad1d9466e6b1..1fb8c1d4a57aa 100644
--- a/shell/browser/file_system_access/file_system_access_permission_context.cc
+++ b/shell/browser/file_system_access/file_system_access_permission_context.cc
@@ -746,7 +746,7 @@ void FileSystemAccessPermissionContext::SetLastPickedDirectory(
base::Value::Dict dict;
dict.Set(GenerateLastPickedDirectoryKey(id), std::move(entry));
MaybeEvictEntries(dict);
+ id_pathinfo_map_.try_emplace(origin, std::move(dict));
diff --git a/shell/browser/hid/electron_hid_delegate.cc b/shell/browser/hid/electron_hid_delegate.cc
index d23760d130b92..aea69296dbfa2 100644
--- a/shell/browser/hid/electron_hid_delegate.cc
+++ b/shell/browser/hid/electron_hid_delegate.cc
@@ -241,8 +241,7 @@ HidChooserController* ElectronHidDelegate::AddControllerForFrame(
auto controller = std::make_unique<HidChooserController>(
render_frame_host, std::move(filters), std::move(exclusion_filters),
std::move(callback), web_contents, weak_factory_.GetWeakPtr());
diff --git a/shell/browser/hid/hid_chooser_context.cc b/shell/browser/hid/hid_chooser_context.cc
index 2fb733cfafdc3..e135dd1c762e5 100644
--- a/shell/browser/hid/hid_chooser_context.cc
+++ b/shell/browser/hid/hid_chooser_context.cc
@@ -307,7 +307,7 @@ void HidChooserContext::SetUpHidManagerConnection(
void HidChooserContext::InitDeviceList(
std::vector<device::mojom::HidDeviceInfoPtr> devices) {
for (auto& device : devices)
+ devices_.try_emplace(device->guid, std::move(device));
diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc
index cee7c0f756e42..572e5e4ae6ded 100644
--- a/shell/browser/net/proxying_url_loader_factory.cc
+++ b/shell/browser/net/proxying_url_loader_factory.cc
@@ -883,9 +883,9 @@ void ProxyingURLLoaderFactory::OnLoaderForCorsPreflightCreated(
// sending request headers is very difficult.
const uint64_t web_request_id = ++(*request_id_generator_);
- auto result = requests_.insert(std::make_pair(
web_request_id, std::make_unique<InProgressRequest>(
- this, web_request_id, frame_routing_id_, request)));
result.first->second->OnLoaderCreated(std::move(receiver));
result.first->second->Restart();
diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm
index a90842f096163..2408fbd98cab0 100644
--- a/shell/browser/notifications/mac/cocoa_notification.mm
+++ b/shell/browser/notifications/mac/cocoa_notification.mm
@@ -93,8 +93,8 @@
actionWithIdentifier:actionIdentifier
title:base::SysUTF16ToNSString(action.text)];
[additionalActions addObject:notificationAction];
- std::make_pair(base::SysNSStringToUTF8(actionIdentifier), i));
+ additional_action_indices_.try_emplace(
+ base::SysNSStringToUTF8(actionIdentifier), i);
}
}
i++;
diff --git a/shell/browser/serial/electron_serial_delegate.cc b/shell/browser/serial/electron_serial_delegate.cc
index e7b9e551fe1d5..bd8f5c5a85c6c 100644
--- a/shell/browser/serial/electron_serial_delegate.cc
+++ b/shell/browser/serial/electron_serial_delegate.cc
@@ -116,8 +116,7 @@ SerialChooserController* ElectronSerialDelegate::AddControllerForFrame(
render_frame_host, std::move(filters),
std::move(allowed_bluetooth_service_class_ids), std::move(callback),
web_contents, weak_factory_.GetWeakPtr());
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index abf9398da4afc..5d096743d8541 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -87,7 +87,7 @@ void SerialChooserContext::GrantPortPermission(
const url::Origin& origin,
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
- port_info_.insert({port.token, port.Clone()});
+ port_info_.try_emplace(port.token, port.Clone());
if (CanStorePersistentEntry(port)) {
auto* permission_manager = static_cast<ElectronPermissionManager*>(
@@ -275,7 +275,7 @@ void SerialChooserContext::SetUpPortManagerConnection(
void SerialChooserContext::OnGetDevices(
std::vector<device::mojom::SerialPortInfoPtr> ports) {
for (auto& port : ports)
- port_info_.insert({port->token, std::move(port)});
+ port_info_.try_emplace(port->token, std::move(port));
diff --git a/shell/browser/usb/electron_usb_delegate.cc b/shell/browser/usb/electron_usb_delegate.cc
index 3b45ce654d272..1d375a363ed22 100644
--- a/shell/browser/usb/electron_usb_delegate.cc
+++ b/shell/browser/usb/electron_usb_delegate.cc
@@ -299,8 +299,7 @@ UsbChooserController* ElectronUsbDelegate::AddControllerForFrame(
auto controller = std::make_unique<UsbChooserController>(
render_frame_host, std::move(options), std::move(callback), web_contents,
weak_factory_.GetWeakPtr());
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index a40d2c197e6a8..ae4a086f5b3fd 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -105,10 +105,8 @@ void UsbChooserContext::InitDeviceList(
std::vector<device::mojom::UsbDeviceInfoPtr> devices) {
for (auto& device_info : devices) {
DCHECK(device_info);
- devices_.insert(
+ if (ShouldExposeDevice(*device_info))
+ devices_.try_emplace(device_info->guid, std::move(device_info));
@@ -289,7 +287,7 @@ void UsbChooserContext::OnDeviceAdded(
DCHECK(!devices_.contains(device_info->guid));
if (!ShouldExposeDevice(*device_info))
return;
- devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
// Notify all observers.
for (auto& observer : device_observer_list_) | [
"- id_pathinfo_map_.insert(std::make_pair(origin, std::move(dict)));",
"- devices_.insert({device->guid, std::move(device)});",
"+ auto result = requests_.try_emplace(",
"+ this, web_request_id, frame_routing_id_, request));",
"- additional_action_indices_.insert(",
"- if (ShouldExposeDevice(*device_info)) {",
"- std::make_pair(device_info->guid, std::move(device_info)));",
"- }",
"+ devices_.try_emplace(device_info->guid, device_info->Clone());"
] | [
22,
49,
63,
66,
78,
143,
145,
146,
157
] | {
"additions": 15,
"author": "ckerr",
"deletions": 21,
"html_url": "https://github.com/electron/electron/pull/46761",
"issue_id": 46761,
"merged_at": "2025-04-25T18:11:54Z",
"omission_probability": 0.1,
"pr_number": 46761,
"repo": "electron/electron",
"title": "refactor: use `std::map::try_emplace()` over `std::map::insert()`",
"total_changes": 36
} |
547 | diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
namespace electron {
-namespace {
-
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
-}
-
-} // namespace
-
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
break;
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
break;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
break;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
break;
}
+
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- }
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
}
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
+ }
+}
+
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
}
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
- for (const auto& [device_id, device_name] : device_map_)
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
}
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
namespace electron {
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron
| diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
-namespace {
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
-}
-} // namespace
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
+ // set a flag to ignore devices - the second time this state fires
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
+ if (device_id_to_name_map_.empty()) {
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
- }
+ }
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron | [
"- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);",
"+ // The first time this state fires is due to a rescan triggering so we",
"+ // we are now safe to pick a device.",
"- if (device_map_.empty()) {",
"- // If the list of bluetooth devices is currently being generated don't fire",
"+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,",
"+}",
"- for (const auto& [device_id, device_name] : device_map_)",
"+#include \"base/memory/weak_ptr.h\"",
"+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;"
] | [
15,
47,
49,
68,
82,
106,
116,
133,
152,
169
] | {
"additions": 42,
"author": "trop[bot]",
"deletions": 40,
"html_url": "https://github.com/electron/electron/pull/46783",
"issue_id": 46783,
"merged_at": "2025-04-25T20:01:20Z",
"omission_probability": 0.1,
"pr_number": 46783,
"repo": "electron/electron",
"title": "fix: bluetooth crash in `select-bluetooth-device` event",
"total_changes": 82
} |
548 | diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
namespace electron {
-namespace {
-
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
-}
-
-} // namespace
-
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
break;
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
break;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
break;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
break;
}
+
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- }
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
}
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
+ }
+}
+
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
}
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
- for (const auto& [device_id, device_name] : device_map_)
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
}
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
namespace electron {
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron
| diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
-namespace {
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
-}
-} // namespace
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
} else {
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ if (refreshing_)
return;
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
- }
+ }
+}
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron | [
"- } else {",
"- auto it = device_map_.begin();",
"+ // Don't fire an event during refresh.",
"- for (const auto& [device_id, device_name] : device_map_)",
"+ vec.reserve(device_id_to_name_map_.size());",
"+#include \"base/memory/weak_ptr.h\"",
"+ void OnDeviceChosen(const std::string& device_id);"
] | [
14,
72,
84,
133,
134,
152,
164
] | {
"additions": 42,
"author": "codebytere",
"deletions": 40,
"html_url": "https://github.com/electron/electron/pull/46745",
"issue_id": 46745,
"merged_at": "2025-04-25T15:26:19Z",
"omission_probability": 0.1,
"pr_number": 46745,
"repo": "electron/electron",
"title": "fix: bluetooth crash in `select-bluetooth-device` event",
"total_changes": 82
} |
549 | diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
namespace electron {
-namespace {
-
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
-}
-
-} // namespace
-
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
break;
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
break;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
break;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
break;
}
+
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- }
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
}
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
+ }
+}
+
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
}
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
- for (const auto& [device_id, device_name] : device_map_)
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
}
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
namespace electron {
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron
| diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
-namespace {
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
-}
-} // namespace
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- if (!prevent_default) {
+ if (!prevent_default)
- }
+ }
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron | [
"- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);",
"- // If emit not implemented select first device that matches the filters",
"- // provided.",
"+}",
"- for (const auto& [device_id, device_name] : device_map_)",
"- std::map<std::string, std::u16string> device_map_;"
] | [
89,
109,
110,
116,
133,
168
] | {
"additions": 42,
"author": "trop[bot]",
"deletions": 40,
"html_url": "https://github.com/electron/electron/pull/46784",
"issue_id": 46784,
"merged_at": "2025-04-25T20:01:12Z",
"omission_probability": 0.1,
"pr_number": 46784,
"repo": "electron/electron",
"title": "fix: bluetooth crash in `select-bluetooth-device` event",
"total_changes": 82
} |
550 | diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
namespace electron {
-namespace {
-
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
-}
-
-} // namespace
-
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
break;
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
break;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
break;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
break;
}
+
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, "");
} else {
- auto it = device_map_.begin();
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- }
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
}
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
- }
+ }
+}
+
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
}
}
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
- for (const auto& [device_id, device_name] : device_map_)
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
}
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
namespace electron {
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
- std::map<std::string, std::u16string> device_map_;
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron
| diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc
index 0c8708a91a484..23f39e1a3160f 100644
--- a/shell/browser/lib/bluetooth_chooser.cc
+++ b/shell/browser/lib/bluetooth_chooser.cc
@@ -25,19 +25,6 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> {
-namespace {
-void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
- const std::string& device_id) {
- if (device_id.empty()) {
- handler.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
- } else {
- handler.Run(content::BluetoothChooserEvent::SELECTED, device_id);
-} // namespace
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents), event_handler_(event_handler) {}
@@ -49,14 +36,13 @@ BluetoothChooser::~BluetoothChooser() {
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
case AdapterPresence::ABSENT:
+ NOTREACHED();
case AdapterPresence::POWERED_OFF:
- // Chrome currently directs the user to system preferences
- // to grant bluetooth permission for this case, should we
- // do something similar ?
- // https://chromium-review.googlesource.com/c/chromium/src/+/2617129
- case AdapterPresence::UNAUTHORIZED:
+ case AdapterPresence::UNAUTHORIZED:
+ event_handler_.Run(content::BluetoothChooserEvent::DENIED_PERMISSION, "");
+ break;
case AdapterPresence::POWERED_ON:
rescan_ = true;
@@ -74,25 +60,27 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
refreshing_ = false;
idle_state = true;
+ // The first time this state fires is due to a rescan triggering so we
+ // set a flag to ignore devices - the second time this state fires
+ // we are now safe to pick a device.
case DiscoveryState::DISCOVERING:
- // The first time this state fires is due to a rescan triggering so set a
- // flag to ignore devices
if (rescan_ && !refreshing_) {
refreshing_ = true;
} else {
- // The second time this state fires we are now safe to pick a device
refreshing_ = false;
}
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
if (!prevent_default && idle_state) {
- if (device_map_.empty()) {
+ if (device_id_to_name_map_.empty()) {
} else {
+ auto it = device_id_to_name_map_.begin();
auto device_id = it->first;
}
@@ -105,38 +93,47 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) {
- if (refreshing_) {
- // If the list of bluetooth devices is currently being generated don't fire
- // an event
+ // Don't fire an event during refresh.
+ if (refreshing_)
return;
- auto [iter, changed] = device_map_.try_emplace(device_id, device_name);
+ // Emit a select-bluetooth-device handler to allow for user to listen for
+ // bluetooth device found. If there's no listener in place, then select the
+ // first device that matches the filters provided.
+ auto [iter, changed] =
+ device_id_to_name_map_.try_emplace(device_id, device_name);
if (!changed && should_update_name) {
iter->second = device_name;
changed = true;
if (changed) {
- // Emit a select-bluetooth-device handler to allow for user to listen for
- // bluetooth device found.
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", GetDeviceList(),
- base::BindOnce(&OnDeviceChosen, event_handler_));
+ base::BindOnce(&BluetoothChooser::OnDeviceChosen,
+ weak_ptr_factory_.GetWeakPtr()));
- // If emit not implemented select first device that matches the filters
- // provided.
- if (!prevent_default) {
+ if (!prevent_default)
- }
+}
+void BluetoothChooser::OnDeviceChosen(const std::string& device_id) {
+ if (event_handler_.is_null())
+ return;
+ if (device_id.empty()) {
+ event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, device_id);
+ } else {
+ event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id);
std::vector<electron::BluetoothChooser::DeviceInfo>
BluetoothChooser::GetDeviceList() {
std::vector<electron::BluetoothChooser::DeviceInfo> vec;
- vec.reserve(device_map_.size());
- for (const auto& [device_id, device_name] : device_map_)
+ vec.reserve(device_id_to_name_map_.size());
+ for (const auto& [device_id, device_name] : device_id_to_name_map_)
vec.emplace_back(device_id, device_name);
return vec;
diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h
index 19f7eac838911..5b377e5e1b696 100644
--- a/shell/browser/lib/bluetooth_chooser.h
+++ b/shell/browser/lib/bluetooth_chooser.h
@@ -5,13 +5,14 @@
#ifndef ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
#define ELECTRON_SHELL_BROWSER_LIB_BLUETOOTH_CHOOSER_H_
-#include <map>
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/public/browser/bluetooth_chooser.h"
#include "shell/browser/api/electron_api_web_contents.h"
+#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
@@ -39,14 +40,18 @@ class BluetoothChooser : public content::BluetoothChooser {
bool is_gatt_connected,
bool is_paired,
int signal_strength_level) override;
+ void OnDeviceChosen(const std::string& device_id);
std::vector<DeviceInfo> GetDeviceList();
private:
+ absl::flat_hash_map<std::string, std::u16string> device_id_to_name_map_;
raw_ptr<api::WebContents> api_web_contents_;
EventHandler event_handler_;
bool refreshing_ = false;
bool rescan_ = false;
+ base::WeakPtrFactory<BluetoothChooser> weak_ptr_factory_{this};
};
} // namespace electron | [
"-}",
"- auto it = device_map_.begin();",
"+ }",
"- std::map<std::string, std::u16string> device_map_;"
] | [
17,
72,
115,
168
] | {
"additions": 42,
"author": "trop[bot]",
"deletions": 40,
"html_url": "https://github.com/electron/electron/pull/46782",
"issue_id": 46782,
"merged_at": "2025-04-25T18:28:29Z",
"omission_probability": 0.1,
"pr_number": 46782,
"repo": "electron/electron",
"title": "fix: bluetooth crash in `select-bluetooth-device` event",
"total_changes": 82
} |
551 | diff --git a/patches/chromium/fix_activate_background_material_on_windows.patch b/patches/chromium/fix_activate_background_material_on_windows.patch
index 96ed54b14c4c6..1b922f3abb069 100644
--- a/patches/chromium/fix_activate_background_material_on_windows.patch
+++ b/patches/chromium/fix_activate_background_material_on_windows.patch
@@ -14,7 +14,7 @@ This patch likely can't be upstreamed as-is, as Chromium doesn't have
this use case in mind currently.
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
-index 29829e282edfa8821bd366a9e9a3755d7f3f8643..9feff09aa83eb88460dce786ab2514f0a9b21c6e 100644
+index 29829e282edfa8821bd366a9e9a3755d7f3f8643..661864ab6aad78a721ac921ae778c40085cdc23e 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -952,13 +952,13 @@ void HWNDMessageHandler::FrameTypeChanged() {
@@ -33,6 +33,15 @@ index 29829e282edfa8821bd366a9e9a3755d7f3f8643..9feff09aa83eb88460dce786ab2514f0
}
void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon,
+@@ -1755,7 +1755,7 @@ void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) {
+ if (delegate_->HasNonClientView() && !active &&
+ thread_id != GetCurrentThreadId()) {
+ // Update the native frame if it is rendering the non-client area.
+- if (HasSystemFrame()) {
++ if (is_translucent_ || HasSystemFrame()) {
+ DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0);
+ }
+ }
@@ -2356,17 +2356,18 @@ LRESULT HWNDMessageHandler::OnNCActivate(UINT message,
delegate_->SchedulePaint();
}
| diff --git a/patches/chromium/fix_activate_background_material_on_windows.patch b/patches/chromium/fix_activate_background_material_on_windows.patch
index 96ed54b14c4c6..1b922f3abb069 100644
--- a/patches/chromium/fix_activate_background_material_on_windows.patch
+++ b/patches/chromium/fix_activate_background_material_on_windows.patch
@@ -14,7 +14,7 @@ This patch likely can't be upstreamed as-is, as Chromium doesn't have
this use case in mind currently.
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
-index 29829e282edfa8821bd366a9e9a3755d7f3f8643..9feff09aa83eb88460dce786ab2514f0a9b21c6e 100644
+index 29829e282edfa8821bd366a9e9a3755d7f3f8643..661864ab6aad78a721ac921ae778c40085cdc23e 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -952,13 +952,13 @@ void HWNDMessageHandler::FrameTypeChanged() {
@@ -33,6 +33,15 @@ index 29829e282edfa8821bd366a9e9a3755d7f3f8643..9feff09aa83eb88460dce786ab2514f0
}
void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon,
+@@ -1755,7 +1755,7 @@ void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) {
+ if (delegate_->HasNonClientView() && !active &&
+- if (HasSystemFrame()) {
++ if (is_translucent_ || HasSystemFrame()) {
+ DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0);
+ }
+ }
@@ -2356,17 +2356,18 @@ LRESULT HWNDMessageHandler::OnNCActivate(UINT message,
delegate_->SchedulePaint();
} | [
"+ thread_id != GetCurrentThreadId()) {",
"+ // Update the native frame if it is rendering the non-client area."
] | [
19,
20
] | {
"additions": 10,
"author": "codebytere",
"deletions": 1,
"html_url": "https://github.com/electron/electron/pull/46657",
"issue_id": 46657,
"merged_at": "2025-04-17T18:34:45Z",
"omission_probability": 0.1,
"pr_number": 46657,
"repo": "electron/electron",
"title": "fix: `backgroundMaterial` on initial activate",
"total_changes": 11
} |
552 | diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..36d63279c9562 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4014,6 +4014,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
+
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..6793733db9518 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -710,6 +710,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ })`);
+ // Reload the webview and the main process will not crash.
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ })`);
+ });
});
describe('<webview>.goForward()', () => {
| diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..36d63279c9562 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4014,6 +4014,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..6793733db9518 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -710,6 +710,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ // Create a crash in the rendering process of a webview
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ // Reload the webview and the main process will not crash.
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ });
});
describe('<webview>.goForward()', () => { | [
"+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl",
"+ it('does not crash when renderer process crashes', async function () {",
"+ nodeintegration: 'on',",
"+ });"
] | [
9,
40,
44,
47
] | {
"additions": 31,
"author": "wujinli",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46735",
"issue_id": 46735,
"merged_at": "2025-04-25T08:10:28Z",
"omission_probability": 0.1,
"pr_number": 46735,
"repo": "electron/electron",
"title": "fix: crash when renderer process crashes while webview is reloading",
"total_changes": 31
} |
553 | diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..38827474a9527 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4016,6 +4016,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
+
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..6793733db9518 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -710,6 +710,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ })`);
+ // Reload the webview and the main process will not crash.
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ })`);
+ });
});
describe('<webview>.goForward()', () => {
| diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..38827474a9527 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4016,6 +4016,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..6793733db9518 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -710,6 +710,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ // Reload the webview and the main process will not crash.
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ })
+ });
});
describe('<webview>.goForward()', () => { | [
"+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {",
"+ // Create a crash in the rendering process of a webview",
"+ resolve()"
] | [
8,
48,
57
] | {
"additions": 31,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46768",
"issue_id": 46768,
"merged_at": "2025-04-25T16:01:42Z",
"omission_probability": 0.1,
"pr_number": 46768,
"repo": "electron/electron",
"title": "fix: crash when renderer process crashes while webview is reloading",
"total_changes": 31
} |
554 | diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 16a33ebafc23e..39c56e0ec441f 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
+
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // translucent windows are assigned a clear background color. This causes
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // Ref:
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if (!transparent()) {
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ }
+ if (![window isOpaque]) {
+ [window setOpaque:YES];
+ }
+ }
+}
+
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options,
| diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 16a33ebafc23e..39c56e0ec441f 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // translucent windows are assigned a clear background color. This causes
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // Ref:
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ if (![window isOpaque]) {
+ [window setOpaque:YES];
+ }
+}
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options, | [
"+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();",
"+ if (!transparent()) {"
] | [
23,
32
] | {
"additions": 23,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46772",
"issue_id": 46772,
"merged_at": "2025-04-25T15:35:32Z",
"omission_probability": 0.1,
"pr_number": 46772,
"repo": "electron/electron",
"title": "fix: vibrancy window border",
"total_changes": 23
} |
555 | diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 8bb7d5b51fa43..a895f26446213 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
+
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // translucent windows are assigned a clear background color. This causes
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // Ref:
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if (!transparent()) {
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ }
+ if (![window isOpaque]) {
+ [window setOpaque:YES];
+ }
+ }
+}
+
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options,
| diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 8bb7d5b51fa43..a895f26446213 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if (!transparent()) {
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ if (![window isOpaque]) {
+ }
+}
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options, | [
"+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();",
"+ // translucent windows are assigned a clear background color. This causes",
"+ // Ref:",
"+ [window setOpaque:YES];"
] | [
23,
26,
30,
37
] | {
"additions": 23,
"author": "clavin",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46648",
"issue_id": 46648,
"merged_at": "2025-04-25T09:42:48Z",
"omission_probability": 0.1,
"pr_number": 46648,
"repo": "electron/electron",
"title": "fix: vibrancy window border",
"total_changes": 23
} |
556 | diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 8bb7d5b51fa43..a895f26446213 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
+
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // translucent windows are assigned a clear background color. This causes
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // Ref:
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if (!transparent()) {
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ }
+ if (![window isOpaque]) {
+ [window setOpaque:YES];
+ }
+ }
+}
+
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options,
| diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
bool CanMaximize() const override;
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override;
+ void OnWidgetInitialized() override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 8bb7d5b51fa43..a895f26446213 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
return std::nullopt;
}
+void NativeWindowMac::OnWidgetInitialized() {
+ // |window_| is not yet assigned when this function is called, so we need to
+ // get the window from the widget.
+ NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
+ // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+ // translucent windows are assigned a clear background color. This causes
+ // undesirable side effects, such as a window with vibrancy losing its natural
+ // system border highlight. We undo that behavior here.
+ //
+ // Ref:
+ // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+ if (!transparent()) {
+ if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+ [window setBackgroundColor:NSColor.windowBackgroundColor];
+ if (![window isOpaque]) {
+ [window setOpaque:YES];
+}
// static
std::unique_ptr<NativeWindow> NativeWindow::Create(
const gin_helper::Dictionary& options, | [
"+ }"
] | [
39
] | {
"additions": 23,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46771",
"issue_id": 46771,
"merged_at": "2025-04-25T15:31:13Z",
"omission_probability": 0.1,
"pr_number": 46771,
"repo": "electron/electron",
"title": "fix: vibrancy window border",
"total_changes": 23
} |
557 | diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index a7983dd39c8bc..04b7651f3a0bb 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -31,6 +31,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/options_switches.h"
#if defined(TOOLKIT_VIEWS)
@@ -72,8 +73,9 @@ namespace {
#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate,
+ const base::span<const uint8_t> val) {
+ auto buffer = electron::Buffer::Copy(isolate, val);
if (buffer.IsEmpty())
return v8::Null(isolate);
else
@@ -348,8 +350,8 @@ void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
messages_callback_map_[message].Run(
- ToBuffer(isolate, static_cast<void*>(&w_param), sizeof(WPARAM)),
- ToBuffer(isolate, static_cast<void*>(&l_param), sizeof(LPARAM)));
+ ToBuffer(isolate, base::byte_span_from_ref(w_param)),
+ ToBuffer(isolate, base::byte_span_from_ref(l_param)));
}
}
#endif
@@ -786,7 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
// landed
NativeWindowHandle handle = window_->GetNativeWindowHandle();
- return ToBuffer(isolate(), &handle, sizeof(handle));
+ return ToBuffer(isolate(), base::byte_span_from_ref(handle));
}
#endif
diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc
index f2cc6a9f9bb3d..862c56217bf2a 100644
--- a/shell/browser/api/electron_api_data_pipe_holder.cc
+++ b/shell/browser/api/electron_api_data_pipe_holder.cc
@@ -17,6 +17,7 @@
#include "net/base/net_errors.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/key_weak_map.h"
+#include "shell/common/node_util.h"
#include "shell/common/node_includes.h"
@@ -114,8 +115,7 @@ class DataPipeReader {
// inside the sandbox
v8::HandleScope handle_scope(promise_.isolate());
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(promise_.isolate(), &buffer_.front(), buffer_.size())
- .ToLocalChecked();
+ electron::Buffer::Copy(promise_.isolate(), buffer_).ToLocalChecked();
promise_.Resolve(buffer);
// Destroy data pipe.
diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc
index f9ecdd0734fbb..e815ec06ac18a 100644
--- a/shell/browser/api/electron_api_safe_storage.cc
+++ b/shell/browser/api/electron_api_safe_storage.cc
@@ -11,6 +11,7 @@
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
namespace {
@@ -72,8 +73,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
return {};
}
- return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
- .ToLocalChecked();
+ return electron::Buffer::Copy(isolate, ciphertext).ToLocalChecked();
}
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..9a3405834253b 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -2979,9 +2979,7 @@ void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
v8::Local<v8::Context>::New(isolate, promise.GetContext()));
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<const char*>(data->front()),
- data->size())
- .ToLocalChecked();
+ electron::Buffer::Copy(isolate, *data).ToLocalChecked();
promise.Resolve(buffer);
}
diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc
index aad1d4eece441..84f9dd2a6cd7d 100644
--- a/shell/common/api/electron_api_clipboard.cc
+++ b/shell/common/api/electron_api_clipboard.cc
@@ -13,6 +13,7 @@
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/process_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
@@ -99,8 +100,7 @@ std::string Clipboard::Read(const std::string& format_string) {
v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
gin_helper::Arguments* args) {
std::string data = Read(format_string);
- return node::Buffer::Copy(args->isolate(), data.data(), data.length())
- .ToLocalChecked();
+ return electron::Buffer::Copy(args->isolate(), data).ToLocalChecked();
}
void Clipboard::WriteBuffer(const std::string& format,
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index d16023390d4ad..da34a3158c3fe 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -122,6 +122,10 @@ base::win::ScopedGDIObject<HICON> ReadICOFromPath(int size,
}
#endif
+[[nodiscard]] v8::Local<v8::Value> NewEmptyBuffer(v8::Isolate* isolate) {
+ return node::Buffer::New(isolate, 0).ToLocalChecked();
+}
+
} // namespace
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
@@ -226,57 +230,48 @@ HICON NativeImage::GetHICON(int size) {
#endif
v8::Local<v8::Value> NativeImage::ToPNG(gin::Arguments* args) {
+ v8::Isolate* const isolate = args->isolate();
float scale_factor = GetScaleFactorFromOptions(args);
if (scale_factor == 1.0f) {
// Use raw 1x PNG bytes when available
- scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
- if (png->size() > 0) {
- const char* data = reinterpret_cast<const char*>(png->front());
- size_t size = png->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
- }
+ const scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
+ const base::span<const uint8_t> png_span = *png;
+ if (!png_span.empty())
+ return electron::Buffer::Copy(isolate, png_span).ToLocalChecked();
}
const SkBitmap bitmap =
image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- std::optional<std::vector<uint8_t>> encoded =
+ const std::optional<std::vector<uint8_t>> encoded =
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false);
if (!encoded.has_value())
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- const char* data = reinterpret_cast<char*>(encoded->data());
- size_t size = encoded->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
+ return NewEmptyBuffer(isolate);
+
+ return electron::Buffer::Copy(isolate, *encoded).ToLocalChecked();
}
v8::Local<v8::Value> NativeImage::ToBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ v8::Isolate* const isolate = args->isolate();
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
+ const float scale = GetScaleFactorFromOptions(args);
+ const auto src = image_.AsImageSkia().GetRepresentation(scale).GetBitmap();
- SkImageInfo info =
- SkImageInfo::MakeN32Premul(bitmap.width(), bitmap.height());
+ const auto dst_info = SkImageInfo::MakeN32Premul(src.dimensions());
+ const size_t dst_n_bytes = dst_info.computeMinByteSize();
+ auto dst_buf = v8::ArrayBuffer::New(isolate, dst_n_bytes);
- auto array_buffer =
- v8::ArrayBuffer::New(args->isolate(), info.computeMinByteSize());
- if (bitmap.readPixels(info, array_buffer->Data(), info.minRowBytes(), 0, 0)) {
- return node::Buffer::New(args->isolate(), array_buffer, 0,
- info.computeMinByteSize())
- .ToLocalChecked();
- }
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
+ if (!src.readPixels(dst_info, dst_buf->Data(), dst_info.minRowBytes(), 0, 0))
+ return NewEmptyBuffer(isolate);
+ return node::Buffer::New(isolate, dst_buf, 0, dst_n_bytes).ToLocalChecked();
}
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
- std::optional<std::vector<uint8_t>> encoded_image =
+ const std::optional<std::vector<uint8_t>> encoded_image =
gfx::JPEG1xEncodedDataFromImage(image_, quality);
- if (!encoded_image.has_value())
- return node::Buffer::New(isolate, 0).ToLocalChecked();
- return node::Buffer::Copy(
- isolate, reinterpret_cast<const char*>(&encoded_image->front()),
- encoded_image->size())
- .ToLocalChecked();
+ if (!encoded_image)
+ return NewEmptyBuffer(isolate);
+ return electron::Buffer::Copy(isolate, *encoded_image).ToLocalChecked();
}
std::string NativeImage::ToDataURL(gin::Arguments* args) {
@@ -301,17 +296,17 @@ v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetNativeHandle(
gin_helper::ErrorThrower thrower) {
+ v8::Isolate* const isolate = thrower.isolate();
#if BUILDFLAG(IS_MAC)
if (IsEmpty())
- return node::Buffer::New(thrower.isolate(), 0).ToLocalChecked();
+ return NewEmptyBuffer(isolate);
NSImage* ptr = image_.AsNSImage();
- return node::Buffer::Copy(thrower.isolate(), reinterpret_cast<char*>(ptr),
- sizeof(void*))
+ return electron::Buffer::Copy(isolate, base::byte_span_from_ref(ptr))
.ToLocalChecked();
#else
thrower.ThrowError("Not implemented");
- return v8::Undefined(thrower.isolate());
+ return v8::Undefined(isolate);
#endif
}
@@ -402,7 +397,7 @@ void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
GURL url;
if (options.Get("buffer", &buffer) && node::Buffer::HasInstance(buffer)) {
skia_rep_added = electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
} else if (options.Get("dataURL", &url)) {
std::string mime_type, charset, data;
@@ -511,7 +506,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
auto info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
auto size_bytes = info.computeMinByteSize();
- const auto buffer_data = electron::util::as_byte_span(buffer);
+ const auto buffer_data = electron::Buffer::as_byte_span(buffer);
if (size_bytes != buffer_data.size()) {
thrower.ThrowError("invalid buffer size");
return {};
@@ -552,7 +547,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
gfx::ImageSkia image_skia;
electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
return Create(args->isolate(), gfx::Image(image_skia));
}
diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc
index bf67315c5b09c..0bf04cff8d135 100644
--- a/shell/common/gin_converters/net_converter.cc
+++ b/shell/common/gin_converters/net_converter.cc
@@ -34,6 +34,7 @@
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/v8_util.h"
namespace gin {
@@ -524,11 +525,11 @@ v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
}
case network::mojom::DataElement::Tag::kBytes: {
upload_data.Set("type", "rawData");
- const auto& bytes = element.As<network::DataElementBytes>().bytes();
- const char* data = reinterpret_cast<const char*>(bytes.data());
upload_data.Set(
"bytes",
- node::Buffer::Copy(isolate, data, bytes.size()).ToLocalChecked());
+ electron::Buffer::Copy(
+ isolate, element.As<network::DataElementBytes>().bytes())
+ .ToLocalChecked());
break;
}
case network::mojom::DataElement::Tag::kDataPipe: {
diff --git a/shell/common/gin_converters/osr_converter.cc b/shell/common/gin_converters/osr_converter.cc
index 7ccc1d71ec883..afa868ae8a526 100644
--- a/shell/common/gin_converters/osr_converter.cc
+++ b/shell/common/gin_converters/osr_converter.cc
@@ -111,12 +111,10 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
dict.Set("metadata", ConvertToV8(isolate, metadata));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- auto handle_buf = node::Buffer::Copy(
- isolate,
- reinterpret_cast<char*>(
- const_cast<uintptr_t*>(&val.shared_texture_handle)),
- sizeof(val.shared_texture_handle));
- dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked());
+ dict.Set("sharedTextureHandle",
+ electron::Buffer::Copy(
+ isolate, base::byte_span_from_ref(val.shared_texture_handle))
+ .ToLocalChecked());
#elif BUILDFLAG(IS_LINUX)
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
diff --git a/shell/common/node_util.cc b/shell/common/node_util.cc
index 6d18f077b61d4..055670cc4ddfb 100644
--- a/shell/common/node_util.cc
+++ b/shell/common/node_util.cc
@@ -75,16 +75,6 @@ void EmitWarning(v8::Isolate* isolate,
emit_warning.Run(warning_msg, warning_type, "");
}
-// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
-// test, so let's isolate the unsafe API use into this function. Instead of
-// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
-// code should prefer to use spans returned by this function.
-base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
- auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
- const auto size = node::Buffer::Length(node_buffer);
- return UNSAFE_BUFFERS(base::span{data, size});
-}
-
node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::IsolateData* isolate_data,
v8::Local<v8::Context> context,
@@ -133,3 +123,28 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
}
} // namespace electron::util
+
+namespace electron::Buffer {
+
+// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
+// test, so let's isolate the unsafe API use into this function. Instead of
+// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
+// code should prefer to use spans returned by this function.
+base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
+ auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
+ const auto size = node::Buffer::Length(node_buffer);
+ return UNSAFE_BUFFERS(base::span{data, size});
+}
+
+v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ const base::span<const char> data) {
+ // SAFETY: span-friendly version of node::Buffer::Copy()
+ return UNSAFE_BUFFERS(node::Buffer::Copy(isolate, data.data(), data.size()));
+}
+
+v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ const base::span<const uint8_t> data) {
+ return Copy(isolate, base::as_chars(data));
+}
+
+} // namespace electron::Buffer
diff --git a/shell/common/node_util.h b/shell/common/node_util.h
index c379d70e8ab9d..36fcfdf940ba4 100644
--- a/shell/common/node_util.h
+++ b/shell/common/node_util.h
@@ -53,11 +53,23 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::EnvironmentFlags::Flags env_flags,
std::string_view process_type = "");
+} // namespace electron::util
+
+namespace electron::Buffer {
+
// Convenience function to view a Node buffer's data as a base::span().
// Analogous to base::as_byte_span()
[[nodiscard]] base::span<uint8_t> as_byte_span(
v8::Local<v8::Value> node_buffer);
-} // namespace electron::util
+// span-friendly version of node::Buffer::Copy()
+[[nodiscard]] v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ base::span<const char> data);
+
+// span-friendly version of node::Buffer::Copy()
+[[nodiscard]] v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ base::span<const uint8_t> data);
+
+} // namespace electron::Buffer
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
| diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index a7983dd39c8bc..04b7651f3a0bb 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -31,6 +31,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/options_switches.h"
#if defined(TOOLKIT_VIEWS)
@@ -72,8 +73,9 @@ namespace {
#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate,
+ auto buffer = electron::Buffer::Copy(isolate, val);
if (buffer.IsEmpty())
return v8::Null(isolate);
else
@@ -348,8 +350,8 @@ void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
messages_callback_map_[message].Run(
- ToBuffer(isolate, static_cast<void*>(&w_param), sizeof(WPARAM)),
- ToBuffer(isolate, static_cast<void*>(&l_param), sizeof(LPARAM)));
+ ToBuffer(isolate, base::byte_span_from_ref(w_param)),
+ ToBuffer(isolate, base::byte_span_from_ref(l_param)));
@@ -786,7 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
// landed
NativeWindowHandle handle = window_->GetNativeWindowHandle();
- return ToBuffer(isolate(), &handle, sizeof(handle));
+ return ToBuffer(isolate(), base::byte_span_from_ref(handle));
diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc
index f2cc6a9f9bb3d..862c56217bf2a 100644
--- a/shell/browser/api/electron_api_data_pipe_holder.cc
+++ b/shell/browser/api/electron_api_data_pipe_holder.cc
@@ -17,6 +17,7 @@
#include "net/base/net_errors.h"
#include "shell/common/key_weak_map.h"
@@ -114,8 +115,7 @@ class DataPipeReader {
// inside the sandbox
v8::HandleScope handle_scope(promise_.isolate());
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(promise_.isolate(), &buffer_.front(), buffer_.size())
- .ToLocalChecked();
+ electron::Buffer::Copy(promise_.isolate(), buffer_).ToLocalChecked();
promise_.Resolve(buffer);
// Destroy data pipe.
diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc
index f9ecdd0734fbb..e815ec06ac18a 100644
--- a/shell/browser/api/electron_api_safe_storage.cc
+++ b/shell/browser/api/electron_api_safe_storage.cc
@@ -11,6 +11,7 @@
#include "shell/common/gin_converters/callback_converter.h"
namespace {
@@ -72,8 +73,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
- return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
+ return electron::Buffer::Copy(isolate, ciphertext).ToLocalChecked();
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..9a3405834253b 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -2979,9 +2979,7 @@ void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
v8::Local<v8::Context>::New(isolate, promise.GetContext()));
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<const char*>(data->front()),
- data->size())
- .ToLocalChecked();
+ electron::Buffer::Copy(isolate, *data).ToLocalChecked();
promise.Resolve(buffer);
diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc
index aad1d4eece441..84f9dd2a6cd7d 100644
--- a/shell/common/api/electron_api_clipboard.cc
+++ b/shell/common/api/electron_api_clipboard.cc
@@ -13,6 +13,7 @@
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/process_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
@@ -99,8 +100,7 @@ std::string Clipboard::Read(const std::string& format_string) {
v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
gin_helper::Arguments* args) {
std::string data = Read(format_string);
- return node::Buffer::Copy(args->isolate(), data.data(), data.length())
+ return electron::Buffer::Copy(args->isolate(), data).ToLocalChecked();
void Clipboard::WriteBuffer(const std::string& format,
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index d16023390d4ad..da34a3158c3fe 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -122,6 +122,10 @@ base::win::ScopedGDIObject<HICON> ReadICOFromPath(int size,
+[[nodiscard]] v8::Local<v8::Value> NewEmptyBuffer(v8::Isolate* isolate) {
+ return node::Buffer::New(isolate, 0).ToLocalChecked();
} // namespace
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
@@ -226,57 +230,48 @@ HICON NativeImage::GetHICON(int size) {
v8::Local<v8::Value> NativeImage::ToPNG(gin::Arguments* args) {
float scale_factor = GetScaleFactorFromOptions(args);
if (scale_factor == 1.0f) {
// Use raw 1x PNG bytes when available
- scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
- const char* data = reinterpret_cast<const char*>(png->front());
- size_t size = png->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
- }
+ const scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
+ const base::span<const uint8_t> png_span = *png;
+ if (!png_span.empty())
+ return electron::Buffer::Copy(isolate, png_span).ToLocalChecked();
const SkBitmap bitmap =
image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- std::optional<std::vector<uint8_t>> encoded =
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false);
if (!encoded.has_value())
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
+ return electron::Buffer::Copy(isolate, *encoded).ToLocalChecked();
v8::Local<v8::Value> NativeImage::ToBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
+ const auto src = image_.AsImageSkia().GetRepresentation(scale).GetBitmap();
- SkImageInfo::MakeN32Premul(bitmap.width(), bitmap.height());
+ const auto dst_info = SkImageInfo::MakeN32Premul(src.dimensions());
+ const size_t dst_n_bytes = dst_info.computeMinByteSize();
+ auto dst_buf = v8::ArrayBuffer::New(isolate, dst_n_bytes);
- if (bitmap.readPixels(info, array_buffer->Data(), info.minRowBytes(), 0, 0)) {
- return node::Buffer::New(args->isolate(), array_buffer, 0,
- info.computeMinByteSize())
- .ToLocalChecked();
- }
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
+ if (!src.readPixels(dst_info, dst_buf->Data(), dst_info.minRowBytes(), 0, 0))
+ return node::Buffer::New(isolate, dst_buf, 0, dst_n_bytes).ToLocalChecked();
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
- std::optional<std::vector<uint8_t>> encoded_image =
+ const std::optional<std::vector<uint8_t>> encoded_image =
gfx::JPEG1xEncodedDataFromImage(image_, quality);
- if (!encoded_image.has_value())
- return node::Buffer::New(isolate, 0).ToLocalChecked();
- return node::Buffer::Copy(
- isolate, reinterpret_cast<const char*>(&encoded_image->front()),
- encoded_image->size())
+ return electron::Buffer::Copy(isolate, *encoded_image).ToLocalChecked();
std::string NativeImage::ToDataURL(gin::Arguments* args) {
@@ -301,17 +296,17 @@ v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetNativeHandle(
gin_helper::ErrorThrower thrower) {
+ v8::Isolate* const isolate = thrower.isolate();
#if BUILDFLAG(IS_MAC)
if (IsEmpty())
- return node::Buffer::New(thrower.isolate(), 0).ToLocalChecked();
NSImage* ptr = image_.AsNSImage();
- return node::Buffer::Copy(thrower.isolate(), reinterpret_cast<char*>(ptr),
- sizeof(void*))
+ return electron::Buffer::Copy(isolate, base::byte_span_from_ref(ptr))
.ToLocalChecked();
#else
thrower.ThrowError("Not implemented");
- return v8::Undefined(thrower.isolate());
+ return v8::Undefined(isolate);
@@ -402,7 +397,7 @@ void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
GURL url;
if (options.Get("buffer", &buffer) && node::Buffer::HasInstance(buffer)) {
skia_rep_added = electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
} else if (options.Get("dataURL", &url)) {
std::string mime_type, charset, data;
@@ -511,7 +506,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
auto info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
auto size_bytes = info.computeMinByteSize();
- const auto buffer_data = electron::util::as_byte_span(buffer);
+ const auto buffer_data = electron::Buffer::as_byte_span(buffer);
if (size_bytes != buffer_data.size()) {
thrower.ThrowError("invalid buffer size");
@@ -552,7 +547,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
gfx::ImageSkia image_skia;
electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
return Create(args->isolate(), gfx::Image(image_skia));
diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc
index bf67315c5b09c..0bf04cff8d135 100644
--- a/shell/common/gin_converters/net_converter.cc
+++ b/shell/common/gin_converters/net_converter.cc
@@ -34,6 +34,7 @@
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/v8_util.h"
namespace gin {
@@ -524,11 +525,11 @@ v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
case network::mojom::DataElement::Tag::kBytes: {
upload_data.Set("type", "rawData");
- const auto& bytes = element.As<network::DataElementBytes>().bytes();
- const char* data = reinterpret_cast<const char*>(bytes.data());
upload_data.Set(
"bytes",
- node::Buffer::Copy(isolate, data, bytes.size()).ToLocalChecked());
+ electron::Buffer::Copy(
+ isolate, element.As<network::DataElementBytes>().bytes())
+ .ToLocalChecked());
break;
case network::mojom::DataElement::Tag::kDataPipe: {
diff --git a/shell/common/gin_converters/osr_converter.cc b/shell/common/gin_converters/osr_converter.cc
index 7ccc1d71ec883..afa868ae8a526 100644
--- a/shell/common/gin_converters/osr_converter.cc
+++ b/shell/common/gin_converters/osr_converter.cc
@@ -111,12 +111,10 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
dict.Set("metadata", ConvertToV8(isolate, metadata));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- auto handle_buf = node::Buffer::Copy(
- isolate,
- const_cast<uintptr_t*>(&val.shared_texture_handle)),
- sizeof(val.shared_texture_handle));
- dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked());
+ dict.Set("sharedTextureHandle",
+ electron::Buffer::Copy(
+ .ToLocalChecked());
#elif BUILDFLAG(IS_LINUX)
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
diff --git a/shell/common/node_util.cc b/shell/common/node_util.cc
index 6d18f077b61d4..055670cc4ddfb 100644
--- a/shell/common/node_util.cc
+++ b/shell/common/node_util.cc
@@ -75,16 +75,6 @@ void EmitWarning(v8::Isolate* isolate,
emit_warning.Run(warning_msg, warning_type, "");
-// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
-// test, so let's isolate the unsafe API use into this function. Instead of
-// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
-// code should prefer to use spans returned by this function.
-base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
- auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
- const auto size = node::Buffer::Length(node_buffer);
- return UNSAFE_BUFFERS(base::span{data, size});
-}
-
node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::IsolateData* isolate_data,
v8::Local<v8::Context> context,
@@ -133,3 +123,28 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
} // namespace electron::util
+// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
+// test, so let's isolate the unsafe API use into this function. Instead of
+// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
+// code should prefer to use spans returned by this function.
+base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
+ auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
+ const auto size = node::Buffer::Length(node_buffer);
+ return UNSAFE_BUFFERS(base::span{data, size});
+ const base::span<const char> data) {
+ // SAFETY: span-friendly version of node::Buffer::Copy()
+ return UNSAFE_BUFFERS(node::Buffer::Copy(isolate, data.data(), data.size()));
+ const base::span<const uint8_t> data) {
+ return Copy(isolate, base::as_chars(data));
diff --git a/shell/common/node_util.h b/shell/common/node_util.h
index c379d70e8ab9d..36fcfdf940ba4 100644
--- a/shell/common/node_util.h
+++ b/shell/common/node_util.h
@@ -53,11 +53,23 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::EnvironmentFlags::Flags env_flags,
std::string_view process_type = "");
+} // namespace electron::util
// Convenience function to view a Node buffer's data as a base::span().
// Analogous to base::as_byte_span()
[[nodiscard]] base::span<uint8_t> as_byte_span(
v8::Local<v8::Value> node_buffer);
-} // namespace electron::util
+ base::span<const char> data);
+ base::span<const uint8_t> data);
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_ | [
"-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {",
"+ const base::span<const uint8_t> val) {",
"- if (png->size() > 0) {",
"+ const std::optional<std::vector<uint8_t>> encoded =",
"- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();",
"- const char* data = reinterpret_cast<char*>(encoded->data());",
"- size_t size = encoded->size();",
"+ const float scale = GetScaleFactorFromOptions(args);",
"- SkImageInfo info =",
"- auto array_buffer =",
"- v8::ArrayBuffer::New(args->isolate(), info.computeMinByteSize());",
"+ if (!encoded_image)",
"- reinterpret_cast<char*>(",
"+ isolate, base::byte_span_from_ref(val.shared_texture_handle))"
] | [
16,
19,
150,
164,
167,
168,
169,
182,
185,
191,
192,
214,
306,
312
] | {
"additions": 93,
"author": "trop[bot]",
"deletions": 72,
"html_url": "https://github.com/electron/electron/pull/46778",
"issue_id": 46778,
"merged_at": "2025-04-25T15:24:43Z",
"omission_probability": 0.1,
"pr_number": 46778,
"repo": "electron/electron",
"title": "refactor: make node Buffers more friendly to `base::span` / `std::span`",
"total_changes": 165
} |
558 | diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index a7983dd39c8bc..04b7651f3a0bb 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -31,6 +31,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/options_switches.h"
#if defined(TOOLKIT_VIEWS)
@@ -72,8 +73,9 @@ namespace {
#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate,
+ const base::span<const uint8_t> val) {
+ auto buffer = electron::Buffer::Copy(isolate, val);
if (buffer.IsEmpty())
return v8::Null(isolate);
else
@@ -348,8 +350,8 @@ void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
messages_callback_map_[message].Run(
- ToBuffer(isolate, static_cast<void*>(&w_param), sizeof(WPARAM)),
- ToBuffer(isolate, static_cast<void*>(&l_param), sizeof(LPARAM)));
+ ToBuffer(isolate, base::byte_span_from_ref(w_param)),
+ ToBuffer(isolate, base::byte_span_from_ref(l_param)));
}
}
#endif
@@ -786,7 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
// landed
NativeWindowHandle handle = window_->GetNativeWindowHandle();
- return ToBuffer(isolate(), &handle, sizeof(handle));
+ return ToBuffer(isolate(), base::byte_span_from_ref(handle));
}
#endif
diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc
index f2cc6a9f9bb3d..862c56217bf2a 100644
--- a/shell/browser/api/electron_api_data_pipe_holder.cc
+++ b/shell/browser/api/electron_api_data_pipe_holder.cc
@@ -17,6 +17,7 @@
#include "net/base/net_errors.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/key_weak_map.h"
+#include "shell/common/node_util.h"
#include "shell/common/node_includes.h"
@@ -114,8 +115,7 @@ class DataPipeReader {
// inside the sandbox
v8::HandleScope handle_scope(promise_.isolate());
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(promise_.isolate(), &buffer_.front(), buffer_.size())
- .ToLocalChecked();
+ electron::Buffer::Copy(promise_.isolate(), buffer_).ToLocalChecked();
promise_.Resolve(buffer);
// Destroy data pipe.
diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc
index f9ecdd0734fbb..e815ec06ac18a 100644
--- a/shell/browser/api/electron_api_safe_storage.cc
+++ b/shell/browser/api/electron_api_safe_storage.cc
@@ -11,6 +11,7 @@
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
namespace {
@@ -72,8 +73,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
return {};
}
- return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
- .ToLocalChecked();
+ return electron::Buffer::Copy(isolate, ciphertext).ToLocalChecked();
}
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 578aa0e5d22fe..ee367466ac6ff 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -2979,9 +2979,7 @@ void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
v8::Local<v8::Context>::New(isolate, promise.GetContext()));
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<const char*>(data->front()),
- data->size())
- .ToLocalChecked();
+ electron::Buffer::Copy(isolate, *data).ToLocalChecked();
promise.Resolve(buffer);
}
diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc
index aad1d4eece441..84f9dd2a6cd7d 100644
--- a/shell/common/api/electron_api_clipboard.cc
+++ b/shell/common/api/electron_api_clipboard.cc
@@ -13,6 +13,7 @@
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/process_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
@@ -99,8 +100,7 @@ std::string Clipboard::Read(const std::string& format_string) {
v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
gin_helper::Arguments* args) {
std::string data = Read(format_string);
- return node::Buffer::Copy(args->isolate(), data.data(), data.length())
- .ToLocalChecked();
+ return electron::Buffer::Copy(args->isolate(), data).ToLocalChecked();
}
void Clipboard::WriteBuffer(const std::string& format,
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index d16023390d4ad..da34a3158c3fe 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -122,6 +122,10 @@ base::win::ScopedGDIObject<HICON> ReadICOFromPath(int size,
}
#endif
+[[nodiscard]] v8::Local<v8::Value> NewEmptyBuffer(v8::Isolate* isolate) {
+ return node::Buffer::New(isolate, 0).ToLocalChecked();
+}
+
} // namespace
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
@@ -226,57 +230,48 @@ HICON NativeImage::GetHICON(int size) {
#endif
v8::Local<v8::Value> NativeImage::ToPNG(gin::Arguments* args) {
+ v8::Isolate* const isolate = args->isolate();
float scale_factor = GetScaleFactorFromOptions(args);
if (scale_factor == 1.0f) {
// Use raw 1x PNG bytes when available
- scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
- if (png->size() > 0) {
- const char* data = reinterpret_cast<const char*>(png->front());
- size_t size = png->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
- }
+ const scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
+ const base::span<const uint8_t> png_span = *png;
+ if (!png_span.empty())
+ return electron::Buffer::Copy(isolate, png_span).ToLocalChecked();
}
const SkBitmap bitmap =
image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- std::optional<std::vector<uint8_t>> encoded =
+ const std::optional<std::vector<uint8_t>> encoded =
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false);
if (!encoded.has_value())
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- const char* data = reinterpret_cast<char*>(encoded->data());
- size_t size = encoded->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
+ return NewEmptyBuffer(isolate);
+
+ return electron::Buffer::Copy(isolate, *encoded).ToLocalChecked();
}
v8::Local<v8::Value> NativeImage::ToBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ v8::Isolate* const isolate = args->isolate();
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
+ const float scale = GetScaleFactorFromOptions(args);
+ const auto src = image_.AsImageSkia().GetRepresentation(scale).GetBitmap();
- SkImageInfo info =
- SkImageInfo::MakeN32Premul(bitmap.width(), bitmap.height());
+ const auto dst_info = SkImageInfo::MakeN32Premul(src.dimensions());
+ const size_t dst_n_bytes = dst_info.computeMinByteSize();
+ auto dst_buf = v8::ArrayBuffer::New(isolate, dst_n_bytes);
- auto array_buffer =
- v8::ArrayBuffer::New(args->isolate(), info.computeMinByteSize());
- if (bitmap.readPixels(info, array_buffer->Data(), info.minRowBytes(), 0, 0)) {
- return node::Buffer::New(args->isolate(), array_buffer, 0,
- info.computeMinByteSize())
- .ToLocalChecked();
- }
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
+ if (!src.readPixels(dst_info, dst_buf->Data(), dst_info.minRowBytes(), 0, 0))
+ return NewEmptyBuffer(isolate);
+ return node::Buffer::New(isolate, dst_buf, 0, dst_n_bytes).ToLocalChecked();
}
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
- std::optional<std::vector<uint8_t>> encoded_image =
+ const std::optional<std::vector<uint8_t>> encoded_image =
gfx::JPEG1xEncodedDataFromImage(image_, quality);
- if (!encoded_image.has_value())
- return node::Buffer::New(isolate, 0).ToLocalChecked();
- return node::Buffer::Copy(
- isolate, reinterpret_cast<const char*>(&encoded_image->front()),
- encoded_image->size())
- .ToLocalChecked();
+ if (!encoded_image)
+ return NewEmptyBuffer(isolate);
+ return electron::Buffer::Copy(isolate, *encoded_image).ToLocalChecked();
}
std::string NativeImage::ToDataURL(gin::Arguments* args) {
@@ -301,17 +296,17 @@ v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetNativeHandle(
gin_helper::ErrorThrower thrower) {
+ v8::Isolate* const isolate = thrower.isolate();
#if BUILDFLAG(IS_MAC)
if (IsEmpty())
- return node::Buffer::New(thrower.isolate(), 0).ToLocalChecked();
+ return NewEmptyBuffer(isolate);
NSImage* ptr = image_.AsNSImage();
- return node::Buffer::Copy(thrower.isolate(), reinterpret_cast<char*>(ptr),
- sizeof(void*))
+ return electron::Buffer::Copy(isolate, base::byte_span_from_ref(ptr))
.ToLocalChecked();
#else
thrower.ThrowError("Not implemented");
- return v8::Undefined(thrower.isolate());
+ return v8::Undefined(isolate);
#endif
}
@@ -402,7 +397,7 @@ void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
GURL url;
if (options.Get("buffer", &buffer) && node::Buffer::HasInstance(buffer)) {
skia_rep_added = electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
} else if (options.Get("dataURL", &url)) {
std::string mime_type, charset, data;
@@ -511,7 +506,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
auto info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
auto size_bytes = info.computeMinByteSize();
- const auto buffer_data = electron::util::as_byte_span(buffer);
+ const auto buffer_data = electron::Buffer::as_byte_span(buffer);
if (size_bytes != buffer_data.size()) {
thrower.ThrowError("invalid buffer size");
return {};
@@ -552,7 +547,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
gfx::ImageSkia image_skia;
electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
return Create(args->isolate(), gfx::Image(image_skia));
}
diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc
index bf67315c5b09c..0bf04cff8d135 100644
--- a/shell/common/gin_converters/net_converter.cc
+++ b/shell/common/gin_converters/net_converter.cc
@@ -34,6 +34,7 @@
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
+#include "shell/common/node_util.h"
#include "shell/common/v8_util.h"
namespace gin {
@@ -524,11 +525,11 @@ v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
}
case network::mojom::DataElement::Tag::kBytes: {
upload_data.Set("type", "rawData");
- const auto& bytes = element.As<network::DataElementBytes>().bytes();
- const char* data = reinterpret_cast<const char*>(bytes.data());
upload_data.Set(
"bytes",
- node::Buffer::Copy(isolate, data, bytes.size()).ToLocalChecked());
+ electron::Buffer::Copy(
+ isolate, element.As<network::DataElementBytes>().bytes())
+ .ToLocalChecked());
break;
}
case network::mojom::DataElement::Tag::kDataPipe: {
diff --git a/shell/common/gin_converters/osr_converter.cc b/shell/common/gin_converters/osr_converter.cc
index 7ccc1d71ec883..afa868ae8a526 100644
--- a/shell/common/gin_converters/osr_converter.cc
+++ b/shell/common/gin_converters/osr_converter.cc
@@ -111,12 +111,10 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
dict.Set("metadata", ConvertToV8(isolate, metadata));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- auto handle_buf = node::Buffer::Copy(
- isolate,
- reinterpret_cast<char*>(
- const_cast<uintptr_t*>(&val.shared_texture_handle)),
- sizeof(val.shared_texture_handle));
- dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked());
+ dict.Set("sharedTextureHandle",
+ electron::Buffer::Copy(
+ isolate, base::byte_span_from_ref(val.shared_texture_handle))
+ .ToLocalChecked());
#elif BUILDFLAG(IS_LINUX)
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
diff --git a/shell/common/node_util.cc b/shell/common/node_util.cc
index 6d18f077b61d4..055670cc4ddfb 100644
--- a/shell/common/node_util.cc
+++ b/shell/common/node_util.cc
@@ -75,16 +75,6 @@ void EmitWarning(v8::Isolate* isolate,
emit_warning.Run(warning_msg, warning_type, "");
}
-// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
-// test, so let's isolate the unsafe API use into this function. Instead of
-// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
-// code should prefer to use spans returned by this function.
-base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
- auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
- const auto size = node::Buffer::Length(node_buffer);
- return UNSAFE_BUFFERS(base::span{data, size});
-}
-
node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::IsolateData* isolate_data,
v8::Local<v8::Context> context,
@@ -133,3 +123,28 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
}
} // namespace electron::util
+
+namespace electron::Buffer {
+
+// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
+// test, so let's isolate the unsafe API use into this function. Instead of
+// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
+// code should prefer to use spans returned by this function.
+base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
+ auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
+ const auto size = node::Buffer::Length(node_buffer);
+ return UNSAFE_BUFFERS(base::span{data, size});
+}
+
+v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ const base::span<const char> data) {
+ // SAFETY: span-friendly version of node::Buffer::Copy()
+ return UNSAFE_BUFFERS(node::Buffer::Copy(isolate, data.data(), data.size()));
+}
+
+v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ const base::span<const uint8_t> data) {
+ return Copy(isolate, base::as_chars(data));
+}
+
+} // namespace electron::Buffer
diff --git a/shell/common/node_util.h b/shell/common/node_util.h
index c379d70e8ab9d..36fcfdf940ba4 100644
--- a/shell/common/node_util.h
+++ b/shell/common/node_util.h
@@ -53,11 +53,23 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::EnvironmentFlags::Flags env_flags,
std::string_view process_type = "");
+} // namespace electron::util
+
+namespace electron::Buffer {
+
// Convenience function to view a Node buffer's data as a base::span().
// Analogous to base::as_byte_span()
[[nodiscard]] base::span<uint8_t> as_byte_span(
v8::Local<v8::Value> node_buffer);
-} // namespace electron::util
+// span-friendly version of node::Buffer::Copy()
+[[nodiscard]] v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ base::span<const char> data);
+
+// span-friendly version of node::Buffer::Copy()
+[[nodiscard]] v8::MaybeLocal<v8::Object> Copy(v8::Isolate* isolate,
+ base::span<const uint8_t> data);
+
+} // namespace electron::Buffer
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
| diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index a7983dd39c8bc..04b7651f3a0bb 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -31,6 +31,7 @@
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/gin_helper/persistent_dictionary.h"
#include "shell/common/options_switches.h"
#if defined(TOOLKIT_VIEWS)
@@ -72,8 +73,9 @@ namespace {
#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate,
+ const base::span<const uint8_t> val) {
+ auto buffer = electron::Buffer::Copy(isolate, val);
if (buffer.IsEmpty())
return v8::Null(isolate);
else
@@ -348,8 +350,8 @@ void BaseWindow::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
v8::HandleScope scope(isolate);
messages_callback_map_[message].Run(
- ToBuffer(isolate, static_cast<void*>(&w_param), sizeof(WPARAM)),
- ToBuffer(isolate, static_cast<void*>(&l_param), sizeof(LPARAM)));
+ ToBuffer(isolate, base::byte_span_from_ref(w_param)),
+ ToBuffer(isolate, base::byte_span_from_ref(l_param)));
@@ -786,7 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
// landed
NativeWindowHandle handle = window_->GetNativeWindowHandle();
- return ToBuffer(isolate(), &handle, sizeof(handle));
+ return ToBuffer(isolate(), base::byte_span_from_ref(handle));
diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc
index f2cc6a9f9bb3d..862c56217bf2a 100644
--- a/shell/browser/api/electron_api_data_pipe_holder.cc
+++ b/shell/browser/api/electron_api_data_pipe_holder.cc
@@ -17,6 +17,7 @@
#include "net/base/net_errors.h"
#include "shell/common/key_weak_map.h"
@@ -114,8 +115,7 @@ class DataPipeReader {
// inside the sandbox
v8::HandleScope handle_scope(promise_.isolate());
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(promise_.isolate(), &buffer_.front(), buffer_.size())
- .ToLocalChecked();
+ electron::Buffer::Copy(promise_.isolate(), buffer_).ToLocalChecked();
promise_.Resolve(buffer);
// Destroy data pipe.
diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc
index f9ecdd0734fbb..e815ec06ac18a 100644
--- a/shell/browser/api/electron_api_safe_storage.cc
+++ b/shell/browser/api/electron_api_safe_storage.cc
@@ -11,6 +11,7 @@
#include "shell/common/gin_converters/callback_converter.h"
namespace {
@@ -72,8 +73,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
- return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
+ return electron::Buffer::Copy(isolate, ciphertext).ToLocalChecked();
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 578aa0e5d22fe..ee367466ac6ff 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -2979,9 +2979,7 @@ void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
v8::Local<v8::Context>::New(isolate, promise.GetContext()));
v8::Local<v8::Value> buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<const char*>(data->front()),
- data->size())
- .ToLocalChecked();
+ electron::Buffer::Copy(isolate, *data).ToLocalChecked();
promise.Resolve(buffer);
diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc
index aad1d4eece441..84f9dd2a6cd7d 100644
--- a/shell/common/api/electron_api_clipboard.cc
+++ b/shell/common/api/electron_api_clipboard.cc
@@ -13,6 +13,7 @@
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/process_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_format_type.h"
@@ -99,8 +100,7 @@ std::string Clipboard::Read(const std::string& format_string) {
v8::Local<v8::Value> Clipboard::ReadBuffer(const std::string& format_string,
gin_helper::Arguments* args) {
std::string data = Read(format_string);
- return node::Buffer::Copy(args->isolate(), data.data(), data.length())
+ return electron::Buffer::Copy(args->isolate(), data).ToLocalChecked();
void Clipboard::WriteBuffer(const std::string& format,
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index d16023390d4ad..da34a3158c3fe 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -122,6 +122,10 @@ base::win::ScopedGDIObject<HICON> ReadICOFromPath(int size,
+[[nodiscard]] v8::Local<v8::Value> NewEmptyBuffer(v8::Isolate* isolate) {
+ return node::Buffer::New(isolate, 0).ToLocalChecked();
} // namespace
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
@@ -226,57 +230,48 @@ HICON NativeImage::GetHICON(int size) {
v8::Local<v8::Value> NativeImage::ToPNG(gin::Arguments* args) {
float scale_factor = GetScaleFactorFromOptions(args);
if (scale_factor == 1.0f) {
// Use raw 1x PNG bytes when available
- scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
- if (png->size() > 0) {
- const char* data = reinterpret_cast<const char*>(png->front());
- size_t size = png->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
+ const scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
+ const base::span<const uint8_t> png_span = *png;
+ if (!png_span.empty())
+ return electron::Buffer::Copy(isolate, png_span).ToLocalChecked();
const SkBitmap bitmap =
image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- std::optional<std::vector<uint8_t>> encoded =
+ const std::optional<std::vector<uint8_t>> encoded =
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false);
if (!encoded.has_value())
- const char* data = reinterpret_cast<char*>(encoded->data());
- size_t size = encoded->size();
- return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
+ return electron::Buffer::Copy(isolate, *encoded).ToLocalChecked();
v8::Local<v8::Value> NativeImage::ToBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
+ const float scale = GetScaleFactorFromOptions(args);
+ const auto src = image_.AsImageSkia().GetRepresentation(scale).GetBitmap();
- SkImageInfo info =
- SkImageInfo::MakeN32Premul(bitmap.width(), bitmap.height());
+ const auto dst_info = SkImageInfo::MakeN32Premul(src.dimensions());
+ const size_t dst_n_bytes = dst_info.computeMinByteSize();
+ auto dst_buf = v8::ArrayBuffer::New(isolate, dst_n_bytes);
- auto array_buffer =
- if (bitmap.readPixels(info, array_buffer->Data(), info.minRowBytes(), 0, 0)) {
- return node::Buffer::New(args->isolate(), array_buffer, 0,
- info.computeMinByteSize())
- .ToLocalChecked();
- }
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
+ if (!src.readPixels(dst_info, dst_buf->Data(), dst_info.minRowBytes(), 0, 0))
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
- std::optional<std::vector<uint8_t>> encoded_image =
+ const std::optional<std::vector<uint8_t>> encoded_image =
gfx::JPEG1xEncodedDataFromImage(image_, quality);
- if (!encoded_image.has_value())
- return node::Buffer::New(isolate, 0).ToLocalChecked();
- return node::Buffer::Copy(
- isolate, reinterpret_cast<const char*>(&encoded_image->front()),
- encoded_image->size())
+ if (!encoded_image)
+ return electron::Buffer::Copy(isolate, *encoded_image).ToLocalChecked();
std::string NativeImage::ToDataURL(gin::Arguments* args) {
@@ -301,17 +296,17 @@ v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetNativeHandle(
gin_helper::ErrorThrower thrower) {
+ v8::Isolate* const isolate = thrower.isolate();
#if BUILDFLAG(IS_MAC)
if (IsEmpty())
- return node::Buffer::New(thrower.isolate(), 0).ToLocalChecked();
NSImage* ptr = image_.AsNSImage();
- return node::Buffer::Copy(thrower.isolate(), reinterpret_cast<char*>(ptr),
- sizeof(void*))
+ return electron::Buffer::Copy(isolate, base::byte_span_from_ref(ptr))
.ToLocalChecked();
#else
thrower.ThrowError("Not implemented");
- return v8::Undefined(thrower.isolate());
+ return v8::Undefined(isolate);
@@ -402,7 +397,7 @@ void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) {
GURL url;
if (options.Get("buffer", &buffer) && node::Buffer::HasInstance(buffer)) {
skia_rep_added = electron::util::AddImageSkiaRepFromBuffer(
- &image_skia, electron::util::as_byte_span(buffer), width, height,
+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,
scale_factor);
} else if (options.Get("dataURL", &url)) {
std::string mime_type, charset, data;
@@ -511,7 +506,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
auto info = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType);
auto size_bytes = info.computeMinByteSize();
- const auto buffer_data = electron::util::as_byte_span(buffer);
+ const auto buffer_data = electron::Buffer::as_byte_span(buffer);
if (size_bytes != buffer_data.size()) {
thrower.ThrowError("invalid buffer size");
@@ -552,7 +547,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
gfx::ImageSkia image_skia;
electron::util::AddImageSkiaRepFromBuffer(
scale_factor);
return Create(args->isolate(), gfx::Image(image_skia));
diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc
index bf67315c5b09c..0bf04cff8d135 100644
--- a/shell/common/gin_converters/net_converter.cc
+++ b/shell/common/gin_converters/net_converter.cc
@@ -34,6 +34,7 @@
#include "shell/common/gin_converters/value_converter.h"
#include "shell/common/v8_util.h"
namespace gin {
@@ -524,11 +525,11 @@ v8::Local<v8::Value> Converter<network::ResourceRequestBody>::ToV8(
case network::mojom::DataElement::Tag::kBytes: {
upload_data.Set("type", "rawData");
- const auto& bytes = element.As<network::DataElementBytes>().bytes();
- const char* data = reinterpret_cast<const char*>(bytes.data());
upload_data.Set(
"bytes",
- node::Buffer::Copy(isolate, data, bytes.size()).ToLocalChecked());
+ electron::Buffer::Copy(
+ isolate, element.As<network::DataElementBytes>().bytes())
+ .ToLocalChecked());
break;
case network::mojom::DataElement::Tag::kDataPipe: {
diff --git a/shell/common/gin_converters/osr_converter.cc b/shell/common/gin_converters/osr_converter.cc
index 7ccc1d71ec883..afa868ae8a526 100644
--- a/shell/common/gin_converters/osr_converter.cc
+++ b/shell/common/gin_converters/osr_converter.cc
@@ -111,12 +111,10 @@ v8::Local<v8::Value> Converter<electron::OffscreenSharedTextureValue>::ToV8(
dict.Set("metadata", ConvertToV8(isolate, metadata));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- auto handle_buf = node::Buffer::Copy(
- isolate,
- reinterpret_cast<char*>(
- const_cast<uintptr_t*>(&val.shared_texture_handle)),
- sizeof(val.shared_texture_handle));
- dict.Set("sharedTextureHandle", handle_buf.ToLocalChecked());
+ dict.Set("sharedTextureHandle",
+ isolate, base::byte_span_from_ref(val.shared_texture_handle))
+ .ToLocalChecked());
#elif BUILDFLAG(IS_LINUX)
auto v8_planes = base::ToVector(val.planes, [isolate](const auto& plane) {
gin::Dictionary v8_plane(isolate, v8::Object::New(isolate));
diff --git a/shell/common/node_util.cc b/shell/common/node_util.cc
index 6d18f077b61d4..055670cc4ddfb 100644
--- a/shell/common/node_util.cc
+++ b/shell/common/node_util.cc
@@ -75,16 +75,6 @@ void EmitWarning(v8::Isolate* isolate,
emit_warning.Run(warning_msg, warning_type, "");
-// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
-// test, so let's isolate the unsafe API use into this function. Instead of
-// code should prefer to use spans returned by this function.
-base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
- auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
- const auto size = node::Buffer::Length(node_buffer);
- return UNSAFE_BUFFERS(base::span{data, size});
-
node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::IsolateData* isolate_data,
v8::Local<v8::Context> context,
@@ -133,3 +123,28 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
} // namespace electron::util
+// SAFETY: There is no node::Buffer API that passes the UNSAFE_BUFFER_USAGE
+// test, so let's isolate the unsafe API use into this function. Instead of
+// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our
+// code should prefer to use spans returned by this function.
+base::span<uint8_t> as_byte_span(v8::Local<v8::Value> node_buffer) {
+ auto* data = reinterpret_cast<uint8_t*>(node::Buffer::Data(node_buffer));
+ const auto size = node::Buffer::Length(node_buffer);
+ const base::span<const char> data) {
+ // SAFETY: span-friendly version of node::Buffer::Copy()
+ return UNSAFE_BUFFERS(node::Buffer::Copy(isolate, data.data(), data.size()));
+ const base::span<const uint8_t> data) {
diff --git a/shell/common/node_util.h b/shell/common/node_util.h
index c379d70e8ab9d..36fcfdf940ba4 100644
--- a/shell/common/node_util.h
+++ b/shell/common/node_util.h
@@ -53,11 +53,23 @@ node::Environment* CreateEnvironment(v8::Isolate* isolate,
node::EnvironmentFlags::Flags env_flags,
std::string_view process_type = "");
+} // namespace electron::util
// Convenience function to view a Node buffer's data as a base::span().
// Analogous to base::as_byte_span()
[[nodiscard]] base::span<uint8_t> as_byte_span(
v8::Local<v8::Value> node_buffer);
-} // namespace electron::util
+ base::span<const char> data);
+ base::span<const uint8_t> data);
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_ | [
"- }",
"- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();",
"- v8::ArrayBuffer::New(args->isolate(), info.computeMinByteSize());",
"+ return node::Buffer::New(isolate, dst_buf, 0, dst_n_bytes).ToLocalChecked();",
"- &image_skia, electron::util::as_byte_span(buffer), width, height,",
"+ &image_skia, electron::Buffer::as_byte_span(buffer), width, height,",
"+ electron::Buffer::Copy(",
"-// calling `Buffer::Data()` and `Buffer::Length()` directly, the rest of our",
"-}",
"+ return UNSAFE_BUFFERS(base::span{data, size});",
"+ return Copy(isolate, base::as_chars(data));"
] | [
154,
167,
192,
201,
264,
265,
311,
327,
333,
352,
363
] | {
"additions": 93,
"author": "ckerr",
"deletions": 72,
"html_url": "https://github.com/electron/electron/pull/46724",
"issue_id": 46724,
"merged_at": "2025-04-25T13:00:10Z",
"omission_probability": 0.1,
"pr_number": 46724,
"repo": "electron/electron",
"title": "refactor: make node Buffers more friendly to `base::span` / `std::span`",
"total_changes": 165
} |
559 | diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 7d4371e7a4a69..c457b11743f89 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,19 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (37.0)
+### Utility Process unhandled rejection behavior change
+
+Utility Processes will now warn with an error message when an unhandled
+rejection occurs instead of crashing the process.
+
+To restore the previous behavior, you can use:
+
+```js
+process.on('unhandledRejection', () => {
+ process.exit(1)
+})
+```
+
### Behavior Changed: WebUSB and WebSerial Blocklist Support
[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
@@ -32,6 +45,8 @@ however, old code that needs to preserve this behavior can emulate it by
creating a random session with `session.fromPartition(some_random_string)`
and then using it in `ProtocolResponse.session`.
+## Planned Breaking API Changes (36.0)
+
### Behavior Changed: `BrowserWindow.IsVisibleOnAllWorkspaces()` on Linux
`BrowserWindow.IsVisibleOnAllWorkspaces()` will now return false on Linux if the
@@ -58,21 +73,6 @@ bitmap = image.getBitmap()
bitmap = image.toBitmap()
```
-## Planned Breaking API Changes (36.0)
-
-### Utility Process unhandled rejection behavior change
-
-Utility Processes will now warn with an error message when an unhandled
-rejection occurs instead of crashing the process.
-
-To restore the previous behavior, you can use:
-
-```js
-process.on('unhandledRejection', () => {
- process.exit(1)
-})
-```
-
### Removed: `isDefault` and `status` properties on `PrinterInfo`
These properties have been removed from the PrinterInfo Object
| diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 7d4371e7a4a69..c457b11743f89 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,19 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (37.0)
+### Utility Process unhandled rejection behavior change
+Utility Processes will now warn with an error message when an unhandled
+rejection occurs instead of crashing the process.
+To restore the previous behavior, you can use:
+```js
+process.on('unhandledRejection', () => {
+ process.exit(1)
+})
+```
### Behavior Changed: WebUSB and WebSerial Blocklist Support
[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
@@ -32,6 +45,8 @@ however, old code that needs to preserve this behavior can emulate it by
creating a random session with `session.fromPartition(some_random_string)`
and then using it in `ProtocolResponse.session`.
+## Planned Breaking API Changes (36.0)
### Behavior Changed: `BrowserWindow.IsVisibleOnAllWorkspaces()` on Linux
`BrowserWindow.IsVisibleOnAllWorkspaces()` will now return false on Linux if the
@@ -58,21 +73,6 @@ bitmap = image.getBitmap()
bitmap = image.toBitmap()
```
-## Planned Breaking API Changes (36.0)
-### Utility Process unhandled rejection behavior change
-rejection occurs instead of crashing the process.
-To restore the previous behavior, you can use:
-```js
-process.on('unhandledRejection', () => {
- process.exit(1)
-```
### Removed: `isDefault` and `status` properties on `PrinterInfo`
These properties have been removed from the PrinterInfo Object | [
"-Utility Processes will now warn with an error message when an unhandled",
"-})"
] | [
41,
49
] | {
"additions": 15,
"author": "mlaurencin",
"deletions": 15,
"html_url": "https://github.com/electron/electron/pull/46762",
"issue_id": 46762,
"merged_at": "2025-04-25T14:10:35Z",
"omission_probability": 0.1,
"pr_number": 46762,
"repo": "electron/electron",
"title": "docs: correct breaking-changes.md for 36.0.0 release",
"total_changes": 30
} |
560 | diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc
index a7296bde7de30..f84f0c49fd89a 100644
--- a/shell/browser/api/electron_api_cookies.cc
+++ b/shell/browser/api/electron_api_cookies.cc
@@ -102,27 +102,6 @@ namespace electron::api {
namespace {
-// Returns whether |domain| matches |filter|.
-bool MatchesDomain(std::string filter, const std::string& domain) {
- // Add a leading '.' character to the filter domain if it doesn't exist.
- if (net::cookie_util::DomainIsHostOnly(filter))
- filter.insert(0, ".");
-
- std::string sub_domain(domain);
- // Strip any leading '.' character from the input cookie domain.
- if (!net::cookie_util::DomainIsHostOnly(sub_domain))
- sub_domain = sub_domain.substr(1);
-
- // Now check whether the domain argument is a subdomain of the filter domain.
- for (sub_domain.insert(0, "."); sub_domain.length() >= filter.length();) {
- if (sub_domain == filter)
- return true;
- const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot.
- sub_domain.erase(0, next_dot);
- }
- return false;
-}
-
// Returns whether |cookie| matches |filter|.
bool MatchesCookie(const base::Value::Dict& filter,
const net::CanonicalCookie& cookie) {
@@ -131,8 +110,7 @@ bool MatchesCookie(const base::Value::Dict& filter,
return false;
if ((str = filter.FindString("path")) && *str != cookie.Path())
return false;
- if ((str = filter.FindString("domain")) &&
- !MatchesDomain(*str, cookie.Domain()))
+ if ((str = filter.FindString("domain")) && !cookie.IsDomainMatch(*str))
return false;
std::optional<bool> secure_filter = filter.FindBool("secure");
if (secure_filter && *secure_filter != cookie.SecureAttribute())
diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts
index afa34738ebd32..49b24a78f79e2 100644
--- a/spec/api-session-spec.ts
+++ b/spec/api-session-spec.ts
@@ -260,6 +260,165 @@ describe('session module', () => {
});
});
+ describe('domain matching', () => {
+ let testSession: Electron.Session;
+
+ beforeEach(() => {
+ testSession = session.fromPartition(`cookies-domain-test-${Date.now()}`);
+ });
+
+ afterEach(async () => {
+ // Clear cookies after each test
+ await testSession.clearStorageData({ storages: ['cookies'] });
+ });
+
+ // Helper to set a cookie and then test if it's retrieved with a domain filter
+ async function testDomainMatching (setCookieOpts: Electron.CookiesSetDetails,
+ domain: string,
+ expectMatch: boolean) {
+ await testSession.cookies.set(setCookieOpts);
+ const cookies = await testSession.cookies.get({ domain });
+
+ if (expectMatch) {
+ expect(cookies).to.have.lengthOf(1);
+ expect(cookies[0].name).to.equal(setCookieOpts.name);
+ expect(cookies[0].value).to.equal(setCookieOpts.value);
+ } else {
+ expect(cookies).to.have.lengthOf(0);
+ }
+ }
+
+ it('should match exact domain', async () => {
+ await testDomainMatching({
+ url: 'http://example.com',
+ name: 'exactMatch',
+ value: 'value1',
+ domain: 'example.com'
+ }, 'example.com', true);
+ });
+
+ it('should match subdomain when filter has leading dot', async () => {
+ await testDomainMatching({
+ url: 'http://sub.example.com',
+ name: 'subdomainMatch',
+ value: 'value2',
+ domain: '.example.com'
+ }, 'sub.example.com', true);
+ });
+
+ it('should match subdomain when filter has no leading dot (host-only normalization)', async () => {
+ await testDomainMatching({
+ url: 'http://sub.example.com',
+ name: 'hostOnlyNormalization',
+ value: 'value3',
+ domain: 'example.com'
+ }, 'sub.example.com', true);
+ });
+
+ it('should not match unrelated domain', async () => {
+ await testDomainMatching({
+ url: 'http://example.com',
+ name: 'noMatch',
+ value: 'value4',
+ domain: 'example.com'
+ }, 'other.com', false);
+ });
+
+ it('should match domain with a leading dot in both cookie and filter', async () => {
+ await testDomainMatching({
+ url: 'http://example.com',
+ name: 'leadingDotBoth',
+ value: 'value5',
+ domain: '.example.com'
+ }, '.example.com', true);
+ });
+
+ it('should handle case insensitivity in domain', async () => {
+ await testDomainMatching({
+ url: 'http://example.com',
+ name: 'caseInsensitive',
+ value: 'value7',
+ domain: 'Example.com'
+ }, 'example.com', true);
+ });
+
+ it('should handle IP address matching', async () => {
+ await testDomainMatching({
+ url: 'http://127.0.0.1',
+ name: 'ipExactMatch',
+ value: 'value8',
+ domain: '127.0.0.1'
+ }, '127.0.0.1', true);
+ });
+
+ it('should not match different IP addresses', async () => {
+ await testDomainMatching({
+ url: 'http://127.0.0.1',
+ name: 'ipMismatch',
+ value: 'value9',
+ domain: '127.0.0.1'
+ }, '127.0.0.2', false);
+ });
+
+ it('should handle complex subdomain matching properly', async () => {
+ // Set a cookie with domain .example.com
+ await testSession.cookies.set({
+ url: 'http://a.b.example.com',
+ name: 'complexSubdomain',
+ value: 'value11',
+ domain: '.example.com'
+ });
+
+ // This should match the cookie
+ const cookies1 = await testSession.cookies.get({ domain: 'a.b.example.com' });
+ expect(cookies1).to.have.lengthOf(1);
+ expect(cookies1[0].name).to.equal('complexSubdomain');
+
+ // This should also match
+ const cookies2 = await testSession.cookies.get({ domain: 'b.example.com' });
+ expect(cookies2).to.have.lengthOf(1);
+
+ // This should also match
+ const cookies3 = await testSession.cookies.get({ domain: 'example.com' });
+ expect(cookies3).to.have.lengthOf(1);
+
+ // This should not match
+ const cookies4 = await testSession.cookies.get({ domain: 'otherexample.com' });
+ expect(cookies4).to.have.lengthOf(0);
+ });
+
+ it('should handle multiple cookies with different domains', async () => {
+ // Set two cookies with different domains
+ await testSession.cookies.set({
+ url: 'http://example.com',
+ name: 'cookie1',
+ value: 'domain1',
+ domain: 'example.com'
+ });
+
+ await testSession.cookies.set({
+ url: 'http://other.com',
+ name: 'cookie2',
+ value: 'domain2',
+ domain: 'other.com'
+ });
+
+ // Filter for the first domain
+ const cookies1 = await testSession.cookies.get({ domain: 'example.com' });
+ expect(cookies1).to.have.lengthOf(1);
+ expect(cookies1[0].name).to.equal('cookie1');
+
+ // Filter for the second domain
+ const cookies2 = await testSession.cookies.get({ domain: 'other.com' });
+ expect(cookies2).to.have.lengthOf(1);
+ expect(cookies2[0].name).to.equal('cookie2');
+
+ // Get all cookies
+ const allCookies = await testSession.cookies.get({});
+ expect(allCookies).to.have.lengthOf(2);
+ });
+ });
+
describe('ses.clearStorageData(options)', () => {
afterEach(closeAllWindows);
it('clears localstorage data', async () => {
| diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc
index a7296bde7de30..f84f0c49fd89a 100644
--- a/shell/browser/api/electron_api_cookies.cc
+++ b/shell/browser/api/electron_api_cookies.cc
@@ -102,27 +102,6 @@ namespace electron::api {
namespace {
-// Returns whether |domain| matches |filter|.
-bool MatchesDomain(std::string filter, const std::string& domain) {
- // Add a leading '.' character to the filter domain if it doesn't exist.
- if (net::cookie_util::DomainIsHostOnly(filter))
- // Strip any leading '.' character from the input cookie domain.
- if (!net::cookie_util::DomainIsHostOnly(sub_domain))
- sub_domain = sub_domain.substr(1);
- // Now check whether the domain argument is a subdomain of the filter domain.
- for (sub_domain.insert(0, "."); sub_domain.length() >= filter.length();) {
- if (sub_domain == filter)
- return true;
- const size_t next_dot = sub_domain.find('.', 1); // Skip over leading dot.
- sub_domain.erase(0, next_dot);
- }
- return false;
-}
// Returns whether |cookie| matches |filter|.
bool MatchesCookie(const base::Value::Dict& filter,
const net::CanonicalCookie& cookie) {
@@ -131,8 +110,7 @@ bool MatchesCookie(const base::Value::Dict& filter,
if ((str = filter.FindString("path")) && *str != cookie.Path())
- if ((str = filter.FindString("domain")) &&
- !MatchesDomain(*str, cookie.Domain()))
+ if ((str = filter.FindString("domain")) && !cookie.IsDomainMatch(*str))
std::optional<bool> secure_filter = filter.FindBool("secure");
if (secure_filter && *secure_filter != cookie.SecureAttribute())
diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts
index afa34738ebd32..49b24a78f79e2 100644
--- a/spec/api-session-spec.ts
+++ b/spec/api-session-spec.ts
@@ -260,6 +260,165 @@ describe('session module', () => {
});
});
+ describe('domain matching', () => {
+ let testSession: Electron.Session;
+ beforeEach(() => {
+ testSession = session.fromPartition(`cookies-domain-test-${Date.now()}`);
+ afterEach(async () => {
+ // Clear cookies after each test
+ async function testDomainMatching (setCookieOpts: Electron.CookiesSetDetails,
+ expectMatch: boolean) {
+ await testSession.cookies.set(setCookieOpts);
+ const cookies = await testSession.cookies.get({ domain });
+ if (expectMatch) {
+ expect(cookies).to.have.lengthOf(1);
+ expect(cookies[0].name).to.equal(setCookieOpts.name);
+ expect(cookies[0].value).to.equal(setCookieOpts.value);
+ } else {
+ expect(cookies).to.have.lengthOf(0);
+ }
+ }
+ it('should match exact domain', async () => {
+ name: 'exactMatch',
+ value: 'value1',
+ it('should match subdomain when filter has leading dot', async () => {
+ name: 'subdomainMatch',
+ it('should match subdomain when filter has no leading dot (host-only normalization)', async () => {
+ value: 'value3',
+ it('should not match unrelated domain', async () => {
+ name: 'noMatch',
+ value: 'value4',
+ }, 'other.com', false);
+ name: 'leadingDotBoth',
+ value: 'value5',
+ }, '.example.com', true);
+ it('should handle case insensitivity in domain', async () => {
+ name: 'caseInsensitive',
+ value: 'value7',
+ domain: 'Example.com'
+ it('should handle IP address matching', async () => {
+ name: 'ipExactMatch',
+ value: 'value8',
+ }, '127.0.0.1', true);
+ it('should not match different IP addresses', async () => {
+ value: 'value9',
+ }, '127.0.0.2', false);
+ // Set a cookie with domain .example.com
+ url: 'http://a.b.example.com',
+ name: 'complexSubdomain',
+ value: 'value11',
+ // This should match the cookie
+ const cookies1 = await testSession.cookies.get({ domain: 'a.b.example.com' });
+ expect(cookies1[0].name).to.equal('complexSubdomain');
+ const cookies2 = await testSession.cookies.get({ domain: 'b.example.com' });
+ const cookies3 = await testSession.cookies.get({ domain: 'example.com' });
+ expect(cookies3).to.have.lengthOf(1);
+ // This should not match
+ const cookies4 = await testSession.cookies.get({ domain: 'otherexample.com' });
+ expect(cookies4).to.have.lengthOf(0);
+ it('should handle multiple cookies with different domains', async () => {
+ // Set two cookies with different domains
+ name: 'cookie1',
+ value: 'domain1',
+ url: 'http://other.com',
+ name: 'cookie2',
+ domain: 'other.com'
+ const cookies1 = await testSession.cookies.get({ domain: 'example.com' });
+ expect(cookies1[0].name).to.equal('cookie1');
+ // Filter for the second domain
+ const cookies2 = await testSession.cookies.get({ domain: 'other.com' });
+ expect(cookies2[0].name).to.equal('cookie2');
+ // Get all cookies
+ const allCookies = await testSession.cookies.get({});
+ expect(allCookies).to.have.lengthOf(2);
+ });
describe('ses.clearStorageData(options)', () => {
afterEach(closeAllWindows);
it('clears localstorage data', async () => { | [
"- filter.insert(0, \".\");",
"- std::string sub_domain(domain);",
"+ await testSession.clearStorageData({ storages: ['cookies'] });",
"+ // Helper to set a cookie and then test if it's retrieved with a domain filter",
"+ domain: string,",
"+ value: 'value2',",
"+ name: 'hostOnlyNormalization',",
"+ it('should match domain with a leading dot in both cookie and filter', async () => {",
"+ name: 'ipMismatch',",
"+ it('should handle complex subdomain matching properly', async () => {",
"+ value: 'domain2',",
"+ // Filter for the first domain"
] | [
12,
14,
59,
62,
64,
91,
99,
114,
144,
150,
189,
193
] | {
"additions": 160,
"author": "ckerr",
"deletions": 23,
"html_url": "https://github.com/electron/electron/pull/46748",
"issue_id": 46748,
"merged_at": "2025-04-25T14:08:16Z",
"omission_probability": 0.1,
"pr_number": 46748,
"repo": "electron/electron",
"title": "refactor: use `net::CanonicalCookie::IsDomainMatch()`",
"total_changes": 183
} |
561 | diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index 000c6b9a766bb..1f0f7fb7c3d6f 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -898,6 +898,8 @@ copying data between CPU and GPU memory, with Chromium's hardware acceleration s
Only a limited number of textures can exist at the same time, so it's important that you call `texture.release()` as soon as you're done with the texture.
By managing the texture lifecycle by yourself, you can safely pass the `texture.textureInfo` to other processes through IPC.
+More details can be found in the [offscreen rendering tutorial](../tutorial/offscreen-rendering.md). To learn about how to handle the texture in native code, refer to [offscreen rendering's code documentation.](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).
+
```js
const { BrowserWindow } = require('electron')
@@ -909,7 +911,7 @@ win.webContents.on('paint', async (e, dirty, image) => {
await new Promise(resolve => setTimeout(resolve, 50))
// You can send the native texture handle to native code for importing into your rendering pipeline.
- // For example: https://github.com/electron/electron/tree/main/spec/fixtures/native-addon/osr-gpu
+ // Read more at https://github.com/electron/electron/blob/main/shell/browser/osr/README.md
// importTextureHandle(dirty, e.texture.textureInfo)
// You must call `e.texture.release()` as soon as possible, before the underlying frame pool is drained.
diff --git a/docs/tutorial/offscreen-rendering.md b/docs/tutorial/offscreen-rendering.md
index 06825fb13cbe6..e62288d459348 100644
--- a/docs/tutorial/offscreen-rendering.md
+++ b/docs/tutorial/offscreen-rendering.md
@@ -36,7 +36,8 @@ setting.
This is an advanced feature requiring a native node module to work with your own code.
The frames are directly copied in GPU textures, thus this mode is very fast because
there's no CPU-GPU memory copies overhead, and you can directly import the shared
- texture to your own rendering program.
+ texture to your own rendering program. You can read more details at
+ [here](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).
2. Use CPU shared memory bitmap
diff --git a/shell/browser/osr/README.md b/shell/browser/osr/README.md
new file mode 100644
index 0000000000000..15f2434b39e51
--- /dev/null
+++ b/shell/browser/osr/README.md
@@ -0,0 +1,131 @@
+# Offscreen Rendering
+
+## Shared Texture Mode
+
+This section provides a brief summary about how an offscreen frame is generated and how to handle it in native code. This only applies to the GPU-accelerated mode with shared texture, when `webPreferences.offscreen.useSharedTexture` is set to `true`.
+
+### Life of an Offscreen Frame
+
+> This is written at the time of Chromium 134 / Electron 35. The code may change in the future. The following description may not completely reflect the procedure, but it generally describes the process.
+
+#### Initialization
+
+1. Electron JS creates a `BrowserWindow` with `webPreferences.offscreen` set to `true`.
+2. Electron C++ creates `OffScreenRenderWidgetHostView`, a subclass of `RenderWidgetHostViewBase`.
+3. It instantiates an `OffScreenVideoConsumer`, passing itself as a reference as `view_`.
+4. The `OffScreenVideoConsumer` calls `view_->CreateVideoCapturer()`, which makes Chromium code use `HostFrameSinkManager` to communicate with `FrameSinkManagerImpl` (in the Renderer Process) to create a `ClientFrameSinkVideoCapturer` and a `FrameSinkVideoCapturerImpl` (in the Renderer Process). It stores `ClientFrameSinkVideoCapturer` in `video_capturer_`.
+5. The `OffScreenVideoConsumer` registers the capture callback to `OffScreenRenderWidgetHostView::OnPaint`.
+6. It sets the target FPS, size constraints for capture, and calls `video_capturer_->Start` with the parameter `viz::mojom::BufferFormatPreference::kPreferGpuMemoryBuffer` to enable shared texture mode and start capturing.
+7. The `FrameSinkVideoCapturerImpl` accepts `kPreferGpuMemoryBuffer` and creates a `GpuMemoryBufferVideoFramePool` to copy the captured frame. The capacity is `kFramePoolCapacity`, currently `10`, meaning it can capture at most `10` frames if the consumer doesn't consume them in time. It is stored in `frame_pool_`.
+8. The `GpuMemoryBufferVideoFramePool` creates a `RenderableGpuMemoryBufferVideoFramePool` using `GmbVideoFramePoolContext` as the context provider, responsible for creating `GpuMemoryBuffer` (or `MappableSharedImage`, as the Chromium team is removing the concept of `GpuMemoryBuffer` and may replace it with `MappableSI` in the future).
+9. The `GmbVideoFramePoolContext` initializes itself in both the Renderer Process and GPU Process.
+
+#### Capturing
+
+1. The `FrameSinkVideoCapturerImpl` starts a capture when it receives an `OnFrameDamaged` event or is explicitly requested to refresh the frame. All event sources are evaluated by `VideoCaptureOracle` to see if the capture frequency meets the limit.
+2. If a frame is determined to be captured, `FrameSinkVideoCapturerImpl` calls `frame_pool_->ReserveVideoFrame()` to make the pool allocate a frame. The `GmbVideoFramePoolContext` then communicates with the GPU Process to create an actual platform-dependent texture (e.g., `ID3D11Texture2D` or `IOSurface`) that supports being shared across processes.
+3. The GPU Process wraps it into a `GpuMemoryBuffer` and sends it back to the Renderer Process, and the pool stores it for further usage.
+4. The `FrameSinkVideoCapturerImpl` then uses this allocated (or reused) frame to create a `CopyOutputRequest` and calls `resolved_target_->RequestCopyOfOutput` to copy the frame to the target texture. The `resolved_target_` is a `CapturableFrameSink` that was previously resolved when calling `CreateVideoCapturer` using `OffScreenRenderWidgetHostView`.
+5. The GPU Process receives the request and renders the frame to the target texture using the requested format (e.g., `RGBA`). It then sends a completed event to the Renderer Process `FrameSinkVideoCapturerImpl`.
+6. The `FrameSinkVideoCapturerImpl` receives the completed event, provides feedback to the `VideoCaptureOracle`, and then calls `frame_pool_->CloneHandleForDelivery` with the captured frame to get a serializable handle to the frame (`HANDLE` or `IOSurfaceRef`). On Windows, it calls `DuplicateHandle` to create a new handle.
+7. It then creates a `VideoFrameInfo` with the frame info and the handle and calls `consumer_->OnFrameCaptured` to deliver the frame to the consumer.
+
+#### Consuming
+
+1. `OffScreenVideoConsumer::OnFrameCaptured` is called when the frame is captured. It creates an Electron C++ struct `OffscreenSharedTextureValue` to extract the required info and handle from the callback. It then creates an `OffscreenReleaserHolder` to take ownership of the handle and the mojom remote releaser to prevent releasing.
+2. It calls the `callback_` with the `OffscreenSharedTextureValue`, which goes to `OffScreenRenderWidgetHostView::OnPaint`. When shared texture mode is enabled, it directly redirects the callback to an `OnPaintCallback` target set during the initialization of `OffScreenRenderWidgetHostView`, currently set by `OffScreenWebContentsView`, whose `callback_` is also set during initialization. Finally, it goes to `WebContents::OnPaint`.
+3. The `WebContents::OnPaint` uses `gin_converter` (`osr_converter.cc`) to convert the `OffscreenSharedTextureValue` to a `v8::Object`. It converts most of the value to a corresponding `v8::Value`, and the handle is converted to a `Buffer`. It also creates a `release` function to destroy the releaser and free the frame we previously took ownership of. The frame can now be reused for further capturing. Finally, it creates a release monitor to detect if the `release` function is called before the garbage collector destroys the JS object; if not, it prints a warning.
+4. The data is then emitted to the `paint` event of `webContents`. You can now grab the data and pass it to your native code for further processing. You can pass the `textureInfo` to other processes using Electron IPC, but you can only `release` it in the main process. Do not keep it for long, or it will drain the buffer pool.
+
+### Native Handling
+
+You now have the texture info for the frame. Here's how you should handle it in native code. Suppose you write a node native addon to handle the shared texture.
+
+Retrieve the handle from the `textureInfo.sharedTextureHandle`. You can also read the buffer in JS and use other methods.
+
+```c++
+auto textureInfo = args[0];
+auto sharedTextureHandle =
+ NAPI_GET_PROPERTY_VALUE(textureInfo, "sharedTextureHandle");
+
+size_t handleBufferSize;
+uint8_t* handleBufferData;
+napi_get_buffer_info(env, sharedTextureHandle,
+ reinterpret_cast<void**>(&handleBufferData),
+ &handleBufferSize);
+```
+
+Import the handle to your rendering program.
+
+```c++
+// Windows
+HANDLE handle = *reinterpret_cast<HANDLE*>(handleBufferData);
+Microsoft::WRL::ComPtr<ID3D11Texture2D> shared_texture = nullptr;
+HRESULT hr = device1->OpenSharedResource1(handle, IID_PPV_ARGS(&shared_texture));
+
+// Extract the texture description
+D3D11_TEXTURE2D_DESC desc;
+shared_texture->GetDesc(&desc);
+
+// Cache the staging texture if it does not exist or size has changed
+if (!cached_staging_texture || cached_width != desc.Width ||
+ cached_height != desc.Height) {
+ if (cached_staging_texture) {
+ cached_staging_texture->Release();
+ }
+
+ desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
+ desc.Usage = D3D11_USAGE_STAGING;
+ desc.BindFlags = 0;
+ desc.MiscFlags = 0;
+
+ std::cout << "Create staging Texture2D width=" << desc.Width
+ << " height=" << desc.Height << std::endl;
+ hr = device->CreateTexture2D(&desc, nullptr, &cached_staging_texture);
+
+ cached_width = desc.Width;
+ cached_height = desc.Height;
+}
+
+// Copy to a intermediate texture
+context->CopyResource(cached_staging_texture.Get(), shared_texture.Get());
+```
+
+```c++
+// macOS
+IOSurfaceRef handle = *reinterpret_cast<IOSurfaceRef*>(handleBufferData);
+
+// Assume you have created a GL context.
+
+GLuint io_surface_tex;
+glGenTextures(1, &io_surface_tex);
+glEnable(GL_TEXTURE_RECTANGLE_ARB);
+glBindTexture(GL_TEXTURE_RECTANGLE_ARB, io_surface_tex);
+
+CGLContextObj cgl_context = CGLGetCurrentContext();
+
+GLsizei width = (GLsizei)IOSurfaceGetWidth(io_surface);
+GLsizei height = (GLsizei)IOSurfaceGetHeight(io_surface);
+
+CGLTexImageIOSurface2D(cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA8, width,
+ height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ io_surface, 0);
+
+glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
+
+// Copy to a intermediate texture from io_surface_tex
+// ...
+```
+
+As introduced above, the shared texture is not a single fixed texture that Chromium draws on every frame (CEF before Chromium 103 works that like, please note this significate difference). It is a pool of textures, so every frame Chromium may pass a different texture to you. As soon as you call release, the texture will be reused by Chromium and may cause picture corruption if you keep reading from it. It is also wrong to only open the handle once and directly read from that opened texture on later events. Be very careful if you want to cache the opened texture(s), on Windows, the duplicated handle's value will not be a reliable mapping to the actual underlying texture.
+
+The suggested way is always open the handle on every event, and copy the shared texture to a intermediate texture that you own and release it as soon as possible. You can use the copied texture for further rendering whenever you want. Opening a shared texture should only takes couple microseconds, and you can also use the damaged rect to only copy a portion of the texture to speed up.
+
+You can also refer to these examples:
+
+* [Electron OSR feature test on Windows](https://github.com/electron/electron/blob/e7fa5c709c555bbe248bc98b50a14b5cfa9ea1d9/spec/fixtures/native-addon/osr-gpu/binding_win.cc#L22)
+* [CEF open handle on Windows](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_render_handler_win_d3d11.cc#L188)
+* [CEF open handle on macOS](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_renderer.cc#L763)
+* [CEF copy to texture on macOS](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_renderer.cc#L763)
| diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index 000c6b9a766bb..1f0f7fb7c3d6f 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -898,6 +898,8 @@ copying data between CPU and GPU memory, with Chromium's hardware acceleration s
Only a limited number of textures can exist at the same time, so it's important that you call `texture.release()` as soon as you're done with the texture.
By managing the texture lifecycle by yourself, you can safely pass the `texture.textureInfo` to other processes through IPC.
+More details can be found in the [offscreen rendering tutorial](../tutorial/offscreen-rendering.md). To learn about how to handle the texture in native code, refer to [offscreen rendering's code documentation.](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).
```js
const { BrowserWindow } = require('electron')
@@ -909,7 +911,7 @@ win.webContents.on('paint', async (e, dirty, image) => {
await new Promise(resolve => setTimeout(resolve, 50))
// You can send the native texture handle to native code for importing into your rendering pipeline.
- // For example: https://github.com/electron/electron/tree/main/spec/fixtures/native-addon/osr-gpu
// importTextureHandle(dirty, e.texture.textureInfo)
// You must call `e.texture.release()` as soon as possible, before the underlying frame pool is drained.
diff --git a/docs/tutorial/offscreen-rendering.md b/docs/tutorial/offscreen-rendering.md
index 06825fb13cbe6..e62288d459348 100644
--- a/docs/tutorial/offscreen-rendering.md
+++ b/docs/tutorial/offscreen-rendering.md
@@ -36,7 +36,8 @@ setting.
This is an advanced feature requiring a native node module to work with your own code.
The frames are directly copied in GPU textures, thus this mode is very fast because
there's no CPU-GPU memory copies overhead, and you can directly import the shared
+ texture to your own rendering program. You can read more details at
2. Use CPU shared memory bitmap
diff --git a/shell/browser/osr/README.md b/shell/browser/osr/README.md
new file mode 100644
index 0000000000000..15f2434b39e51
--- /dev/null
+++ b/shell/browser/osr/README.md
@@ -0,0 +1,131 @@
+# Offscreen Rendering
+## Shared Texture Mode
+This section provides a brief summary about how an offscreen frame is generated and how to handle it in native code. This only applies to the GPU-accelerated mode with shared texture, when `webPreferences.offscreen.useSharedTexture` is set to `true`.
+### Life of an Offscreen Frame
+#### Initialization
+2. Electron C++ creates `OffScreenRenderWidgetHostView`, a subclass of `RenderWidgetHostViewBase`.
+3. It instantiates an `OffScreenVideoConsumer`, passing itself as a reference as `view_`.
+4. The `OffScreenVideoConsumer` calls `view_->CreateVideoCapturer()`, which makes Chromium code use `HostFrameSinkManager` to communicate with `FrameSinkManagerImpl` (in the Renderer Process) to create a `ClientFrameSinkVideoCapturer` and a `FrameSinkVideoCapturerImpl` (in the Renderer Process). It stores `ClientFrameSinkVideoCapturer` in `video_capturer_`.
+6. It sets the target FPS, size constraints for capture, and calls `video_capturer_->Start` with the parameter `viz::mojom::BufferFormatPreference::kPreferGpuMemoryBuffer` to enable shared texture mode and start capturing.
+7. The `FrameSinkVideoCapturerImpl` accepts `kPreferGpuMemoryBuffer` and creates a `GpuMemoryBufferVideoFramePool` to copy the captured frame. The capacity is `kFramePoolCapacity`, currently `10`, meaning it can capture at most `10` frames if the consumer doesn't consume them in time. It is stored in `frame_pool_`.
+8. The `GpuMemoryBufferVideoFramePool` creates a `RenderableGpuMemoryBufferVideoFramePool` using `GmbVideoFramePoolContext` as the context provider, responsible for creating `GpuMemoryBuffer` (or `MappableSharedImage`, as the Chromium team is removing the concept of `GpuMemoryBuffer` and may replace it with `MappableSI` in the future).
+9. The `GmbVideoFramePoolContext` initializes itself in both the Renderer Process and GPU Process.
+1. The `FrameSinkVideoCapturerImpl` starts a capture when it receives an `OnFrameDamaged` event or is explicitly requested to refresh the frame. All event sources are evaluated by `VideoCaptureOracle` to see if the capture frequency meets the limit.
+2. If a frame is determined to be captured, `FrameSinkVideoCapturerImpl` calls `frame_pool_->ReserveVideoFrame()` to make the pool allocate a frame. The `GmbVideoFramePoolContext` then communicates with the GPU Process to create an actual platform-dependent texture (e.g., `ID3D11Texture2D` or `IOSurface`) that supports being shared across processes.
+4. The `FrameSinkVideoCapturerImpl` then uses this allocated (or reused) frame to create a `CopyOutputRequest` and calls `resolved_target_->RequestCopyOfOutput` to copy the frame to the target texture. The `resolved_target_` is a `CapturableFrameSink` that was previously resolved when calling `CreateVideoCapturer` using `OffScreenRenderWidgetHostView`.
+5. The GPU Process receives the request and renders the frame to the target texture using the requested format (e.g., `RGBA`). It then sends a completed event to the Renderer Process `FrameSinkVideoCapturerImpl`.
+6. The `FrameSinkVideoCapturerImpl` receives the completed event, provides feedback to the `VideoCaptureOracle`, and then calls `frame_pool_->CloneHandleForDelivery` with the captured frame to get a serializable handle to the frame (`HANDLE` or `IOSurfaceRef`). On Windows, it calls `DuplicateHandle` to create a new handle.
+7. It then creates a `VideoFrameInfo` with the frame info and the handle and calls `consumer_->OnFrameCaptured` to deliver the frame to the consumer.
+#### Consuming
+1. `OffScreenVideoConsumer::OnFrameCaptured` is called when the frame is captured. It creates an Electron C++ struct `OffscreenSharedTextureValue` to extract the required info and handle from the callback. It then creates an `OffscreenReleaserHolder` to take ownership of the handle and the mojom remote releaser to prevent releasing.
+2. It calls the `callback_` with the `OffscreenSharedTextureValue`, which goes to `OffScreenRenderWidgetHostView::OnPaint`. When shared texture mode is enabled, it directly redirects the callback to an `OnPaintCallback` target set during the initialization of `OffScreenRenderWidgetHostView`, currently set by `OffScreenWebContentsView`, whose `callback_` is also set during initialization. Finally, it goes to `WebContents::OnPaint`.
+3. The `WebContents::OnPaint` uses `gin_converter` (`osr_converter.cc`) to convert the `OffscreenSharedTextureValue` to a `v8::Object`. It converts most of the value to a corresponding `v8::Value`, and the handle is converted to a `Buffer`. It also creates a `release` function to destroy the releaser and free the frame we previously took ownership of. The frame can now be reused for further capturing. Finally, it creates a release monitor to detect if the `release` function is called before the garbage collector destroys the JS object; if not, it prints a warning.
+### Native Handling
+You now have the texture info for the frame. Here's how you should handle it in native code. Suppose you write a node native addon to handle the shared texture.
+Retrieve the handle from the `textureInfo.sharedTextureHandle`. You can also read the buffer in JS and use other methods.
+auto textureInfo = args[0];
+auto sharedTextureHandle =
+ NAPI_GET_PROPERTY_VALUE(textureInfo, "sharedTextureHandle");
+size_t handleBufferSize;
+uint8_t* handleBufferData;
+napi_get_buffer_info(env, sharedTextureHandle,
+ reinterpret_cast<void**>(&handleBufferData),
+ &handleBufferSize);
+Import the handle to your rendering program.
+// Windows
+HANDLE handle = *reinterpret_cast<HANDLE*>(handleBufferData);
+Microsoft::WRL::ComPtr<ID3D11Texture2D> shared_texture = nullptr;
+HRESULT hr = device1->OpenSharedResource1(handle, IID_PPV_ARGS(&shared_texture));
+// Extract the texture description
+D3D11_TEXTURE2D_DESC desc;
+// Cache the staging texture if it does not exist or size has changed
+if (!cached_staging_texture || cached_width != desc.Width ||
+ cached_height != desc.Height) {
+ if (cached_staging_texture) {
+ cached_staging_texture->Release();
+ }
+ desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
+ desc.Usage = D3D11_USAGE_STAGING;
+ desc.BindFlags = 0;
+ desc.MiscFlags = 0;
+ std::cout << "Create staging Texture2D width=" << desc.Width
+ << " height=" << desc.Height << std::endl;
+ hr = device->CreateTexture2D(&desc, nullptr, &cached_staging_texture);
+ cached_width = desc.Width;
+ cached_height = desc.Height;
+}
+// Copy to a intermediate texture
+context->CopyResource(cached_staging_texture.Get(), shared_texture.Get());
+// macOS
+IOSurfaceRef handle = *reinterpret_cast<IOSurfaceRef*>(handleBufferData);
+// Assume you have created a GL context.
+glGenTextures(1, &io_surface_tex);
+glEnable(GL_TEXTURE_RECTANGLE_ARB);
+glBindTexture(GL_TEXTURE_RECTANGLE_ARB, io_surface_tex);
+CGLContextObj cgl_context = CGLGetCurrentContext();
+GLsizei height = (GLsizei)IOSurfaceGetHeight(io_surface);
+CGLTexImageIOSurface2D(cgl_context, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA8, width,
+ height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ io_surface, 0);
+glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
+// Copy to a intermediate texture from io_surface_tex
+// ...
+As introduced above, the shared texture is not a single fixed texture that Chromium draws on every frame (CEF before Chromium 103 works that like, please note this significate difference). It is a pool of textures, so every frame Chromium may pass a different texture to you. As soon as you call release, the texture will be reused by Chromium and may cause picture corruption if you keep reading from it. It is also wrong to only open the handle once and directly read from that opened texture on later events. Be very careful if you want to cache the opened texture(s), on Windows, the duplicated handle's value will not be a reliable mapping to the actual underlying texture.
+The suggested way is always open the handle on every event, and copy the shared texture to a intermediate texture that you own and release it as soon as possible. You can use the copied texture for further rendering whenever you want. Opening a shared texture should only takes couple microseconds, and you can also use the damaged rect to only copy a portion of the texture to speed up.
+You can also refer to these examples:
+* [Electron OSR feature test on Windows](https://github.com/electron/electron/blob/e7fa5c709c555bbe248bc98b50a14b5cfa9ea1d9/spec/fixtures/native-addon/osr-gpu/binding_win.cc#L22)
+* [CEF open handle on Windows](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_render_handler_win_d3d11.cc#L188)
+* [CEF open handle on macOS](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_renderer.cc#L763)
+* [CEF copy to texture on macOS](https://github.com/chromiumembedded/cef/blob/144e01e377249cd614378cb7084a3ed9b06803ca/tests/cefclient/browser/osr_renderer.cc#L763) | [
"+ // Read more at https://github.com/electron/electron/blob/main/shell/browser/osr/README.md",
"- texture to your own rendering program.",
"+ [here](https://github.com/electron/electron/blob/main/shell/browser/osr/README.md).",
"+> This is written at the time of Chromium 134 / Electron 35. The code may change in the future. The following description may not completely reflect the procedure, but it generally describes the process.",
"+1. Electron JS creates a `BrowserWindow` with `webPreferences.offscreen` set to `true`.",
"+5. The `OffScreenVideoConsumer` registers the capture callback to `OffScreenRenderWidgetHostView::OnPaint`.",
"+#### Capturing",
"+3. The GPU Process wraps it into a `GpuMemoryBuffer` and sends it back to the Renderer Process, and the pool stores it for further usage.",
"+4. The data is then emitted to the `paint` event of `webContents`. You can now grab the data and pass it to your native code for further processing. You can pass the `textureInfo` to other processes using Electron IPC, but you can only `release` it in the main process. Do not keep it for long, or it will drain the buffer pool.",
"+shared_texture->GetDesc(&desc);",
"+GLuint io_surface_tex;",
"+GLsizei width = (GLsizei)IOSurfaceGetWidth(io_surface);"
] | [
18,
30,
32,
50,
54,
58,
64,
68,
79,
109,
141,
148
] | {
"additions": 136,
"author": "reitowo",
"deletions": 2,
"html_url": "https://github.com/electron/electron/pull/45670",
"issue_id": 45670,
"merged_at": "2025-02-27T16:10:59Z",
"omission_probability": 0.1,
"pr_number": 45670,
"repo": "electron/electron",
"title": "docs: add docs about shared texture mode osr",
"total_changes": 138
} |
562 | diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index b2cb62c766398..66fa93620db9c 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4135,6 +4135,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
+
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index fad065a48c8f3..e7d3374646a05 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -753,6 +753,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ })`);
+ // Reload the webview and the main process will not crash.
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ })`);
+ });
});
describe('<webview>.goForward()', () => {
| diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index b2cb62c766398..66fa93620db9c 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4135,6 +4135,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ return false;
+ return true;
+}
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index fad065a48c8f3..e7d3374646a05 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -753,6 +753,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ // Reload the webview and the main process will not crash.
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ });
});
describe('<webview>.goForward()', () => { | [
"+ // and triggers a fatal NOTREACHED.",
"+ if (is_guest())",
"+ webview.executeJavaScript('process.crash()', true)"
] | [
10,
11,
51
] | {
"additions": 31,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46770",
"issue_id": 46770,
"merged_at": "2025-04-25T11:13:17Z",
"omission_probability": 0.1,
"pr_number": 46770,
"repo": "electron/electron",
"title": "fix: crash when renderer process crashes while webview is reloading",
"total_changes": 31
} |
563 | diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 2c2f8f2b8feda..489d32b6854cb 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4101,6 +4101,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
+
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 1a1b339beaa72..20dbaec29449e 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -755,6 +755,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})
+ webview.executeJavaScript('process.crash()', true)
+ })`);
+ // Reload the webview and the main process will not crash.
+ await w.executeJavaScript(`new Promise((resolve, reject) => {
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
+ })
+ })`);
+ });
});
describe('<webview>.goForward()', () => {
| diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 2c2f8f2b8feda..489d32b6854cb 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -4101,6 +4101,14 @@ void WebContents::ExitPictureInPicture() {
PictureInPictureWindowManager::GetInstance()->ExitPictureInPicture();
}
+bool WebContents::ShouldFocusPageAfterCrash(content::WebContents* source) {
+ // WebView uses WebContentsViewChildFrame, which doesn't have a Focus impl
+ // and triggers a fatal NOTREACHED.
+ if (is_guest())
+ return false;
+ return true;
+}
void WebContents::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as,
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 1a1b339beaa72..20dbaec29449e 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -755,6 +755,7 @@ class WebContents final : public ExclusiveAccessContext,
content::PictureInPictureResult EnterPictureInPicture(
content::WebContents* web_contents) override;
void ExitPictureInPicture() override;
+ bool ShouldFocusPageAfterCrash(content::WebContents* source) override;
// InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts
index dfc30937706e1..23d07e32569d8 100644
--- a/spec/webview-spec.ts
+++ b/spec/webview-spec.ts
@@ -1895,6 +1895,28 @@ describe('<webview> tag', function () {
expect(channel).to.equal('onbeforeunload');
});
+ it('does not crash when renderer process crashes', async function () {
+ // It takes more time to wait for the rendering process to crash
+ this.timeout(120000);
+ await loadWebView(w, {
+ nodeintegration: 'on',
+ webpreferences: 'contextIsolation=no',
+ src: blankPageUrl
+ });
+ // Create a crash in the rendering process of a webview
+ webview.executeJavaScript('process.crash()', true)
+ // Reload the webview and the main process will not crash.
+ webview.reload()
+ webview.addEventListener('did-finish-load', () => {
+ resolve()
});
describe('<webview>.goForward()', () => { | [
"+ webview.addEventListener('render-process-gone', (e) => resolve({...e}), {once: true})",
"+ })",
"+ });"
] | [
50,
58,
60
] | {
"additions": 31,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46769",
"issue_id": 46769,
"merged_at": "2025-04-25T11:12:54Z",
"omission_probability": 0.1,
"pr_number": 46769,
"repo": "electron/electron",
"title": "fix: crash when renderer process crashes while webview is reloading",
"total_changes": 31
} |
564 | diff --git a/DEPS b/DEPS
index 31fd17451674e..287c049ac1c4c 100644
--- a/DEPS
+++ b/DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
- '136.0.7103.33',
+ '136.0.7103.48',
'node_version':
'v22.14.0',
'nan_version':
diff --git a/patches/chromium/build_add_public_config_simdutf_config.patch b/patches/chromium/build_add_public_config_simdutf_config.patch
index 11a7174857f61..3417d2da5db21 100644
--- a/patches/chromium/build_add_public_config_simdutf_config.patch
+++ b/patches/chromium/build_add_public_config_simdutf_config.patch
@@ -11,7 +11,7 @@ To accomplish this, we need to make simdutf's config public here
for use by third_party/electron_node.
diff --git a/third_party/simdutf/BUILD.gn b/third_party/simdutf/BUILD.gn
-index d88fe7e43ac2a8129702e58bd2cd2aea094452e3..3cbeb89587f37b0ebc3622258fea0161ebf1d7b2 100644
+index 5fbce38841f04dad38f202f529ae84c609c6a8de..9f5ef9bceade8e30bbd2be616b9143e9708fefd8 100644
--- a/third_party/simdutf/BUILD.gn
+++ b/third_party/simdutf/BUILD.gn
@@ -6,9 +6,14 @@ source_set("header") {
diff --git a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
index ccd60b62c4c0b..b8e6f9b1f8afb 100644
--- a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
+++ b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
@@ -33,10 +33,10 @@ index 95c73dcb082999d0a85d82f1fe330d27c88055ca..64cd976eba849435779b280b2941f915
"//base",
"//build:branding_buildflags",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
-index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f97b187357 100644
+index b5783087429ee651d21e04f6f5f11f5cb6f015a8..dae1cca8cee4fccfed3183aca1ba7cc32652ea58 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
-@@ -4593,7 +4593,7 @@ static_library("browser") {
+@@ -4599,7 +4599,7 @@ static_library("browser") {
[ "//chrome/browser/ui/webui/signin:profile_impl" ]
}
@@ -46,10 +46,10 @@ index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f9
# than here in :chrome_dll.
deps += [ "//chrome:packed_resources_integrity_header" ]
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
-index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c47f49959e 100644
+index a1338c3f145e3ae0ca0acbe20ffcec35c3cc5ba1..39d0efc3367b80b18cf3a4ef8756f147807ad79b 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
-@@ -7092,9 +7092,12 @@ test("unit_tests") {
+@@ -7096,9 +7096,12 @@ test("unit_tests") {
"//chrome/notification_helper",
]
@@ -63,7 +63,7 @@ index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c4
"//chrome//services/util_win:unit_tests",
"//chrome/app:chrome_dll_resources",
"//chrome/app:win_unit_tests",
-@@ -8063,6 +8066,10 @@ test("unit_tests") {
+@@ -8067,6 +8070,10 @@ test("unit_tests") {
"../browser/performance_manager/policies/background_tab_loading_policy_unittest.cc",
]
@@ -74,7 +74,7 @@ index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c4
sources += [
# The importer code is not used on Android.
"../common/importer/firefox_importer_utils_unittest.cc",
-@@ -8118,7 +8125,6 @@ test("unit_tests") {
+@@ -8122,7 +8129,6 @@ test("unit_tests") {
# Non-android deps for "unit_tests" target.
deps += [
"../browser/screen_ai:screen_ai_install_state",
diff --git a/patches/chromium/can_create_window.patch b/patches/chromium/can_create_window.patch
index 48655e4a29fc7..5ac6345a8f52b 100644
--- a/patches/chromium/can_create_window.patch
+++ b/patches/chromium/can_create_window.patch
@@ -9,10 +9,10 @@ potentially prevent a window from being created.
TODO(loc): this patch is currently broken.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
-index d905ce52d71b2e2a4163fda68f584b3a3f305716..57a450929264e3f7592b5eab5126d176dbff8a58 100644
+index d9be4e90a7c43a8a7dec829304856daddcc58dc0..f6f98ea0824896e7e0a27e672480660b0671d146 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
-@@ -9644,6 +9644,7 @@ void RenderFrameHostImpl::CreateNewWindow(
+@@ -9652,6 +9652,7 @@ void RenderFrameHostImpl::CreateNewWindow(
last_committed_origin_, params->window_container_type,
params->target_url, params->referrer.To<Referrer>(),
params->frame_name, params->disposition, *params->features,
@@ -21,10 +21,10 @@ index d905ce52d71b2e2a4163fda68f584b3a3f305716..57a450929264e3f7592b5eab5126d176
&no_javascript_access);
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index f80d8ecc385df65610608ee78d6b09f2824a53fb..17009e944d6f3d23c721be521bf7843dbce1320e 100644
+index 2896b2b15d9c22e27c37719867c20213b9983984..83c5918c1bc0417ed3c744828b9f93e7c00d22c3 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -5095,6 +5095,12 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5101,6 +5101,12 @@ FrameTree* WebContentsImpl::CreateNewWindow(
SetPartitionedPopinOpenerOnNewWindowIfNeeded(new_contents_impl, params,
opener);
@@ -37,7 +37,7 @@ index f80d8ecc385df65610608ee78d6b09f2824a53fb..17009e944d6f3d23c721be521bf7843d
// If the new frame has a name, make sure any SiteInstances that can find
// this named frame have proxies for it. Must be called after
// SetSessionStorageNamespace, since this calls CreateRenderView, which uses
-@@ -5136,12 +5142,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5142,12 +5148,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
AddWebContentsDestructionObserver(new_contents_impl);
}
diff --git a/patches/chromium/chore_partial_revert_of.patch b/patches/chromium/chore_partial_revert_of.patch
index 14d92201cd07f..a2ece673822c0 100644
--- a/patches/chromium/chore_partial_revert_of.patch
+++ b/patches/chromium/chore_partial_revert_of.patch
@@ -14,10 +14,10 @@ track down the source of this problem & figure out if we can fix it
by changing something in Electron.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 3b43dcfef507b98f8af6f0c14c4fa9af0a7b9593..9c301542a54c3aeb5ec7ce408e312b48b33d22e3 100644
+index 5465e9d42a5c4eed3b6f819418a7b0ab92c7eae2..54ff9675fef009c5bb79becb59146436508ad835 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -5014,7 +5014,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5020,7 +5020,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
: IsGuest();
// While some guest types do not have a guest SiteInstance, the ones that
// don't all override WebContents creation above.
diff --git a/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch b/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
index 7a9f3b4f86e1b..27a9ad01bd17b 100644
--- a/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
+++ b/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
@@ -218,10 +218,10 @@ index c6838c83ef971b88769b1f3fba8095025ae25464..2da6a4e08340e72ba7de5d03444c2f17
content::WebContents* AddNewContents(
content::WebContents* source,
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 09c1b87b58fb2bf99c2a3b81b300e0cc1b9a0115..a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074 100644
+index d13c38de7a2e69565020ab92c874bf1289d63833..d7ec62c6761bcc8d4bb5889e873e22c4a27e7f17 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -4977,8 +4977,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -4983,8 +4983,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
// TODO(crbug.com/40202416): Support a way for MPArch guests to support this.
if (delegate_ && delegate_->IsWebContentsCreationOverridden(
source_site_instance, params.window_container_type,
diff --git a/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch b/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
index 725961ddd8861..aab52cd7e99d4 100644
--- a/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
+++ b/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
@@ -87,10 +87,10 @@ index 75df43e3cd2721a92c90c18154d53d5c203e2465..ce42c75c8face36d21f53f44c0201ac4
// The view with active text input state, i.e., a focused <input> element.
// It will be nullptr if no such view exists. Note that the active view
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index a793aa22e549e0fa8fee4665775761db97496eb2..3b43dcfef507b98f8af6f0c14c4fa9af0a7b9593 100644
+index 26f41d34766899e81e32c319aad00172ffdc5fca..5465e9d42a5c4eed3b6f819418a7b0ab92c7eae2 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -9843,7 +9843,7 @@ void WebContentsImpl::OnFocusedElementChangedInFrame(
+@@ -9856,7 +9856,7 @@ void WebContentsImpl::OnFocusedElementChangedInFrame(
"WebContentsImpl::OnFocusedElementChangedInFrame",
"render_frame_host", frame);
RenderWidgetHostViewBase* root_view =
diff --git a/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch b/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
index 63d244ca9ba91..06b952870f56d 100644
--- a/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
+++ b/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
@@ -10,10 +10,10 @@ an about:blank check to this area.
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5403876
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
-index 6372615eecc862325e88ebb9b189d380459163c7..38e360457b2fcb658db8c94fe26169a3f61a9cbc 100644
+index 80a6556e7b9bebc40ec61cb8b250b931b5d02bc2..b6a527a05d1f1f4286a72ec0efefcfe81288bc7c 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
-@@ -808,8 +808,8 @@ void VerifyThatBrowserAndRendererCalculatedOriginsToCommitMatch(
+@@ -809,8 +809,8 @@ void VerifyThatBrowserAndRendererCalculatedOriginsToCommitMatch(
// TODO(crbug.com/40092527): Consider adding a separate boolean that
// tracks this instead of piggybacking `origin_calculation_debug_info`.
if (renderer_side_origin.opaque() &&
diff --git a/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch b/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
index 0333718125f9e..fe633c675f5b1 100644
--- a/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
+++ b/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
@@ -44,10 +44,10 @@ index 20fcda4eb20459b69247003c51c2a3ed37c7b1e8..9bcab4e1e8a0fa429488555f4f7bd1c5
void RenderWidgetHostImpl::ShowContextMenuAtPoint(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 17009e944d6f3d23c721be521bf7843dbce1320e..09c1b87b58fb2bf99c2a3b81b300e0cc1b9a0115 100644
+index 83c5918c1bc0417ed3c744828b9f93e7c00d22c3..d13c38de7a2e69565020ab92c874bf1289d63833 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -5847,6 +5847,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
+@@ -5853,6 +5853,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
return text_input_manager_.get();
}
@@ -60,10 +60,10 @@ index 17009e944d6f3d23c721be521bf7843dbce1320e..09c1b87b58fb2bf99c2a3b81b300e0cc
RenderWidgetHostImpl* render_widget_host) {
return render_widget_host == GetPrimaryMainFrame()->GetRenderWidgetHost();
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
-index b3b274099fbe0df8892e686236e9a1f759c4d0e8..2baa178ed1d147c92de0ed32e94d9e2dbfc98310 100644
+index 8fa21e99ab8624817fead79c1b032af9b499c573..17d7fc9c29b8a9f57145fcf920c8bbd913da124b 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
-@@ -1178,6 +1178,7 @@ class CONTENT_EXPORT WebContentsImpl
+@@ -1186,6 +1186,7 @@ class CONTENT_EXPORT WebContentsImpl
void SendScreenRects() override;
void SendActiveState(bool active) override;
TextInputManager* GetTextInputManager() override;
@@ -72,7 +72,7 @@ index b3b274099fbe0df8892e686236e9a1f759c4d0e8..2baa178ed1d147c92de0ed32e94d9e2d
RenderWidgetHostImpl* render_widget_host) override;
bool IsShowingContextMenuOnPage() const override;
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
-index 9f9f4cc755886236da2f10516b119643fca9c933..cf263ec4bf7cc5443b5cca5b2d44d3a66f2a405b 100644
+index e06a02965a79f4bd0047d33262e2e9511e62fcce..9cf1f30f59d4ab49441ca633d6fa1b784268ca32 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -37,6 +37,7 @@
@@ -83,7 +83,7 @@ index 9f9f4cc755886236da2f10516b119643fca9c933..cf263ec4bf7cc5443b5cca5b2d44d3a6
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
-@@ -642,6 +643,9 @@ class CONTENT_EXPORT WebContentsObserver : public base::CheckedObserver {
+@@ -646,6 +647,9 @@ class CONTENT_EXPORT WebContentsObserver : public base::CheckedObserver {
// Invoked when the primary main frame changes size.
virtual void PrimaryMainFrameWasResized(bool width_changed) {}
diff --git a/patches/chromium/refactor_expose_file_system_access_blocklist.patch b/patches/chromium/refactor_expose_file_system_access_blocklist.patch
index 275fb4db72bf3..6a6e599c4dba1 100644
--- a/patches/chromium/refactor_expose_file_system_access_blocklist.patch
+++ b/patches/chromium/refactor_expose_file_system_access_blocklist.patch
@@ -8,7 +8,7 @@ it in Electron and prevent drift from Chrome's blocklist. We should look for a w
to upstream this change to Chrome.
diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
-index f08ff195ede9980cd0f491053510ed09c1b6c58a..2bdfcc05ef92c1983a9517deea98ed589ac0a065 100644
+index 6720c3f12d4ff86bd9c5262d3b0b5e42065ce506..c5081166876717cac04159855b690a24e2424ea8 100644
--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
@@ -45,7 +45,6 @@
@@ -153,7 +153,7 @@ index f08ff195ede9980cd0f491053510ed09c1b6c58a..2bdfcc05ef92c1983a9517deea98ed58
// Describes a rule for blocking a directory, which can be constructed
// dynamically (based on state) or statically (from kBlockedPaths).
diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
-index 68a712cb272224d7a75ff3f512e45ed82eab5a86..d46119d9a7a32c9dc0c4844da73c63b42af9f7a8 100644
+index ce16f32c9ec1280c1d68942dcaf392c21f9e7963..1e0f372a25b49babb33acc05ee86f475684b0441 100644
--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
@@ -21,7 +21,7 @@
diff --git a/patches/chromium/refactor_unfilter_unresponsive_events.patch b/patches/chromium/refactor_unfilter_unresponsive_events.patch
index e2db2163f2e0c..60d9345a1b810 100644
--- a/patches/chromium/refactor_unfilter_unresponsive_events.patch
+++ b/patches/chromium/refactor_unfilter_unresponsive_events.patch
@@ -15,10 +15,10 @@ This CL removes these filters so the unresponsive event can still be
accessed from our JS event. The filtering is moved into Electron's code.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 9c301542a54c3aeb5ec7ce408e312b48b33d22e3..d41390bf10906e6998b2c66476032541bfb97141 100644
+index 54ff9675fef009c5bb79becb59146436508ad835..aebd3b4fd597db7b02214dd61708711dc4ad75f3 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -9980,25 +9980,13 @@ void WebContentsImpl::RendererUnresponsive(
+@@ -9993,25 +9993,13 @@ void WebContentsImpl::RendererUnresponsive(
base::RepeatingClosure hang_monitor_restarter) {
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::RendererUnresponsive",
"render_widget_host", render_widget_host);
diff --git a/patches/chromium/web_contents.patch b/patches/chromium/web_contents.patch
index f4ac29b0edba8..f138ae5d41c96 100644
--- a/patches/chromium/web_contents.patch
+++ b/patches/chromium/web_contents.patch
@@ -9,10 +9,10 @@ is needed for OSR.
Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074..59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb 100644
+index d7ec62c6761bcc8d4bb5889e873e22c4a27e7f17..ac8aa81e213689a612d322fa75e81798ae1010e6 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -3916,6 +3916,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
+@@ -3922,6 +3922,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
params.main_frame_name, GetOpener(), primary_main_frame_policy,
base::UnguessableToken::Create());
@@ -26,7 +26,7 @@ index a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074..59fb6d36a047c2ce43dd4de3c3c44922
std::unique_ptr<WebContentsViewDelegate> delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
-@@ -3926,6 +3933,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
+@@ -3932,6 +3939,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
view_ = CreateWebContentsView(this, std::move(delegate),
&render_view_host_delegate_view_);
}
diff --git a/patches/chromium/webview_fullscreen.patch b/patches/chromium/webview_fullscreen.patch
index fae5f9ef2e997..44dab18bf4ba5 100644
--- a/patches/chromium/webview_fullscreen.patch
+++ b/patches/chromium/webview_fullscreen.patch
@@ -15,10 +15,10 @@ Note that we also need to manually update embedder's
`api::WebContents::IsFullscreenForTabOrPending` value.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
-index 57a450929264e3f7592b5eab5126d176dbff8a58..6372615eecc862325e88ebb9b189d380459163c7 100644
+index f6f98ea0824896e7e0a27e672480660b0671d146..80a6556e7b9bebc40ec61cb8b250b931b5d02bc2 100644
--- a/content/browser/renderer_host/render_frame_host_impl.cc
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
-@@ -8754,6 +8754,17 @@ void RenderFrameHostImpl::EnterFullscreen(
+@@ -8762,6 +8762,17 @@ void RenderFrameHostImpl::EnterFullscreen(
}
}
@@ -37,10 +37,10 @@ index 57a450929264e3f7592b5eab5126d176dbff8a58..6372615eecc862325e88ebb9b189d380
if (had_fullscreen_token && !GetView()->HasFocus())
GetView()->Focus();
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
-index 59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb..a793aa22e549e0fa8fee4665775761db97496eb2 100644
+index ac8aa81e213689a612d322fa75e81798ae1010e6..26f41d34766899e81e32c319aad00172ffdc5fca 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
-@@ -4191,21 +4191,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
+@@ -4197,21 +4197,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) {
OPTIONAL_TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
"WebContentsImpl::PreHandleKeyboardEvent");
@@ -78,7 +78,7 @@ index 59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb..a793aa22e549e0fa8fee4665775761db
}
bool WebContentsImpl::HandleMouseEvent(const blink::WebMouseEvent& event) {
-@@ -4364,7 +4368,7 @@ void WebContentsImpl::EnterFullscreenMode(
+@@ -4370,7 +4374,7 @@ void WebContentsImpl::EnterFullscreenMode(
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::EnterFullscreenMode");
DCHECK(CanEnterFullscreenMode(requesting_frame));
DCHECK(requesting_frame->IsActive());
| diff --git a/DEPS b/DEPS
index 31fd17451674e..287c049ac1c4c 100644
--- a/DEPS
+++ b/DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
- '136.0.7103.33',
+ '136.0.7103.48',
'node_version':
'v22.14.0',
'nan_version':
diff --git a/patches/chromium/build_add_public_config_simdutf_config.patch b/patches/chromium/build_add_public_config_simdutf_config.patch
index 11a7174857f61..3417d2da5db21 100644
--- a/patches/chromium/build_add_public_config_simdutf_config.patch
+++ b/patches/chromium/build_add_public_config_simdutf_config.patch
@@ -11,7 +11,7 @@ To accomplish this, we need to make simdutf's config public here
for use by third_party/electron_node.
diff --git a/third_party/simdutf/BUILD.gn b/third_party/simdutf/BUILD.gn
-index d88fe7e43ac2a8129702e58bd2cd2aea094452e3..3cbeb89587f37b0ebc3622258fea0161ebf1d7b2 100644
+index 5fbce38841f04dad38f202f529ae84c609c6a8de..9f5ef9bceade8e30bbd2be616b9143e9708fefd8 100644
--- a/third_party/simdutf/BUILD.gn
+++ b/third_party/simdutf/BUILD.gn
@@ -6,9 +6,14 @@ source_set("header") {
diff --git a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
index ccd60b62c4c0b..b8e6f9b1f8afb 100644
--- a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
+++ b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
@@ -33,10 +33,10 @@ index 95c73dcb082999d0a85d82f1fe330d27c88055ca..64cd976eba849435779b280b2941f915
"//base",
"//build:branding_buildflags",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
-index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f97b187357 100644
+index b5783087429ee651d21e04f6f5f11f5cb6f015a8..dae1cca8cee4fccfed3183aca1ba7cc32652ea58 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
-@@ -4593,7 +4593,7 @@ static_library("browser") {
[ "//chrome/browser/ui/webui/signin:profile_impl" ]
@@ -46,10 +46,10 @@ index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f9
# than here in :chrome_dll.
deps += [ "//chrome:packed_resources_integrity_header" ]
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
-index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c47f49959e 100644
+index a1338c3f145e3ae0ca0acbe20ffcec35c3cc5ba1..39d0efc3367b80b18cf3a4ef8756f147807ad79b 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
-@@ -7092,9 +7092,12 @@ test("unit_tests") {
+@@ -7096,9 +7096,12 @@ test("unit_tests") {
"//chrome/notification_helper",
@@ -63,7 +63,7 @@ index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c4
"//chrome//services/util_win:unit_tests",
"//chrome/app:chrome_dll_resources",
"//chrome/app:win_unit_tests",
-@@ -8063,6 +8066,10 @@ test("unit_tests") {
+@@ -8067,6 +8070,10 @@ test("unit_tests") {
"../browser/performance_manager/policies/background_tab_loading_policy_unittest.cc",
@@ -74,7 +74,7 @@ index 5de0d083bbbeddd5f394ac0154789566789099fb..692e44b75ac164a6f88398a4177913c4
sources += [
# The importer code is not used on Android.
"../common/importer/firefox_importer_utils_unittest.cc",
-@@ -8118,7 +8125,6 @@ test("unit_tests") {
+@@ -8122,7 +8129,6 @@ test("unit_tests") {
# Non-android deps for "unit_tests" target.
deps += [
"../browser/screen_ai:screen_ai_install_state",
diff --git a/patches/chromium/can_create_window.patch b/patches/chromium/can_create_window.patch
index 48655e4a29fc7..5ac6345a8f52b 100644
--- a/patches/chromium/can_create_window.patch
+++ b/patches/chromium/can_create_window.patch
@@ -9,10 +9,10 @@ potentially prevent a window from being created.
TODO(loc): this patch is currently broken.
-index d905ce52d71b2e2a4163fda68f584b3a3f305716..57a450929264e3f7592b5eab5126d176dbff8a58 100644
+index d9be4e90a7c43a8a7dec829304856daddcc58dc0..f6f98ea0824896e7e0a27e672480660b0671d146 100644
-@@ -9644,6 +9644,7 @@ void RenderFrameHostImpl::CreateNewWindow(
+@@ -9652,6 +9652,7 @@ void RenderFrameHostImpl::CreateNewWindow(
last_committed_origin_, params->window_container_type,
params->target_url, params->referrer.To<Referrer>(),
params->frame_name, params->disposition, *params->features,
@@ -21,10 +21,10 @@ index d905ce52d71b2e2a4163fda68f584b3a3f305716..57a450929264e3f7592b5eab5126d176
&no_javascript_access);
-index f80d8ecc385df65610608ee78d6b09f2824a53fb..17009e944d6f3d23c721be521bf7843dbce1320e 100644
+index 2896b2b15d9c22e27c37719867c20213b9983984..83c5918c1bc0417ed3c744828b9f93e7c00d22c3 100644
-@@ -5095,6 +5095,12 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5101,6 +5101,12 @@ FrameTree* WebContentsImpl::CreateNewWindow(
SetPartitionedPopinOpenerOnNewWindowIfNeeded(new_contents_impl, params,
opener);
@@ -37,7 +37,7 @@ index f80d8ecc385df65610608ee78d6b09f2824a53fb..17009e944d6f3d23c721be521bf7843d
// If the new frame has a name, make sure any SiteInstances that can find
// this named frame have proxies for it. Must be called after
// SetSessionStorageNamespace, since this calls CreateRenderView, which uses
-@@ -5136,12 +5142,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5142,12 +5148,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
AddWebContentsDestructionObserver(new_contents_impl);
diff --git a/patches/chromium/chore_partial_revert_of.patch b/patches/chromium/chore_partial_revert_of.patch
index 14d92201cd07f..a2ece673822c0 100644
--- a/patches/chromium/chore_partial_revert_of.patch
+++ b/patches/chromium/chore_partial_revert_of.patch
@@ -14,10 +14,10 @@ track down the source of this problem & figure out if we can fix it
by changing something in Electron.
-index 3b43dcfef507b98f8af6f0c14c4fa9af0a7b9593..9c301542a54c3aeb5ec7ce408e312b48b33d22e3 100644
+index 5465e9d42a5c4eed3b6f819418a7b0ab92c7eae2..54ff9675fef009c5bb79becb59146436508ad835 100644
-@@ -5014,7 +5014,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -5020,7 +5020,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
: IsGuest();
// While some guest types do not have a guest SiteInstance, the ones that
// don't all override WebContents creation above.
diff --git a/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch b/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
index 7a9f3b4f86e1b..27a9ad01bd17b 100644
--- a/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
+++ b/patches/chromium/chore_provide_iswebcontentscreationoverridden_with_full_params.patch
@@ -218,10 +218,10 @@ index c6838c83ef971b88769b1f3fba8095025ae25464..2da6a4e08340e72ba7de5d03444c2f17
content::WebContents* AddNewContents(
content::WebContents* source,
-index 09c1b87b58fb2bf99c2a3b81b300e0cc1b9a0115..a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074 100644
+index d13c38de7a2e69565020ab92c874bf1289d63833..d7ec62c6761bcc8d4bb5889e873e22c4a27e7f17 100644
-@@ -4977,8 +4977,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
+@@ -4983,8 +4983,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
// TODO(crbug.com/40202416): Support a way for MPArch guests to support this.
if (delegate_ && delegate_->IsWebContentsCreationOverridden(
source_site_instance, params.window_container_type,
diff --git a/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch b/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
index 725961ddd8861..aab52cd7e99d4 100644
--- a/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
+++ b/patches/chromium/fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
@@ -87,10 +87,10 @@ index 75df43e3cd2721a92c90c18154d53d5c203e2465..ce42c75c8face36d21f53f44c0201ac4
// The view with active text input state, i.e., a focused <input> element.
// It will be nullptr if no such view exists. Note that the active view
-index a793aa22e549e0fa8fee4665775761db97496eb2..3b43dcfef507b98f8af6f0c14c4fa9af0a7b9593 100644
+index 26f41d34766899e81e32c319aad00172ffdc5fca..5465e9d42a5c4eed3b6f819418a7b0ab92c7eae2 100644
-@@ -9843,7 +9843,7 @@ void WebContentsImpl::OnFocusedElementChangedInFrame(
+@@ -9856,7 +9856,7 @@ void WebContentsImpl::OnFocusedElementChangedInFrame(
"WebContentsImpl::OnFocusedElementChangedInFrame",
"render_frame_host", frame);
RenderWidgetHostViewBase* root_view =
diff --git a/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch b/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
index 63d244ca9ba91..06b952870f56d 100644
--- a/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
+++ b/patches/chromium/partially_revert_is_newly_created_to_allow_for_browser_initiated.patch
@@ -10,10 +10,10 @@ an about:blank check to this area.
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/5403876
+index 80a6556e7b9bebc40ec61cb8b250b931b5d02bc2..b6a527a05d1f1f4286a72ec0efefcfe81288bc7c 100644
-@@ -808,8 +808,8 @@ void VerifyThatBrowserAndRendererCalculatedOriginsToCommitMatch(
+@@ -809,8 +809,8 @@ void VerifyThatBrowserAndRendererCalculatedOriginsToCommitMatch(
// TODO(crbug.com/40092527): Consider adding a separate boolean that
// tracks this instead of piggybacking `origin_calculation_debug_info`.
if (renderer_side_origin.opaque() &&
diff --git a/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch b/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
index 0333718125f9e..fe633c675f5b1 100644
--- a/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
+++ b/patches/chromium/refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
@@ -44,10 +44,10 @@ index 20fcda4eb20459b69247003c51c2a3ed37c7b1e8..9bcab4e1e8a0fa429488555f4f7bd1c5
void RenderWidgetHostImpl::ShowContextMenuAtPoint(
-index 17009e944d6f3d23c721be521bf7843dbce1320e..09c1b87b58fb2bf99c2a3b81b300e0cc1b9a0115 100644
+index 83c5918c1bc0417ed3c744828b9f93e7c00d22c3..d13c38de7a2e69565020ab92c874bf1289d63833 100644
-@@ -5847,6 +5847,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
+@@ -5853,6 +5853,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
return text_input_manager_.get();
@@ -60,10 +60,10 @@ index 17009e944d6f3d23c721be521bf7843dbce1320e..09c1b87b58fb2bf99c2a3b81b300e0cc
RenderWidgetHostImpl* render_widget_host) {
return render_widget_host == GetPrimaryMainFrame()->GetRenderWidgetHost();
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
+index 8fa21e99ab8624817fead79c1b032af9b499c573..17d7fc9c29b8a9f57145fcf920c8bbd913da124b 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
+@@ -1186,6 +1186,7 @@ class CONTENT_EXPORT WebContentsImpl
void SendScreenRects() override;
void SendActiveState(bool active) override;
TextInputManager* GetTextInputManager() override;
@@ -72,7 +72,7 @@ index b3b274099fbe0df8892e686236e9a1f759c4d0e8..2baa178ed1d147c92de0ed32e94d9e2d
RenderWidgetHostImpl* render_widget_host) override;
bool IsShowingContextMenuOnPage() const override;
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
-index 9f9f4cc755886236da2f10516b119643fca9c933..cf263ec4bf7cc5443b5cca5b2d44d3a66f2a405b 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -37,6 +37,7 @@
@@ -83,7 +83,7 @@ index 9f9f4cc755886236da2f10516b119643fca9c933..cf263ec4bf7cc5443b5cca5b2d44d3a6
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
-@@ -642,6 +643,9 @@ class CONTENT_EXPORT WebContentsObserver : public base::CheckedObserver {
+@@ -646,6 +647,9 @@ class CONTENT_EXPORT WebContentsObserver : public base::CheckedObserver {
// Invoked when the primary main frame changes size.
virtual void PrimaryMainFrameWasResized(bool width_changed) {}
diff --git a/patches/chromium/refactor_expose_file_system_access_blocklist.patch b/patches/chromium/refactor_expose_file_system_access_blocklist.patch
index 275fb4db72bf3..6a6e599c4dba1 100644
--- a/patches/chromium/refactor_expose_file_system_access_blocklist.patch
+++ b/patches/chromium/refactor_expose_file_system_access_blocklist.patch
@@ -8,7 +8,7 @@ it in Electron and prevent drift from Chrome's blocklist. We should look for a w
to upstream this change to Chrome.
diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
+index 6720c3f12d4ff86bd9c5262d3b0b5e42065ce506..c5081166876717cac04159855b690a24e2424ea8 100644
--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.cc
@@ -45,7 +45,6 @@
@@ -153,7 +153,7 @@ index f08ff195ede9980cd0f491053510ed09c1b6c58a..2bdfcc05ef92c1983a9517deea98ed58
// Describes a rule for blocking a directory, which can be constructed
// dynamically (based on state) or statically (from kBlockedPaths).
diff --git a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
-index 68a712cb272224d7a75ff3f512e45ed82eab5a86..d46119d9a7a32c9dc0c4844da73c63b42af9f7a8 100644
+index ce16f32c9ec1280c1d68942dcaf392c21f9e7963..1e0f372a25b49babb33acc05ee86f475684b0441 100644
--- a/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
+++ b/chrome/browser/file_system_access/chrome_file_system_access_permission_context.h
@@ -21,7 +21,7 @@
diff --git a/patches/chromium/refactor_unfilter_unresponsive_events.patch b/patches/chromium/refactor_unfilter_unresponsive_events.patch
index e2db2163f2e0c..60d9345a1b810 100644
--- a/patches/chromium/refactor_unfilter_unresponsive_events.patch
+++ b/patches/chromium/refactor_unfilter_unresponsive_events.patch
@@ -15,10 +15,10 @@ This CL removes these filters so the unresponsive event can still be
accessed from our JS event. The filtering is moved into Electron's code.
-index 9c301542a54c3aeb5ec7ce408e312b48b33d22e3..d41390bf10906e6998b2c66476032541bfb97141 100644
+index 54ff9675fef009c5bb79becb59146436508ad835..aebd3b4fd597db7b02214dd61708711dc4ad75f3 100644
-@@ -9980,25 +9980,13 @@ void WebContentsImpl::RendererUnresponsive(
+@@ -9993,25 +9993,13 @@ void WebContentsImpl::RendererUnresponsive(
base::RepeatingClosure hang_monitor_restarter) {
OPTIONAL_TRACE_EVENT1("content", "WebContentsImpl::RendererUnresponsive",
"render_widget_host", render_widget_host);
diff --git a/patches/chromium/web_contents.patch b/patches/chromium/web_contents.patch
index f4ac29b0edba8..f138ae5d41c96 100644
--- a/patches/chromium/web_contents.patch
+++ b/patches/chromium/web_contents.patch
@@ -9,10 +9,10 @@ is needed for OSR.
Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
-index a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074..59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb 100644
+index d7ec62c6761bcc8d4bb5889e873e22c4a27e7f17..ac8aa81e213689a612d322fa75e81798ae1010e6 100644
-@@ -3916,6 +3916,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
+@@ -3922,6 +3922,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
params.main_frame_name, GetOpener(), primary_main_frame_policy,
base::UnguessableToken::Create());
@@ -26,7 +26,7 @@ index a1ba9ea494a6b2da2b3fdfeb02491d37b3da9074..59fb6d36a047c2ce43dd4de3c3c44922
std::unique_ptr<WebContentsViewDelegate> delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
-@@ -3926,6 +3933,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
+@@ -3932,6 +3939,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
view_ = CreateWebContentsView(this, std::move(delegate),
&render_view_host_delegate_view_);
diff --git a/patches/chromium/webview_fullscreen.patch b/patches/chromium/webview_fullscreen.patch
index fae5f9ef2e997..44dab18bf4ba5 100644
--- a/patches/chromium/webview_fullscreen.patch
+++ b/patches/chromium/webview_fullscreen.patch
@@ -15,10 +15,10 @@ Note that we also need to manually update embedder's
`api::WebContents::IsFullscreenForTabOrPending` value.
-index 57a450929264e3f7592b5eab5126d176dbff8a58..6372615eecc862325e88ebb9b189d380459163c7 100644
+index f6f98ea0824896e7e0a27e672480660b0671d146..80a6556e7b9bebc40ec61cb8b250b931b5d02bc2 100644
-@@ -8754,6 +8754,17 @@ void RenderFrameHostImpl::EnterFullscreen(
+@@ -8762,6 +8762,17 @@ void RenderFrameHostImpl::EnterFullscreen(
@@ -37,10 +37,10 @@ index 57a450929264e3f7592b5eab5126d176dbff8a58..6372615eecc862325e88ebb9b189d380
if (had_fullscreen_token && !GetView()->HasFocus())
GetView()->Focus();
-index 59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb..a793aa22e549e0fa8fee4665775761db97496eb2 100644
+index ac8aa81e213689a612d322fa75e81798ae1010e6..26f41d34766899e81e32c319aad00172ffdc5fca 100644
-@@ -4191,21 +4191,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
+@@ -4197,21 +4197,25 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent(
const input::NativeWebKeyboardEvent& event) {
OPTIONAL_TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
"WebContentsImpl::PreHandleKeyboardEvent");
@@ -78,7 +78,7 @@ index 59fb6d36a047c2ce43dd4de3c3c4492275d5f0cb..a793aa22e549e0fa8fee4665775761db
bool WebContentsImpl::HandleMouseEvent(const blink::WebMouseEvent& event) {
-@@ -4364,7 +4368,7 @@ void WebContentsImpl::EnterFullscreenMode(
+@@ -4370,7 +4374,7 @@ void WebContentsImpl::EnterFullscreenMode(
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::EnterFullscreenMode");
DCHECK(CanEnterFullscreenMode(requesting_frame));
DCHECK(requesting_frame->IsActive()); | [
"+@@ -4599,7 +4599,7 @@ static_library(\"browser\") {",
"-index 6372615eecc862325e88ebb9b189d380459163c7..38e360457b2fcb658db8c94fe26169a3f61a9cbc 100644",
"-index b3b274099fbe0df8892e686236e9a1f759c4d0e8..2baa178ed1d147c92de0ed32e94d9e2dbfc98310 100644",
"-@@ -1178,6 +1178,7 @@ class CONTENT_EXPORT WebContentsImpl",
"+index e06a02965a79f4bd0047d33262e2e9511e62fcce..9cf1f30f59d4ab49441ca633d6fa1b784268ca32 100644",
"-index f08ff195ede9980cd0f491053510ed09c1b6c58a..2bdfcc05ef92c1983a9517deea98ed589ac0a065 100644"
] | [
39,
172,
202,
206,
216,
237
] | {
"additions": 39,
"author": "electron-roller[bot]",
"deletions": 39,
"html_url": "https://github.com/electron/electron/pull/46756",
"issue_id": 46756,
"merged_at": "2025-04-25T09:40:46Z",
"omission_probability": 0.1,
"pr_number": 46756,
"repo": "electron/electron",
"title": "chore: bump chromium to 136.0.7103.48 (36-x-y)",
"total_changes": 78
} |
565 | diff --git a/filenames.gni b/filenames.gni
index ea1637c990309..45fafbdb52eb5 100644
--- a/filenames.gni
+++ b/filenames.gni
@@ -125,6 +125,7 @@ filenames = {
"shell/browser/animation_util.h",
"shell/browser/animation_util_mac.mm",
"shell/browser/api/electron_api_app_mac.mm",
+ "shell/browser/api/electron_api_base_window_mac.mm",
"shell/browser/api/electron_api_menu_mac.h",
"shell/browser/api/electron_api_menu_mac.mm",
"shell/browser/api/electron_api_native_theme_mac.mm",
diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index 848cc6cc2c9f8..a7983dd39c8bc 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -70,6 +70,7 @@ namespace electron::api {
namespace {
+#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@@ -78,6 +79,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
else
return buffer.ToLocalChecked();
}
+#endif
[[nodiscard]] constexpr std::array<int, 2U> ToArray(const gfx::Size size) {
return {size.width(), size.height()};
@@ -778,6 +780,7 @@ std::string BaseWindow::GetMediaSourceId() const {
return window_->GetDesktopMediaID().ToString();
}
+#if !BUILDFLAG(IS_MAC)
v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
@@ -785,6 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
}
+#endif
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) {
gin_helper::Dictionary options;
diff --git a/shell/browser/api/electron_api_base_window_mac.mm b/shell/browser/api/electron_api_base_window_mac.mm
new file mode 100644
index 0000000000000..148ec216283f7
--- /dev/null
+++ b/shell/browser/api/electron_api_base_window_mac.mm
@@ -0,0 +1,32 @@
+// Copyright (c) 2025 Microsoft, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "shell/browser/api/electron_api_base_window.h"
+
+#include "electron/buildflags/buildflags.h"
+#include "shell/browser/api/electron_api_view.h"
+#include "shell/browser/native_window.h"
+#include "shell/common/node_includes.h"
+
+namespace {
+
+// Converts binary data to Buffer.
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
+ auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+ if (buffer.IsEmpty())
+ return v8::Null(isolate);
+ else
+ return buffer.ToLocalChecked();
+}
+
+} // namespace
+
+namespace electron::api {
+
+v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
+ NSView* handle = window_->GetNativeWindowHandle().GetNativeNSView();
+ return ToBuffer(isolate(), &handle, sizeof(handle));
+}
+
+} // namespace electron::api
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..bf5f6ec4b44b2 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,15 +3743,17 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
}
+#if !BUILDFLAG(IS_MAC)
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer = node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr),
- sizeof(gfx::NativeView));
+ auto buffer =
+ node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
if (buffer.IsEmpty())
return v8::Null(isolate);
else
return buffer.ToLocalChecked();
}
+#endif
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 52c4362839610..1358b3dde95da 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
+#include "shell/common/node_includes.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -92,4 +93,22 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
}
+namespace {
+
+// Converts binary data to Buffer.
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
+ auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+ if (buffer.IsEmpty())
+ return v8::Null(isolate);
+ else
+ return buffer.ToLocalChecked();
+}
+
+} // namespace
+
+v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
+ NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
+ return ToBuffer(isolate, &handle, sizeof(handle));
+}
+
} // namespace electron::api
diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h
index cc4d150ca72b1..831cf8947aa85 100644
--- a/shell/browser/native_window.h
+++ b/shell/browser/native_window.h
@@ -58,9 +58,9 @@ class BrowserView;
}
#if BUILDFLAG(IS_MAC)
-typedef gfx::NativeView NativeWindowHandle;
+using NativeWindowHandle = gfx::NativeView;
#else
-typedef gfx::AcceleratedWidget NativeWindowHandle;
+using NativeWindowHandle = gfx::AcceleratedWidget;
#endif
class NativeWindow : public base::SupportsUserData,
| diff --git a/filenames.gni b/filenames.gni
index ea1637c990309..45fafbdb52eb5 100644
--- a/filenames.gni
+++ b/filenames.gni
@@ -125,6 +125,7 @@ filenames = {
"shell/browser/animation_util.h",
"shell/browser/animation_util_mac.mm",
"shell/browser/api/electron_api_app_mac.mm",
+ "shell/browser/api/electron_api_base_window_mac.mm",
"shell/browser/api/electron_api_menu_mac.h",
"shell/browser/api/electron_api_menu_mac.mm",
"shell/browser/api/electron_api_native_theme_mac.mm",
diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index 848cc6cc2c9f8..a7983dd39c8bc 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -70,6 +70,7 @@ namespace electron::api {
namespace {
// Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@@ -78,6 +79,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
[[nodiscard]] constexpr std::array<int, 2U> ToArray(const gfx::Size size) {
return {size.width(), size.height()};
@@ -778,6 +780,7 @@ std::string BaseWindow::GetMediaSourceId() const {
return window_->GetDesktopMediaID().ToString();
v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
@@ -785,6 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) {
gin_helper::Dictionary options;
diff --git a/shell/browser/api/electron_api_base_window_mac.mm b/shell/browser/api/electron_api_base_window_mac.mm
new file mode 100644
index 0000000000000..148ec216283f7
--- /dev/null
+++ b/shell/browser/api/electron_api_base_window_mac.mm
@@ -0,0 +1,32 @@
+// Copyright (c) 2025 Microsoft, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+#include "shell/browser/api/electron_api_base_window.h"
+#include "electron/buildflags/buildflags.h"
+#include "shell/browser/api/electron_api_view.h"
+#include "shell/browser/native_window.h"
+namespace electron::api {
+v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
+ NSView* handle = window_->GetNativeWindowHandle().GetNativeNSView();
+ return ToBuffer(isolate(), &handle, sizeof(handle));
+} // namespace electron::api
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..bf5f6ec4b44b2 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,15 +3743,17 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer = node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr),
- sizeof(gfx::NativeView));
+ auto buffer =
+ node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
if (buffer.IsEmpty())
return v8::Null(isolate);
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 52c4362839610..1358b3dde95da 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -92,4 +93,22 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
+v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
+ NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
+ return ToBuffer(isolate, &handle, sizeof(handle));
} // namespace electron::api
diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h
index cc4d150ca72b1..831cf8947aa85 100644
--- a/shell/browser/native_window.h
+++ b/shell/browser/native_window.h
@@ -58,9 +58,9 @@ class BrowserView;
#if BUILDFLAG(IS_MAC)
-typedef gfx::NativeView NativeWindowHandle;
+using NativeWindowHandle = gfx::NativeView;
#else
-typedef gfx::AcceleratedWidget NativeWindowHandle;
+using NativeWindowHandle = gfx::AcceleratedWidget;
#endif
class NativeWindow : public base::SupportsUserData, | [] | [] | {
"additions": 62,
"author": "trop[bot]",
"deletions": 4,
"html_url": "https://github.com/electron/electron/pull/46750",
"issue_id": 46750,
"merged_at": "2025-04-24T14:53:54Z",
"omission_probability": 0.1,
"pr_number": 46750,
"repo": "electron/electron",
"title": "fix: explicitly call GetNativeNSView() on macOS",
"total_changes": 66
} |
566 | diff --git a/filenames.gni b/filenames.gni
index ea1637c990309..45fafbdb52eb5 100644
--- a/filenames.gni
+++ b/filenames.gni
@@ -125,6 +125,7 @@ filenames = {
"shell/browser/animation_util.h",
"shell/browser/animation_util_mac.mm",
"shell/browser/api/electron_api_app_mac.mm",
+ "shell/browser/api/electron_api_base_window_mac.mm",
"shell/browser/api/electron_api_menu_mac.h",
"shell/browser/api/electron_api_menu_mac.mm",
"shell/browser/api/electron_api_native_theme_mac.mm",
diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index 848cc6cc2c9f8..a7983dd39c8bc 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -70,6 +70,7 @@ namespace electron::api {
namespace {
+#if !BUILDFLAG(IS_MAC)
// Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@@ -78,6 +79,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
else
return buffer.ToLocalChecked();
}
+#endif
[[nodiscard]] constexpr std::array<int, 2U> ToArray(const gfx::Size size) {
return {size.width(), size.height()};
@@ -778,6 +780,7 @@ std::string BaseWindow::GetMediaSourceId() const {
return window_->GetDesktopMediaID().ToString();
}
+#if !BUILDFLAG(IS_MAC)
v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
@@ -785,6 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
}
+#endif
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) {
gin_helper::Dictionary options;
diff --git a/shell/browser/api/electron_api_base_window_mac.mm b/shell/browser/api/electron_api_base_window_mac.mm
new file mode 100644
index 0000000000000..148ec216283f7
--- /dev/null
+++ b/shell/browser/api/electron_api_base_window_mac.mm
@@ -0,0 +1,32 @@
+// Copyright (c) 2025 Microsoft, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "shell/browser/api/electron_api_base_window.h"
+
+#include "electron/buildflags/buildflags.h"
+#include "shell/browser/api/electron_api_view.h"
+#include "shell/browser/native_window.h"
+#include "shell/common/node_includes.h"
+
+namespace {
+
+// Converts binary data to Buffer.
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
+ auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+ if (buffer.IsEmpty())
+ return v8::Null(isolate);
+ else
+ return buffer.ToLocalChecked();
+}
+
+} // namespace
+
+namespace electron::api {
+
+v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
+ NSView* handle = window_->GetNativeWindowHandle().GetNativeNSView();
+ return ToBuffer(isolate(), &handle, sizeof(handle));
+}
+
+} // namespace electron::api
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..bf5f6ec4b44b2 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,15 +3743,17 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
}
+#if !BUILDFLAG(IS_MAC)
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer = node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr),
- sizeof(gfx::NativeView));
+ auto buffer =
+ node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
if (buffer.IsEmpty())
return v8::Null(isolate);
else
return buffer.ToLocalChecked();
}
+#endif
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 52c4362839610..1358b3dde95da 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
+#include "shell/common/node_includes.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -92,4 +93,22 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
}
+namespace {
+
+// Converts binary data to Buffer.
+v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
+ auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
+ if (buffer.IsEmpty())
+ return v8::Null(isolate);
+ else
+ return buffer.ToLocalChecked();
+}
+
+} // namespace
+
+v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
+ NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
+ return ToBuffer(isolate, &handle, sizeof(handle));
+}
+
} // namespace electron::api
diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h
index cc4d150ca72b1..831cf8947aa85 100644
--- a/shell/browser/native_window.h
+++ b/shell/browser/native_window.h
@@ -58,9 +58,9 @@ class BrowserView;
}
#if BUILDFLAG(IS_MAC)
-typedef gfx::NativeView NativeWindowHandle;
+using NativeWindowHandle = gfx::NativeView;
#else
-typedef gfx::AcceleratedWidget NativeWindowHandle;
+using NativeWindowHandle = gfx::AcceleratedWidget;
#endif
class NativeWindow : public base::SupportsUserData,
| diff --git a/filenames.gni b/filenames.gni
index ea1637c990309..45fafbdb52eb5 100644
--- a/filenames.gni
+++ b/filenames.gni
@@ -125,6 +125,7 @@ filenames = {
"shell/browser/animation_util.h",
"shell/browser/animation_util_mac.mm",
"shell/browser/api/electron_api_app_mac.mm",
+ "shell/browser/api/electron_api_base_window_mac.mm",
"shell/browser/api/electron_api_menu_mac.h",
"shell/browser/api/electron_api_menu_mac.mm",
"shell/browser/api/electron_api_native_theme_mac.mm",
diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc
index 848cc6cc2c9f8..a7983dd39c8bc 100644
--- a/shell/browser/api/electron_api_base_window.cc
+++ b/shell/browser/api/electron_api_base_window.cc
@@ -70,6 +70,7 @@ namespace electron::api {
namespace {
// Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@@ -78,6 +79,7 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
[[nodiscard]] constexpr std::array<int, 2U> ToArray(const gfx::Size size) {
return {size.width(), size.height()};
@@ -778,6 +780,7 @@ std::string BaseWindow::GetMediaSourceId() const {
return window_->GetDesktopMediaID().ToString();
v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
// TODO(MarshallOfSound): Replace once
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
@@ -785,6 +788,7 @@ v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
NativeWindowHandle handle = window_->GetNativeWindowHandle();
return ToBuffer(isolate(), &handle, sizeof(handle));
void BaseWindow::SetProgressBar(double progress, gin_helper::Arguments* args) {
gin_helper::Dictionary options;
diff --git a/shell/browser/api/electron_api_base_window_mac.mm b/shell/browser/api/electron_api_base_window_mac.mm
new file mode 100644
index 0000000000000..148ec216283f7
--- /dev/null
+++ b/shell/browser/api/electron_api_base_window_mac.mm
@@ -0,0 +1,32 @@
+// Copyright (c) 2025 Microsoft, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+#include "shell/browser/api/electron_api_base_window.h"
+#include "electron/buildflags/buildflags.h"
+#include "shell/browser/api/electron_api_view.h"
+#include "shell/browser/native_window.h"
+v8::Local<v8::Value> BaseWindow::GetNativeWindowHandle() {
+ return ToBuffer(isolate(), &handle, sizeof(handle));
+} // namespace electron::api
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index 0779c4919b29a..bf5f6ec4b44b2 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,15 +3743,17 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer = node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr),
- sizeof(gfx::NativeView));
+ auto buffer =
+ node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
if (buffer.IsEmpty())
return v8::Null(isolate);
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 52c4362839610..1358b3dde95da 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -92,4 +93,22 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
+v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
+ NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
} // namespace electron::api
diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h
index cc4d150ca72b1..831cf8947aa85 100644
--- a/shell/browser/native_window.h
+++ b/shell/browser/native_window.h
@@ -58,9 +58,9 @@ class BrowserView;
#if BUILDFLAG(IS_MAC)
-typedef gfx::NativeView NativeWindowHandle;
+using NativeWindowHandle = gfx::NativeView;
#else
-typedef gfx::AcceleratedWidget NativeWindowHandle;
+using NativeWindowHandle = gfx::AcceleratedWidget;
#endif
class NativeWindow : public base::SupportsUserData, | [
"+namespace electron::api {",
"+ NSView* handle = window_->GetNativeWindowHandle().GetNativeNSView();",
"+ return ToBuffer(isolate, &handle, sizeof(handle));"
] | [
78,
81,
141
] | {
"additions": 62,
"author": "ckerr",
"deletions": 4,
"html_url": "https://github.com/electron/electron/pull/46733",
"issue_id": 46733,
"merged_at": "2025-04-23T22:55:18Z",
"omission_probability": 0.1,
"pr_number": 46733,
"repo": "electron/electron",
"title": "fix: explicitly call GetNativeNSView() on macOS",
"total_changes": 66
} |
567 | diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc
index e5320308a2dcf..44de6c197f09b 100644
--- a/shell/browser/native_window_views.cc
+++ b/shell/browser/native_window_views.cc
@@ -642,8 +642,22 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
#endif
}
-#if BUILDFLAG(IS_LINUX)
void NativeWindowViews::Maximize() {
+#if BUILDFLAG(IS_WIN)
+ if (IsTranslucent()) {
+ // If a window is translucent but not transparent on Windows,
+ // that means it must have a backgroundMaterial set.
+ if (!transparent())
+ SetRoundedCorners(false);
+ restore_bounds_ = GetBounds();
+ auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
+ GetNativeWindow());
+ SetBounds(display.work_area(), false);
+ NotifyWindowMaximize();
+ return;
+ }
+#endif
+
if (IsVisible()) {
widget()->Maximize();
} else {
@@ -652,44 +666,46 @@ void NativeWindowViews::Maximize() {
NotifyWindowShow();
}
}
-#endif
void NativeWindowViews::Unmaximize() {
- if (IsMaximized()) {
+ if (!IsMaximized())
+ return;
+
#if BUILDFLAG(IS_WIN)
+ if (IsTranslucent()) {
+ SetBounds(restore_bounds_, false);
+ NotifyWindowUnmaximize();
if (transparent()) {
- SetBounds(restore_bounds_, false);
- NotifyWindowUnmaximize();
UpdateThickFrame();
- return;
+ } else {
+ SetRoundedCorners(true);
}
+ return;
+ }
#endif
- widget()->Restore();
+ widget()->Restore();
#if BUILDFLAG(IS_WIN)
- UpdateThickFrame();
+ UpdateThickFrame();
#endif
- }
}
bool NativeWindowViews::IsMaximized() const {
- if (widget()->IsMaximized()) {
+ if (widget()->IsMaximized())
return true;
- } else {
+
#if BUILDFLAG(IS_WIN)
- if (transparent() && !IsMinimized()) {
- // Compare the size of the window with the size of the display
- auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
- GetNativeWindow());
- // Maximized if the window is the same dimensions and placement as the
- // display
- return GetBounds() == display.work_area();
- }
+ if (IsTranslucent() && !IsMinimized()) {
+ // If the window is the same dimensions and placement as the
+ // display, we consider it maximized.
+ auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
+ GetNativeWindow());
+ return GetBounds() == display.work_area();
+ }
#endif
- return false;
- }
+ return false;
}
void NativeWindowViews::Minimize() {
@@ -702,10 +718,14 @@ void NativeWindowViews::Minimize() {
void NativeWindowViews::Restore() {
#if BUILDFLAG(IS_WIN)
- if (IsMaximized() && transparent()) {
+ if (IsMaximized() && IsTranslucent()) {
SetBounds(restore_bounds_, false);
NotifyWindowRestore();
- UpdateThickFrame();
+ if (transparent()) {
+ UpdateThickFrame();
+ } else {
+ SetRoundedCorners(true);
+ }
return;
}
#endif
@@ -845,7 +865,7 @@ gfx::Size NativeWindowViews::GetContentSize() const {
gfx::Rect NativeWindowViews::GetNormalBounds() const {
#if BUILDFLAG(IS_WIN)
- if (IsMaximized() && transparent())
+ if (IsMaximized() && IsTranslucent())
return restore_bounds_;
#endif
return widget()->GetRestoredBounds();
@@ -860,8 +880,8 @@ void NativeWindowViews::SetContentSizeConstraints(
if (!thick_frame_)
return;
#endif
- // widget_delegate() is only available after Init() is called, we make use of
- // this to determine whether native widget has initialized.
+ // widget_delegate() is only available after Init() is called, we make use
+ // of this to determine whether native widget has initialized.
if (widget() && widget()->widget_delegate())
widget()->OnSizeConstraintsChanged();
if (resizable_)
@@ -1639,9 +1659,9 @@ void NativeWindowViews::UpdateThickFrame() {
return;
if (IsMaximized() && !transparent()) {
- // For maximized window add thick frame always, otherwise it will be removed
- // in HWNDMessageHandler::SizeConstraintsChanged() which will result in
- // maximized window bounds change.
+ // For maximized window add thick frame always, otherwise it will be
+ // removed in HWNDMessageHandler::SizeConstraintsChanged() which will
+ // result in maximized window bounds change.
FlipWindowStyle(GetAcceleratedWidget(), true, WS_THICKFRAME);
} else if (has_frame()) {
FlipWindowStyle(GetAcceleratedWidget(), resizable_, WS_THICKFRAME);
@@ -1679,10 +1699,10 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
// WidgetObserver::OnWidgetBoundsChanged is being called from
// Widget::OnNativeWidgetMove() and not Widget::OnNativeWidgetSizeChanged.
// |GetWindowBoundsInScreen| has a ~1 pixel margin
- // of error because it converts from floats to integers between calculations,
- // so if we check existing bounds directly against the new bounds without
- // accounting for that we'll have constant false positives when the window is
- // moving but the user hasn't changed its size at all.
+ // of error because it converts from floats to integers between
+ // calculations, so if we check existing bounds directly against the new
+ // bounds without accounting for that we'll have constant false positives
+ // when the window is moving but the user hasn't changed its size at all.
auto isWithinOnePixel = [](gfx::Size old_size, gfx::Size new_size) -> bool {
return base::IsApproximatelyEqual(old_size.width(), new_size.width(), 1) &&
base::IsApproximatelyEqual(old_size.height(), new_size.height(), 1);
@@ -1807,8 +1827,8 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
ui::mojom::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized()) {
#if BUILDFLAG(IS_WIN)
- // Only restore Maximized state when window is NOT transparent style
- if (!transparent()) {
+ // Restore maximized state for windows that are not translucent.
+ if (!IsTranslucent()) {
return ui::mojom::WindowShowState::kMaximized;
}
#else
diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h
index 05c7bbc866fe9..fe2c3a197b117 100644
--- a/shell/browser/native_window_views.h
+++ b/shell/browser/native_window_views.h
@@ -202,11 +202,9 @@ class NativeWindowViews : public NativeWindow,
void OnWidgetMove() override;
#if BUILDFLAG(IS_WIN)
bool ExecuteWindowsCommand(int command_id) override;
-#endif
-
-#if BUILDFLAG(IS_WIN)
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
void ResetWindowControls();
+ void SetRoundedCorners(bool rounded);
void SetForwardMouseMessages(bool forward);
static LRESULT CALLBACK SubclassProc(HWND hwnd,
UINT msg,
diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc
index 9857d93b22f1b..91bd2413ce6e5 100644
--- a/shell/browser/native_window_views_win.cc
+++ b/shell/browser/native_window_views_win.cc
@@ -8,6 +8,7 @@
#include "base/win/atl.h" // Must be before UIAutomationCore.h
#include "base/win/scoped_handle.h"
+#include "base/win/windows_version.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "shell/browser/browser.h"
#include "shell/browser/native_window_views.h"
@@ -225,25 +226,6 @@ bool IsScreenReaderActive() {
std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
HHOOK NativeWindowViews::mouse_hook_ = nullptr;
-void NativeWindowViews::Maximize() {
- // Only use Maximize() when window is NOT transparent style
- if (!transparent()) {
- if (IsVisible()) {
- widget()->Maximize();
- } else {
- widget()->native_widget_private()->Show(
- ui::mojom::WindowShowState::kMaximized, gfx::Rect());
- NotifyWindowShow();
- }
- } else {
- restore_bounds_ = GetBounds();
- auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
- GetNativeWindow());
- SetBounds(display.work_area(), false);
- NotifyWindowMaximize();
- }
-}
-
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
const auto command_name = AppCommandToString(command_id);
NotifyWindowExecuteAppCommand(command_name);
@@ -535,6 +517,24 @@ void NativeWindowViews::ResetWindowControls() {
}
}
+// Windows with |backgroundMaterial| expand to the same dimensions and
+// placement as the display to approximate maximization - unless we remove
+// rounded corners there will be a gap between the window and the display
+// at the corners noticable to users.
+void NativeWindowViews::SetRoundedCorners(bool rounded) {
+ // DWMWA_WINDOW_CORNER_PREFERENCE is supported after Windows 11 Build 22000.
+ if (base::win::GetVersion() < base::win::Version::WIN11)
+ return;
+
+ DWM_WINDOW_CORNER_PREFERENCE round_pref =
+ rounded ? DWMWCP_ROUND : DWMWCP_DONOTROUND;
+ HRESULT result = DwmSetWindowAttribute(GetAcceleratedWidget(),
+ DWMWA_WINDOW_CORNER_PREFERENCE,
+ &round_pref, sizeof(round_pref));
+ if (FAILED(result))
+ LOG(WARNING) << "Failed to set rounded corners to " << rounded;
+}
+
void NativeWindowViews::SetForwardMouseMessages(bool forward) {
if (forward && !forwarding_mouse_messages_) {
forwarding_mouse_messages_ = true;
| diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc
index e5320308a2dcf..44de6c197f09b 100644
--- a/shell/browser/native_window_views.cc
+++ b/shell/browser/native_window_views.cc
@@ -642,8 +642,22 @@ void NativeWindowViews::SetEnabledInternal(bool enable) {
-#if BUILDFLAG(IS_LINUX)
void NativeWindowViews::Maximize() {
+#if BUILDFLAG(IS_WIN)
+ // If a window is translucent but not transparent on Windows,
+ // that means it must have a backgroundMaterial set.
+ if (!transparent())
+ SetRoundedCorners(false);
+ restore_bounds_ = GetBounds();
+ SetBounds(display.work_area(), false);
+ NotifyWindowMaximize();
+#endif
if (IsVisible()) {
widget()->Maximize();
} else {
@@ -652,44 +666,46 @@ void NativeWindowViews::Maximize() {
NotifyWindowShow();
void NativeWindowViews::Unmaximize() {
- if (IsMaximized()) {
+ if (!IsMaximized())
+ SetBounds(restore_bounds_, false);
+ NotifyWindowUnmaximize();
if (transparent()) {
- SetBounds(restore_bounds_, false);
- NotifyWindowUnmaximize();
UpdateThickFrame();
- return;
- widget()->Restore();
+ widget()->Restore();
+ UpdateThickFrame();
bool NativeWindowViews::IsMaximized() const {
- if (widget()->IsMaximized()) {
+ if (widget()->IsMaximized())
return true;
- // Compare the size of the window with the size of the display
- auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
- GetNativeWindow());
- // display
- return GetBounds() == display.work_area();
+ if (IsTranslucent() && !IsMinimized()) {
+ // If the window is the same dimensions and placement as the
+ // display, we consider it maximized.
+ return GetBounds() == display.work_area();
- return false;
+ return false;
void NativeWindowViews::Minimize() {
@@ -702,10 +718,14 @@ void NativeWindowViews::Minimize() {
void NativeWindowViews::Restore() {
- if (IsMaximized() && transparent()) {
+ if (IsMaximized() && IsTranslucent()) {
SetBounds(restore_bounds_, false);
NotifyWindowRestore();
+ UpdateThickFrame();
+ }
@@ -845,7 +865,7 @@ gfx::Size NativeWindowViews::GetContentSize() const {
gfx::Rect NativeWindowViews::GetNormalBounds() const {
- if (IsMaximized() && transparent())
+ if (IsMaximized() && IsTranslucent())
return restore_bounds_;
return widget()->GetRestoredBounds();
@@ -860,8 +880,8 @@ void NativeWindowViews::SetContentSizeConstraints(
if (!thick_frame_)
- // widget_delegate() is only available after Init() is called, we make use of
- // this to determine whether native widget has initialized.
+ // widget_delegate() is only available after Init() is called, we make use
+ // of this to determine whether native widget has initialized.
if (widget() && widget()->widget_delegate())
widget()->OnSizeConstraintsChanged();
if (resizable_)
@@ -1639,9 +1659,9 @@ void NativeWindowViews::UpdateThickFrame() {
if (IsMaximized() && !transparent()) {
- // For maximized window add thick frame always, otherwise it will be removed
- // in HWNDMessageHandler::SizeConstraintsChanged() which will result in
- // maximized window bounds change.
+ // For maximized window add thick frame always, otherwise it will be
+ // removed in HWNDMessageHandler::SizeConstraintsChanged() which will
FlipWindowStyle(GetAcceleratedWidget(), true, WS_THICKFRAME);
} else if (has_frame()) {
FlipWindowStyle(GetAcceleratedWidget(), resizable_, WS_THICKFRAME);
@@ -1679,10 +1699,10 @@ void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* changed_widget,
// WidgetObserver::OnWidgetBoundsChanged is being called from
// Widget::OnNativeWidgetMove() and not Widget::OnNativeWidgetSizeChanged.
// |GetWindowBoundsInScreen| has a ~1 pixel margin
- // of error because it converts from floats to integers between calculations,
- // so if we check existing bounds directly against the new bounds without
- // accounting for that we'll have constant false positives when the window is
- // moving but the user hasn't changed its size at all.
+ // of error because it converts from floats to integers between
+ // calculations, so if we check existing bounds directly against the new
+ // bounds without accounting for that we'll have constant false positives
+ // when the window is moving but the user hasn't changed its size at all.
auto isWithinOnePixel = [](gfx::Size old_size, gfx::Size new_size) -> bool {
return base::IsApproximatelyEqual(old_size.width(), new_size.width(), 1) &&
base::IsApproximatelyEqual(old_size.height(), new_size.height(), 1);
@@ -1807,8 +1827,8 @@ void NativeWindowViews::OnMouseEvent(ui::MouseEvent* event) {
ui::mojom::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized()) {
- // Only restore Maximized state when window is NOT transparent style
- if (!transparent()) {
+ // Restore maximized state for windows that are not translucent.
return ui::mojom::WindowShowState::kMaximized;
#else
diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h
index 05c7bbc866fe9..fe2c3a197b117 100644
--- a/shell/browser/native_window_views.h
+++ b/shell/browser/native_window_views.h
@@ -202,11 +202,9 @@ class NativeWindowViews : public NativeWindow,
void OnWidgetMove() override;
bool ExecuteWindowsCommand(int command_id) override;
-#if BUILDFLAG(IS_WIN)
void HandleSizeEvent(WPARAM w_param, LPARAM l_param);
void ResetWindowControls();
+ void SetRoundedCorners(bool rounded);
void SetForwardMouseMessages(bool forward);
static LRESULT CALLBACK SubclassProc(HWND hwnd,
UINT msg,
diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc
index 9857d93b22f1b..91bd2413ce6e5 100644
--- a/shell/browser/native_window_views_win.cc
+++ b/shell/browser/native_window_views_win.cc
@@ -8,6 +8,7 @@
#include "base/win/atl.h" // Must be before UIAutomationCore.h
#include "base/win/scoped_handle.h"
+#include "base/win/windows_version.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "shell/browser/browser.h"
#include "shell/browser/native_window_views.h"
@@ -225,25 +226,6 @@ bool IsScreenReaderActive() {
std::set<NativeWindowViews*> NativeWindowViews::forwarding_windows_;
HHOOK NativeWindowViews::mouse_hook_ = nullptr;
-void NativeWindowViews::Maximize() {
- // Only use Maximize() when window is NOT transparent style
- if (!transparent()) {
- if (IsVisible()) {
- widget()->Maximize();
- } else {
- widget()->native_widget_private()->Show(
- ui::mojom::WindowShowState::kMaximized, gfx::Rect());
- NotifyWindowShow();
- restore_bounds_ = GetBounds();
- auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
- SetBounds(display.work_area(), false);
- NotifyWindowMaximize();
-}
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
const auto command_name = AppCommandToString(command_id);
NotifyWindowExecuteAppCommand(command_name);
@@ -535,6 +517,24 @@ void NativeWindowViews::ResetWindowControls() {
+// Windows with |backgroundMaterial| expand to the same dimensions and
+// placement as the display to approximate maximization - unless we remove
+// rounded corners there will be a gap between the window and the display
+// at the corners noticable to users.
+ // DWMWA_WINDOW_CORNER_PREFERENCE is supported after Windows 11 Build 22000.
+ DWM_WINDOW_CORNER_PREFERENCE round_pref =
+ rounded ? DWMWCP_ROUND : DWMWCP_DONOTROUND;
+ HRESULT result = DwmSetWindowAttribute(GetAcceleratedWidget(),
+ DWMWA_WINDOW_CORNER_PREFERENCE,
+ &round_pref, sizeof(round_pref));
+ if (FAILED(result))
+ LOG(WARNING) << "Failed to set rounded corners to " << rounded;
+}
void NativeWindowViews::SetForwardMouseMessages(bool forward) {
if (forward && !forwarding_mouse_messages_) {
forwarding_mouse_messages_ = true; | [
"- if (transparent() && !IsMinimized()) {",
"- // Maximized if the window is the same dimensions and placement as the",
"+ if (transparent()) {",
"+ // result in maximized window bounds change.",
"+ if (!IsTranslucent()) {",
"- GetNativeWindow());",
"+void NativeWindowViews::SetRoundedCorners(bool rounded) {",
"+ if (base::win::GetVersion() < base::win::Version::WIN11)"
] | [
72,
76,
104,
141,
167,
217,
234,
236
] | {
"additions": 75,
"author": "codebytere",
"deletions": 57,
"html_url": "https://github.com/electron/electron/pull/45456",
"issue_id": 45456,
"merged_at": "2025-02-07T20:00:36Z",
"omission_probability": 0.1,
"pr_number": 45456,
"repo": "electron/electron",
"title": "fix: window maximizing with Mica",
"total_changes": 132
} |
568 | diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..578aa0e5d22fe 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,18 +3743,6 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
}
-#if !BUILDFLAG(IS_MAC)
-v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
- gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
- if (buffer.IsEmpty())
- return v8::Null(isolate);
- else
- return buffer.ToLocalChecked();
-}
-#endif
-
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
return v8::Null(isolate);
@@ -4466,7 +4454,6 @@ void WebContents::FillObjectTemplate(v8::Isolate* isolate,
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
.SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents)
- .SetMethod("getNativeView", &WebContents::GetNativeView)
.SetMethod("isBeingCaptured", &WebContents::IsBeingCaptured)
.SetMethod("setWebRTCIPHandlingPolicy",
&WebContents::SetWebRTCIPHandlingPolicy)
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..9ae4a7c878cec 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -250,7 +250,6 @@ class WebContents final : public ExclusiveAccessContext,
bool IsCurrentlyAudible();
void SetEmbedder(const WebContents* embedder);
void SetDevToolsWebContents(const WebContents* devtools);
- v8::Local<v8::Value> GetNativeView(v8::Isolate* isolate) const;
bool IsBeingCaptured();
void HandleNewRenderFrame(content::RenderFrameHost* render_frame_host);
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 1358b3dde95da..52c4362839610 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,7 +6,6 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
-#include "shell/common/node_includes.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -93,22 +92,4 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
}
-namespace {
-
-// Converts binary data to Buffer.
-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
- if (buffer.IsEmpty())
- return v8::Null(isolate);
- else
- return buffer.ToLocalChecked();
-}
-
-} // namespace
-
-v8::Local<v8::Value> WebContents::GetNativeView(v8::Isolate* isolate) const {
- NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
- return ToBuffer(isolate, &handle, sizeof(handle));
-}
-
} // namespace electron::api
| diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc
index bf5f6ec4b44b2..578aa0e5d22fe 100644
--- a/shell/browser/api/electron_api_web_contents.cc
+++ b/shell/browser/api/electron_api_web_contents.cc
@@ -3743,18 +3743,6 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
inspectable_web_contents_->SetDevToolsWebContents(devtools->web_contents());
-#if !BUILDFLAG(IS_MAC)
- gfx::NativeView ptr = web_contents()->GetNativeView();
- auto buffer =
- node::Buffer::Copy(isolate, reinterpret_cast<char*>(&ptr), sizeof(ptr));
-#endif
v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty())
return v8::Null(isolate);
@@ -4466,7 +4454,6 @@ void WebContents::FillObjectTemplate(v8::Isolate* isolate,
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
.SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents)
- .SetMethod("getNativeView", &WebContents::GetNativeView)
.SetMethod("isBeingCaptured", &WebContents::IsBeingCaptured)
.SetMethod("setWebRTCIPHandlingPolicy",
&WebContents::SetWebRTCIPHandlingPolicy)
diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h
index 30a2365bc0a9c..9ae4a7c878cec 100644
--- a/shell/browser/api/electron_api_web_contents.h
+++ b/shell/browser/api/electron_api_web_contents.h
@@ -250,7 +250,6 @@ class WebContents final : public ExclusiveAccessContext,
bool IsCurrentlyAudible();
void SetEmbedder(const WebContents* embedder);
void SetDevToolsWebContents(const WebContents* devtools);
- v8::Local<v8::Value> GetNativeView(v8::Isolate* isolate) const;
bool IsBeingCaptured();
void HandleNewRenderFrame(content::RenderFrameHost* render_frame_host);
diff --git a/shell/browser/api/electron_api_web_contents_mac.mm b/shell/browser/api/electron_api_web_contents_mac.mm
index 1358b3dde95da..52c4362839610 100644
--- a/shell/browser/api/electron_api_web_contents_mac.mm
+++ b/shell/browser/api/electron_api_web_contents_mac.mm
@@ -6,7 +6,6 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
-#include "shell/common/node_includes.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/base/cocoa/nsmenu_additions.h"
#include "ui/base/cocoa/nsmenuitem_additions.h"
@@ -93,22 +92,4 @@ - (void)redispatchKeyEvent:(NSEvent*)event;
return false;
-namespace {
-// Converts binary data to Buffer.
-v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
- auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
-} // namespace
- NSView* handle = web_contents()->GetNativeView().GetNativeNSView();
- return ToBuffer(isolate, &handle, sizeof(handle));
} // namespace electron::api | [] | [] | {
"additions": 0,
"author": "ckerr",
"deletions": 33,
"html_url": "https://github.com/electron/electron/pull/46734",
"issue_id": 46734,
"merged_at": "2025-04-24T01:33:51Z",
"omission_probability": 0.1,
"pr_number": 46734,
"repo": "electron/electron",
"title": "chore: remove `WebContents.getNativeView()`",
"total_changes": 33
} |
569 | diff --git a/docs/api/native-image.md b/docs/api/native-image.md
index 91ee4e68ef042..14ee825618c30 100644
--- a/docs/api/native-image.md
+++ b/docs/api/native-image.md
@@ -271,16 +271,12 @@ changes:
Returns `string` - The [Data URL][data-url] of the image.
-#### `image.getBitmap([options])`
+#### `image.getBitmap([options])` _Deprecated_
* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
-Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
-
-The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does not
-copy the bitmap data, so you have to use the returned Buffer immediately in
-current event loop tick; otherwise the data might be changed or destroyed.
+Legacy alias for `image.toBitmap()`.
#### `image.getNativeHandle()` _macOS_
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index bcb733a8ad985..0dc3cd9dfc7cb 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -887,7 +887,7 @@ const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
win.webContents.on('paint', (event, dirty, image) => {
- // updateBitmap(dirty, image.getBitmap())
+ // updateBitmap(dirty, image.toBitmap())
})
win.loadURL('https://github.com')
```
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 9d26d0b458365..4a75e7f95ad06 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -27,6 +27,19 @@ window is not currently visible.
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
+### Deprecated: `NativeImage.getBitmap()`
+
+`NativeImage.toBitmap()` returns a newly-allocated copy of the bitmap. `NativeImage.getBitmap()` was originally an alternative function that returned the original instead of a copy. This changed when sandboxing was introduced, so both return a copy and are functionally equivalent.
+
+Client code should call `NativeImage.toBitmap()` instead:
+
+```js
+// Deprecated
+bitmap = image.getBitmap()
+// Use this instead
+bitmap = image.toBitmap()
+```
+
## Planned Breaking API Changes (36.0)
### Removed:`isDefault` and `status` properties on `PrinterInfo`
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index a6e27003600b6..d16023390d4ad 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -287,17 +287,16 @@ std::string NativeImage::ToDataURL(gin::Arguments* args) {
}
v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ static bool deprecated_warning_issued = false;
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- SkPixelRef* ref = bitmap.pixelRef();
- if (!ref)
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- return node::Buffer::Copy(args->isolate(),
- reinterpret_cast<char*>(ref->pixels()),
- bitmap.computeByteSize())
- .ToLocalChecked();
+ if (!deprecated_warning_issued) {
+ deprecated_warning_issued = true;
+ util::EmitWarning(isolate_,
+ "getBitmap() is deprecated, use toBitmap() instead.",
+ "DeprecationWarning");
+ }
+
+ return ToBitmap(args);
}
v8::Local<v8::Value> NativeImage::GetNativeHandle(
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts
index f90078f9a391f..56980c7683d3e 100755
--- a/spec/api-browser-window-spec.ts
+++ b/spec/api-browser-window-spec.ts
@@ -4599,7 +4599,7 @@ describe('BrowserWindow module', () => {
try {
const expectedSize = rect.width * rect.height * 4;
- expect(image.getBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
+ expect(image.toBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
done();
} catch (e) {
done(e);
diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts
index bbd30cff7aa6a..72a5ffeaee52b 100644
--- a/spec/api-native-image-spec.ts
+++ b/spec/api-native-image-spec.ts
@@ -4,6 +4,7 @@ import { expect } from 'chai';
import * as path from 'node:path';
+import { expectDeprecationMessages } from './lib/deprecate-helpers';
import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
describe('nativeImage module', () => {
@@ -78,15 +79,20 @@ describe('nativeImage module', () => {
});
describe('createEmpty()', () => {
- it('returns an empty image', () => {
+ it('returns an empty image', async () => {
const empty = nativeImage.createEmpty();
expect(empty.isEmpty()).to.be.true();
expect(empty.getAspectRatio()).to.equal(1);
expect(empty.toDataURL()).to.equal('data:image/png;base64,');
expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,');
expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 });
- expect(empty.getBitmap()).to.be.empty();
- expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ await expectDeprecationMessages(
+ () => {
+ expect(empty.getBitmap()).to.be.empty();
+ expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ },
+ 'getBitmap() is deprecated, use toBitmap() instead.'
+ );
expect(empty.toBitmap()).to.be.empty();
expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty();
expect(empty.toJPEG(100)).to.be.empty();
diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts
index 64fd6232540a2..e4fc47f7383df 100644
--- a/spec/ts-smoke/electron/main.ts
+++ b/spec/ts-smoke/electron/main.ts
@@ -1291,7 +1291,7 @@ const win4 = new BrowserWindow({
});
win4.webContents.on('paint', (event, dirty, _image) => {
- console.log(dirty, _image.getBitmap());
+ console.log(dirty, _image.toBitmap());
});
win4.webContents.on('devtools-open-url', (event, url) => {
| diff --git a/docs/api/native-image.md b/docs/api/native-image.md
index 91ee4e68ef042..14ee825618c30 100644
--- a/docs/api/native-image.md
+++ b/docs/api/native-image.md
@@ -271,16 +271,12 @@ changes:
Returns `string` - The [Data URL][data-url] of the image.
-#### `image.getBitmap([options])`
* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
-Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
-
-The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does not
-current event loop tick; otherwise the data might be changed or destroyed.
+Legacy alias for `image.toBitmap()`.
#### `image.getNativeHandle()` _macOS_
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index bcb733a8ad985..0dc3cd9dfc7cb 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -887,7 +887,7 @@ const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
win.webContents.on('paint', (event, dirty, image) => {
- // updateBitmap(dirty, image.getBitmap())
+ // updateBitmap(dirty, image.toBitmap())
})
win.loadURL('https://github.com')
```
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 9d26d0b458365..4a75e7f95ad06 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -27,6 +27,19 @@ window is not currently visible.
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
+### Deprecated: `NativeImage.getBitmap()`
+Client code should call `NativeImage.toBitmap()` instead:
+```js
+// Deprecated
+bitmap = image.getBitmap()
+// Use this instead
+bitmap = image.toBitmap()
+```
## Planned Breaking API Changes (36.0)
### Removed:`isDefault` and `status` properties on `PrinterInfo`
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index a6e27003600b6..d16023390d4ad 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -287,17 +287,16 @@ std::string NativeImage::ToDataURL(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ static bool deprecated_warning_issued = false;
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- SkPixelRef* ref = bitmap.pixelRef();
- if (!ref)
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- reinterpret_cast<char*>(ref->pixels()),
- bitmap.computeByteSize())
- .ToLocalChecked();
+ if (!deprecated_warning_issued) {
+ deprecated_warning_issued = true;
+ util::EmitWarning(isolate_,
+ "getBitmap() is deprecated, use toBitmap() instead.",
+ "DeprecationWarning");
+ return ToBitmap(args);
v8::Local<v8::Value> NativeImage::GetNativeHandle(
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts
index f90078f9a391f..56980c7683d3e 100755
--- a/spec/api-browser-window-spec.ts
+++ b/spec/api-browser-window-spec.ts
@@ -4599,7 +4599,7 @@ describe('BrowserWindow module', () => {
try {
const expectedSize = rect.width * rect.height * 4;
- expect(image.getBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
+ expect(image.toBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
done();
} catch (e) {
done(e);
diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts
index bbd30cff7aa6a..72a5ffeaee52b 100644
--- a/spec/api-native-image-spec.ts
+++ b/spec/api-native-image-spec.ts
@@ -4,6 +4,7 @@ import { expect } from 'chai';
import * as path from 'node:path';
import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
describe('nativeImage module', () => {
@@ -78,15 +79,20 @@ describe('nativeImage module', () => {
});
describe('createEmpty()', () => {
- it('returns an empty image', () => {
+ it('returns an empty image', async () => {
const empty = nativeImage.createEmpty();
expect(empty.isEmpty()).to.be.true();
expect(empty.getAspectRatio()).to.equal(1);
expect(empty.toDataURL()).to.equal('data:image/png;base64,');
expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,');
expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 });
- expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ await expectDeprecationMessages(
+ () => {
+ expect(empty.getBitmap()).to.be.empty();
+ expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ },
+ 'getBitmap() is deprecated, use toBitmap() instead.'
expect(empty.toBitmap()).to.be.empty();
expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty();
expect(empty.toJPEG(100)).to.be.empty();
diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts
index 64fd6232540a2..e4fc47f7383df 100644
--- a/spec/ts-smoke/electron/main.ts
+++ b/spec/ts-smoke/electron/main.ts
@@ -1291,7 +1291,7 @@ const win4 = new BrowserWindow({
win4.webContents.on('paint', (event, dirty, _image) => {
- console.log(dirty, _image.getBitmap());
+ console.log(dirty, _image.toBitmap());
win4.webContents.on('devtools-open-url', (event, url) => { | [
"+#### `image.getBitmap([options])` _Deprecated_",
"-copy the bitmap data, so you have to use the returned Buffer immediately in",
"+`NativeImage.toBitmap()` returns a newly-allocated copy of the bitmap. `NativeImage.getBitmap()` was originally an alternative function that returned the original instead of a copy. This changed when sandboxing was introduced, so both return a copy and are functionally equivalent.",
"- return node::Buffer::Copy(args->isolate(),",
"+ }",
"+import { expectDeprecationMessages } from './lib/deprecate-helpers';",
"- expect(empty.getBitmap()).to.be.empty();",
"+ );"
] | [
9,
17,
46,
76,
85,
112,
128,
136
] | {
"additions": 36,
"author": "trop[bot]",
"deletions": 22,
"html_url": "https://github.com/electron/electron/pull/46736",
"issue_id": 46736,
"merged_at": "2025-04-23T13:10:18Z",
"omission_probability": 0.1,
"pr_number": 46736,
"repo": "electron/electron",
"title": "refactor: remove redundant NativeImage::GetBitmap()",
"total_changes": 58
} |
570 | diff --git a/docs/api/native-image.md b/docs/api/native-image.md
index 91ee4e68ef042..14ee825618c30 100644
--- a/docs/api/native-image.md
+++ b/docs/api/native-image.md
@@ -271,16 +271,12 @@ changes:
Returns `string` - The [Data URL][data-url] of the image.
-#### `image.getBitmap([options])`
+#### `image.getBitmap([options])` _Deprecated_
* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
-Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
-
-The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does not
-copy the bitmap data, so you have to use the returned Buffer immediately in
-current event loop tick; otherwise the data might be changed or destroyed.
+Legacy alias for `image.toBitmap()`.
#### `image.getNativeHandle()` _macOS_
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index bcb733a8ad985..0dc3cd9dfc7cb 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -887,7 +887,7 @@ const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
win.webContents.on('paint', (event, dirty, image) => {
- // updateBitmap(dirty, image.getBitmap())
+ // updateBitmap(dirty, image.toBitmap())
})
win.loadURL('https://github.com')
```
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index f0556a639aa1f..7d4371e7a4a69 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -45,6 +45,19 @@ window is not currently visible.
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
+### Deprecated: `NativeImage.getBitmap()`
+
+`NativeImage.toBitmap()` returns a newly-allocated copy of the bitmap. `NativeImage.getBitmap()` was originally an alternative function that returned the original instead of a copy. This changed when sandboxing was introduced, so both return a copy and are functionally equivalent.
+
+Client code should call `NativeImage.toBitmap()` instead:
+
+```js
+// Deprecated
+bitmap = image.getBitmap()
+// Use this instead
+bitmap = image.toBitmap()
+```
+
## Planned Breaking API Changes (36.0)
### Utility Process unhandled rejection behavior change
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index a6e27003600b6..d16023390d4ad 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -287,17 +287,16 @@ std::string NativeImage::ToDataURL(gin::Arguments* args) {
}
v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ static bool deprecated_warning_issued = false;
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- SkPixelRef* ref = bitmap.pixelRef();
- if (!ref)
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- return node::Buffer::Copy(args->isolate(),
- reinterpret_cast<char*>(ref->pixels()),
- bitmap.computeByteSize())
- .ToLocalChecked();
+ if (!deprecated_warning_issued) {
+ deprecated_warning_issued = true;
+ util::EmitWarning(isolate_,
+ "getBitmap() is deprecated, use toBitmap() instead.",
+ "DeprecationWarning");
+ }
+
+ return ToBitmap(args);
}
v8::Local<v8::Value> NativeImage::GetNativeHandle(
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts
index f90078f9a391f..56980c7683d3e 100755
--- a/spec/api-browser-window-spec.ts
+++ b/spec/api-browser-window-spec.ts
@@ -4599,7 +4599,7 @@ describe('BrowserWindow module', () => {
try {
const expectedSize = rect.width * rect.height * 4;
- expect(image.getBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
+ expect(image.toBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
done();
} catch (e) {
done(e);
diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts
index bbd30cff7aa6a..72a5ffeaee52b 100644
--- a/spec/api-native-image-spec.ts
+++ b/spec/api-native-image-spec.ts
@@ -4,6 +4,7 @@ import { expect } from 'chai';
import * as path from 'node:path';
+import { expectDeprecationMessages } from './lib/deprecate-helpers';
import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
describe('nativeImage module', () => {
@@ -78,15 +79,20 @@ describe('nativeImage module', () => {
});
describe('createEmpty()', () => {
- it('returns an empty image', () => {
+ it('returns an empty image', async () => {
const empty = nativeImage.createEmpty();
expect(empty.isEmpty()).to.be.true();
expect(empty.getAspectRatio()).to.equal(1);
expect(empty.toDataURL()).to.equal('data:image/png;base64,');
expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,');
expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 });
- expect(empty.getBitmap()).to.be.empty();
- expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ await expectDeprecationMessages(
+ () => {
+ expect(empty.getBitmap()).to.be.empty();
+ expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ },
+ 'getBitmap() is deprecated, use toBitmap() instead.'
+ );
expect(empty.toBitmap()).to.be.empty();
expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty();
expect(empty.toJPEG(100)).to.be.empty();
diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts
index 64fd6232540a2..e4fc47f7383df 100644
--- a/spec/ts-smoke/electron/main.ts
+++ b/spec/ts-smoke/electron/main.ts
@@ -1291,7 +1291,7 @@ const win4 = new BrowserWindow({
});
win4.webContents.on('paint', (event, dirty, _image) => {
- console.log(dirty, _image.getBitmap());
+ console.log(dirty, _image.toBitmap());
});
win4.webContents.on('devtools-open-url', (event, url) => {
| diff --git a/docs/api/native-image.md b/docs/api/native-image.md
index 91ee4e68ef042..14ee825618c30 100644
--- a/docs/api/native-image.md
+++ b/docs/api/native-image.md
@@ -271,16 +271,12 @@ changes:
Returns `string` - The [Data URL][data-url] of the image.
-#### `image.getBitmap([options])`
* `options` Object (optional)
* `scaleFactor` Number (optional) - Defaults to 1.0.
-Returns `Buffer` - A [Buffer][buffer] that contains the image's raw bitmap pixel data.
-The difference between `getBitmap()` and `toBitmap()` is that `getBitmap()` does not
-copy the bitmap data, so you have to use the returned Buffer immediately in
-current event loop tick; otherwise the data might be changed or destroyed.
+Legacy alias for `image.toBitmap()`.
#### `image.getNativeHandle()` _macOS_
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md
index bcb733a8ad985..0dc3cd9dfc7cb 100644
--- a/docs/api/web-contents.md
+++ b/docs/api/web-contents.md
@@ -887,7 +887,7 @@ const { BrowserWindow } = require('electron')
const win = new BrowserWindow({ webPreferences: { offscreen: true } })
win.webContents.on('paint', (event, dirty, image) => {
- // updateBitmap(dirty, image.getBitmap())
+ // updateBitmap(dirty, image.toBitmap())
})
win.loadURL('https://github.com')
```
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index f0556a639aa1f..7d4371e7a4a69 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -45,6 +45,19 @@ window is not currently visible.
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
+### Deprecated: `NativeImage.getBitmap()`
+`NativeImage.toBitmap()` returns a newly-allocated copy of the bitmap. `NativeImage.getBitmap()` was originally an alternative function that returned the original instead of a copy. This changed when sandboxing was introduced, so both return a copy and are functionally equivalent.
+Client code should call `NativeImage.toBitmap()` instead:
+```js
+// Deprecated
+bitmap = image.getBitmap()
+// Use this instead
+bitmap = image.toBitmap()
+```
## Planned Breaking API Changes (36.0)
### Utility Process unhandled rejection behavior change
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc
index a6e27003600b6..d16023390d4ad 100644
--- a/shell/common/api/electron_api_native_image.cc
+++ b/shell/common/api/electron_api_native_image.cc
@@ -287,17 +287,16 @@ std::string NativeImage::ToDataURL(gin::Arguments* args) {
v8::Local<v8::Value> NativeImage::GetBitmap(gin::Arguments* args) {
- float scale_factor = GetScaleFactorFromOptions(args);
+ static bool deprecated_warning_issued = false;
- const SkBitmap bitmap =
- image_.AsImageSkia().GetRepresentation(scale_factor).GetBitmap();
- SkPixelRef* ref = bitmap.pixelRef();
- if (!ref)
- return node::Buffer::New(args->isolate(), 0).ToLocalChecked();
- return node::Buffer::Copy(args->isolate(),
- reinterpret_cast<char*>(ref->pixels()),
- bitmap.computeByteSize())
- .ToLocalChecked();
+ if (!deprecated_warning_issued) {
+ deprecated_warning_issued = true;
+ "getBitmap() is deprecated, use toBitmap() instead.",
+ "DeprecationWarning");
+ }
v8::Local<v8::Value> NativeImage::GetNativeHandle(
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts
index f90078f9a391f..56980c7683d3e 100755
--- a/spec/api-browser-window-spec.ts
+++ b/spec/api-browser-window-spec.ts
@@ -4599,7 +4599,7 @@ describe('BrowserWindow module', () => {
try {
const expectedSize = rect.width * rect.height * 4;
- expect(image.getBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
done();
} catch (e) {
done(e);
diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts
index bbd30cff7aa6a..72a5ffeaee52b 100644
--- a/spec/api-native-image-spec.ts
+++ b/spec/api-native-image-spec.ts
@@ -4,6 +4,7 @@ import { expect } from 'chai';
import * as path from 'node:path';
+import { expectDeprecationMessages } from './lib/deprecate-helpers';
import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
describe('nativeImage module', () => {
@@ -78,15 +79,20 @@ describe('nativeImage module', () => {
});
describe('createEmpty()', () => {
- it('returns an empty image', () => {
+ it('returns an empty image', async () => {
const empty = nativeImage.createEmpty();
expect(empty.isEmpty()).to.be.true();
expect(empty.getAspectRatio()).to.equal(1);
expect(empty.toDataURL()).to.equal('data:image/png;base64,');
expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,');
expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 });
- expect(empty.getBitmap()).to.be.empty();
- expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ await expectDeprecationMessages(
+ () => {
+ expect(empty.getBitmap()).to.be.empty();
+ expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
+ },
+ );
expect(empty.toBitmap()).to.be.empty();
expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty();
expect(empty.toJPEG(100)).to.be.empty();
diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts
index 64fd6232540a2..e4fc47f7383df 100644
--- a/spec/ts-smoke/electron/main.ts
+++ b/spec/ts-smoke/electron/main.ts
@@ -1291,7 +1291,7 @@ const win4 = new BrowserWindow({
win4.webContents.on('paint', (event, dirty, _image) => {
+ console.log(dirty, _image.toBitmap());
win4.webContents.on('devtools-open-url', (event, url) => { | [
"+#### `image.getBitmap([options])` _Deprecated_",
"-",
"+ util::EmitWarning(isolate_,",
"+ return ToBitmap(args);",
"+ expect(image.toBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);",
"+ 'getBitmap() is deprecated, use toBitmap() instead.'",
"- console.log(dirty, _image.getBitmap());"
] | [
9,
15,
82,
87,
100,
135,
148
] | {
"additions": 36,
"author": "ckerr",
"deletions": 22,
"html_url": "https://github.com/electron/electron/pull/46696",
"issue_id": 46696,
"merged_at": "2025-04-23T09:00:43Z",
"omission_probability": 0.1,
"pr_number": 46696,
"repo": "electron/electron",
"title": "refactor: remove redundant NativeImage::GetBitmap()",
"total_changes": 58
} |
571 | diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md
index 5eba3efaa1577..f415e14819299 100644
--- a/docs/api/desktop-capturer.md
+++ b/docs/api/desktop-capturer.md
@@ -9,79 +9,65 @@ The following example shows how to capture video from a desktop window whose
title is `Electron`:
```js
-// In the main process.
-const { BrowserWindow, desktopCapturer } = require('electron')
+// main.js
+const { app, BrowserWindow, desktopCapturer, session } = require('electron')
-const mainWindow = new BrowserWindow()
+app.whenReady().then(() => {
+ const mainWindow = new BrowserWindow()
-desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
- for (const source of sources) {
- if (source.name === 'Electron') {
- mainWindow.webContents.send('SET_SOURCE', source.id)
- return
- }
- }
+ session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
+ desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {
+ // Grant access to the first screen found.
+ callback({ video: sources[0], audio: 'loopback' })
+ })
+ })
+
+ mainWindow.loadFile('index.html')
})
```
-```js @ts-nocheck
-// In the preload script.
-const { ipcRenderer } = require('electron')
-
-ipcRenderer.on('SET_SOURCE', async (event, sourceId) => {
- try {
- const stream = await navigator.mediaDevices.getUserMedia({
- audio: false,
- video: {
- mandatory: {
- chromeMediaSource: 'desktop',
- chromeMediaSourceId: sourceId,
- minWidth: 1280,
- maxWidth: 1280,
- minHeight: 720,
- maxHeight: 720
- }
- }
- })
- handleStream(stream)
- } catch (e) {
- handleError(e)
- }
+```js
+// renderer.js
+const startButton = document.getElementById('startButton')
+const stopButton = document.getElementById('stopButton')
+const video = document.querySelector('video')
+
+startButton.addEventListener('click', () => {
+ navigator.mediaDevices.getDisplayMedia({
+ audio: true,
+ video: {
+ width: 320,
+ height: 240,
+ frameRate: 30
+ }
+ }).then(stream => {
+ video.srcObject = stream
+ video.onloadedmetadata = (e) => video.play()
+ }).catch(e => console.log(e))
})
-function handleStream (stream) {
- const video = document.querySelector('video')
- video.srcObject = stream
- video.onloadedmetadata = (e) => video.play()
-}
-
-function handleError (e) {
- console.log(e)
-}
+stopButton.addEventListener('click', () => {
+ video.pause()
+})
```
-To capture video from a source provided by `desktopCapturer` the constraints
-passed to [`navigator.mediaDevices.getUserMedia`][] must include
-`chromeMediaSource: 'desktop'`, and `audio: false`.
+```html
+<!-- index.html -->
+<html>
+<meta http-equiv="content-security-policy" content="script-src 'self' 'unsafe-inline'" />
+ <body>
+ <button id="startButton" class="button">Start</button>
+ <button id="stopButton" class="button">Stop</button>
+ <video width="320" height="240" autoplay></video>
+ <script src="renderer.js"></script>
+ </body>
+</html>
+```
-To capture both audio and video from the entire desktop the constraints passed
-to [`navigator.mediaDevices.getUserMedia`][] must include `chromeMediaSource: 'desktop'`,
-for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint.
+See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information.
-```js
-const constraints = {
- audio: {
- mandatory: {
- chromeMediaSource: 'desktop'
- }
- },
- video: {
- mandatory: {
- chromeMediaSource: 'desktop'
- }
- }
-}
-```
+**Note:** `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
+selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
## Methods
| diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md
index 5eba3efaa1577..f415e14819299 100644
--- a/docs/api/desktop-capturer.md
+++ b/docs/api/desktop-capturer.md
@@ -9,79 +9,65 @@ The following example shows how to capture video from a desktop window whose
title is `Electron`:
```js
-// In the main process.
-const { BrowserWindow, desktopCapturer } = require('electron')
+// main.js
+const { app, BrowserWindow, desktopCapturer, session } = require('electron')
-const mainWindow = new BrowserWindow()
+app.whenReady().then(() => {
+ const mainWindow = new BrowserWindow()
-desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => {
- for (const source of sources) {
- if (source.name === 'Electron') {
- mainWindow.webContents.send('SET_SOURCE', source.id)
- return
+ session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
+ desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {
+ // Grant access to the first screen found.
+ callback({ video: sources[0], audio: 'loopback' })
+ })
+ })
+ mainWindow.loadFile('index.html')
-```js @ts-nocheck
-// In the preload script.
-const { ipcRenderer } = require('electron')
-ipcRenderer.on('SET_SOURCE', async (event, sourceId) => {
- try {
- const stream = await navigator.mediaDevices.getUserMedia({
- audio: false,
- video: {
- mandatory: {
- chromeMediaSource: 'desktop',
- chromeMediaSourceId: sourceId,
- maxWidth: 1280,
- minHeight: 720,
- maxHeight: 720
- }
- }
- handleError(e)
+```js
+// renderer.js
+const startButton = document.getElementById('startButton')
+const video = document.querySelector('video')
+startButton.addEventListener('click', () => {
+ navigator.mediaDevices.getDisplayMedia({
+ audio: true,
+ video: {
+ width: 320,
+ height: 240,
+ frameRate: 30
+ }
+ video.srcObject = stream
+ video.onloadedmetadata = (e) => video.play()
+ }).catch(e => console.log(e))
-function handleStream (stream) {
- const video = document.querySelector('video')
- video.srcObject = stream
- video.onloadedmetadata = (e) => video.play()
-function handleError (e) {
- console.log(e)
+stopButton.addEventListener('click', () => {
+ video.pause()
+})
-To capture video from a source provided by `desktopCapturer` the constraints
-passed to [`navigator.mediaDevices.getUserMedia`][] must include
-`chromeMediaSource: 'desktop'`, and `audio: false`.
+<!-- index.html -->
+<html>
+<meta http-equiv="content-security-policy" content="script-src 'self' 'unsafe-inline'" />
+ <body>
+ <button id="startButton" class="button">Start</button>
+ <video width="320" height="240" autoplay></video>
+ <script src="renderer.js"></script>
+ </body>
+</html>
+```
-To capture both audio and video from the entire desktop the constraints passed
-to [`navigator.mediaDevices.getUserMedia`][] must include `chromeMediaSource: 'desktop'`,
-for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint.
+See [`navigator.mediaDevices.getDisplayMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia) for more information.
-```js
-const constraints = {
- audio: {
- },
- video: {
-```
+**Note:** `navigator.mediaDevices.getDisplayMedia` does not permit the use of `deviceId` for
+selection of a source - see [specification](https://w3c.github.io/mediacapture-screen-share/#constraints).
## Methods | [
"- minWidth: 1280,",
"- })",
"- handleStream(stream)",
"- } catch (e) {",
"+const stopButton = document.getElementById('stopButton')",
"+ }).then(stream => {",
"+```html",
"+ <button id=\"stopButton\" class=\"button\">Stop</button>"
] | [
47,
53,
54,
55,
61,
72,
95,
101
] | {
"additions": 48,
"author": "codebytere",
"deletions": 62,
"html_url": "https://github.com/electron/electron/pull/42957",
"issue_id": 42957,
"merged_at": "2024-07-23T09:55:23Z",
"omission_probability": 0.1,
"pr_number": 42957,
"repo": "electron/electron",
"title": "docs: improve desktop capture example",
"total_changes": 110
} |
572 | diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 5aa7d95d70fa5..92e2e1760c57b 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -145,3 +145,4 @@ fix_win32_synchronous_spellcheck.patch
fix_enable_wrap_iter_in_string_view_and_array.patch
fix_linter_error.patch
revert_enable_crel_for_arm32_targets.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..3298782f91e5b
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index f2499bc084312a09b2324567d270fc1b899e7617..12ee7e75e437426f28002c7c9f4d5f5b5016ec53 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2415,9 +2415,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates];
| diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 5aa7d95d70fa5..92e2e1760c57b 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -145,3 +145,4 @@ fix_win32_synchronous_spellcheck.patch
fix_enable_wrap_iter_in_string_view_and_array.patch
fix_linter_error.patch
revert_enable_crel_for_arm32_targets.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..3298782f91e5b
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+index f2499bc084312a09b2324567d270fc1b899e7617..12ee7e75e437426f28002c7c9f4d5f5b5016ec53 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2415,9 +2415,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates]; | [
"+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range",
"+Content-Transfer-Encoding: 8bit",
"+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm",
"+ } else {"
] | [
18,
21,
40,
47
] | {
"additions": 43,
"author": "deepak1556",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46688",
"issue_id": 46688,
"merged_at": "2025-04-21T00:49:15Z",
"omission_probability": 0.1,
"pr_number": 46688,
"repo": "electron/electron",
"title": "fix: crash on reconversion with google IME and editcontext on macOS",
"total_changes": 43
} |
573 | diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 7e801c05a49dc..b9c114414d857 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -146,3 +146,4 @@ fix_drag_and_drop_icons_on_windows.patch
chore_remove_conflicting_allow_unsafe_libc_calls.patch
fix_take_snapped_status_into_account_when_showing_a_window.patch
chore_modify_chromium_handling_of_mouse_events.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..9dcc7614a03c7
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index cb65efb56849d57e2e656f90d5b1d737ba2d952d..baad4cf7479646a25967892ef267bcea90c01ad0 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2430,9 +2430,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates];
| diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 7e801c05a49dc..b9c114414d857 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -146,3 +146,4 @@ fix_drag_and_drop_icons_on_windows.patch
chore_remove_conflicting_allow_unsafe_libc_calls.patch
fix_take_snapped_status_into_account_when_showing_a_window.patch
chore_modify_chromium_handling_of_mouse_events.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..9dcc7614a03c7
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+This CL fixes the issue by converting such invalid NSRange to
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Commit-Queue: Keren Zhu <[email protected]>
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index cb65efb56849d57e2e656f90d5b1d737ba2d952d..baad4cf7479646a25967892ef267bcea90c01ad0 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2430,9 +2430,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates]; | [
"+Content-Transfer-Encoding: 8bit",
"+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).",
"+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915",
"+Reviewed-by: Marijn Kruisselbrink <[email protected]>",
"+Cr-Commit-Position: refs/heads/main@{#1448935}"
] | [
21,
31,
35,
37,
38
] | {
"additions": 43,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46700",
"issue_id": 46700,
"merged_at": "2025-04-23T09:00:49Z",
"omission_probability": 0.1,
"pr_number": 46700,
"repo": "electron/electron",
"title": "fix: crash on reconversion with google IME and editcontext on macOS",
"total_changes": 43
} |
574 | diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index f2329238db745..ffa0d94599489 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -154,3 +154,4 @@ chore_modify_chromium_handling_of_mouse_events.patch
cherry-pick-b8f80176b163.patch
fix_false_activation_logic_for_context_menu.patch
mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
+cherry-pick-0333ecde9142.patch
diff --git a/patches/chromium/cherry-pick-0333ecde9142.patch b/patches/chromium/cherry-pick-0333ecde9142.patch
new file mode 100644
index 0000000000000..4a2d203aead11
--- /dev/null
+++ b/patches/chromium/cherry-pick-0333ecde9142.patch
@@ -0,0 +1,104 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alvin Ji <[email protected]>
+Date: Tue, 8 Apr 2025 10:46:18 -0700
+Subject: usb: Use GlobalRenderFrameHostId in UsbChooserController
+
+The UsbChooserController currently holds a raw pointer to the requesting
+RenderFrameHost. This can lead to use-after-free issues if the
+RenderFrameHost is destroyed before the chooser controller. This CL
+replaces the raw pointer with a `GlobalRenderFrameHostId`. This ID can
+be used to retrieve the RenderFrameHost when needed, and checks are
+added to ensure the RenderFrameHost is still valid before accessing it.
+
+Bug: 405292639
+Change-Id: Ifedaf80f6700d57ea28691abfaf4d2ff9cdbb448
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6440254
+Commit-Queue: Alvin Ji <[email protected]>
+Reviewed-by: Matt Reynolds <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1444224}
+
+diff --git a/chrome/browser/usb/usb_chooser_controller.cc b/chrome/browser/usb/usb_chooser_controller.cc
+index fae7decadcf5ca7b508068aa803e11a9027dde1e..112a7986523e37a8bc87f564f9d80fc3a4bdf433 100644
+--- a/chrome/browser/usb/usb_chooser_controller.cc
++++ b/chrome/browser/usb/usb_chooser_controller.cc
+@@ -99,8 +99,8 @@ UsbChooserController::UsbChooserController(
+ CreateChooserTitle(render_frame_host, IDS_USB_DEVICE_CHOOSER_PROMPT)),
+ options_(std::move(options)),
+ callback_(std::move(callback)),
+- requesting_frame_(render_frame_host) {
+- RenderFrameHost* main_frame = requesting_frame_->GetMainFrame();
++ render_frame_host_id_(render_frame_host->GetGlobalId()) {
++ RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
+ origin_ = main_frame->GetLastCommittedOrigin();
+ Profile* profile =
+ Profile::FromBrowserContext(main_frame->GetBrowserContext());
+@@ -202,7 +202,15 @@ void UsbChooserController::Cancel() {
+ void UsbChooserController::Close() {}
+
+ void UsbChooserController::OpenHelpCenterUrl() const {
+- WebContents::FromRenderFrameHost(requesting_frame_)
++ content::RenderFrameHost* render_frame_host =
++ content::RenderFrameHost::FromID(render_frame_host_id_);
++ if (!render_frame_host) {
++ // When |render_frame_host| is not valid anymore we don't want to open help
++ // center url.
++ return;
++ }
++
++ WebContents::FromRenderFrameHost(render_frame_host)
+ ->OpenURL(content::OpenURLParams(
+ GURL(chrome::kChooserUsbOverviewURL), content::Referrer(),
+ WindowOpenDisposition::NEW_FOREGROUND_TAB,
+@@ -266,6 +274,14 @@ void UsbChooserController::GotUsbDeviceList(
+
+ bool UsbChooserController::DisplayDevice(
+ const device::mojom::UsbDeviceInfo& device_info) const {
++ content::RenderFrameHost* render_frame_host =
++ content::RenderFrameHost::FromID(render_frame_host_id_);
++ if (!render_frame_host) {
++ // When |render_frame_host| is not valid anymore we don't want to display
++ // any device information.
++ return false;
++ }
++
+ if (!device::UsbDeviceFilterMatchesAny(options_->filters, device_info)) {
+ return false;
+ }
+@@ -280,10 +296,9 @@ bool UsbChooserController::DisplayDevice(
+ bool is_usb_unrestricted = false;
+ if (base::FeatureList::IsEnabled(blink::features::kUnrestrictedUsb)) {
+ is_usb_unrestricted =
+- requesting_frame_ &&
+- requesting_frame_->IsFeatureEnabled(
+- blink::mojom::PermissionsPolicyFeature::kUsbUnrestricted) &&
+- content::HasIsolatedContextCapability(requesting_frame_);
++ render_frame_host->IsFeatureEnabled(
++ network::mojom::PermissionsPolicyFeature::kUsbUnrestricted) &&
++ content::HasIsolatedContextCapability(render_frame_host);
+ }
+ // Isolated context with permission to access the policy-controlled feature
+ // "usb-unrestricted" can bypass the USB blocklist.
+diff --git a/chrome/browser/usb/usb_chooser_controller.h b/chrome/browser/usb/usb_chooser_controller.h
+index de5d7fb1a3be1c356f291b444175bbf375d0bf83..8e1bb06e8fcfbe3feeb4bd30452fb5d6d546074c 100644
+--- a/chrome/browser/usb/usb_chooser_controller.h
++++ b/chrome/browser/usb/usb_chooser_controller.h
+@@ -15,6 +15,7 @@
+ #include "base/scoped_observation.h"
+ #include "chrome/browser/usb/usb_chooser_context.h"
+ #include "components/permissions/chooser_controller.h"
++#include "content/public/browser/global_routing_id.h"
+ #include "services/device/public/mojom/usb_device.mojom.h"
+ #include "third_party/blink/public/mojom/usb/web_usb_service.mojom.h"
+ #include "url/origin.h"
+@@ -64,8 +65,9 @@ class UsbChooserController : public permissions::ChooserController,
+ blink::mojom::WebUsbService::GetPermissionCallback callback_;
+ url::Origin origin_;
+
+- const raw_ptr<content::RenderFrameHost, AcrossTasksDanglingUntriaged>
+- requesting_frame_;
++ // Hold the GlobalRenderFrameHostId for requesting frame so we can always
++ // check whether the frame host is still valid before we access it.
++ const content::GlobalRenderFrameHostId render_frame_host_id_;
+ base::WeakPtr<UsbChooserContext> chooser_context_;
+ base::ScopedObservation<UsbChooserContext, UsbChooserContext::DeviceObserver>
+ observation_{this};
| diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index f2329238db745..ffa0d94599489 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -154,3 +154,4 @@ chore_modify_chromium_handling_of_mouse_events.patch
cherry-pick-b8f80176b163.patch
fix_false_activation_logic_for_context_menu.patch
mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
+cherry-pick-0333ecde9142.patch
diff --git a/patches/chromium/cherry-pick-0333ecde9142.patch b/patches/chromium/cherry-pick-0333ecde9142.patch
new file mode 100644
index 0000000000000..4a2d203aead11
--- /dev/null
+++ b/patches/chromium/cherry-pick-0333ecde9142.patch
@@ -0,0 +1,104 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Alvin Ji <[email protected]>
+Date: Tue, 8 Apr 2025 10:46:18 -0700
+Subject: usb: Use GlobalRenderFrameHostId in UsbChooserController
+The UsbChooserController currently holds a raw pointer to the requesting
+RenderFrameHost. This can lead to use-after-free issues if the
+be used to retrieve the RenderFrameHost when needed, and checks are
+added to ensure the RenderFrameHost is still valid before accessing it.
+Bug: 405292639
+Change-Id: Ifedaf80f6700d57ea28691abfaf4d2ff9cdbb448
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6440254
+Commit-Queue: Alvin Ji <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1444224}
+diff --git a/chrome/browser/usb/usb_chooser_controller.cc b/chrome/browser/usb/usb_chooser_controller.cc
+index fae7decadcf5ca7b508068aa803e11a9027dde1e..112a7986523e37a8bc87f564f9d80fc3a4bdf433 100644
+--- a/chrome/browser/usb/usb_chooser_controller.cc
++++ b/chrome/browser/usb/usb_chooser_controller.cc
+@@ -99,8 +99,8 @@ UsbChooserController::UsbChooserController(
+ options_(std::move(options)),
+ callback_(std::move(callback)),
+- requesting_frame_(render_frame_host) {
+- RenderFrameHost* main_frame = requesting_frame_->GetMainFrame();
++ render_frame_host_id_(render_frame_host->GetGlobalId()) {
++ RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
+ origin_ = main_frame->GetLastCommittedOrigin();
+ Profile* profile =
+ Profile::FromBrowserContext(main_frame->GetBrowserContext());
+@@ -202,7 +202,15 @@ void UsbChooserController::Cancel() {
+ void UsbChooserController::Close() {}
+ void UsbChooserController::OpenHelpCenterUrl() const {
++ // When |render_frame_host| is not valid anymore we don't want to open help
++ // center url.
++ return;
+ ->OpenURL(content::OpenURLParams(
+ GURL(chrome::kChooserUsbOverviewURL), content::Referrer(),
+ WindowOpenDisposition::NEW_FOREGROUND_TAB,
+@@ -266,6 +274,14 @@ void UsbChooserController::GotUsbDeviceList(
+ bool UsbChooserController::DisplayDevice(
+ const device::mojom::UsbDeviceInfo& device_info) const {
++ // any device information.
++ return false;
+ if (!device::UsbDeviceFilterMatchesAny(options_->filters, device_info)) {
+ return false;
+@@ -280,10 +296,9 @@ bool UsbChooserController::DisplayDevice(
+ bool is_usb_unrestricted = false;
+ if (base::FeatureList::IsEnabled(blink::features::kUnrestrictedUsb)) {
+ is_usb_unrestricted =
+- requesting_frame_ &&
+- requesting_frame_->IsFeatureEnabled(
+- blink::mojom::PermissionsPolicyFeature::kUsbUnrestricted) &&
+- content::HasIsolatedContextCapability(requesting_frame_);
++ render_frame_host->IsFeatureEnabled(
++ content::HasIsolatedContextCapability(render_frame_host);
+ // Isolated context with permission to access the policy-controlled feature
+ // "usb-unrestricted" can bypass the USB blocklist.
+diff --git a/chrome/browser/usb/usb_chooser_controller.h b/chrome/browser/usb/usb_chooser_controller.h
+index de5d7fb1a3be1c356f291b444175bbf375d0bf83..8e1bb06e8fcfbe3feeb4bd30452fb5d6d546074c 100644
+--- a/chrome/browser/usb/usb_chooser_controller.h
++++ b/chrome/browser/usb/usb_chooser_controller.h
+@@ -15,6 +15,7 @@
+ #include "base/scoped_observation.h"
+ #include "chrome/browser/usb/usb_chooser_context.h"
+ #include "components/permissions/chooser_controller.h"
++#include "content/public/browser/global_routing_id.h"
+ #include "services/device/public/mojom/usb_device.mojom.h"
+ #include "third_party/blink/public/mojom/usb/web_usb_service.mojom.h"
+ #include "url/origin.h"
+@@ -64,8 +65,9 @@ class UsbChooserController : public permissions::ChooserController,
+ blink::mojom::WebUsbService::GetPermissionCallback callback_;
+ url::Origin origin_;
+- const raw_ptr<content::RenderFrameHost, AcrossTasksDanglingUntriaged>
+- requesting_frame_;
++ // Hold the GlobalRenderFrameHostId for requesting frame so we can always
++ // check whether the frame host is still valid before we access it.
++ const content::GlobalRenderFrameHostId render_frame_host_id_;
+ base::WeakPtr<UsbChooserContext> chooser_context_;
+ base::ScopedObservation<UsbChooserContext, UsbChooserContext::DeviceObserver>
+ observation_{this}; | [
"+RenderFrameHost is destroyed before the chooser controller. This CL",
"+replaces the raw pointer with a `GlobalRenderFrameHostId`. This ID can",
"+Reviewed-by: Matt Reynolds <[email protected]>",
"+ CreateChooserTitle(render_frame_host, IDS_USB_DEVICE_CHOOSER_PROMPT)),",
"+- WebContents::FromRenderFrameHost(requesting_frame_)",
"++ WebContents::FromRenderFrameHost(render_frame_host)",
"++ // When |render_frame_host| is not valid anymore we don't want to display",
"++ network::mojom::PermissionsPolicyFeature::kUsbUnrestricted) &&"
] | [
22,
23,
31,
39,
53,
62,
73,
90
] | {
"additions": 103,
"author": "VerteDinde",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46728",
"issue_id": 46728,
"merged_at": "2025-04-23T00:27:30Z",
"omission_probability": 0.1,
"pr_number": 46728,
"repo": "electron/electron",
"title": "chore: cherry-pick 0333ecde9142 from chromium",
"total_changes": 103
} |
575 | diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+
+ Menu.setApplicationMenu(menu);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(false);
+
+ win.setMinimizable(true);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => {
| diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ role: 'minimize'
+ }]);
+ Menu.setApplicationMenu(menu);
+ expect(win.isMinimized()).to.equal(false);
+ win.setMinimizable(true);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => { | [
"+ label: 'text',"
] | [
36
] | {
"additions": 20,
"author": "trop[bot]",
"deletions": 2,
"html_url": "https://github.com/electron/electron/pull/46714",
"issue_id": 46714,
"merged_at": "2025-04-22T20:41:53Z",
"omission_probability": 0.1,
"pr_number": 46714,
"repo": "electron/electron",
"title": "fix: stop menu minimization if set false",
"total_changes": 22
} |
576 | diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+
+ Menu.setApplicationMenu(menu);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(false);
+
+ win.setMinimizable(true);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => {
| diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+ Menu.setApplicationMenu(menu);
+ expect(win.isMinimized()).to.equal(false);
+ win.setMinimizable(true);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => { | [] | [] | {
"additions": 20,
"author": "mlaurencin",
"deletions": 2,
"html_url": "https://github.com/electron/electron/pull/46279",
"issue_id": 46279,
"merged_at": "2025-04-22T08:58:30Z",
"omission_probability": 0.1,
"pr_number": 46279,
"repo": "electron/electron",
"title": "fix: stop menu minimization if set false",
"total_changes": 22
} |
577 | diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h
index 1ee4443f9cdb2..68619364a8fbf 100644
--- a/shell/browser/api/electron_api_base_window.h
+++ b/shell/browser/api/electron_api_base_window.h
@@ -42,7 +42,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
- NativeWindow* window() const { return window_.get(); }
+ const NativeWindow* window() const { return window_.get(); }
+ NativeWindow* window() { return window_.get(); }
protected:
// Common constructor.
@@ -262,6 +263,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
#endif
int32_t GetID() const;
+ private:
// Helpers.
// Remove this window from parent window's |child_windows_|.
@@ -290,7 +292,6 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Reference to JS wrapper to prevent garbage collection.
v8::Global<v8::Value> self_ref_;
- private:
base::WeakPtrFactory<BaseWindow> weak_factory_{this};
};
diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc
index 742ca07976da6..b27c7f0f32c96 100644
--- a/shell/browser/api/electron_api_browser_window.cc
+++ b/shell/browser/api/electron_api_browser_window.cc
@@ -36,7 +36,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
std::string color;
if (options.Get(options::kBackgroundColor, &color)) {
web_preferences.SetHidden(options::kBackgroundColor, color);
- } else if (window_->IsTranslucent()) {
+ } else if (window()->IsTranslucent()) {
// If the BrowserWindow is transparent or a vibrancy type has been set,
// also propagate transparency to the WebContents unless a separate
// backgroundColor has been set.
@@ -67,7 +67,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
gin::Handle<WebContentsView> web_contents_view =
WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get());
- window_->AddDraggableRegionProvider(web_contents_view.get());
+ window()->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents.
@@ -209,7 +209,7 @@ void BrowserWindow::UpdateWindowControlsOverlay(
void BrowserWindow::CloseImmediately() {
// Close all child windows before closing current window.
v8::HandleScope handle_scope(isolate());
- for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
+ for (v8::Local<v8::Value> value : GetChildWindows()) {
gin::Handle<BrowserWindow> child;
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
child->window()->CloseImmediately();
| diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h
index 1ee4443f9cdb2..68619364a8fbf 100644
--- a/shell/browser/api/electron_api_base_window.h
+++ b/shell/browser/api/electron_api_base_window.h
@@ -42,7 +42,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
- NativeWindow* window() const { return window_.get(); }
+ const NativeWindow* window() const { return window_.get(); }
+ NativeWindow* window() { return window_.get(); }
protected:
// Common constructor.
@@ -262,6 +263,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
#endif
int32_t GetID() const;
// Helpers.
// Remove this window from parent window's |child_windows_|.
@@ -290,7 +292,6 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Reference to JS wrapper to prevent garbage collection.
v8::Global<v8::Value> self_ref_;
- private:
base::WeakPtrFactory<BaseWindow> weak_factory_{this};
};
diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc
index 742ca07976da6..b27c7f0f32c96 100644
--- a/shell/browser/api/electron_api_browser_window.cc
+++ b/shell/browser/api/electron_api_browser_window.cc
@@ -36,7 +36,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
std::string color;
if (options.Get(options::kBackgroundColor, &color)) {
web_preferences.SetHidden(options::kBackgroundColor, color);
- } else if (window_->IsTranslucent()) {
+ } else if (window()->IsTranslucent()) {
// If the BrowserWindow is transparent or a vibrancy type has been set,
// also propagate transparency to the WebContents unless a separate
// backgroundColor has been set.
@@ -67,7 +67,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
gin::Handle<WebContentsView> web_contents_view =
WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get());
- window_->AddDraggableRegionProvider(web_contents_view.get());
+ window()->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents.
@@ -209,7 +209,7 @@ void BrowserWindow::UpdateWindowControlsOverlay(
void BrowserWindow::CloseImmediately() {
// Close all child windows before closing current window.
v8::HandleScope handle_scope(isolate());
- for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
+ for (v8::Local<v8::Value> value : GetChildWindows()) {
gin::Handle<BrowserWindow> child;
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
child->window()->CloseImmediately(); | [
"+ private:"
] | [
18
] | {
"additions": 6,
"author": "trop[bot]",
"deletions": 5,
"html_url": "https://github.com/electron/electron/pull/46710",
"issue_id": 46710,
"merged_at": "2025-04-22T17:33:02Z",
"omission_probability": 0.1,
"pr_number": 46710,
"repo": "electron/electron",
"title": "refactor: make `electron::api::BaseWindow` fields private",
"total_changes": 11
} |
578 | diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h
index 1ee4443f9cdb2..68619364a8fbf 100644
--- a/shell/browser/api/electron_api_base_window.h
+++ b/shell/browser/api/electron_api_base_window.h
@@ -42,7 +42,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
- NativeWindow* window() const { return window_.get(); }
+ const NativeWindow* window() const { return window_.get(); }
+ NativeWindow* window() { return window_.get(); }
protected:
// Common constructor.
@@ -262,6 +263,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
#endif
int32_t GetID() const;
+ private:
// Helpers.
// Remove this window from parent window's |child_windows_|.
@@ -290,7 +292,6 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Reference to JS wrapper to prevent garbage collection.
v8::Global<v8::Value> self_ref_;
- private:
base::WeakPtrFactory<BaseWindow> weak_factory_{this};
};
diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc
index 742ca07976da6..b27c7f0f32c96 100644
--- a/shell/browser/api/electron_api_browser_window.cc
+++ b/shell/browser/api/electron_api_browser_window.cc
@@ -36,7 +36,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
std::string color;
if (options.Get(options::kBackgroundColor, &color)) {
web_preferences.SetHidden(options::kBackgroundColor, color);
- } else if (window_->IsTranslucent()) {
+ } else if (window()->IsTranslucent()) {
// If the BrowserWindow is transparent or a vibrancy type has been set,
// also propagate transparency to the WebContents unless a separate
// backgroundColor has been set.
@@ -67,7 +67,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
gin::Handle<WebContentsView> web_contents_view =
WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get());
- window_->AddDraggableRegionProvider(web_contents_view.get());
+ window()->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents.
@@ -209,7 +209,7 @@ void BrowserWindow::UpdateWindowControlsOverlay(
void BrowserWindow::CloseImmediately() {
// Close all child windows before closing current window.
v8::HandleScope handle_scope(isolate());
- for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
+ for (v8::Local<v8::Value> value : GetChildWindows()) {
gin::Handle<BrowserWindow> child;
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
child->window()->CloseImmediately();
| diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h
index 1ee4443f9cdb2..68619364a8fbf 100644
--- a/shell/browser/api/electron_api_base_window.h
+++ b/shell/browser/api/electron_api_base_window.h
@@ -42,7 +42,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
- NativeWindow* window() const { return window_.get(); }
+ const NativeWindow* window() const { return window_.get(); }
+ NativeWindow* window() { return window_.get(); }
protected:
// Common constructor.
@@ -262,6 +263,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
#endif
int32_t GetID() const;
+ private:
// Helpers.
// Remove this window from parent window's |child_windows_|.
@@ -290,7 +292,6 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
// Reference to JS wrapper to prevent garbage collection.
v8::Global<v8::Value> self_ref_;
- private:
base::WeakPtrFactory<BaseWindow> weak_factory_{this};
};
diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc
index 742ca07976da6..b27c7f0f32c96 100644
--- a/shell/browser/api/electron_api_browser_window.cc
+++ b/shell/browser/api/electron_api_browser_window.cc
@@ -36,7 +36,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
std::string color;
if (options.Get(options::kBackgroundColor, &color)) {
web_preferences.SetHidden(options::kBackgroundColor, color);
- } else if (window_->IsTranslucent()) {
+ } else if (window()->IsTranslucent()) {
// If the BrowserWindow is transparent or a vibrancy type has been set,
// also propagate transparency to the WebContents unless a separate
// backgroundColor has been set.
@@ -67,7 +67,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
gin::Handle<WebContentsView> web_contents_view =
WebContentsView::Create(isolate, web_preferences);
DCHECK(web_contents_view.get());
- window_->AddDraggableRegionProvider(web_contents_view.get());
+ window()->AddDraggableRegionProvider(web_contents_view.get());
web_contents_view_.Reset(isolate, web_contents_view.ToV8());
// Save a reference of the WebContents.
@@ -209,7 +209,7 @@ void BrowserWindow::UpdateWindowControlsOverlay(
void BrowserWindow::CloseImmediately() {
// Close all child windows before closing current window.
v8::HandleScope handle_scope(isolate());
- for (v8::Local<v8::Value> value : child_windows_.Values(isolate())) {
+ for (v8::Local<v8::Value> value : GetChildWindows()) {
gin::Handle<BrowserWindow> child;
if (gin::ConvertFromV8(isolate(), value, &child) && !child.IsEmpty())
child->window()->CloseImmediately(); | [] | [] | {
"additions": 6,
"author": "ckerr",
"deletions": 5,
"html_url": "https://github.com/electron/electron/pull/46689",
"issue_id": 46689,
"merged_at": "2025-04-22T08:19:12Z",
"omission_probability": 0.1,
"pr_number": 46689,
"repo": "electron/electron",
"title": "refactor: make `electron::api::BaseWindow` fields private",
"total_changes": 11
} |
579 | diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+
+ Menu.setApplicationMenu(menu);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(false);
+
+ win.setMinimizable(true);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => {
| diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+ expect(win.isMinimized()).to.equal(false);
+ win.setMinimizable(true);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => { | [
"+ Menu.setApplicationMenu(menu);"
] | [
40
] | {
"additions": 20,
"author": "trop[bot]",
"deletions": 2,
"html_url": "https://github.com/electron/electron/pull/46716",
"issue_id": 46716,
"merged_at": "2025-04-22T14:44:56Z",
"omission_probability": 0.1,
"pr_number": 46716,
"repo": "electron/electron",
"title": "fix: stop menu minimization if set false",
"total_changes": 22
} |
580 | diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+
+ Menu.setApplicationMenu(menu);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(false);
+
+ win.setMinimizable(true);
+ menu._executeCommand({}, menu.items[0].commandId);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => {
| diff --git a/lib/browser/api/menu-item-roles.ts b/lib/browser/api/menu-item-roles.ts
index fe2b07ed0fee7..1bb48b636e929 100644
--- a/lib/browser/api/menu-item-roles.ts
+++ b/lib/browser/api/menu-item-roles.ts
@@ -78,7 +78,9 @@ export const roleList: Record<RoleId, Role> = {
minimize: {
label: 'Minimize',
accelerator: 'CommandOrControl+M',
- windowMethod: w => w.minimize()
+ windowMethod: w => {
+ if (w.minimizable) w.minimize();
+ }
},
paste: {
label: 'Paste',
diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts
index e385b4773d63b..dd71140cacabe 100644
--- a/spec/api-menu-item-spec.ts
+++ b/spec/api-menu-item-spec.ts
@@ -2,7 +2,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from '
import { expect } from 'chai';
-import { ifdescribe } from './lib/spec-helpers';
+import { ifit, ifdescribe } from './lib/spec-helpers';
import { closeAllWindows } from './lib/window-helpers';
import { roleList, execute } from '../lib/browser/api/menu-item-roles';
@@ -205,6 +205,22 @@ describe('MenuItems', () => {
const canExecute = execute(item.role as any, win, win.webContents);
expect(canExecute).to.be.true('can execute');
});
+ ifit(process.platform === 'win32')('does not execute minimize role when minimizable false', () => {
+ const win = new BrowserWindow({ minimizable: false });
+ const menu = Menu.buildFromTemplate([{
+ label: 'text',
+ role: 'minimize'
+ }]);
+ Menu.setApplicationMenu(menu);
+ expect(win.isMinimized()).to.equal(false);
+ win.setMinimizable(true);
+ expect(win.isMinimized()).to.equal(true);
+ });
});
describe('MenuItem command id', () => { | [] | [] | {
"additions": 20,
"author": "trop[bot]",
"deletions": 2,
"html_url": "https://github.com/electron/electron/pull/46715",
"issue_id": 46715,
"merged_at": "2025-04-22T14:44:36Z",
"omission_probability": 0.1,
"pr_number": 46715,
"repo": "electron/electron",
"title": "fix: stop menu minimization if set false",
"total_changes": 22
} |
581 | diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 1750a07d4567b..f2329238db745 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -153,3 +153,4 @@ fix_take_snapped_status_into_account_when_showing_a_window.patch
chore_modify_chromium_handling_of_mouse_events.patch
cherry-pick-b8f80176b163.patch
fix_false_activation_logic_for_context_menu.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..b97396ae8863d
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index c89f25bf49d773f5f77b2434bd6fabcfd8cb4e33..87c5c0b3d04769dcbcf43880d5ec88dea93b4d58 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2337,9 +2337,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates];
| diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index 1750a07d4567b..f2329238db745 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -153,3 +153,4 @@ fix_take_snapped_status_into_account_when_showing_a_window.patch
chore_modify_chromium_handling_of_mouse_events.patch
cherry-pick-b8f80176b163.patch
fix_false_activation_logic_for_context_menu.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..b97396ae8863d
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+Fixed: 409864204
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates]; | [
"+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d",
"+Commit-Queue: Keren Zhu <[email protected]>",
"+index c89f25bf49d773f5f77b2434bd6fabcfd8cb4e33..87c5c0b3d04769dcbcf43880d5ec88dea93b4d58 100644",
"+@@ -2337,9 +2337,10 @@ - (void)setMarkedText:(id)string"
] | [
34,
36,
41,
44
] | {
"additions": 43,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46701",
"issue_id": 46701,
"merged_at": "2025-04-22T05:29:01Z",
"omission_probability": 0.1,
"pr_number": 46701,
"repo": "electron/electron",
"title": "fix: crash on reconversion with google IME and editcontext on macOS",
"total_changes": 43
} |
582 | diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index db2f7faefb4b7..970ba996347a5 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -145,3 +145,4 @@ fix_win32_synchronous_spellcheck.patch
chore_remove_conflicting_allow_unsafe_libc_calls.patch
fix_linter_error.patch
revert_enable_crel_for_arm32_targets.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..3298782f91e5b
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+It appears that Google Japanese IME can call -setMarkedText: with an
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index f2499bc084312a09b2324567d270fc1b899e7617..12ee7e75e437426f28002c7c9f4d5f5b5016ec53 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2415,9 +2415,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates];
| diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index db2f7faefb4b7..970ba996347a5 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -145,3 +145,4 @@ fix_win32_synchronous_spellcheck.patch
chore_remove_conflicting_allow_unsafe_libc_calls.patch
fix_linter_error.patch
revert_enable_crel_for_arm32_targets.patch
+mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
diff --git a/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
new file mode 100644
index 0000000000000..3298782f91e5b
--- /dev/null
+++ b/patches/chromium/mac_fix_check_on_ime_reconversion_due_to_invalid_replacement_range.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keren Zhu <[email protected]>
+Date: Fri, 18 Apr 2025 11:02:46 -0700
+Subject: mac: fix CHECK on IME reconversion due to invalid replacement range
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+invalid replacement range when doing text reconversion (変換, i.e.,
+conversion between different text with same pronunciation). This range
+is a NSRange and NSRange.location is supposed to be NSNotFound (2^31-1)
+for invalid range, but the IME can pass in 2^32. Subsequently causing
+CHECK error.
+This CL fixes the issue by converting such invalid NSRange to
+gfx::InvalidRange using FromPossiblyInvalidNSRange(range).
+Fixed: 409864204
+Change-Id: I08ff426a933ef76aa81e33af59aa32e2ac0b674d
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6470915
+Commit-Queue: Keren Zhu <[email protected]>
+Reviewed-by: Marijn Kruisselbrink <[email protected]>
+Cr-Commit-Position: refs/heads/main@{#1448935}
+diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+index f2499bc084312a09b2324567d270fc1b899e7617..12ee7e75e437426f28002c7c9f4d5f5b5016ec53 100644
+--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
++++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
+@@ -2415,9 +2415,10 @@ - (void)setMarkedText:(id)string
+ if ([self isHandlingKeyDown] && !_isReconversionTriggered) {
+ _setMarkedTextReplacementRange = gfx::Range(replacementRange);
+ } else {
+- _host->ImeSetComposition(_markedText, _imeTextSpans,
+- gfx::Range(replacementRange), newSelRange.location,
+- NSMaxRange(newSelRange));
++ _host->ImeSetComposition(
++ _markedText, _imeTextSpans,
++ gfx::Range::FromPossiblyInvalidNSRange(replacementRange),
++ newSelRange.location, NSMaxRange(newSelRange));
+ }
+
+ [[self inputContext] invalidateCharacterCoordinates]; | [
"+It appears that Google Japanese IME can call -setMarkedText: with an"
] | [
23
] | {
"additions": 43,
"author": "trop[bot]",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46699",
"issue_id": 46699,
"merged_at": "2025-04-21T14:28:20Z",
"omission_probability": 0.1,
"pr_number": 46699,
"repo": "electron/electron",
"title": "fix: crash on reconversion with google IME and editcontext on macOS",
"total_changes": 43
} |
583 | diff --git a/shell/browser/api/electron_api_auto_updater.cc b/shell/browser/api/electron_api_auto_updater.cc
index 2a1feaa9d837e..4111342ec1f98 100644
--- a/shell/browser/api/electron_api_auto_updater.cc
+++ b/shell/browser/api/electron_api_auto_updater.cc
@@ -46,10 +46,6 @@ void AutoUpdater::OnError(const std::string& message) {
gin::StringToV8(isolate, message),
};
- gin_helper::MicrotasksScope microtasks_scope{
- wrapper->GetCreationContextChecked(), true,
- v8::MicrotasksScope::kRunMicrotasks};
-
node::MakeCallback(isolate, wrapper, "emit", args.size(), args.data(),
{0, 0});
}
diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc
index a2bc082ed0e0e..dc8ba3709ed90 100644
--- a/shell/common/api/electron_bindings.cc
+++ b/shell/common/api/electron_bindings.cc
@@ -235,12 +235,11 @@ void ElectronBindings::DidReceiveMemoryDump(
base::ProcessId target_pid,
bool success,
std::unique_ptr<memory_instrumentation::GlobalMemoryDump> global_dump) {
+ DCHECK(electron::IsBrowserProcess());
v8::Isolate* isolate = promise.isolate();
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> local_context =
v8::Local<v8::Context>::New(isolate, context);
- gin_helper::MicrotasksScope microtasks_scope{
- local_context, true, v8::MicrotasksScope::kRunMicrotasks};
v8::Context::Scope context_scope(local_context);
if (!success) {
diff --git a/shell/common/v8_util.cc b/shell/common/v8_util.cc
index 85ed35cf1ae1f..842e2a1cd36ea 100644
--- a/shell/common/v8_util.cc
+++ b/shell/common/v8_util.cc
@@ -36,7 +36,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate {
bool Serialize(v8::Local<v8::Value> value, blink::CloneableMessage* out) {
gin_helper::MicrotasksScope microtasks_scope{
- isolate_->GetCurrentContext(), false,
+ isolate_->GetCurrentContext(), true,
v8::MicrotasksScope::kDoNotRunMicrotasks};
WriteBlinkEnvelope(19);
diff --git a/shell/renderer/api/electron_api_spell_check_client.cc b/shell/renderer/api/electron_api_spell_check_client.cc
index 46b8a03163a69..58ac2da5e0288 100644
--- a/shell/renderer/api/electron_api_spell_check_client.cc
+++ b/shell/renderer/api/electron_api_spell_check_client.cc
@@ -215,8 +215,8 @@ void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
DCHECK(!scope.spell_check_.IsEmpty());
auto context = isolate_->GetCurrentContext();
- gin_helper::MicrotasksScope microtasks_scope{
- context, false, v8::MicrotasksScope::kDoNotRunMicrotasks};
+ v8::MicrotasksScope microtasks_scope(
+ context, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
isolate_, base::BindRepeating(&SpellCheckClient::OnSpellCheckDone,
diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc
index 2c985c9a59c03..2f8511a3a70d0 100644
--- a/shell/renderer/electron_sandboxed_renderer_client.cc
+++ b/shell/renderer/electron_sandboxed_renderer_client.cc
@@ -146,8 +146,8 @@ void ElectronSandboxedRendererClient::WillReleaseScriptContext(
return;
auto* isolate = context->GetIsolate();
- gin_helper::MicrotasksScope microtasks_scope{
- context, false, v8::MicrotasksScope::kDoNotRunMicrotasks};
+ v8::MicrotasksScope microtasks_scope(
+ context, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context);
InvokeEmitProcessEvent(context, "exit");
@@ -164,8 +164,8 @@ void ElectronSandboxedRendererClient::EmitProcessEvent(
v8::HandleScope handle_scope{isolate};
v8::Local<v8::Context> context = GetContext(frame, isolate);
- gin_helper::MicrotasksScope microtasks_scope{
- context, false, v8::MicrotasksScope::kDoNotRunMicrotasks};
+ v8::MicrotasksScope microtasks_scope(
+ context, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Context::Scope context_scope(context);
InvokeEmitProcessEvent(context, event_name);
| diff --git a/shell/browser/api/electron_api_auto_updater.cc b/shell/browser/api/electron_api_auto_updater.cc
index 2a1feaa9d837e..4111342ec1f98 100644
--- a/shell/browser/api/electron_api_auto_updater.cc
+++ b/shell/browser/api/electron_api_auto_updater.cc
@@ -46,10 +46,6 @@ void AutoUpdater::OnError(const std::string& message) {
gin::StringToV8(isolate, message),
};
- gin_helper::MicrotasksScope microtasks_scope{
- wrapper->GetCreationContextChecked(), true,
- v8::MicrotasksScope::kRunMicrotasks};
-
node::MakeCallback(isolate, wrapper, "emit", args.size(), args.data(),
{0, 0});
}
diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc
index a2bc082ed0e0e..dc8ba3709ed90 100644
--- a/shell/common/api/electron_bindings.cc
+++ b/shell/common/api/electron_bindings.cc
@@ -235,12 +235,11 @@ void ElectronBindings::DidReceiveMemoryDump(
base::ProcessId target_pid,
bool success,
std::unique_ptr<memory_instrumentation::GlobalMemoryDump> global_dump) {
+ DCHECK(electron::IsBrowserProcess());
v8::Isolate* isolate = promise.isolate();
v8::Local<v8::Context> local_context =
v8::Local<v8::Context>::New(isolate, context);
- local_context, true, v8::MicrotasksScope::kRunMicrotasks};
v8::Context::Scope context_scope(local_context);
if (!success) {
diff --git a/shell/common/v8_util.cc b/shell/common/v8_util.cc
index 85ed35cf1ae1f..842e2a1cd36ea 100644
--- a/shell/common/v8_util.cc
+++ b/shell/common/v8_util.cc
@@ -36,7 +36,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate {
bool Serialize(v8::Local<v8::Value> value, blink::CloneableMessage* out) {
gin_helper::MicrotasksScope microtasks_scope{
- isolate_->GetCurrentContext(), false,
+ isolate_->GetCurrentContext(), true,
v8::MicrotasksScope::kDoNotRunMicrotasks};
WriteBlinkEnvelope(19);
diff --git a/shell/renderer/api/electron_api_spell_check_client.cc b/shell/renderer/api/electron_api_spell_check_client.cc
index 46b8a03163a69..58ac2da5e0288 100644
--- a/shell/renderer/api/electron_api_spell_check_client.cc
+++ b/shell/renderer/api/electron_api_spell_check_client.cc
@@ -215,8 +215,8 @@ void SpellCheckClient::SpellCheckWords(const SpellCheckScope& scope,
DCHECK(!scope.spell_check_.IsEmpty());
auto context = isolate_->GetCurrentContext();
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
isolate_, base::BindRepeating(&SpellCheckClient::OnSpellCheckDone,
diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc
index 2c985c9a59c03..2f8511a3a70d0 100644
--- a/shell/renderer/electron_sandboxed_renderer_client.cc
+++ b/shell/renderer/electron_sandboxed_renderer_client.cc
@@ -146,8 +146,8 @@ void ElectronSandboxedRendererClient::WillReleaseScriptContext(
return;
auto* isolate = context->GetIsolate();
InvokeEmitProcessEvent(context, "exit");
@@ -164,8 +164,8 @@ void ElectronSandboxedRendererClient::EmitProcessEvent(
v8::HandleScope handle_scope{isolate};
v8::Local<v8::Context> context = GetContext(frame, isolate);
InvokeEmitProcessEvent(context, event_name); | [] | [] | {
"additions": 8,
"author": "clavin",
"deletions": 13,
"html_url": "https://github.com/electron/electron/pull/46681",
"issue_id": 46681,
"merged_at": "2025-04-19T17:18:04Z",
"omission_probability": 0.1,
"pr_number": 46681,
"repo": "electron/electron",
"title": "refactor: reduce & remove no-op MicrotasksScope calls",
"total_changes": 21
} |
584 | diff --git a/DEPS b/DEPS
index 84c9d9f31b22d..31fd17451674e 100644
--- a/DEPS
+++ b/DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
- '136.0.7103.25',
+ '136.0.7103.33',
'node_version':
'v22.14.0',
'nan_version':
diff --git a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
index 5373ec0788055..ccd60b62c4c0b 100644
--- a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
+++ b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
@@ -33,7 +33,7 @@ index 95c73dcb082999d0a85d82f1fe330d27c88055ca..64cd976eba849435779b280b2941f915
"//base",
"//build:branding_buildflags",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
-index 2af2794b353d89f01d84b6ba28201f025ae124c7..b656ba6241b6a61d772219d1e80fb6b601aba224 100644
+index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f97b187357 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4593,7 +4593,7 @@ static_library("browser") {
diff --git a/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch b/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
index 89ff145669506..5428d36fdc299 100644
--- a/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
+++ b/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
@@ -31,7 +31,7 @@ index 7bda1853d47034c80a4e416b9839e8d18c5a8e2c..e5df49253103c44f01195fa93988753f
// Register the CGWindowID (used to identify this window for video capture)
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
-index 4d1c7d95c338b247f7c63315d536fcc7a7e4b637..55bb9b36f8d0894c972c05ba162fd5b41048013d 100644
+index 44c9248daecd67ccbc32f9afdbb8e7449d435b6c..e7d43ffc134e76f54aa5a71c668ce725a3f9bf6a 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -1223,6 +1223,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
diff --git a/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
index 80fc10643c7b7..0fcc4487f1b9d 100644
--- a/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
+++ b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
@@ -35,10 +35,10 @@ system font by checking if it's kCTFontPriorityAttribute is set to
system priority.
diff --git a/base/BUILD.gn b/base/BUILD.gn
-index 50893c5653a42160c25f3f92aeb2164b292c8364..36928057b408d76fa6fc8d0131bf47f860fabe1a 100644
+index 57a6af006161508474e0647d22580e872168ef4e..08205acb929894d87fecaee2c155aef5715cf180 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
-@@ -1040,6 +1040,7 @@ component("base") {
+@@ -1041,6 +1041,7 @@ component("base") {
"//build:ios_buildflags",
"//build/config/compiler:compiler_buildflags",
"//third_party/modp_b64",
@@ -449,7 +449,7 @@ index dcaa590375f7cc42996a95ceb0804733d382f60b..e80557dfa4992823ffca81e77aaeef1a
bool shouldShowWindowTitle = YES;
if (_bridge)
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
-index 5c0a53152095c2f799251f78b3c3464504104bfc..2c81ecef35d40036111cbd3dbdb44f7086d8946e 100644
+index 0b964e176e59e77a0743e2d347aa185bc7c80bc5..49a60b9aa0597c3397906303b73a4c1650cc60ce 100644
--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
+++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
@@ -42,6 +42,7 @@
@@ -460,7 +460,7 @@ index 5c0a53152095c2f799251f78b3c3464504104bfc..2c81ecef35d40036111cbd3dbdb44f70
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/cert/x509_util_apple.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
-@@ -679,10 +680,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
+@@ -681,10 +682,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
// this should be treated as an error and caught early.
CHECK(bridged_view_);
| diff --git a/DEPS b/DEPS
index 84c9d9f31b22d..31fd17451674e 100644
--- a/DEPS
+++ b/DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
vars = {
'chromium_version':
- '136.0.7103.25',
+ '136.0.7103.33',
'node_version':
'v22.14.0',
'nan_version':
diff --git a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
index 5373ec0788055..ccd60b62c4c0b 100644
--- a/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
+++ b/patches/chromium/build_do_not_depend_on_packed_resource_integrity.patch
@@ -33,7 +33,7 @@ index 95c73dcb082999d0a85d82f1fe330d27c88055ca..64cd976eba849435779b280b2941f915
"//base",
"//build:branding_buildflags",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
-index 2af2794b353d89f01d84b6ba28201f025ae124c7..b656ba6241b6a61d772219d1e80fb6b601aba224 100644
+index a3623400c3548b31e3e9bc8c15e6c5081e4990cc..db7e78e4b72de2af313741bb802b51f97b187357 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4593,7 +4593,7 @@ static_library("browser") {
diff --git a/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch b/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
index 89ff145669506..5428d36fdc299 100644
--- a/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
+++ b/patches/chromium/fix_adjust_headless_mode_handling_in_native_widget.patch
@@ -31,7 +31,7 @@ index 7bda1853d47034c80a4e416b9839e8d18c5a8e2c..e5df49253103c44f01195fa93988753f
// Register the CGWindowID (used to identify this window for video capture)
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
-index 4d1c7d95c338b247f7c63315d536fcc7a7e4b637..55bb9b36f8d0894c972c05ba162fd5b41048013d 100644
+index 44c9248daecd67ccbc32f9afdbb8e7449d435b6c..e7d43ffc134e76f54aa5a71c668ce725a3f9bf6a 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -1223,6 +1223,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
diff --git a/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
index 80fc10643c7b7..0fcc4487f1b9d 100644
--- a/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
+++ b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch
@@ -35,10 +35,10 @@ system font by checking if it's kCTFontPriorityAttribute is set to
system priority.
diff --git a/base/BUILD.gn b/base/BUILD.gn
-index 50893c5653a42160c25f3f92aeb2164b292c8364..36928057b408d76fa6fc8d0131bf47f860fabe1a 100644
+index 57a6af006161508474e0647d22580e872168ef4e..08205acb929894d87fecaee2c155aef5715cf180 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
-@@ -1040,6 +1040,7 @@ component("base") {
+@@ -1041,6 +1041,7 @@ component("base") {
"//build:ios_buildflags",
"//build/config/compiler:compiler_buildflags",
"//third_party/modp_b64",
@@ -449,7 +449,7 @@ index dcaa590375f7cc42996a95ceb0804733d382f60b..e80557dfa4992823ffca81e77aaeef1a
bool shouldShowWindowTitle = YES;
if (_bridge)
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
+index 0b964e176e59e77a0743e2d347aa185bc7c80bc5..49a60b9aa0597c3397906303b73a4c1650cc60ce 100644
--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
+++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
@@ -42,6 +42,7 @@
@@ -460,7 +460,7 @@ index 5c0a53152095c2f799251f78b3c3464504104bfc..2c81ecef35d40036111cbd3dbdb44f70
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/cert/x509_util_apple.h"
#include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
-@@ -679,10 +680,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
+@@ -681,10 +682,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
// this should be treated as an error and caught early.
CHECK(bridged_view_); | [
"-index 5c0a53152095c2f799251f78b3c3464504104bfc..2c81ecef35d40036111cbd3dbdb44f7086d8946e 100644"
] | [
60
] | {
"additions": 7,
"author": "electron-roller[bot]",
"deletions": 7,
"html_url": "https://github.com/electron/electron/pull/46665",
"issue_id": 46665,
"merged_at": "2025-04-18T00:01:26Z",
"omission_probability": 0.1,
"pr_number": 46665,
"repo": "electron/electron",
"title": "chore: bump chromium to 136.0.7103.33 (36-x-y)",
"total_changes": 14
} |
585 | diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn
index 60fb38aab58da..a9a7cee308ef2 100644
--- a/chromium_src/BUILD.gn
+++ b/chromium_src/BUILD.gn
@@ -85,6 +85,8 @@ static_library("chrome") {
"//chrome/browser/process_singleton.h",
"//chrome/browser/process_singleton_internal.cc",
"//chrome/browser/process_singleton_internal.h",
+ "//chrome/browser/serial/serial_blocklist.cc",
+ "//chrome/browser/serial/serial_blocklist.h",
"//chrome/browser/themes/browser_theme_pack.cc",
"//chrome/browser/themes/browser_theme_pack.h",
"//chrome/browser/themes/custom_theme_supplier.cc",
@@ -144,6 +146,8 @@ static_library("chrome") {
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.cc",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.h",
+ "//chrome/browser/usb/usb_blocklist.cc",
+ "//chrome/browser/usb/usb_blocklist.h",
"//extensions/browser/app_window/size_constraints.cc",
"//extensions/browser/app_window/size_constraints.h",
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc",
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 3d570fda9e778..f0556a639aa1f 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,12 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (37.0)
+### Behavior Changed: WebUSB and WebSerial Blocklist Support
+
+[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
+
+To disable these, users can pass `disable-usb-blocklist` and `disable-serial-blocklist` as command line flags.
+
### Removed: `null` value for `session` property in `ProtocolResponse`
This deprecated feature has been removed.
diff --git a/docs/tutorial/devices.md b/docs/tutorial/devices.md
index ae6d21ae6bd63..37af4e01fd2d9 100644
--- a/docs/tutorial/devices.md
+++ b/docs/tutorial/devices.md
@@ -57,7 +57,7 @@ the WebHID API:
### Blocklist
-By default Electron employs the same [blocklist](https://github.com/WICG/webhid/blob/main/blocklist.txt)
+By default Electron employs the same [blocklist](https://wicg.github.io/webhid/#blocklist)
used by Chromium. If you wish to override this behavior, you can do so by
setting the `disable-hid-blocklist` flag:
@@ -104,6 +104,16 @@ There are several additional APIs for working with the Web Serial API:
* [`ses.setPermissionCheckHandler(handler)`](../api/session.md#sessetpermissioncheckhandlerhandler)
can be used to disable serial access for specific origins.
+### Blocklist
+
+By default Electron employs the same [blocklist](https://wicg.github.io/serial/#blocklist)
+used by Chromium. If you wish to override this behavior, you can do so by
+setting the `disable-serial-blocklist` flag:
+
+```js
+app.commandLine.appendSwitch('disable-serial-blocklist')
+```
+
### Example
This example demonstrates an Electron application that automatically selects
@@ -145,6 +155,16 @@ Electron provides several APIs for working with the WebUSB API:
* [`ses.setUSBProtectedClassesHandler](../api/session.md#sessetusbprotectedclasseshandlerhandler)
can be used to allow usage of [protected USB classes](https://wicg.github.io/webusb/#usbinterface-interface) that are not available by default.
+### Blocklist
+
+By default Electron employs the same [blocklist](https://wicg.github.io/webusb/#blocklist)
+used by Chromium. If you wish to override this behavior, you can do so by
+setting the `disable-usb-blocklist` flag:
+
+```js
+app.commandLine.appendSwitch('disable-usb-blocklist')
+```
+
### Example
This example demonstrates an Electron application that automatically selects
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index be387c644e9ad..c0ae6ed24851c 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -9,7 +9,9 @@
#include <utility>
#include "base/base64.h"
+#include "base/command_line.h"
#include "base/values.h"
+#include "chrome/browser/serial/serial_blocklist.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -104,6 +106,12 @@ bool SerialChooserContext::HasPortPermission(
const url::Origin& origin,
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
+ bool blocklist_disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ kDisableSerialBlocklist);
+ if (!blocklist_disabled && SerialBlocklist::Get().IsExcluded(port)) {
+ return false;
+ }
+
auto it = ephemeral_ports_.find(origin);
if (it != ephemeral_ports_.end()) {
const std::set<base::UnguessableToken>& ports = it->second;
diff --git a/shell/browser/serial/serial_chooser_context.h b/shell/browser/serial/serial_chooser_context.h
index 0dbeb15dc81f8..100287e52e25b 100644
--- a/shell/browser/serial/serial_chooser_context.h
+++ b/shell/browser/serial/serial_chooser_context.h
@@ -36,6 +36,8 @@ namespace electron {
class ElectronBrowserContext;
+const char kDisableSerialBlocklist[] = "disable-serial-blocklist";
+
inline constexpr std::string_view kPortNameKey = "name";
inline constexpr std::string_view kTokenKey = "token";
inline constexpr std::string_view kBluetoothDevicePathKey =
diff --git a/shell/browser/serial/serial_chooser_controller.cc b/shell/browser/serial/serial_chooser_controller.cc
index 9ab960a3b9785..217f495fd02af 100644
--- a/shell/browser/serial/serial_chooser_controller.cc
+++ b/shell/browser/serial/serial_chooser_controller.cc
@@ -7,9 +7,12 @@
#include <algorithm>
#include <utility>
+#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
+#include "chrome/browser/serial/serial_blocklist.h"
+#include "content/public/browser/console_message.h"
#include "content/public/browser/web_contents.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -120,8 +123,7 @@ SerialChooserController::SerialChooserController(
allowed_bluetooth_service_class_ids_(
std::move(allowed_bluetooth_service_class_ids)),
callback_(std::move(callback)),
- serial_delegate_(serial_delegate),
- render_frame_host_id_(render_frame_host->GetGlobalId()) {
+ initiator_document_(render_frame_host->GetWeakDocumentPtr()) {
origin_ = web_contents_->GetPrimaryMainFrame()->GetLastCommittedOrigin();
chooser_context_ = SerialChooserContextFactory::GetForBrowserContext(
@@ -210,7 +212,7 @@ void SerialChooserController::OnDeviceChosen(const std::string& port_id) {
return ptr->token.ToString() == port_id;
});
if (it != ports_.end()) {
- auto* rfh = content::RenderFrameHost::FromID(render_frame_host_id_);
+ auto* rfh = initiator_document_.AsRenderFrameHostIfValid();
chooser_context_->GrantPortPermission(origin_, *it->get(), rfh);
RunCallback(it->Clone());
} else {
@@ -246,6 +248,34 @@ void SerialChooserController::OnGetDevices(
bool SerialChooserController::DisplayDevice(
const device::mojom::SerialPortInfo& port) const {
+ bool blocklist_disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
+ kDisableSerialBlocklist);
+ if (!blocklist_disabled && SerialBlocklist::Get().IsExcluded(port)) {
+ if (port.has_vendor_id && port.has_product_id) {
+ AddMessageToConsole(
+ blink::mojom::ConsoleMessageLevel::kInfo,
+ base::StringPrintf(
+ "Skipping a port blocked by "
+ "the Serial blocklist: vendorId=%d, "
+ "productId=%d, name='%s', serial='%s'",
+ port.vendor_id, port.product_id,
+ port.display_name ? port.display_name.value().c_str() : "",
+ port.serial_number ? port.serial_number.value().c_str() : ""));
+ } else if (port.bluetooth_service_class_id) {
+ AddMessageToConsole(
+ blink::mojom::ConsoleMessageLevel::kInfo,
+ base::StringPrintf(
+ "Skipping a port blocked by "
+ "the Serial blocklist: bluetoothServiceClassId=%s, "
+ "name='%s'",
+ port.bluetooth_service_class_id->value().c_str(),
+ port.display_name ? port.display_name.value().c_str() : ""));
+ } else {
+ NOTREACHED();
+ }
+ return false;
+ }
+
if (filters_.empty()) {
return BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port);
}
@@ -260,6 +290,15 @@ bool SerialChooserController::DisplayDevice(
return false;
}
+void SerialChooserController::AddMessageToConsole(
+ blink::mojom::ConsoleMessageLevel level,
+ const std::string& message) const {
+ if (content::RenderFrameHost* rfh =
+ initiator_document_.AsRenderFrameHostIfValid()) {
+ rfh->AddMessageToConsole(level, message);
+ }
+}
+
void SerialChooserController::RunCallback(
device::mojom::SerialPortInfoPtr port) {
if (callback_) {
diff --git a/shell/browser/serial/serial_chooser_controller.h b/shell/browser/serial/serial_chooser_controller.h
index e88db05bb80ec..b030be80c8c02 100644
--- a/shell/browser/serial/serial_chooser_controller.h
+++ b/shell/browser/serial/serial_chooser_controller.h
@@ -12,9 +12,11 @@
#include "base/scoped_observation.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/serial_chooser.h"
+#include "content/public/browser/weak_document_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "services/device/public/mojom/serial.mojom-forward.h"
#include "shell/browser/serial/serial_chooser_context.h"
+#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "third_party/blink/public/mojom/serial/serial.mojom-forward.h"
namespace content {
@@ -66,6 +68,8 @@ class SerialChooserController final
void GetDevices();
void OnGetDevices(std::vector<device::mojom::SerialPortInfoPtr> ports);
bool DisplayDevice(const device::mojom::SerialPortInfo& port) const;
+ void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level,
+ const std::string& message) const;
void RunCallback(device::mojom::SerialPortInfoPtr port);
void OnDeviceChosen(const std::string& port_id);
void OnGetAdapter(base::OnceClosure callback,
@@ -78,6 +82,7 @@ class SerialChooserController final
std::vector<blink::mojom::SerialPortFilterPtr> filters_;
std::vector<::device::BluetoothUUID> allowed_bluetooth_service_class_ids_;
content::SerialChooser::Callback callback_;
+ content::WeakDocumentPtr initiator_document_;
url::Origin origin_;
base::WeakPtr<SerialChooserContext> chooser_context_;
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index 1273b7dbd41e7..1cb6037349244 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -8,9 +8,11 @@
#include <utility>
#include <vector>
+#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
+#include "chrome/browser/usb/usb_blocklist.h"
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/device_service.h"
#include "services/device/public/cpp/usb/usb_ids.h"
@@ -215,6 +217,12 @@ void UsbChooserContext::GrantDevicePermission(
bool UsbChooserContext::HasDevicePermission(
const url::Origin& origin,
const device::mojom::UsbDeviceInfo& device_info) {
+ bool blocklist_disabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableUSBBlocklist);
+ if (!blocklist_disabled && UsbBlocklist::Get().IsExcluded(device_info)) {
+ return false;
+ }
+
auto it = ephemeral_devices_.find(origin);
if (it != ephemeral_devices_.end() && it->second.contains(device_info.guid)) {
return true;
diff --git a/shell/browser/usb/usb_chooser_context.h b/shell/browser/usb/usb_chooser_context.h
index d62c9ad5edfb1..1f1929b4168cc 100644
--- a/shell/browser/usb/usb_chooser_context.h
+++ b/shell/browser/usb/usb_chooser_context.h
@@ -33,6 +33,8 @@ namespace electron {
class ElectronBrowserContext;
+const char kDisableUSBBlocklist[] = "disable-usb-blocklist";
+
class UsbChooserContext : public KeyedService,
public device::mojom::UsbDeviceManagerClient {
public:
diff --git a/shell/browser/usb/usb_chooser_controller.cc b/shell/browser/usb/usb_chooser_controller.cc
index ccc8c8c2bb11e..d786846a0e86d 100644
--- a/shell/browser/usb/usb_chooser_controller.cc
+++ b/shell/browser/usb/usb_chooser_controller.cc
@@ -8,7 +8,9 @@
#include <cstddef>
#include <utility>
+#include "base/command_line.h"
#include "base/functional/bind.h"
+#include "chrome/browser/usb/usb_blocklist.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@@ -140,6 +142,8 @@ void UsbChooserController::GotUsbDeviceList(
bool UsbChooserController::DisplayDevice(
const device::mojom::UsbDeviceInfo& device_info) const {
+ bool blocklist_disabled =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableUSBBlocklist);
if (!device::UsbDeviceFilterMatchesAny(options_->filters, device_info)) {
return false;
}
@@ -151,6 +155,10 @@ bool UsbChooserController::DisplayDevice(
return false;
}
+ if (!blocklist_disabled && UsbBlocklist::Get().IsExcluded(device_info)) {
+ return false;
+ }
+
return true;
}
| diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn
index 60fb38aab58da..a9a7cee308ef2 100644
--- a/chromium_src/BUILD.gn
+++ b/chromium_src/BUILD.gn
@@ -85,6 +85,8 @@ static_library("chrome") {
"//chrome/browser/process_singleton.h",
"//chrome/browser/process_singleton_internal.cc",
"//chrome/browser/process_singleton_internal.h",
+ "//chrome/browser/serial/serial_blocklist.cc",
+ "//chrome/browser/serial/serial_blocklist.h",
"//chrome/browser/themes/browser_theme_pack.cc",
"//chrome/browser/themes/browser_theme_pack.h",
"//chrome/browser/themes/custom_theme_supplier.cc",
@@ -144,6 +146,8 @@ static_library("chrome") {
"//chrome/browser/ui/views/overlay/video_overlay_window_views.h",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.cc",
"//chrome/browser/ui/webui/accessibility/accessibility_ui.h",
+ "//chrome/browser/usb/usb_blocklist.cc",
+ "//chrome/browser/usb/usb_blocklist.h",
"//extensions/browser/app_window/size_constraints.cc",
"//extensions/browser/app_window/size_constraints.h",
"//ui/base/accelerators/global_accelerator_listener/global_accelerator_listener.cc",
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index 3d570fda9e778..f0556a639aa1f 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,12 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (37.0)
+### Behavior Changed: WebUSB and WebSerial Blocklist Support
+[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
+To disable these, users can pass `disable-usb-blocklist` and `disable-serial-blocklist` as command line flags.
### Removed: `null` value for `session` property in `ProtocolResponse`
This deprecated feature has been removed.
diff --git a/docs/tutorial/devices.md b/docs/tutorial/devices.md
index ae6d21ae6bd63..37af4e01fd2d9 100644
--- a/docs/tutorial/devices.md
+++ b/docs/tutorial/devices.md
@@ -57,7 +57,7 @@ the WebHID API:
### Blocklist
-By default Electron employs the same [blocklist](https://github.com/WICG/webhid/blob/main/blocklist.txt)
+By default Electron employs the same [blocklist](https://wicg.github.io/webhid/#blocklist)
used by Chromium. If you wish to override this behavior, you can do so by
setting the `disable-hid-blocklist` flag:
@@ -104,6 +104,16 @@ There are several additional APIs for working with the Web Serial API:
* [`ses.setPermissionCheckHandler(handler)`](../api/session.md#sessetpermissioncheckhandlerhandler)
can be used to disable serial access for specific origins.
+By default Electron employs the same [blocklist](https://wicg.github.io/serial/#blocklist)
+setting the `disable-serial-blocklist` flag:
+app.commandLine.appendSwitch('disable-serial-blocklist')
@@ -145,6 +155,16 @@ Electron provides several APIs for working with the WebUSB API:
* [`ses.setUSBProtectedClassesHandler](../api/session.md#sessetusbprotectedclasseshandlerhandler)
can be used to allow usage of [protected USB classes](https://wicg.github.io/webusb/#usbinterface-interface) that are not available by default.
+By default Electron employs the same [blocklist](https://wicg.github.io/webusb/#blocklist)
+setting the `disable-usb-blocklist` flag:
+app.commandLine.appendSwitch('disable-usb-blocklist')
diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc
index be387c644e9ad..c0ae6ed24851c 100644
--- a/shell/browser/serial/serial_chooser_context.cc
+++ b/shell/browser/serial/serial_chooser_context.cc
@@ -9,7 +9,9 @@
#include "base/base64.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -104,6 +106,12 @@ bool SerialChooserContext::HasPortPermission(
const device::mojom::SerialPortInfo& port,
content::RenderFrameHost* render_frame_host) {
auto it = ephemeral_ports_.find(origin);
if (it != ephemeral_ports_.end()) {
const std::set<base::UnguessableToken>& ports = it->second;
diff --git a/shell/browser/serial/serial_chooser_context.h b/shell/browser/serial/serial_chooser_context.h
index 0dbeb15dc81f8..100287e52e25b 100644
--- a/shell/browser/serial/serial_chooser_context.h
+++ b/shell/browser/serial/serial_chooser_context.h
@@ -36,6 +36,8 @@ namespace electron {
+const char kDisableSerialBlocklist[] = "disable-serial-blocklist";
inline constexpr std::string_view kPortNameKey = "name";
inline constexpr std::string_view kTokenKey = "token";
inline constexpr std::string_view kBluetoothDevicePathKey =
diff --git a/shell/browser/serial/serial_chooser_controller.cc b/shell/browser/serial/serial_chooser_controller.cc
index 9ab960a3b9785..217f495fd02af 100644
--- a/shell/browser/serial/serial_chooser_controller.cc
+++ b/shell/browser/serial/serial_chooser_controller.cc
@@ -7,9 +7,12 @@
#include <algorithm>
#include "base/containers/contains.h"
#include "base/strings/string_number_conversions.h"
+#include "content/public/browser/console_message.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -120,8 +123,7 @@ SerialChooserController::SerialChooserController(
allowed_bluetooth_service_class_ids_(
std::move(allowed_bluetooth_service_class_ids)),
callback_(std::move(callback)),
- serial_delegate_(serial_delegate),
- render_frame_host_id_(render_frame_host->GetGlobalId()) {
+ initiator_document_(render_frame_host->GetWeakDocumentPtr()) {
origin_ = web_contents_->GetPrimaryMainFrame()->GetLastCommittedOrigin();
chooser_context_ = SerialChooserContextFactory::GetForBrowserContext(
@@ -210,7 +212,7 @@ void SerialChooserController::OnDeviceChosen(const std::string& port_id) {
return ptr->token.ToString() == port_id;
});
if (it != ports_.end()) {
- auto* rfh = content::RenderFrameHost::FromID(render_frame_host_id_);
+ auto* rfh = initiator_document_.AsRenderFrameHostIfValid();
chooser_context_->GrantPortPermission(origin_, *it->get(), rfh);
RunCallback(it->Clone());
} else {
@@ -246,6 +248,34 @@ void SerialChooserController::OnGetDevices(
bool SerialChooserController::DisplayDevice(
const device::mojom::SerialPortInfo& port) const {
+ if (port.has_vendor_id && port.has_product_id) {
+ "the Serial blocklist: vendorId=%d, "
+ "productId=%d, name='%s', serial='%s'",
+ port.vendor_id, port.product_id,
+ port.display_name ? port.display_name.value().c_str() : "",
+ port.serial_number ? port.serial_number.value().c_str() : ""));
+ } else if (port.bluetooth_service_class_id) {
+ "the Serial blocklist: bluetoothServiceClassId=%s, "
+ "name='%s'",
+ port.bluetooth_service_class_id->value().c_str(),
+ port.display_name ? port.display_name.value().c_str() : ""));
+ } else {
+ NOTREACHED();
+ }
if (filters_.empty()) {
return BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port);
@@ -260,6 +290,15 @@ bool SerialChooserController::DisplayDevice(
return false;
+void SerialChooserController::AddMessageToConsole(
+ blink::mojom::ConsoleMessageLevel level,
+ const std::string& message) const {
+ if (content::RenderFrameHost* rfh =
+ initiator_document_.AsRenderFrameHostIfValid()) {
+ rfh->AddMessageToConsole(level, message);
+}
void SerialChooserController::RunCallback(
device::mojom::SerialPortInfoPtr port) {
if (callback_) {
diff --git a/shell/browser/serial/serial_chooser_controller.h b/shell/browser/serial/serial_chooser_controller.h
index e88db05bb80ec..b030be80c8c02 100644
--- a/shell/browser/serial/serial_chooser_controller.h
+++ b/shell/browser/serial/serial_chooser_controller.h
@@ -12,9 +12,11 @@
#include "base/scoped_observation.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/serial_chooser.h"
+#include "content/public/browser/weak_document_ptr.h"
#include "services/device/public/mojom/serial.mojom-forward.h"
#include "shell/browser/serial/serial_chooser_context.h"
+#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "third_party/blink/public/mojom/serial/serial.mojom-forward.h"
namespace content {
@@ -66,6 +68,8 @@ class SerialChooserController final
void GetDevices();
void OnGetDevices(std::vector<device::mojom::SerialPortInfoPtr> ports);
bool DisplayDevice(const device::mojom::SerialPortInfo& port) const;
+ void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level,
+ const std::string& message) const;
void RunCallback(device::mojom::SerialPortInfoPtr port);
void OnDeviceChosen(const std::string& port_id);
void OnGetAdapter(base::OnceClosure callback,
@@ -78,6 +82,7 @@ class SerialChooserController final
std::vector<blink::mojom::SerialPortFilterPtr> filters_;
std::vector<::device::BluetoothUUID> allowed_bluetooth_service_class_ids_;
content::SerialChooser::Callback callback_;
+ content::WeakDocumentPtr initiator_document_;
url::Origin origin_;
base::WeakPtr<SerialChooserContext> chooser_context_;
diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc
index 1273b7dbd41e7..1cb6037349244 100644
--- a/shell/browser/usb/usb_chooser_context.cc
+++ b/shell/browser/usb/usb_chooser_context.cc
@@ -8,9 +8,11 @@
#include <vector>
#include "base/task/sequenced_task_runner.h"
#include "components/content_settings/core/common/content_settings.h"
#include "services/device/public/cpp/usb/usb_ids.h"
@@ -215,6 +217,12 @@ void UsbChooserContext::GrantDevicePermission(
bool UsbChooserContext::HasDevicePermission(
const device::mojom::UsbDeviceInfo& device_info) {
auto it = ephemeral_devices_.find(origin);
if (it != ephemeral_devices_.end() && it->second.contains(device_info.guid)) {
return true;
diff --git a/shell/browser/usb/usb_chooser_context.h b/shell/browser/usb/usb_chooser_context.h
index d62c9ad5edfb1..1f1929b4168cc 100644
--- a/shell/browser/usb/usb_chooser_context.h
+++ b/shell/browser/usb/usb_chooser_context.h
@@ -33,6 +33,8 @@ namespace electron {
+const char kDisableUSBBlocklist[] = "disable-usb-blocklist";
class UsbChooserContext : public KeyedService,
public device::mojom::UsbDeviceManagerClient {
public:
diff --git a/shell/browser/usb/usb_chooser_controller.cc b/shell/browser/usb/usb_chooser_controller.cc
index ccc8c8c2bb11e..d786846a0e86d 100644
--- a/shell/browser/usb/usb_chooser_controller.cc
+++ b/shell/browser/usb/usb_chooser_controller.cc
@@ -8,7 +8,9 @@
#include <cstddef>
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/render_frame_host.h"
@@ -140,6 +142,8 @@ void UsbChooserController::GotUsbDeviceList(
bool UsbChooserController::DisplayDevice(
const device::mojom::UsbDeviceInfo& device_info) const {
if (!device::UsbDeviceFilterMatchesAny(options_->filters, device_info)) {
@@ -151,6 +155,10 @@ bool UsbChooserController::DisplayDevice(
return true; | [] | [] | {
"additions": 106,
"author": "codebytere",
"deletions": 4,
"html_url": "https://github.com/electron/electron/pull/46600",
"issue_id": 46600,
"merged_at": "2025-04-17T18:34:34Z",
"omission_probability": 0.1,
"pr_number": 46600,
"repo": "electron/electron",
"title": "feat: support Web Serial & WebUSB blocklists",
"total_changes": 110
} |
586 | diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
blink::TransferableMessage transferable_message;
+ gin_helper::ErrorThrower thrower(args->isolate());
+
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
v8::Local<v8::Value> transferables;
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ thrower.ThrowTypeError("transferables must be an array of MessagePorts");
+ return;
+ }
+
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
+ }
+
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
}
}
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-namespace {
-
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- if (!val->IsObject())
- return false;
-
- v8::Local<v8::Object> port = val.As<v8::Object>();
-
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- return false;
-
- const auto* info = static_cast<gin::WrapperInfo*>(
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
-
- return info && info->embedder == gin::kEmbedderNativeGin;
-}
-
-} // namespace
-
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
blink::TransferableMessage transferable_message;
gin_helper::ErrorThrower thrower(args->isolate());
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- return;
- }
-
- if (!electron::SerializeV8Value(args->isolate(), message_value,
- &transferable_message)) {
- // SerializeV8Value sets an exception.
- return;
+ if (args->GetNext(&message_value)) {
+ if (!electron::SerializeV8Value(args->isolate(), message_value,
+ &transferable_message)) {
+ // SerializeV8Value sets an exception.
+ return;
+ }
}
v8::Local<v8::Value> transferables;
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
}
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ if (!val->IsObject())
+ return false;
+
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ return false;
+
+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ if (info != wrapper_info)
+ return false;
+
+ return true;
+}
+
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& obj,
+ const gin::WrapperInfo* wrapper_info);
+
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ it('throws when the transferable is invalid', async () => {
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ w.loadURL('about:blank');
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ // @ts-expect-error
+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }
+ }})()`);
+ const [, msg] = await p;
+ expect(msg.error).to.eql('Invalid value for transfer');
+ });
+
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ it('should not throw when supported values are passed as message', () => {
+ const { port1 } = new MessageChannelMain();
+
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage([]); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
+ });
+
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain();
| diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
+ gin_helper::ErrorThrower thrower(args->isolate());
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- if (!val->IsObject())
- v8::Local<v8::Object> port = val.As<v8::Object>();
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
- return info && info->embedder == gin::kEmbedderNativeGin;
-}
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
gin_helper::ErrorThrower thrower(args->isolate());
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- }
- if (!electron::SerializeV8Value(args->isolate(), message_value,
- &transferable_message)) {
- // SerializeV8Value sets an exception.
+ if (args->GetNext(&message_value)) {
+ &transferable_message)) {
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ if (!val->IsObject())
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ return true;
+}
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
+bool IsValidWrappable(const v8::Local<v8::Value>& obj,
+ const gin::WrapperInfo* wrapper_info);
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ // @ts-expect-error
+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }
+ }})()`);
+ const [, msg] = await p;
+ expect(msg.error).to.eql('Invalid value for transfer');
+ });
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ const { port1 } = new MessageChannelMain();
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage([]); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
+ });
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain(); | [
"+ thrower.ThrowTypeError(\"transferables must be an array of MessagePorts\");",
"-namespace {",
"- const auto* info = static_cast<gin::WrapperInfo*>(",
"-} // namespace",
"+ if (!electron::SerializeV8Value(args->isolate(), message_value,",
"+ // SerializeV8Value sets an exception.",
"+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(",
"+ if (info != wrapper_info)",
"+ it('throws when the transferable is invalid', async () => {",
"+ w.loadURL('about:blank');",
"+ it('should not throw when supported values are passed as message', () => {"
] | [
21,
58,
69,
75,
96,
98,
131,
133,
164,
166,
188
] | {
"additions": 82,
"author": "codebytere",
"deletions": 31,
"html_url": "https://github.com/electron/electron/pull/46639",
"issue_id": 46639,
"merged_at": "2025-04-17T13:09:48Z",
"omission_probability": 0.1,
"pr_number": 46639,
"repo": "electron/electron",
"title": "fix: `postMessage` crash with invalid transferrable",
"total_changes": 113
} |
587 | diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
blink::TransferableMessage transferable_message;
+ gin_helper::ErrorThrower thrower(args->isolate());
+
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
v8::Local<v8::Value> transferables;
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ thrower.ThrowTypeError("transferables must be an array of MessagePorts");
+ return;
+ }
+
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
+ }
+
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
}
}
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-namespace {
-
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- if (!val->IsObject())
- return false;
-
- v8::Local<v8::Object> port = val.As<v8::Object>();
-
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- return false;
-
- const auto* info = static_cast<gin::WrapperInfo*>(
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
-
- return info && info->embedder == gin::kEmbedderNativeGin;
-}
-
-} // namespace
-
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
blink::TransferableMessage transferable_message;
gin_helper::ErrorThrower thrower(args->isolate());
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- return;
- }
-
- if (!electron::SerializeV8Value(args->isolate(), message_value,
- &transferable_message)) {
- // SerializeV8Value sets an exception.
- return;
+ if (args->GetNext(&message_value)) {
+ if (!electron::SerializeV8Value(args->isolate(), message_value,
+ &transferable_message)) {
+ // SerializeV8Value sets an exception.
+ return;
+ }
}
v8::Local<v8::Value> transferables;
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
}
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ if (!val->IsObject())
+ return false;
+
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ return false;
+
+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ if (info != wrapper_info)
+ return false;
+
+ return true;
+}
+
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& obj,
+ const gin::WrapperInfo* wrapper_info);
+
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ it('throws when the transferable is invalid', async () => {
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ w.loadURL('about:blank');
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ // @ts-expect-error
+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }
+ }})()`);
+ const [, msg] = await p;
+ expect(msg.error).to.eql('Invalid value for transfer');
+ });
+
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ it('should not throw when supported values are passed as message', () => {
+ const { port1 } = new MessageChannelMain();
+
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage([]); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
+ });
+
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain();
| diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
+ gin_helper::ErrorThrower thrower(args->isolate());
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ thrower.ThrowTypeError("transferables must be an array of MessagePorts");
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-namespace {
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- if (!val->IsObject())
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- const auto* info = static_cast<gin::WrapperInfo*>(
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
- return info && info->embedder == gin::kEmbedderNativeGin;
-}
-} // namespace
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
gin_helper::ErrorThrower thrower(args->isolate());
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- }
- &transferable_message)) {
- // SerializeV8Value sets an exception.
+ if (args->GetNext(&message_value)) {
+ if (!electron::SerializeV8Value(args->isolate(), message_value,
+ &transferable_message)) {
+ // SerializeV8Value sets an exception.
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ if (info != wrapper_info)
+ return true;
+}
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
+bool IsValidWrappable(const v8::Local<v8::Value>& obj,
+ const gin::WrapperInfo* wrapper_info);
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ w.loadURL('about:blank');
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }
+ }})()`);
+ expect(msg.error).to.eql('Invalid value for transfer');
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ it('should not throw when supported values are passed as message', () => {
+ const { port1 } = new MessageChannelMain();
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
+ });
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain(); | [
"- v8::Local<v8::Object> port = val.As<v8::Object>();",
"- if (!electron::SerializeV8Value(args->isolate(), message_value,",
"+ if (!val->IsObject())",
"+ it('throws when the transferable is invalid', async () => {",
"+ // @ts-expect-error",
"+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);",
"+ const [, msg] = await p;",
"+ });",
"+ expect(() => { port1.postMessage([]); }).to.not.throw();"
] | [
64,
91,
124,
164,
171,
172,
177,
179,
197
] | {
"additions": 82,
"author": "trop[bot]",
"deletions": 31,
"html_url": "https://github.com/electron/electron/pull/46666",
"issue_id": 46666,
"merged_at": "2025-04-17T16:23:27Z",
"omission_probability": 0.1,
"pr_number": 46666,
"repo": "electron/electron",
"title": "fix: `postMessage` crash with invalid transferrable",
"total_changes": 113
} |
588 | diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
blink::TransferableMessage transferable_message;
+ gin_helper::ErrorThrower thrower(args->isolate());
+
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
v8::Local<v8::Value> transferables;
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ thrower.ThrowTypeError("transferables must be an array of MessagePorts");
+ return;
+ }
+
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
+ }
+
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
}
}
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-namespace {
-
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- if (!val->IsObject())
- return false;
-
- v8::Local<v8::Object> port = val.As<v8::Object>();
-
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- return false;
-
- const auto* info = static_cast<gin::WrapperInfo*>(
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
-
- return info && info->embedder == gin::kEmbedderNativeGin;
-}
-
-} // namespace
-
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
blink::TransferableMessage transferable_message;
gin_helper::ErrorThrower thrower(args->isolate());
+ // |message| is any value that can be serialized to StructuredClone.
v8::Local<v8::Value> message_value;
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- return;
- }
-
- if (!electron::SerializeV8Value(args->isolate(), message_value,
- &transferable_message)) {
- // SerializeV8Value sets an exception.
- return;
+ if (args->GetNext(&message_value)) {
+ if (!electron::SerializeV8Value(args->isolate(), message_value,
+ &transferable_message)) {
+ // SerializeV8Value sets an exception.
+ return;
+ }
}
v8::Local<v8::Value> transferables;
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
}
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
+ if (!gin_helper::IsValidWrappable(wrapped_port_values[i],
+ &MessagePort::kWrapperInfo)) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ if (!val->IsObject())
+ return false;
+
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ return false;
+
+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ if (info != wrapper_info)
+ return false;
+
+ return true;
+}
+
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
namespace gin_helper {
+bool IsValidWrappable(const v8::Local<v8::Value>& obj,
+ const gin::WrapperInfo* wrapper_info);
+
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ it('throws when the transferable is invalid', async () => {
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ w.loadURL('about:blank');
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ // @ts-expect-error
+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }
+ }})()`);
+ const [, msg] = await p;
+ expect(msg.error).to.eql('Invalid value for transfer');
+ });
+
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ it('should not throw when supported values are passed as message', () => {
+ const { port1 } = new MessageChannelMain();
+
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage([]); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
+ });
+
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain();
| diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc
index 573d38448e164..d9ff0996d91d8 100644
--- a/shell/browser/api/electron_api_utility_process.cc
+++ b/shell/browser/api/electron_api_utility_process.cc
@@ -330,6 +330,9 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
return;
+ gin_helper::ErrorThrower thrower(args->isolate());
if (args->GetNext(&message_value)) {
if (!electron::SerializeV8Value(args->isolate(), message_value,
@@ -342,9 +345,25 @@ void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
std::vector<gin::Handle<MessagePort>> wrapped_ports;
if (args->GetNext(&transferables)) {
+ std::vector<v8::Local<v8::Value>> wrapped_port_values;
+ if (!gin::ConvertFromV8(args->isolate(), transferables,
+ &wrapped_port_values)) {
+ for (size_t i = 0; i < wrapped_port_values.size(); ++i) {
+ thrower.ThrowTypeError(
+ base::StrCat({"Port at index ", base::NumberToString(i),
+ " is not a valid port"}));
+ return;
+ }
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
- gin_helper::ErrorThrower(args->isolate())
- .ThrowTypeError("Invalid value for transfer");
+ thrower.ThrowTypeError("Passed an invalid MessagePort");
return;
diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc
index 7d48119484cb2..4ea7f19e8dd3a 100644
--- a/shell/browser/api/message_port.cc
+++ b/shell/browser/api/message_port.cc
@@ -17,6 +17,7 @@
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
+#include "shell/common/gin_helper/wrappable.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
@@ -26,25 +27,6 @@
namespace electron {
-bool IsValidWrappable(const v8::Local<v8::Value>& val) {
- v8::Local<v8::Object> port = val.As<v8::Object>();
- if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
- const auto* info = static_cast<gin::WrapperInfo*>(
- port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
-}
-} // namespace
gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin};
MessagePort::MessagePort() = default;
@@ -77,16 +59,14 @@ void MessagePort::PostMessage(gin::Arguments* args) {
gin_helper::ErrorThrower thrower(args->isolate());
- if (!args->GetNext(&message_value)) {
- thrower.ThrowTypeError("Expected at least one argument to postMessage");
- }
- if (!electron::SerializeV8Value(args->isolate(), message_value,
- // SerializeV8Value sets an exception.
+ if (args->GetNext(&message_value)) {
+ if (!electron::SerializeV8Value(args->isolate(), message_value,
+ &transferable_message)) {
+ // SerializeV8Value sets an exception.
@@ -100,7 +80,8 @@ void MessagePort::PostMessage(gin::Arguments* args) {
for (unsigned i = 0; i < wrapped_port_values.size(); ++i) {
- if (!IsValidWrappable(wrapped_port_values[i])) {
thrower.ThrowTypeError("Port at index " + base::NumberToString(i) +
" is not a valid port");
return;
diff --git a/shell/common/gin_helper/wrappable.cc b/shell/common/gin_helper/wrappable.cc
index 1d0f45e004e48..5b4a0369441cc 100644
--- a/shell/common/gin_helper/wrappable.cc
+++ b/shell/common/gin_helper/wrappable.cc
@@ -10,6 +10,23 @@
+bool IsValidWrappable(const v8::Local<v8::Value>& val,
+ const gin::WrapperInfo* wrapper_info) {
+ if (!val->IsObject())
+ v8::Local<v8::Object> port = val.As<v8::Object>();
+ if (port->InternalFieldCount() != gin::kNumberOfInternalFields)
+ const gin::WrapperInfo* info = static_cast<gin::WrapperInfo*>(
+ port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex));
+ if (info != wrapper_info)
+ return true;
+}
WrappableBase::WrappableBase() = default;
WrappableBase::~WrappableBase() {
diff --git a/shell/common/gin_helper/wrappable.h b/shell/common/gin_helper/wrappable.h
index 531d446f7673d..76c0faeeebf00 100644
--- a/shell/common/gin_helper/wrappable.h
+++ b/shell/common/gin_helper/wrappable.h
@@ -11,6 +11,9 @@
+ const gin::WrapperInfo* wrapper_info);
namespace internal {
void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val);
diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts
index 88eaaf4a0b307..ceda0926e261e 100644
--- a/spec/api-ipc-spec.ts
+++ b/spec/api-ipc-spec.ts
@@ -236,6 +236,23 @@ describe('ipc module', () => {
expect(ev.senderFrame.routingId).to.equal(w.webContents.mainFrame.routingId);
});
+ it('throws when the transferable is invalid', async () => {
+ const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
+ w.loadURL('about:blank');
+ const p = once(ipcMain, 'port');
+ await w.webContents.executeJavaScript(`(${function () {
+ try {
+ const buffer = new ArrayBuffer(10);
+ // @ts-expect-error
+ require('electron').ipcRenderer.postMessage('port', '', [buffer]);
+ } catch (e) {
+ require('electron').ipcRenderer.postMessage('port', { error: (e as Error).message });
+ }})()`);
+ const [, msg] = await p;
+ });
it('can communicate between main and renderer', async () => {
const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } });
w.loadURL('about:blank');
@@ -411,6 +428,20 @@ describe('ipc module', () => {
expect(port2).not.to.be.null();
});
+ it('should not throw when supported values are passed as message', () => {
+ // @ts-expect-error - this shouldn't crash.
+ expect(() => { port1.postMessage(); }).to.not.throw();
+ expect(() => { port1.postMessage(undefined); }).to.not.throw();
+ expect(() => { port1.postMessage(42); }).to.not.throw();
+ expect(() => { port1.postMessage(false); }).to.not.throw();
+ expect(() => { port1.postMessage([]); }).to.not.throw();
+ expect(() => { port1.postMessage('hello'); }).to.not.throw();
+ expect(() => { port1.postMessage({ hello: 'goodbye' }); }).to.not.throw();
it('throws an error when an invalid parameter is sent to postMessage', () => {
const { port1 } = new MessageChannelMain(); | [
"+ thrower.ThrowTypeError(\"transferables must be an array of MessagePorts\");",
"-namespace {",
"- if (!val->IsObject())",
"- return info && info->embedder == gin::kEmbedderNativeGin;",
"- &transferable_message)) {",
"+bool IsValidWrappable(const v8::Local<v8::Value>& obj,",
"+ }",
"+ expect(msg.error).to.eql('Invalid value for transfer');",
"+ const { port1 } = new MessageChannelMain();",
"+ });"
] | [
21,
58,
61,
72,
92,
150,
175,
178,
189,
200
] | {
"additions": 82,
"author": "trop[bot]",
"deletions": 31,
"html_url": "https://github.com/electron/electron/pull/46667",
"issue_id": 46667,
"merged_at": "2025-04-17T16:23:24Z",
"omission_probability": 0.1,
"pr_number": 46667,
"repo": "electron/electron",
"title": "fix: `postMessage` crash with invalid transferrable",
"total_changes": 113
} |
589 | diff --git a/docs/api/base-window.md b/docs/api/base-window.md
index 38a82de051b02..d23ced860c5b9 100644
--- a/docs/api/base-window.md
+++ b/docs/api/base-window.md
@@ -342,12 +342,12 @@ Emitted when the window has closed a sheet.
Emitted when the native new tab button is clicked.
-#### Event: 'system-context-menu' _Windows_
+#### Event: 'system-context-menu' _Windows_ _Linux_
Returns:
* `event` Event
-* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
+* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
Emitted when the system context menu is triggered on the window, this is
normally only triggered when the user right clicks on the non-client area
@@ -356,6 +356,8 @@ as `-webkit-app-region: drag` in a frameless window.
Calling `event.preventDefault()` will prevent the menu from being displayed.
+To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows).
+
### Static Methods
The `BaseWindow` class has the following static methods:
diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md
index 46f3d0289edf1..96ef6896ffbea 100644
--- a/docs/api/browser-window.md
+++ b/docs/api/browser-window.md
@@ -421,12 +421,12 @@ Emitted when the window has closed a sheet.
Emitted when the native new tab button is clicked.
-#### Event: 'system-context-menu' _Windows_
+#### Event: 'system-context-menu' _Windows_ _Linux_
Returns:
* `event` Event
-* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
+* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
Emitted when the system context menu is triggered on the window, this is
normally only triggered when the user right clicks on the non-client area
@@ -435,6 +435,8 @@ as `-webkit-app-region: drag` in a frameless window.
Calling `event.preventDefault()` will prevent the menu from being displayed.
+To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows).
+
### Static Methods
The `BrowserWindow` class has the following static methods:
diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
index eb8d61f7f6afc..c58e7726e903f 100644
--- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
+++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
@@ -17,6 +17,9 @@
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/client_frame_view_linux.h"
#include "third_party/skia/include/core/SkRegion.h"
+#include "ui/aura/window_delegate.h"
+#include "ui/base/hit_test.h"
+#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/linux/linux_ui.h"
@@ -262,13 +265,45 @@ void ElectronDesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) {
is_mousedown &&
(mouse_event->IsRightMouseButton() ||
(mouse_event->IsLeftMouseButton() && mouse_event->IsControlDown()));
- if (is_system_menu_trigger) {
- electron::api::WebContents::SetDisableDraggableRegions(true);
+
+ if (!is_system_menu_trigger) {
views::DesktopWindowTreeHostLinux::DispatchEvent(event);
- electron::api::WebContents::SetDisableDraggableRegions(false);
return;
}
+
+ // Determine the non-client area and dispatch 'system-context-menu'.
+ if (GetContentWindow() && GetContentWindow()->delegate()) {
+ ui::LocatedEvent* located_event = event->AsLocatedEvent();
+ gfx::PointF location = located_event->location_f();
+ gfx::PointF location_in_dip =
+ GetRootTransform().InverseMapPoint(location).value_or(location);
+ int hit_test_code = GetContentWindow()->delegate()->GetNonClientComponent(
+ gfx::ToRoundedPoint(location_in_dip));
+ if (hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE) {
+ bool prevent_default = false;
+ native_window_view_->NotifyWindowSystemContextMenu(
+ located_event->x(), located_event->y(), &prevent_default);
+
+ // If |prevent_default| is true, then the user might want to show a
+ // custom menu - proceed propagation and emit context-menu in the
+ // renderer. Otherwise, show the native system window controls menu.
+ if (prevent_default) {
+ electron::api::WebContents::SetDisableDraggableRegions(true);
+ views::DesktopWindowTreeHostLinux::DispatchEvent(event);
+ electron::api::WebContents::SetDisableDraggableRegions(false);
+ } else {
+ if (ui::OzonePlatform::GetInstance()
+ ->GetPlatformRuntimeProperties()
+ .supports_server_window_menus) {
+ views::DesktopWindowTreeHostLinux::ShowWindowControlsMenu(
+ display::Screen::GetScreen()->GetCursorScreenPoint());
+ }
+ }
+ return;
+ }
+ }
}
+
views::DesktopWindowTreeHostLinux::DispatchEvent(event);
}
| diff --git a/docs/api/base-window.md b/docs/api/base-window.md
index 38a82de051b02..d23ced860c5b9 100644
--- a/docs/api/base-window.md
+++ b/docs/api/base-window.md
@@ -342,12 +342,12 @@ Emitted when the window has closed a sheet.
@@ -356,6 +356,8 @@ as `-webkit-app-region: drag` in a frameless window.
The `BaseWindow` class has the following static methods:
diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md
index 46f3d0289edf1..96ef6896ffbea 100644
--- a/docs/api/browser-window.md
+++ b/docs/api/browser-window.md
@@ -421,12 +421,12 @@ Emitted when the window has closed a sheet.
@@ -435,6 +435,8 @@ as `-webkit-app-region: drag` in a frameless window.
The `BrowserWindow` class has the following static methods:
diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
index eb8d61f7f6afc..c58e7726e903f 100644
--- a/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
+++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.cc
@@ -17,6 +17,9 @@
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/client_frame_view_linux.h"
#include "third_party/skia/include/core/SkRegion.h"
+#include "ui/aura/window_delegate.h"
+#include "ui/base/hit_test.h"
+#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/linux/linux_ui.h"
@@ -262,13 +265,45 @@ void ElectronDesktopWindowTreeHostLinux::DispatchEvent(ui::Event* event) {
is_mousedown &&
(mouse_event->IsRightMouseButton() ||
(mouse_event->IsLeftMouseButton() && mouse_event->IsControlDown()));
- if (is_system_menu_trigger) {
- electron::api::WebContents::SetDisableDraggableRegions(true);
+ if (!is_system_menu_trigger) {
views::DesktopWindowTreeHostLinux::DispatchEvent(event);
- electron::api::WebContents::SetDisableDraggableRegions(false);
return;
}
+ // Determine the non-client area and dispatch 'system-context-menu'.
+ if (GetContentWindow() && GetContentWindow()->delegate()) {
+ ui::LocatedEvent* located_event = event->AsLocatedEvent();
+ gfx::PointF location = located_event->location_f();
+ gfx::PointF location_in_dip =
+ GetRootTransform().InverseMapPoint(location).value_or(location);
+ int hit_test_code = GetContentWindow()->delegate()->GetNonClientComponent(
+ gfx::ToRoundedPoint(location_in_dip));
+ if (hit_test_code != HTCLIENT && hit_test_code != HTNOWHERE) {
+ bool prevent_default = false;
+ native_window_view_->NotifyWindowSystemContextMenu(
+ located_event->x(), located_event->y(), &prevent_default);
+ // If |prevent_default| is true, then the user might want to show a
+ // custom menu - proceed propagation and emit context-menu in the
+ // renderer. Otherwise, show the native system window controls menu.
+ if (prevent_default) {
+ electron::api::WebContents::SetDisableDraggableRegions(true);
+ views::DesktopWindowTreeHostLinux::DispatchEvent(event);
+ electron::api::WebContents::SetDisableDraggableRegions(false);
+ } else {
+ if (ui::OzonePlatform::GetInstance()
+ ->GetPlatformRuntimeProperties()
+ .supports_server_window_menus) {
+ views::DesktopWindowTreeHostLinux::ShowWindowControlsMenu(
+ display::Screen::GetScreen()->GetCursorScreenPoint());
+ }
+ }
+ return;
+ }
+ }
}
views::DesktopWindowTreeHostLinux::DispatchEvent(event);
} | [] | [] | {
"additions": 46,
"author": "codebytere",
"deletions": 7,
"html_url": "https://github.com/electron/electron/pull/45848",
"issue_id": 45848,
"merged_at": "2025-04-01T09:00:39Z",
"omission_probability": 0.1,
"pr_number": 45848,
"repo": "electron/electron",
"title": "feat: support `system-context-menu` on Linux",
"total_changes": 53
} |
590 | diff --git a/docs/api/native-theme.md b/docs/api/native-theme.md
index e6bdd6c806067..7860c870307b4 100644
--- a/docs/api/native-theme.md
+++ b/docs/api/native-theme.md
@@ -63,6 +63,14 @@ Your application should then always use `shouldUseDarkColors` to determine what
A `boolean` for if the OS / Chromium currently has high-contrast mode enabled
or is being instructed to show a high-contrast UI.
+### `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI` _macOS_ _Windows_ _Readonly_
+
+A `boolean` property indicating whether or not the system theme has been set to dark or light.
+
+On Windows this property distinguishes between system and app light/dark theme, returning
+`true` if the system theme is set to dark theme and `false` otherwise. On macOS the return
+value will be the same as `nativeTheme.shouldUseDarkColors`.
+
### `nativeTheme.shouldUseInvertedColorScheme` _macOS_ _Windows_ _Readonly_
A `boolean` for if the OS / Chromium currently has an inverted color scheme
diff --git a/shell/browser/api/electron_api_native_theme.cc b/shell/browser/api/electron_api_native_theme.cc
index a86481e4d67a5..01e470c227c22 100644
--- a/shell/browser/api/electron_api_native_theme.cc
+++ b/shell/browser/api/electron_api_native_theme.cc
@@ -63,6 +63,10 @@ bool NativeTheme::ShouldUseHighContrastColors() {
return ui_theme_->UserHasContrastPreference();
}
+bool NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI() {
+ return ui_theme_->ShouldUseDarkColorsForSystemIntegratedUI();
+}
+
bool NativeTheme::InForcedColorsMode() {
return ui_theme_->InForcedColorsMode();
}
@@ -109,6 +113,8 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder(
&NativeTheme::SetThemeSource)
.SetProperty("shouldUseHighContrastColors",
&NativeTheme::ShouldUseHighContrastColors)
+ .SetProperty("shouldUseDarkColorsForSystemIntegratedUI",
+ &NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI)
.SetProperty("shouldUseInvertedColorScheme",
&NativeTheme::ShouldUseInvertedColorScheme)
.SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode)
diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h
index d94f148ec5315..86cc3412d3852 100644
--- a/shell/browser/api/electron_api_native_theme.h
+++ b/shell/browser/api/electron_api_native_theme.h
@@ -48,6 +48,7 @@ class NativeTheme final : public gin::Wrappable<NativeTheme>,
ui::NativeTheme::ThemeSource GetThemeSource() const;
bool ShouldUseDarkColors();
bool ShouldUseHighContrastColors();
+ bool ShouldUseDarkColorsForSystemIntegratedUI();
bool ShouldUseInvertedColorScheme();
bool InForcedColorsMode();
bool GetPrefersReducedTransparency();
diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts
index 2d2a3a3b00d6a..d68caf06fb81d 100644
--- a/spec/api-native-theme-spec.ts
+++ b/spec/api-native-theme-spec.ts
@@ -102,6 +102,12 @@ describe('nativeTheme module', () => {
});
});
+ describe('nativeTheme.shouldUseDarkColorsForSystemIntegratedUI', () => {
+ it('returns a boolean', () => {
+ expect(nativeTheme.shouldUseDarkColorsForSystemIntegratedUI).to.be.a('boolean');
+ });
+ });
+
describe('nativeTheme.inForcedColorsMode', () => {
it('returns a boolean', () => {
expect(nativeTheme.inForcedColorsMode).to.be.a('boolean');
| diff --git a/docs/api/native-theme.md b/docs/api/native-theme.md
index e6bdd6c806067..7860c870307b4 100644
--- a/docs/api/native-theme.md
+++ b/docs/api/native-theme.md
@@ -63,6 +63,14 @@ Your application should then always use `shouldUseDarkColors` to determine what
A `boolean` for if the OS / Chromium currently has high-contrast mode enabled
or is being instructed to show a high-contrast UI.
+### `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI` _macOS_ _Windows_ _Readonly_
+A `boolean` property indicating whether or not the system theme has been set to dark or light.
+On Windows this property distinguishes between system and app light/dark theme, returning
+`true` if the system theme is set to dark theme and `false` otherwise. On macOS the return
+value will be the same as `nativeTheme.shouldUseDarkColors`.
### `nativeTheme.shouldUseInvertedColorScheme` _macOS_ _Windows_ _Readonly_
A `boolean` for if the OS / Chromium currently has an inverted color scheme
diff --git a/shell/browser/api/electron_api_native_theme.cc b/shell/browser/api/electron_api_native_theme.cc
index a86481e4d67a5..01e470c227c22 100644
--- a/shell/browser/api/electron_api_native_theme.cc
+++ b/shell/browser/api/electron_api_native_theme.cc
@@ -63,6 +63,10 @@ bool NativeTheme::ShouldUseHighContrastColors() {
return ui_theme_->UserHasContrastPreference();
+bool NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI() {
+}
bool NativeTheme::InForcedColorsMode() {
return ui_theme_->InForcedColorsMode();
@@ -109,6 +113,8 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder(
&NativeTheme::SetThemeSource)
.SetProperty("shouldUseHighContrastColors",
&NativeTheme::ShouldUseHighContrastColors)
+ .SetProperty("shouldUseDarkColorsForSystemIntegratedUI",
+ &NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI)
.SetProperty("shouldUseInvertedColorScheme",
&NativeTheme::ShouldUseInvertedColorScheme)
.SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode)
diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h
index d94f148ec5315..86cc3412d3852 100644
--- a/shell/browser/api/electron_api_native_theme.h
+++ b/shell/browser/api/electron_api_native_theme.h
@@ -48,6 +48,7 @@ class NativeTheme final : public gin::Wrappable<NativeTheme>,
ui::NativeTheme::ThemeSource GetThemeSource() const;
bool ShouldUseDarkColors();
bool ShouldUseHighContrastColors();
+ bool ShouldUseDarkColorsForSystemIntegratedUI();
bool ShouldUseInvertedColorScheme();
bool InForcedColorsMode();
bool GetPrefersReducedTransparency();
diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts
index 2d2a3a3b00d6a..d68caf06fb81d 100644
--- a/spec/api-native-theme-spec.ts
+++ b/spec/api-native-theme-spec.ts
@@ -102,6 +102,12 @@ describe('nativeTheme module', () => {
});
});
+ describe('nativeTheme.shouldUseDarkColorsForSystemIntegratedUI', () => {
+ it('returns a boolean', () => {
+ expect(nativeTheme.shouldUseDarkColorsForSystemIntegratedUI).to.be.a('boolean');
+ });
+ });
describe('nativeTheme.inForcedColorsMode', () => {
it('returns a boolean', () => {
expect(nativeTheme.inForcedColorsMode).to.be.a('boolean'); | [
"+ return ui_theme_->ShouldUseDarkColorsForSystemIntegratedUI();"
] | [
28
] | {
"additions": 21,
"author": "codebytere",
"deletions": 0,
"html_url": "https://github.com/electron/electron/pull/46438",
"issue_id": 46438,
"merged_at": "2025-04-10T10:08:30Z",
"omission_probability": 0.1,
"pr_number": 46438,
"repo": "electron/electron",
"title": "feat: expose `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI`",
"total_changes": 21
} |
591 | diff --git a/.golangci.yml b/.golangci.yml
index d8401bdd6fa..b8c21d815b1 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,8 +1,22 @@
-version: "2"
-run:
- timeout: 10m
+formatters:
+ enable:
+ - gofmt
+ - goimports
+
+ exclusions:
+ generated: lax
+
+ settings:
+ gofmt:
+ simplify: true
+
+ goimports:
+ local-prefixes:
+ - helm.sh/helm/v4
+
linters:
default: none
+
enable:
- depguard
- dupl
@@ -13,60 +27,37 @@ linters:
- revive
- staticcheck
- unused
- settings:
- depguard:
- rules:
- Main:
- deny:
- - pkg: github.com/hashicorp/go-multierror
- desc: "use errors instead"
- - pkg: github.com/pkg/errors
- desc: "use errors instead"
- dupl:
- threshold: 400
+
exclusions:
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
generated: lax
+
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
- rules:
- - linters:
- - revive
- text: 'redefines-builtin-id: redefinition of the built-in function append'
- - linters:
- - revive
- text: 'redefines-builtin-id: redefinition of the built-in function clear'
- - linters:
- - revive
- text: 'redefines-builtin-id: redefinition of the built-in function max'
- - linters:
- - revive
- text: 'redefines-builtin-id: redefinition of the built-in function min'
- - linters:
- - revive
- text: 'redefines-builtin-id: redefinition of the built-in function new'
- paths:
- - third_party$
- - builtin$
- - examples$
-formatters:
- enable:
- - gofmt
- - goimports
+
+ rules: []
+
+ warn-unused: true
+
settings:
- gofmt:
- simplify: true
- goimports:
- local-prefixes:
- - helm.sh/helm/v4
- exclusions:
- generated: lax
- paths:
- - third_party$
- - builtin$
- - examples$
+ depguard:
+ rules:
+ Main:
+ deny:
+ - pkg: github.com/hashicorp/go-multierror
+ desc: "use errors instead"
+ - pkg: github.com/pkg/errors
+ desc: "use errors instead"
+
+ dupl:
+ threshold: 400
+
+run:
+ timeout: 10m
+
+version: "2"
| diff --git a/.golangci.yml b/.golangci.yml
index d8401bdd6fa..b8c21d815b1 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,8 +1,22 @@
-version: "2"
-run:
- timeout: 10m
+formatters:
+ enable:
+ - gofmt
+ - goimports
+ exclusions:
+ generated: lax
+ settings:
+ gofmt:
+ simplify: true
+ goimports:
+ - helm.sh/helm/v4
linters:
default: none
enable:
- depguard
- dupl
@@ -13,60 +27,37 @@ linters:
- revive
- staticcheck
- unused
- settings:
- depguard:
- rules:
- Main:
- deny:
- - pkg: github.com/hashicorp/go-multierror
- - pkg: github.com/pkg/errors
- dupl:
- threshold: 400
exclusions:
# Helm, and the Go source code itself, sometimes uses these names outside their built-in
# functions. As the Go source code has re-used these names it's ok for Helm to do the same.
# Linting will look for redefinition of built-in id's but we opt-in to the ones we choose to use.
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
- rules:
- text: 'redefines-builtin-id: redefinition of the built-in function append'
- text: 'redefines-builtin-id: redefinition of the built-in function clear'
- text: 'redefines-builtin-id: redefinition of the built-in function max'
- text: 'redefines-builtin-id: redefinition of the built-in function min'
- text: 'redefines-builtin-id: redefinition of the built-in function new'
-formatters:
- enable:
- - gofmt
- - goimports
+ rules: []
+ warn-unused: true
settings:
- gofmt:
- simplify: true
- local-prefixes:
- - helm.sh/helm/v4
- generated: lax
+ depguard:
+ rules:
+ Main:
+ deny:
+ - pkg: github.com/hashicorp/go-multierror
+ - pkg: github.com/pkg/errors
+ dupl:
+ threshold: 400
+run:
+ timeout: 10m
+version: "2" | [
"+ local-prefixes:",
"- goimports:",
"- exclusions:"
] | [
21,
89,
92
] | {
"additions": 40,
"author": "mmorel-35",
"deletions": 49,
"html_url": "https://github.com/helm/helm/pull/30786",
"issue_id": 30786,
"merged_at": "2025-04-25T19:49:24Z",
"omission_probability": 0.1,
"pr_number": 30786,
"repo": "helm/helm",
"title": "refactor: reorganize .golangci.yml for better clarity and structure",
"total_changes": 89
} |
592 | diff --git a/pkg/chart/v2/chart.go b/pkg/chart/v2/chart.go
index dcc2a43eb36..66ddf98a507 100644
--- a/pkg/chart/v2/chart.go
+++ b/pkg/chart/v2/chart.go
@@ -113,6 +113,8 @@ func (ch *Chart) ChartPath() string {
}
// ChartFullPath returns the full path to this chart.
+// Note that the path may not correspond to the path where the file can be found on the file system if the path
+// points to an aliased subchart.
func (ch *Chart) ChartFullPath() string {
if !ch.IsRoot() {
return ch.Parent().ChartFullPath() + "/charts/" + ch.Name()
diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go
index b7f78010baf..e2cce6f2f5a 100644
--- a/pkg/chart/v2/util/dependencies.go
+++ b/pkg/chart/v2/util/dependencies.go
@@ -91,6 +91,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) {
}
}
+// getAliasDependency finds the chart for an alias dependency and copies parts that will be modified
func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Chart {
for _, c := range charts {
if c == nil {
@@ -104,17 +105,38 @@ func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Cha
}
out := *c
- md := *c.Metadata
- out.Metadata = &md
+ out.Metadata = copyMetadata(c.Metadata)
+
+ // empty dependencies and shallow copy all dependencies, otherwise parent info may be corrupted if
+ // there is more than one dependency aliasing this chart
+ out.SetDependencies()
+ for _, dependency := range c.Dependencies() {
+ cpy := *dependency
+ out.AddDependency(&cpy)
+ }
if dep.Alias != "" {
- md.Name = dep.Alias
+ out.Metadata.Name = dep.Alias
}
return &out
}
return nil
}
+func copyMetadata(metadata *chart.Metadata) *chart.Metadata {
+ md := *metadata
+
+ if md.Dependencies != nil {
+ dependencies := make([]*chart.Dependency, len(md.Dependencies))
+ for i := range md.Dependencies {
+ dependency := *md.Dependencies[i]
+ dependencies[i] = &dependency
+ }
+ md.Dependencies = dependencies
+ }
+ return &md
+}
+
// processDependencyEnabled removes disabled charts from dependencies
func processDependencyEnabled(c *chart.Chart, v map[string]interface{}, path string) error {
if c.Metadata.Dependencies == nil {
diff --git a/pkg/chart/v2/util/dependencies_test.go b/pkg/chart/v2/util/dependencies_test.go
index 5bd33299052..9b7fe3bef40 100644
--- a/pkg/chart/v2/util/dependencies_test.go
+++ b/pkg/chart/v2/util/dependencies_test.go
@@ -286,6 +286,38 @@ func TestProcessDependencyImportValues(t *testing.T) {
}
}
+func TestProcessDependencyImportValuesFromSharedDependencyToAliases(t *testing.T) {
+ c := loadChart(t, "testdata/chart-with-import-from-aliased-dependencies")
+
+ if err := processDependencyEnabled(c, c.Values, ""); err != nil {
+ t.Fatalf("expected no errors but got %q", err)
+ }
+ if err := processDependencyImportValues(c, true); err != nil {
+ t.Fatalf("processing import values dependencies %v", err)
+ }
+ e := make(map[string]string)
+
+ e["foo-defaults.defaultValue"] = "42"
+ e["bar-defaults.defaultValue"] = "42"
+
+ e["foo.defaults.defaultValue"] = "42"
+ e["bar.defaults.defaultValue"] = "42"
+
+ e["foo.grandchild.defaults.defaultValue"] = "42"
+ e["bar.grandchild.defaults.defaultValue"] = "42"
+
+ cValues := Values(c.Values)
+ for kk, vv := range e {
+ pv, err := cValues.PathValue(kk)
+ if err != nil {
+ t.Fatalf("retrieving import values table %v %v", kk, err)
+ }
+ if pv != vv {
+ t.Errorf("failed to match imported value %v with expected %v", pv, vv)
+ }
+ }
+}
+
func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) {
c := loadChart(t, "testdata/three-level-dependent-chart/umbrella")
@@ -430,6 +462,9 @@ func TestDependentChartAliases(t *testing.T) {
if aliasChart == nil {
t.Fatalf("failed to get dependency chart for alias %s", req[2].Name)
}
+ if aliasChart.Parent() != c {
+ t.Fatalf("dependency chart has wrong parent, expected %s but got %s", c.Name(), aliasChart.Parent().Name())
+ }
if req[2].Alias != "" {
if aliasChart.Name() != req[2].Alias {
t.Fatalf("dependency chart name should be %s but got %s", req[2].Alias, aliasChart.Name())
@@ -521,3 +556,32 @@ func TestDependentChartsWithSomeSubchartsSpecifiedInDependency(t *testing.T) {
t.Fatalf("expected 1 dependency specified in Chart.yaml, got %d", len(c.Metadata.Dependencies))
}
}
+
+func validateDependencyTree(t *testing.T, c *chart.Chart) {
+ for _, dependency := range c.Dependencies() {
+ if dependency.Parent() != c {
+ if dependency.Parent() != c {
+ t.Fatalf("dependency chart %s has wrong parent, expected %s but got %s", dependency.Name(), c.Name(), dependency.Parent().Name())
+ }
+ }
+ // recurse entire tree
+ validateDependencyTree(t, dependency)
+ }
+}
+
+func TestChartWithDependencyAliasedTwiceAndDoublyReferencedSubDependency(t *testing.T) {
+ c := loadChart(t, "testdata/chart-with-dependency-aliased-twice")
+
+ if len(c.Dependencies()) != 1 {
+ t.Fatalf("expected one dependency for this chart, but got %d", len(c.Dependencies()))
+ }
+
+ if err := processDependencyEnabled(c, c.Values, ""); err != nil {
+ t.Fatalf("expected no errors but got %q", err)
+ }
+
+ if len(c.Dependencies()) != 2 {
+ t.Fatal("expected two dependencies after processing aliases")
+ }
+ validateDependencyTree(t, c)
+}
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml
new file mode 100644
index 00000000000..d778f8fe93e
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml
@@ -0,0 +1,14 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: chart-with-dependency-aliased-twice
+type: application
+version: 1.0.0
+
+dependencies:
+ - name: child
+ alias: foo
+ version: 1.0.0
+ - name: child
+ alias: bar
+ version: 1.0.0
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml
new file mode 100644
index 00000000000..220fda6635f
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml
@@ -0,0 +1,6 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: child
+type: application
+version: 1.0.0
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml
new file mode 100644
index 00000000000..50e620a8dd4
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml
@@ -0,0 +1,6 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: grandchild
+type: application
+version: 1.0.0
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml
new file mode 100644
index 00000000000..1830492efe3
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml
@@ -0,0 +1,7 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ .Chart.Name }}-{{ .Values.from }}
+data:
+ {{- toYaml .Values | nindent 2 }}
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml
new file mode 100644
index 00000000000..b5d55af7c5f
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml
@@ -0,0 +1,7 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ .Chart.Name }}
+data:
+ {{- toYaml .Values | nindent 2 }}
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml
new file mode 100644
index 00000000000..695521a4ae5
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml
@@ -0,0 +1,7 @@
+foo:
+ grandchild:
+ from: foo
+bar:
+ grandchild:
+ from: bar
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml
new file mode 100644
index 00000000000..c408f0ca8d8
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml
@@ -0,0 +1,20 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: chart-with-dependency-aliased-twice
+type: application
+version: 1.0.0
+
+dependencies:
+ - name: child
+ alias: foo
+ version: 1.0.0
+ import-values:
+ - parent: foo-defaults
+ child: defaults
+ - name: child
+ alias: bar
+ version: 1.0.0
+ import-values:
+ - parent: bar-defaults
+ child: defaults
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml
new file mode 100644
index 00000000000..ecdaf04dcdd
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml
@@ -0,0 +1,12 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: child
+type: application
+version: 1.0.0
+
+dependencies:
+ - name: grandchild
+ version: 1.0.0
+ import-values:
+ - parent: defaults
+ child: defaults
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml
new file mode 100644
index 00000000000..50e620a8dd4
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml
@@ -0,0 +1,6 @@
+apiVersion: v2
+appVersion: 1.0.0
+name: grandchild
+type: application
+version: 1.0.0
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml
new file mode 100644
index 00000000000..f51c594f4fe
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml
@@ -0,0 +1,2 @@
+defaults:
+ defaultValue: "42"
\ No newline at end of file
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml
new file mode 100644
index 00000000000..3140f53ddd5
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml
@@ -0,0 +1,7 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ .Chart.Name }}
+data:
+ {{ .Values.defaults | toYaml }}
+
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml
new file mode 100644
index 00000000000..a2b62c95aae
--- /dev/null
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml
@@ -0,0 +1,7 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ .Chart.Name }}
+data:
+ {{ toYaml .Values.defaults | indent 2 }}
+
| diff --git a/pkg/chart/v2/chart.go b/pkg/chart/v2/chart.go
index dcc2a43eb36..66ddf98a507 100644
--- a/pkg/chart/v2/chart.go
+++ b/pkg/chart/v2/chart.go
@@ -113,6 +113,8 @@ func (ch *Chart) ChartPath() string {
// ChartFullPath returns the full path to this chart.
+// Note that the path may not correspond to the path where the file can be found on the file system if the path
func (ch *Chart) ChartFullPath() string {
if !ch.IsRoot() {
return ch.Parent().ChartFullPath() + "/charts/" + ch.Name()
diff --git a/pkg/chart/v2/util/dependencies.go b/pkg/chart/v2/util/dependencies.go
index b7f78010baf..e2cce6f2f5a 100644
--- a/pkg/chart/v2/util/dependencies.go
+++ b/pkg/chart/v2/util/dependencies.go
@@ -91,6 +91,7 @@ func processDependencyTags(reqs []*chart.Dependency, cvals Values) {
+// getAliasDependency finds the chart for an alias dependency and copies parts that will be modified
func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Chart {
for _, c := range charts {
if c == nil {
@@ -104,17 +105,38 @@ func getAliasDependency(charts []*chart.Chart, dep *chart.Dependency) *chart.Cha
out := *c
- out.Metadata = &md
+ // empty dependencies and shallow copy all dependencies, otherwise parent info may be corrupted if
+ // there is more than one dependency aliasing this chart
+ for _, dependency := range c.Dependencies() {
+ cpy := *dependency
+ out.AddDependency(&cpy)
if dep.Alias != "" {
- md.Name = dep.Alias
+ out.Metadata.Name = dep.Alias
return &out
return nil
+func copyMetadata(metadata *chart.Metadata) *chart.Metadata {
+ md := *metadata
+ if md.Dependencies != nil {
+ dependencies := make([]*chart.Dependency, len(md.Dependencies))
+ for i := range md.Dependencies {
+ dependency := *md.Dependencies[i]
+ dependencies[i] = &dependency
+ md.Dependencies = dependencies
// processDependencyEnabled removes disabled charts from dependencies
func processDependencyEnabled(c *chart.Chart, v map[string]interface{}, path string) error {
if c.Metadata.Dependencies == nil {
diff --git a/pkg/chart/v2/util/dependencies_test.go b/pkg/chart/v2/util/dependencies_test.go
index 5bd33299052..9b7fe3bef40 100644
--- a/pkg/chart/v2/util/dependencies_test.go
+++ b/pkg/chart/v2/util/dependencies_test.go
@@ -286,6 +286,38 @@ func TestProcessDependencyImportValues(t *testing.T) {
+ c := loadChart(t, "testdata/chart-with-import-from-aliased-dependencies")
+ t.Fatalf("processing import values dependencies %v", err)
+ e := make(map[string]string)
+ e["foo-defaults.defaultValue"] = "42"
+ e["bar-defaults.defaultValue"] = "42"
+ e["foo.defaults.defaultValue"] = "42"
+ e["bar.defaults.defaultValue"] = "42"
+ e["foo.grandchild.defaults.defaultValue"] = "42"
+ e["bar.grandchild.defaults.defaultValue"] = "42"
+ cValues := Values(c.Values)
+ for kk, vv := range e {
+ pv, err := cValues.PathValue(kk)
+ if err != nil {
+ if pv != vv {
+ t.Errorf("failed to match imported value %v with expected %v", pv, vv)
func TestProcessDependencyImportValuesMultiLevelPrecedence(t *testing.T) {
c := loadChart(t, "testdata/three-level-dependent-chart/umbrella")
@@ -430,6 +462,9 @@ func TestDependentChartAliases(t *testing.T) {
if aliasChart == nil {
t.Fatalf("failed to get dependency chart for alias %s", req[2].Name)
+ if aliasChart.Parent() != c {
+ t.Fatalf("dependency chart has wrong parent, expected %s but got %s", c.Name(), aliasChart.Parent().Name())
if req[2].Alias != "" {
if aliasChart.Name() != req[2].Alias {
t.Fatalf("dependency chart name should be %s but got %s", req[2].Alias, aliasChart.Name())
@@ -521,3 +556,32 @@ func TestDependentChartsWithSomeSubchartsSpecifiedInDependency(t *testing.T) {
t.Fatalf("expected 1 dependency specified in Chart.yaml, got %d", len(c.Metadata.Dependencies))
+func validateDependencyTree(t *testing.T, c *chart.Chart) {
+ if dependency.Parent() != c {
+ if dependency.Parent() != c {
+ t.Fatalf("dependency chart %s has wrong parent, expected %s but got %s", dependency.Name(), c.Name(), dependency.Parent().Name())
+ }
+ // recurse entire tree
+ validateDependencyTree(t, dependency)
+func TestChartWithDependencyAliasedTwiceAndDoublyReferencedSubDependency(t *testing.T) {
+ c := loadChart(t, "testdata/chart-with-dependency-aliased-twice")
+ if len(c.Dependencies()) != 1 {
+ t.Fatalf("expected one dependency for this chart, but got %d", len(c.Dependencies()))
+ if len(c.Dependencies()) != 2 {
+ t.Fatal("expected two dependencies after processing aliases")
+ validateDependencyTree(t, c)
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml
index 00000000000..d778f8fe93e
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/Chart.yaml
@@ -0,0 +1,14 @@
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml
index 00000000000..220fda6635f
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/Chart.yaml
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/Chart.yaml
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml
index 00000000000..1830492efe3
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/charts/grandchild/templates/dummy.yaml
+ name: {{ .Chart.Name }}-{{ .Values.from }}
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml
index 00000000000..b5d55af7c5f
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/charts/child/templates/dummy.yaml
diff --git a/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml
index 00000000000..695521a4ae5
+++ b/pkg/chart/v2/util/testdata/chart-with-dependency-aliased-twice/values.yaml
+ from: foo
+ from: bar
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml
index 00000000000..c408f0ca8d8
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/Chart.yaml
@@ -0,0 +1,20 @@
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml
index 00000000000..ecdaf04dcdd
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/Chart.yaml
@@ -0,0 +1,12 @@
+ - name: grandchild
+ - parent: defaults
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/Chart.yaml
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml
index 00000000000..f51c594f4fe
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/charts/grandchild/values.yaml
@@ -0,0 +1,2 @@
+defaults:
+ defaultValue: "42"
\ No newline at end of file
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml
index 00000000000..3140f53ddd5
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/charts/child/templates/dummy.yaml
+ {{ .Values.defaults | toYaml }}
diff --git a/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml
index 00000000000..a2b62c95aae
+++ b/pkg/chart/v2/util/testdata/chart-with-import-from-aliased-dependencies/templates/dummy.yaml
+ {{ toYaml .Values.defaults | indent 2 }} | [
"+// points to an aliased subchart.",
"-\t\tmd := *c.Metadata",
"+\t\tout.Metadata = copyMetadata(c.Metadata)",
"+\t\tout.SetDependencies()",
"+\treturn &md",
"+func TestProcessDependencyImportValuesFromSharedDependencyToAliases(t *testing.T) {",
"+\tif err := processDependencyImportValues(c, true); err != nil {",
"+\t\t\tt.Fatalf(\"retrieving import values table %v %v\", kk, err)",
"+\tfor _, dependency := range c.Dependencies() {",
"+foo:",
"+bar:",
"+ - parent: foo-defaults",
"+ - parent: bar-defaults"
] | [
9,
29,
31,
35,
61,
75,
81,
99,
126,
229,
232,
253,
259
] | {
"additions": 192,
"author": "dastrobu",
"deletions": 3,
"html_url": "https://github.com/helm/helm/pull/9175",
"issue_id": 9175,
"merged_at": "2025-04-23T18:40:52Z",
"omission_probability": 0.1,
"pr_number": 9175,
"repo": "helm/helm",
"title": "fix: copy dependencies on aliasing to avoid sharing chart references on multiply aliased dependencies",
"total_changes": 195
} |
593 | diff --git a/pkg/action/package.go b/pkg/action/package.go
index 9ffe1722e42..8f37779e65f 100644
--- a/pkg/action/package.go
+++ b/pkg/action/package.go
@@ -39,6 +39,7 @@ type Package struct {
Key string
Keyring string
PassphraseFile string
+ cachedPassphrase []byte
Version string
AppVersion string
Destination string
@@ -55,6 +56,10 @@ type Package struct {
InsecureSkipTLSverify bool
}
+const (
+ passPhraseFileStdin = "-"
+)
+
// NewPackage creates a new Package object with the given configuration.
func NewPackage() *Package {
return &Package{}
@@ -128,7 +133,7 @@ func (p *Package) Clearsign(filename string) error {
passphraseFetcher := promptUser
if p.PassphraseFile != "" {
- passphraseFetcher, err = passphraseFileFetcher(p.PassphraseFile, os.Stdin)
+ passphraseFetcher, err = p.passphraseFileFetcher(p.PassphraseFile, os.Stdin)
if err != nil {
return err
}
@@ -156,25 +161,42 @@ func promptUser(name string) ([]byte, error) {
return pw, err
}
-func passphraseFileFetcher(passphraseFile string, stdin *os.File) (provenance.PassphraseFetcher, error) {
- file, err := openPassphraseFile(passphraseFile, stdin)
- if err != nil {
- return nil, err
- }
- defer file.Close()
+func (p *Package) passphraseFileFetcher(passphraseFile string, stdin *os.File) (provenance.PassphraseFetcher, error) {
+ // When reading from stdin we cache the passphrase here. If we are
+ // packaging multiple charts, we reuse the cached passphrase. This
+ // allows giving the passphrase once on stdin without failing with
+ // complaints about stdin already being closed.
+ //
+ // An alternative to this would be to omit file.Close() for stdin
+ // below and require the user to provide the same passphrase once
+ // per chart on stdin, but that does not seem very user-friendly.
+
+ if p.cachedPassphrase == nil {
+ file, err := openPassphraseFile(passphraseFile, stdin)
+ if err != nil {
+ return nil, err
+ }
+ defer file.Close()
- reader := bufio.NewReader(file)
- passphrase, _, err := reader.ReadLine()
- if err != nil {
- return nil, err
+ reader := bufio.NewReader(file)
+ passphrase, _, err := reader.ReadLine()
+ if err != nil {
+ return nil, err
+ }
+ p.cachedPassphrase = passphrase
+
+ return func(_ string) ([]byte, error) {
+ return passphrase, nil
+ }, nil
}
+
return func(_ string) ([]byte, error) {
- return passphrase, nil
+ return p.cachedPassphrase, nil
}, nil
}
func openPassphraseFile(passphraseFile string, stdin *os.File) (*os.File, error) {
- if passphraseFile == "-" {
+ if passphraseFile == passPhraseFileStdin {
stat, err := stdin.Stat()
if err != nil {
return nil, err
diff --git a/pkg/action/package_test.go b/pkg/action/package_test.go
index 26eeb1a2ba7..12bea10dd33 100644
--- a/pkg/action/package_test.go
+++ b/pkg/action/package_test.go
@@ -29,8 +29,9 @@ import (
func TestPassphraseFileFetcher(t *testing.T) {
secret := "secret"
directory := ensure.TempFile(t, "passphrase-file", []byte(secret))
+ testPkg := NewPackage()
- fetcher, err := passphraseFileFetcher(path.Join(directory, "passphrase-file"), nil)
+ fetcher, err := testPkg.passphraseFileFetcher(path.Join(directory, "passphrase-file"), nil)
if err != nil {
t.Fatal("Unable to create passphraseFileFetcher", err)
}
@@ -48,8 +49,9 @@ func TestPassphraseFileFetcher(t *testing.T) {
func TestPassphraseFileFetcher_WithLineBreak(t *testing.T) {
secret := "secret"
directory := ensure.TempFile(t, "passphrase-file", []byte(secret+"\n\n."))
+ testPkg := NewPackage()
- fetcher, err := passphraseFileFetcher(path.Join(directory, "passphrase-file"), nil)
+ fetcher, err := testPkg.passphraseFileFetcher(path.Join(directory, "passphrase-file"), nil)
if err != nil {
t.Fatal("Unable to create passphraseFileFetcher", err)
}
@@ -66,17 +68,48 @@ func TestPassphraseFileFetcher_WithLineBreak(t *testing.T) {
func TestPassphraseFileFetcher_WithInvalidStdin(t *testing.T) {
directory := t.TempDir()
+ testPkg := NewPackage()
stdin, err := os.CreateTemp(directory, "non-existing")
if err != nil {
t.Fatal("Unable to create test file", err)
}
- if _, err := passphraseFileFetcher("-", stdin); err == nil {
+ if _, err := testPkg.passphraseFileFetcher("-", stdin); err == nil {
t.Error("Expected passphraseFileFetcher returning an error")
}
}
+func TestPassphraseFileFetcher_WithStdinAndMultipleFetches(t *testing.T) {
+ testPkg := NewPackage()
+ stdin, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal("Unable to create pipe", err)
+ }
+
+ passphrase := "secret-from-stdin"
+
+ go func() {
+ w.Write([]byte(passphrase + "\n"))
+ }()
+
+ for i := 0; i < 4; i++ {
+ fetcher, err := testPkg.passphraseFileFetcher("-", stdin)
+ if err != nil {
+ t.Errorf("Expected passphraseFileFetcher to not return an error, but got %v", err)
+ }
+
+ pass, err := fetcher("key")
+ if err != nil {
+ t.Errorf("Expected passphraseFileFetcher invocation to succeed, failed with %v", err)
+ }
+
+ if string(pass) != string(passphrase) {
+ t.Errorf("Expected multiple passphrase fetch to return %q, got %q", passphrase, pass)
+ }
+ }
+}
+
func TestValidateVersion(t *testing.T) {
type args struct {
ver string
| diff --git a/pkg/action/package.go b/pkg/action/package.go
index 9ffe1722e42..8f37779e65f 100644
--- a/pkg/action/package.go
+++ b/pkg/action/package.go
@@ -39,6 +39,7 @@ type Package struct {
Key string
Keyring string
PassphraseFile string
+ cachedPassphrase []byte
Version string
AppVersion string
Destination string
@@ -55,6 +56,10 @@ type Package struct {
InsecureSkipTLSverify bool
+const (
+ passPhraseFileStdin = "-"
+)
// NewPackage creates a new Package object with the given configuration.
func NewPackage() *Package {
return &Package{}
@@ -128,7 +133,7 @@ func (p *Package) Clearsign(filename string) error {
passphraseFetcher := promptUser
if p.PassphraseFile != "" {
- passphraseFetcher, err = passphraseFileFetcher(p.PassphraseFile, os.Stdin)
+ passphraseFetcher, err = p.passphraseFileFetcher(p.PassphraseFile, os.Stdin)
return err
}
@@ -156,25 +161,42 @@ func promptUser(name string) ([]byte, error) {
return pw, err
-func passphraseFileFetcher(passphraseFile string, stdin *os.File) (provenance.PassphraseFetcher, error) {
- file, err := openPassphraseFile(passphraseFile, stdin)
- }
- defer file.Close()
+func (p *Package) passphraseFileFetcher(passphraseFile string, stdin *os.File) (provenance.PassphraseFetcher, error) {
+ // When reading from stdin we cache the passphrase here. If we are
+ // packaging multiple charts, we reuse the cached passphrase. This
+ // allows giving the passphrase once on stdin without failing with
+ //
+ // An alternative to this would be to omit file.Close() for stdin
+ // below and require the user to provide the same passphrase once
+ // per chart on stdin, but that does not seem very user-friendly.
+ if p.cachedPassphrase == nil {
+ file, err := openPassphraseFile(passphraseFile, stdin)
+ defer file.Close()
- reader := bufio.NewReader(file)
- passphrase, _, err := reader.ReadLine()
+ passphrase, _, err := reader.ReadLine()
+ p.cachedPassphrase = passphrase
+ return func(_ string) ([]byte, error) {
+ return passphrase, nil
+ }, nil
return func(_ string) ([]byte, error) {
- return passphrase, nil
+ return p.cachedPassphrase, nil
}, nil
func openPassphraseFile(passphraseFile string, stdin *os.File) (*os.File, error) {
- if passphraseFile == "-" {
+ if passphraseFile == passPhraseFileStdin {
stat, err := stdin.Stat()
return nil, err
diff --git a/pkg/action/package_test.go b/pkg/action/package_test.go
index 26eeb1a2ba7..12bea10dd33 100644
--- a/pkg/action/package_test.go
+++ b/pkg/action/package_test.go
@@ -29,8 +29,9 @@ import (
func TestPassphraseFileFetcher(t *testing.T) {
directory := ensure.TempFile(t, "passphrase-file", []byte(secret))
@@ -48,8 +49,9 @@ func TestPassphraseFileFetcher(t *testing.T) {
func TestPassphraseFileFetcher_WithLineBreak(t *testing.T) {
directory := ensure.TempFile(t, "passphrase-file", []byte(secret+"\n\n."))
@@ -66,17 +68,48 @@ func TestPassphraseFileFetcher_WithLineBreak(t *testing.T) {
func TestPassphraseFileFetcher_WithInvalidStdin(t *testing.T) {
directory := t.TempDir()
stdin, err := os.CreateTemp(directory, "non-existing")
t.Fatal("Unable to create test file", err)
- if _, err := passphraseFileFetcher("-", stdin); err == nil {
+ if _, err := testPkg.passphraseFileFetcher("-", stdin); err == nil {
t.Error("Expected passphraseFileFetcher returning an error")
+ stdin, w, err := os.Pipe()
+ if err != nil {
+ t.Fatal("Unable to create pipe", err)
+ passphrase := "secret-from-stdin"
+ go func() {
+ w.Write([]byte(passphrase + "\n"))
+ }()
+ for i := 0; i < 4; i++ {
+ fetcher, err := testPkg.passphraseFileFetcher("-", stdin)
+ t.Errorf("Expected passphraseFileFetcher to not return an error, but got %v", err)
+ pass, err := fetcher("key")
+ t.Errorf("Expected passphraseFileFetcher invocation to succeed, failed with %v", err)
+ if string(pass) != string(passphrase) {
+ t.Errorf("Expected multiple passphrase fetch to return %q, got %q", passphrase, pass)
+}
func TestValidateVersion(t *testing.T) {
type args struct {
ver string | [
"+\t// complaints about stdin already being closed.",
"+\t\treader := bufio.NewReader(file)",
"+func TestPassphraseFileFetcher_WithStdinAndMultipleFetches(t *testing.T) {"
] | [
46,
63,
130
] | {
"additions": 71,
"author": "klihub",
"deletions": 16,
"html_url": "https://github.com/helm/helm/pull/30718",
"issue_id": 30718,
"merged_at": "2025-04-16T20:07:44Z",
"omission_probability": 0.1,
"pr_number": 30718,
"repo": "helm/helm",
"title": "Allow signing multiple charts with a single passphrase from stdin.",
"total_changes": 87
} |
594 | diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go
index 061d90e338b..e97cdadd5af 100644
--- a/pkg/lint/rules/chartfile_test.go
+++ b/pkg/lint/rules/chartfile_test.go
@@ -166,10 +166,30 @@ func TestValidateChartSources(t *testing.T) {
}
func TestValidateChartIconPresence(t *testing.T) {
- err := validateChartIconPresence(badChart)
- if err == nil {
- t.Errorf("validateChartIconPresence to return a linter error, got no error")
- }
+ t.Run("Icon absent", func(t *testing.T) {
+ testChart := &chart.Metadata{
+ Icon: "",
+ }
+
+ err := validateChartIconPresence(testChart)
+
+ if err == nil {
+ t.Errorf("validateChartIconPresence to return a linter error, got no error")
+ } else if !strings.Contains(err.Error(), "icon is recommended") {
+ t.Errorf("expected %q, got %q", "icon is recommended", err.Error())
+ }
+ })
+ t.Run("Icon present", func(t *testing.T) {
+ testChart := &chart.Metadata{
+ Icon: "http://example.org/icon.png",
+ }
+
+ err := validateChartIconPresence(testChart)
+
+ if err != nil {
+ t.Errorf("Unexpected error: %q", err.Error())
+ }
+ })
}
func TestValidateChartIconURL(t *testing.T) {
| diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go
index 061d90e338b..e97cdadd5af 100644
--- a/pkg/lint/rules/chartfile_test.go
+++ b/pkg/lint/rules/chartfile_test.go
@@ -166,10 +166,30 @@ func TestValidateChartSources(t *testing.T) {
func TestValidateChartIconPresence(t *testing.T) {
- err := validateChartIconPresence(badChart)
- if err == nil {
- t.Errorf("validateChartIconPresence to return a linter error, got no error")
- }
+ Icon: "",
+ if err == nil {
+ t.Errorf("validateChartIconPresence to return a linter error, got no error")
+ } else if !strings.Contains(err.Error(), "icon is recommended") {
+ t.Errorf("expected %q, got %q", "icon is recommended", err.Error())
+ t.Run("Icon present", func(t *testing.T) {
+ Icon: "http://example.org/icon.png",
+ if err != nil {
+ t.Errorf("Unexpected error: %q", err.Error())
func TestValidateChartIconURL(t *testing.T) { | [
"+\tt.Run(\"Icon absent\", func(t *testing.T) {"
] | [
12
] | {
"additions": 24,
"author": "rpolishchuk",
"deletions": 4,
"html_url": "https://github.com/helm/helm/pull/30783",
"issue_id": 30783,
"merged_at": "2025-04-23T19:58:14Z",
"omission_probability": 0.1,
"pr_number": 30783,
"repo": "helm/helm",
"title": "fix: chart icon presence test",
"total_changes": 28
} |
595 | diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go
index 2667dc2b1a9..3b9f2bfeac6 100644
--- a/pkg/repo/chartrepo.go
+++ b/pkg/repo/chartrepo.go
@@ -219,7 +219,10 @@ func FindChartInRepoURL(repoURL string, chartName string, getters getter.Provide
}
cv, err := repoIndex.Get(chartName, opts.ChartVersion)
if err != nil {
- return "", errors.Errorf("%s not found in %s repository", errMsg, repoURL)
+ return "", ChartNotFoundError{
+ Chart: errMsg,
+ RepoURL: repoURL,
+ }
}
if len(cv.URLs) == 0 {
diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go
index 41bac98279b..c29c95a7e58 100644
--- a/pkg/repo/chartrepo_test.go
+++ b/pkg/repo/chartrepo_test.go
@@ -18,6 +18,7 @@ package repo
import (
"bytes"
+ "errors"
"net/http"
"net/http/httptest"
"os"
@@ -202,6 +203,9 @@ func TestErrorFindChartInRepoURL(t *testing.T) {
} else if err.Error() != `chart "nginx1" not found in `+srv.URL+` repository` {
t.Errorf("Expected error for chart not found, but got a different error (%v)", err)
}
+ if !errors.Is(err, ChartNotFoundError{}) {
+ t.Errorf("error is not of correct error type structure")
+ }
if _, err = FindChartInRepoURL(srv.URL, "nginx1", g, WithChartVersion("0.1.0")); err == nil {
t.Errorf("Expected error for chart not found, but did not get any errors")
diff --git a/pkg/repo/error.go b/pkg/repo/error.go
new file mode 100644
index 00000000000..16264ed2603
--- /dev/null
+++ b/pkg/repo/error.go
@@ -0,0 +1,35 @@
+/*
+Copyright The Helm Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package repo
+
+import (
+ "fmt"
+)
+
+type ChartNotFoundError struct {
+ RepoURL string
+ Chart string
+}
+
+func (e ChartNotFoundError) Error() string {
+ return fmt.Sprintf("%s not found in %s repository", e.Chart, e.RepoURL)
+}
+
+func (e ChartNotFoundError) Is(err error) bool {
+ _, ok := err.(ChartNotFoundError)
+ return ok
+}
| diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go
index 2667dc2b1a9..3b9f2bfeac6 100644
--- a/pkg/repo/chartrepo.go
+++ b/pkg/repo/chartrepo.go
@@ -219,7 +219,10 @@ func FindChartInRepoURL(repoURL string, chartName string, getters getter.Provide
cv, err := repoIndex.Get(chartName, opts.ChartVersion)
if err != nil {
- return "", errors.Errorf("%s not found in %s repository", errMsg, repoURL)
+ return "", ChartNotFoundError{
+ Chart: errMsg,
+ RepoURL: repoURL,
if len(cv.URLs) == 0 {
diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go
index 41bac98279b..c29c95a7e58 100644
--- a/pkg/repo/chartrepo_test.go
+++ b/pkg/repo/chartrepo_test.go
@@ -18,6 +18,7 @@ package repo
import (
"bytes"
+ "errors"
"net/http"
"net/http/httptest"
"os"
@@ -202,6 +203,9 @@ func TestErrorFindChartInRepoURL(t *testing.T) {
} else if err.Error() != `chart "nginx1" not found in `+srv.URL+` repository` {
t.Errorf("Expected error for chart not found, but got a different error (%v)", err)
+ if !errors.Is(err, ChartNotFoundError{}) {
+ t.Errorf("error is not of correct error type structure")
+ }
if _, err = FindChartInRepoURL(srv.URL, "nginx1", g, WithChartVersion("0.1.0")); err == nil {
t.Errorf("Expected error for chart not found, but did not get any errors")
diff --git a/pkg/repo/error.go b/pkg/repo/error.go
new file mode 100644
index 00000000000..16264ed2603
--- /dev/null
+++ b/pkg/repo/error.go
@@ -0,0 +1,35 @@
+/*
+Copyright The Helm Authors.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+package repo
+import (
+)
+type ChartNotFoundError struct {
+ RepoURL string
+ Chart string
+ _, ok := err.(ChartNotFoundError)
+ return ok | [
"+\t\t}",
"+*/",
"+\t\"fmt\"",
"+func (e ChartNotFoundError) Error() string {",
"+\treturn fmt.Sprintf(\"%s not found in %s repository\", e.Chart, e.RepoURL)",
"+func (e ChartNotFoundError) Is(err error) bool {"
] | [
12,
58,
63,
71,
72,
75
] | {
"additions": 43,
"author": "stephenpmurray",
"deletions": 1,
"html_url": "https://github.com/helm/helm/pull/30788",
"issue_id": 30788,
"merged_at": "2025-04-23T14:48:39Z",
"omission_probability": 0.1,
"pr_number": 30788,
"repo": "helm/helm",
"title": "ref(helm): Export Chart Not Found error",
"total_changes": 44
} |
596 | diff --git a/.golangci.yml b/.golangci.yml
index f0d45e5eae6..a34e5f53868 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -4,6 +4,7 @@ run:
linters:
default: none
enable:
+ - depguard
- dupl
- govet
- ineffassign
@@ -13,6 +14,12 @@ linters:
- staticcheck
- unused
settings:
+ depguard:
+ rules:
+ Main:
+ deny:
+ - pkg: github.com/hashicorp/go-multierror
+ desc: "use errors instead"
dupl:
threshold: 400
exclusions:
diff --git a/go.mod b/go.mod
index 912d382bced..0a99cf330d1 100644
--- a/go.mod
+++ b/go.mod
@@ -19,7 +19,6 @@ require (
github.com/gobwas/glob v0.2.3
github.com/gofrs/flock v0.12.1
github.com/gosuri/uitable v0.0.4
- github.com/hashicorp/go-multierror v1.1.1
github.com/jmoiron/sqlx v1.4.0
github.com/lib/pq v1.10.9
github.com/mattn/go-shellwords v1.0.12
@@ -95,7 +94,6 @@ require (
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
- github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
diff --git a/go.sum b/go.sum
index ea10b6adc19..60866b9a99c 100644
--- a/go.sum
+++ b/go.sum
@@ -162,11 +162,6 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJr
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0=
-github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
-github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
-github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go
index f384193e6a0..bdd17b1520a 100644
--- a/pkg/kube/wait.go
+++ b/pkg/kube/wait.go
@@ -18,12 +18,12 @@ package kube // import "helm.sh/helm/v4/pkg/kube"
import (
"context"
+ stderrors "errors"
"fmt"
"log/slog"
"net/http"
"time"
- multierror "github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
appsv1beta1 "k8s.io/api/apps/v1beta1"
@@ -233,7 +233,7 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
for range infos {
err := <-errs
if err != nil {
- result = multierror.Append(result, err)
+ result = stderrors.Join(result, err)
}
}
| diff --git a/.golangci.yml b/.golangci.yml
index f0d45e5eae6..a34e5f53868 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -4,6 +4,7 @@ run:
linters:
default: none
enable:
+ - depguard
- dupl
- govet
- ineffassign
@@ -13,6 +14,12 @@ linters:
- staticcheck
- unused
settings:
+ depguard:
+ rules:
+ Main:
+ deny:
+ - pkg: github.com/hashicorp/go-multierror
dupl:
threshold: 400
exclusions:
diff --git a/go.mod b/go.mod
index 912d382bced..0a99cf330d1 100644
--- a/go.mod
+++ b/go.mod
@@ -19,7 +19,6 @@ require (
github.com/gobwas/glob v0.2.3
github.com/gofrs/flock v0.12.1
github.com/gosuri/uitable v0.0.4
github.com/jmoiron/sqlx v1.4.0
github.com/lib/pq v1.10.9
github.com/mattn/go-shellwords v1.0.12
@@ -95,7 +94,6 @@ require (
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
- github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
diff --git a/go.sum b/go.sum
index ea10b6adc19..60866b9a99c 100644
--- a/go.sum
+++ b/go.sum
@@ -162,11 +162,6 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJr
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 h1:ad0vkEBuk23VJzZR9nkLVG0YAoN9coASF1GusYX6AlU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0/go.mod h1:igFoXX2ELCW06bol23DWPB5BEWfZISOzSP5K2sbLea0=
-github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
-github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
-github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw=
github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU=
github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4=
diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go
index f384193e6a0..bdd17b1520a 100644
--- a/pkg/kube/wait.go
+++ b/pkg/kube/wait.go
@@ -18,12 +18,12 @@ package kube // import "helm.sh/helm/v4/pkg/kube"
import (
"context"
+ stderrors "errors"
"fmt"
"log/slog"
"net/http"
"time"
- multierror "github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
appsv1beta1 "k8s.io/api/apps/v1beta1"
@@ -233,7 +233,7 @@ func perform(infos ResourceList, fn func(*resource.Info) error) error {
for range infos {
err := <-errs
if err != nil {
- result = multierror.Append(result, err)
+ result = stderrors.Join(result, err)
}
} | [
"+ desc: \"use errors instead\"",
"-\tgithub.com/hashicorp/go-multierror v1.1.1",
"-github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I="
] | [
21,
33,
54
] | {
"additions": 9,
"author": "mmorel-35",
"deletions": 9,
"html_url": "https://github.com/helm/helm/pull/30781",
"issue_id": 30781,
"merged_at": "2025-04-22T16:45:31Z",
"omission_probability": 0.1,
"pr_number": 30781,
"repo": "helm/helm",
"title": "chore: remove `github.com/hashicorp/go-multierror` dependency",
"total_changes": 18
} |
597 | diff --git a/.github/env b/.github/env
new file mode 100644
index 00000000000..da621263579
--- /dev/null
+++ b/.github/env
@@ -0,0 +1,2 @@
+GOLANG_VERSION=1.24
+GOLANGCI_LINT_VERSION=v1.64
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index e59d186f0d5..1b4ab8c9cf9 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -19,10 +19,12 @@ jobs:
steps:
- name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # [email protected]
+ - name: Add variables to environment file
+ run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
with:
- go-version: '1.23'
+ go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
- name: Test source headers are present
run: make test-source-headers
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index c1c8aeb2295..c8e8520ab8e 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -15,12 +15,16 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # [email protected]
+ - name: Add variables to environment file
+ run: cat ".github/env" >> "$GITHUB_ENV"
+
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
with:
- go-version: '1.23'
+ go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
+
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #[email protected]
with:
- version: v1.62
+ version: ${{ env.GOLANGCI_LINT_VERSION }}
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index 2dda4c06eb1..aceff5cbbd9 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -13,10 +13,12 @@ jobs:
name: govulncheck
runs-on: ubuntu-latest
steps:
+ - name: Add variables to environment file
+ run: cat ".github/env" >> "$GITHUB_ENV"
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
with:
- go-version: '1.23'
+ go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
- name: govulncheck
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # [email protected]
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 011e3818754..46e898cba73 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -24,10 +24,13 @@ jobs:
with:
fetch-depth: 0
+ - name: Add variables to environment file
+ run: cat ".github/env" >> "$GITHUB_ENV"
+
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
with:
- go-version: '1.23'
+ go-version: '${{ env.GOLANG_VERSION }}'
- name: Run unit tests
run: make test-coverage
@@ -80,10 +83,13 @@ jobs:
- name: Checkout source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # [email protected]
+ - name: Add variables to environment file
+ run: cat ".github/env" >> "$GITHUB_ENV"
+
- name: Setup Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # [email protected]
with:
- go-version: '1.23'
+ go-version: '${{ env.GOLANG_VERSION }}'
check-latest: true
- name: Run unit tests
diff --git a/go.mod b/go.mod
index cdb722976e0..d2bdb7148de 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module helm.sh/helm/v3
-go 1.23.7
+go 1.24
require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
| diff --git a/.github/env b/.github/env
new file mode 100644
index 00000000000..da621263579
--- /dev/null
+++ b/.github/env
@@ -0,0 +1,2 @@
+GOLANG_VERSION=1.24
+GOLANGCI_LINT_VERSION=v1.64
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index e59d186f0d5..1b4ab8c9cf9 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -19,10 +19,12 @@ jobs:
- name: Test source headers are present
run: make test-source-headers
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index c1c8aeb2295..c8e8520ab8e 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -15,12 +15,16 @@ jobs:
- name: Checkout
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 #[email protected]
+ version: ${{ env.GOLANGCI_LINT_VERSION }}
diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml
index 2dda4c06eb1..aceff5cbbd9 100644
--- a/.github/workflows/govulncheck.yml
+++ b/.github/workflows/govulncheck.yml
@@ -13,10 +13,12 @@ jobs:
name: govulncheck
runs-on: ubuntu-latest
- name: govulncheck
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # [email protected]
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 011e3818754..46e898cba73 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -24,10 +24,13 @@ jobs:
fetch-depth: 0
run: make test-coverage
@@ -80,10 +83,13 @@ jobs:
diff --git a/go.mod b/go.mod
index cdb722976e0..d2bdb7148de 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module helm.sh/helm/v3
-go 1.23.7
+go 1.24
require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 | [
"- version: v1.62"
] | [
47
] | {
"additions": 23,
"author": "dongjiang1989",
"deletions": 7,
"html_url": "https://github.com/helm/helm/pull/30771",
"issue_id": 30771,
"merged_at": "2025-04-18T19:11:57Z",
"omission_probability": 0.1,
"pr_number": 30771,
"repo": "helm/helm",
"title": "[v3 backport] chore: Update Golang to v1.24",
"total_changes": 30
} |
598 | diff --git a/Makefile b/Makefile
index 21144cf5ae6..0785fdb2eb3 100644
--- a/Makefile
+++ b/Makefile
@@ -156,7 +156,7 @@ format: $(GOIMPORTS)
# Generate golden files used in unit tests
.PHONY: gen-test-golden
gen-test-golden:
-gen-test-golden: PKG = ./cmd/helm ./pkg/action
+gen-test-golden: PKG = ./pkg/cmd ./pkg/action
gen-test-golden: TESTFLAGS = -update
gen-test-golden: test-unit
diff --git a/go.mod b/go.mod
index ad119b6b8d7..36455fdbae0 100644
--- a/go.mod
+++ b/go.mod
@@ -33,7 +33,6 @@ require (
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
github.com/stretchr/testify v1.10.0
- github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.37.0
golang.org/x/term v0.31.0
golang.org/x/text v0.24.0
@@ -136,8 +135,6 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
- github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
- github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 // indirect
diff --git a/go.sum b/go.sum
index 4fcd483a489..2cf58474523 100644
--- a/go.sum
+++ b/go.sum
@@ -326,13 +326,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
-github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
-github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
-github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
-github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
-github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
-github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
-github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
diff --git a/pkg/chart/v2/util/jsonschema.go b/pkg/chart/v2/util/jsonschema.go
index 66ab42542c4..a8baef0f695 100644
--- a/pkg/chart/v2/util/jsonschema.go
+++ b/pkg/chart/v2/util/jsonschema.go
@@ -18,14 +18,11 @@ package util
import (
"bytes"
- "encoding/json"
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/santhosh-tekuri/jsonschema/v6"
- "github.com/xeipuuv/gojsonschema"
- "sigs.k8s.io/yaml"
chart "helm.sh/helm/v4/pkg/chart/v2"
)
@@ -64,69 +61,50 @@ func ValidateAgainstSingleSchema(values Values, schemaJSON []byte) (reterr error
}
}()
- valuesData, err := yaml.Marshal(values)
+ // This unmarshal function leverages UseNumber() for number precision. The parser
+ // used for values does this as well.
+ schema, err := jsonschema.UnmarshalJSON(bytes.NewReader(schemaJSON))
if err != nil {
return err
}
- valuesJSON, err := yaml.YAMLToJSON(valuesData)
+
+ compiler := jsonschema.NewCompiler()
+ err = compiler.AddResource("file:///values.schema.json", schema)
if err != nil {
return err
}
- if bytes.Equal(valuesJSON, []byte("null")) {
- valuesJSON = []byte("{}")
- }
-
- if schemaIs2020(schemaJSON) {
- return validateUsingNewValidator(valuesJSON, schemaJSON)
- }
-
- schemaLoader := gojsonschema.NewBytesLoader(schemaJSON)
- valuesLoader := gojsonschema.NewBytesLoader(valuesJSON)
- result, err := gojsonschema.Validate(schemaLoader, valuesLoader)
+ validator, err := compiler.Compile("file:///values.schema.json")
if err != nil {
return err
}
- if !result.Valid() {
- var sb strings.Builder
- for _, desc := range result.Errors() {
- sb.WriteString(fmt.Sprintf("- %s\n", desc))
- }
- return errors.New(sb.String())
+ err = validator.Validate(values.AsMap())
+ if err != nil {
+ return JSONSchemaValidationError{err}
}
return nil
}
-func validateUsingNewValidator(valuesJSON, schemaJSON []byte) error {
- schema, err := jsonschema.UnmarshalJSON(bytes.NewReader(schemaJSON))
- if err != nil {
- return err
- }
- values, err := jsonschema.UnmarshalJSON(bytes.NewReader(valuesJSON))
- if err != nil {
- return err
- }
+// Note, JSONSchemaValidationError is used to wrap the error from the underlying
+// validation package so that Helm has a clean interface and the validation package
+// could be replaced without changing the Helm SDK API.
- compiler := jsonschema.NewCompiler()
- err = compiler.AddResource("file:///values.schema.json", schema)
- if err != nil {
- return err
- }
+// JSONSchemaValidationError is the error returned when there is a schema validation
+// error.
+type JSONSchemaValidationError struct {
+ embeddedErr error
+}
- validator, err := compiler.Compile("file:///values.schema.json")
- if err != nil {
- return err
- }
+// Error prints the error message
+func (e JSONSchemaValidationError) Error() string {
+ errStr := e.embeddedErr.Error()
- return validator.Validate(values)
-}
+ // This string prefixes all of our error details. Further up the stack of helm error message
+ // building more detail is provided to users. This is removed.
+ errStr = strings.TrimPrefix(errStr, "jsonschema validation failed with 'file:///values.schema.json#'\n")
-func schemaIs2020(schemaJSON []byte) bool {
- var partialSchema struct {
- Schema string `json:"$schema"`
- }
- _ = json.Unmarshal(schemaJSON, &partialSchema)
- return partialSchema.Schema == "https://json-schema.org/draft/2020-12/schema"
+ // The extra new line is needed for when there are sub-charts.
+ return errStr + "\n"
}
diff --git a/pkg/chart/v2/util/jsonschema_test.go b/pkg/chart/v2/util/jsonschema_test.go
index 6337ab25936..d781aa4be9a 100644
--- a/pkg/chart/v2/util/jsonschema_test.go
+++ b/pkg/chart/v2/util/jsonschema_test.go
@@ -69,7 +69,7 @@ func TestValidateAgainstSingleSchemaNegative(t *testing.T) {
}
schema, err := os.ReadFile("./testdata/test-values.schema.json")
if err != nil {
- t.Fatalf("Error reading YAML file: %s", err)
+ t.Fatalf("Error reading JSON file: %s", err)
}
var errString string
@@ -79,8 +79,8 @@ func TestValidateAgainstSingleSchemaNegative(t *testing.T) {
errString = err.Error()
}
- expectedErrString := `- (root): employmentInfo is required
-- age: Must be greater than or equal to 0
+ expectedErrString := `- at '': missing property 'employmentInfo'
+- at '/age': minimum: got -5, want 0
`
if errString != expectedErrString {
t.Errorf("Error string :\n`%s`\ndoes not match expected\n`%s`", errString, expectedErrString)
@@ -174,7 +174,7 @@ func TestValidateAgainstSchemaNegative(t *testing.T) {
}
expectedErrString := `subchart:
-- (root): age is required
+- at '': missing property 'age'
`
if errString != expectedErrString {
t.Errorf("Error string :\n`%s`\ndoes not match expected\n`%s`", errString, expectedErrString)
@@ -238,9 +238,9 @@ func TestValidateAgainstSchema2020Negative(t *testing.T) {
}
expectedErrString := `subchart:
-jsonschema validation failed with 'file:///values.schema.json#'
- at '/data': no items match contains schema
- - at '/data/0': got number, want string`
+ - at '/data/0': got number, want string
+`
if errString != expectedErrString {
t.Errorf("Error string :\n`%s`\ndoes not match expected\n`%s`", errString, expectedErrString)
}
diff --git a/pkg/cmd/testdata/output/schema-negative-cli.txt b/pkg/cmd/testdata/output/schema-negative-cli.txt
index c4a5cc51673..12bcc51032e 100644
--- a/pkg/cmd/testdata/output/schema-negative-cli.txt
+++ b/pkg/cmd/testdata/output/schema-negative-cli.txt
@@ -1,4 +1,4 @@
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
empty:
-- age: Must be greater than or equal to 0
+- at '/age': minimum: got -5, want 0
diff --git a/pkg/cmd/testdata/output/schema-negative.txt b/pkg/cmd/testdata/output/schema-negative.txt
index 929af5518e1..daf132635e5 100644
--- a/pkg/cmd/testdata/output/schema-negative.txt
+++ b/pkg/cmd/testdata/output/schema-negative.txt
@@ -1,5 +1,5 @@
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
empty:
-- (root): employmentInfo is required
-- age: Must be greater than or equal to 0
+- at '': missing property 'employmentInfo'
+- at '/age': minimum: got -5, want 0
diff --git a/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt b/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
index 7396b4bfe4d..179550f69e6 100644
--- a/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
+++ b/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
@@ -1,4 +1,4 @@
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
subchart-with-schema:
-- age: Must be greater than or equal to 0
+- at '/age': minimum: got -25, want 0
diff --git a/pkg/cmd/testdata/output/subchart-schema-negative.txt b/pkg/cmd/testdata/output/subchart-schema-negative.txt
index 7b1f654a2c9..7522ef3e45f 100644
--- a/pkg/cmd/testdata/output/subchart-schema-negative.txt
+++ b/pkg/cmd/testdata/output/subchart-schema-negative.txt
@@ -1,6 +1,6 @@
Error: INSTALLATION FAILED: values don't meet the specifications of the schema(s) in the following chart(s):
chart-without-schema:
-- (root): lastname is required
+- at '': missing property 'lastname'
subchart-with-schema:
-- (root): age is required
+- at '': missing property 'age'
diff --git a/pkg/lint/rules/values_test.go b/pkg/lint/rules/values_test.go
index 8a2556a6019..3486957856b 100644
--- a/pkg/lint/rules/values_test.go
+++ b/pkg/lint/rules/values_test.go
@@ -96,7 +96,7 @@ func TestValidateValuesFileSchemaFailure(t *testing.T) {
t.Fatal("expected values file to fail parsing")
}
- assert.Contains(t, err.Error(), "Expected: string, given: integer", "integer should be caught by schema")
+ assert.Contains(t, err.Error(), "- at '/username': got number, want string")
}
func TestValidateValuesFileSchemaOverrides(t *testing.T) {
@@ -129,7 +129,7 @@ func TestValidateValuesFile(t *testing.T) {
name: "value not overridden",
yaml: "username: admin\npassword:",
overrides: map[string]interface{}{"username": "anotherUser"},
- errorMessage: "Expected: string, given: null",
+ errorMessage: "- at '/password': got null, want string",
},
{
name: "value overridden",
| diff --git a/Makefile b/Makefile
index 21144cf5ae6..0785fdb2eb3 100644
--- a/Makefile
+++ b/Makefile
@@ -156,7 +156,7 @@ format: $(GOIMPORTS)
# Generate golden files used in unit tests
.PHONY: gen-test-golden
gen-test-golden:
-gen-test-golden: PKG = ./cmd/helm ./pkg/action
+gen-test-golden: PKG = ./pkg/cmd ./pkg/action
gen-test-golden: TESTFLAGS = -update
gen-test-golden: test-unit
diff --git a/go.mod b/go.mod
index ad119b6b8d7..36455fdbae0 100644
--- a/go.mod
+++ b/go.mod
@@ -33,7 +33,6 @@ require (
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
github.com/stretchr/testify v1.10.0
- github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/crypto v0.37.0
golang.org/x/term v0.31.0
golang.org/x/text v0.24.0
@@ -136,8 +135,6 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
- github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
- github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 // indirect
diff --git a/go.sum b/go.sum
index 4fcd483a489..2cf58474523 100644
--- a/go.sum
+++ b/go.sum
@@ -326,13 +326,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
-github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
-github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
-github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
-github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
-github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
-github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
-github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
diff --git a/pkg/chart/v2/util/jsonschema.go b/pkg/chart/v2/util/jsonschema.go
index 66ab42542c4..a8baef0f695 100644
--- a/pkg/chart/v2/util/jsonschema.go
+++ b/pkg/chart/v2/util/jsonschema.go
@@ -18,14 +18,11 @@ package util
import (
"bytes"
- "encoding/json"
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/santhosh-tekuri/jsonschema/v6"
- "github.com/xeipuuv/gojsonschema"
- "sigs.k8s.io/yaml"
chart "helm.sh/helm/v4/pkg/chart/v2"
)
@@ -64,69 +61,50 @@ func ValidateAgainstSingleSchema(values Values, schemaJSON []byte) (reterr error
}
}()
+ // used for values does this as well.
+ schema, err := jsonschema.UnmarshalJSON(bytes.NewReader(schemaJSON))
- valuesJSON, err := yaml.YAMLToJSON(valuesData)
+
+ compiler := jsonschema.NewCompiler()
+ err = compiler.AddResource("file:///values.schema.json", schema)
- valuesJSON = []byte("{}")
- if schemaIs2020(schemaJSON) {
- return validateUsingNewValidator(valuesJSON, schemaJSON)
- schemaLoader := gojsonschema.NewBytesLoader(schemaJSON)
- valuesLoader := gojsonschema.NewBytesLoader(valuesJSON)
- result, err := gojsonschema.Validate(schemaLoader, valuesLoader)
+ validator, err := compiler.Compile("file:///values.schema.json")
- if !result.Valid() {
- for _, desc := range result.Errors() {
- }
- return errors.New(sb.String())
+ err = validator.Validate(values.AsMap())
+ if err != nil {
+ return JSONSchemaValidationError{err}
return nil
-func validateUsingNewValidator(valuesJSON, schemaJSON []byte) error {
- schema, err := jsonschema.UnmarshalJSON(bytes.NewReader(schemaJSON))
- values, err := jsonschema.UnmarshalJSON(bytes.NewReader(valuesJSON))
+// Note, JSONSchemaValidationError is used to wrap the error from the underlying
+// validation package so that Helm has a clean interface and the validation package
- compiler := jsonschema.NewCompiler()
- err = compiler.AddResource("file:///values.schema.json", schema)
+// JSONSchemaValidationError is the error returned when there is a schema validation
+// error.
+type JSONSchemaValidationError struct {
+ embeddedErr error
+}
- validator, err := compiler.Compile("file:///values.schema.json")
+// Error prints the error message
+func (e JSONSchemaValidationError) Error() string {
+ errStr := e.embeddedErr.Error()
- return validator.Validate(values)
-}
+ // This string prefixes all of our error details. Further up the stack of helm error message
+ // building more detail is provided to users. This is removed.
+ errStr = strings.TrimPrefix(errStr, "jsonschema validation failed with 'file:///values.schema.json#'\n")
-func schemaIs2020(schemaJSON []byte) bool {
- var partialSchema struct {
- Schema string `json:"$schema"`
- _ = json.Unmarshal(schemaJSON, &partialSchema)
- return partialSchema.Schema == "https://json-schema.org/draft/2020-12/schema"
+ // The extra new line is needed for when there are sub-charts.
+ return errStr + "\n"
diff --git a/pkg/chart/v2/util/jsonschema_test.go b/pkg/chart/v2/util/jsonschema_test.go
index 6337ab25936..d781aa4be9a 100644
--- a/pkg/chart/v2/util/jsonschema_test.go
+++ b/pkg/chart/v2/util/jsonschema_test.go
@@ -69,7 +69,7 @@ func TestValidateAgainstSingleSchemaNegative(t *testing.T) {
schema, err := os.ReadFile("./testdata/test-values.schema.json")
- t.Fatalf("Error reading YAML file: %s", err)
var errString string
@@ -79,8 +79,8 @@ func TestValidateAgainstSingleSchemaNegative(t *testing.T) {
errString = err.Error()
- expectedErrString := `- (root): employmentInfo is required
@@ -174,7 +174,7 @@ func TestValidateAgainstSchemaNegative(t *testing.T) {
@@ -238,9 +238,9 @@ func TestValidateAgainstSchema2020Negative(t *testing.T) {
-jsonschema validation failed with 'file:///values.schema.json#'
- at '/data': no items match contains schema
diff --git a/pkg/cmd/testdata/output/schema-negative-cli.txt b/pkg/cmd/testdata/output/schema-negative-cli.txt
index c4a5cc51673..12bcc51032e 100644
--- a/pkg/cmd/testdata/output/schema-negative-cli.txt
+++ b/pkg/cmd/testdata/output/schema-negative-cli.txt
diff --git a/pkg/cmd/testdata/output/schema-negative.txt b/pkg/cmd/testdata/output/schema-negative.txt
index 929af5518e1..daf132635e5 100644
--- a/pkg/cmd/testdata/output/schema-negative.txt
+++ b/pkg/cmd/testdata/output/schema-negative.txt
@@ -1,5 +1,5 @@
-- (root): employmentInfo is required
+- at '': missing property 'employmentInfo'
diff --git a/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt b/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
index 7396b4bfe4d..179550f69e6 100644
--- a/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
+++ b/pkg/cmd/testdata/output/subchart-schema-cli-negative.txt
+- at '/age': minimum: got -25, want 0
diff --git a/pkg/cmd/testdata/output/subchart-schema-negative.txt b/pkg/cmd/testdata/output/subchart-schema-negative.txt
index 7b1f654a2c9..7522ef3e45f 100644
--- a/pkg/cmd/testdata/output/subchart-schema-negative.txt
+++ b/pkg/cmd/testdata/output/subchart-schema-negative.txt
@@ -1,6 +1,6 @@
chart-without-schema:
+- at '': missing property 'lastname'
diff --git a/pkg/lint/rules/values_test.go b/pkg/lint/rules/values_test.go
index 8a2556a6019..3486957856b 100644
--- a/pkg/lint/rules/values_test.go
+++ b/pkg/lint/rules/values_test.go
@@ -96,7 +96,7 @@ func TestValidateValuesFileSchemaFailure(t *testing.T) {
t.Fatal("expected values file to fail parsing")
- assert.Contains(t, err.Error(), "Expected: string, given: integer", "integer should be caught by schema")
+ assert.Contains(t, err.Error(), "- at '/username': got number, want string")
func TestValidateValuesFileSchemaOverrides(t *testing.T) {
@@ -129,7 +129,7 @@ func TestValidateValuesFile(t *testing.T) {
name: "value not overridden",
yaml: "username: admin\npassword:",
overrides: map[string]interface{}{"username": "anotherUser"},
- errorMessage: "Expected: string, given: null",
},
{
name: "value overridden", | [
"-\tvaluesData, err := yaml.Marshal(values)",
"+\t// This unmarshal function leverages UseNumber() for number precision. The parser",
"-\tif bytes.Equal(valuesJSON, []byte(\"null\")) {",
"-\t\tvar sb strings.Builder",
"-\t\t\tsb.WriteString(fmt.Sprintf(\"- %s\\n\", desc))",
"+// could be replaced without changing the Helm SDK API.",
"+\t\tt.Fatalf(\"Error reading JSON file: %s\", err)",
"+\texpectedErrString := `- at '': missing property 'employmentInfo'",
"- - at '/data/0': got number, want string`",
"+ - at '/data/0': got number, want string",
"+`",
"-- (root): lastname is required",
"+\t\t\terrorMessage: \"- at '/password': got null, want string\","
] | [
75,
76,
89,
107,
109,
131,
176,
186,
206,
207,
208,
251,
275
] | {
"additions": 41,
"author": "mattfarina",
"deletions": 73,
"html_url": "https://github.com/helm/helm/pull/30754",
"issue_id": 30754,
"merged_at": "2025-04-16T14:18:46Z",
"omission_probability": 0.1,
"pr_number": 30754,
"repo": "helm/helm",
"title": "Simplify the JSON Schema checking",
"total_changes": 114
} |
599 | diff --git a/pkg/action/action.go b/pkg/action/action.go
index 937b42537d2..e91054a2889 100644
--- a/pkg/action/action.go
+++ b/pkg/action/action.go
@@ -25,6 +25,7 @@ import (
"path"
"path/filepath"
"strings"
+ "text/template"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/meta"
@@ -80,6 +81,9 @@ type Configuration struct {
// Capabilities describes the capabilities of the Kubernetes cluster.
Capabilities *chartutil.Capabilities
+ // CustomTemplateFuncs is defined by users to provide custom template funcs
+ CustomTemplateFuncs template.FuncMap
+
// HookOutputFunc called with container name and returns and expects writer that will receive the log output.
HookOutputFunc func(namespace, pod, container string) io.Writer
}
@@ -118,10 +122,14 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu
}
e := engine.New(restConfig)
e.EnableDNS = enableDNS
+ e.CustomTemplateFuncs = cfg.CustomTemplateFuncs
+
files, err2 = e.Render(ch, values)
} else {
var e engine.Engine
e.EnableDNS = enableDNS
+ e.CustomTemplateFuncs = cfg.CustomTemplateFuncs
+
files, err2 = e.Render(ch, values)
}
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index 7235b026a75..0b0933def48 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -44,6 +44,8 @@ type Engine struct {
clientProvider *ClientProvider
// EnableDNS tells the engine to allow DNS lookups when rendering templates
EnableDNS bool
+ // CustomTemplateFuncs is defined by users to provide custom template funcs
+ CustomTemplateFuncs template.FuncMap
}
// New creates a new instance of Engine using the passed in rest config.
@@ -244,6 +246,11 @@ func (e Engine) initFunMap(t *template.Template) {
}
}
+ // Set custom template funcs
+ for k, v := range e.CustomTemplateFuncs {
+ funcMap[k] = v
+ }
+
t.Funcs(funcMap)
}
diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go
index a54e99cada4..68e0158fa9d 100644
--- a/pkg/engine/engine_test.go
+++ b/pkg/engine/engine_test.go
@@ -1300,3 +1300,63 @@ func TestRenderTplMissingKeyString(t *testing.T) {
t.Fatal(err)
}
}
+
+func TestRenderCustomTemplateFuncs(t *testing.T) {
+ // Create a chart with two templates that use custom functions
+ c := &chart.Chart{
+ Metadata: &chart.Metadata{Name: "CustomFunc"},
+ Templates: []*chart.File{
+ {
+ Name: "templates/manifest",
+ Data: []byte(`{{exclaim .Values.message}}`),
+ },
+ {
+ Name: "templates/override",
+ Data: []byte(`{{ upper .Values.message }}`),
+ },
+ },
+ }
+ v := chartutil.Values{
+ "Values": chartutil.Values{
+ "message": "hello",
+ },
+ "Chart": c.Metadata,
+ "Release": chartutil.Values{
+ "Name": "TestRelease",
+ },
+ }
+
+ // Define a custom template function "exclaim" that appends "!!!" to a string and override "upper" function
+ customFuncs := template.FuncMap{
+ "exclaim": func(input string) string {
+ return input + "!!!"
+ },
+ "upper": func(s string) string {
+ return "custom:" + s
+ },
+ }
+
+ // Create an engine instance and set the CustomTemplateFuncs.
+ e := new(Engine)
+ e.CustomTemplateFuncs = customFuncs
+
+ // Render the chart.
+ out, err := e.Render(c, v)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // Expected output should be "hello!!!".
+ expected := "hello!!!"
+ key := "CustomFunc/templates/manifest"
+ if rendered, ok := out[key]; !ok || rendered != expected {
+ t.Errorf("Expected %q, got %q", expected, rendered)
+ }
+
+ // Verify that the rendered template used the custom "upper" function.
+ expected = "custom:hello"
+ key = "CustomFunc/templates/override"
+ if rendered, ok := out[key]; !ok || rendered != expected {
+ t.Errorf("Expected %q, got %q", expected, rendered)
+ }
+}
| diff --git a/pkg/action/action.go b/pkg/action/action.go
index 937b42537d2..e91054a2889 100644
--- a/pkg/action/action.go
+++ b/pkg/action/action.go
@@ -25,6 +25,7 @@ import (
"path"
"path/filepath"
"strings"
+ "text/template"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/meta"
@@ -80,6 +81,9 @@ type Configuration struct {
// Capabilities describes the capabilities of the Kubernetes cluster.
Capabilities *chartutil.Capabilities
// HookOutputFunc called with container name and returns and expects writer that will receive the log output.
HookOutputFunc func(namespace, pod, container string) io.Writer
@@ -118,10 +122,14 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu
e := engine.New(restConfig)
} else {
var e engine.Engine
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index 7235b026a75..0b0933def48 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -44,6 +44,8 @@ type Engine struct {
clientProvider *ClientProvider
// EnableDNS tells the engine to allow DNS lookups when rendering templates
EnableDNS bool
// New creates a new instance of Engine using the passed in rest config.
@@ -244,6 +246,11 @@ func (e Engine) initFunMap(t *template.Template) {
+ // Set custom template funcs
+ for k, v := range e.CustomTemplateFuncs {
+ funcMap[k] = v
t.Funcs(funcMap)
diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.go
index a54e99cada4..68e0158fa9d 100644
--- a/pkg/engine/engine_test.go
+++ b/pkg/engine/engine_test.go
@@ -1300,3 +1300,63 @@ func TestRenderTplMissingKeyString(t *testing.T) {
t.Fatal(err)
+func TestRenderCustomTemplateFuncs(t *testing.T) {
+ // Create a chart with two templates that use custom functions
+ c := &chart.Chart{
+ Metadata: &chart.Metadata{Name: "CustomFunc"},
+ Name: "templates/manifest",
+ Data: []byte(`{{exclaim .Values.message}}`),
+ Name: "templates/override",
+ Data: []byte(`{{ upper .Values.message }}`),
+ v := chartutil.Values{
+ "Values": chartutil.Values{
+ "message": "hello",
+ "Chart": c.Metadata,
+ "Release": chartutil.Values{
+ "Name": "TestRelease",
+ // Define a custom template function "exclaim" that appends "!!!" to a string and override "upper" function
+ customFuncs := template.FuncMap{
+ return input + "!!!"
+ "upper": func(s string) string {
+ return "custom:" + s
+ // Create an engine instance and set the CustomTemplateFuncs.
+ e := new(Engine)
+ e.CustomTemplateFuncs = customFuncs
+ // Render the chart.
+ out, err := e.Render(c, v)
+ if err != nil {
+ t.Fatal(err)
+ // Expected output should be "hello!!!".
+ expected := "hello!!!"
+ key := "CustomFunc/templates/manifest"
+ // Verify that the rendered template used the custom "upper" function.
+ expected = "custom:hello"
+ key = "CustomFunc/templates/override"
+} | [
"+\t\tTemplates: []*chart.File{",
"+\t\t\"exclaim\": func(input string) string {"
] | [
75,
98
] | {
"additions": 75,
"author": "ipaqsa",
"deletions": 0,
"html_url": "https://github.com/helm/helm/pull/30734",
"issue_id": 30734,
"merged_at": "2025-04-21T15:13:13Z",
"omission_probability": 0.1,
"pr_number": 30734,
"repo": "helm/helm",
"title": "feat(pkg/engine): add support for custom template funcs",
"total_changes": 75
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.