Skip to content

Commit 6e831f9

Browse files
committed
Split out ServerReferenceMetadata into Id and Bound Arguments (#26351)
This is just moving some stuff around and renaming things. This tuple is opaque to the Flight implementation and we should probably encode it separately as a single string instead of a model object. The term "Metadata" isn't the same as when used for ClientReferences so it's not really the right term anyway. I also made it optional since a bound function with no arguments bound is technically different than a raw instance of that function (it's a clone). I also renamed the type ReactModel to ReactClientValue. This is the generic serializable type for something that can pass through the serializable boundary from server to client. There will be another one for client to server. I also filled in missing classes and ensure the serializable sub-types are explicit. E.g. Array and Thenable. DiffTrain build for [2b003a5](2b003a5)
1 parent fb25407 commit 6e831f9

7 files changed

+27
-11
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
978fae4b4f6d5aa28887b530b5c9bf28b1e7b74b
1+
2b003a5cc6df77f745e1639404f912bd0077a39b

compiled/facebook-www/ReactFlightDOMRelayClient-dev.classic.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ function createServerReferenceProxy(response, metaData) {
472472
var args = Array.prototype.slice.call(arguments);
473473
var p = metaData.bound;
474474

475+
if (!p) {
476+
return callServer(metaData.id, args);
477+
}
478+
475479
if (p.status === INITIALIZED) {
476480
var bound = p.value;
477481
return callServer(metaData.id, bound.concat(args));

compiled/facebook-www/ReactFlightDOMRelayClient-dev.modern.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ function createServerReferenceProxy(response, metaData) {
472472
var args = Array.prototype.slice.call(arguments);
473473
var p = metaData.bound;
474474

475+
if (!p) {
476+
return callServer(metaData.id, args);
477+
}
478+
475479
if (p.status === INITIALIZED) {
476480
var bound = p.value;
477481
return callServer(metaData.id, bound.concat(args));

compiled/facebook-www/ReactFlightDOMRelayClient-prod.classic.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,13 @@ function createServerReferenceProxy(response, metaData) {
231231
return function () {
232232
var args = Array.prototype.slice.call(arguments),
233233
p = metaData.bound;
234-
return "fulfilled" === p.status
235-
? callServer(metaData.id, p.value.concat(args))
236-
: Promise.resolve(p).then(function (bound) {
237-
return callServer(metaData.id, bound.concat(args));
238-
});
234+
return p
235+
? "fulfilled" === p.status
236+
? callServer(metaData.id, p.value.concat(args))
237+
: Promise.resolve(p).then(function (bound) {
238+
return callServer(metaData.id, bound.concat(args));
239+
})
240+
: callServer(metaData.id, args);
239241
};
240242
}
241243
function parseModelString(response, parentObject, key, value) {

compiled/facebook-www/ReactFlightDOMRelayClient-prod.modern.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,13 @@ function createServerReferenceProxy(response, metaData) {
231231
return function () {
232232
var args = Array.prototype.slice.call(arguments),
233233
p = metaData.bound;
234-
return "fulfilled" === p.status
235-
? callServer(metaData.id, p.value.concat(args))
236-
: Promise.resolve(p).then(function (bound) {
237-
return callServer(metaData.id, bound.concat(args));
238-
});
234+
return p
235+
? "fulfilled" === p.status
236+
? callServer(metaData.id, p.value.concat(args))
237+
: Promise.resolve(p).then(function (bound) {
238+
return callServer(metaData.id, bound.concat(args));
239+
})
240+
: callServer(metaData.id, args);
239241
};
240242
}
241243
function parseModelString(response, parentObject, key, value) {

compiled/facebook-www/ReactFlightDOMRelayServer-dev.classic.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,8 @@ function getOrCreateServerContext(globalName) {
12251225
return ContextRegistry[globalName];
12261226
}
12271227

1228+
// Thenable<ReactClientValue>
1229+
12281230
var PENDING = 0;
12291231
var COMPLETED = 1;
12301232
var ERRORED = 4;

compiled/facebook-www/ReactFlightDOMRelayServer-dev.modern.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,8 @@ function getOrCreateServerContext(globalName) {
12251225
return ContextRegistry[globalName];
12261226
}
12271227

1228+
// Thenable<ReactClientValue>
1229+
12281230
var PENDING = 0;
12291231
var COMPLETED = 1;
12301232
var ERRORED = 4;

0 commit comments

Comments
 (0)