forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-dom-server-rendering-stub.production.js
248 lines (202 loc) · 8.89 KB
/
react-dom-server-rendering-stub.production.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/**
* @license React
* react-dom-server-rendering-stub.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var React = require("next/dist/compiled/react-experimental");
var ReactVersion = '18.3.0-experimental-2bc7d336a-20240205';
const Internals = {
usingClientEntryPoint: false,
Events: null,
Dispatcher: {
current: null
}
};
// Do not require this module directly! Use normal `invariant` calls with
// template literal strings. The messages will be replaced with error codes
// during build.
function formatProdErrorMessage(code) {
let url = 'https://react.dev/errors/' + code;
if (arguments.length > 1) {
url += '?args[]=' + encodeURIComponent(arguments[1]);
for (let i = 2; i < arguments.length; i++) {
url += '&args[]=' + encodeURIComponent(arguments[i]);
}
}
return "Minified React error #" + code + "; visit " + url + " for the full message or " + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.';
}
function getCrossOriginString(input) {
if (typeof input === 'string') {
return input === 'use-credentials' ? input : '';
}
return undefined;
}
function getCrossOriginStringAs(as, input) {
if (as === 'font') {
return '';
}
if (typeof input === 'string') {
return input === 'use-credentials' ? input : '';
}
return undefined;
}
const Dispatcher = Internals.Dispatcher;
function prefetchDNS(href) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
dispatcher.prefetchDNS(href);
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preconnect(href, options) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
const crossOrigin = options ? getCrossOriginString(options.crossOrigin) : null;
dispatcher.preconnect(href, crossOrigin);
} // We don't error because preconnect needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preload(href, options) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string' && // We check existence because we cannot enforce this function is actually called with the stated type
typeof options === 'object' && options !== null && typeof options.as === 'string') {
const as = options.as;
const crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);
dispatcher.preload(href, as, {
crossOrigin,
integrity: typeof options.integrity === 'string' ? options.integrity : undefined,
nonce: typeof options.nonce === 'string' ? options.nonce : undefined,
type: typeof options.type === 'string' ? options.type : undefined,
fetchPriority: typeof options.fetchPriority === 'string' ? options.fetchPriority : undefined,
referrerPolicy: typeof options.referrerPolicy === 'string' ? options.referrerPolicy : undefined,
imageSrcSet: typeof options.imageSrcSet === 'string' ? options.imageSrcSet : undefined,
imageSizes: typeof options.imageSizes === 'string' ? options.imageSizes : undefined
});
} // We don't error because preload needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preloadModule(href, options) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
if (options) {
const crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);
dispatcher.preloadModule(href, {
as: typeof options.as === 'string' && options.as !== 'script' ? options.as : undefined,
crossOrigin,
integrity: typeof options.integrity === 'string' ? options.integrity : undefined
});
} else {
dispatcher.preloadModule(href);
}
} // We don't error because preload needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preinit(href, options) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string' && options && typeof options.as === 'string') {
const as = options.as;
const crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);
const integrity = typeof options.integrity === 'string' ? options.integrity : undefined;
const fetchPriority = typeof options.fetchPriority === 'string' ? options.fetchPriority : undefined;
if (as === 'style') {
dispatcher.preinitStyle(href, typeof options.precedence === 'string' ? options.precedence : undefined, {
crossOrigin,
integrity,
fetchPriority
});
} else if (as === 'script') {
dispatcher.preinitScript(href, {
crossOrigin,
integrity,
fetchPriority,
nonce: typeof options.nonce === 'string' ? options.nonce : undefined
});
}
} // We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preinitModule(href, options) {
const dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
if (typeof options === 'object' && options !== null) {
if (options.as == null || options.as === 'script') {
const crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);
dispatcher.preinitModuleScript(href, {
crossOrigin,
integrity: typeof options.integrity === 'string' ? options.integrity : undefined,
nonce: typeof options.nonce === 'string' ? options.nonce : undefined
});
}
} else if (options == null) {
dispatcher.preinitModuleScript(href);
}
} // We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
const ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; // Since the "not pending" value is always the same, we can reuse the
function resolveDispatcher() {
// Copied from react/src/ReactHooks.js. It's the same thing but in a
// different package.
const dispatcher = ReactCurrentDispatcher.current;
// intentionally don't throw our own error because this is in a hot path.
// Also helps ensure this is inlined.
return dispatcher;
}
function useFormStatus() {
{
const dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] We know this exists because of the feature check above.
return dispatcher.useHostTransitionStatus();
}
}
function useFormState(action, initialState, permalink) {
{
const dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional
return dispatcher.useFormState(action, initialState, permalink);
}
}
function createPortal() {
throw Error(formatProdErrorMessage(448));
}
function flushSync() {
throw Error(formatProdErrorMessage(449));
} // on the server we just call the callback because there is
// not update mechanism. Really this should not be called on the
// server but since the semantics are generally clear enough we
// can provide this trivial implementation.
function batchedUpdates(fn, a) {
return fn(a);
}
// Export all exports so that they're available in tests.
function experimental_useFormStatus() {
return useFormStatus();
}
function experimental_useFormState(action, initialState, permalink) {
return useFormState(action, initialState, permalink);
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = createPortal;
exports.experimental_useFormState = experimental_useFormState;
exports.experimental_useFormStatus = experimental_useFormStatus;
exports.flushSync = flushSync;
exports.preconnect = preconnect;
exports.prefetchDNS = prefetchDNS;
exports.preinit = preinit;
exports.preinitModule = preinitModule;
exports.preload = preload;
exports.preloadModule = preloadModule;
exports.unstable_batchedUpdates = batchedUpdates;
exports.useFormState = useFormState;
exports.useFormStatus = useFormStatus;
exports.version = ReactVersion;