main
js 68 lines 1.85 KB
Raw
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 {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
11 import type {AsyncDispatcher} from 'react-reconciler/src/ReactInternalTypes';
12
13 import type {
14 Reference,
15 TaintEntry,
16 RequestCleanupQueue,
17 } from './ReactTaintRegistry';
18
19 import {
20 TaintRegistryObjects,
21 TaintRegistryValues,
22 TaintRegistryByteLengths,
23 TaintRegistryPendingRequests,
24 } from './ReactTaintRegistry';
25
26 import {enableTaint} from 'shared/ReactFeatureFlags';
27
28 export type SharedStateServer = {
29 H: null | Dispatcher, // ReactCurrentDispatcher for Hooks
30 A: null | AsyncDispatcher, // ReactCurrentCache for Cache
31
32 // enableTaint
33 TaintRegistryObjects: WeakMap<Reference, string>,
34 TaintRegistryValues: Map<string | bigint, TaintEntry>,
35 TaintRegistryByteLengths: Set<number>,
36 TaintRegistryPendingRequests: Set<RequestCleanupQueue>,
37
38 // DEV-only
39
40 // ReactDebugCurrentFrame
41 getCurrentStack: null | (() => string),
42
43 // ReactOwnerStackReset
44 recentlyCreatedOwnerStacks: 0,
45 };
46
47 export type RendererTask = boolean => RendererTask | null;
48
49 const ReactSharedInternals: SharedStateServer = {
50 H: null,
51 A: null,
52 } as any;
53
54 if (enableTaint) {
55 ReactSharedInternals.TaintRegistryObjects = TaintRegistryObjects;
56 ReactSharedInternals.TaintRegistryValues = TaintRegistryValues;
57 ReactSharedInternals.TaintRegistryByteLengths = TaintRegistryByteLengths;
58 ReactSharedInternals.TaintRegistryPendingRequests =
59 TaintRegistryPendingRequests;
60 }
61
62 if (__DEV__) {
63 // Stack implementation injected by the current renderer.
64 ReactSharedInternals.getCurrentStack = null as null | (() => string);
65 ReactSharedInternals.recentlyCreatedOwnerStacks = 0;
66 }
67
68 export default ReactSharedInternals;