annotate third_party/bun/node_modules/react/cjs/react-jsx-runtime.development.js @ 22:947b81010aba

[Dowa & Seobeo] Updated so that Dowa hashmaps can use arena and not be broken. Split up web so taht it can handle different paths. Also fixes issues with hash collisions which was pain in the ass.
author June Park <parkjune1995@gmail.com>
date Tue, 07 Oct 2025 07:11:02 -0700
parents de54585a40f1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
2 * @license React
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
3 * react-jsx-runtime.development.js
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
4 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
5 * Copyright (c) Facebook, Inc. and its affiliates.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
6 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
7 * This source code is licensed under the MIT license found in the
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
8 * LICENSE file in the root directory of this source tree.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
9 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
10
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
11 'use strict';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
12
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
13 if (process.env.NODE_ENV !== "production") {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
14 (function() {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
15 'use strict';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
16
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
17 var React = require('react');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
18
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
19 // ATTENTION
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
20 // When adding new symbols to this file,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
21 // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
22 // The Symbol used to tag the ReactElement-like types.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
23 var REACT_ELEMENT_TYPE = Symbol.for('react.element');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
24 var REACT_PORTAL_TYPE = Symbol.for('react.portal');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
25 var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
26 var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
27 var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
28 var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
29 var REACT_CONTEXT_TYPE = Symbol.for('react.context');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
30 var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
31 var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
32 var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
33 var REACT_MEMO_TYPE = Symbol.for('react.memo');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
34 var REACT_LAZY_TYPE = Symbol.for('react.lazy');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
35 var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
36 var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
37 var FAUX_ITERATOR_SYMBOL = '@@iterator';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
38 function getIteratorFn(maybeIterable) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
39 if (maybeIterable === null || typeof maybeIterable !== 'object') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
40 return null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
41 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
42
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
43 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
44
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
45 if (typeof maybeIterator === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
46 return maybeIterator;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
47 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
48
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
49 return null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
50 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
51
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
52 var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
53
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
54 function error(format) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
55 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
56 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
57 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
58 args[_key2 - 1] = arguments[_key2];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
59 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
60
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
61 printWarning('error', format, args);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
62 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
63 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
64 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
65
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
66 function printWarning(level, format, args) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
67 // When changing this logic, you might want to also
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
68 // update consoleWithStackDev.www.js as well.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
69 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
70 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
71 var stack = ReactDebugCurrentFrame.getStackAddendum();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
72
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
73 if (stack !== '') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
74 format += '%s';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
75 args = args.concat([stack]);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
76 } // eslint-disable-next-line react-internal/safe-string-coercion
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
77
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
78
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
79 var argsWithFormat = args.map(function (item) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
80 return String(item);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
81 }); // Careful: RN currently depends on this prefix
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
82
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
83 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
84 // breaks IE9: https://github.com/facebook/react/issues/13610
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
85 // eslint-disable-next-line react-internal/no-production-logging
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
86
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
87 Function.prototype.apply.call(console[level], console, argsWithFormat);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
88 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
89 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
90
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
91 // -----------------------------------------------------------------------------
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
92
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
93 var enableScopeAPI = false; // Experimental Create Event Handle API.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
94 var enableCacheElement = false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
95 var enableTransitionTracing = false; // No known bugs, but needs performance testing
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
96
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
97 var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
98 // stuff. Intended to enable React core members to more easily debug scheduling
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
99 // issues in DEV builds.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
100
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
101 var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
102
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
103 var REACT_MODULE_REFERENCE;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
104
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
105 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
106 REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
107 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
108
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
109 function isValidElementType(type) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
110 if (typeof type === 'string' || typeof type === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
111 return true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
112 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
113
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
114
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
115 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
116 return true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
117 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
118
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
119 if (typeof type === 'object' && type !== null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
120 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
121 // types supported by any Flight configuration anywhere since
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
122 // we don't know which Flight build this will end up being used
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
123 // with.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
124 type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
125 return true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
126 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
127 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
128
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
129 return false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
130 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
131
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
132 function getWrappedName(outerType, innerType, wrapperName) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
133 var displayName = outerType.displayName;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
134
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
135 if (displayName) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
136 return displayName;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
137 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
138
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
139 var functionName = innerType.displayName || innerType.name || '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
140 return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
141 } // Keep in sync with react-reconciler/getComponentNameFromFiber
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
142
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
143
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
144 function getContextName(type) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
145 return type.displayName || 'Context';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
146 } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
147
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
148
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
149 function getComponentNameFromType(type) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
150 if (type == null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
151 // Host root, text node or just invalid type.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
152 return null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
153 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
154
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
155 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
156 if (typeof type.tag === 'number') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
157 error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
158 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
159 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
160
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
161 if (typeof type === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
162 return type.displayName || type.name || null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
163 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
164
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
165 if (typeof type === 'string') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
166 return type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
167 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
168
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
169 switch (type) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
170 case REACT_FRAGMENT_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
171 return 'Fragment';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
172
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
173 case REACT_PORTAL_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
174 return 'Portal';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
175
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
176 case REACT_PROFILER_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
177 return 'Profiler';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
178
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
179 case REACT_STRICT_MODE_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
180 return 'StrictMode';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
181
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
182 case REACT_SUSPENSE_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
183 return 'Suspense';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
184
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
185 case REACT_SUSPENSE_LIST_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
186 return 'SuspenseList';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
187
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
188 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
189
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
190 if (typeof type === 'object') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
191 switch (type.$$typeof) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
192 case REACT_CONTEXT_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
193 var context = type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
194 return getContextName(context) + '.Consumer';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
195
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
196 case REACT_PROVIDER_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
197 var provider = type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
198 return getContextName(provider._context) + '.Provider';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
199
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
200 case REACT_FORWARD_REF_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
201 return getWrappedName(type, type.render, 'ForwardRef');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
202
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
203 case REACT_MEMO_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
204 var outerName = type.displayName || null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
205
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
206 if (outerName !== null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
207 return outerName;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
208 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
209
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
210 return getComponentNameFromType(type.type) || 'Memo';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
211
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
212 case REACT_LAZY_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
213 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
214 var lazyComponent = type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
215 var payload = lazyComponent._payload;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
216 var init = lazyComponent._init;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
217
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
218 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
219 return getComponentNameFromType(init(payload));
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
220 } catch (x) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
221 return null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
222 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
223 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
224
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
225 // eslint-disable-next-line no-fallthrough
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
226 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
227 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
228
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
229 return null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
230 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
231
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
232 var assign = Object.assign;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
233
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
234 // Helpers to patch console.logs to avoid logging during side-effect free
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
235 // replaying on render function. This currently only patches the object
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
236 // lazily which won't cover if the log function was extracted eagerly.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
237 // We could also eagerly patch the method.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
238 var disabledDepth = 0;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
239 var prevLog;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
240 var prevInfo;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
241 var prevWarn;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
242 var prevError;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
243 var prevGroup;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
244 var prevGroupCollapsed;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
245 var prevGroupEnd;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
246
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
247 function disabledLog() {}
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
248
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
249 disabledLog.__reactDisabledLog = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
250 function disableLogs() {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
251 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
252 if (disabledDepth === 0) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
253 /* eslint-disable react-internal/no-production-logging */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
254 prevLog = console.log;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
255 prevInfo = console.info;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
256 prevWarn = console.warn;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
257 prevError = console.error;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
258 prevGroup = console.group;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
259 prevGroupCollapsed = console.groupCollapsed;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
260 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
261
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
262 var props = {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
263 configurable: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
264 enumerable: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
265 value: disabledLog,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
266 writable: true
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
267 }; // $FlowFixMe Flow thinks console is immutable.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
268
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
269 Object.defineProperties(console, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
270 info: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
271 log: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
272 warn: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
273 error: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
274 group: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
275 groupCollapsed: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
276 groupEnd: props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
277 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
278 /* eslint-enable react-internal/no-production-logging */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
279 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
280
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
281 disabledDepth++;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
282 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
283 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
284 function reenableLogs() {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
285 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
286 disabledDepth--;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
287
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
288 if (disabledDepth === 0) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
289 /* eslint-disable react-internal/no-production-logging */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
290 var props = {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
291 configurable: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
292 enumerable: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
293 writable: true
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
294 }; // $FlowFixMe Flow thinks console is immutable.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
295
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
296 Object.defineProperties(console, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
297 log: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
298 value: prevLog
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
299 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
300 info: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
301 value: prevInfo
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
302 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
303 warn: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
304 value: prevWarn
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
305 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
306 error: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
307 value: prevError
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
308 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
309 group: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
310 value: prevGroup
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
311 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
312 groupCollapsed: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
313 value: prevGroupCollapsed
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
314 }),
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
315 groupEnd: assign({}, props, {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
316 value: prevGroupEnd
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
317 })
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
318 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
319 /* eslint-enable react-internal/no-production-logging */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
320 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
321
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
322 if (disabledDepth < 0) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
323 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
324 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
325 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
326 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
327
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
328 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
329 var prefix;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
330 function describeBuiltInComponentFrame(name, source, ownerFn) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
331 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
332 if (prefix === undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
333 // Extract the VM specific prefix used by each line.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
334 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
335 throw Error();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
336 } catch (x) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
337 var match = x.stack.trim().match(/\n( *(at )?)/);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
338 prefix = match && match[1] || '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
339 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
340 } // We use the prefix to ensure our stacks line up with native stack frames.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
341
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
342
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
343 return '\n' + prefix + name;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
344 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
345 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
346 var reentry = false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
347 var componentFrameCache;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
348
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
349 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
350 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
351 componentFrameCache = new PossiblyWeakMap();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
352 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
353
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
354 function describeNativeComponentFrame(fn, construct) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
355 // If something asked for a stack inside a fake render, it should get ignored.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
356 if ( !fn || reentry) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
357 return '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
358 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
359
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
360 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
361 var frame = componentFrameCache.get(fn);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
362
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
363 if (frame !== undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
364 return frame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
365 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
366 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
367
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
368 var control;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
369 reentry = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
370 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
371
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
372 Error.prepareStackTrace = undefined;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
373 var previousDispatcher;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
374
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
375 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
376 previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
377 // for warnings.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
378
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
379 ReactCurrentDispatcher.current = null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
380 disableLogs();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
381 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
382
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
383 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
384 // This should throw.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
385 if (construct) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
386 // Something should be setting the props in the constructor.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
387 var Fake = function () {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
388 throw Error();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
389 }; // $FlowFixMe
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
390
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
391
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
392 Object.defineProperty(Fake.prototype, 'props', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
393 set: function () {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
394 // We use a throwing setter instead of frozen or non-writable props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
395 // because that won't throw in a non-strict mode function.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
396 throw Error();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
397 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
398 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
399
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
400 if (typeof Reflect === 'object' && Reflect.construct) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
401 // We construct a different control for this case to include any extra
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
402 // frames added by the construct call.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
403 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
404 Reflect.construct(Fake, []);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
405 } catch (x) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
406 control = x;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
407 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
408
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
409 Reflect.construct(fn, [], Fake);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
410 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
411 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
412 Fake.call();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
413 } catch (x) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
414 control = x;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
415 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
416
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
417 fn.call(Fake.prototype);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
418 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
419 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
420 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
421 throw Error();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
422 } catch (x) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
423 control = x;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
424 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
425
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
426 fn();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
427 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
428 } catch (sample) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
429 // This is inlined manually because closure doesn't do it for us.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
430 if (sample && control && typeof sample.stack === 'string') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
431 // This extracts the first frame from the sample that isn't also in the control.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
432 // Skipping one frame that we assume is the frame that calls the two.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
433 var sampleLines = sample.stack.split('\n');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
434 var controlLines = control.stack.split('\n');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
435 var s = sampleLines.length - 1;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
436 var c = controlLines.length - 1;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
437
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
438 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
439 // We expect at least one stack frame to be shared.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
440 // Typically this will be the root most one. However, stack frames may be
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
441 // cut off due to maximum stack limits. In this case, one maybe cut off
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
442 // earlier than the other. We assume that the sample is longer or the same
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
443 // and there for cut off earlier. So we should find the root most frame in
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
444 // the sample somewhere in the control.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
445 c--;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
446 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
447
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
448 for (; s >= 1 && c >= 0; s--, c--) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
449 // Next we find the first one that isn't the same which should be the
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
450 // frame that called our sample function and the control.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
451 if (sampleLines[s] !== controlLines[c]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
452 // In V8, the first line is describing the message but other VMs don't.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
453 // If we're about to return the first line, and the control is also on the same
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
454 // line, that's a pretty good indicator that our sample threw at same line as
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
455 // the control. I.e. before we entered the sample frame. So we ignore this result.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
456 // This can happen if you passed a class to function component, or non-function.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
457 if (s !== 1 || c !== 1) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
458 do {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
459 s--;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
460 c--; // We may still have similar intermediate frames from the construct call.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
461 // The next one that isn't the same should be our match though.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
462
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
463 if (c < 0 || sampleLines[s] !== controlLines[c]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
464 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
465 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
466 // but we have a user-provided "displayName"
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
467 // splice it in to make the stack more readable.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
468
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
469
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
470 if (fn.displayName && _frame.includes('<anonymous>')) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
471 _frame = _frame.replace('<anonymous>', fn.displayName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
472 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
473
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
474 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
475 if (typeof fn === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
476 componentFrameCache.set(fn, _frame);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
477 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
478 } // Return the line we found.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
479
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
480
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
481 return _frame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
482 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
483 } while (s >= 1 && c >= 0);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
484 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
485
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
486 break;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
487 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
488 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
489 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
490 } finally {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
491 reentry = false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
492
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
493 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
494 ReactCurrentDispatcher.current = previousDispatcher;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
495 reenableLogs();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
496 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
497
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
498 Error.prepareStackTrace = previousPrepareStackTrace;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
499 } // Fallback to just using the name if we couldn't make it throw.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
500
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
501
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
502 var name = fn ? fn.displayName || fn.name : '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
503 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
504
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
505 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
506 if (typeof fn === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
507 componentFrameCache.set(fn, syntheticFrame);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
508 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
509 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
510
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
511 return syntheticFrame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
512 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
513 function describeFunctionComponentFrame(fn, source, ownerFn) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
514 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
515 return describeNativeComponentFrame(fn, false);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
516 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
517 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
518
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
519 function shouldConstruct(Component) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
520 var prototype = Component.prototype;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
521 return !!(prototype && prototype.isReactComponent);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
522 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
523
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
524 function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
525
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
526 if (type == null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
527 return '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
528 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
529
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
530 if (typeof type === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
531 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
532 return describeNativeComponentFrame(type, shouldConstruct(type));
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
533 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
534 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
535
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
536 if (typeof type === 'string') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
537 return describeBuiltInComponentFrame(type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
538 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
539
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
540 switch (type) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
541 case REACT_SUSPENSE_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
542 return describeBuiltInComponentFrame('Suspense');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
543
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
544 case REACT_SUSPENSE_LIST_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
545 return describeBuiltInComponentFrame('SuspenseList');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
546 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
547
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
548 if (typeof type === 'object') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
549 switch (type.$$typeof) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
550 case REACT_FORWARD_REF_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
551 return describeFunctionComponentFrame(type.render);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
552
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
553 case REACT_MEMO_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
554 // Memo may contain any component type so we recursively resolve it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
555 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
556
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
557 case REACT_LAZY_TYPE:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
558 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
559 var lazyComponent = type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
560 var payload = lazyComponent._payload;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
561 var init = lazyComponent._init;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
562
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
563 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
564 // Lazy may contain any component type so we recursively resolve it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
565 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
566 } catch (x) {}
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
567 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
568 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
569 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
570
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
571 return '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
572 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
573
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
574 var hasOwnProperty = Object.prototype.hasOwnProperty;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
575
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
576 var loggedTypeFailures = {};
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
577 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
578
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
579 function setCurrentlyValidatingElement(element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
580 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
581 if (element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
582 var owner = element._owner;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
583 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
584 ReactDebugCurrentFrame.setExtraStackFrame(stack);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
585 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
586 ReactDebugCurrentFrame.setExtraStackFrame(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
587 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
588 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
589 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
590
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
591 function checkPropTypes(typeSpecs, values, location, componentName, element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
592 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
593 // $FlowFixMe This is okay but Flow doesn't know it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
594 var has = Function.call.bind(hasOwnProperty);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
595
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
596 for (var typeSpecName in typeSpecs) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
597 if (has(typeSpecs, typeSpecName)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
598 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
599 // fail the render phase where it didn't fail before. So we log it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
600 // After these have been cleaned up, we'll let them throw.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
601
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
602 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
603 // This is intentionally an invariant that gets caught. It's the same
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
604 // behavior as without this statement except with a better message.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
605 if (typeof typeSpecs[typeSpecName] !== 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
606 // eslint-disable-next-line react-internal/prod-error-codes
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
607 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
608 err.name = 'Invariant Violation';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
609 throw err;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
610 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
611
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
612 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
613 } catch (ex) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
614 error$1 = ex;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
615 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
616
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
617 if (error$1 && !(error$1 instanceof Error)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
618 setCurrentlyValidatingElement(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
619
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
620 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
621
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
622 setCurrentlyValidatingElement(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
623 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
624
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
625 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
626 // Only monitor this failure once because there tends to be a lot of the
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
627 // same error.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
628 loggedTypeFailures[error$1.message] = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
629 setCurrentlyValidatingElement(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
630
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
631 error('Failed %s type: %s', location, error$1.message);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
632
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
633 setCurrentlyValidatingElement(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
634 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
635 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
636 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
637 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
638 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
639
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
640 var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
641
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
642 function isArray(a) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
643 return isArrayImpl(a);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
644 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
645
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
646 /*
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
647 * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
648 * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
649 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
650 * The functions in this module will throw an easier-to-understand,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
651 * easier-to-debug exception with a clear errors message message explaining the
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
652 * problem. (Instead of a confusing exception thrown inside the implementation
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
653 * of the `value` object).
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
654 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
655 // $FlowFixMe only called in DEV, so void return is not possible.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
656 function typeName(value) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
657 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
658 // toStringTag is needed for namespaced types like Temporal.Instant
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
659 var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
660 var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
661 return type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
662 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
663 } // $FlowFixMe only called in DEV, so void return is not possible.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
664
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
665
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
666 function willCoercionThrow(value) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
667 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
668 try {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
669 testStringCoercion(value);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
670 return false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
671 } catch (e) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
672 return true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
673 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
674 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
675 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
676
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
677 function testStringCoercion(value) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
678 // If you ended up here by following an exception call stack, here's what's
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
679 // happened: you supplied an object or symbol value to React (as a prop, key,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
680 // DOM attribute, CSS property, string ref, etc.) and when React tried to
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
681 // coerce it to a string using `'' + value`, an exception was thrown.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
682 //
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
683 // The most common types that will cause this exception are `Symbol` instances
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
684 // and Temporal objects like `Temporal.Instant`. But any object that has a
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
685 // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
686 // exception. (Library authors do this to prevent users from using built-in
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
687 // numeric operators like `+` or comparison operators like `>=` because custom
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
688 // methods are needed to perform accurate arithmetic or comparison.)
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
689 //
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
690 // To fix the problem, coerce this object or symbol value to a string before
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
691 // passing it to React. The most reliable way is usually `String(value)`.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
692 //
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
693 // To find which value is throwing, check the browser or debugger console.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
694 // Before this exception was thrown, there should be `console.error` output
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
695 // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
696 // problem and how that type was used: key, atrribute, input value prop, etc.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
697 // In most cases, this console output also shows the component and its
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
698 // ancestor components where the exception happened.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
699 //
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
700 // eslint-disable-next-line react-internal/safe-string-coercion
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
701 return '' + value;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
702 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
703 function checkKeyStringCoercion(value) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
704 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
705 if (willCoercionThrow(value)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
706 error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
707
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
708 return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
709 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
710 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
711 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
712
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
713 var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
714 var RESERVED_PROPS = {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
715 key: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
716 ref: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
717 __self: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
718 __source: true
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
719 };
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
720 var specialPropKeyWarningShown;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
721 var specialPropRefWarningShown;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
722 var didWarnAboutStringRefs;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
723
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
724 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
725 didWarnAboutStringRefs = {};
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
726 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
727
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
728 function hasValidRef(config) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
729 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
730 if (hasOwnProperty.call(config, 'ref')) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
731 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
732
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
733 if (getter && getter.isReactWarning) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
734 return false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
735 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
736 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
737 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
738
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
739 return config.ref !== undefined;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
740 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
741
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
742 function hasValidKey(config) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
743 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
744 if (hasOwnProperty.call(config, 'key')) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
745 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
746
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
747 if (getter && getter.isReactWarning) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
748 return false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
749 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
750 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
751 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
752
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
753 return config.key !== undefined;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
754 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
755
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
756 function warnIfStringRefCannotBeAutoConverted(config, self) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
757 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
758 if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
759 var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
760
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
761 if (!didWarnAboutStringRefs[componentName]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
762 error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
763
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
764 didWarnAboutStringRefs[componentName] = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
765 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
766 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
767 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
768 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
769
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
770 function defineKeyPropWarningGetter(props, displayName) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
771 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
772 var warnAboutAccessingKey = function () {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
773 if (!specialPropKeyWarningShown) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
774 specialPropKeyWarningShown = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
775
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
776 error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
777 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
778 };
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
779
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
780 warnAboutAccessingKey.isReactWarning = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
781 Object.defineProperty(props, 'key', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
782 get: warnAboutAccessingKey,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
783 configurable: true
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
784 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
785 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
786 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
787
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
788 function defineRefPropWarningGetter(props, displayName) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
789 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
790 var warnAboutAccessingRef = function () {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
791 if (!specialPropRefWarningShown) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
792 specialPropRefWarningShown = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
793
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
794 error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
795 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
796 };
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
797
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
798 warnAboutAccessingRef.isReactWarning = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
799 Object.defineProperty(props, 'ref', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
800 get: warnAboutAccessingRef,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
801 configurable: true
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
802 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
803 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
804 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
805 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
806 * Factory method to create a new React element. This no longer adheres to
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
807 * the class pattern, so do not use new to call it. Also, instanceof check
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
808 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
809 * if something is a React Element.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
810 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
811 * @param {*} type
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
812 * @param {*} props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
813 * @param {*} key
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
814 * @param {string|object} ref
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
815 * @param {*} owner
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
816 * @param {*} self A *temporary* helper to detect places where `this` is
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
817 * different from the `owner` when React.createElement is called, so that we
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
818 * can warn. We want to get rid of owner and replace string `ref`s with arrow
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
819 * functions, and as long as `this` and owner are the same, there will be no
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
820 * change in behavior.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
821 * @param {*} source An annotation object (added by a transpiler or otherwise)
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
822 * indicating filename, line number, and/or other information.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
823 * @internal
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
824 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
825
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
826
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
827 var ReactElement = function (type, key, ref, self, source, owner, props) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
828 var element = {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
829 // This tag allows us to uniquely identify this as a React Element
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
830 $$typeof: REACT_ELEMENT_TYPE,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
831 // Built-in properties that belong on the element
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
832 type: type,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
833 key: key,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
834 ref: ref,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
835 props: props,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
836 // Record the component responsible for creating this element.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
837 _owner: owner
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
838 };
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
839
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
840 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
841 // The validation flag is currently mutative. We put it on
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
842 // an external backing store so that we can freeze the whole object.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
843 // This can be replaced with a WeakMap once they are implemented in
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
844 // commonly used development environments.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
845 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
846 // the validation flag non-enumerable (where possible, which should
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
847 // include every environment we run tests in), so the test framework
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
848 // ignores it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
849
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
850 Object.defineProperty(element._store, 'validated', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
851 configurable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
852 enumerable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
853 writable: true,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
854 value: false
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
855 }); // self and source are DEV only properties.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
856
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
857 Object.defineProperty(element, '_self', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
858 configurable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
859 enumerable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
860 writable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
861 value: self
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
862 }); // Two elements created in two different places should be considered
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
863 // equal for testing purposes and therefore we hide it from enumeration.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
864
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
865 Object.defineProperty(element, '_source', {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
866 configurable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
867 enumerable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
868 writable: false,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
869 value: source
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
870 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
871
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
872 if (Object.freeze) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
873 Object.freeze(element.props);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
874 Object.freeze(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
875 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
876 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
877
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
878 return element;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
879 };
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
880 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
881 * https://github.com/reactjs/rfcs/pull/107
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
882 * @param {*} type
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
883 * @param {object} props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
884 * @param {string} key
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
885 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
886
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
887 function jsxDEV(type, config, maybeKey, source, self) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
888 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
889 var propName; // Reserved names are extracted
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
890
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
891 var props = {};
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
892 var key = null;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
893 var ref = null; // Currently, key can be spread in as a prop. This causes a potential
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
894 // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
895 // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
896 // but as an intermediary step, we will use jsxDEV for everything except
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
897 // <div {...props} key="Hi" />, because we aren't currently able to tell if
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
898 // key is explicitly declared to be undefined or not.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
899
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
900 if (maybeKey !== undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
901 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
902 checkKeyStringCoercion(maybeKey);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
903 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
904
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
905 key = '' + maybeKey;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
906 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
907
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
908 if (hasValidKey(config)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
909 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
910 checkKeyStringCoercion(config.key);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
911 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
912
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
913 key = '' + config.key;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
914 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
915
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
916 if (hasValidRef(config)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
917 ref = config.ref;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
918 warnIfStringRefCannotBeAutoConverted(config, self);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
919 } // Remaining properties are added to a new props object
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
920
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
921
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
922 for (propName in config) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
923 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
924 props[propName] = config[propName];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
925 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
926 } // Resolve default props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
927
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
928
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
929 if (type && type.defaultProps) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
930 var defaultProps = type.defaultProps;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
931
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
932 for (propName in defaultProps) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
933 if (props[propName] === undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
934 props[propName] = defaultProps[propName];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
935 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
936 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
937 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
938
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
939 if (key || ref) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
940 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
941
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
942 if (key) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
943 defineKeyPropWarningGetter(props, displayName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
944 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
945
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
946 if (ref) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
947 defineRefPropWarningGetter(props, displayName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
948 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
949 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
950
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
951 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
952 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
953 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
954
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
955 var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
956 var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
957
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
958 function setCurrentlyValidatingElement$1(element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
959 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
960 if (element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
961 var owner = element._owner;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
962 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
963 ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
964 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
965 ReactDebugCurrentFrame$1.setExtraStackFrame(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
966 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
967 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
968 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
969
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
970 var propTypesMisspellWarningShown;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
971
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
972 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
973 propTypesMisspellWarningShown = false;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
974 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
975 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
976 * Verifies the object is a ReactElement.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
977 * See https://reactjs.org/docs/react-api.html#isvalidelement
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
978 * @param {?object} object
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
979 * @return {boolean} True if `object` is a ReactElement.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
980 * @final
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
981 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
982
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
983
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
984 function isValidElement(object) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
985 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
986 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
987 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
988 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
989
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
990 function getDeclarationErrorAddendum() {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
991 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
992 if (ReactCurrentOwner$1.current) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
993 var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
994
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
995 if (name) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
996 return '\n\nCheck the render method of `' + name + '`.';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
997 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
998 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
999
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1000 return '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1001 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1002 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1003
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1004 function getSourceInfoErrorAddendum(source) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1005 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1006 if (source !== undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1007 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1008 var lineNumber = source.lineNumber;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1009 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1010 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1011
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1012 return '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1013 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1014 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1015 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1016 * Warn if there's no key explicitly set on dynamic arrays of children or
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1017 * object keys are not valid. This allows us to keep track of children between
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1018 * updates.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1019 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1020
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1021
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1022 var ownerHasKeyUseWarning = {};
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1023
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1024 function getCurrentComponentErrorInfo(parentType) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1025 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1026 var info = getDeclarationErrorAddendum();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1027
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1028 if (!info) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1029 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1030
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1031 if (parentName) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1032 info = "\n\nCheck the top-level render call using <" + parentName + ">.";
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1033 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1034 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1035
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1036 return info;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1037 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1038 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1039 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1040 * Warn if the element doesn't have an explicit key assigned to it.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1041 * This element is in an array. The array could grow and shrink or be
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1042 * reordered. All children that haven't already been validated are required to
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1043 * have a "key" property assigned to it. Error statuses are cached so a warning
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1044 * will only be shown once.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1045 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1046 * @internal
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1047 * @param {ReactElement} element Element that requires a key.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1048 * @param {*} parentType element's parent's type.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1049 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1050
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1051
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1052 function validateExplicitKey(element, parentType) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1053 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1054 if (!element._store || element._store.validated || element.key != null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1055 return;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1056 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1057
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1058 element._store.validated = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1059 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1060
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1061 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1062 return;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1063 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1064
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1065 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1066 // property, it may be the creator of the child that's responsible for
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1067 // assigning it a key.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1068
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1069 var childOwner = '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1070
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1071 if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1072 // Give the component that originally created this child.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1073 childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1074 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1075
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1076 setCurrentlyValidatingElement$1(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1077
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1078 error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1079
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1080 setCurrentlyValidatingElement$1(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1081 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1082 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1083 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1084 * Ensure that every element either is passed in a static location, in an
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1085 * array with an explicit keys property defined, or in an object literal
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1086 * with valid key property.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1087 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1088 * @internal
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1089 * @param {ReactNode} node Statically passed child of any type.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1090 * @param {*} parentType node's parent's type.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1091 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1092
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1093
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1094 function validateChildKeys(node, parentType) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1095 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1096 if (typeof node !== 'object') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1097 return;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1098 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1099
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1100 if (isArray(node)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1101 for (var i = 0; i < node.length; i++) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1102 var child = node[i];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1103
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1104 if (isValidElement(child)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1105 validateExplicitKey(child, parentType);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1106 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1107 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1108 } else if (isValidElement(node)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1109 // This element was passed in a valid location.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1110 if (node._store) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1111 node._store.validated = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1112 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1113 } else if (node) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1114 var iteratorFn = getIteratorFn(node);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1115
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1116 if (typeof iteratorFn === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1117 // Entry iterators used to provide implicit keys,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1118 // but now we print a separate warning for them later.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1119 if (iteratorFn !== node.entries) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1120 var iterator = iteratorFn.call(node);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1121 var step;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1122
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1123 while (!(step = iterator.next()).done) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1124 if (isValidElement(step.value)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1125 validateExplicitKey(step.value, parentType);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1126 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1127 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1128 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1129 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1130 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1131 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1132 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1133 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1134 * Given an element, validate that its props follow the propTypes definition,
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1135 * provided by the type.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1136 *
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1137 * @param {ReactElement} element
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1138 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1139
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1140
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1141 function validatePropTypes(element) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1142 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1143 var type = element.type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1144
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1145 if (type === null || type === undefined || typeof type === 'string') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1146 return;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1147 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1148
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1149 var propTypes;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1150
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1151 if (typeof type === 'function') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1152 propTypes = type.propTypes;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1153 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1154 // Inner props are checked in the reconciler.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1155 type.$$typeof === REACT_MEMO_TYPE)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1156 propTypes = type.propTypes;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1157 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1158 return;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1159 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1160
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1161 if (propTypes) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1162 // Intentionally inside to avoid triggering lazy initializers:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1163 var name = getComponentNameFromType(type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1164 checkPropTypes(propTypes, element.props, 'prop', name, element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1165 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1166 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1167
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1168 var _name = getComponentNameFromType(type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1169
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1170 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1171 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1172
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1173 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1174 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1175 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1176 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1177 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1178 /**
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1179 * Given a fragment, validate that it can only be provided with fragment props
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1180 * @param {ReactElement} fragment
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1181 */
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1182
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1183
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1184 function validateFragmentProps(fragment) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1185 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1186 var keys = Object.keys(fragment.props);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1187
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1188 for (var i = 0; i < keys.length; i++) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1189 var key = keys[i];
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1190
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1191 if (key !== 'children' && key !== 'key') {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1192 setCurrentlyValidatingElement$1(fragment);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1193
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1194 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1195
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1196 setCurrentlyValidatingElement$1(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1197 break;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1198 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1199 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1200
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1201 if (fragment.ref !== null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1202 setCurrentlyValidatingElement$1(fragment);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1203
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1204 error('Invalid attribute `ref` supplied to `React.Fragment`.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1205
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1206 setCurrentlyValidatingElement$1(null);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1207 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1208 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1209 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1210
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1211 var didWarnAboutKeySpread = {};
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1212 function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1213 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1214 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1215 // succeed and there will likely be errors in render.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1216
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1217 if (!validType) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1218 var info = '';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1219
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1220 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1221 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1222 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1223
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1224 var sourceInfo = getSourceInfoErrorAddendum(source);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1225
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1226 if (sourceInfo) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1227 info += sourceInfo;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1228 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1229 info += getDeclarationErrorAddendum();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1230 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1231
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1232 var typeString;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1233
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1234 if (type === null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1235 typeString = 'null';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1236 } else if (isArray(type)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1237 typeString = 'array';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1238 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1239 typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1240 info = ' Did you accidentally export a JSX literal instead of a component?';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1241 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1242 typeString = typeof type;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1243 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1244
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1245 error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1246 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1247
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1248 var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1249 // TODO: Drop this when these are no longer allowed as the type argument.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1250
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1251 if (element == null) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1252 return element;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1253 } // Skip key warning if the type isn't valid since our key validation logic
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1254 // doesn't expect a non-string/function type and can throw confusing errors.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1255 // We don't want exception behavior to differ between dev and prod.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1256 // (Rendering will throw with a helpful message and as soon as the type is
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1257 // fixed, the key warnings will appear.)
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1258
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1259
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1260 if (validType) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1261 var children = props.children;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1262
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1263 if (children !== undefined) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1264 if (isStaticChildren) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1265 if (isArray(children)) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1266 for (var i = 0; i < children.length; i++) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1267 validateChildKeys(children[i], type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1268 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1269
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1270 if (Object.freeze) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1271 Object.freeze(children);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1272 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1273 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1274 error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1275 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1276 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1277 validateChildKeys(children, type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1278 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1279 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1280 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1281
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1282 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1283 if (hasOwnProperty.call(props, 'key')) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1284 var componentName = getComponentNameFromType(type);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1285 var keys = Object.keys(props).filter(function (k) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1286 return k !== 'key';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1287 });
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1288 var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1289
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1290 if (!didWarnAboutKeySpread[componentName + beforeExample]) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1291 var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1292
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1293 error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1294
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1295 didWarnAboutKeySpread[componentName + beforeExample] = true;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1296 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1297 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1298 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1299
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1300 if (type === REACT_FRAGMENT_TYPE) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1301 validateFragmentProps(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1302 } else {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1303 validatePropTypes(element);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1304 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1305
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1306 return element;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1307 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1308 } // These two functions exist to still get child warnings in dev
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1309 // even with the prod transform. This means that jsxDEV is purely
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1310 // opt-in behavior for better messages but that we won't stop
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1311 // giving you warnings if you use production apis.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1312
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1313 function jsxWithValidationStatic(type, props, key) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1314 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1315 return jsxWithValidation(type, props, key, true);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1316 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1317 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1318 function jsxWithValidationDynamic(type, props, key) {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1319 {
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1320 return jsxWithValidation(type, props, key, false);
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1321 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1322 }
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1323
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1324 var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1325 // for now we can ship identical prod functions
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1326
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1327 var jsxs = jsxWithValidationStatic ;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1328
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1329 exports.Fragment = REACT_FRAGMENT_TYPE;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1330 exports.jsx = jsx;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1331 exports.jsxs = jsxs;
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1332 })();
de54585a40f1 Adding bun and node modules.
June Park <parkjune1995@gmail.com>
parents:
diff changeset
1333 }