react-server-dom-webpack 18.3.0-next-855b77c9b-20230202 → 18.3.0-next-758fc7fde-20230207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2481 @@
1
+ /**
2
+ * @license React
3
+ * react-server-dom-webpack-server.edge.development.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ if (process.env.NODE_ENV !== "production") {
14
+ (function() {
15
+ 'use strict';
16
+
17
+ var React = require('react');
18
+ var ReactDOM = require('react-dom');
19
+
20
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
21
+
22
+ function error(format) {
23
+ {
24
+ {
25
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
26
+ args[_key2 - 1] = arguments[_key2];
27
+ }
28
+
29
+ printWarning('error', format, args);
30
+ }
31
+ }
32
+ }
33
+
34
+ function printWarning(level, format, args) {
35
+ // When changing this logic, you might want to also
36
+ // update consoleWithStackDev.www.js as well.
37
+ {
38
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
39
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
40
+
41
+ if (stack !== '') {
42
+ format += '%s';
43
+ args = args.concat([stack]);
44
+ } // eslint-disable-next-line react-internal/safe-string-coercion
45
+
46
+
47
+ var argsWithFormat = args.map(function (item) {
48
+ return String(item);
49
+ }); // Careful: RN currently depends on this prefix
50
+
51
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
52
+ // breaks IE9: https://github.com/facebook/react/issues/13610
53
+ // eslint-disable-next-line react-internal/no-production-logging
54
+
55
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
56
+ }
57
+ }
58
+
59
+ function scheduleWork(callback) {
60
+ callback();
61
+ }
62
+
63
+ var supportsRequestStorage = typeof AsyncLocalStorage === 'function';
64
+ var requestStorage = supportsRequestStorage ? new AsyncLocalStorage() : null;
65
+ var VIEW_SIZE = 512;
66
+ var currentView = null;
67
+ var writtenBytes = 0;
68
+ function beginWriting(destination) {
69
+ currentView = new Uint8Array(VIEW_SIZE);
70
+ writtenBytes = 0;
71
+ }
72
+ function writeChunk(destination, chunk) {
73
+ if (chunk.length === 0) {
74
+ return;
75
+ }
76
+
77
+ if (chunk.length > VIEW_SIZE) {
78
+ {
79
+ if (precomputedChunkSet.has(chunk)) {
80
+ error('A large precomputed chunk was passed to writeChunk without being copied.' + ' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' + ' Use "cloneChunk" to make a copy of this large precomputed chunk before writing it. This is a bug in React.');
81
+ }
82
+ } // this chunk may overflow a single view which implies it was not
83
+ // one that is cached by the streaming renderer. We will enqueu
84
+ // it directly and expect it is not re-used
85
+
86
+
87
+ if (writtenBytes > 0) {
88
+ destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
89
+ currentView = new Uint8Array(VIEW_SIZE);
90
+ writtenBytes = 0;
91
+ }
92
+
93
+ destination.enqueue(chunk);
94
+ return;
95
+ }
96
+
97
+ var bytesToWrite = chunk;
98
+ var allowableBytes = currentView.length - writtenBytes;
99
+
100
+ if (allowableBytes < bytesToWrite.length) {
101
+ // this chunk would overflow the current view. We enqueue a full view
102
+ // and start a new view with the remaining chunk
103
+ if (allowableBytes === 0) {
104
+ // the current view is already full, send it
105
+ destination.enqueue(currentView);
106
+ } else {
107
+ // fill up the current view and apply the remaining chunk bytes
108
+ // to a new view.
109
+ currentView.set(bytesToWrite.subarray(0, allowableBytes), writtenBytes); // writtenBytes += allowableBytes; // this can be skipped because we are going to immediately reset the view
110
+
111
+ destination.enqueue(currentView);
112
+ bytesToWrite = bytesToWrite.subarray(allowableBytes);
113
+ }
114
+
115
+ currentView = new Uint8Array(VIEW_SIZE);
116
+ writtenBytes = 0;
117
+ }
118
+
119
+ currentView.set(bytesToWrite, writtenBytes);
120
+ writtenBytes += bytesToWrite.length;
121
+ }
122
+ function writeChunkAndReturn(destination, chunk) {
123
+ writeChunk(destination, chunk); // in web streams there is no backpressure so we can alwas write more
124
+
125
+ return true;
126
+ }
127
+ function completeWriting(destination) {
128
+ if (currentView && writtenBytes > 0) {
129
+ destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
130
+ currentView = null;
131
+ writtenBytes = 0;
132
+ }
133
+ }
134
+ function close(destination) {
135
+ destination.close();
136
+ }
137
+ var textEncoder = new TextEncoder();
138
+ function stringToChunk(content) {
139
+ return textEncoder.encode(content);
140
+ }
141
+ var precomputedChunkSet = new Set() ;
142
+ function stringToPrecomputedChunk(content) {
143
+ var precomputedChunk = textEncoder.encode(content);
144
+
145
+ {
146
+ precomputedChunkSet.add(precomputedChunk);
147
+ }
148
+
149
+ return precomputedChunk;
150
+ }
151
+ function closeWithError(destination, error) {
152
+ // $FlowFixMe[method-unbinding]
153
+ if (typeof destination.error === 'function') {
154
+ // $FlowFixMe: This is an Error object or the destination accepts other types.
155
+ destination.error(error);
156
+ } else {
157
+ // Earlier implementations doesn't support this method. In that environment you're
158
+ // supposed to throw from a promise returned but we don't return a promise in our
159
+ // approach. We could fork this implementation but this is environment is an edge
160
+ // case to begin with. It's even less common to run this in an older environment.
161
+ // Even then, this is not where errors are supposed to happen and they get reported
162
+ // to a global callback in addition to this anyway. So it's fine just to close this.
163
+ destination.close();
164
+ }
165
+ }
166
+
167
+ // This file is an intermediate layer to translate between Flight
168
+ var stringify = JSON.stringify;
169
+
170
+ function serializeRowHeader(tag, id) {
171
+ return id.toString(16) + ':' + tag;
172
+ }
173
+
174
+ function processErrorChunkProd(request, id, digest) {
175
+ {
176
+ // These errors should never make it into a build so we don't need to encode them in codes.json
177
+ // eslint-disable-next-line react-internal/prod-error-codes
178
+ throw new Error('processErrorChunkProd should never be called while in development mode. Use processErrorChunkDev instead. This is a bug in React.');
179
+ }
180
+
181
+ var errorInfo = {
182
+ digest: digest
183
+ };
184
+ var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
185
+ }
186
+ function processErrorChunkDev(request, id, digest, message, stack) {
187
+
188
+ var errorInfo = {
189
+ digest: digest,
190
+ message: message,
191
+ stack: stack
192
+ };
193
+ var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
194
+ return stringToChunk(row);
195
+ }
196
+ function processModelChunk(request, id, model) {
197
+ var json = stringify(model, request.toJSON);
198
+ var row = id.toString(16) + ':' + json + '\n';
199
+ return stringToChunk(row);
200
+ }
201
+ function processReferenceChunk(request, id, reference) {
202
+ var json = stringify(reference);
203
+ var row = id.toString(16) + ':' + json + '\n';
204
+ return stringToChunk(row);
205
+ }
206
+ function processModuleChunk(request, id, moduleMetaData) {
207
+ var json = stringify(moduleMetaData);
208
+ var row = serializeRowHeader('I', id) + json + '\n';
209
+ return stringToChunk(row);
210
+ }
211
+
212
+ // eslint-disable-next-line no-unused-vars
213
+ var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
214
+ function getClientReferenceKey(reference) {
215
+ return reference.filepath + '#' + reference.name + (reference.async ? '#async' : '');
216
+ }
217
+ function isClientReference(reference) {
218
+ return reference.$$typeof === CLIENT_REFERENCE_TAG;
219
+ }
220
+ function resolveModuleMetaData(config, clientReference) {
221
+ var resolvedModuleData = config[clientReference.filepath][clientReference.name];
222
+
223
+ if (clientReference.async) {
224
+ return {
225
+ id: resolvedModuleData.id,
226
+ chunks: resolvedModuleData.chunks,
227
+ name: resolvedModuleData.name,
228
+ async: true
229
+ };
230
+ } else {
231
+ return resolvedModuleData;
232
+ }
233
+ }
234
+
235
+ // ATTENTION
236
+ // When adding new symbols to this file,
237
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
238
+ // The Symbol used to tag the ReactElement-like types.
239
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
240
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
241
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
242
+ var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
243
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
244
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
245
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
246
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
247
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
248
+ var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
249
+ var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
250
+
251
+ // It is handled by React separately and shouldn't be written to the DOM.
252
+
253
+ var RESERVED = 0; // A simple string attribute.
254
+ // Attributes that aren't in the filter are presumed to have this type.
255
+
256
+ var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
257
+ // "enumerated" attributes with "true" and "false" as possible values.
258
+ // When true, it should be set to a "true" string.
259
+ // When false, it should be set to a "false" string.
260
+
261
+ var BOOLEANISH_STRING = 2; // A real boolean attribute.
262
+ // When true, it should be present (set either to an empty string or its name).
263
+ // When false, it should be omitted.
264
+
265
+ var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
266
+ // When true, it should be present (set either to an empty string or its name).
267
+ // When false, it should be omitted.
268
+ // For any other value, should be present with that value.
269
+
270
+ var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
271
+ // When falsy, it should be removed.
272
+
273
+ var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
274
+ // When falsy, it should be removed.
275
+
276
+ var POSITIVE_NUMERIC = 6;
277
+
278
+ function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
279
+ this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
280
+ this.attributeName = attributeName;
281
+ this.attributeNamespace = attributeNamespace;
282
+ this.mustUseProperty = mustUseProperty;
283
+ this.propertyName = name;
284
+ this.type = type;
285
+ this.sanitizeURL = sanitizeURL;
286
+ this.removeEmptyString = removeEmptyString;
287
+ } // When adding attributes to this list, be sure to also add them to
288
+ // the `possibleStandardNames` module to ensure casing and incorrect
289
+ // name warnings.
290
+
291
+
292
+ var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
293
+
294
+ var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
295
+ // elements (not just inputs). Now that ReactDOMInput assigns to the
296
+ // defaultValue property -- do we need this?
297
+ 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
298
+
299
+ reservedProps.forEach(function (name) {
300
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
301
+ properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
302
+ name, // attributeName
303
+ null, // attributeNamespace
304
+ false, // sanitizeURL
305
+ false);
306
+ }); // A few React string attributes have a different name.
307
+ // This is a mapping from React prop names to the attribute names.
308
+
309
+ [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
310
+ var name = _ref[0],
311
+ attributeName = _ref[1];
312
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
313
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
314
+ attributeName, // attributeName
315
+ null, // attributeNamespace
316
+ false, // sanitizeURL
317
+ false);
318
+ }); // These are "enumerated" HTML attributes that accept "true" and "false".
319
+ // In React, we let users pass `true` and `false` even though technically
320
+ // these aren't boolean attributes (they are coerced to strings).
321
+
322
+ ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
323
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
324
+ properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
325
+ name.toLowerCase(), // attributeName
326
+ null, // attributeNamespace
327
+ false, // sanitizeURL
328
+ false);
329
+ }); // These are "enumerated" SVG attributes that accept "true" and "false".
330
+ // In React, we let users pass `true` and `false` even though technically
331
+ // these aren't boolean attributes (they are coerced to strings).
332
+ // Since these are SVG attributes, their attribute names are case-sensitive.
333
+
334
+ ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
335
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
336
+ properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
337
+ name, // attributeName
338
+ null, // attributeNamespace
339
+ false, // sanitizeURL
340
+ false);
341
+ }); // These are HTML boolean attributes.
342
+
343
+ ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
344
+ // on the client side because the browsers are inconsistent. Instead we call focus().
345
+ 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
346
+ 'itemScope'].forEach(function (name) {
347
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
348
+ properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
349
+ name.toLowerCase(), // attributeName
350
+ null, // attributeNamespace
351
+ false, // sanitizeURL
352
+ false);
353
+ }); // These are the few React props that we set as DOM properties
354
+ // rather than attributes. These are all booleans.
355
+
356
+ ['checked', // Note: `option.selected` is not updated if `select.multiple` is
357
+ // disabled with `removeAttribute`. We have special logic for handling this.
358
+ 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
359
+ // you'll need to set attributeName to name.toLowerCase()
360
+ // instead in the assignment below.
361
+ ].forEach(function (name) {
362
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
363
+ properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
364
+ name, // attributeName
365
+ null, // attributeNamespace
366
+ false, // sanitizeURL
367
+ false);
368
+ }); // These are HTML attributes that are "overloaded booleans": they behave like
369
+ // booleans, but can also accept a string value.
370
+
371
+ ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
372
+ // you'll need to set attributeName to name.toLowerCase()
373
+ // instead in the assignment below.
374
+ ].forEach(function (name) {
375
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
376
+ properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
377
+ name, // attributeName
378
+ null, // attributeNamespace
379
+ false, // sanitizeURL
380
+ false);
381
+ }); // These are HTML attributes that must be positive numbers.
382
+
383
+ ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
384
+ // you'll need to set attributeName to name.toLowerCase()
385
+ // instead in the assignment below.
386
+ ].forEach(function (name) {
387
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
388
+ properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
389
+ name, // attributeName
390
+ null, // attributeNamespace
391
+ false, // sanitizeURL
392
+ false);
393
+ }); // These are HTML attributes that must be numbers.
394
+
395
+ ['rowSpan', 'start'].forEach(function (name) {
396
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
397
+ properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
398
+ name.toLowerCase(), // attributeName
399
+ null, // attributeNamespace
400
+ false, // sanitizeURL
401
+ false);
402
+ });
403
+ var CAMELIZE = /[\-\:]([a-z])/g;
404
+
405
+ var capitalize = function (token) {
406
+ return token[1].toUpperCase();
407
+ }; // This is a list of all SVG attributes that need special casing, namespacing,
408
+ // or boolean value assignment. Regular attributes that just accept strings
409
+ // and have the same names are omitted, just like in the HTML attribute filter.
410
+ // Some of these attributes can be hard to find. This list was created by
411
+ // scraping the MDN documentation.
412
+
413
+
414
+ ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height' // NOTE: if you add a camelCased prop to this list,
415
+ // you'll need to set attributeName to name.toLowerCase()
416
+ // instead in the assignment below.
417
+ ].forEach(function (attributeName) {
418
+ var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
419
+
420
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
421
+ attributeName, null, // attributeNamespace
422
+ false, // sanitizeURL
423
+ false);
424
+ }); // String SVG attributes with the xlink namespace.
425
+
426
+ ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
427
+ // you'll need to set attributeName to name.toLowerCase()
428
+ // instead in the assignment below.
429
+ ].forEach(function (attributeName) {
430
+ var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
431
+
432
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
433
+ attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
434
+ false);
435
+ }); // String SVG attributes with the xml namespace.
436
+
437
+ ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
438
+ // you'll need to set attributeName to name.toLowerCase()
439
+ // instead in the assignment below.
440
+ ].forEach(function (attributeName) {
441
+ var name = attributeName.replace(CAMELIZE, capitalize); // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
442
+
443
+ properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
444
+ attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
445
+ false);
446
+ }); // These attribute exists both in HTML and SVG.
447
+ // The attribute name is case-sensitive in SVG so we can't just use
448
+ // the React name like we do for attributes that exist only in HTML.
449
+
450
+ ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
451
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
452
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
453
+ attributeName.toLowerCase(), // attributeName
454
+ null, // attributeNamespace
455
+ false, // sanitizeURL
456
+ false);
457
+ }); // These attributes accept URLs. These must not allow javascript: URLS.
458
+ // These will also need to accept Trusted Types object in the future.
459
+
460
+ var xlinkHref = 'xlinkHref'; // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
461
+
462
+ properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
463
+ 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
464
+ false);
465
+ ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
466
+ // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
467
+ properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
468
+ attributeName.toLowerCase(), // attributeName
469
+ null, // attributeNamespace
470
+ true, // sanitizeURL
471
+ true);
472
+ });
473
+
474
+ /**
475
+ * CSS properties which accept numbers but are not in units of "px".
476
+ */
477
+ var isUnitlessNumber = {
478
+ animationIterationCount: true,
479
+ aspectRatio: true,
480
+ borderImageOutset: true,
481
+ borderImageSlice: true,
482
+ borderImageWidth: true,
483
+ boxFlex: true,
484
+ boxFlexGroup: true,
485
+ boxOrdinalGroup: true,
486
+ columnCount: true,
487
+ columns: true,
488
+ flex: true,
489
+ flexGrow: true,
490
+ flexPositive: true,
491
+ flexShrink: true,
492
+ flexNegative: true,
493
+ flexOrder: true,
494
+ gridArea: true,
495
+ gridRow: true,
496
+ gridRowEnd: true,
497
+ gridRowSpan: true,
498
+ gridRowStart: true,
499
+ gridColumn: true,
500
+ gridColumnEnd: true,
501
+ gridColumnSpan: true,
502
+ gridColumnStart: true,
503
+ fontWeight: true,
504
+ lineClamp: true,
505
+ lineHeight: true,
506
+ opacity: true,
507
+ order: true,
508
+ orphans: true,
509
+ tabSize: true,
510
+ widows: true,
511
+ zIndex: true,
512
+ zoom: true,
513
+ // SVG-related properties
514
+ fillOpacity: true,
515
+ floodOpacity: true,
516
+ stopOpacity: true,
517
+ strokeDasharray: true,
518
+ strokeDashoffset: true,
519
+ strokeMiterlimit: true,
520
+ strokeOpacity: true,
521
+ strokeWidth: true
522
+ };
523
+ /**
524
+ * @param {string} prefix vendor-specific prefix, eg: Webkit
525
+ * @param {string} key style name, eg: transitionDuration
526
+ * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
527
+ * WebkitTransitionDuration
528
+ */
529
+
530
+ function prefixKey(prefix, key) {
531
+ return prefix + key.charAt(0).toUpperCase() + key.substring(1);
532
+ }
533
+ /**
534
+ * Support style names that may come passed in prefixed by adding permutations
535
+ * of vendor prefixes.
536
+ */
537
+
538
+
539
+ var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
540
+ // infinite loop, because it iterates over the newly added props too.
541
+
542
+ Object.keys(isUnitlessNumber).forEach(function (prop) {
543
+ prefixes.forEach(function (prefix) {
544
+ isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
545
+ });
546
+ });
547
+
548
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
549
+
550
+ function isArray(a) {
551
+ return isArrayImpl(a);
552
+ }
553
+
554
+ // The build script is at scripts/rollup/generate-inline-fizz-runtime.js.
555
+ // Run `yarn generate-inline-fizz-runtime` to generate.
556
+ var clientRenderBoundary = '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};';
557
+ var completeBoundary = '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};';
558
+ var completeBoundaryWithStyles = '$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};';
559
+ var completeSegment = '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};';
560
+
561
+ var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
562
+
563
+ var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
564
+
565
+ var dataElementQuotedEnd = stringToPrecomputedChunk('"></template>');
566
+ var startInlineScript = stringToPrecomputedChunk('<script>');
567
+ var endInlineScript = stringToPrecomputedChunk('</script>');
568
+ var startScriptSrc = stringToPrecomputedChunk('<script src="');
569
+ var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
570
+ var scriptIntegirty = stringToPrecomputedChunk('" integrity="');
571
+ var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
572
+
573
+ var textSeparator = stringToPrecomputedChunk('<!-- -->');
574
+
575
+ var styleAttributeStart = stringToPrecomputedChunk(' style="');
576
+ var styleAssign = stringToPrecomputedChunk(':');
577
+ var styleSeparator = stringToPrecomputedChunk(';');
578
+
579
+ var attributeSeparator = stringToPrecomputedChunk(' ');
580
+ var attributeAssign = stringToPrecomputedChunk('="');
581
+ var attributeEnd = stringToPrecomputedChunk('"');
582
+ var attributeEmptyString = stringToPrecomputedChunk('=""');
583
+
584
+ var endOfStartTag = stringToPrecomputedChunk('>');
585
+ var endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
586
+
587
+ var selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
588
+
589
+ var leadingNewline = stringToPrecomputedChunk('\n');
590
+
591
+ var DOCTYPE = stringToPrecomputedChunk('<!DOCTYPE html>');
592
+ var endTag1 = stringToPrecomputedChunk('</');
593
+ var endTag2 = stringToPrecomputedChunk('>');
594
+ // A placeholder is a node inside a hidden partial tree that can be filled in later, but before
595
+ // display. It's never visible to users. We use the template tag because it can be used in every
596
+ // type of parent. <script> tags also work in every other tag except <colgroup>.
597
+
598
+ var placeholder1 = stringToPrecomputedChunk('<template id="');
599
+ var placeholder2 = stringToPrecomputedChunk('"></template>');
600
+
601
+ var startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
602
+ var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template id="');
603
+ var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
604
+ var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
605
+ var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
606
+ var clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk('<template');
607
+ var clientRenderedSuspenseBoundaryErrorAttrInterstitial = stringToPrecomputedChunk('"');
608
+ var clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk(' data-dgst="');
609
+ var clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk(' data-msg="');
610
+ var clientRenderedSuspenseBoundaryError1C = stringToPrecomputedChunk(' data-stck="');
611
+ var clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk('></template>');
612
+ var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
613
+ var startSegmentHTML2 = stringToPrecomputedChunk('">');
614
+ var endSegmentHTML = stringToPrecomputedChunk('</div>');
615
+ var startSegmentSVG = stringToPrecomputedChunk('<svg aria-hidden="true" style="display:none" id="');
616
+ var startSegmentSVG2 = stringToPrecomputedChunk('">');
617
+ var endSegmentSVG = stringToPrecomputedChunk('</svg>');
618
+ var startSegmentMathML = stringToPrecomputedChunk('<math aria-hidden="true" style="display:none" id="');
619
+ var startSegmentMathML2 = stringToPrecomputedChunk('">');
620
+ var endSegmentMathML = stringToPrecomputedChunk('</math>');
621
+ var startSegmentTable = stringToPrecomputedChunk('<table hidden id="');
622
+ var startSegmentTable2 = stringToPrecomputedChunk('">');
623
+ var endSegmentTable = stringToPrecomputedChunk('</table>');
624
+ var startSegmentTableBody = stringToPrecomputedChunk('<table hidden><tbody id="');
625
+ var startSegmentTableBody2 = stringToPrecomputedChunk('">');
626
+ var endSegmentTableBody = stringToPrecomputedChunk('</tbody></table>');
627
+ var startSegmentTableRow = stringToPrecomputedChunk('<table hidden><tr id="');
628
+ var startSegmentTableRow2 = stringToPrecomputedChunk('">');
629
+ var endSegmentTableRow = stringToPrecomputedChunk('</tr></table>');
630
+ var startSegmentColGroup = stringToPrecomputedChunk('<table hidden><colgroup id="');
631
+ var startSegmentColGroup2 = stringToPrecomputedChunk('">');
632
+ var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
633
+ var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegment + ';$RS("');
634
+ var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
635
+ var completeSegmentScript2 = stringToPrecomputedChunk('","');
636
+ var completeSegmentScriptEnd = stringToPrecomputedChunk('")</script>');
637
+ var completeSegmentData1 = stringToPrecomputedChunk('<template data-rsi="" data-sid="');
638
+ var completeSegmentData2 = stringToPrecomputedChunk('" data-pid="');
639
+ var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundary + ';$RC("');
640
+ var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("');
641
+ var completeBoundaryWithStylesScript1FullBoth = stringToPrecomputedChunk(completeBoundary + ';' + completeBoundaryWithStyles + ';$RR("');
642
+ var completeBoundaryWithStylesScript1FullPartial = stringToPrecomputedChunk(completeBoundaryWithStyles + ';$RR("');
643
+ var completeBoundaryWithStylesScript1Partial = stringToPrecomputedChunk('$RR("');
644
+ var completeBoundaryScript2 = stringToPrecomputedChunk('","');
645
+ var completeBoundaryScript3a = stringToPrecomputedChunk('",');
646
+ var completeBoundaryScript3b = stringToPrecomputedChunk('"');
647
+ var completeBoundaryScriptEnd = stringToPrecomputedChunk(')</script>');
648
+ var completeBoundaryData1 = stringToPrecomputedChunk('<template data-rci="" data-bid="');
649
+ var completeBoundaryWithStylesData1 = stringToPrecomputedChunk('<template data-rri="" data-bid="');
650
+ var completeBoundaryData2 = stringToPrecomputedChunk('" data-sid="');
651
+ var completeBoundaryData3a = stringToPrecomputedChunk('" data-sty="');
652
+ var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderBoundary + ';$RX("');
653
+ var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
654
+ var clientRenderScript1A = stringToPrecomputedChunk('"');
655
+ var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(',');
656
+ var clientRenderScriptEnd = stringToPrecomputedChunk(')</script>');
657
+ var clientRenderData1 = stringToPrecomputedChunk('<template data-rxi="" data-bid="');
658
+ var clientRenderData2 = stringToPrecomputedChunk('" data-dgst="');
659
+ var clientRenderData3 = stringToPrecomputedChunk('" data-msg="');
660
+ var clientRenderData4 = stringToPrecomputedChunk('" data-stck="');
661
+
662
+ var precedencePlaceholderStart = stringToPrecomputedChunk('<style data-precedence="');
663
+ var precedencePlaceholderEnd = stringToPrecomputedChunk('"></style>');
664
+
665
+ var arrayFirstOpenBracket = stringToPrecomputedChunk('[');
666
+ var arraySubsequentOpenBracket = stringToPrecomputedChunk(',[');
667
+ var arrayInterstitial = stringToPrecomputedChunk(',');
668
+ var arrayCloseBracket = stringToPrecomputedChunk(']'); // This function writes a 2D array of strings to be embedded in javascript.
669
+
670
+ var rendererSigil;
671
+
672
+ {
673
+ // Use this to detect multiple renderers using the same context
674
+ rendererSigil = {};
675
+ } // Used to store the parent path of all context overrides in a shared linked list.
676
+ // Forming a reverse tree.
677
+ // The structure of a context snapshot is an implementation of this file.
678
+ // Currently, it's implemented as tracking the current active node.
679
+
680
+
681
+ var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
682
+ // This global (actually thread local) state represents what state all those "current",
683
+ // fields are currently in.
684
+
685
+ var currentActiveSnapshot = null;
686
+
687
+ function popNode(prev) {
688
+ {
689
+ prev.context._currentValue = prev.parentValue;
690
+ }
691
+ }
692
+
693
+ function pushNode(next) {
694
+ {
695
+ next.context._currentValue = next.value;
696
+ }
697
+ }
698
+
699
+ function popToNearestCommonAncestor(prev, next) {
700
+ if (prev === next) ; else {
701
+ popNode(prev);
702
+ var parentPrev = prev.parent;
703
+ var parentNext = next.parent;
704
+
705
+ if (parentPrev === null) {
706
+ if (parentNext !== null) {
707
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
708
+ }
709
+ } else {
710
+ if (parentNext === null) {
711
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
712
+ }
713
+
714
+ popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
715
+
716
+ pushNode(next);
717
+ }
718
+ }
719
+ }
720
+
721
+ function popAllPrevious(prev) {
722
+ popNode(prev);
723
+ var parentPrev = prev.parent;
724
+
725
+ if (parentPrev !== null) {
726
+ popAllPrevious(parentPrev);
727
+ }
728
+ }
729
+
730
+ function pushAllNext(next) {
731
+ var parentNext = next.parent;
732
+
733
+ if (parentNext !== null) {
734
+ pushAllNext(parentNext);
735
+ }
736
+
737
+ pushNode(next);
738
+ }
739
+
740
+ function popPreviousToCommonLevel(prev, next) {
741
+ popNode(prev);
742
+ var parentPrev = prev.parent;
743
+
744
+ if (parentPrev === null) {
745
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
746
+ }
747
+
748
+ if (parentPrev.depth === next.depth) {
749
+ // We found the same level. Now we just need to find a shared ancestor.
750
+ popToNearestCommonAncestor(parentPrev, next);
751
+ } else {
752
+ // We must still be deeper.
753
+ popPreviousToCommonLevel(parentPrev, next);
754
+ }
755
+ }
756
+
757
+ function popNextToCommonLevel(prev, next) {
758
+ var parentNext = next.parent;
759
+
760
+ if (parentNext === null) {
761
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
762
+ }
763
+
764
+ if (prev.depth === parentNext.depth) {
765
+ // We found the same level. Now we just need to find a shared ancestor.
766
+ popToNearestCommonAncestor(prev, parentNext);
767
+ } else {
768
+ // We must still be deeper.
769
+ popNextToCommonLevel(prev, parentNext);
770
+ }
771
+
772
+ pushNode(next);
773
+ } // Perform context switching to the new snapshot.
774
+ // To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
775
+ // updating all the context's current values. That way reads, always just read the current value.
776
+ // At the cost of updating contexts even if they're never read by this subtree.
777
+
778
+
779
+ function switchContext(newSnapshot) {
780
+ // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
781
+ // We also need to update any new contexts that are now on the stack with the deepest value.
782
+ // The easiest way to update new contexts is to just reapply them in reverse order from the
783
+ // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
784
+ // for that. Therefore this algorithm is recursive.
785
+ // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
786
+ // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
787
+ // 3) Then we reapply new contexts on the way back up the stack.
788
+ var prev = currentActiveSnapshot;
789
+ var next = newSnapshot;
790
+
791
+ if (prev !== next) {
792
+ if (prev === null) {
793
+ // $FlowFixMe: This has to be non-null since it's not equal to prev.
794
+ pushAllNext(next);
795
+ } else if (next === null) {
796
+ popAllPrevious(prev);
797
+ } else if (prev.depth === next.depth) {
798
+ popToNearestCommonAncestor(prev, next);
799
+ } else if (prev.depth > next.depth) {
800
+ popPreviousToCommonLevel(prev, next);
801
+ } else {
802
+ popNextToCommonLevel(prev, next);
803
+ }
804
+
805
+ currentActiveSnapshot = next;
806
+ }
807
+ }
808
+ function pushProvider(context, nextValue) {
809
+ var prevValue;
810
+
811
+ {
812
+ prevValue = context._currentValue;
813
+ context._currentValue = nextValue;
814
+
815
+ {
816
+ if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
817
+ error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
818
+ }
819
+
820
+ context._currentRenderer = rendererSigil;
821
+ }
822
+ }
823
+
824
+ var prevNode = currentActiveSnapshot;
825
+ var newNode = {
826
+ parent: prevNode,
827
+ depth: prevNode === null ? 0 : prevNode.depth + 1,
828
+ context: context,
829
+ parentValue: prevValue,
830
+ value: nextValue
831
+ };
832
+ currentActiveSnapshot = newNode;
833
+ return newNode;
834
+ }
835
+ function popProvider() {
836
+ var prevSnapshot = currentActiveSnapshot;
837
+
838
+ if (prevSnapshot === null) {
839
+ throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.');
840
+ }
841
+
842
+ {
843
+ var value = prevSnapshot.parentValue;
844
+
845
+ if (value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
846
+ prevSnapshot.context._currentValue = prevSnapshot.context._defaultValue;
847
+ } else {
848
+ prevSnapshot.context._currentValue = value;
849
+ }
850
+ }
851
+
852
+ return currentActiveSnapshot = prevSnapshot.parent;
853
+ }
854
+ function getActiveContext() {
855
+ return currentActiveSnapshot;
856
+ }
857
+ function readContext(context) {
858
+ var value = context._currentValue ;
859
+ return value;
860
+ }
861
+
862
+ // Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
863
+ // changes to one module should be reflected in the others.
864
+ // TODO: Rename this module and the corresponding Fiber one to "Thenable"
865
+ // instead of "Wakeable". Or some other more appropriate name.
866
+ // An error that is thrown (e.g. by `use`) to trigger Suspense. If we
867
+ // detect this is caught by userspace, we'll log a warning in development.
868
+ var SuspenseException = new Error("Suspense Exception: This is not a real error! It's an implementation " + 'detail of `use` to interrupt the current render. You must either ' + 'rethrow it immediately, or move the `use` call outside of the ' + '`try/catch` block. Capturing without rethrowing will lead to ' + 'unexpected behavior.\n\n' + 'To handle async errors, wrap your component in an error boundary, or ' + "call the promise's `.catch` method and pass the result to `use`");
869
+ function createThenableState() {
870
+ // The ThenableState is created the first time a component suspends. If it
871
+ // suspends again, we'll reuse the same state.
872
+ return [];
873
+ }
874
+
875
+ function noop() {}
876
+
877
+ function trackUsedThenable(thenableState, thenable, index) {
878
+ var previous = thenableState[index];
879
+
880
+ if (previous === undefined) {
881
+ thenableState.push(thenable);
882
+ } else {
883
+ if (previous !== thenable) {
884
+ // Reuse the previous thenable, and drop the new one. We can assume
885
+ // they represent the same value, because components are idempotent.
886
+ // Avoid an unhandled rejection errors for the Promises that we'll
887
+ // intentionally ignore.
888
+ thenable.then(noop, noop);
889
+ thenable = previous;
890
+ }
891
+ } // We use an expando to track the status and result of a thenable so that we
892
+ // can synchronously unwrap the value. Think of this as an extension of the
893
+ // Promise API, or a custom interface that is a superset of Thenable.
894
+ //
895
+ // If the thenable doesn't have a status, set it to "pending" and attach
896
+ // a listener that will update its status and result when it resolves.
897
+
898
+
899
+ switch (thenable.status) {
900
+ case 'fulfilled':
901
+ {
902
+ var fulfilledValue = thenable.value;
903
+ return fulfilledValue;
904
+ }
905
+
906
+ case 'rejected':
907
+ {
908
+ var rejectedError = thenable.reason;
909
+ throw rejectedError;
910
+ }
911
+
912
+ default:
913
+ {
914
+ if (typeof thenable.status === 'string') ; else {
915
+ var pendingThenable = thenable;
916
+ pendingThenable.status = 'pending';
917
+ pendingThenable.then(function (fulfilledValue) {
918
+ if (thenable.status === 'pending') {
919
+ var fulfilledThenable = thenable;
920
+ fulfilledThenable.status = 'fulfilled';
921
+ fulfilledThenable.value = fulfilledValue;
922
+ }
923
+ }, function (error) {
924
+ if (thenable.status === 'pending') {
925
+ var rejectedThenable = thenable;
926
+ rejectedThenable.status = 'rejected';
927
+ rejectedThenable.reason = error;
928
+ }
929
+ }); // Check one more time in case the thenable resolved synchronously
930
+
931
+ switch (thenable.status) {
932
+ case 'fulfilled':
933
+ {
934
+ var fulfilledThenable = thenable;
935
+ return fulfilledThenable.value;
936
+ }
937
+
938
+ case 'rejected':
939
+ {
940
+ var rejectedThenable = thenable;
941
+ throw rejectedThenable.reason;
942
+ }
943
+ }
944
+ } // Suspend.
945
+ //
946
+ // Throwing here is an implementation detail that allows us to unwind the
947
+ // call stack. But we shouldn't allow it to leak into userspace. Throw an
948
+ // opaque placeholder value instead of the actual thenable. If it doesn't
949
+ // get captured by the work loop, log a warning, because that means
950
+ // something in userspace must have caught it.
951
+
952
+
953
+ suspendedThenable = thenable;
954
+ throw SuspenseException;
955
+ }
956
+ }
957
+ } // This is used to track the actual thenable that suspended so it can be
958
+ // passed to the rest of the Suspense implementation — which, for historical
959
+ // reasons, expects to receive a thenable.
960
+
961
+ var suspendedThenable = null;
962
+ function getSuspendedThenable() {
963
+ // This is called right after `use` suspends by throwing an exception. `use`
964
+ // throws an opaque value instead of the thenable itself so that it can't be
965
+ // caught in userspace. Then the work loop accesses the actual thenable using
966
+ // this function.
967
+ if (suspendedThenable === null) {
968
+ throw new Error('Expected a suspended thenable. This is a bug in React. Please file ' + 'an issue.');
969
+ }
970
+
971
+ var thenable = suspendedThenable;
972
+ suspendedThenable = null;
973
+ return thenable;
974
+ }
975
+
976
+ var currentRequest = null;
977
+ var thenableIndexCounter = 0;
978
+ var thenableState = null;
979
+ function prepareToUseHooksForRequest(request) {
980
+ currentRequest = request;
981
+ }
982
+ function resetHooksForRequest() {
983
+ currentRequest = null;
984
+ }
985
+ function prepareToUseHooksForComponent(prevThenableState) {
986
+ thenableIndexCounter = 0;
987
+ thenableState = prevThenableState;
988
+ }
989
+ function getThenableStateAfterSuspending() {
990
+ var state = thenableState;
991
+ thenableState = null;
992
+ return state;
993
+ }
994
+
995
+ function readContext$1(context) {
996
+ {
997
+ if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
998
+ if (isClientReference(context)) {
999
+ error('Cannot read a Client Context from a Server Component.');
1000
+ } else {
1001
+ error('Only createServerContext is supported in Server Components.');
1002
+ }
1003
+ }
1004
+
1005
+ if (currentRequest === null) {
1006
+ error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
1007
+ }
1008
+ }
1009
+
1010
+ return readContext(context);
1011
+ }
1012
+
1013
+ var HooksDispatcher = {
1014
+ useMemo: function (nextCreate) {
1015
+ return nextCreate();
1016
+ },
1017
+ useCallback: function (callback) {
1018
+ return callback;
1019
+ },
1020
+ useDebugValue: function () {},
1021
+ useDeferredValue: unsupportedHook,
1022
+ useTransition: unsupportedHook,
1023
+ readContext: readContext$1,
1024
+ useContext: readContext$1,
1025
+ useReducer: unsupportedHook,
1026
+ useRef: unsupportedHook,
1027
+ useState: unsupportedHook,
1028
+ useInsertionEffect: unsupportedHook,
1029
+ useLayoutEffect: unsupportedHook,
1030
+ useImperativeHandle: unsupportedHook,
1031
+ useEffect: unsupportedHook,
1032
+ useId: useId,
1033
+ useMutableSource: unsupportedHook,
1034
+ useSyncExternalStore: unsupportedHook,
1035
+ useCacheRefresh: function () {
1036
+ return unsupportedRefresh;
1037
+ },
1038
+ useMemoCache: function (size) {
1039
+ var data = new Array(size);
1040
+
1041
+ for (var i = 0; i < size; i++) {
1042
+ data[i] = REACT_MEMO_CACHE_SENTINEL;
1043
+ }
1044
+
1045
+ return data;
1046
+ },
1047
+ use: use
1048
+ };
1049
+
1050
+ function unsupportedHook() {
1051
+ throw new Error('This Hook is not supported in Server Components.');
1052
+ }
1053
+
1054
+ function unsupportedRefresh() {
1055
+ throw new Error('Refreshing the cache is not supported in Server Components.');
1056
+ }
1057
+
1058
+ function useId() {
1059
+ if (currentRequest === null) {
1060
+ throw new Error('useId can only be used while React is rendering');
1061
+ }
1062
+
1063
+ var id = currentRequest.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
1064
+
1065
+ return ':' + currentRequest.identifierPrefix + 'S' + id.toString(32) + ':';
1066
+ }
1067
+
1068
+ function use(usable) {
1069
+ if (usable !== null && typeof usable === 'object' || typeof usable === 'function') {
1070
+ // $FlowFixMe[method-unbinding]
1071
+ if (typeof usable.then === 'function') {
1072
+ // This is a thenable.
1073
+ var thenable = usable; // Track the position of the thenable within this fiber.
1074
+
1075
+ var index = thenableIndexCounter;
1076
+ thenableIndexCounter += 1;
1077
+
1078
+ if (thenableState === null) {
1079
+ thenableState = createThenableState();
1080
+ }
1081
+
1082
+ return trackUsedThenable(thenableState, thenable, index);
1083
+ } else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
1084
+ var context = usable;
1085
+ return readContext$1(context);
1086
+ }
1087
+ }
1088
+
1089
+ {
1090
+ if (isClientReference(usable)) {
1091
+ error('Cannot use() an already resolved Client Reference.');
1092
+ }
1093
+ } // eslint-disable-next-line react-internal/safe-string-coercion
1094
+
1095
+
1096
+ throw new Error('An unsupported type was passed to use(): ' + String(usable));
1097
+ }
1098
+
1099
+ function createSignal() {
1100
+ return new AbortController().signal;
1101
+ }
1102
+
1103
+ function resolveCache() {
1104
+ if (currentCache) return currentCache;
1105
+
1106
+ if (supportsRequestStorage) {
1107
+ var cache = requestStorage.getStore();
1108
+ if (cache) return cache;
1109
+ } // Since we override the dispatcher all the time, we're effectively always
1110
+ // active and so to support cache() and fetch() outside of render, we yield
1111
+ // an empty Map.
1112
+
1113
+
1114
+ return new Map();
1115
+ }
1116
+
1117
+ var DefaultCacheDispatcher = {
1118
+ getCacheSignal: function () {
1119
+ var cache = resolveCache();
1120
+ var entry = cache.get(createSignal);
1121
+
1122
+ if (entry === undefined) {
1123
+ entry = createSignal();
1124
+ cache.set(createSignal, entry);
1125
+ }
1126
+
1127
+ return entry;
1128
+ },
1129
+ getCacheForType: function (resourceType) {
1130
+ var cache = resolveCache();
1131
+ var entry = cache.get(resourceType);
1132
+
1133
+ if (entry === undefined) {
1134
+ entry = resourceType(); // TODO: Warn if undefined?
1135
+
1136
+ cache.set(resourceType, entry);
1137
+ }
1138
+
1139
+ return entry;
1140
+ }
1141
+ };
1142
+ var currentCache = null;
1143
+ function setCurrentCache(cache) {
1144
+ currentCache = cache;
1145
+ return currentCache;
1146
+ }
1147
+ function getCurrentCache() {
1148
+ return currentCache;
1149
+ }
1150
+
1151
+ var ContextRegistry = ReactSharedInternals.ContextRegistry;
1152
+ function getOrCreateServerContext(globalName) {
1153
+ if (!ContextRegistry[globalName]) {
1154
+ ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe function signature doesn't reflect the symbol value
1155
+ REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
1156
+ }
1157
+
1158
+ return ContextRegistry[globalName];
1159
+ }
1160
+
1161
+ var PENDING = 0;
1162
+ var COMPLETED = 1;
1163
+ var ABORTED = 3;
1164
+ var ERRORED = 4;
1165
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
1166
+ var ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
1167
+
1168
+ function defaultErrorHandler(error) {
1169
+ console['error'](error); // Don't transform to our wrapper
1170
+ }
1171
+
1172
+ var OPEN = 0;
1173
+ var CLOSING = 1;
1174
+ var CLOSED = 2;
1175
+ function createRequest(model, bundlerConfig, onError, context, identifierPrefix) {
1176
+ if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1177
+ throw new Error('Currently React only supports one RSC renderer at a time.');
1178
+ }
1179
+
1180
+ ReactCurrentCache.current = DefaultCacheDispatcher;
1181
+ var abortSet = new Set();
1182
+ var pingedTasks = [];
1183
+ var request = {
1184
+ status: OPEN,
1185
+ fatalError: null,
1186
+ destination: null,
1187
+ bundlerConfig: bundlerConfig,
1188
+ cache: new Map(),
1189
+ nextChunkId: 0,
1190
+ pendingChunks: 0,
1191
+ abortableTasks: abortSet,
1192
+ pingedTasks: pingedTasks,
1193
+ completedModuleChunks: [],
1194
+ completedJSONChunks: [],
1195
+ completedErrorChunks: [],
1196
+ writtenSymbols: new Map(),
1197
+ writtenModules: new Map(),
1198
+ writtenProviders: new Map(),
1199
+ identifierPrefix: identifierPrefix || '',
1200
+ identifierCount: 1,
1201
+ onError: onError === undefined ? defaultErrorHandler : onError,
1202
+ // $FlowFixMe[missing-this-annot]
1203
+ toJSON: function (key, value) {
1204
+ return resolveModelToJSON(request, this, key, value);
1205
+ }
1206
+ };
1207
+ request.pendingChunks++;
1208
+ var rootContext = createRootContext(context);
1209
+ var rootTask = createTask(request, model, rootContext, abortSet);
1210
+ pingedTasks.push(rootTask);
1211
+ return request;
1212
+ }
1213
+
1214
+ function createRootContext(reqContext) {
1215
+ return importServerContexts(reqContext);
1216
+ }
1217
+
1218
+ var POP = {}; // Used for DEV messages to keep track of which parent rendered some props,
1219
+ // in case they error.
1220
+
1221
+ var jsxPropsParents = new WeakMap();
1222
+ var jsxChildrenParents = new WeakMap();
1223
+
1224
+ function serializeThenable(request, thenable) {
1225
+ request.pendingChunks++;
1226
+ var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
1227
+
1228
+ switch (thenable.status) {
1229
+ case 'fulfilled':
1230
+ {
1231
+ // We have the resolved value, we can go ahead and schedule it for serialization.
1232
+ newTask.model = thenable.value;
1233
+ pingTask(request, newTask);
1234
+ return newTask.id;
1235
+ }
1236
+
1237
+ case 'rejected':
1238
+ {
1239
+ var x = thenable.reason;
1240
+ var digest = logRecoverableError(request, x);
1241
+
1242
+ {
1243
+ var _getErrorMessageAndSt = getErrorMessageAndStackDev(x),
1244
+ message = _getErrorMessageAndSt.message,
1245
+ stack = _getErrorMessageAndSt.stack;
1246
+
1247
+ emitErrorChunkDev(request, newTask.id, digest, message, stack);
1248
+ }
1249
+
1250
+ return newTask.id;
1251
+ }
1252
+
1253
+ default:
1254
+ {
1255
+ if (typeof thenable.status === 'string') {
1256
+ // Only instrument the thenable if the status if not defined. If
1257
+ // it's defined, but an unknown value, assume it's been instrumented by
1258
+ // some custom userspace implementation. We treat it as "pending".
1259
+ break;
1260
+ }
1261
+
1262
+ var pendingThenable = thenable;
1263
+ pendingThenable.status = 'pending';
1264
+ pendingThenable.then(function (fulfilledValue) {
1265
+ if (thenable.status === 'pending') {
1266
+ var fulfilledThenable = thenable;
1267
+ fulfilledThenable.status = 'fulfilled';
1268
+ fulfilledThenable.value = fulfilledValue;
1269
+ }
1270
+ }, function (error) {
1271
+ if (thenable.status === 'pending') {
1272
+ var rejectedThenable = thenable;
1273
+ rejectedThenable.status = 'rejected';
1274
+ rejectedThenable.reason = error;
1275
+ }
1276
+ });
1277
+ break;
1278
+ }
1279
+ }
1280
+
1281
+ thenable.then(function (value) {
1282
+ newTask.model = value;
1283
+ pingTask(request, newTask);
1284
+ }, function (reason) {
1285
+ // TODO: Is it safe to directly emit these without being inside a retry?
1286
+ var digest = logRecoverableError(request, reason);
1287
+
1288
+ {
1289
+ var _getErrorMessageAndSt2 = getErrorMessageAndStackDev(reason),
1290
+ _message = _getErrorMessageAndSt2.message,
1291
+ _stack = _getErrorMessageAndSt2.stack;
1292
+
1293
+ emitErrorChunkDev(request, newTask.id, digest, _message, _stack);
1294
+ }
1295
+ });
1296
+ return newTask.id;
1297
+ }
1298
+
1299
+ function readThenable(thenable) {
1300
+ if (thenable.status === 'fulfilled') {
1301
+ return thenable.value;
1302
+ } else if (thenable.status === 'rejected') {
1303
+ throw thenable.reason;
1304
+ }
1305
+
1306
+ throw thenable;
1307
+ }
1308
+
1309
+ function createLazyWrapperAroundWakeable(wakeable) {
1310
+ // This is a temporary fork of the `use` implementation until we accept
1311
+ // promises everywhere.
1312
+ var thenable = wakeable;
1313
+
1314
+ switch (thenable.status) {
1315
+ case 'fulfilled':
1316
+ case 'rejected':
1317
+ break;
1318
+
1319
+ default:
1320
+ {
1321
+ if (typeof thenable.status === 'string') {
1322
+ // Only instrument the thenable if the status if not defined. If
1323
+ // it's defined, but an unknown value, assume it's been instrumented by
1324
+ // some custom userspace implementation. We treat it as "pending".
1325
+ break;
1326
+ }
1327
+
1328
+ var pendingThenable = thenable;
1329
+ pendingThenable.status = 'pending';
1330
+ pendingThenable.then(function (fulfilledValue) {
1331
+ if (thenable.status === 'pending') {
1332
+ var fulfilledThenable = thenable;
1333
+ fulfilledThenable.status = 'fulfilled';
1334
+ fulfilledThenable.value = fulfilledValue;
1335
+ }
1336
+ }, function (error) {
1337
+ if (thenable.status === 'pending') {
1338
+ var rejectedThenable = thenable;
1339
+ rejectedThenable.status = 'rejected';
1340
+ rejectedThenable.reason = error;
1341
+ }
1342
+ });
1343
+ break;
1344
+ }
1345
+ }
1346
+
1347
+ var lazyType = {
1348
+ $$typeof: REACT_LAZY_TYPE,
1349
+ _payload: thenable,
1350
+ _init: readThenable
1351
+ };
1352
+ return lazyType;
1353
+ }
1354
+
1355
+ function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
1356
+ if (ref !== null && ref !== undefined) {
1357
+ // When the ref moves to the regular props object this will implicitly
1358
+ // throw for functions. We could probably relax it to a DEV warning for other
1359
+ // cases.
1360
+ throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
1361
+ }
1362
+
1363
+ {
1364
+ jsxPropsParents.set(props, type);
1365
+
1366
+ if (typeof props.children === 'object' && props.children !== null) {
1367
+ jsxChildrenParents.set(props.children, type);
1368
+ }
1369
+ }
1370
+
1371
+ if (typeof type === 'function') {
1372
+ if (isClientReference(type)) {
1373
+ // This is a reference to a Client Component.
1374
+ return [REACT_ELEMENT_TYPE, type, key, props];
1375
+ } // This is a server-side component.
1376
+
1377
+
1378
+ prepareToUseHooksForComponent(prevThenableState);
1379
+ var result = type(props);
1380
+
1381
+ if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1382
+ // When the return value is in children position we can resolve it immediately,
1383
+ // to its value without a wrapper if it's synchronously available.
1384
+ var thenable = result;
1385
+
1386
+ if (thenable.status === 'fulfilled') {
1387
+ return thenable.value;
1388
+ } // TODO: Once we accept Promises as children on the client, we can just return
1389
+ // the thenable here.
1390
+
1391
+
1392
+ return createLazyWrapperAroundWakeable(result);
1393
+ }
1394
+
1395
+ return result;
1396
+ } else if (typeof type === 'string') {
1397
+ // This is a host element. E.g. HTML.
1398
+ return [REACT_ELEMENT_TYPE, type, key, props];
1399
+ } else if (typeof type === 'symbol') {
1400
+ if (type === REACT_FRAGMENT_TYPE) {
1401
+ // For key-less fragments, we add a small optimization to avoid serializing
1402
+ // it as a wrapper.
1403
+ // TODO: If a key is specified, we should propagate its key to any children.
1404
+ // Same as if a Server Component has a key.
1405
+ return props.children;
1406
+ } // This might be a built-in React component. We'll let the client decide.
1407
+ // Any built-in works as long as its props are serializable.
1408
+
1409
+
1410
+ return [REACT_ELEMENT_TYPE, type, key, props];
1411
+ } else if (type != null && typeof type === 'object') {
1412
+ if (isClientReference(type)) {
1413
+ // This is a reference to a Client Component.
1414
+ return [REACT_ELEMENT_TYPE, type, key, props];
1415
+ }
1416
+
1417
+ switch (type.$$typeof) {
1418
+ case REACT_LAZY_TYPE:
1419
+ {
1420
+ var payload = type._payload;
1421
+ var init = type._init;
1422
+ var wrappedType = init(payload);
1423
+ return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
1424
+ }
1425
+
1426
+ case REACT_FORWARD_REF_TYPE:
1427
+ {
1428
+ var render = type.render;
1429
+ prepareToUseHooksForComponent(prevThenableState);
1430
+ return render(props, undefined);
1431
+ }
1432
+
1433
+ case REACT_MEMO_TYPE:
1434
+ {
1435
+ return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
1436
+ }
1437
+
1438
+ case REACT_PROVIDER_TYPE:
1439
+ {
1440
+ pushProvider(type._context, props.value);
1441
+
1442
+ {
1443
+ var extraKeys = Object.keys(props).filter(function (value) {
1444
+ if (value === 'children' || value === 'value') {
1445
+ return false;
1446
+ }
1447
+
1448
+ return true;
1449
+ });
1450
+
1451
+ if (extraKeys.length !== 0) {
1452
+ error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
1453
+ }
1454
+ }
1455
+
1456
+ return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
1457
+ {
1458
+ value: props.value,
1459
+ children: props.children,
1460
+ __pop: POP
1461
+ }];
1462
+ }
1463
+ }
1464
+ }
1465
+
1466
+ throw new Error("Unsupported Server Component type: " + describeValueForErrorMessage(type));
1467
+ }
1468
+
1469
+ function pingTask(request, task) {
1470
+ var pingedTasks = request.pingedTasks;
1471
+ pingedTasks.push(task);
1472
+
1473
+ if (pingedTasks.length === 1) {
1474
+ scheduleWork(function () {
1475
+ return performWork(request);
1476
+ });
1477
+ }
1478
+ }
1479
+
1480
+ function createTask(request, model, context, abortSet) {
1481
+ var id = request.nextChunkId++;
1482
+ var task = {
1483
+ id: id,
1484
+ status: PENDING,
1485
+ model: model,
1486
+ context: context,
1487
+ ping: function () {
1488
+ return pingTask(request, task);
1489
+ },
1490
+ thenableState: null
1491
+ };
1492
+ abortSet.add(task);
1493
+ return task;
1494
+ }
1495
+
1496
+ function serializeByValueID(id) {
1497
+ return '$' + id.toString(16);
1498
+ }
1499
+
1500
+ function serializeLazyID(id) {
1501
+ return '$L' + id.toString(16);
1502
+ }
1503
+
1504
+ function serializePromiseID(id) {
1505
+ return '$@' + id.toString(16);
1506
+ }
1507
+
1508
+ function serializeSymbolReference(name) {
1509
+ return '$S' + name;
1510
+ }
1511
+
1512
+ function serializeProviderReference(name) {
1513
+ return '$P' + name;
1514
+ }
1515
+
1516
+ function serializeClientReference(request, parent, key, moduleReference) {
1517
+ var moduleKey = getClientReferenceKey(moduleReference);
1518
+ var writtenModules = request.writtenModules;
1519
+ var existingId = writtenModules.get(moduleKey);
1520
+
1521
+ if (existingId !== undefined) {
1522
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1523
+ // If we're encoding the "type" of an element, we can refer
1524
+ // to that by a lazy reference instead of directly since React
1525
+ // knows how to deal with lazy values. This lets us suspend
1526
+ // on this component rather than its parent until the code has
1527
+ // loaded.
1528
+ return serializeLazyID(existingId);
1529
+ }
1530
+
1531
+ return serializeByValueID(existingId);
1532
+ }
1533
+
1534
+ try {
1535
+ var moduleMetaData = resolveModuleMetaData(request.bundlerConfig, moduleReference);
1536
+ request.pendingChunks++;
1537
+ var moduleId = request.nextChunkId++;
1538
+ emitModuleChunk(request, moduleId, moduleMetaData);
1539
+ writtenModules.set(moduleKey, moduleId);
1540
+
1541
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1542
+ // If we're encoding the "type" of an element, we can refer
1543
+ // to that by a lazy reference instead of directly since React
1544
+ // knows how to deal with lazy values. This lets us suspend
1545
+ // on this component rather than its parent until the code has
1546
+ // loaded.
1547
+ return serializeLazyID(moduleId);
1548
+ }
1549
+
1550
+ return serializeByValueID(moduleId);
1551
+ } catch (x) {
1552
+ request.pendingChunks++;
1553
+ var errorId = request.nextChunkId++;
1554
+ var digest = logRecoverableError(request, x);
1555
+
1556
+ {
1557
+ var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
1558
+ message = _getErrorMessageAndSt3.message,
1559
+ stack = _getErrorMessageAndSt3.stack;
1560
+
1561
+ emitErrorChunkDev(request, errorId, digest, message, stack);
1562
+ }
1563
+
1564
+ return serializeByValueID(errorId);
1565
+ }
1566
+ }
1567
+
1568
+ function escapeStringValue(value) {
1569
+ if (value[0] === '$') {
1570
+ // We need to escape $ or @ prefixed strings since we use those to encode
1571
+ // references to IDs and as special symbol values.
1572
+ return '$' + value;
1573
+ } else {
1574
+ return value;
1575
+ }
1576
+ }
1577
+
1578
+ function isObjectPrototype(object) {
1579
+ if (!object) {
1580
+ return false;
1581
+ }
1582
+
1583
+ var ObjectPrototype = Object.prototype;
1584
+
1585
+ if (object === ObjectPrototype) {
1586
+ return true;
1587
+ } // It might be an object from a different Realm which is
1588
+ // still just a plain simple object.
1589
+
1590
+
1591
+ if (Object.getPrototypeOf(object)) {
1592
+ return false;
1593
+ }
1594
+
1595
+ var names = Object.getOwnPropertyNames(object);
1596
+
1597
+ for (var i = 0; i < names.length; i++) {
1598
+ if (!(names[i] in ObjectPrototype)) {
1599
+ return false;
1600
+ }
1601
+ }
1602
+
1603
+ return true;
1604
+ }
1605
+
1606
+ function isSimpleObject(object) {
1607
+ if (!isObjectPrototype(Object.getPrototypeOf(object))) {
1608
+ return false;
1609
+ }
1610
+
1611
+ var names = Object.getOwnPropertyNames(object);
1612
+
1613
+ for (var i = 0; i < names.length; i++) {
1614
+ var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
1615
+
1616
+ if (!descriptor) {
1617
+ return false;
1618
+ }
1619
+
1620
+ if (!descriptor.enumerable) {
1621
+ if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
1622
+ // React adds key and ref getters to props objects to issue warnings.
1623
+ // Those getters will not be transferred to the client, but that's ok,
1624
+ // so we'll special case them.
1625
+ continue;
1626
+ }
1627
+
1628
+ return false;
1629
+ }
1630
+ }
1631
+
1632
+ return true;
1633
+ }
1634
+
1635
+ function objectName(object) {
1636
+ // $FlowFixMe[method-unbinding]
1637
+ var name = Object.prototype.toString.call(object);
1638
+ return name.replace(/^\[object (.*)\]$/, function (m, p0) {
1639
+ return p0;
1640
+ });
1641
+ }
1642
+
1643
+ function describeKeyForErrorMessage(key) {
1644
+ var encodedKey = JSON.stringify(key);
1645
+ return '"' + key + '"' === encodedKey ? key : encodedKey;
1646
+ }
1647
+
1648
+ function describeValueForErrorMessage(value) {
1649
+ switch (typeof value) {
1650
+ case 'string':
1651
+ {
1652
+ return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
1653
+ }
1654
+
1655
+ case 'object':
1656
+ {
1657
+ if (isArray(value)) {
1658
+ return '[...]';
1659
+ }
1660
+
1661
+ var name = objectName(value);
1662
+
1663
+ if (name === 'Object') {
1664
+ return '{...}';
1665
+ }
1666
+
1667
+ return name;
1668
+ }
1669
+
1670
+ case 'function':
1671
+ return 'function';
1672
+
1673
+ default:
1674
+ // eslint-disable-next-line react-internal/safe-string-coercion
1675
+ return String(value);
1676
+ }
1677
+ }
1678
+
1679
+ function describeElementType(type) {
1680
+ if (typeof type === 'string') {
1681
+ return type;
1682
+ }
1683
+
1684
+ switch (type) {
1685
+ case REACT_SUSPENSE_TYPE:
1686
+ return 'Suspense';
1687
+
1688
+ case REACT_SUSPENSE_LIST_TYPE:
1689
+ return 'SuspenseList';
1690
+ }
1691
+
1692
+ if (typeof type === 'object') {
1693
+ switch (type.$$typeof) {
1694
+ case REACT_FORWARD_REF_TYPE:
1695
+ return describeElementType(type.render);
1696
+
1697
+ case REACT_MEMO_TYPE:
1698
+ return describeElementType(type.type);
1699
+
1700
+ case REACT_LAZY_TYPE:
1701
+ {
1702
+ var lazyComponent = type;
1703
+ var payload = lazyComponent._payload;
1704
+ var init = lazyComponent._init;
1705
+
1706
+ try {
1707
+ // Lazy may contain any component type so we recursively resolve it.
1708
+ return describeElementType(init(payload));
1709
+ } catch (x) {}
1710
+ }
1711
+ }
1712
+ }
1713
+
1714
+ return '';
1715
+ }
1716
+
1717
+ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1718
+ var objKind = objectName(objectOrArray);
1719
+
1720
+ if (objKind !== 'Object' && objKind !== 'Array') {
1721
+ return objKind;
1722
+ }
1723
+
1724
+ var str = '';
1725
+ var start = -1;
1726
+ var length = 0;
1727
+
1728
+ if (isArray(objectOrArray)) {
1729
+ if ( jsxChildrenParents.has(objectOrArray)) {
1730
+ // Print JSX Children
1731
+ var type = jsxChildrenParents.get(objectOrArray);
1732
+ str = '<' + describeElementType(type) + '>';
1733
+ var array = objectOrArray;
1734
+
1735
+ for (var i = 0; i < array.length; i++) {
1736
+ var value = array[i];
1737
+ var substr = void 0;
1738
+
1739
+ if (typeof value === 'string') {
1740
+ substr = value;
1741
+ } else if (typeof value === 'object' && value !== null) {
1742
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
1743
+ substr = '{' + describeObjectForErrorMessage(value) + '}';
1744
+ } else {
1745
+ substr = '{' + describeValueForErrorMessage(value) + '}';
1746
+ }
1747
+
1748
+ if ('' + i === expandedName) {
1749
+ start = str.length;
1750
+ length = substr.length;
1751
+ str += substr;
1752
+ } else if (substr.length < 15 && str.length + substr.length < 40) {
1753
+ str += substr;
1754
+ } else {
1755
+ str += '{...}';
1756
+ }
1757
+ }
1758
+
1759
+ str += '</' + describeElementType(type) + '>';
1760
+ } else {
1761
+ // Print Array
1762
+ str = '[';
1763
+ var _array = objectOrArray;
1764
+
1765
+ for (var _i = 0; _i < _array.length; _i++) {
1766
+ if (_i > 0) {
1767
+ str += ', ';
1768
+ }
1769
+
1770
+ var _value = _array[_i];
1771
+
1772
+ var _substr = void 0;
1773
+
1774
+ if (typeof _value === 'object' && _value !== null) {
1775
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
1776
+ _substr = describeObjectForErrorMessage(_value);
1777
+ } else {
1778
+ _substr = describeValueForErrorMessage(_value);
1779
+ }
1780
+
1781
+ if ('' + _i === expandedName) {
1782
+ start = str.length;
1783
+ length = _substr.length;
1784
+ str += _substr;
1785
+ } else if (_substr.length < 10 && str.length + _substr.length < 40) {
1786
+ str += _substr;
1787
+ } else {
1788
+ str += '...';
1789
+ }
1790
+ }
1791
+
1792
+ str += ']';
1793
+ }
1794
+ } else {
1795
+ if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
1796
+ str = '<' + describeElementType(objectOrArray.type) + '/>';
1797
+ } else if ( jsxPropsParents.has(objectOrArray)) {
1798
+ // Print JSX
1799
+ var _type = jsxPropsParents.get(objectOrArray);
1800
+
1801
+ str = '<' + (describeElementType(_type) || '...');
1802
+ var object = objectOrArray;
1803
+ var names = Object.keys(object);
1804
+
1805
+ for (var _i2 = 0; _i2 < names.length; _i2++) {
1806
+ str += ' ';
1807
+ var name = names[_i2];
1808
+ str += describeKeyForErrorMessage(name) + '=';
1809
+ var _value2 = object[name];
1810
+
1811
+ var _substr2 = void 0;
1812
+
1813
+ if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
1814
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
1815
+ _substr2 = describeObjectForErrorMessage(_value2);
1816
+ } else {
1817
+ _substr2 = describeValueForErrorMessage(_value2);
1818
+ }
1819
+
1820
+ if (typeof _value2 !== 'string') {
1821
+ _substr2 = '{' + _substr2 + '}';
1822
+ }
1823
+
1824
+ if (name === expandedName) {
1825
+ start = str.length;
1826
+ length = _substr2.length;
1827
+ str += _substr2;
1828
+ } else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
1829
+ str += _substr2;
1830
+ } else {
1831
+ str += '...';
1832
+ }
1833
+ }
1834
+
1835
+ str += '>';
1836
+ } else {
1837
+ // Print Object
1838
+ str = '{';
1839
+ var _object = objectOrArray;
1840
+
1841
+ var _names = Object.keys(_object);
1842
+
1843
+ for (var _i3 = 0; _i3 < _names.length; _i3++) {
1844
+ if (_i3 > 0) {
1845
+ str += ', ';
1846
+ }
1847
+
1848
+ var _name = _names[_i3];
1849
+ str += describeKeyForErrorMessage(_name) + ': ';
1850
+ var _value3 = _object[_name];
1851
+
1852
+ var _substr3 = void 0;
1853
+
1854
+ if (typeof _value3 === 'object' && _value3 !== null) {
1855
+ // $FlowFixMe[incompatible-call] found when upgrading Flow
1856
+ _substr3 = describeObjectForErrorMessage(_value3);
1857
+ } else {
1858
+ _substr3 = describeValueForErrorMessage(_value3);
1859
+ }
1860
+
1861
+ if (_name === expandedName) {
1862
+ start = str.length;
1863
+ length = _substr3.length;
1864
+ str += _substr3;
1865
+ } else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
1866
+ str += _substr3;
1867
+ } else {
1868
+ str += '...';
1869
+ }
1870
+ }
1871
+
1872
+ str += '}';
1873
+ }
1874
+ }
1875
+
1876
+ if (expandedName === undefined) {
1877
+ return str;
1878
+ }
1879
+
1880
+ if (start > -1 && length > 0) {
1881
+ var highlight = ' '.repeat(start) + '^'.repeat(length);
1882
+ return '\n ' + str + '\n ' + highlight;
1883
+ }
1884
+
1885
+ return '\n ' + str;
1886
+ }
1887
+
1888
+ var insideContextProps = null;
1889
+ var isInsideContextValue = false;
1890
+ function resolveModelToJSON(request, parent, key, value) {
1891
+ {
1892
+ // $FlowFixMe
1893
+ var originalValue = parent[key];
1894
+
1895
+ if (typeof originalValue === 'object' && originalValue !== value) {
1896
+ if (objectName(originalValue) !== 'Object') {
1897
+ var jsxParentType = jsxChildrenParents.get(parent);
1898
+
1899
+ if (typeof jsxParentType === 'string') {
1900
+ error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
1901
+ } else {
1902
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
1903
+ }
1904
+ } else {
1905
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
1906
+ }
1907
+ }
1908
+ } // Special Symbols
1909
+
1910
+
1911
+ switch (value) {
1912
+ case REACT_ELEMENT_TYPE:
1913
+ return '$';
1914
+ }
1915
+
1916
+ {
1917
+ if (parent[0] === REACT_ELEMENT_TYPE && parent[1] && parent[1].$$typeof === REACT_PROVIDER_TYPE && key === '3') {
1918
+ insideContextProps = value;
1919
+ } else if (insideContextProps === parent && key === 'value') {
1920
+ isInsideContextValue = true;
1921
+ } else if (insideContextProps === parent && key === 'children') {
1922
+ isInsideContextValue = false;
1923
+ }
1924
+ } // Resolve Server Components.
1925
+
1926
+
1927
+ while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
1928
+ {
1929
+ if (isInsideContextValue) {
1930
+ error('React elements are not allowed in ServerContext');
1931
+ }
1932
+ }
1933
+
1934
+ try {
1935
+ switch (value.$$typeof) {
1936
+ case REACT_ELEMENT_TYPE:
1937
+ {
1938
+ // TODO: Concatenate keys of parents onto children.
1939
+ var element = value; // Attempt to render the Server Component.
1940
+
1941
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
1942
+ break;
1943
+ }
1944
+
1945
+ case REACT_LAZY_TYPE:
1946
+ {
1947
+ var payload = value._payload;
1948
+ var init = value._init;
1949
+ value = init(payload);
1950
+ break;
1951
+ }
1952
+ }
1953
+ } catch (thrownValue) {
1954
+ var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
1955
+ // reasons, the rest of the Suspense implementation expects the thrown
1956
+ // value to be a thenable, because before `use` existed that was the
1957
+ // (unstable) API for suspending. This implementation detail can change
1958
+ // later, once we deprecate the old API in favor of `use`.
1959
+ getSuspendedThenable() : thrownValue; // $FlowFixMe[method-unbinding]
1960
+
1961
+ if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
1962
+ // Something suspended, we'll need to create a new task and resolve it later.
1963
+ request.pendingChunks++;
1964
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
1965
+ var ping = newTask.ping;
1966
+ x.then(ping, ping);
1967
+ newTask.thenableState = getThenableStateAfterSuspending();
1968
+ return serializeLazyID(newTask.id);
1969
+ } else {
1970
+ // Something errored. We'll still send everything we have up until this point.
1971
+ // We'll replace this element with a lazy reference that throws on the client
1972
+ // once it gets rendered.
1973
+ request.pendingChunks++;
1974
+ var errorId = request.nextChunkId++;
1975
+ var digest = logRecoverableError(request, x);
1976
+
1977
+ {
1978
+ var _getErrorMessageAndSt4 = getErrorMessageAndStackDev(x),
1979
+ message = _getErrorMessageAndSt4.message,
1980
+ stack = _getErrorMessageAndSt4.stack;
1981
+
1982
+ emitErrorChunkDev(request, errorId, digest, message, stack);
1983
+ }
1984
+
1985
+ return serializeLazyID(errorId);
1986
+ }
1987
+ }
1988
+ }
1989
+
1990
+ if (value === null) {
1991
+ return null;
1992
+ }
1993
+
1994
+ if (typeof value === 'object') {
1995
+ if (isClientReference(value)) {
1996
+ return serializeClientReference(request, parent, key, value);
1997
+ } else if (typeof value.then === 'function') {
1998
+ // We assume that any object with a .then property is a "Thenable" type,
1999
+ // or a Promise type. Either of which can be represented by a Promise.
2000
+ var promiseId = serializeThenable(request, value);
2001
+ return serializePromiseID(promiseId);
2002
+ } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
2003
+ var providerKey = value._context._globalName;
2004
+ var writtenProviders = request.writtenProviders;
2005
+ var providerId = writtenProviders.get(key);
2006
+
2007
+ if (providerId === undefined) {
2008
+ request.pendingChunks++;
2009
+ providerId = request.nextChunkId++;
2010
+ writtenProviders.set(providerKey, providerId);
2011
+ emitProviderChunk(request, providerId, providerKey);
2012
+ }
2013
+
2014
+ return serializeByValueID(providerId);
2015
+ } else if (value === POP) {
2016
+ popProvider();
2017
+
2018
+ {
2019
+ insideContextProps = null;
2020
+ isInsideContextValue = false;
2021
+ }
2022
+
2023
+ return undefined;
2024
+ }
2025
+
2026
+ {
2027
+ if (value !== null && !isArray(value)) {
2028
+ // Verify that this is a simple plain object.
2029
+ if (objectName(value) !== 'Object') {
2030
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
2031
+ } else if (!isSimpleObject(value)) {
2032
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
2033
+ } else if (Object.getOwnPropertySymbols) {
2034
+ var symbols = Object.getOwnPropertySymbols(value);
2035
+
2036
+ if (symbols.length > 0) {
2037
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
2038
+ }
2039
+ }
2040
+ }
2041
+ } // $FlowFixMe
2042
+
2043
+
2044
+ return value;
2045
+ }
2046
+
2047
+ if (typeof value === 'string') {
2048
+ return escapeStringValue(value);
2049
+ }
2050
+
2051
+ if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'undefined') {
2052
+ return value;
2053
+ }
2054
+
2055
+ if (typeof value === 'function') {
2056
+ if (isClientReference(value)) {
2057
+ return serializeClientReference(request, parent, key, value);
2058
+ }
2059
+
2060
+ if (/^on[A-Z]/.test(key)) {
2061
+ throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, key) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
2062
+ } else {
2063
+ throw new Error('Functions cannot be passed directly to Client Components ' + "because they're not serializable." + describeObjectForErrorMessage(parent, key));
2064
+ }
2065
+ }
2066
+
2067
+ if (typeof value === 'symbol') {
2068
+ var writtenSymbols = request.writtenSymbols;
2069
+ var existingId = writtenSymbols.get(value);
2070
+
2071
+ if (existingId !== undefined) {
2072
+ return serializeByValueID(existingId);
2073
+ } // $FlowFixMe `description` might be undefined
2074
+
2075
+
2076
+ var name = value.description;
2077
+
2078
+ if (Symbol.for(name) !== value) {
2079
+ throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe `description` might be undefined
2080
+ value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
2081
+ }
2082
+
2083
+ request.pendingChunks++;
2084
+ var symbolId = request.nextChunkId++;
2085
+ emitSymbolChunk(request, symbolId, name);
2086
+ writtenSymbols.set(value, symbolId);
2087
+ return serializeByValueID(symbolId);
2088
+ }
2089
+
2090
+ if (typeof value === 'bigint') {
2091
+ throw new Error("BigInt (" + value + ") is not yet supported in Client Component props." + describeObjectForErrorMessage(parent, key));
2092
+ }
2093
+
2094
+ throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
2095
+ }
2096
+
2097
+ function logRecoverableError(request, error) {
2098
+ var onError = request.onError;
2099
+ var errorDigest = onError(error);
2100
+
2101
+ if (errorDigest != null && typeof errorDigest !== 'string') {
2102
+ // eslint-disable-next-line react-internal/prod-error-codes
2103
+ throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
2104
+ }
2105
+
2106
+ return errorDigest || '';
2107
+ }
2108
+
2109
+ function getErrorMessageAndStackDev(error) {
2110
+ {
2111
+ var message;
2112
+ var stack = '';
2113
+
2114
+ try {
2115
+ if (error instanceof Error) {
2116
+ // eslint-disable-next-line react-internal/safe-string-coercion
2117
+ message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
2118
+
2119
+ stack = String(error.stack);
2120
+ } else {
2121
+ message = 'Error: ' + error;
2122
+ }
2123
+ } catch (x) {
2124
+ message = 'An error occurred but serializing the error message failed.';
2125
+ }
2126
+
2127
+ return {
2128
+ message: message,
2129
+ stack: stack
2130
+ };
2131
+ }
2132
+ }
2133
+
2134
+ function fatalError(request, error) {
2135
+ // This is called outside error handling code such as if an error happens in React internals.
2136
+ if (request.destination !== null) {
2137
+ request.status = CLOSED;
2138
+ closeWithError(request.destination, error);
2139
+ } else {
2140
+ request.status = CLOSING;
2141
+ request.fatalError = error;
2142
+ }
2143
+ }
2144
+
2145
+ function emitErrorChunkProd(request, id, digest) {
2146
+ var processedChunk = processErrorChunkProd(request, id, digest);
2147
+ request.completedErrorChunks.push(processedChunk);
2148
+ }
2149
+
2150
+ function emitErrorChunkDev(request, id, digest, message, stack) {
2151
+ var processedChunk = processErrorChunkDev(request, id, digest, message, stack);
2152
+ request.completedErrorChunks.push(processedChunk);
2153
+ }
2154
+
2155
+ function emitModuleChunk(request, id, moduleMetaData) {
2156
+ var processedChunk = processModuleChunk(request, id, moduleMetaData);
2157
+ request.completedModuleChunks.push(processedChunk);
2158
+ }
2159
+
2160
+ function emitSymbolChunk(request, id, name) {
2161
+ var symbolReference = serializeSymbolReference(name);
2162
+ var processedChunk = processReferenceChunk(request, id, symbolReference);
2163
+ request.completedModuleChunks.push(processedChunk);
2164
+ }
2165
+
2166
+ function emitProviderChunk(request, id, contextName) {
2167
+ var contextReference = serializeProviderReference(contextName);
2168
+ var processedChunk = processReferenceChunk(request, id, contextReference);
2169
+ request.completedJSONChunks.push(processedChunk);
2170
+ }
2171
+
2172
+ function retryTask(request, task) {
2173
+ if (task.status !== PENDING) {
2174
+ // We completed this by other means before we had a chance to retry it.
2175
+ return;
2176
+ }
2177
+
2178
+ switchContext(task.context);
2179
+
2180
+ try {
2181
+ var value = task.model;
2182
+
2183
+ if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2184
+ // TODO: Concatenate keys of parents onto children.
2185
+ var element = value; // When retrying a component, reuse the thenableState from the
2186
+ // previous attempt.
2187
+
2188
+ var prevThenableState = task.thenableState; // Attempt to render the Server Component.
2189
+ // Doing this here lets us reuse this same task if the next component
2190
+ // also suspends.
2191
+
2192
+ task.model = value;
2193
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
2194
+ // using the same task, but we reset its thenable state before continuing.
2195
+
2196
+ task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
2197
+ // from the render above because we don't need to reset the thenable state
2198
+ // until the next time something suspends and retries.
2199
+
2200
+ while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2201
+ // TODO: Concatenate keys of parents onto children.
2202
+ var nextElement = value;
2203
+ task.model = value;
2204
+ value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
2205
+ }
2206
+ }
2207
+
2208
+ var processedChunk = processModelChunk(request, task.id, value);
2209
+ request.completedJSONChunks.push(processedChunk);
2210
+ request.abortableTasks.delete(task);
2211
+ task.status = COMPLETED;
2212
+ } catch (thrownValue) {
2213
+ var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2214
+ // reasons, the rest of the Suspense implementation expects the thrown
2215
+ // value to be a thenable, because before `use` existed that was the
2216
+ // (unstable) API for suspending. This implementation detail can change
2217
+ // later, once we deprecate the old API in favor of `use`.
2218
+ getSuspendedThenable() : thrownValue; // $FlowFixMe[method-unbinding]
2219
+
2220
+ if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
2221
+ // Something suspended again, let's pick it back up later.
2222
+ var ping = task.ping;
2223
+ x.then(ping, ping);
2224
+ task.thenableState = getThenableStateAfterSuspending();
2225
+ return;
2226
+ } else {
2227
+ request.abortableTasks.delete(task);
2228
+ task.status = ERRORED;
2229
+ var digest = logRecoverableError(request, x);
2230
+
2231
+ {
2232
+ var _getErrorMessageAndSt5 = getErrorMessageAndStackDev(x),
2233
+ message = _getErrorMessageAndSt5.message,
2234
+ stack = _getErrorMessageAndSt5.stack;
2235
+
2236
+ emitErrorChunkDev(request, task.id, digest, message, stack);
2237
+ }
2238
+ }
2239
+ }
2240
+ }
2241
+
2242
+ function performWork(request) {
2243
+ var prevDispatcher = ReactCurrentDispatcher.current;
2244
+ var prevCache = getCurrentCache();
2245
+ ReactCurrentDispatcher.current = HooksDispatcher;
2246
+ setCurrentCache(request.cache);
2247
+ prepareToUseHooksForRequest(request);
2248
+
2249
+ try {
2250
+ var pingedTasks = request.pingedTasks;
2251
+ request.pingedTasks = [];
2252
+
2253
+ for (var i = 0; i < pingedTasks.length; i++) {
2254
+ var task = pingedTasks[i];
2255
+ retryTask(request, task);
2256
+ }
2257
+
2258
+ if (request.destination !== null) {
2259
+ flushCompletedChunks(request, request.destination);
2260
+ }
2261
+ } catch (error) {
2262
+ logRecoverableError(request, error);
2263
+ fatalError(request, error);
2264
+ } finally {
2265
+ ReactCurrentDispatcher.current = prevDispatcher;
2266
+ setCurrentCache(prevCache);
2267
+ resetHooksForRequest();
2268
+ }
2269
+ }
2270
+
2271
+ function abortTask(task, request, errorId) {
2272
+ task.status = ABORTED; // Instead of emitting an error per task.id, we emit a model that only
2273
+ // has a single value referencing the error.
2274
+
2275
+ var ref = serializeByValueID(errorId);
2276
+ var processedChunk = processReferenceChunk(request, task.id, ref);
2277
+ request.completedErrorChunks.push(processedChunk);
2278
+ }
2279
+
2280
+ function flushCompletedChunks(request, destination) {
2281
+ beginWriting();
2282
+
2283
+ try {
2284
+ // We emit module chunks first in the stream so that
2285
+ // they can be preloaded as early as possible.
2286
+ var moduleChunks = request.completedModuleChunks;
2287
+ var i = 0;
2288
+
2289
+ for (; i < moduleChunks.length; i++) {
2290
+ request.pendingChunks--;
2291
+ var chunk = moduleChunks[i];
2292
+ var keepWriting = writeChunkAndReturn(destination, chunk);
2293
+
2294
+ if (!keepWriting) {
2295
+ request.destination = null;
2296
+ i++;
2297
+ break;
2298
+ }
2299
+ }
2300
+
2301
+ moduleChunks.splice(0, i); // Next comes model data.
2302
+
2303
+ var jsonChunks = request.completedJSONChunks;
2304
+ i = 0;
2305
+
2306
+ for (; i < jsonChunks.length; i++) {
2307
+ request.pendingChunks--;
2308
+ var _chunk = jsonChunks[i];
2309
+
2310
+ var _keepWriting = writeChunkAndReturn(destination, _chunk);
2311
+
2312
+ if (!_keepWriting) {
2313
+ request.destination = null;
2314
+ i++;
2315
+ break;
2316
+ }
2317
+ }
2318
+
2319
+ jsonChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
2320
+ // any error messages and prioritize display of other parts of
2321
+ // the page.
2322
+
2323
+ var errorChunks = request.completedErrorChunks;
2324
+ i = 0;
2325
+
2326
+ for (; i < errorChunks.length; i++) {
2327
+ request.pendingChunks--;
2328
+ var _chunk2 = errorChunks[i];
2329
+
2330
+ var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
2331
+
2332
+ if (!_keepWriting2) {
2333
+ request.destination = null;
2334
+ i++;
2335
+ break;
2336
+ }
2337
+ }
2338
+
2339
+ errorChunks.splice(0, i);
2340
+ } finally {
2341
+ completeWriting(destination);
2342
+ }
2343
+
2344
+ if (request.pendingChunks === 0) {
2345
+ // We're done.
2346
+ close(destination);
2347
+ }
2348
+ }
2349
+
2350
+ function startWork(request) {
2351
+ if (supportsRequestStorage) {
2352
+ scheduleWork(function () {
2353
+ return requestStorage.run(request.cache, performWork, request);
2354
+ });
2355
+ } else {
2356
+ scheduleWork(function () {
2357
+ return performWork(request);
2358
+ });
2359
+ }
2360
+ }
2361
+ function startFlowing(request, destination) {
2362
+ if (request.status === CLOSING) {
2363
+ request.status = CLOSED;
2364
+ closeWithError(destination, request.fatalError);
2365
+ return;
2366
+ }
2367
+
2368
+ if (request.status === CLOSED) {
2369
+ return;
2370
+ }
2371
+
2372
+ if (request.destination !== null) {
2373
+ // We're already flowing.
2374
+ return;
2375
+ }
2376
+
2377
+ request.destination = destination;
2378
+
2379
+ try {
2380
+ flushCompletedChunks(request, destination);
2381
+ } catch (error) {
2382
+ logRecoverableError(request, error);
2383
+ fatalError(request, error);
2384
+ }
2385
+ } // This is called to early terminate a request. It creates an error at all pending tasks.
2386
+
2387
+ function abort(request, reason) {
2388
+ try {
2389
+ var abortableTasks = request.abortableTasks;
2390
+
2391
+ if (abortableTasks.size > 0) {
2392
+ // We have tasks to abort. We'll emit one error row and then emit a reference
2393
+ // to that row from every row that's still remaining.
2394
+ var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
2395
+ var digest = logRecoverableError(request, error);
2396
+ request.pendingChunks++;
2397
+ var errorId = request.nextChunkId++;
2398
+
2399
+ if (true) {
2400
+ var _getErrorMessageAndSt6 = getErrorMessageAndStackDev(error),
2401
+ message = _getErrorMessageAndSt6.message,
2402
+ stack = _getErrorMessageAndSt6.stack;
2403
+
2404
+ emitErrorChunkDev(request, errorId, digest, message, stack);
2405
+ } else {
2406
+ emitErrorChunkProd(request, errorId, digest);
2407
+ }
2408
+
2409
+ abortableTasks.forEach(function (task) {
2410
+ return abortTask(task, request, errorId);
2411
+ });
2412
+ abortableTasks.clear();
2413
+ }
2414
+
2415
+ if (request.destination !== null) {
2416
+ flushCompletedChunks(request, request.destination);
2417
+ }
2418
+ } catch (error) {
2419
+ logRecoverableError(request, error);
2420
+ fatalError(request, error);
2421
+ }
2422
+ }
2423
+
2424
+ function importServerContexts(contexts) {
2425
+ if (contexts) {
2426
+ var prevContext = getActiveContext();
2427
+ switchContext(rootContextSnapshot);
2428
+
2429
+ for (var i = 0; i < contexts.length; i++) {
2430
+ var _contexts$i = contexts[i],
2431
+ name = _contexts$i[0],
2432
+ value = _contexts$i[1];
2433
+ var context = getOrCreateServerContext(name);
2434
+ pushProvider(context, value);
2435
+ }
2436
+
2437
+ var importedContext = getActiveContext();
2438
+ switchContext(prevContext);
2439
+ return importedContext;
2440
+ }
2441
+
2442
+ return rootContextSnapshot;
2443
+ }
2444
+
2445
+ function renderToReadableStream(model, webpackMap, options) {
2446
+ var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined);
2447
+
2448
+ if (options && options.signal) {
2449
+ var signal = options.signal;
2450
+
2451
+ if (signal.aborted) {
2452
+ abort(request, signal.reason);
2453
+ } else {
2454
+ var listener = function () {
2455
+ abort(request, signal.reason);
2456
+ signal.removeEventListener('abort', listener);
2457
+ };
2458
+
2459
+ signal.addEventListener('abort', listener);
2460
+ }
2461
+ }
2462
+
2463
+ var stream = new ReadableStream({
2464
+ type: 'bytes',
2465
+ start: function (controller) {
2466
+ startWork(request);
2467
+ },
2468
+ pull: function (controller) {
2469
+ startFlowing(request, controller);
2470
+ },
2471
+ cancel: function (reason) {}
2472
+ }, // $FlowFixMe size() methods are not allowed on byte streams.
2473
+ {
2474
+ highWaterMark: 0
2475
+ });
2476
+ return stream;
2477
+ }
2478
+
2479
+ exports.renderToReadableStream = renderToReadableStream;
2480
+ })();
2481
+ }