react-server-dom-webpack 18.3.0-next-fccf3a9fb-20230213 → 18.3.0-next-4fcc9184a-20230217

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