react-server-dom-webpack 18.3.0-next-a8875eab7-20230310 → 18.3.0-next-56a3c18e5-20230314
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 +582 -1
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +22 -19
- package/cjs/react-server-dom-webpack-client.edge.development.js +4 -1
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +16 -16
- package/cjs/react-server-dom-webpack-client.node.development.js +4 -1
- package/cjs/react-server-dom-webpack-client.node.production.min.js +18 -18
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +15 -15
- package/cjs/react-server-dom-webpack-server.browser.development.js +1146 -617
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +57 -46
- package/cjs/react-server-dom-webpack-server.edge.development.js +1146 -617
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +55 -44
- package/cjs/react-server-dom-webpack-server.node.development.js +1181 -613
- package/cjs/react-server-dom-webpack-server.node.production.min.js +58 -46
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1145 -617
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +52 -41
- package/package.json +3 -3
- package/umd/react-server-dom-webpack-client.browser.development.js +582 -1
- package/umd/react-server-dom-webpack-client.browser.production.min.js +17 -14
- package/umd/react-server-dom-webpack-server.browser.development.js +1146 -617
- package/umd/react-server-dom-webpack-server.browser.production.min.js +44 -37
@@ -48,7 +48,7 @@
|
|
48
48
|
}
|
49
49
|
|
50
50
|
return metadata;
|
51
|
-
}
|
51
|
+
}
|
52
52
|
// If they're still pending they're a thenable. This map also exists
|
53
53
|
// in Webpack but unfortunately it's not exposed so we have to
|
54
54
|
// replicate it in user space. null means that it has already loaded.
|
@@ -147,13 +147,35 @@
|
|
147
147
|
return moduleExports[metadata.name];
|
148
148
|
}
|
149
149
|
|
150
|
+
var knownServerReferences = new WeakMap();
|
151
|
+
|
150
152
|
// ATTENTION
|
151
153
|
// When adding new symbols to this file,
|
152
154
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
153
155
|
// The Symbol used to tag the ReactElement-like types.
|
154
156
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
157
|
+
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
158
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
159
|
+
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
160
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
161
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
155
162
|
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
156
163
|
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
164
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
165
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
166
|
+
function getIteratorFn(maybeIterable) {
|
167
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
168
|
+
return null;
|
169
|
+
}
|
170
|
+
|
171
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
172
|
+
|
173
|
+
if (typeof maybeIterator === 'function') {
|
174
|
+
return maybeIterator;
|
175
|
+
}
|
176
|
+
|
177
|
+
return null;
|
178
|
+
}
|
157
179
|
|
158
180
|
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
159
181
|
|
@@ -560,6 +582,7 @@
|
|
560
582
|
});
|
561
583
|
};
|
562
584
|
|
585
|
+
knownServerReferences.set(proxy, metaData);
|
563
586
|
return proxy;
|
564
587
|
}
|
565
588
|
|
@@ -881,6 +904,555 @@
|
|
881
904
|
return response;
|
882
905
|
}
|
883
906
|
|
907
|
+
function error(format) {
|
908
|
+
{
|
909
|
+
{
|
910
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
911
|
+
args[_key2 - 1] = arguments[_key2];
|
912
|
+
}
|
913
|
+
|
914
|
+
printWarning('error', format, args);
|
915
|
+
}
|
916
|
+
}
|
917
|
+
}
|
918
|
+
|
919
|
+
function printWarning(level, format, args) {
|
920
|
+
// When changing this logic, you might want to also
|
921
|
+
// update consoleWithStackDev.www.js as well.
|
922
|
+
{
|
923
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
924
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
925
|
+
|
926
|
+
if (stack !== '') {
|
927
|
+
format += '%s';
|
928
|
+
args = args.concat([stack]);
|
929
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
930
|
+
|
931
|
+
|
932
|
+
var argsWithFormat = args.map(function (item) {
|
933
|
+
return String(item);
|
934
|
+
}); // Careful: RN currently depends on this prefix
|
935
|
+
|
936
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
937
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
938
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
939
|
+
|
940
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
941
|
+
}
|
942
|
+
}
|
943
|
+
|
944
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
945
|
+
|
946
|
+
function isArray(a) {
|
947
|
+
return isArrayImpl(a);
|
948
|
+
}
|
949
|
+
|
950
|
+
// in case they error.
|
951
|
+
|
952
|
+
var jsxPropsParents = new WeakMap();
|
953
|
+
var jsxChildrenParents = new WeakMap();
|
954
|
+
|
955
|
+
function isObjectPrototype(object) {
|
956
|
+
if (!object) {
|
957
|
+
return false;
|
958
|
+
}
|
959
|
+
|
960
|
+
var ObjectPrototype = Object.prototype;
|
961
|
+
|
962
|
+
if (object === ObjectPrototype) {
|
963
|
+
return true;
|
964
|
+
} // It might be an object from a different Realm which is
|
965
|
+
// still just a plain simple object.
|
966
|
+
|
967
|
+
|
968
|
+
if (Object.getPrototypeOf(object)) {
|
969
|
+
return false;
|
970
|
+
}
|
971
|
+
|
972
|
+
var names = Object.getOwnPropertyNames(object);
|
973
|
+
|
974
|
+
for (var i = 0; i < names.length; i++) {
|
975
|
+
if (!(names[i] in ObjectPrototype)) {
|
976
|
+
return false;
|
977
|
+
}
|
978
|
+
}
|
979
|
+
|
980
|
+
return true;
|
981
|
+
}
|
982
|
+
|
983
|
+
function isSimpleObject(object) {
|
984
|
+
if (!isObjectPrototype(Object.getPrototypeOf(object))) {
|
985
|
+
return false;
|
986
|
+
}
|
987
|
+
|
988
|
+
var names = Object.getOwnPropertyNames(object);
|
989
|
+
|
990
|
+
for (var i = 0; i < names.length; i++) {
|
991
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
992
|
+
|
993
|
+
if (!descriptor) {
|
994
|
+
return false;
|
995
|
+
}
|
996
|
+
|
997
|
+
if (!descriptor.enumerable) {
|
998
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
999
|
+
// React adds key and ref getters to props objects to issue warnings.
|
1000
|
+
// Those getters will not be transferred to the client, but that's ok,
|
1001
|
+
// so we'll special case them.
|
1002
|
+
continue;
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
return false;
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
return true;
|
1010
|
+
}
|
1011
|
+
function objectName(object) {
|
1012
|
+
// $FlowFixMe[method-unbinding]
|
1013
|
+
var name = Object.prototype.toString.call(object);
|
1014
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
1015
|
+
return p0;
|
1016
|
+
});
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
function describeKeyForErrorMessage(key) {
|
1020
|
+
var encodedKey = JSON.stringify(key);
|
1021
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
function describeValueForErrorMessage(value) {
|
1025
|
+
switch (typeof value) {
|
1026
|
+
case 'string':
|
1027
|
+
{
|
1028
|
+
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
case 'object':
|
1032
|
+
{
|
1033
|
+
if (isArray(value)) {
|
1034
|
+
return '[...]';
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
var name = objectName(value);
|
1038
|
+
|
1039
|
+
if (name === 'Object') {
|
1040
|
+
return '{...}';
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
return name;
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
case 'function':
|
1047
|
+
return 'function';
|
1048
|
+
|
1049
|
+
default:
|
1050
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
1051
|
+
return String(value);
|
1052
|
+
}
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
function describeElementType(type) {
|
1056
|
+
if (typeof type === 'string') {
|
1057
|
+
return type;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
switch (type) {
|
1061
|
+
case REACT_SUSPENSE_TYPE:
|
1062
|
+
return 'Suspense';
|
1063
|
+
|
1064
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
1065
|
+
return 'SuspenseList';
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
if (typeof type === 'object') {
|
1069
|
+
switch (type.$$typeof) {
|
1070
|
+
case REACT_FORWARD_REF_TYPE:
|
1071
|
+
return describeElementType(type.render);
|
1072
|
+
|
1073
|
+
case REACT_MEMO_TYPE:
|
1074
|
+
return describeElementType(type.type);
|
1075
|
+
|
1076
|
+
case REACT_LAZY_TYPE:
|
1077
|
+
{
|
1078
|
+
var lazyComponent = type;
|
1079
|
+
var payload = lazyComponent._payload;
|
1080
|
+
var init = lazyComponent._init;
|
1081
|
+
|
1082
|
+
try {
|
1083
|
+
// Lazy may contain any component type so we recursively resolve it.
|
1084
|
+
return describeElementType(init(payload));
|
1085
|
+
} catch (x) {}
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
return '';
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1094
|
+
var objKind = objectName(objectOrArray);
|
1095
|
+
|
1096
|
+
if (objKind !== 'Object' && objKind !== 'Array') {
|
1097
|
+
return objKind;
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
var str = '';
|
1101
|
+
var start = -1;
|
1102
|
+
var length = 0;
|
1103
|
+
|
1104
|
+
if (isArray(objectOrArray)) {
|
1105
|
+
if (jsxChildrenParents.has(objectOrArray)) {
|
1106
|
+
// Print JSX Children
|
1107
|
+
var type = jsxChildrenParents.get(objectOrArray);
|
1108
|
+
str = '<' + describeElementType(type) + '>';
|
1109
|
+
var array = objectOrArray;
|
1110
|
+
|
1111
|
+
for (var i = 0; i < array.length; i++) {
|
1112
|
+
var value = array[i];
|
1113
|
+
var substr = void 0;
|
1114
|
+
|
1115
|
+
if (typeof value === 'string') {
|
1116
|
+
substr = value;
|
1117
|
+
} else if (typeof value === 'object' && value !== null) {
|
1118
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1119
|
+
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1120
|
+
} else {
|
1121
|
+
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
if ('' + i === expandedName) {
|
1125
|
+
start = str.length;
|
1126
|
+
length = substr.length;
|
1127
|
+
str += substr;
|
1128
|
+
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
1129
|
+
str += substr;
|
1130
|
+
} else {
|
1131
|
+
str += '{...}';
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
str += '</' + describeElementType(type) + '>';
|
1136
|
+
} else {
|
1137
|
+
// Print Array
|
1138
|
+
str = '[';
|
1139
|
+
var _array = objectOrArray;
|
1140
|
+
|
1141
|
+
for (var _i = 0; _i < _array.length; _i++) {
|
1142
|
+
if (_i > 0) {
|
1143
|
+
str += ', ';
|
1144
|
+
}
|
1145
|
+
|
1146
|
+
var _value = _array[_i];
|
1147
|
+
|
1148
|
+
var _substr = void 0;
|
1149
|
+
|
1150
|
+
if (typeof _value === 'object' && _value !== null) {
|
1151
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1152
|
+
_substr = describeObjectForErrorMessage(_value);
|
1153
|
+
} else {
|
1154
|
+
_substr = describeValueForErrorMessage(_value);
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
if ('' + _i === expandedName) {
|
1158
|
+
start = str.length;
|
1159
|
+
length = _substr.length;
|
1160
|
+
str += _substr;
|
1161
|
+
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
1162
|
+
str += _substr;
|
1163
|
+
} else {
|
1164
|
+
str += '...';
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
str += ']';
|
1169
|
+
}
|
1170
|
+
} else {
|
1171
|
+
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1172
|
+
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1173
|
+
} else if (jsxPropsParents.has(objectOrArray)) {
|
1174
|
+
// Print JSX
|
1175
|
+
var _type = jsxPropsParents.get(objectOrArray);
|
1176
|
+
|
1177
|
+
str = '<' + (describeElementType(_type) || '...');
|
1178
|
+
var object = objectOrArray;
|
1179
|
+
var names = Object.keys(object);
|
1180
|
+
|
1181
|
+
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
1182
|
+
str += ' ';
|
1183
|
+
var name = names[_i2];
|
1184
|
+
str += describeKeyForErrorMessage(name) + '=';
|
1185
|
+
var _value2 = object[name];
|
1186
|
+
|
1187
|
+
var _substr2 = void 0;
|
1188
|
+
|
1189
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1190
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1191
|
+
_substr2 = describeObjectForErrorMessage(_value2);
|
1192
|
+
} else {
|
1193
|
+
_substr2 = describeValueForErrorMessage(_value2);
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
if (typeof _value2 !== 'string') {
|
1197
|
+
_substr2 = '{' + _substr2 + '}';
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
if (name === expandedName) {
|
1201
|
+
start = str.length;
|
1202
|
+
length = _substr2.length;
|
1203
|
+
str += _substr2;
|
1204
|
+
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
1205
|
+
str += _substr2;
|
1206
|
+
} else {
|
1207
|
+
str += '...';
|
1208
|
+
}
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
str += '>';
|
1212
|
+
} else {
|
1213
|
+
// Print Object
|
1214
|
+
str = '{';
|
1215
|
+
var _object = objectOrArray;
|
1216
|
+
|
1217
|
+
var _names = Object.keys(_object);
|
1218
|
+
|
1219
|
+
for (var _i3 = 0; _i3 < _names.length; _i3++) {
|
1220
|
+
if (_i3 > 0) {
|
1221
|
+
str += ', ';
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
var _name = _names[_i3];
|
1225
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1226
|
+
var _value3 = _object[_name];
|
1227
|
+
|
1228
|
+
var _substr3 = void 0;
|
1229
|
+
|
1230
|
+
if (typeof _value3 === 'object' && _value3 !== null) {
|
1231
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1232
|
+
_substr3 = describeObjectForErrorMessage(_value3);
|
1233
|
+
} else {
|
1234
|
+
_substr3 = describeValueForErrorMessage(_value3);
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
if (_name === expandedName) {
|
1238
|
+
start = str.length;
|
1239
|
+
length = _substr3.length;
|
1240
|
+
str += _substr3;
|
1241
|
+
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1242
|
+
str += _substr3;
|
1243
|
+
} else {
|
1244
|
+
str += '...';
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
str += '}';
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
if (expandedName === undefined) {
|
1253
|
+
return str;
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
if (start > -1 && length > 0) {
|
1257
|
+
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
1258
|
+
return '\n ' + str + '\n ' + highlight;
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
return '\n ' + str;
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
// Thenable<ReactServerValue>
|
1265
|
+
// function serializeByValueID(id: number): string {
|
1266
|
+
// return '$' + id.toString(16);
|
1267
|
+
// }
|
1268
|
+
|
1269
|
+
function serializePromiseID(id) {
|
1270
|
+
return '$@' + id.toString(16);
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
function serializeServerReferenceID(id) {
|
1274
|
+
return '$F' + id.toString(16);
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
function serializeSymbolReference(name) {
|
1278
|
+
return '$S' + name;
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
function serializeUndefined() {
|
1282
|
+
return '$undefined';
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
function escapeStringValue(value) {
|
1286
|
+
if (value[0] === '$') {
|
1287
|
+
// We need to escape $ prefixed strings since we use those to encode
|
1288
|
+
// references to IDs and as special symbol values.
|
1289
|
+
return '$' + value;
|
1290
|
+
} else {
|
1291
|
+
return value;
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
function processReply(root, resolve, reject) {
|
1296
|
+
var nextPartId = 1;
|
1297
|
+
var pendingParts = 0;
|
1298
|
+
var formData = null;
|
1299
|
+
|
1300
|
+
function resolveToJSON(key, value) {
|
1301
|
+
var parent = this;
|
1302
|
+
|
1303
|
+
{
|
1304
|
+
// $FlowFixMe
|
1305
|
+
var originalValue = this[key];
|
1306
|
+
|
1307
|
+
if (typeof originalValue === 'object' && originalValue !== value) {
|
1308
|
+
if (objectName(originalValue) !== 'Object') {
|
1309
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
1310
|
+
} else {
|
1311
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
if (value === null) {
|
1317
|
+
return null;
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
if (typeof value === 'object') {
|
1321
|
+
// $FlowFixMe[method-unbinding]
|
1322
|
+
if (typeof value.then === 'function') {
|
1323
|
+
// We assume that any object with a .then property is a "Thenable" type,
|
1324
|
+
// or a Promise type. Either of which can be represented by a Promise.
|
1325
|
+
if (formData === null) {
|
1326
|
+
// Upgrade to use FormData to allow us to stream this value.
|
1327
|
+
formData = new FormData();
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
pendingParts++;
|
1331
|
+
var promiseId = nextPartId++;
|
1332
|
+
var thenable = value;
|
1333
|
+
thenable.then(function (partValue) {
|
1334
|
+
var partJSON = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
1335
|
+
|
1336
|
+
var data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
1337
|
+
|
1338
|
+
data.append('' + promiseId, partJSON);
|
1339
|
+
pendingParts--;
|
1340
|
+
|
1341
|
+
if (pendingParts === 0) {
|
1342
|
+
resolve(data);
|
1343
|
+
}
|
1344
|
+
}, function (reason) {
|
1345
|
+
// In the future we could consider serializing this as an error
|
1346
|
+
// that throws on the server instead.
|
1347
|
+
reject(reason);
|
1348
|
+
});
|
1349
|
+
return serializePromiseID(promiseId);
|
1350
|
+
}
|
1351
|
+
|
1352
|
+
if (!isArray(value)) {
|
1353
|
+
var iteratorFn = getIteratorFn(value);
|
1354
|
+
|
1355
|
+
if (iteratorFn) {
|
1356
|
+
return Array.from(value);
|
1357
|
+
}
|
1358
|
+
}
|
1359
|
+
|
1360
|
+
{
|
1361
|
+
if (value !== null && !isArray(value)) {
|
1362
|
+
// Verify that this is a simple plain object.
|
1363
|
+
if (value.$$typeof === REACT_ELEMENT_TYPE) {
|
1364
|
+
error('React Element cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
1365
|
+
} else if (value.$$typeof === REACT_LAZY_TYPE) {
|
1366
|
+
error('React Lazy cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
1367
|
+
} else if (value.$$typeof === REACT_PROVIDER_TYPE) {
|
1368
|
+
error('React Context Providers cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
1369
|
+
} else if (objectName(value) !== 'Object') {
|
1370
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
1371
|
+
} else if (!isSimpleObject(value)) {
|
1372
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
1373
|
+
} else if (Object.getOwnPropertySymbols) {
|
1374
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
1375
|
+
|
1376
|
+
if (symbols.length > 0) {
|
1377
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
1378
|
+
}
|
1379
|
+
}
|
1380
|
+
}
|
1381
|
+
} // $FlowFixMe
|
1382
|
+
|
1383
|
+
|
1384
|
+
return value;
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
if (typeof value === 'string') {
|
1388
|
+
return escapeStringValue(value);
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
if (typeof value === 'boolean' || typeof value === 'number') {
|
1392
|
+
return value;
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
if (typeof value === 'undefined') {
|
1396
|
+
return serializeUndefined();
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
if (typeof value === 'function') {
|
1400
|
+
var metaData = knownServerReferences.get(value);
|
1401
|
+
|
1402
|
+
if (metaData !== undefined) {
|
1403
|
+
var metaDataJSON = JSON.stringify(metaData, resolveToJSON);
|
1404
|
+
|
1405
|
+
if (formData === null) {
|
1406
|
+
// Upgrade to use FormData to allow us to stream this value.
|
1407
|
+
formData = new FormData();
|
1408
|
+
} // The reference to this function came from the same client so we can pass it back.
|
1409
|
+
|
1410
|
+
|
1411
|
+
var refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
|
1412
|
+
|
1413
|
+
formData.set('' + refId, metaDataJSON);
|
1414
|
+
return serializeServerReferenceID(refId);
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
throw new Error('Client Functions cannot be passed directly to Server Functions. ' + 'Only Functions passed from the Server can be passed back again.');
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
if (typeof value === 'symbol') {
|
1421
|
+
// $FlowFixMe `description` might be undefined
|
1422
|
+
var name = value.description;
|
1423
|
+
|
1424
|
+
if (Symbol.for(name) !== value) {
|
1425
|
+
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Server Functions. ' + ("The symbol Symbol.for(" + // $FlowFixMe `description` might be undefined
|
1426
|
+
value.description + ") cannot be found among global symbols."));
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
return serializeSymbolReference(name);
|
1430
|
+
}
|
1431
|
+
|
1432
|
+
if (typeof value === 'bigint') {
|
1433
|
+
throw new Error("BigInt (" + value + ") is not yet supported as an argument to a Server Function.");
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
|
1437
|
+
} // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
|
1438
|
+
|
1439
|
+
|
1440
|
+
var json = JSON.stringify(root, resolveToJSON);
|
1441
|
+
|
1442
|
+
if (formData === null) {
|
1443
|
+
// If it's a simple data structure, we just use plain JSON.
|
1444
|
+
resolve(json);
|
1445
|
+
} else {
|
1446
|
+
// Otherwise, we use FormData to let us stream in the result.
|
1447
|
+
formData.set('0', json);
|
1448
|
+
|
1449
|
+
if (pendingParts === 0) {
|
1450
|
+
// $FlowFixMe[incompatible-call] this has already been refined.
|
1451
|
+
resolve(formData);
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
|
884
1456
|
function createResponseFromOptions(options) {
|
885
1457
|
return createResponse(null, options && options.callServer ? options.callServer : undefined);
|
886
1458
|
}
|
@@ -952,8 +1524,17 @@
|
|
952
1524
|
return getRoot(response);
|
953
1525
|
}
|
954
1526
|
|
1527
|
+
function encodeReply(value)
|
1528
|
+
/* We don't use URLSearchParams yet but maybe */
|
1529
|
+
{
|
1530
|
+
return new Promise(function (resolve, reject) {
|
1531
|
+
processReply(value, resolve, reject);
|
1532
|
+
});
|
1533
|
+
}
|
1534
|
+
|
955
1535
|
exports.createFromFetch = createFromFetch;
|
956
1536
|
exports.createFromReadableStream = createFromReadableStream;
|
957
1537
|
exports.createFromXHR = createFromXHR;
|
1538
|
+
exports.encodeReply = encodeReply;
|
958
1539
|
|
959
1540
|
}));
|