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,14 +1,69 @@
|
|
1
|
-
|
2
|
-
React
|
3
|
-
react-server-dom-webpack-node-register.js
|
1
|
+
/**
|
2
|
+
* @license React
|
3
|
+
* react-server-dom-webpack-node-register.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
|
+
*/
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
"use strict";
|
12
|
+
const acorn = require("acorn-loose"),
|
13
|
+
url = require("url"),
|
14
|
+
Module = require("module");
|
15
|
+
module.exports = function () {
|
16
|
+
const Server = require("react-server-dom-webpack/server"),
|
17
|
+
registerServerReference = Server.registerServerReference,
|
18
|
+
createClientModuleProxy = Server.createClientModuleProxy,
|
19
|
+
originalCompile = Module.prototype._compile;
|
20
|
+
Module.prototype._compile = function (content, filename) {
|
21
|
+
if (
|
22
|
+
-1 === content.indexOf("use client") &&
|
23
|
+
-1 === content.indexOf("use server")
|
24
|
+
)
|
25
|
+
return originalCompile.apply(this, arguments);
|
26
|
+
try {
|
27
|
+
var body = acorn.parse(content, {
|
28
|
+
ecmaVersion: "2024",
|
29
|
+
sourceType: "source"
|
30
|
+
}).body;
|
31
|
+
} catch (x) {
|
32
|
+
return (
|
33
|
+
console.error("Error parsing %s %s", url, x.message),
|
34
|
+
originalCompile.apply(this, arguments)
|
35
|
+
);
|
36
|
+
}
|
37
|
+
var useClient = !1,
|
38
|
+
useServer = !1;
|
39
|
+
for (var i = 0; i < body.length; i++) {
|
40
|
+
var node = body[i];
|
41
|
+
if ("ExpressionStatement" !== node.type || !node.directive) break;
|
42
|
+
"use client" === node.directive && (useClient = !0);
|
43
|
+
"use server" === node.directive && (useServer = !0);
|
44
|
+
}
|
45
|
+
if (!useClient && !useServer) return originalCompile.apply(this, arguments);
|
46
|
+
if (useClient && useServer)
|
47
|
+
throw Error(
|
48
|
+
'Cannot have both "use client" and "use server" directives in the same file.'
|
49
|
+
);
|
50
|
+
useClient &&
|
51
|
+
((body = url.pathToFileURL(filename).href),
|
52
|
+
(this.exports = createClientModuleProxy(body)));
|
53
|
+
if (useServer)
|
54
|
+
if (
|
55
|
+
(originalCompile.apply(this, arguments),
|
56
|
+
(useServer = url.pathToFileURL(filename).href),
|
57
|
+
(body = this.exports),
|
58
|
+
"function" === typeof body)
|
59
|
+
)
|
60
|
+
registerServerReference(body, useServer, null);
|
61
|
+
else
|
62
|
+
for (useClient = Object.keys(body), i = 0; i < useClient.length; i++) {
|
63
|
+
node = useClient[i];
|
64
|
+
const value = body[useClient[i]];
|
65
|
+
"function" === typeof value &&
|
66
|
+
registerServerReference(value, useServer, node);
|
67
|
+
}
|
68
|
+
};
|
69
|
+
};
|
@@ -1,24 +1,399 @@
|
|
1
|
-
|
2
|
-
React
|
3
|
-
react-server-dom-webpack-plugin.js
|
1
|
+
/**
|
2
|
+
* @license React
|
3
|
+
* react-server-dom-webpack-plugin.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
|
+
*/
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
"use strict";
|
12
|
+
var path = require("path"),
|
13
|
+
url = require("url"),
|
14
|
+
asyncLib = require("neo-async"),
|
15
|
+
acorn = require("acorn-loose"),
|
16
|
+
ModuleDependency = require("webpack/lib/dependencies/ModuleDependency"),
|
17
|
+
NullDependency = require("webpack/lib/dependencies/NullDependency"),
|
18
|
+
Template = require("webpack/lib/Template"),
|
19
|
+
webpack = require("webpack");
|
20
|
+
function _unsupportedIterableToArray(o, minLen) {
|
21
|
+
if (o) {
|
22
|
+
if ("string" === typeof o) return _arrayLikeToArray(o, minLen);
|
23
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
24
|
+
"Object" === n && o.constructor && (n = o.constructor.name);
|
25
|
+
if ("Map" === n || "Set" === n) return Array.from(o);
|
26
|
+
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
27
|
+
return _arrayLikeToArray(o, minLen);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
function _arrayLikeToArray(arr, len) {
|
31
|
+
if (null == len || len > arr.length) len = arr.length;
|
32
|
+
for (var i = 0, arr2 = Array(len); i < len; i++) arr2[i] = arr[i];
|
33
|
+
return arr2;
|
34
|
+
}
|
35
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
36
|
+
var it;
|
37
|
+
if ("undefined" === typeof Symbol || null == o[Symbol.iterator]) {
|
38
|
+
if (
|
39
|
+
Array.isArray(o) ||
|
40
|
+
(it = _unsupportedIterableToArray(o)) ||
|
41
|
+
(allowArrayLike && o && "number" === typeof o.length)
|
42
|
+
) {
|
43
|
+
it && (o = it);
|
44
|
+
var i = 0;
|
45
|
+
allowArrayLike = function () {};
|
46
|
+
return {
|
47
|
+
s: allowArrayLike,
|
48
|
+
n: function () {
|
49
|
+
return i >= o.length ? { done: !0 } : { done: !1, value: o[i++] };
|
50
|
+
},
|
51
|
+
e: function (e) {
|
52
|
+
throw e;
|
53
|
+
},
|
54
|
+
f: allowArrayLike
|
55
|
+
};
|
56
|
+
}
|
57
|
+
throw new TypeError(
|
58
|
+
"Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
|
59
|
+
);
|
60
|
+
}
|
61
|
+
var normalCompletion = !0,
|
62
|
+
didErr = !1,
|
63
|
+
err;
|
64
|
+
return {
|
65
|
+
s: function () {
|
66
|
+
it = o[Symbol.iterator]();
|
67
|
+
},
|
68
|
+
n: function () {
|
69
|
+
var step = it.next();
|
70
|
+
normalCompletion = step.done;
|
71
|
+
return step;
|
72
|
+
},
|
73
|
+
e: function (e) {
|
74
|
+
didErr = !0;
|
75
|
+
err = e;
|
76
|
+
},
|
77
|
+
f: function () {
|
78
|
+
try {
|
79
|
+
normalCompletion || null == it.return || it.return();
|
80
|
+
} finally {
|
81
|
+
if (didErr) throw err;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
};
|
85
|
+
}
|
86
|
+
const isArrayImpl = Array.isArray;
|
87
|
+
class ClientReferenceDependency extends ModuleDependency {
|
88
|
+
constructor(request) {
|
89
|
+
super(request);
|
90
|
+
}
|
91
|
+
get type() {
|
92
|
+
return "client-reference";
|
93
|
+
}
|
94
|
+
}
|
95
|
+
const clientFileName = require.resolve("../client.browser.js");
|
96
|
+
class ReactFlightWebpackPlugin {
|
97
|
+
constructor(options) {
|
98
|
+
this.ssrManifestFilename =
|
99
|
+
this.clientManifestFilename =
|
100
|
+
this.chunkName =
|
101
|
+
this.clientReferences =
|
102
|
+
void 0;
|
103
|
+
if (!options || "boolean" !== typeof options.isServer)
|
104
|
+
throw Error(
|
105
|
+
"React Server Plugin: You must specify the isServer option as a boolean."
|
106
|
+
);
|
107
|
+
if (options.isServer) throw Error("TODO: Implement the server compiler.");
|
108
|
+
options.clientReferences
|
109
|
+
? "string" !== typeof options.clientReferences &&
|
110
|
+
isArrayImpl(options.clientReferences)
|
111
|
+
? (this.clientReferences = options.clientReferences)
|
112
|
+
: (this.clientReferences = [options.clientReferences])
|
113
|
+
: (this.clientReferences = [
|
114
|
+
{ directory: ".", recursive: !0, include: /\.(js|ts|jsx|tsx)$/ }
|
115
|
+
]);
|
116
|
+
"string" === typeof options.chunkName
|
117
|
+
? ((this.chunkName = options.chunkName),
|
118
|
+
/\[(index|request)\]/.test(this.chunkName) ||
|
119
|
+
(this.chunkName += "[index]"))
|
120
|
+
: (this.chunkName = "client[index]");
|
121
|
+
this.clientManifestFilename =
|
122
|
+
options.clientManifestFilename || "react-client-manifest.json";
|
123
|
+
this.ssrManifestFilename =
|
124
|
+
options.ssrManifestFilename || "react-ssr-manifest.json";
|
125
|
+
}
|
126
|
+
apply(compiler) {
|
127
|
+
const _this = this;
|
128
|
+
let resolvedClientReferences,
|
129
|
+
clientFileNameFound = !1;
|
130
|
+
compiler.hooks.beforeCompile.tapAsync(
|
131
|
+
"React Server Plugin",
|
132
|
+
(_ref, callback) => {
|
133
|
+
_ref = _ref.contextModuleFactory;
|
134
|
+
const contextResolver = compiler.resolverFactory.get("context", {}),
|
135
|
+
normalResolver = compiler.resolverFactory.get("normal");
|
136
|
+
_this.resolveAllClientFiles(
|
137
|
+
compiler.context,
|
138
|
+
contextResolver,
|
139
|
+
normalResolver,
|
140
|
+
compiler.inputFileSystem,
|
141
|
+
_ref,
|
142
|
+
function (err, resolvedClientRefs) {
|
143
|
+
err
|
144
|
+
? callback(err)
|
145
|
+
: ((resolvedClientReferences = resolvedClientRefs), callback());
|
146
|
+
}
|
147
|
+
);
|
148
|
+
}
|
149
|
+
);
|
150
|
+
compiler.hooks.thisCompilation.tap(
|
151
|
+
"React Server Plugin",
|
152
|
+
(compilation, _ref2) => {
|
153
|
+
_ref2 = _ref2.normalModuleFactory;
|
154
|
+
compilation.dependencyFactories.set(ClientReferenceDependency, _ref2);
|
155
|
+
compilation.dependencyTemplates.set(
|
156
|
+
ClientReferenceDependency,
|
157
|
+
new NullDependency.Template()
|
158
|
+
);
|
159
|
+
compilation = parser => {
|
160
|
+
parser.hooks.program.tap("React Server Plugin", () => {
|
161
|
+
const module = parser.state.module;
|
162
|
+
if (
|
163
|
+
module.resource === clientFileName &&
|
164
|
+
((clientFileNameFound = !0), resolvedClientReferences)
|
165
|
+
)
|
166
|
+
for (let i = 0; i < resolvedClientReferences.length; i++) {
|
167
|
+
const dep = resolvedClientReferences[i];
|
168
|
+
var chunkName = _this.chunkName
|
169
|
+
.replace(/\[index\]/g, "" + i)
|
170
|
+
.replace(/\[request\]/g, Template.toPath(dep.userRequest));
|
171
|
+
chunkName = new webpack.AsyncDependenciesBlock(
|
172
|
+
{ name: chunkName },
|
173
|
+
null,
|
174
|
+
dep.request
|
175
|
+
);
|
176
|
+
chunkName.addDependency(dep);
|
177
|
+
module.addBlock(chunkName);
|
178
|
+
}
|
179
|
+
});
|
180
|
+
};
|
181
|
+
_ref2.hooks.parser
|
182
|
+
.for("javascript/auto")
|
183
|
+
.tap("HarmonyModulesPlugin", compilation);
|
184
|
+
_ref2.hooks.parser
|
185
|
+
.for("javascript/esm")
|
186
|
+
.tap("HarmonyModulesPlugin", compilation);
|
187
|
+
_ref2.hooks.parser
|
188
|
+
.for("javascript/dynamic")
|
189
|
+
.tap("HarmonyModulesPlugin", compilation);
|
190
|
+
}
|
191
|
+
);
|
192
|
+
compiler.hooks.make.tap("React Server Plugin", compilation => {
|
193
|
+
compilation.hooks.processAssets.tap(
|
194
|
+
{
|
195
|
+
name: "React Server Plugin",
|
196
|
+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
197
|
+
},
|
198
|
+
function () {
|
199
|
+
if (!1 === clientFileNameFound)
|
200
|
+
compilation.warnings.push(
|
201
|
+
new webpack.WebpackError(
|
202
|
+
"Client runtime at react-server-dom-webpack/client was not found. React Server Components module map file " +
|
203
|
+
_this.clientManifestFilename +
|
204
|
+
" was not created."
|
205
|
+
)
|
206
|
+
);
|
207
|
+
else {
|
208
|
+
var configuredCrossOriginLoading =
|
209
|
+
compilation.outputOptions.crossOriginLoading;
|
210
|
+
configuredCrossOriginLoading =
|
211
|
+
"string" === typeof configuredCrossOriginLoading
|
212
|
+
? "use-credentials" === configuredCrossOriginLoading
|
213
|
+
? configuredCrossOriginLoading
|
214
|
+
: "anonymous"
|
215
|
+
: null;
|
216
|
+
var resolvedClientFiles = new Set(
|
217
|
+
(resolvedClientReferences || []).map(ref => ref.request)
|
218
|
+
),
|
219
|
+
clientManifest = {},
|
220
|
+
moduleMap = {};
|
221
|
+
configuredCrossOriginLoading = {
|
222
|
+
moduleLoading: {
|
223
|
+
prefix: compilation.outputOptions.publicPath || "",
|
224
|
+
crossOrigin: configuredCrossOriginLoading
|
225
|
+
},
|
226
|
+
moduleMap
|
227
|
+
};
|
228
|
+
var runtimeChunkFiles = new Set();
|
229
|
+
compilation.entrypoints.forEach(entrypoint => {
|
230
|
+
(entrypoint = entrypoint.getRuntimeChunk()) &&
|
231
|
+
entrypoint.files.forEach(runtimeFile => {
|
232
|
+
runtimeChunkFiles.add(runtimeFile);
|
233
|
+
});
|
234
|
+
});
|
235
|
+
compilation.chunkGroups.forEach(function (chunkGroup) {
|
236
|
+
function recordModule(id, module) {
|
237
|
+
if (
|
238
|
+
resolvedClientFiles.has(module.resource) &&
|
239
|
+
((module = url.pathToFileURL(module.resource).href),
|
240
|
+
void 0 !== module)
|
241
|
+
) {
|
242
|
+
const ssrExports = {};
|
243
|
+
clientManifest[module] = { id, chunks, name: "*" };
|
244
|
+
ssrExports["*"] = { specifier: module, name: "*" };
|
245
|
+
moduleMap[id] = ssrExports;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
const chunks = [];
|
249
|
+
chunkGroup.chunks.forEach(function (c) {
|
250
|
+
var _iterator = _createForOfIteratorHelper(c.files),
|
251
|
+
_step;
|
252
|
+
try {
|
253
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
254
|
+
const file = _step.value;
|
255
|
+
if (!file.endsWith(".js")) break;
|
256
|
+
if (file.endsWith(".hot-update.js")) break;
|
257
|
+
chunks.push(c.id, file);
|
258
|
+
break;
|
259
|
+
}
|
260
|
+
} catch (err) {
|
261
|
+
_iterator.e(err);
|
262
|
+
} finally {
|
263
|
+
_iterator.f();
|
264
|
+
}
|
265
|
+
});
|
266
|
+
chunkGroup.chunks.forEach(function (chunk) {
|
267
|
+
chunk = compilation.chunkGraph.getChunkModulesIterable(chunk);
|
268
|
+
Array.from(chunk).forEach(function (module) {
|
269
|
+
const moduleId = compilation.chunkGraph.getModuleId(module);
|
270
|
+
recordModule(moduleId, module);
|
271
|
+
module.modules &&
|
272
|
+
module.modules.forEach(concatenatedMod => {
|
273
|
+
recordModule(moduleId, concatenatedMod);
|
274
|
+
});
|
275
|
+
});
|
276
|
+
});
|
277
|
+
});
|
278
|
+
var clientOutput = JSON.stringify(clientManifest, null, 2);
|
279
|
+
compilation.emitAsset(
|
280
|
+
_this.clientManifestFilename,
|
281
|
+
new webpack.sources.RawSource(clientOutput, !1)
|
282
|
+
);
|
283
|
+
configuredCrossOriginLoading = JSON.stringify(
|
284
|
+
configuredCrossOriginLoading,
|
285
|
+
null,
|
286
|
+
2
|
287
|
+
);
|
288
|
+
compilation.emitAsset(
|
289
|
+
_this.ssrManifestFilename,
|
290
|
+
new webpack.sources.RawSource(configuredCrossOriginLoading, !1)
|
291
|
+
);
|
292
|
+
}
|
293
|
+
}
|
294
|
+
);
|
295
|
+
});
|
296
|
+
}
|
297
|
+
resolveAllClientFiles(
|
298
|
+
context,
|
299
|
+
contextResolver,
|
300
|
+
normalResolver,
|
301
|
+
fs,
|
302
|
+
contextModuleFactory,
|
303
|
+
callback
|
304
|
+
) {
|
305
|
+
function hasUseClientDirective(source) {
|
306
|
+
if (-1 === source.indexOf("use client")) return !1;
|
307
|
+
let body;
|
308
|
+
try {
|
309
|
+
body = acorn.parse(source, {
|
310
|
+
ecmaVersion: "2024",
|
311
|
+
sourceType: "module"
|
312
|
+
}).body;
|
313
|
+
} catch (x) {
|
314
|
+
return !1;
|
315
|
+
}
|
316
|
+
for (source = 0; source < body.length; source++) {
|
317
|
+
const node = body[source];
|
318
|
+
if ("ExpressionStatement" !== node.type || !node.directive) break;
|
319
|
+
if ("use client" === node.directive) return !0;
|
320
|
+
}
|
321
|
+
return !1;
|
322
|
+
}
|
323
|
+
asyncLib.map(
|
324
|
+
this.clientReferences,
|
325
|
+
(clientReferencePath, cb) => {
|
326
|
+
"string" === typeof clientReferencePath
|
327
|
+
? cb(null, [new ClientReferenceDependency(clientReferencePath)])
|
328
|
+
: contextResolver.resolve(
|
329
|
+
{},
|
330
|
+
context,
|
331
|
+
clientReferencePath.directory,
|
332
|
+
{},
|
333
|
+
(err, resolvedDirectory) => {
|
334
|
+
if (err) return cb(err);
|
335
|
+
contextModuleFactory.resolveDependencies(
|
336
|
+
fs,
|
337
|
+
{
|
338
|
+
resource: resolvedDirectory,
|
339
|
+
resourceQuery: "",
|
340
|
+
recursive:
|
341
|
+
void 0 === clientReferencePath.recursive
|
342
|
+
? !0
|
343
|
+
: clientReferencePath.recursive,
|
344
|
+
regExp: clientReferencePath.include,
|
345
|
+
include: void 0,
|
346
|
+
exclude: clientReferencePath.exclude
|
347
|
+
},
|
348
|
+
(err2, deps) => {
|
349
|
+
if (err2) return cb(err2);
|
350
|
+
err2 = deps.map(dep => {
|
351
|
+
var request = path.join(
|
352
|
+
resolvedDirectory,
|
353
|
+
dep.userRequest
|
354
|
+
);
|
355
|
+
request = new ClientReferenceDependency(request);
|
356
|
+
request.userRequest = dep.userRequest;
|
357
|
+
return request;
|
358
|
+
});
|
359
|
+
asyncLib.filter(
|
360
|
+
err2,
|
361
|
+
(clientRefDep, filterCb) => {
|
362
|
+
normalResolver.resolve(
|
363
|
+
{},
|
364
|
+
context,
|
365
|
+
clientRefDep.request,
|
366
|
+
{},
|
367
|
+
(err3, resolvedPath) => {
|
368
|
+
if (err3 || "string" !== typeof resolvedPath)
|
369
|
+
return filterCb(null, !1);
|
370
|
+
fs.readFile(
|
371
|
+
resolvedPath,
|
372
|
+
"utf-8",
|
373
|
+
(err4, content) => {
|
374
|
+
if (err4 || "string" !== typeof content)
|
375
|
+
return filterCb(null, !1);
|
376
|
+
err4 = hasUseClientDirective(content);
|
377
|
+
filterCb(null, err4);
|
378
|
+
}
|
379
|
+
);
|
380
|
+
}
|
381
|
+
);
|
382
|
+
},
|
383
|
+
cb
|
384
|
+
);
|
385
|
+
}
|
386
|
+
);
|
387
|
+
}
|
388
|
+
);
|
389
|
+
},
|
390
|
+
(err, result) => {
|
391
|
+
if (err) return callback(err);
|
392
|
+
err = [];
|
393
|
+
for (let i = 0; i < result.length; i++) err.push.apply(err, result[i]);
|
394
|
+
callback(null, err);
|
395
|
+
}
|
396
|
+
);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
module.exports = ReactFlightWebpackPlugin;
|
@@ -17,6 +17,21 @@ if (process.env.NODE_ENV !== "production") {
|
|
17
17
|
var React = require('react');
|
18
18
|
var ReactDOM = require('react-dom');
|
19
19
|
|
20
|
+
function _defineProperty(obj, key, value) {
|
21
|
+
if (key in obj) {
|
22
|
+
Object.defineProperty(obj, key, {
|
23
|
+
value: value,
|
24
|
+
enumerable: true,
|
25
|
+
configurable: true,
|
26
|
+
writable: true
|
27
|
+
});
|
28
|
+
} else {
|
29
|
+
obj[key] = value;
|
30
|
+
}
|
31
|
+
|
32
|
+
return obj;
|
33
|
+
}
|
34
|
+
|
20
35
|
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
|
21
36
|
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
22
37
|
|
@@ -823,11 +838,7 @@ function createTemporaryReference(id) {
|
|
823
838
|
return new Proxy(reference, proxyHandlers);
|
824
839
|
}
|
825
840
|
|
826
|
-
|
827
|
-
// When adding new symbols to this file,
|
828
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
829
|
-
// The Symbol used to tag the ReactElement-like types.
|
830
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
841
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ;
|
831
842
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
832
843
|
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
833
844
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
@@ -1746,18 +1757,56 @@ function renderFunctionComponent(request, task, key, Component, props, owner) {
|
|
1746
1757
|
}
|
1747
1758
|
}
|
1748
1759
|
|
1749
|
-
if (typeof result === 'object' && result !== null
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1760
|
+
if (typeof result === 'object' && result !== null) {
|
1761
|
+
if (typeof result.then === 'function') {
|
1762
|
+
// When the return value is in children position we can resolve it immediately,
|
1763
|
+
// to its value without a wrapper if it's synchronously available.
|
1764
|
+
var thenable = result;
|
1765
|
+
|
1766
|
+
if (thenable.status === 'fulfilled') {
|
1767
|
+
return thenable.value;
|
1768
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1769
|
+
// the thenable here.
|
1770
|
+
|
1753
1771
|
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
// the
|
1772
|
+
result = createLazyWrapperAroundWakeable(result);
|
1773
|
+
} // Normally we'd serialize an Iterator/AsyncIterator as a single-shot which is not compatible
|
1774
|
+
// to be rendered as a React Child. However, because we have the function to recreate
|
1775
|
+
// an iterable from rendering the element again, we can effectively treat it as multi-
|
1776
|
+
// shot. Therefore we treat this as an Iterable/AsyncIterable, whether it was one or not, by
|
1777
|
+
// adding a wrapper so that this component effectively renders down to an AsyncIterable.
|
1758
1778
|
|
1759
1779
|
|
1760
|
-
|
1780
|
+
var iteratorFn = getIteratorFn(result);
|
1781
|
+
|
1782
|
+
if (iteratorFn) {
|
1783
|
+
var iterableChild = result;
|
1784
|
+
result = _defineProperty({}, Symbol.iterator, function () {
|
1785
|
+
var iterator = iteratorFn.call(iterableChild);
|
1786
|
+
|
1787
|
+
{
|
1788
|
+
// If this was an Iterator but not a GeneratorFunction we warn because
|
1789
|
+
// it might have been a mistake. Technically you can make this mistake with
|
1790
|
+
// GeneratorFunctions and even single-shot Iterables too but it's extra
|
1791
|
+
// tempting to try to return the value from a generator.
|
1792
|
+
if (iterator === iterableChild) {
|
1793
|
+
var isGeneratorComponent = // $FlowIgnore[method-unbinding]
|
1794
|
+
Object.prototype.toString.call(Component) === '[object GeneratorFunction]' && // $FlowIgnore[method-unbinding]
|
1795
|
+
Object.prototype.toString.call(iterableChild) === '[object Generator]';
|
1796
|
+
|
1797
|
+
if (!isGeneratorComponent) {
|
1798
|
+
error('Returning an Iterator from a Server Component is not supported ' + 'since it cannot be looped over more than once. ');
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
|
1803
|
+
return iterator;
|
1804
|
+
});
|
1805
|
+
|
1806
|
+
{
|
1807
|
+
result._debugInfo = iterableChild._debugInfo;
|
1808
|
+
}
|
1809
|
+
}
|
1761
1810
|
} // Track this element's key on the Server Component on the keyPath context..
|
1762
1811
|
|
1763
1812
|
|
@@ -2229,6 +2278,11 @@ function serializeSet(request, set) {
|
|
2229
2278
|
return '$W' + id.toString(16);
|
2230
2279
|
}
|
2231
2280
|
|
2281
|
+
function serializeIterator(request, iterator) {
|
2282
|
+
var id = outlineModel(request, Array.from(iterator));
|
2283
|
+
return '$i' + id.toString(16);
|
2284
|
+
}
|
2285
|
+
|
2232
2286
|
function escapeStringValue(value) {
|
2233
2287
|
if (value[0] === '$') {
|
2234
2288
|
// We need to escape $ prefixed strings since we use those to encode
|
@@ -2493,7 +2547,15 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2493
2547
|
var iteratorFn = getIteratorFn(value);
|
2494
2548
|
|
2495
2549
|
if (iteratorFn) {
|
2496
|
-
return
|
2550
|
+
// TODO: Should we serialize the return value as well like we do for AsyncIterables?
|
2551
|
+
var iterator = iteratorFn.call(value);
|
2552
|
+
|
2553
|
+
if (iterator === value) {
|
2554
|
+
// Iterator, not Iterable
|
2555
|
+
return serializeIterator(request, iterator);
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
return renderFragment(request, task, Array.from(iterator));
|
2497
2559
|
}
|
2498
2560
|
|
2499
2561
|
|
@@ -3794,6 +3856,16 @@ function parseModelString(response, obj, key, value) {
|
|
3794
3856
|
return _data2;
|
3795
3857
|
}
|
3796
3858
|
|
3859
|
+
case 'i':
|
3860
|
+
{
|
3861
|
+
// Iterator
|
3862
|
+
var _id5 = parseInt(value.slice(2), 16);
|
3863
|
+
|
3864
|
+
var _data3 = getOutlinedModel(response, _id5);
|
3865
|
+
|
3866
|
+
return _data3[Symbol.iterator]();
|
3867
|
+
}
|
3868
|
+
|
3797
3869
|
case 'I':
|
3798
3870
|
{
|
3799
3871
|
// $Infinity
|