-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathreact-dom-server-rendering-stub.development.js
332 lines (278 loc) · 15.2 KB
/
react-dom-server-rendering-stub.development.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/**
* @license React
* react-dom-server-rendering-stub.development.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';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
var React = require("next/dist/compiled/react");
var ReactVersion = '18.3.0-canary-2807d781a-20230918';
var Internals = {
usingClientEntryPoint: false,
Events: null,
Dispatcher: {
current: null
}
};
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function error(format) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
var stack = ReactDebugCurrentFrame.getStackAddendum();
if (stack !== '') {
format += '%s';
args = args.concat([stack]);
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
var Dispatcher = Internals.Dispatcher;
function prefetchDNS(href) {
{
if (typeof href !== 'string' || !href) {
error('ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.', getValueDescriptorExpectingObjectForWarning(href));
} else if (arguments.length > 1) {
var options = arguments[1];
if (typeof options === 'object' && options.hasOwnProperty('crossOrigin')) {
error('ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.', getValueDescriptorExpectingEnumForWarning(options));
} else {
error('ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.', getValueDescriptorExpectingEnumForWarning(options));
}
}
}
var 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) {
{
if (typeof href !== 'string' || !href) {
error('ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.', getValueDescriptorExpectingObjectForWarning(href));
} else if (options != null && typeof options !== 'object') {
error('ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.', getValueDescriptorExpectingEnumForWarning(options));
} else if (options != null && typeof options.crossOrigin !== 'string') {
error('ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.', getValueDescriptorExpectingObjectForWarning(options.crossOrigin));
}
}
var dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
var crossOrigin = options ? getCrossOrigin('preconnect', 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) {
{
var encountered = '';
if (typeof href !== 'string' || !href) {
encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".";
}
if (options == null || typeof options !== 'object') {
encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + ".";
} else if (typeof options.as !== 'string' || !options.as) {
encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".";
}
if (encountered) {
error('ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s', encountered);
}
}
var 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') {
var as = options.as;
var crossOrigin = getCrossOrigin(as, options.crossOrigin);
dispatcher.preload(href, as, {
crossOrigin: 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) {
{
var encountered = '';
if (typeof href !== 'string' || !href) {
encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".";
}
if (options !== undefined && typeof options !== 'object') {
encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + ".";
} else if (options && 'as' in options && typeof options.as !== 'string') {
encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".";
}
if (encountered) {
error('ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s', encountered);
}
}
var dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
if (options) {
var crossOrigin = getCrossOrigin(options.as, options.crossOrigin);
dispatcher.preloadModule(href, {
as: typeof options.as === 'string' && options.as !== 'script' ? options.as : undefined,
crossOrigin: 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) {
{
if (typeof href !== 'string' || !href) {
error('ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.', getValueDescriptorExpectingObjectForWarning(href));
} else if (options == null || typeof options !== 'object') {
error('ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.', getValueDescriptorExpectingEnumForWarning(options));
} else if (options.as !== 'style' && options.as !== 'script') {
error('ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".', getValueDescriptorExpectingEnumForWarning(options.as));
}
}
var dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string' && options && typeof options.as === 'string') {
var as = options.as;
var crossOrigin = getCrossOrigin(as, options.crossOrigin);
var integrity = typeof options.integrity === 'string' ? options.integrity : undefined;
var fetchPriority = typeof options.fetchPriority === 'string' ? options.fetchPriority : undefined;
if (as === 'style') {
dispatcher.preinitStyle(href, typeof options.precedence === 'string' ? options.precedence : undefined, {
crossOrigin: crossOrigin,
integrity: integrity,
fetchPriority: fetchPriority
});
} else if (as === 'script') {
dispatcher.preinitScript(href, {
crossOrigin: crossOrigin,
integrity: integrity,
fetchPriority: 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) {
{
var encountered = '';
if (typeof href !== 'string' || !href) {
encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".";
}
if (options !== undefined && typeof options !== 'object') {
encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + ".";
} else if (options && 'as' in options && options.as !== 'script') {
encountered += " The `as` option encountered was " + getValueDescriptorExpectingEnumForWarning(options.as) + ".";
}
if (encountered) {
error('ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s', encountered);
} else {
var as = options && typeof options.as === 'string' ? options.as : 'script';
switch (as) {
case 'script':
{
break;
}
// We have an invalid as type and need to warn
default:
{
var typeOfAs = getValueDescriptorExpectingEnumForWarning(as);
error('ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script"' + ' but received "%s" instead. This warning was generated for `href` "%s". In the future other' + ' module types will be supported, aligning with the import-attributes proposal. Learn more here:' + ' (https://github.com/tc39/proposal-import-attributes)', typeOfAs, href);
}
}
}
}
var dispatcher = Dispatcher.current;
if (dispatcher && typeof href === 'string') {
if (options == null || typeof options === 'object' && (options.as == null || options.as === 'script')) {
var crossOrigin = options ? getCrossOrigin(undefined, options.crossOrigin) : undefined;
dispatcher.preinitModuleScript(href, {
crossOrigin: crossOrigin,
integrity: options && typeof options.integrity === 'string' ? options.integrity : 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 getCrossOrigin(as, crossOrigin) {
return as === 'font' ? '' : typeof crossOrigin === 'string' ? crossOrigin === 'use-credentials' ? 'use-credentials' : '' : undefined;
}
function getValueDescriptorExpectingObjectForWarning(thing) {
return thing === null ? '`null`' : thing === undefined ? '`undefined`' : thing === '' ? 'an empty string' : "something with type \"" + typeof thing + "\"";
}
function getValueDescriptorExpectingEnumForWarning(thing) {
return thing === null ? '`null`' : thing === undefined ? '`undefined`' : thing === '' ? 'an empty string' : typeof thing === 'string' ? JSON.stringify(thing) : typeof thing === 'number' ? '`' + thing + '`' : "something with type \"" + typeof thing + "\"";
}
function useFormStatus() {
{
throw new Error('Not implemented.');
}
}
function useFormState(action, initialState, permalink) {
{
throw new Error('Not implemented.');
}
}
function createPortal() {
throw new Error('createPortal was called on the server. Portals are not currently' + ' supported on the server. Update your program to conditionally call' + ' createPortal on the client only.');
}
function flushSync() {
throw new Error('flushSync was called on the server. This is likely caused by a' + ' function being called during render or in module scope that was' + ' intended to be called from an effect or event handler. Update your' + ' to not call flushSync no the server.');
} // 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);
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = createPortal;
exports.experimental_useFormState = useFormState;
exports.experimental_useFormStatus = 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.version = ReactVersion;
})();
}