139
140
import {
141
describeObjectForErrorMessage,
142
+ isGetter,
143
isSimpleObject,
144
jsxPropsParents,
145
jsxChildrenParents,
149
import ReactSharedInternals from './ReactSharedInternalsServer';
150
import isArray from 'shared/isArray';
151
import getPrototypeOf from 'shared/getPrototypeOf';
152
+import hasOwnProperty from 'shared/hasOwnProperty';
153
import binaryToComparableString from 'shared/binaryToComparableString';
154
155
import {SuspenseException, getSuspendedThenable} from './ReactFlightThenable';
3908
return '$E' + source;
3909
}
3910
3911
+const CONSTRUCTOR_MARKER: symbol = __DEV__ ? Symbol() : (null: any);
3912
+
3913
let debugModelRoot: mixed = null;
3914
let debugNoOutline: mixed = null;
3915
// This is a forked version of renderModel which should never error, never suspend and is limited
3945
(value: any),
3946
);
3947
}
3948
+ if (value.$$typeof === CONSTRUCTOR_MARKER) {
3949
+ const constructor: Function = (value: any).constructor;
3950
+ let ref = request.writtenDebugObjects.get(constructor);
3951
+ if (ref === undefined) {
3952
+ const id = outlineDebugModel(request, counter, constructor);
3953
+ ref = serializeByValueID(id);
3954
+ }
3955
+ return '$P' + ref.slice(1);
3956
+ }
3957
+
3958
if (request.temporaryReferences !== undefined) {
3959
const tempRef = resolveTemporaryReference(
3960
request.temporaryReferences,
4155
return Array.from((value: any));
4156
}
4157
4158
+ const proto = getPrototypeOf(value);
4159
+ if (proto !== ObjectPrototype && proto !== null) {
4160
+ const object: Object = value;
4161
+ const instanceDescription: Object = Object.create(null);
4162
+ for (const propName in object) {
4163
+ if (hasOwnProperty.call(value, propName) || isGetter(proto, propName)) {
4164
+ // We intentionally invoke getters on the prototype to read any enumerable getters.
4165
+ instanceDescription[propName] = object[propName];
4166
+ }
4167
+ }
4168
+ const constructor = proto.constructor;
4169
+ if (
4170
+ typeof constructor === 'function' &&
4171
+ constructor.prototype === proto
4172
+ ) {
4173
+ // This is a simple class shape.
4174
+ if (hasOwnProperty.call(object, '') || isGetter(proto, '')) {
4175
+ // This object already has an empty property name. Skip encoding its prototype.
4176
+ } else {
4177
+ instanceDescription[''] = {
4178
+ $$typeof: CONSTRUCTOR_MARKER,
4179
+ constructor: constructor,
4180
+ };
4181
+ }
4182
+ }
4183
+ return instanceDescription;
4184
+ }
4185
+
4186
// $FlowFixMe[incompatible-return]
4187
return value;
4188
}