react-server-dom-webpack 19.0.0-canary-33a32441e9-20240418 → 19.0.0-canary-cb151849e1-20240424
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.
- package/cjs/react-server-dom-webpack-client.browser.development.js +36 -8
- package/cjs/react-server-dom-webpack-client.browser.production.js +768 -1652
- package/cjs/react-server-dom-webpack-client.edge.development.js +36 -8
- package/cjs/react-server-dom-webpack-client.edge.production.js +894 -1863
- package/cjs/react-server-dom-webpack-client.node.development.js +36 -8
- package/cjs/react-server-dom-webpack-client.node.production.js +870 -1818
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +36 -8
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +854 -1776
- package/cjs/react-server-dom-webpack-node-register.js +68 -13
- package/cjs/react-server-dom-webpack-plugin.js +398 -23
- package/cjs/react-server-dom-webpack-server.browser.development.js +87 -15
- package/cjs/react-server-dom-webpack-server.browser.production.js +1590 -3050
- package/cjs/react-server-dom-webpack-server.edge.development.js +87 -15
- package/cjs/react-server-dom-webpack-server.edge.production.js +1586 -3029
- package/cjs/react-server-dom-webpack-server.node.development.js +87 -15
- package/cjs/react-server-dom-webpack-server.node.production.js +1720 -3239
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +87 -15
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1702 -3180
- package/client.browser.js +1 -1
- package/client.edge.js +1 -1
- package/client.node.js +1 -1
- package/client.node.unbundled.js +1 -1
- package/esm/{react-server-dom-webpack-node-loader.production.min.js → react-server-dom-webpack-node-loader.production.js} +1 -1
- package/package.json +4 -4
- package/server.browser.js +1 -1
- package/server.edge.js +1 -1
- package/server.node.js +1 -1
- package/server.node.unbundled.js +1 -1
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +0 -40
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +0 -46
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-client.node.production.min.js +0 -45
- package/cjs/react-server-dom-webpack-client.node.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +0 -44
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-node-register.js.map +0 -1
- package/cjs/react-server-dom-webpack-plugin.js.map +0 -1
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +0 -82
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +0 -83
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-server.node.production.min.js +0 -86
- package/cjs/react-server-dom-webpack-server.node.production.min.js.map +0 -1
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0 -84
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* @license React
|
3
|
-
* react-server-dom-webpack-client.browser.production.
|
3
|
+
* react-server-dom-webpack-client.browser.production.js
|
4
4
|
*
|
5
5
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
6
6
|
*
|
@@ -8,1808 +8,924 @@
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
// -----------------------------------------------------------------------------
|
16
|
-
const enableBinaryFlight = false;
|
17
|
-
|
18
|
-
function createStringDecoder() {
|
19
|
-
return new TextDecoder();
|
20
|
-
}
|
21
|
-
const decoderOptions = {
|
22
|
-
stream: true
|
23
|
-
};
|
24
|
-
function readPartialStringChunk(decoder, buffer) {
|
25
|
-
return decoder.decode(buffer, decoderOptions);
|
26
|
-
}
|
27
|
-
function readFinalStringChunk(decoder, buffer) {
|
28
|
-
return decoder.decode(buffer);
|
29
|
-
}
|
30
|
-
|
31
|
-
// This is the parsed shape of the wire format which is why it is
|
32
|
-
// condensed to only the essentialy information
|
33
|
-
const ID = 0;
|
34
|
-
const CHUNKS = 1;
|
35
|
-
const NAME = 2; // export const ASYNC = 3;
|
36
|
-
// This logic is correct because currently only include the 4th tuple member
|
37
|
-
// when the module is async. If that changes we will need to actually assert
|
38
|
-
// the value is true. We don't index into the 4th slot because flow does not
|
39
|
-
// like the potential out of bounds access
|
40
|
-
|
41
|
-
function isAsyncImport(metadata) {
|
42
|
-
return metadata.length === 4;
|
43
|
-
}
|
44
|
-
|
11
|
+
"use strict";
|
12
|
+
var ReactDOM = require("react-dom"),
|
13
|
+
decoderOptions = { stream: !0 };
|
45
14
|
function resolveClientReference(bundlerConfig, metadata) {
|
46
15
|
if (bundlerConfig) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
if (isAsyncImport(metadata)) {
|
66
|
-
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
|
67
|
-
/* async */
|
68
|
-
];
|
69
|
-
} else {
|
70
|
-
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
71
|
-
}
|
16
|
+
var moduleExports = bundlerConfig[metadata[0]];
|
17
|
+
if ((bundlerConfig = moduleExports[metadata[2]]))
|
18
|
+
moduleExports = bundlerConfig.name;
|
19
|
+
else {
|
20
|
+
bundlerConfig = moduleExports["*"];
|
21
|
+
if (!bundlerConfig)
|
22
|
+
throw Error(
|
23
|
+
'Could not find the module "' +
|
24
|
+
metadata[0] +
|
25
|
+
'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.'
|
26
|
+
);
|
27
|
+
moduleExports = metadata[2];
|
28
|
+
}
|
29
|
+
return 4 === metadata.length
|
30
|
+
? [bundlerConfig.id, bundlerConfig.chunks, moduleExports, 1]
|
31
|
+
: [bundlerConfig.id, bundlerConfig.chunks, moduleExports];
|
72
32
|
}
|
73
|
-
|
74
33
|
return metadata;
|
75
34
|
}
|
76
|
-
|
77
|
-
// in Webpack but unfortunately it's not exposed so we have to
|
78
|
-
// replicate it in user space. null means that it has already loaded.
|
79
|
-
|
80
|
-
const chunkCache = new Map();
|
81
|
-
|
35
|
+
var chunkCache = new Map();
|
82
36
|
function requireAsyncModule(id) {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if (typeof promise.then !== 'function') {
|
87
|
-
// This wasn't a promise after all.
|
88
|
-
return null;
|
89
|
-
} else if (promise.status === 'fulfilled') {
|
90
|
-
// This module was already resolved earlier.
|
37
|
+
var promise = __webpack_require__(id);
|
38
|
+
if ("function" !== typeof promise.then || "fulfilled" === promise.status)
|
91
39
|
return null;
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
108
|
-
} // Start preloading the modules since we might need them soon.
|
109
|
-
// This function doesn't suspend.
|
110
|
-
|
111
|
-
|
40
|
+
promise.then(
|
41
|
+
function (value) {
|
42
|
+
promise.status = "fulfilled";
|
43
|
+
promise.value = value;
|
44
|
+
},
|
45
|
+
function (reason) {
|
46
|
+
promise.status = "rejected";
|
47
|
+
promise.reason = reason;
|
48
|
+
}
|
49
|
+
);
|
50
|
+
return promise;
|
51
|
+
}
|
52
|
+
function ignoreReject() {}
|
112
53
|
function preloadModule(metadata) {
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
promises.push(
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
return Promise.all(promises).then(() => {
|
139
|
-
return requireAsyncModule(metadata[ID]);
|
140
|
-
});
|
141
|
-
}
|
142
|
-
} else if (promises.length > 0) {
|
143
|
-
return Promise.all(promises);
|
144
|
-
} else {
|
145
|
-
return null;
|
146
|
-
}
|
147
|
-
} // Actually require the module or suspend if it's not yet ready.
|
148
|
-
// Increase priority if necessary.
|
149
|
-
|
150
|
-
function requireModule(metadata) {
|
151
|
-
let moduleExports = __webpack_require__(metadata[ID]);
|
152
|
-
|
153
|
-
if (isAsyncImport(metadata)) {
|
154
|
-
if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
|
155
|
-
// This Promise should've been instrumented by preloadModule.
|
156
|
-
moduleExports = moduleExports.value;
|
157
|
-
} else {
|
158
|
-
throw moduleExports.reason;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
|
-
if (metadata[NAME] === '*') {
|
163
|
-
// This is a placeholder value that represents that the caller imported this
|
164
|
-
// as a CommonJS module as is.
|
165
|
-
return moduleExports;
|
166
|
-
}
|
167
|
-
|
168
|
-
if (metadata[NAME] === '') {
|
169
|
-
// This is a placeholder value that represents that the caller accessed the
|
170
|
-
// default property of this if it was an ESM interop module.
|
171
|
-
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
172
|
-
}
|
173
|
-
|
174
|
-
return moduleExports[metadata[NAME]];
|
175
|
-
}
|
176
|
-
|
177
|
-
const chunkMap = new Map();
|
178
|
-
/**
|
179
|
-
* We patch the chunk filename function in webpack to insert our own resolution
|
180
|
-
* of chunks that come from Flight and may not be known to the webpack runtime
|
181
|
-
*/
|
182
|
-
|
183
|
-
const webpackGetChunkFilename = __webpack_require__.u;
|
184
|
-
|
54
|
+
for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) {
|
55
|
+
var chunkId = chunks[i++],
|
56
|
+
chunkFilename = chunks[i++],
|
57
|
+
entry = chunkCache.get(chunkId);
|
58
|
+
void 0 === entry
|
59
|
+
? (chunkMap.set(chunkId, chunkFilename),
|
60
|
+
(chunkFilename = __webpack_chunk_load__(chunkId)),
|
61
|
+
promises.push(chunkFilename),
|
62
|
+
(entry = chunkCache.set.bind(chunkCache, chunkId, null)),
|
63
|
+
chunkFilename.then(entry, ignoreReject),
|
64
|
+
chunkCache.set(chunkId, chunkFilename))
|
65
|
+
: null !== entry && promises.push(entry);
|
66
|
+
}
|
67
|
+
return 4 === metadata.length
|
68
|
+
? 0 === promises.length
|
69
|
+
? requireAsyncModule(metadata[0])
|
70
|
+
: Promise.all(promises).then(function () {
|
71
|
+
return requireAsyncModule(metadata[0]);
|
72
|
+
})
|
73
|
+
: 0 < promises.length
|
74
|
+
? Promise.all(promises)
|
75
|
+
: null;
|
76
|
+
}
|
77
|
+
var chunkMap = new Map(),
|
78
|
+
webpackGetChunkFilename = __webpack_require__.u;
|
185
79
|
__webpack_require__.u = function (chunkId) {
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
}
|
191
|
-
|
192
|
-
return webpackGetChunkFilename(chunkId);
|
80
|
+
var flightChunk = chunkMap.get(chunkId);
|
81
|
+
return void 0 !== flightChunk
|
82
|
+
? flightChunk
|
83
|
+
: webpackGetChunkFilename(chunkId);
|
193
84
|
};
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
const ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
201
|
-
|
202
|
-
// This client file is in the shared folder because it applies to both SSR and browser contexts.
|
203
|
-
function dispatchHint(code, model) {
|
204
|
-
const dispatcher = ReactDOMSharedInternals.d;
|
205
|
-
/* ReactDOMCurrentDispatcher */
|
206
|
-
|
207
|
-
switch (code) {
|
208
|
-
case 'D':
|
209
|
-
{
|
210
|
-
const refined = refineModel(code, model);
|
211
|
-
const href = refined;
|
212
|
-
dispatcher.D(
|
213
|
-
/* prefetchDNS */
|
214
|
-
href);
|
215
|
-
return;
|
216
|
-
}
|
217
|
-
|
218
|
-
case 'C':
|
219
|
-
{
|
220
|
-
const refined = refineModel(code, model);
|
221
|
-
|
222
|
-
if (typeof refined === 'string') {
|
223
|
-
const href = refined;
|
224
|
-
dispatcher.C(
|
225
|
-
/* preconnect */
|
226
|
-
href);
|
227
|
-
} else {
|
228
|
-
const href = refined[0];
|
229
|
-
const crossOrigin = refined[1];
|
230
|
-
dispatcher.C(
|
231
|
-
/* preconnect */
|
232
|
-
href, crossOrigin);
|
233
|
-
}
|
234
|
-
|
235
|
-
return;
|
236
|
-
}
|
237
|
-
|
238
|
-
case 'L':
|
239
|
-
{
|
240
|
-
const refined = refineModel(code, model);
|
241
|
-
const href = refined[0];
|
242
|
-
const as = refined[1];
|
243
|
-
|
244
|
-
if (refined.length === 3) {
|
245
|
-
const options = refined[2];
|
246
|
-
dispatcher.L(
|
247
|
-
/* preload */
|
248
|
-
href, as, options);
|
249
|
-
} else {
|
250
|
-
dispatcher.L(
|
251
|
-
/* preload */
|
252
|
-
href, as);
|
253
|
-
}
|
254
|
-
|
255
|
-
return;
|
256
|
-
}
|
257
|
-
|
258
|
-
case 'm':
|
259
|
-
{
|
260
|
-
const refined = refineModel(code, model);
|
261
|
-
|
262
|
-
if (typeof refined === 'string') {
|
263
|
-
const href = refined;
|
264
|
-
dispatcher.m(
|
265
|
-
/* preloadModule */
|
266
|
-
href);
|
267
|
-
} else {
|
268
|
-
const href = refined[0];
|
269
|
-
const options = refined[1];
|
270
|
-
dispatcher.m(
|
271
|
-
/* preloadModule */
|
272
|
-
href, options);
|
273
|
-
}
|
274
|
-
|
275
|
-
return;
|
276
|
-
}
|
277
|
-
|
278
|
-
case 'X':
|
279
|
-
{
|
280
|
-
const refined = refineModel(code, model);
|
281
|
-
|
282
|
-
if (typeof refined === 'string') {
|
283
|
-
const href = refined;
|
284
|
-
dispatcher.X(
|
285
|
-
/* preinitScript */
|
286
|
-
href);
|
287
|
-
} else {
|
288
|
-
const href = refined[0];
|
289
|
-
const options = refined[1];
|
290
|
-
dispatcher.X(
|
291
|
-
/* preinitScript */
|
292
|
-
href, options);
|
293
|
-
}
|
294
|
-
|
295
|
-
return;
|
296
|
-
}
|
297
|
-
|
298
|
-
case 'S':
|
299
|
-
{
|
300
|
-
const refined = refineModel(code, model);
|
301
|
-
|
302
|
-
if (typeof refined === 'string') {
|
303
|
-
const href = refined;
|
304
|
-
dispatcher.S(
|
305
|
-
/* preinitStyle */
|
306
|
-
href);
|
307
|
-
} else {
|
308
|
-
const href = refined[0];
|
309
|
-
const precedence = refined[1] === 0 ? undefined : refined[1];
|
310
|
-
const options = refined.length === 3 ? refined[2] : undefined;
|
311
|
-
dispatcher.S(
|
312
|
-
/* preinitStyle */
|
313
|
-
href, precedence, options);
|
314
|
-
}
|
315
|
-
|
316
|
-
return;
|
317
|
-
}
|
318
|
-
|
319
|
-
case 'M':
|
320
|
-
{
|
321
|
-
const refined = refineModel(code, model);
|
322
|
-
|
323
|
-
if (typeof refined === 'string') {
|
324
|
-
const href = refined;
|
325
|
-
dispatcher.M(
|
326
|
-
/* preinitModuleScript */
|
327
|
-
href);
|
328
|
-
} else {
|
329
|
-
const href = refined[0];
|
330
|
-
const options = refined[1];
|
331
|
-
dispatcher.M(
|
332
|
-
/* preinitModuleScript */
|
333
|
-
href, options);
|
334
|
-
}
|
335
|
-
|
336
|
-
return;
|
337
|
-
}
|
338
|
-
}
|
339
|
-
} // Flow is having trouble refining the HintModels so we help it a bit.
|
340
|
-
// This should be compiled out in the production build.
|
341
|
-
|
342
|
-
function refineModel(code, model) {
|
343
|
-
return model;
|
344
|
-
}
|
345
|
-
|
346
|
-
// ATTENTION
|
347
|
-
// When adding new symbols to this file,
|
348
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
349
|
-
// The Symbol used to tag the ReactElement-like types.
|
350
|
-
const REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
351
|
-
const REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
352
|
-
const MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
353
|
-
const FAUX_ITERATOR_SYMBOL = '@@iterator';
|
85
|
+
var ReactDOMSharedInternals =
|
86
|
+
ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
87
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
88
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
89
|
+
MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
354
90
|
function getIteratorFn(maybeIterable) {
|
355
|
-
if (
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
}
|
364
|
-
|
365
|
-
return null;
|
366
|
-
}
|
367
|
-
|
368
|
-
const isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
369
|
-
|
370
|
-
function isArray(a) {
|
371
|
-
return isArrayImpl(a);
|
372
|
-
}
|
373
|
-
|
374
|
-
const getPrototypeOf = Object.getPrototypeOf;
|
375
|
-
|
376
|
-
function createTemporaryReferenceSet() {
|
377
|
-
return [];
|
378
|
-
}
|
91
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
|
92
|
+
maybeIterable =
|
93
|
+
(MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
|
94
|
+
maybeIterable["@@iterator"];
|
95
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
96
|
+
}
|
97
|
+
var isArrayImpl = Array.isArray,
|
98
|
+
getPrototypeOf = Object.getPrototypeOf;
|
379
99
|
function writeTemporaryReference(set, object) {
|
380
|
-
|
381
|
-
// object. This ensures that we always generate a deterministic encoding of
|
382
|
-
// each slot in the reply for cacheability.
|
383
|
-
const newId = set.length;
|
100
|
+
var newId = set.length;
|
384
101
|
set.push(object);
|
385
102
|
return newId;
|
386
103
|
}
|
387
|
-
|
388
|
-
|
389
|
-
throw new Error("The RSC response contained a reference that doesn't exist in the temporary reference set. " + 'Always pass the matching set that was used to create the reply when parsing its response.');
|
390
|
-
}
|
391
|
-
|
392
|
-
return set[id];
|
393
|
-
}
|
394
|
-
|
395
|
-
const ObjectPrototype = Object.prototype;
|
396
|
-
const knownServerReferences = new WeakMap(); // Serializable values
|
397
|
-
// Thenable<ReactServerValue>
|
398
|
-
|
399
|
-
function serializeByValueID(id) {
|
400
|
-
return '$' + id.toString(16);
|
401
|
-
}
|
402
|
-
|
403
|
-
function serializePromiseID(id) {
|
404
|
-
return '$@' + id.toString(16);
|
405
|
-
}
|
406
|
-
|
407
|
-
function serializeServerReferenceID(id) {
|
408
|
-
return '$F' + id.toString(16);
|
409
|
-
}
|
410
|
-
|
411
|
-
function serializeTemporaryReferenceID(id) {
|
412
|
-
return '$T' + id.toString(16);
|
413
|
-
}
|
414
|
-
|
415
|
-
function serializeFormDataReference(id) {
|
416
|
-
// Why K? F is "Function". D is "Date". What else?
|
417
|
-
return '$K' + id.toString(16);
|
418
|
-
}
|
419
|
-
|
104
|
+
var ObjectPrototype = Object.prototype,
|
105
|
+
knownServerReferences = new WeakMap();
|
420
106
|
function serializeNumber(number) {
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
function serializeUndefined() {
|
439
|
-
return '$undefined';
|
440
|
-
}
|
441
|
-
|
442
|
-
function serializeDateFromDateJSON(dateJSON) {
|
443
|
-
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
|
444
|
-
// We need only tack on a $D prefix.
|
445
|
-
return '$D' + dateJSON;
|
446
|
-
}
|
447
|
-
|
448
|
-
function serializeBigInt(n) {
|
449
|
-
return '$n' + n.toString(10);
|
450
|
-
}
|
451
|
-
|
452
|
-
function serializeMapID(id) {
|
453
|
-
return '$Q' + id.toString(16);
|
454
|
-
}
|
455
|
-
|
456
|
-
function serializeSetID(id) {
|
457
|
-
return '$W' + id.toString(16);
|
458
|
-
}
|
459
|
-
|
460
|
-
function escapeStringValue(value) {
|
461
|
-
if (value[0] === '$') {
|
462
|
-
// We need to escape $ prefixed strings since we use those to encode
|
463
|
-
// references to IDs and as special symbol values.
|
464
|
-
return '$' + value;
|
465
|
-
} else {
|
466
|
-
return value;
|
467
|
-
}
|
468
|
-
}
|
469
|
-
|
470
|
-
function processReply(root, formFieldPrefix, temporaryReferences, resolve, reject) {
|
471
|
-
let nextPartId = 1;
|
472
|
-
let pendingParts = 0;
|
473
|
-
let formData = null;
|
474
|
-
|
107
|
+
return Number.isFinite(number)
|
108
|
+
? 0 === number && -Infinity === 1 / number
|
109
|
+
? "$-0"
|
110
|
+
: number
|
111
|
+
: Infinity === number
|
112
|
+
? "$Infinity"
|
113
|
+
: -Infinity === number
|
114
|
+
? "$-Infinity"
|
115
|
+
: "$NaN";
|
116
|
+
}
|
117
|
+
function processReply(
|
118
|
+
root,
|
119
|
+
formFieldPrefix,
|
120
|
+
temporaryReferences,
|
121
|
+
resolve,
|
122
|
+
reject
|
123
|
+
) {
|
475
124
|
function resolveToJSON(key, value) {
|
476
|
-
|
477
|
-
|
478
|
-
if (value === null) {
|
479
|
-
return null;
|
480
|
-
}
|
481
|
-
|
482
|
-
if (typeof value === 'object') {
|
125
|
+
if (null === value) return null;
|
126
|
+
if ("object" === typeof value) {
|
483
127
|
switch (value.$$typeof) {
|
484
128
|
case REACT_ELEMENT_TYPE:
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
129
|
+
if (void 0 === temporaryReferences)
|
130
|
+
throw Error(
|
131
|
+
"React Element cannot be passed to Server Functions from the Client without a temporary reference set. Pass a TemporaryReferenceSet to the options."
|
132
|
+
);
|
133
|
+
return (
|
134
|
+
"$T" +
|
135
|
+
writeTemporaryReference(temporaryReferences, value).toString(16)
|
136
|
+
);
|
493
137
|
case REACT_LAZY_TYPE:
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
const retry = function () {
|
526
|
-
// While the first promise resolved, its value isn't necessarily what we'll
|
527
|
-
// resolve into because we might suspend again.
|
528
|
-
try {
|
529
|
-
const partJSON = JSON.stringify(value, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
530
|
-
|
531
|
-
const data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
532
|
-
|
533
|
-
data.append(formFieldPrefix + lazyId, partJSON);
|
534
|
-
pendingParts--;
|
535
|
-
|
536
|
-
if (pendingParts === 0) {
|
537
|
-
resolve(data);
|
538
|
-
}
|
539
|
-
} catch (reason) {
|
540
|
-
reject(reason);
|
541
|
-
}
|
542
|
-
};
|
543
|
-
|
544
|
-
thenable.then(retry, retry);
|
545
|
-
return serializeByValueID(lazyId);
|
546
|
-
} else {
|
547
|
-
// In the future we could consider serializing this as an error
|
548
|
-
// that throws on the server instead.
|
549
|
-
reject(x);
|
550
|
-
return null;
|
551
|
-
}
|
552
|
-
} finally {
|
553
|
-
pendingParts--;
|
138
|
+
key = value._payload;
|
139
|
+
var init = value._init;
|
140
|
+
null === formData && (formData = new FormData());
|
141
|
+
pendingParts++;
|
142
|
+
try {
|
143
|
+
var resolvedModel = init(key),
|
144
|
+
lazyId = nextPartId++,
|
145
|
+
partJSON = JSON.stringify(resolvedModel, resolveToJSON);
|
146
|
+
formData.append(formFieldPrefix + lazyId, partJSON);
|
147
|
+
return "$" + lazyId.toString(16);
|
148
|
+
} catch (x) {
|
149
|
+
if (
|
150
|
+
"object" === typeof x &&
|
151
|
+
null !== x &&
|
152
|
+
"function" === typeof x.then
|
153
|
+
) {
|
154
|
+
pendingParts++;
|
155
|
+
var lazyId$21 = nextPartId++;
|
156
|
+
resolvedModel = function () {
|
157
|
+
try {
|
158
|
+
var partJSON$22 = JSON.stringify(value, resolveToJSON),
|
159
|
+
data$23 = formData;
|
160
|
+
data$23.append(formFieldPrefix + lazyId$21, partJSON$22);
|
161
|
+
pendingParts--;
|
162
|
+
0 === pendingParts && resolve(data$23);
|
163
|
+
} catch (reason) {
|
164
|
+
reject(reason);
|
165
|
+
}
|
166
|
+
};
|
167
|
+
x.then(resolvedModel, resolvedModel);
|
168
|
+
return "$" + lazyId$21.toString(16);
|
554
169
|
}
|
170
|
+
reject(x);
|
171
|
+
return null;
|
172
|
+
} finally {
|
173
|
+
pendingParts--;
|
555
174
|
}
|
556
|
-
}
|
557
|
-
|
558
|
-
|
559
|
-
if (typeof value.then === 'function') {
|
560
|
-
// We assume that any object with a .then property is a "Thenable" type,
|
561
|
-
// or a Promise type. Either of which can be represented by a Promise.
|
562
|
-
if (formData === null) {
|
563
|
-
// Upgrade to use FormData to allow us to stream this value.
|
564
|
-
formData = new FormData();
|
565
|
-
}
|
566
|
-
|
175
|
+
}
|
176
|
+
if ("function" === typeof value.then) {
|
177
|
+
null === formData && (formData = new FormData());
|
567
178
|
pendingParts++;
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
if (pendingParts === 0) {
|
580
|
-
resolve(data);
|
179
|
+
var promiseId = nextPartId++;
|
180
|
+
value.then(
|
181
|
+
function (partValue) {
|
182
|
+
try {
|
183
|
+
var partJSON$25 = JSON.stringify(partValue, resolveToJSON);
|
184
|
+
partValue = formData;
|
185
|
+
partValue.append(formFieldPrefix + promiseId, partJSON$25);
|
186
|
+
pendingParts--;
|
187
|
+
0 === pendingParts && resolve(partValue);
|
188
|
+
} catch (reason) {
|
189
|
+
reject(reason);
|
581
190
|
}
|
582
|
-
}
|
191
|
+
},
|
192
|
+
function (reason) {
|
583
193
|
reject(reason);
|
584
194
|
}
|
585
|
-
|
586
|
-
|
587
|
-
// that throws on the server instead.
|
588
|
-
reject(reason);
|
589
|
-
});
|
590
|
-
return serializePromiseID(promiseId);
|
195
|
+
);
|
196
|
+
return "$@" + promiseId.toString(16);
|
591
197
|
}
|
592
|
-
|
593
|
-
if (isArray(value)) {
|
594
|
-
// $FlowFixMe[incompatible-return]
|
595
|
-
return value;
|
596
|
-
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
|
597
|
-
|
598
|
-
|
198
|
+
if (isArrayImpl(value)) return value;
|
599
199
|
if (value instanceof FormData) {
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
const refId = nextPartId++; // Copy all the form fields with a prefix for this reference.
|
607
|
-
// These must come first in the form order because we assume that all the
|
608
|
-
// fields are available before this is referenced.
|
609
|
-
|
610
|
-
const prefix = formFieldPrefix + refId + '_'; // $FlowFixMe[prop-missing]: FormData has forEach.
|
611
|
-
|
612
|
-
value.forEach((originalValue, originalKey) => {
|
613
|
-
data.append(prefix + originalKey, originalValue);
|
200
|
+
null === formData && (formData = new FormData());
|
201
|
+
var data$27 = formData;
|
202
|
+
resolvedModel = nextPartId++;
|
203
|
+
var prefix = formFieldPrefix + resolvedModel + "_";
|
204
|
+
value.forEach(function (originalValue, originalKey) {
|
205
|
+
data$27.append(prefix + originalKey, originalValue);
|
614
206
|
});
|
615
|
-
return
|
616
|
-
}
|
617
|
-
|
618
|
-
if (value instanceof Map) {
|
619
|
-
const partJSON = JSON.stringify(Array.from(value), resolveToJSON);
|
620
|
-
|
621
|
-
if (formData === null) {
|
622
|
-
formData = new FormData();
|
623
|
-
}
|
624
|
-
|
625
|
-
const mapId = nextPartId++;
|
626
|
-
formData.append(formFieldPrefix + mapId, partJSON);
|
627
|
-
return serializeMapID(mapId);
|
207
|
+
return "$K" + resolvedModel.toString(16);
|
628
208
|
}
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
formData
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
209
|
+
if (value instanceof Map)
|
210
|
+
return (
|
211
|
+
(resolvedModel = JSON.stringify(Array.from(value), resolveToJSON)),
|
212
|
+
null === formData && (formData = new FormData()),
|
213
|
+
(lazyId = nextPartId++),
|
214
|
+
formData.append(formFieldPrefix + lazyId, resolvedModel),
|
215
|
+
"$Q" + lazyId.toString(16)
|
216
|
+
);
|
217
|
+
if (value instanceof Set)
|
218
|
+
return (
|
219
|
+
(resolvedModel = JSON.stringify(Array.from(value), resolveToJSON)),
|
220
|
+
null === formData && (formData = new FormData()),
|
221
|
+
(lazyId = nextPartId++),
|
222
|
+
formData.append(formFieldPrefix + lazyId, resolvedModel),
|
223
|
+
"$W" + lazyId.toString(16)
|
224
|
+
);
|
225
|
+
if ((resolvedModel = getIteratorFn(value)))
|
226
|
+
return (
|
227
|
+
(resolvedModel = resolvedModel.call(value)),
|
228
|
+
resolvedModel === value
|
229
|
+
? ((resolvedModel = JSON.stringify(
|
230
|
+
Array.from(resolvedModel),
|
231
|
+
resolveToJSON
|
232
|
+
)),
|
233
|
+
null === formData && (formData = new FormData()),
|
234
|
+
(lazyId = nextPartId++),
|
235
|
+
formData.append(formFieldPrefix + lazyId, resolvedModel),
|
236
|
+
"$i" + lazyId.toString(16))
|
237
|
+
: Array.from(resolvedModel)
|
238
|
+
);
|
239
|
+
resolvedModel = getPrototypeOf(value);
|
240
|
+
if (
|
241
|
+
resolvedModel !== ObjectPrototype &&
|
242
|
+
(null === resolvedModel || null !== getPrototypeOf(resolvedModel))
|
243
|
+
) {
|
244
|
+
if (void 0 === temporaryReferences)
|
245
|
+
throw Error(
|
246
|
+
"Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported."
|
247
|
+
);
|
248
|
+
return (
|
249
|
+
"$T" +
|
250
|
+
writeTemporaryReference(temporaryReferences, value).toString(16)
|
251
|
+
);
|
640
252
|
}
|
641
|
-
|
642
|
-
const iteratorFn = getIteratorFn(value);
|
643
|
-
|
644
|
-
if (iteratorFn) {
|
645
|
-
return Array.from(value);
|
646
|
-
} // Verify that this is a simple plain object.
|
647
|
-
|
648
|
-
|
649
|
-
const proto = getPrototypeOf(value);
|
650
|
-
|
651
|
-
if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
|
652
|
-
if (temporaryReferences === undefined) {
|
653
|
-
throw new Error('Only plain objects, and a few built-ins, can be passed to Server Actions. ' + 'Classes or null prototypes are not supported.');
|
654
|
-
} // We can serialize class instances as temporary references.
|
655
|
-
|
656
|
-
|
657
|
-
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
658
|
-
}
|
659
|
-
|
660
|
-
|
661
253
|
return value;
|
662
254
|
}
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
}
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
if (typeof value === 'symbol') {
|
717
|
-
if (temporaryReferences === undefined) {
|
718
|
-
throw new Error('Symbols cannot be passed to a Server Function without a ' + 'temporary reference set. Pass a TemporaryReferenceSet to the options.' + (''));
|
719
|
-
}
|
720
|
-
|
721
|
-
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
722
|
-
}
|
723
|
-
|
724
|
-
if (typeof value === 'bigint') {
|
725
|
-
return serializeBigInt(value);
|
726
|
-
}
|
727
|
-
|
728
|
-
throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
|
729
|
-
} // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
|
730
|
-
|
731
|
-
|
732
|
-
const json = JSON.stringify(root, resolveToJSON);
|
733
|
-
|
734
|
-
if (formData === null) {
|
735
|
-
// If it's a simple data structure, we just use plain JSON.
|
736
|
-
resolve(json);
|
737
|
-
} else {
|
738
|
-
// Otherwise, we use FormData to let us stream in the result.
|
739
|
-
formData.set(formFieldPrefix + '0', json);
|
740
|
-
|
741
|
-
if (pendingParts === 0) {
|
742
|
-
// $FlowFixMe[incompatible-call] this has already been refined.
|
743
|
-
resolve(formData);
|
744
|
-
}
|
745
|
-
}
|
746
|
-
}
|
747
|
-
|
748
|
-
function registerServerReference(proxy, reference, encodeFormAction) {
|
749
|
-
|
255
|
+
if ("string" === typeof value) {
|
256
|
+
if ("Z" === value[value.length - 1] && this[key] instanceof Date)
|
257
|
+
return "$D" + value;
|
258
|
+
resolvedModel = "$" === value[0] ? "$" + value : value;
|
259
|
+
return resolvedModel;
|
260
|
+
}
|
261
|
+
if ("boolean" === typeof value) return value;
|
262
|
+
if ("number" === typeof value) return serializeNumber(value);
|
263
|
+
if ("undefined" === typeof value) return "$undefined";
|
264
|
+
if ("function" === typeof value) {
|
265
|
+
resolvedModel = knownServerReferences.get(value);
|
266
|
+
if (void 0 !== resolvedModel)
|
267
|
+
return (
|
268
|
+
(resolvedModel = JSON.stringify(resolvedModel, resolveToJSON)),
|
269
|
+
null === formData && (formData = new FormData()),
|
270
|
+
(lazyId = nextPartId++),
|
271
|
+
formData.set(formFieldPrefix + lazyId, resolvedModel),
|
272
|
+
"$F" + lazyId.toString(16)
|
273
|
+
);
|
274
|
+
if (void 0 === temporaryReferences)
|
275
|
+
throw Error(
|
276
|
+
"Client Functions cannot be passed directly to Server Functions. Only Functions passed from the Server can be passed back again."
|
277
|
+
);
|
278
|
+
return (
|
279
|
+
"$T" + writeTemporaryReference(temporaryReferences, value).toString(16)
|
280
|
+
);
|
281
|
+
}
|
282
|
+
if ("symbol" === typeof value) {
|
283
|
+
if (void 0 === temporaryReferences)
|
284
|
+
throw Error(
|
285
|
+
"Symbols cannot be passed to a Server Function without a temporary reference set. Pass a TemporaryReferenceSet to the options."
|
286
|
+
);
|
287
|
+
return (
|
288
|
+
"$T" + writeTemporaryReference(temporaryReferences, value).toString(16)
|
289
|
+
);
|
290
|
+
}
|
291
|
+
if ("bigint" === typeof value) return "$n" + value.toString(10);
|
292
|
+
throw Error(
|
293
|
+
"Type " +
|
294
|
+
typeof value +
|
295
|
+
" is not supported as an argument to a Server Function."
|
296
|
+
);
|
297
|
+
}
|
298
|
+
var nextPartId = 1,
|
299
|
+
pendingParts = 0,
|
300
|
+
formData = null;
|
301
|
+
root = JSON.stringify(root, resolveToJSON);
|
302
|
+
null === formData
|
303
|
+
? resolve(root)
|
304
|
+
: (formData.set(formFieldPrefix + "0", root),
|
305
|
+
0 === pendingParts && resolve(formData));
|
306
|
+
}
|
307
|
+
function registerServerReference(proxy, reference) {
|
750
308
|
knownServerReferences.set(proxy, reference);
|
751
|
-
} // $FlowFixMe[method-unbinding]
|
752
|
-
|
753
|
-
function createServerReference(id, callServer, encodeFormAction) {
|
754
|
-
const proxy = function () {
|
755
|
-
// $FlowFixMe[method-unbinding]
|
756
|
-
const args = Array.prototype.slice.call(arguments);
|
757
|
-
return callServer(id, args);
|
758
|
-
};
|
759
|
-
|
760
|
-
registerServerReference(proxy, {
|
761
|
-
id,
|
762
|
-
bound: null
|
763
|
-
});
|
764
|
-
return proxy;
|
765
309
|
}
|
766
|
-
|
767
|
-
const ROW_ID = 0;
|
768
|
-
const ROW_TAG = 1;
|
769
|
-
const ROW_LENGTH = 2;
|
770
|
-
const ROW_CHUNK_BY_NEWLINE = 3;
|
771
|
-
const ROW_CHUNK_BY_LENGTH = 4;
|
772
|
-
const PENDING = 'pending';
|
773
|
-
const BLOCKED = 'blocked';
|
774
|
-
const CYCLIC = 'cyclic';
|
775
|
-
const RESOLVED_MODEL = 'resolved_model';
|
776
|
-
const RESOLVED_MODULE = 'resolved_module';
|
777
|
-
const INITIALIZED = 'fulfilled';
|
778
|
-
const ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
779
|
-
|
780
310
|
function Chunk(status, value, reason, response) {
|
781
311
|
this.status = status;
|
782
312
|
this.value = value;
|
783
313
|
this.reason = reason;
|
784
314
|
this._response = response;
|
785
|
-
}
|
786
|
-
|
787
|
-
|
788
|
-
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
789
|
-
|
315
|
+
}
|
316
|
+
Chunk.prototype = Object.create(Promise.prototype);
|
790
317
|
Chunk.prototype.then = function (resolve, reject) {
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
switch (chunk.status) {
|
795
|
-
case RESOLVED_MODEL:
|
796
|
-
initializeModelChunk(chunk);
|
318
|
+
switch (this.status) {
|
319
|
+
case "resolved_model":
|
320
|
+
initializeModelChunk(this);
|
797
321
|
break;
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
switch (chunk.status) {
|
806
|
-
case INITIALIZED:
|
807
|
-
resolve(chunk.value);
|
322
|
+
case "resolved_module":
|
323
|
+
initializeModuleChunk(this);
|
324
|
+
}
|
325
|
+
switch (this.status) {
|
326
|
+
case "fulfilled":
|
327
|
+
resolve(this.value);
|
808
328
|
break;
|
809
|
-
|
810
|
-
case
|
811
|
-
case
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
}
|
817
|
-
|
818
|
-
chunk.value.push(resolve);
|
819
|
-
}
|
820
|
-
|
821
|
-
if (reject) {
|
822
|
-
if (chunk.reason === null) {
|
823
|
-
chunk.reason = [];
|
824
|
-
}
|
825
|
-
|
826
|
-
chunk.reason.push(reject);
|
827
|
-
}
|
828
|
-
|
329
|
+
case "pending":
|
330
|
+
case "blocked":
|
331
|
+
case "cyclic":
|
332
|
+
resolve &&
|
333
|
+
(null === this.value && (this.value = []), this.value.push(resolve));
|
334
|
+
reject &&
|
335
|
+
(null === this.reason && (this.reason = []), this.reason.push(reject));
|
829
336
|
break;
|
830
|
-
|
831
337
|
default:
|
832
|
-
|
833
|
-
reject(chunk.reason);
|
834
|
-
}
|
835
|
-
|
836
|
-
break;
|
338
|
+
reject && reject(this.reason);
|
837
339
|
}
|
838
340
|
};
|
839
|
-
|
840
341
|
function readChunk(chunk) {
|
841
|
-
// If we have resolved content, we try to initialize it first which
|
842
|
-
// might put us back into one of the other states.
|
843
342
|
switch (chunk.status) {
|
844
|
-
case
|
343
|
+
case "resolved_model":
|
845
344
|
initializeModelChunk(chunk);
|
846
345
|
break;
|
847
|
-
|
848
|
-
case RESOLVED_MODULE:
|
346
|
+
case "resolved_module":
|
849
347
|
initializeModuleChunk(chunk);
|
850
|
-
|
851
|
-
} // The status might have changed after initialization.
|
852
|
-
|
853
|
-
|
348
|
+
}
|
854
349
|
switch (chunk.status) {
|
855
|
-
case
|
350
|
+
case "fulfilled":
|
856
351
|
return chunk.value;
|
857
|
-
|
858
|
-
case
|
859
|
-
case
|
860
|
-
case CYCLIC:
|
861
|
-
// eslint-disable-next-line no-throw-literal
|
352
|
+
case "pending":
|
353
|
+
case "blocked":
|
354
|
+
case "cyclic":
|
862
355
|
throw chunk;
|
863
|
-
|
864
356
|
default:
|
865
357
|
throw chunk.reason;
|
866
358
|
}
|
867
359
|
}
|
868
|
-
|
869
|
-
function getRoot(response) {
|
870
|
-
const chunk = getChunk(response, 0);
|
871
|
-
return chunk;
|
872
|
-
}
|
873
|
-
|
874
|
-
function createPendingChunk(response) {
|
875
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
876
|
-
return new Chunk(PENDING, null, null, response);
|
877
|
-
}
|
878
|
-
|
879
|
-
function createBlockedChunk(response) {
|
880
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
881
|
-
return new Chunk(BLOCKED, null, null, response);
|
882
|
-
}
|
883
|
-
|
884
|
-
function createErrorChunk(response, error) {
|
885
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
886
|
-
return new Chunk(ERRORED, null, error, response);
|
887
|
-
}
|
888
|
-
|
889
360
|
function wakeChunk(listeners, value) {
|
890
|
-
for (
|
891
|
-
const listener = listeners[i];
|
892
|
-
listener(value);
|
893
|
-
}
|
361
|
+
for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value);
|
894
362
|
}
|
895
|
-
|
896
363
|
function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
|
897
364
|
switch (chunk.status) {
|
898
|
-
case
|
365
|
+
case "fulfilled":
|
899
366
|
wakeChunk(resolveListeners, chunk.value);
|
900
367
|
break;
|
901
|
-
|
902
|
-
case
|
903
|
-
case
|
904
|
-
case CYCLIC:
|
368
|
+
case "pending":
|
369
|
+
case "blocked":
|
370
|
+
case "cyclic":
|
905
371
|
chunk.value = resolveListeners;
|
906
372
|
chunk.reason = rejectListeners;
|
907
373
|
break;
|
908
|
-
|
909
|
-
|
910
|
-
if (rejectListeners) {
|
911
|
-
wakeChunk(rejectListeners, chunk.reason);
|
912
|
-
}
|
913
|
-
|
914
|
-
break;
|
374
|
+
case "rejected":
|
375
|
+
rejectListeners && wakeChunk(rejectListeners, chunk.reason);
|
915
376
|
}
|
916
377
|
}
|
917
|
-
|
918
378
|
function triggerErrorOnChunk(chunk, error) {
|
919
|
-
if (chunk.status
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
const listeners = chunk.reason;
|
925
|
-
const erroredChunk = chunk;
|
926
|
-
erroredChunk.status = ERRORED;
|
927
|
-
erroredChunk.reason = error;
|
928
|
-
|
929
|
-
if (listeners !== null) {
|
930
|
-
wakeChunk(listeners, error);
|
931
|
-
}
|
932
|
-
}
|
933
|
-
|
934
|
-
function createResolvedModelChunk(response, value) {
|
935
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
936
|
-
return new Chunk(RESOLVED_MODEL, value, null, response);
|
937
|
-
}
|
938
|
-
|
939
|
-
function createResolvedModuleChunk(response, value) {
|
940
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
941
|
-
return new Chunk(RESOLVED_MODULE, value, null, response);
|
942
|
-
}
|
943
|
-
|
944
|
-
function createInitializedTextChunk(response, value) {
|
945
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
946
|
-
return new Chunk(INITIALIZED, value, null, response);
|
947
|
-
}
|
948
|
-
|
949
|
-
function resolveModelChunk(chunk, value) {
|
950
|
-
if (chunk.status !== PENDING) {
|
951
|
-
|
952
|
-
return;
|
953
|
-
}
|
954
|
-
|
955
|
-
const resolveListeners = chunk.value;
|
956
|
-
const rejectListeners = chunk.reason;
|
957
|
-
const resolvedChunk = chunk;
|
958
|
-
resolvedChunk.status = RESOLVED_MODEL;
|
959
|
-
resolvedChunk.value = value;
|
960
|
-
|
961
|
-
if (resolveListeners !== null) {
|
962
|
-
// This is unfortunate that we're reading this eagerly if
|
963
|
-
// we already have listeners attached since they might no
|
964
|
-
// longer be rendered or might not be the highest pri.
|
965
|
-
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
966
|
-
|
967
|
-
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
379
|
+
if ("pending" === chunk.status || "blocked" === chunk.status) {
|
380
|
+
var listeners = chunk.reason;
|
381
|
+
chunk.status = "rejected";
|
382
|
+
chunk.reason = error;
|
383
|
+
null !== listeners && wakeChunk(listeners, error);
|
968
384
|
}
|
969
385
|
}
|
970
|
-
|
971
386
|
function resolveModuleChunk(chunk, value) {
|
972
|
-
if (chunk.status
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
resolvedChunk.status = RESOLVED_MODULE;
|
981
|
-
resolvedChunk.value = value;
|
982
|
-
|
983
|
-
if (resolveListeners !== null) {
|
984
|
-
initializeModuleChunk(resolvedChunk);
|
985
|
-
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
387
|
+
if ("pending" === chunk.status || "blocked" === chunk.status) {
|
388
|
+
var resolveListeners = chunk.value,
|
389
|
+
rejectListeners = chunk.reason;
|
390
|
+
chunk.status = "resolved_module";
|
391
|
+
chunk.value = value;
|
392
|
+
null !== resolveListeners &&
|
393
|
+
(initializeModuleChunk(chunk),
|
394
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
|
986
395
|
}
|
987
396
|
}
|
988
|
-
|
989
|
-
|
990
|
-
let initializingChunkBlockedModel = null;
|
991
|
-
|
397
|
+
var initializingChunk = null,
|
398
|
+
initializingChunkBlockedModel = null;
|
992
399
|
function initializeModelChunk(chunk) {
|
993
|
-
|
994
|
-
|
400
|
+
var prevChunk = initializingChunk,
|
401
|
+
prevBlocked = initializingChunkBlockedModel;
|
995
402
|
initializingChunk = chunk;
|
996
403
|
initializingChunkBlockedModel = null;
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
const cyclicChunk = chunk;
|
1002
|
-
cyclicChunk.status = CYCLIC;
|
1003
|
-
cyclicChunk.value = null;
|
1004
|
-
cyclicChunk.reason = null;
|
1005
|
-
|
404
|
+
var resolvedModel = chunk.value;
|
405
|
+
chunk.status = "cyclic";
|
406
|
+
chunk.value = null;
|
407
|
+
chunk.reason = null;
|
1006
408
|
try {
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
initializedChunk.value = value;
|
1022
|
-
|
1023
|
-
if (resolveListeners !== null) {
|
1024
|
-
wakeChunk(resolveListeners, value);
|
1025
|
-
}
|
409
|
+
var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
|
410
|
+
if (
|
411
|
+
null !== initializingChunkBlockedModel &&
|
412
|
+
0 < initializingChunkBlockedModel.deps
|
413
|
+
)
|
414
|
+
(initializingChunkBlockedModel.value = value),
|
415
|
+
(chunk.status = "blocked"),
|
416
|
+
(chunk.value = null),
|
417
|
+
(chunk.reason = null);
|
418
|
+
else {
|
419
|
+
var resolveListeners = chunk.value;
|
420
|
+
chunk.status = "fulfilled";
|
421
|
+
chunk.value = value;
|
422
|
+
null !== resolveListeners && wakeChunk(resolveListeners, value);
|
1026
423
|
}
|
1027
424
|
} catch (error) {
|
1028
|
-
|
1029
|
-
erroredChunk.status = ERRORED;
|
1030
|
-
erroredChunk.reason = error;
|
425
|
+
(chunk.status = "rejected"), (chunk.reason = error);
|
1031
426
|
} finally {
|
1032
|
-
initializingChunk = prevChunk
|
1033
|
-
|
427
|
+
(initializingChunk = prevChunk),
|
428
|
+
(initializingChunkBlockedModel = prevBlocked);
|
1034
429
|
}
|
1035
430
|
}
|
1036
|
-
|
1037
431
|
function initializeModuleChunk(chunk) {
|
1038
432
|
try {
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
433
|
+
var metadata = chunk.value,
|
434
|
+
moduleExports = __webpack_require__(metadata[0]);
|
435
|
+
if (4 === metadata.length && "function" === typeof moduleExports.then)
|
436
|
+
if ("fulfilled" === moduleExports.status)
|
437
|
+
moduleExports = moduleExports.value;
|
438
|
+
else throw moduleExports.reason;
|
439
|
+
var JSCompiler_inline_result =
|
440
|
+
"*" === metadata[2]
|
441
|
+
? moduleExports
|
442
|
+
: "" === metadata[2]
|
443
|
+
? moduleExports.__esModule
|
444
|
+
? moduleExports.default
|
445
|
+
: moduleExports
|
446
|
+
: moduleExports[metadata[2]];
|
447
|
+
chunk.status = "fulfilled";
|
448
|
+
chunk.value = JSCompiler_inline_result;
|
1043
449
|
} catch (error) {
|
1044
|
-
|
1045
|
-
erroredChunk.status = ERRORED;
|
1046
|
-
erroredChunk.reason = error;
|
450
|
+
(chunk.status = "rejected"), (chunk.reason = error);
|
1047
451
|
}
|
1048
|
-
}
|
1049
|
-
// error upon read. Also notify any pending promises.
|
1050
|
-
|
1051
|
-
|
452
|
+
}
|
1052
453
|
function reportGlobalError(response, error) {
|
1053
|
-
response._chunks.forEach(chunk
|
1054
|
-
|
1055
|
-
// trigger an error but if it wasn't then we need to
|
1056
|
-
// because we won't be getting any new data to resolve it.
|
1057
|
-
if (chunk.status === PENDING) {
|
1058
|
-
triggerErrorOnChunk(chunk, error);
|
1059
|
-
}
|
454
|
+
response._chunks.forEach(function (chunk) {
|
455
|
+
"pending" === chunk.status && triggerErrorOnChunk(chunk, error);
|
1060
456
|
});
|
1061
457
|
}
|
1062
|
-
|
1063
|
-
function createElement(type, key, props, owner) // DEV-only
|
1064
|
-
{
|
1065
|
-
let element;
|
1066
|
-
|
1067
|
-
{
|
1068
|
-
element = {
|
1069
|
-
// This tag allows us to uniquely identify this as a React Element
|
1070
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
1071
|
-
type,
|
1072
|
-
key,
|
1073
|
-
ref: null,
|
1074
|
-
props
|
1075
|
-
};
|
1076
|
-
}
|
1077
|
-
|
1078
|
-
return element;
|
1079
|
-
}
|
1080
|
-
|
1081
|
-
function createLazyChunkWrapper(chunk) {
|
1082
|
-
const lazyType = {
|
1083
|
-
$$typeof: REACT_LAZY_TYPE,
|
1084
|
-
_payload: chunk,
|
1085
|
-
_init: readChunk
|
1086
|
-
};
|
1087
|
-
|
1088
|
-
return lazyType;
|
1089
|
-
}
|
1090
|
-
|
1091
458
|
function getChunk(response, id) {
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
chunk
|
1097
|
-
chunks.set(id, chunk);
|
1098
|
-
}
|
1099
|
-
|
459
|
+
var chunks = response._chunks,
|
460
|
+
chunk = chunks.get(id);
|
461
|
+
chunk ||
|
462
|
+
((chunk = new Chunk("pending", null, null, response)),
|
463
|
+
chunks.set(id, chunk));
|
1100
464
|
return chunk;
|
1101
465
|
}
|
1102
|
-
|
1103
466
|
function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
if (!cyclic) {
|
1110
|
-
blocked.deps++;
|
1111
|
-
}
|
1112
|
-
} else {
|
467
|
+
if (initializingChunkBlockedModel) {
|
468
|
+
var blocked = initializingChunkBlockedModel;
|
469
|
+
cyclic || blocked.deps++;
|
470
|
+
} else
|
1113
471
|
blocked = initializingChunkBlockedModel = {
|
1114
472
|
deps: cyclic ? 0 : 1,
|
1115
473
|
value: null
|
1116
474
|
};
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value`
|
1121
|
-
// is a stale `null`, the resolved value can be used directly.
|
1122
|
-
|
1123
|
-
if (key === '' && blocked.value === null) {
|
1124
|
-
blocked.value = parentObject[key];
|
1125
|
-
}
|
1126
|
-
|
475
|
+
return function (value) {
|
476
|
+
parentObject[key] = map(response, value);
|
477
|
+
"" === key && null === blocked.value && (blocked.value = parentObject[key]);
|
1127
478
|
blocked.deps--;
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
const resolveListeners = chunk.value;
|
1135
|
-
const initializedChunk = chunk;
|
1136
|
-
initializedChunk.status = INITIALIZED;
|
1137
|
-
initializedChunk.value = blocked.value;
|
1138
|
-
|
1139
|
-
if (resolveListeners !== null) {
|
1140
|
-
wakeChunk(resolveListeners, blocked.value);
|
1141
|
-
}
|
1142
|
-
}
|
479
|
+
0 === blocked.deps &&
|
480
|
+
"blocked" === chunk.status &&
|
481
|
+
((value = chunk.value),
|
482
|
+
(chunk.status = "fulfilled"),
|
483
|
+
(chunk.value = blocked.value),
|
484
|
+
null !== value && wakeChunk(value, blocked.value));
|
1143
485
|
};
|
1144
486
|
}
|
1145
|
-
|
1146
487
|
function createModelReject(chunk) {
|
1147
|
-
return
|
488
|
+
return function (error) {
|
489
|
+
return triggerErrorOnChunk(chunk, error);
|
490
|
+
};
|
1148
491
|
}
|
1149
|
-
|
1150
492
|
function createServerReferenceProxy(response, metaData) {
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
return callServer(metaData.id, bound.concat(args));
|
1165
|
-
} // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
|
1166
|
-
// TODO: Remove the wrapper once that's fixed.
|
1167
|
-
|
1168
|
-
|
1169
|
-
return Promise.resolve(p).then(function (bound) {
|
1170
|
-
return callServer(metaData.id, bound.concat(args));
|
1171
|
-
});
|
1172
|
-
};
|
1173
|
-
|
1174
|
-
registerServerReference(proxy, metaData);
|
493
|
+
function proxy() {
|
494
|
+
var args = Array.prototype.slice.call(arguments),
|
495
|
+
p = metaData.bound;
|
496
|
+
return p
|
497
|
+
? "fulfilled" === p.status
|
498
|
+
? callServer(metaData.id, p.value.concat(args))
|
499
|
+
: Promise.resolve(p).then(function (bound) {
|
500
|
+
return callServer(metaData.id, bound.concat(args));
|
501
|
+
})
|
502
|
+
: callServer(metaData.id, args);
|
503
|
+
}
|
504
|
+
var callServer = response._callServer;
|
505
|
+
knownServerReferences.set(proxy, metaData);
|
1175
506
|
return proxy;
|
1176
507
|
}
|
1177
|
-
|
1178
508
|
function getOutlinedModel(response, id, parentObject, key, map) {
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
initializeModelChunk(chunk);
|
509
|
+
id = getChunk(response, id);
|
510
|
+
switch (id.status) {
|
511
|
+
case "resolved_model":
|
512
|
+
initializeModelChunk(id);
|
1184
513
|
break;
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
case
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
514
|
+
case "resolved_module":
|
515
|
+
initializeModuleChunk(id);
|
516
|
+
}
|
517
|
+
switch (id.status) {
|
518
|
+
case "fulfilled":
|
519
|
+
return map(response, id.value);
|
520
|
+
case "pending":
|
521
|
+
case "blocked":
|
522
|
+
case "cyclic":
|
523
|
+
var parentChunk = initializingChunk;
|
524
|
+
id.then(
|
525
|
+
createModelResolver(
|
526
|
+
parentChunk,
|
527
|
+
parentObject,
|
528
|
+
key,
|
529
|
+
"cyclic" === id.status,
|
530
|
+
response,
|
531
|
+
map
|
532
|
+
),
|
533
|
+
createModelReject(parentChunk)
|
534
|
+
);
|
1203
535
|
return null;
|
1204
|
-
|
1205
536
|
default:
|
1206
|
-
throw
|
537
|
+
throw id.reason;
|
1207
538
|
}
|
1208
539
|
}
|
1209
|
-
|
1210
540
|
function createMap(response, model) {
|
1211
541
|
return new Map(model);
|
1212
542
|
}
|
1213
|
-
|
1214
543
|
function createSet(response, model) {
|
1215
544
|
return new Set(model);
|
1216
545
|
}
|
1217
|
-
|
1218
546
|
function createFormData(response, model) {
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
return
|
547
|
+
response = new FormData();
|
548
|
+
for (var i = 0; i < model.length; i++)
|
549
|
+
response.append(model[i][0], model[i][1]);
|
550
|
+
return response;
|
551
|
+
}
|
552
|
+
function extractIterator(response, model) {
|
553
|
+
return model[Symbol.iterator]();
|
1226
554
|
}
|
1227
|
-
|
1228
555
|
function createModel(response, model) {
|
1229
556
|
return model;
|
1230
557
|
}
|
1231
|
-
|
1232
558
|
function parseModelString(response, parentObject, key, value) {
|
1233
|
-
if (value[0]
|
1234
|
-
if (
|
1235
|
-
// A very common symbol.
|
1236
|
-
return REACT_ELEMENT_TYPE;
|
1237
|
-
}
|
1238
|
-
|
559
|
+
if ("$" === value[0]) {
|
560
|
+
if ("$" === value) return REACT_ELEMENT_TYPE;
|
1239
561
|
switch (value[1]) {
|
1240
|
-
case
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
case
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
case
|
1310
|
-
|
1311
|
-
|
1312
|
-
return undefined;
|
1313
|
-
}
|
1314
|
-
|
1315
|
-
case 'K':
|
1316
|
-
{
|
1317
|
-
// FormData
|
1318
|
-
const id = parseInt(value.slice(2), 16);
|
1319
|
-
return getOutlinedModel(response, id, parentObject, key, createFormData);
|
1320
|
-
}
|
1321
|
-
|
1322
|
-
case 'I':
|
1323
|
-
{
|
1324
|
-
// $Infinity
|
1325
|
-
return Infinity;
|
1326
|
-
}
|
1327
|
-
|
1328
|
-
case '-':
|
1329
|
-
{
|
1330
|
-
// $-0 or $-Infinity
|
1331
|
-
if (value === '$-0') {
|
1332
|
-
return -0;
|
1333
|
-
} else {
|
1334
|
-
return -Infinity;
|
1335
|
-
}
|
1336
|
-
}
|
1337
|
-
|
1338
|
-
case 'N':
|
1339
|
-
{
|
1340
|
-
// $NaN
|
1341
|
-
return NaN;
|
1342
|
-
}
|
1343
|
-
|
1344
|
-
case 'u':
|
1345
|
-
{
|
1346
|
-
// matches "$undefined"
|
1347
|
-
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
1348
|
-
return undefined;
|
1349
|
-
}
|
1350
|
-
|
1351
|
-
case 'D':
|
1352
|
-
{
|
1353
|
-
// Date
|
1354
|
-
return new Date(Date.parse(value.slice(2)));
|
1355
|
-
}
|
1356
|
-
|
1357
|
-
case 'n':
|
1358
|
-
{
|
1359
|
-
// BigInt
|
1360
|
-
return BigInt(value.slice(2));
|
1361
|
-
}
|
1362
|
-
|
1363
|
-
case 'E':
|
1364
|
-
|
562
|
+
case "$":
|
563
|
+
return value.slice(1);
|
564
|
+
case "L":
|
565
|
+
return (
|
566
|
+
(parentObject = parseInt(value.slice(2), 16)),
|
567
|
+
(response = getChunk(response, parentObject)),
|
568
|
+
{ $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
|
569
|
+
);
|
570
|
+
case "@":
|
571
|
+
if (2 === value.length) return new Promise(function () {});
|
572
|
+
parentObject = parseInt(value.slice(2), 16);
|
573
|
+
return getChunk(response, parentObject);
|
574
|
+
case "S":
|
575
|
+
return Symbol.for(value.slice(2));
|
576
|
+
case "F":
|
577
|
+
return (
|
578
|
+
(value = parseInt(value.slice(2), 16)),
|
579
|
+
getOutlinedModel(
|
580
|
+
response,
|
581
|
+
value,
|
582
|
+
parentObject,
|
583
|
+
key,
|
584
|
+
createServerReferenceProxy
|
585
|
+
)
|
586
|
+
);
|
587
|
+
case "T":
|
588
|
+
parentObject = parseInt(value.slice(2), 16);
|
589
|
+
response = response._tempRefs;
|
590
|
+
if (null == response)
|
591
|
+
throw Error(
|
592
|
+
"Missing a temporary reference set but the RSC response returned a temporary reference. Pass a temporaryReference option with the set that was used with the reply."
|
593
|
+
);
|
594
|
+
if (0 > parentObject || parentObject >= response.length)
|
595
|
+
throw Error(
|
596
|
+
"The RSC response contained a reference that doesn't exist in the temporary reference set. Always pass the matching set that was used to create the reply when parsing its response."
|
597
|
+
);
|
598
|
+
return response[parentObject];
|
599
|
+
case "Q":
|
600
|
+
return (
|
601
|
+
(value = parseInt(value.slice(2), 16)),
|
602
|
+
getOutlinedModel(response, value, parentObject, key, createMap)
|
603
|
+
);
|
604
|
+
case "W":
|
605
|
+
return (
|
606
|
+
(value = parseInt(value.slice(2), 16)),
|
607
|
+
getOutlinedModel(response, value, parentObject, key, createSet)
|
608
|
+
);
|
609
|
+
case "B":
|
610
|
+
return;
|
611
|
+
case "K":
|
612
|
+
return (
|
613
|
+
(value = parseInt(value.slice(2), 16)),
|
614
|
+
getOutlinedModel(response, value, parentObject, key, createFormData)
|
615
|
+
);
|
616
|
+
case "i":
|
617
|
+
return (
|
618
|
+
(value = parseInt(value.slice(2), 16)),
|
619
|
+
getOutlinedModel(response, value, parentObject, key, extractIterator)
|
620
|
+
);
|
621
|
+
case "I":
|
622
|
+
return Infinity;
|
623
|
+
case "-":
|
624
|
+
return "$-0" === value ? -0 : -Infinity;
|
625
|
+
case "N":
|
626
|
+
return NaN;
|
627
|
+
case "u":
|
628
|
+
return;
|
629
|
+
case "D":
|
630
|
+
return new Date(Date.parse(value.slice(2)));
|
631
|
+
case "n":
|
632
|
+
return BigInt(value.slice(2));
|
1365
633
|
default:
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
}
|
634
|
+
return (
|
635
|
+
(value = parseInt(value.slice(1), 16)),
|
636
|
+
getOutlinedModel(response, value, parentObject, key, createModel)
|
637
|
+
);
|
1371
638
|
}
|
1372
639
|
}
|
1373
|
-
|
1374
|
-
return value;
|
1375
|
-
}
|
1376
|
-
|
1377
|
-
function parseModelTuple(response, value) {
|
1378
|
-
const tuple = value;
|
1379
|
-
|
1380
|
-
if (tuple[0] === REACT_ELEMENT_TYPE) {
|
1381
|
-
// TODO: Consider having React just directly accept these arrays as elements.
|
1382
|
-
// Or even change the ReactElement type to be an array.
|
1383
|
-
return createElement(tuple[1], tuple[2], tuple[3]);
|
1384
|
-
}
|
1385
|
-
|
1386
640
|
return value;
|
1387
641
|
}
|
1388
|
-
|
1389
642
|
function missingCall() {
|
1390
|
-
throw
|
643
|
+
throw Error(
|
644
|
+
'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
|
645
|
+
);
|
1391
646
|
}
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
647
|
+
function resolveModule(response, id, model) {
|
648
|
+
var chunks = response._chunks,
|
649
|
+
chunk = chunks.get(id);
|
650
|
+
model = JSON.parse(model, response._fromJSON);
|
651
|
+
var clientReference = resolveClientReference(response._bundlerConfig, model);
|
652
|
+
if ((model = preloadModule(clientReference))) {
|
653
|
+
if (chunk) {
|
654
|
+
var blockedChunk = chunk;
|
655
|
+
blockedChunk.status = "blocked";
|
656
|
+
} else
|
657
|
+
(blockedChunk = new Chunk("blocked", null, null, response)),
|
658
|
+
chunks.set(id, blockedChunk);
|
659
|
+
model.then(
|
660
|
+
function () {
|
661
|
+
return resolveModuleChunk(blockedChunk, clientReference);
|
662
|
+
},
|
663
|
+
function (error) {
|
664
|
+
return triggerErrorOnChunk(blockedChunk, error);
|
665
|
+
}
|
666
|
+
);
|
667
|
+
} else
|
668
|
+
chunk
|
669
|
+
? resolveModuleChunk(chunk, clientReference)
|
670
|
+
: chunks.set(
|
671
|
+
id,
|
672
|
+
new Chunk("resolved_module", clientReference, null, response)
|
673
|
+
);
|
674
|
+
}
|
675
|
+
function createFromJSONCallback(response) {
|
676
|
+
return function (key, value) {
|
677
|
+
return "string" === typeof value
|
678
|
+
? parseModelString(response, this, key, value)
|
679
|
+
: "object" === typeof value && null !== value
|
680
|
+
? ((key =
|
681
|
+
value[0] === REACT_ELEMENT_TYPE
|
682
|
+
? {
|
683
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
684
|
+
type: value[1],
|
685
|
+
key: value[2],
|
686
|
+
ref: null,
|
687
|
+
props: value[3]
|
688
|
+
}
|
689
|
+
: value),
|
690
|
+
key)
|
691
|
+
: value;
|
692
|
+
};
|
693
|
+
}
|
694
|
+
function createResponseFromOptions(options) {
|
695
|
+
var callServer = options && options.callServer ? options.callServer : void 0;
|
696
|
+
options =
|
697
|
+
options && options.temporaryReferences
|
698
|
+
? options.temporaryReferences
|
699
|
+
: void 0;
|
700
|
+
var chunks = new Map();
|
701
|
+
callServer = {
|
702
|
+
_bundlerConfig: null,
|
703
|
+
_moduleLoading: null,
|
704
|
+
_callServer: void 0 !== callServer ? callServer : missingCall,
|
705
|
+
_encodeFormAction: void 0,
|
706
|
+
_nonce: void 0,
|
1401
707
|
_chunks: chunks,
|
1402
|
-
_stringDecoder:
|
708
|
+
_stringDecoder: new TextDecoder(),
|
1403
709
|
_fromJSON: null,
|
1404
710
|
_rowState: 0,
|
1405
711
|
_rowID: 0,
|
1406
712
|
_rowTag: 0,
|
1407
713
|
_rowLength: 0,
|
1408
714
|
_buffer: [],
|
1409
|
-
_tempRefs:
|
1410
|
-
};
|
1411
|
-
|
1412
|
-
|
1413
|
-
return response;
|
1414
|
-
}
|
1415
|
-
|
1416
|
-
function resolveModel(response, id, model) {
|
1417
|
-
const chunks = response._chunks;
|
1418
|
-
const chunk = chunks.get(id);
|
1419
|
-
|
1420
|
-
if (!chunk) {
|
1421
|
-
chunks.set(id, createResolvedModelChunk(response, model));
|
1422
|
-
} else {
|
1423
|
-
resolveModelChunk(chunk, model);
|
1424
|
-
}
|
1425
|
-
}
|
1426
|
-
|
1427
|
-
function resolveText(response, id, text) {
|
1428
|
-
const chunks = response._chunks;
|
1429
|
-
|
1430
|
-
chunks.set(id, createInitializedTextChunk(response, text));
|
1431
|
-
}
|
1432
|
-
|
1433
|
-
function resolveModule(response, id, model) {
|
1434
|
-
const chunks = response._chunks;
|
1435
|
-
const chunk = chunks.get(id);
|
1436
|
-
const clientReferenceMetadata = parseModel(response, model);
|
1437
|
-
const clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata);
|
1438
|
-
// For now we preload all modules as early as possible since it's likely
|
1439
|
-
// that we'll need them.
|
1440
|
-
|
1441
|
-
const promise = preloadModule(clientReference);
|
1442
|
-
|
1443
|
-
if (promise) {
|
1444
|
-
let blockedChunk;
|
1445
|
-
|
1446
|
-
if (!chunk) {
|
1447
|
-
// Technically, we should just treat promise as the chunk in this
|
1448
|
-
// case. Because it'll just behave as any other promise.
|
1449
|
-
blockedChunk = createBlockedChunk(response);
|
1450
|
-
chunks.set(id, blockedChunk);
|
1451
|
-
} else {
|
1452
|
-
// This can't actually happen because we don't have any forward
|
1453
|
-
// references to modules.
|
1454
|
-
blockedChunk = chunk;
|
1455
|
-
blockedChunk.status = BLOCKED;
|
1456
|
-
}
|
1457
|
-
|
1458
|
-
promise.then(() => resolveModuleChunk(blockedChunk, clientReference), error => triggerErrorOnChunk(blockedChunk, error));
|
1459
|
-
} else {
|
1460
|
-
if (!chunk) {
|
1461
|
-
chunks.set(id, createResolvedModuleChunk(response, clientReference));
|
1462
|
-
} else {
|
1463
|
-
// This can't actually happen because we don't have any forward
|
1464
|
-
// references to modules.
|
1465
|
-
resolveModuleChunk(chunk, clientReference);
|
1466
|
-
}
|
1467
|
-
}
|
1468
|
-
}
|
1469
|
-
|
1470
|
-
function resolveErrorProd(response, id, digest) {
|
1471
|
-
|
1472
|
-
const error = new Error('An error occurred in the Server Components render. The specific message is omitted in production' + ' builds to avoid leaking sensitive details. A digest property is included on this error instance which' + ' may provide additional details about the nature of the error.');
|
1473
|
-
error.stack = 'Error: ' + error.message;
|
1474
|
-
error.digest = digest;
|
1475
|
-
const errorWithDigest = error;
|
1476
|
-
const chunks = response._chunks;
|
1477
|
-
const chunk = chunks.get(id);
|
1478
|
-
|
1479
|
-
if (!chunk) {
|
1480
|
-
chunks.set(id, createErrorChunk(response, errorWithDigest));
|
1481
|
-
} else {
|
1482
|
-
triggerErrorOnChunk(chunk, errorWithDigest);
|
1483
|
-
}
|
1484
|
-
}
|
1485
|
-
|
1486
|
-
function resolveHint(response, code, model) {
|
1487
|
-
const hintModel = parseModel(response, model);
|
1488
|
-
dispatchHint(code, hintModel);
|
1489
|
-
}
|
1490
|
-
|
1491
|
-
function processFullRow(response, id, tag, buffer, chunk) {
|
1492
|
-
|
1493
|
-
const stringDecoder = response._stringDecoder;
|
1494
|
-
let row = '';
|
1495
|
-
|
1496
|
-
for (let i = 0; i < buffer.length; i++) {
|
1497
|
-
row += readPartialStringChunk(stringDecoder, buffer[i]);
|
1498
|
-
}
|
1499
|
-
|
1500
|
-
row += readFinalStringChunk(stringDecoder, chunk);
|
1501
|
-
|
1502
|
-
switch (tag) {
|
1503
|
-
case 73
|
1504
|
-
/* "I" */
|
1505
|
-
:
|
1506
|
-
{
|
1507
|
-
resolveModule(response, id, row);
|
1508
|
-
return;
|
1509
|
-
}
|
1510
|
-
|
1511
|
-
case 72
|
1512
|
-
/* "H" */
|
1513
|
-
:
|
1514
|
-
{
|
1515
|
-
const code = row[0];
|
1516
|
-
resolveHint(response, code, row.slice(1));
|
1517
|
-
return;
|
1518
|
-
}
|
1519
|
-
|
1520
|
-
case 69
|
1521
|
-
/* "E" */
|
1522
|
-
:
|
1523
|
-
{
|
1524
|
-
const errorInfo = JSON.parse(row);
|
1525
|
-
|
1526
|
-
{
|
1527
|
-
resolveErrorProd(response, id, errorInfo.digest);
|
1528
|
-
}
|
1529
|
-
|
1530
|
-
return;
|
1531
|
-
}
|
1532
|
-
|
1533
|
-
case 84
|
1534
|
-
/* "T" */
|
1535
|
-
:
|
1536
|
-
{
|
1537
|
-
resolveText(response, id, row);
|
1538
|
-
return;
|
1539
|
-
}
|
1540
|
-
|
1541
|
-
case 68
|
1542
|
-
/* "D" */
|
1543
|
-
:
|
1544
|
-
|
1545
|
-
case 87
|
1546
|
-
/* "W" */
|
1547
|
-
:
|
1548
|
-
{
|
1549
|
-
|
1550
|
-
throw new Error('Failed to read a RSC payload created by a development version of React ' + 'on the server while using a production version on the client. Always use ' + 'matching versions on the server and the client.');
|
1551
|
-
}
|
1552
|
-
|
1553
|
-
case 82
|
1554
|
-
/* "R" */
|
1555
|
-
:
|
1556
|
-
// Fallthrough
|
1557
|
-
|
1558
|
-
case 114
|
1559
|
-
/* "r" */
|
1560
|
-
:
|
1561
|
-
// Fallthrough
|
1562
|
-
|
1563
|
-
case 88
|
1564
|
-
/* "X" */
|
1565
|
-
:
|
1566
|
-
// Fallthrough
|
1567
|
-
|
1568
|
-
case 120
|
1569
|
-
/* "x" */
|
1570
|
-
:
|
1571
|
-
// Fallthrough
|
1572
|
-
|
1573
|
-
case 67
|
1574
|
-
/* "C" */
|
1575
|
-
:
|
1576
|
-
// Fallthrough
|
1577
|
-
|
1578
|
-
case 80
|
1579
|
-
/* "P" */
|
1580
|
-
:
|
1581
|
-
// Fallthrough
|
1582
|
-
|
1583
|
-
default:
|
1584
|
-
/* """ "{" "[" "t" "f" "n" "0" - "9" */
|
1585
|
-
{
|
1586
|
-
// We assume anything else is JSON.
|
1587
|
-
resolveModel(response, id, row);
|
1588
|
-
return;
|
1589
|
-
}
|
1590
|
-
}
|
715
|
+
_tempRefs: options
|
716
|
+
};
|
717
|
+
callServer._fromJSON = createFromJSONCallback(callServer);
|
718
|
+
return callServer;
|
1591
719
|
}
|
1592
|
-
|
1593
|
-
function
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
rowTag
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
720
|
+
function startReadingFromStream(response, stream) {
|
721
|
+
function progress(_ref) {
|
722
|
+
var value = _ref.value;
|
723
|
+
if (_ref.done) reportGlobalError(response, Error("Connection closed."));
|
724
|
+
else {
|
725
|
+
var i = 0,
|
726
|
+
rowState = response._rowState,
|
727
|
+
rowID = response._rowID,
|
728
|
+
rowTag = response._rowTag,
|
729
|
+
rowLength = response._rowLength;
|
730
|
+
_ref = response._buffer;
|
731
|
+
for (var chunkLength = value.length; i < chunkLength; ) {
|
732
|
+
var lastIdx = -1;
|
733
|
+
switch (rowState) {
|
734
|
+
case 0:
|
735
|
+
lastIdx = value[i++];
|
736
|
+
58 === lastIdx
|
737
|
+
? (rowState = 1)
|
738
|
+
: (rowID =
|
739
|
+
(rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
|
740
|
+
continue;
|
741
|
+
case 1:
|
742
|
+
rowState = value[i];
|
743
|
+
84 === rowState
|
744
|
+
? ((rowTag = rowState), (rowState = 2), i++)
|
745
|
+
: (64 < rowState && 91 > rowState) ||
|
746
|
+
114 === rowState ||
|
747
|
+
120 === rowState
|
748
|
+
? ((rowTag = rowState), (rowState = 3), i++)
|
749
|
+
: ((rowTag = 0), (rowState = 3));
|
750
|
+
continue;
|
751
|
+
case 2:
|
752
|
+
lastIdx = value[i++];
|
753
|
+
44 === lastIdx
|
754
|
+
? (rowState = 4)
|
755
|
+
: (rowLength =
|
756
|
+
(rowLength << 4) |
|
757
|
+
(96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
|
758
|
+
continue;
|
759
|
+
case 3:
|
760
|
+
lastIdx = value.indexOf(10, i);
|
761
|
+
break;
|
762
|
+
case 4:
|
763
|
+
(lastIdx = i + rowLength), lastIdx > value.length && (lastIdx = -1);
|
764
|
+
}
|
765
|
+
var offset = value.byteOffset + i;
|
766
|
+
if (-1 < lastIdx) {
|
767
|
+
i = new Uint8Array(value.buffer, offset, lastIdx - i);
|
768
|
+
rowLength = response;
|
769
|
+
offset = rowTag;
|
770
|
+
var stringDecoder = rowLength._stringDecoder;
|
771
|
+
rowTag = "";
|
772
|
+
for (var i$jscomp$0 = 0; i$jscomp$0 < _ref.length; i$jscomp$0++)
|
773
|
+
rowTag += stringDecoder.decode(_ref[i$jscomp$0], decoderOptions);
|
774
|
+
rowTag += stringDecoder.decode(i);
|
775
|
+
switch (offset) {
|
776
|
+
case 73:
|
777
|
+
resolveModule(rowLength, rowID, rowTag);
|
778
|
+
break;
|
779
|
+
case 72:
|
780
|
+
rowID = rowTag[0];
|
781
|
+
rowTag = rowTag.slice(1);
|
782
|
+
rowLength = JSON.parse(rowTag, rowLength._fromJSON);
|
783
|
+
rowTag = ReactDOMSharedInternals.d;
|
784
|
+
switch (rowID) {
|
785
|
+
case "D":
|
786
|
+
rowTag.D(rowLength);
|
787
|
+
break;
|
788
|
+
case "C":
|
789
|
+
"string" === typeof rowLength
|
790
|
+
? rowTag.C(rowLength)
|
791
|
+
: rowTag.C(rowLength[0], rowLength[1]);
|
792
|
+
break;
|
793
|
+
case "L":
|
794
|
+
rowID = rowLength[0];
|
795
|
+
i = rowLength[1];
|
796
|
+
3 === rowLength.length
|
797
|
+
? rowTag.L(rowID, i, rowLength[2])
|
798
|
+
: rowTag.L(rowID, i);
|
799
|
+
break;
|
800
|
+
case "m":
|
801
|
+
"string" === typeof rowLength
|
802
|
+
? rowTag.m(rowLength)
|
803
|
+
: rowTag.m(rowLength[0], rowLength[1]);
|
804
|
+
break;
|
805
|
+
case "X":
|
806
|
+
"string" === typeof rowLength
|
807
|
+
? rowTag.X(rowLength)
|
808
|
+
: rowTag.X(rowLength[0], rowLength[1]);
|
809
|
+
break;
|
810
|
+
case "S":
|
811
|
+
"string" === typeof rowLength
|
812
|
+
? rowTag.S(rowLength)
|
813
|
+
: rowTag.S(
|
814
|
+
rowLength[0],
|
815
|
+
0 === rowLength[1] ? void 0 : rowLength[1],
|
816
|
+
3 === rowLength.length ? rowLength[2] : void 0
|
817
|
+
);
|
818
|
+
break;
|
819
|
+
case "M":
|
820
|
+
"string" === typeof rowLength
|
821
|
+
? rowTag.M(rowLength)
|
822
|
+
: rowTag.M(rowLength[0], rowLength[1]);
|
823
|
+
}
|
824
|
+
break;
|
825
|
+
case 69:
|
826
|
+
rowTag = JSON.parse(rowTag);
|
827
|
+
i = rowTag.digest;
|
828
|
+
rowTag = Error(
|
829
|
+
"An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
|
830
|
+
);
|
831
|
+
rowTag.stack = "Error: " + rowTag.message;
|
832
|
+
rowTag.digest = i;
|
833
|
+
i = rowLength._chunks;
|
834
|
+
(offset = i.get(rowID))
|
835
|
+
? triggerErrorOnChunk(offset, rowTag)
|
836
|
+
: i.set(rowID, new Chunk("rejected", null, rowTag, rowLength));
|
837
|
+
break;
|
838
|
+
case 84:
|
839
|
+
rowLength._chunks.set(
|
840
|
+
rowID,
|
841
|
+
new Chunk("fulfilled", rowTag, null, rowLength)
|
842
|
+
);
|
843
|
+
break;
|
844
|
+
case 68:
|
845
|
+
case 87:
|
846
|
+
throw Error(
|
847
|
+
"Failed to read a RSC payload created by a development version of React on the server while using a production version on the client. Always use matching versions on the server and the client."
|
848
|
+
);
|
849
|
+
default:
|
850
|
+
(i = rowLength._chunks),
|
851
|
+
(offset = i.get(rowID))
|
852
|
+
? ((rowLength = offset),
|
853
|
+
(rowID = rowTag),
|
854
|
+
"pending" === rowLength.status &&
|
855
|
+
((rowTag = rowLength.value),
|
856
|
+
(i = rowLength.reason),
|
857
|
+
(rowLength.status = "resolved_model"),
|
858
|
+
(rowLength.value = rowID),
|
859
|
+
null !== rowTag &&
|
860
|
+
(initializeModelChunk(rowLength),
|
861
|
+
wakeChunkIfInitialized(rowLength, rowTag, i))))
|
862
|
+
: i.set(
|
863
|
+
rowID,
|
864
|
+
new Chunk("resolved_model", rowTag, null, rowLength)
|
865
|
+
);
|
1684
866
|
}
|
1685
|
-
|
867
|
+
i = lastIdx;
|
868
|
+
3 === rowState && i++;
|
869
|
+
rowLength = rowID = rowTag = rowState = 0;
|
870
|
+
_ref.length = 0;
|
871
|
+
} else {
|
872
|
+
value = new Uint8Array(value.buffer, offset, value.byteLength - i);
|
873
|
+
_ref.push(value);
|
874
|
+
rowLength -= value.byteLength;
|
1686
875
|
break;
|
1687
876
|
}
|
1688
|
-
}
|
1689
|
-
|
1690
|
-
const offset = chunk.byteOffset + i;
|
1691
|
-
|
1692
|
-
if (lastIdx > -1) {
|
1693
|
-
// We found the last chunk of the row
|
1694
|
-
const length = lastIdx - i;
|
1695
|
-
const lastChunk = new Uint8Array(chunk.buffer, offset, length);
|
1696
|
-
processFullRow(response, rowID, rowTag, buffer, lastChunk); // Reset state machine for a new row
|
1697
|
-
|
1698
|
-
i = lastIdx;
|
1699
|
-
|
1700
|
-
if (rowState === ROW_CHUNK_BY_NEWLINE) {
|
1701
|
-
// If we're trailing by a newline we need to skip it.
|
1702
|
-
i++;
|
1703
877
|
}
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
buffer.length = 0;
|
1710
|
-
} else {
|
1711
|
-
// The rest of this row is in a future chunk. We stash the rest of the
|
1712
|
-
// current chunk until we can process the full row.
|
1713
|
-
const length = chunk.byteLength - i;
|
1714
|
-
const remainingSlice = new Uint8Array(chunk.buffer, offset, length);
|
1715
|
-
buffer.push(remainingSlice); // Update how many bytes we're still waiting for. If we're looking for
|
1716
|
-
// a newline, this doesn't hurt since we'll just ignore it.
|
1717
|
-
|
1718
|
-
rowLength -= remainingSlice.byteLength;
|
1719
|
-
break;
|
1720
|
-
}
|
1721
|
-
}
|
1722
|
-
|
1723
|
-
response._rowState = rowState;
|
1724
|
-
response._rowID = rowID;
|
1725
|
-
response._rowTag = rowTag;
|
1726
|
-
response._rowLength = rowLength;
|
1727
|
-
}
|
1728
|
-
|
1729
|
-
function parseModel(response, json) {
|
1730
|
-
return JSON.parse(json, response._fromJSON);
|
1731
|
-
}
|
1732
|
-
|
1733
|
-
function createFromJSONCallback(response) {
|
1734
|
-
// $FlowFixMe[missing-this-annot]
|
1735
|
-
return function (key, value) {
|
1736
|
-
if (typeof value === 'string') {
|
1737
|
-
// We can't use .bind here because we need the "this" value.
|
1738
|
-
return parseModelString(response, this, key, value);
|
1739
|
-
}
|
1740
|
-
|
1741
|
-
if (typeof value === 'object' && value !== null) {
|
1742
|
-
return parseModelTuple(response, value);
|
1743
|
-
}
|
1744
|
-
|
1745
|
-
return value;
|
1746
|
-
};
|
1747
|
-
}
|
1748
|
-
|
1749
|
-
function close(response) {
|
1750
|
-
// In case there are any remaining unresolved chunks, they won't
|
1751
|
-
// be resolved now. So we need to issue an error to those.
|
1752
|
-
// Ideally we should be able to early bail out if we kept a
|
1753
|
-
// ref count of pending chunks.
|
1754
|
-
reportGlobalError(response, new Error('Connection closed.'));
|
1755
|
-
}
|
1756
|
-
|
1757
|
-
function createResponseFromOptions(options) {
|
1758
|
-
return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined, // encodeFormAction
|
1759
|
-
undefined, // nonce
|
1760
|
-
options && options.temporaryReferences ? options.temporaryReferences : undefined);
|
1761
|
-
}
|
1762
|
-
|
1763
|
-
function startReadingFromStream(response, stream) {
|
1764
|
-
const reader = stream.getReader();
|
1765
|
-
|
1766
|
-
function progress(_ref) {
|
1767
|
-
let done = _ref.done,
|
1768
|
-
value = _ref.value;
|
1769
|
-
|
1770
|
-
if (done) {
|
1771
|
-
close(response);
|
1772
|
-
return;
|
878
|
+
response._rowState = rowState;
|
879
|
+
response._rowID = rowID;
|
880
|
+
response._rowTag = rowTag;
|
881
|
+
response._rowLength = rowLength;
|
882
|
+
return reader.read().then(progress).catch(error);
|
1773
883
|
}
|
1774
|
-
|
1775
|
-
const buffer = value;
|
1776
|
-
processBinaryChunk(response, buffer);
|
1777
|
-
return reader.read().then(progress).catch(error);
|
1778
884
|
}
|
1779
|
-
|
1780
885
|
function error(e) {
|
1781
886
|
reportGlobalError(response, e);
|
1782
887
|
}
|
1783
|
-
|
888
|
+
var reader = stream.getReader();
|
1784
889
|
reader.read().then(progress).catch(error);
|
1785
890
|
}
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
}
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
function
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
891
|
+
exports.createFromFetch = function (promiseForResponse, options) {
|
892
|
+
var response = createResponseFromOptions(options);
|
893
|
+
promiseForResponse.then(
|
894
|
+
function (r) {
|
895
|
+
startReadingFromStream(response, r.body);
|
896
|
+
},
|
897
|
+
function (e) {
|
898
|
+
reportGlobalError(response, e);
|
899
|
+
}
|
900
|
+
);
|
901
|
+
return getChunk(response, 0);
|
902
|
+
};
|
903
|
+
exports.createFromReadableStream = function (stream, options) {
|
904
|
+
options = createResponseFromOptions(options);
|
905
|
+
startReadingFromStream(options, stream);
|
906
|
+
return getChunk(options, 0);
|
907
|
+
};
|
908
|
+
exports.createServerReference = function (id, callServer) {
|
909
|
+
function proxy() {
|
910
|
+
var args = Array.prototype.slice.call(arguments);
|
911
|
+
return callServer(id, args);
|
912
|
+
}
|
913
|
+
registerServerReference(proxy, { id: id, bound: null });
|
914
|
+
return proxy;
|
915
|
+
};
|
916
|
+
exports.createTemporaryReferenceSet = function () {
|
917
|
+
return [];
|
918
|
+
};
|
919
|
+
exports.encodeReply = function (value, options) {
|
920
|
+
return new Promise(function (resolve, reject) {
|
921
|
+
processReply(
|
922
|
+
value,
|
923
|
+
"",
|
924
|
+
options && options.temporaryReferences
|
925
|
+
? options.temporaryReferences
|
926
|
+
: void 0,
|
927
|
+
resolve,
|
928
|
+
reject
|
929
|
+
);
|
1808
930
|
});
|
1809
|
-
}
|
1810
|
-
|
1811
|
-
exports.createFromFetch = createFromFetch;
|
1812
|
-
exports.createFromReadableStream = createFromReadableStream;
|
1813
|
-
exports.createServerReference = createServerReference;
|
1814
|
-
exports.createTemporaryReferenceSet = createTemporaryReferenceSet;
|
1815
|
-
exports.encodeReply = encodeReply;
|
931
|
+
};
|