Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
LihiSaar authored Jan 16, 2025
2 parents db91f17 + 87276ef commit 7f24247
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 67 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/shared_discord_notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
types: [labeled]

jobs:
notify:
if: ${{ github.event.label.name == 'React Core Team' }}
notify_core:
if: ${{ !contains(github.event.pull_request.title, '[compiler]') && github.event.label.name == 'React Core Team' }}
runs-on: ubuntu-latest
steps:
- name: Discord Webhook Action
Expand All @@ -19,3 +19,17 @@ jobs:
embed-title: '#${{ github.event.number }} (+${{github.event.pull_request.additions}} -${{github.event.pull_request.deletions}}): ${{ github.event.pull_request.title }}'
embed-description: ${{ github.event.pull_request.body }}
embed-url: ${{ github.event.pull_request.html_url }}
notify_compiler:
if: ${{ contains(github.event.pull_request.title, '[compiler]') && github.event.label.name == 'React Core Team' }}
runs-on: ubuntu-latest
steps:
- name: Discord Webhook Action
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.COMPILER_DISCORD_WEBHOOK_URL }}
embed-author-name: ${{ github.event.pull_request.user.login }}
embed-author-url: ${{ github.event.pull_request.user.html_url }}
embed-author-icon-url: ${{ github.event.pull_request.user.avatar_url }}
embed-title: '#${{ github.event.number }} (+${{github.event.pull_request.additions}} -${{github.event.pull_request.deletions}}): ${{ github.event.pull_request.title }}'
embed-description: ${{ github.event.pull_request.body }}
embed-url: ${{ github.event.pull_request.html_url }}
3 changes: 2 additions & 1 deletion packages/react-devtools-extensions/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"permissions": [
"scripting",
"storage",
"tabs"
"tabs",
"clipboardWrite"
],
"host_permissions": [
"<all_urls>"
Expand Down
3 changes: 2 additions & 1 deletion packages/react-devtools-extensions/edge/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"permissions": [
"scripting",
"storage",
"tabs"
"tabs",
"clipboardWrite"
],
"host_permissions": [
"<all_urls>"
Expand Down
3 changes: 2 additions & 1 deletion packages/react-devtools-extensions/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"permissions": [
"scripting",
"storage",
"tabs"
"tabs",
"clipboardWrite"
],
"host_permissions": [
"<all_urls>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import * as React from 'react';
import {useContext, useMemo, useRef, useState} from 'react';
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
import {copy} from 'clipboard-js';
import {
BridgeContext,
Expand Down Expand Up @@ -178,10 +177,8 @@ function Row({
validAttributes === null ||
validAttributes.indexOf(newAttribute) >= 0;

batchedUpdates(() => {
setLocalAttribute(newAttribute);
setIsAttributeValid(isValid);
});
setLocalAttribute(newAttribute);
setIsAttributeValid(isValid);
};

// $FlowFixMe[missing-local-annot]
Expand All @@ -192,10 +189,8 @@ function Row({
isValid = true;
} catch (error) {}

batchedUpdates(() => {
setLocalValue(newValue);
setIsValueValid(isValid);
});
setLocalValue(newValue);
setIsValueValid(isValid);
};

const resetAttribute = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
useMemo,
useState,
} from 'react';
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
import {createResource} from 'react-devtools-shared/src/devtools/cache';
import {
BridgeContext,
Expand Down Expand Up @@ -120,10 +119,8 @@ function NativeStyleContextController({children}: Props): React.Node {
const request = inProgressRequests.get(element);
if (request != null) {
inProgressRequests.delete(element);
batchedUpdates(() => {
request.resolveFn(styleAndLayout);
setCurrentStyleAndLayout(styleAndLayout);
});
request.resolveFn(styleAndLayout);
setCurrentStyleAndLayout(styleAndLayout);
} else {
resource.write(element, styleAndLayout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {ReactContext} from 'shared/ReactTypes';

import * as React from 'react';
import {createContext, useCallback, useContext, useMemo, useState} from 'react';
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
import {useLocalStorage, useSubscription} from '../hooks';
import {
TreeDispatcherContext,
Expand Down Expand Up @@ -166,31 +165,28 @@ function ProfilerContextController({children}: Props): React.Node {
);

if (prevProfilingData !== profilingData) {
batchedUpdates(() => {
setPrevProfilingData(profilingData);

const dataForRoots =
profilingData !== null ? profilingData.dataForRoots : null;
if (dataForRoots != null) {
const firstRootID = dataForRoots.keys().next().value || null;

if (rootID === null || !dataForRoots.has(rootID)) {
let selectedElementRootID = null;
if (inspectedElementID !== null) {
selectedElementRootID =
store.getRootIDForElement(inspectedElementID);
}
if (
selectedElementRootID !== null &&
dataForRoots.has(selectedElementRootID)
) {
setRootIDAndClearFiber(selectedElementRootID);
} else {
setRootIDAndClearFiber(firstRootID);
}
setPrevProfilingData(profilingData);

const dataForRoots =
profilingData !== null ? profilingData.dataForRoots : null;
if (dataForRoots != null) {
const firstRootID = dataForRoots.keys().next().value || null;

if (rootID === null || !dataForRoots.has(rootID)) {
let selectedElementRootID = null;
if (inspectedElementID !== null) {
selectedElementRootID = store.getRootIDForElement(inspectedElementID);
}
if (
selectedElementRootID !== null &&
dataForRoots.has(selectedElementRootID)
) {
setRootIDAndClearFiber(selectedElementRootID);
} else {
setRootIDAndClearFiber(firstRootID);
}
}
});
}
}

const [isCommitFilterEnabled, setIsCommitFilterEnabled] =
Expand Down Expand Up @@ -229,15 +225,13 @@ function ProfilerContextController({children}: Props): React.Node {
);

if (isProfiling) {
batchedUpdates(() => {
if (selectedCommitIndex !== null) {
selectCommitIndex(null);
}
if (selectedFiberID !== null) {
selectFiberID(null);
selectFiberName(null);
}
});
if (selectedCommitIndex !== null) {
selectCommitIndex(null);
}
if (selectedFiberID !== null) {
selectFiberID(null);
selectFiberName(null);
}
}

const value = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import * as React from 'react';
import {Fragment, useContext, useEffect, useState} from 'react';
import {unstable_batchedUpdates as batchedUpdates} from 'react-dom';
import {ModalDialogContext} from './ModalDialog';
import {StoreContext} from './context';
import {UNSUPPORTED_VERSION_URL} from '../constants';
Expand All @@ -26,14 +25,12 @@ export default function UnsupportedVersionDialog(_: {}): null {
useEffect(() => {
if (state === 'dialog-not-shown') {
const showDialog = () => {
batchedUpdates(() => {
setState('show-dialog');
dispatch({
canBeDismissed: true,
id: 'UnsupportedVersionDialog',
type: 'SHOW',
content: <DialogContent />,
});
setState('show-dialog');
dispatch({
canBeDismissed: true,
id: 'UnsupportedVersionDialog',
type: 'SHOW',
content: <DialogContent />,
});
};

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,5 @@ export const enableUpdaterTracking = __PROFILE__;

// Internal only.
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;

export const enableRemoveConsolePatches = true;
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ export const enableFabricCompleteRootInCommitPhase = __VARIANT__;
export const enableSiblingPrerendering = __VARIANT__;
export const enableUseResourceEffectHook = __VARIANT__;
export const enableOwnerStacks = __VARIANT__;
export const enableRemoveConsolePatches = __VARIANT__;
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const {
passChildrenWhenCloningPersistedNodes,
enableSiblingPrerendering,
enableOwnerStacks,
enableRemoveConsolePatches,
} = dynamicFlags;

// The rest of the flags are static for better dead code elimination.
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const enableProfilerTimer = __PROFILE__;
export const enableProfilerCommitHooks = __PROFILE__;
export const enableProfilerNestedUpdatePhase = __PROFILE__;
export const enableUpdaterTracking = __PROFILE__;
export const enableRemoveConsolePatches = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const disableDefaultPropsExceptForClasses = true;

export const enableObjectFiber = false;
export const enableOwnerStacks = false;
export const enableRemoveConsolePatches = true;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const enableHydrationLaneScheduling = true;
export const enableYieldingBeforePassive = false;
export const enableThrottledScheduling = false;
export const enableViewTransition = false;
export const enableRemoveConsolePatches = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const enableYieldingBeforePassive = false;

export const enableThrottledScheduling = false;
export const enableViewTransition = false;
export const enableRemoveConsolePatches = false;

// Flow magic to verify the exports of this file match the original version.
((((null: any): ExportsType): FeatureFlagsType): ExportsType);
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const enableInfiniteRenderLoopDetection = __VARIANT__;
export const enableSiblingPrerendering = __VARIANT__;

export const enableUseResourceEffectHook = __VARIANT__;
export const enableRemoveConsolePatches = __VARIANT__;

// TODO: These flags are hard-coded to the default values used in open source.
// Update the tests so that they pass in either mode, then set these
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const {
syncLaneExpirationMs,
transitionLaneExpirationMs,
enableOwnerStacks,
enableRemoveConsolePatches,
} = dynamicFeatureFlags;

// On WWW, __EXPERIMENTAL__ is used for a new modern build.
Expand Down
21 changes: 19 additions & 2 deletions packages/shared/forks/consoleWithStackDev.rn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
*/

import ReactSharedInternals from 'shared/ReactSharedInternals';
import * as dynamicFlagsUntyped from 'ReactNativeInternalFeatureFlags';
const enableRemoveConsolePatches =
dynamicFlagsUntyped && dynamicFlagsUntyped.enableRemoveConsolePatches;

let suppressWarning = false;
export function setSuppressWarning(newSuppressWarning) {
if (enableRemoveConsolePatches) {
return;
}
if (__DEV__) {
suppressWarning = newSuppressWarning;
}
Expand All @@ -21,22 +27,33 @@ export function setSuppressWarning(newSuppressWarning) {
// they are left as they are instead.

export function warn(format, ...args) {
if (__DEV__) {
if (enableRemoveConsolePatches) {
if (__DEV__) {
console['warn'](format, ...args);
}
} else if (__DEV__) {
if (!suppressWarning) {
printWarning('warn', format, args);
}
}
}

export function error(format, ...args) {
if (__DEV__) {
if (enableRemoveConsolePatches) {
if (__DEV__) {
console['error'](format, ...args);
}
} else if (__DEV__) {
if (!suppressWarning) {
printWarning('error', format, args);
}
}
}

function printWarning(level, format, args) {
if (enableRemoveConsolePatches) {
return;
}
if (__DEV__) {
if (ReactSharedInternals.getCurrentStack) {
const stack = ReactSharedInternals.getCurrentStack();
Expand Down
20 changes: 18 additions & 2 deletions packages/shared/forks/consoleWithStackDev.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,49 @@
* LICENSE file in the root directory of this source tree.
*/

const {enableRemoveConsolePatches} = require('ReactFeatureFlags');

// This refers to a WWW module.
const warningWWW = require('warning');

let suppressWarning = false;
export function setSuppressWarning(newSuppressWarning) {
if (enableRemoveConsolePatches) {
return;
}
if (__DEV__) {
suppressWarning = newSuppressWarning;
}
}

export function warn(format, ...args) {
if (__DEV__) {
if (enableRemoveConsolePatches) {
if (__DEV__) {
console['warn'](format, ...args);
}
} else if (__DEV__) {
if (!suppressWarning) {
printWarning('warn', format, args);
}
}
}

export function error(format, ...args) {
if (__DEV__) {
if (enableRemoveConsolePatches) {
if (__DEV__) {
console['error'](format, ...args);
}
} else if (__DEV__) {
if (!suppressWarning) {
printWarning('error', format, args);
}
}
}

function printWarning(level, format, args) {
if (enableRemoveConsolePatches) {
return;
}
if (__DEV__) {
const React = require('react');
const ReactSharedInternals =
Expand Down
Loading

0 comments on commit 7f24247

Please sign in to comment.