GeezerVison is showing github.com — [DOM] Shrink ReactDOMSharedInternals source representation (#28771) · react/react-native@9007fdc
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/client/ReactDOMUpdatePriority.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,15 +25,15 @@ export function setCurrentUpdatePriority( | 25 | 25 | // is much longer. I hope this is consistent enough to rely on across builds | 26 | 26 | IntentionallyUnusedArgument?: empty, | 27 | 27 | ): void { | 28 | | - ReactDOMSharedInternals.up = newPriority; | | 28 | + ReactDOMSharedInternals.p /* currentUpdatePriority */ = newPriority; | 29 | 29 | } | 30 | 30 |
| 31 | 31 | export function getCurrentUpdatePriority(): EventPriority { | 32 | | - return ReactDOMSharedInternals.up; | | 32 | + return ReactDOMSharedInternals.p; /* currentUpdatePriority */ | 33 | 33 | } | 34 | 34 |
| 35 | 35 | export function resolveUpdatePriority(): EventPriority { | 36 | | - const updatePriority = ReactDOMSharedInternals.up; | | 36 | + const updatePriority = ReactDOMSharedInternals.p; /* currentUpdatePriority */ | 37 | 37 | if (updatePriority !== NoEventPriority) { | 38 | 38 | return updatePriority; | 39 | 39 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -104,8 +104,6 @@ import escapeSelectorAttributeValueInsideDoubleQuotes from './escapeSelectorAttr | 104 | 104 | import {flushSyncWork as flushSyncWorkOnAllRoots} from 'react-reconciler/src/ReactFiberWorkLoop'; | 105 | 105 |
| 106 | 106 | import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals'; | 107 | | -const ReactDOMCurrentDispatcher = | 108 | | - ReactDOMSharedInternals.ReactDOMCurrentDispatcher; | 109 | 107 |
| 110 | 108 | export type Type = string; | 111 | 109 | export type Props = { | @@ -1924,8 +1922,9 @@ function getDocumentFromRoot(root: HoistableRoot): Document { | 1924 | 1922 | return root.ownerDocument || root; | 1925 | 1923 | } | 1926 | 1924 |
| 1927 | | -const previousDispatcher = ReactDOMCurrentDispatcher.current; | 1928 | | -ReactDOMCurrentDispatcher.current = { | | 1925 | +const previousDispatcher = | | 1926 | + ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */ | | 1927 | +ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = { | 1929 | 1928 | flushSyncWork: disableLegacyMode | 1930 | 1929 | ? flushSyncWork | 1931 | 1930 | : previousDispatcher.flushSyncWork, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/server/ReactDOMFlightServerHostDispatcher.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,11 +23,10 @@ import { | 23 | 23 | } from 'react-server/src/ReactFlightServer'; | 24 | 24 |
| 25 | 25 | import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals'; | 26 | | -const ReactDOMCurrentDispatcher = | 27 | | - ReactDOMSharedInternals.ReactDOMCurrentDispatcher; | 28 | 26 |
| 29 | | -const previousDispatcher = ReactDOMCurrentDispatcher.current; | 30 | | -ReactDOMCurrentDispatcher.current = { | | 27 | +const previousDispatcher = | | 28 | + ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */ | | 29 | +ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = { | 31 | 30 | flushSyncWork: previousDispatcher.flushSyncWork, | 32 | 31 | prefetchDNS, | 33 | 32 | preconnect, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -83,11 +83,10 @@ import {getValueDescriptorExpectingObjectForWarning} from '../shared/ReactDOMRes | 83 | 83 | import {NotPending} from '../shared/ReactDOMFormActions'; | 84 | 84 |
| 85 | 85 | import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals'; | 86 | | -const ReactDOMCurrentDispatcher = | 87 | | - ReactDOMSharedInternals.ReactDOMCurrentDispatcher; | 88 | 86 |
| 89 | | -const previousDispatcher = ReactDOMCurrentDispatcher.current; | 90 | | -ReactDOMCurrentDispatcher.current = { | | 87 | +const previousDispatcher = | | 88 | + ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */ | | 89 | +ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ = { | 91 | 90 | flushSyncWork: previousDispatcher.flushSyncWork, | 92 | 91 | prefetchDNS, | 93 | 92 | preconnect, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom-bindings/src/shared/ReactFlightClientConfigDOM.js +5-11Lines changed: 5 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | import type {HintCode, HintModel} from '../server/ReactFlightServerConfigDOM'; | 14 | 14 |
| 15 | 15 | import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals'; | 16 | | -const ReactDOMCurrentDispatcher = | 17 | | - ReactDOMSharedInternals.ReactDOMCurrentDispatcher; | 18 | 16 |
| 19 | 17 | import {getCrossOriginString} from './crossOriginStrings'; | 20 | 18 |
| 21 | 19 | export function dispatchHint<Code: HintCode>( | 22 | 20 | code: Code, | 23 | 21 | model: HintModel<Code>, | 24 | 22 | ): void { | 25 | | - const dispatcher = ReactDOMCurrentDispatcher.current; | | 23 | + const dispatcher = ReactDOMSharedInternals.d; /* ReactDOMCurrentDispatcher */ | 26 | 24 | switch (code) { | 27 | 25 | case 'D': { | 28 | 26 | const refined = refineModel(code, model); | @@ -117,25 +115,21 @@ export function preinitModuleForSSR( | 117 | 115 | nonce: ?string, | 118 | 116 | crossOrigin: ?string, | 119 | 117 | ) { | 120 | | - const dispatcher = ReactDOMCurrentDispatcher.current; | 121 | | - if (dispatcher) { | 122 | | - dispatcher.preinitModuleScript(href, { | | 118 | + ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ | | 119 | + .preinitModuleScript(href, { | 123 | 120 | crossOrigin: getCrossOriginString(crossOrigin), | 124 | 121 | nonce, | 125 | 122 | }); | 126 | | - } | 127 | 123 | } | 128 | 124 |
| 129 | 125 | export function preinitScriptForSSR( | 130 | 126 | href: string, | 131 | 127 | nonce: ?string, | 132 | 128 | crossOrigin: ?string, | 133 | 129 | ) { | 134 | | - const dispatcher = ReactDOMCurrentDispatcher.current; | 135 | | - if (dispatcher) { | 136 | | - dispatcher.preinitScript(href, { | | 130 | + ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */ | | 131 | + .preinitScript(href, { | 137 | 132 | crossOrigin: getCrossOriginString(crossOrigin), | 138 | 133 | nonce, | 139 | 134 | }); | 140 | | - } | 141 | 135 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/client.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,13 +27,13 @@ export function createRoot( | 27 | 27 | options?: CreateRootOptions, | 28 | 28 | ): RootType { | 29 | 29 | if (__DEV__) { | 30 | | - Internals.usingClientEntryPoint = true; | | 30 | + (Internals: any).usingClientEntryPoint = true; | 31 | 31 | } | 32 | 32 | try { | 33 | 33 | return createRootImpl(container, options); | 34 | 34 | } finally { | 35 | 35 | if (__DEV__) { | 36 | | - Internals.usingClientEntryPoint = false; | | 36 | + (Internals: any).usingClientEntryPoint = false; | 37 | 37 | } | 38 | 38 | } | 39 | 39 | } | @@ -44,13 +44,13 @@ export function hydrateRoot( | 44 | 44 | options?: HydrateRootOptions, | 45 | 45 | ): RootType { | 46 | 46 | if (__DEV__) { | 47 | | - Internals.usingClientEntryPoint = true; | | 47 | + (Internals: any).usingClientEntryPoint = true; | 48 | 48 | } | 49 | 49 | try { | 50 | 50 | return hydrateRootImpl(container, children, options); | 51 | 51 | } finally { | 52 | 52 | if (__DEV__) { | 53 | | - Internals.usingClientEntryPoint = false; | | 53 | + (Internals: any).usingClientEntryPoint = false; | 54 | 54 | } | 55 | 55 | } | 56 | 56 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/index.classic.fb.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | import {isEnabled} from 'react-dom-bindings/src/events/ReactDOMEventListener'; | 11 | 11 |
| 12 | | -import Internals from './src/ReactDOMSharedInternals'; | | 12 | +import Internals from './src/ReactDOMSharedInternalsFB'; | 13 | 13 |
| 14 | 14 | // For classic WWW builds, include a few internals that are already in use. | 15 | 15 | Object.assign((Internals: any), { | @@ -32,7 +32,7 @@ export { | 32 | 32 | preinit, | 33 | 33 | preinitModule, | 34 | 34 | version, | 35 | | -} from './src/client/ReactDOM'; | | 35 | +} from './src/client/ReactDOMFB'; | 36 | 36 |
| 37 | 37 | export { | 38 | 38 | createRoot, | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/index.modern.fb.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | * @flow | 8 | 8 | */ | 9 | 9 |
| 10 | | -export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './src/ReactDOMSharedInternals'; | | 10 | +export {default as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED} from './src/ReactDOMSharedInternalsFB'; | 11 | 11 | export { | 12 | 12 | createPortal, | 13 | 13 | flushSync, | @@ -23,6 +23,6 @@ export { | 23 | 23 | preinit, | 24 | 24 | preinitModule, | 25 | 25 | version, | 26 | | -} from './src/client/ReactDOM'; | | 26 | +} from './src/client/ReactDOMFB'; | 27 | 27 |
| 28 | 28 | export {createRoot, hydrateRoot} from './src/client/ReactDOMRootFB'; |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/ReactDOMSharedInternals.js +16-14Lines changed: 16 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,18 +12,19 @@ import type {HostDispatcher} from './shared/ReactDOMTypes'; | 12 | 12 |
| 13 | 13 | import {NoEventPriority} from 'react-reconciler/src/ReactEventPriorities'; | 14 | 14 |
| 15 | | -type InternalsType = { | 16 | | - usingClientEntryPoint: boolean, | 17 | | - Events: [any, any, any, any, any, any], | 18 | | - ReactDOMCurrentDispatcher: { | 19 | | - current: HostDispatcher, | 20 | | - }, | | 15 | +type ReactDOMInternals = { | | 16 | + d /* ReactDOMCurrentDispatcher */: HostDispatcher, | | 17 | + p /* currentUpdatePriority */: EventPriority, | 21 | 18 | findDOMNode: | 22 | 19 | | null | 23 | 20 | | (( | 24 | 21 | componentOrElement: React$Component<any, any>, | 25 | 22 | ) => null | Element | Text), | 26 | | - up /* currentUpdatePriority */: EventPriority, | | 23 | + usingClientEntryPoint: boolean, | | 24 | +}; | | 25 | + | | 26 | +export type ReactDOMInternalsDev = ReactDOMInternals & { | | 27 | + usingClientEntryPoint: boolean, | 27 | 28 | }; | 28 | 29 |
| 29 | 30 | function noop() {} | @@ -39,14 +40,15 @@ const DefaultDispatcher: HostDispatcher = { | 39 | 40 | preinitModuleScript: noop, | 40 | 41 | }; | 41 | 42 |
| 42 | | -const Internals: InternalsType = { | 43 | | - usingClientEntryPoint: false, | 44 | | - Events: (null: any), | 45 | | - ReactDOMCurrentDispatcher: { | 46 | | - current: DefaultDispatcher, | 47 | | - }, | | 43 | +const Internals: ReactDOMInternals = { | | 44 | + d /* ReactDOMCurrentDispatcher */: DefaultDispatcher, | | 45 | + p /* currentUpdatePriority */: NoEventPriority, | 48 | 46 | findDOMNode: null, | 49 | | - up /* currentUpdatePriority */: NoEventPriority, | | 47 | + usingClientEntryPoint: false, | 50 | 48 | }; | 51 | 49 |
| | 50 | +// if (__DEV__) { | | 51 | +// (Internals: any).usingClientEntryPoint = false; | | 52 | +// } | | 53 | + | 52 | 54 | export default Internals; |
Collapse file Copy file name to clipboard +46Lines changed: 46 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +/** | | 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. | | 3 | + * | | 4 | + * This source code is licensed under the MIT license found in the | | 5 | + * LICENSE file in the root directory of this source tree. | | 6 | + * | | 7 | + * @flow | | 8 | + */ | | 9 | + | | 10 | +import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities'; | | 11 | +import type {HostDispatcher} from './shared/ReactDOMTypes'; | | 12 | + | | 13 | +import {NoEventPriority} from 'react-reconciler/src/ReactEventPriorities'; | | 14 | + | | 15 | +type ReactDOMInternals = { | | 16 | + Events: [any, any, any, any, any, any], | | 17 | + d /* ReactDOMCurrentDispatcher */: HostDispatcher, | | 18 | + p /* currentUpdatePriority */: EventPriority, | | 19 | + findDOMNode: | | 20 | + | null | | 21 | + | (( | | 22 | + componentOrElement: React$Component<any, any>, | | 23 | + ) => null | Element | Text), | | 24 | +}; | | 25 | + | | 26 | +function noop() {} | | 27 | + | | 28 | +const DefaultDispatcher: HostDispatcher = { | | 29 | + flushSyncWork: noop, | | 30 | + prefetchDNS: noop, | | 31 | + preconnect: noop, | | 32 | + preload: noop, | | 33 | + preloadModule: noop, | | 34 | + preinitScript: noop, | | 35 | + preinitStyle: noop, | | 36 | + preinitModuleScript: noop, | | 37 | +}; | | 38 | + | | 39 | +const Internals: ReactDOMInternals = { | | 40 | + Events: (null: any), | | 41 | + d /* ReactDOMCurrentDispatcher */: DefaultDispatcher, | | 42 | + p /* currentUpdatePriority */: NoEventPriority, | | 43 | + findDOMNode: null, | | 44 | +}; | | 45 | + | | 46 | +export default Internals; |
|