(
request: Request,
counter: {objectLimit: number},
parent:
| {+[propertyName: string | number]: ReactClientValue}
| $ReadOnlyArray<ReactClientValue>,
parentPropertyName: string,
value: ReactClientValue,
)
| 4580 | // This is a forked version of renderModel which should never error, never suspend and is limited |
| 4581 | // in the depth it can encode. |
| 4582 | function renderDebugModel( |
| 4583 | request: Request, |
| 4584 | counter: {objectLimit: number}, |
| 4585 | parent: |
| 4586 | | {+[propertyName: string | number]: ReactClientValue} |
| 4587 | | $ReadOnlyArray<ReactClientValue>, |
| 4588 | parentPropertyName: string, |
| 4589 | value: ReactClientValue, |
| 4590 | ): ReactJSONValue { |
| 4591 | if (value === null) { |
| 4592 | return null; |
| 4593 | } |
| 4594 | |
| 4595 | // Special Symbol, that's very common. |
| 4596 | if (value === REACT_ELEMENT_TYPE) { |
| 4597 | return '$'; |
| 4598 | } |
| 4599 | |
| 4600 | if (typeof value === 'object') { |
| 4601 | if (isClientReference(value)) { |
| 4602 | // We actually have this value on the client so we could import it. |
| 4603 | // This might be confusing though because on the Server it won't actually |
| 4604 | // be this value, so if you're debugging client references maybe you'd be |
| 4605 | // better with a place holder. |
| 4606 | return serializeDebugClientReference( |
| 4607 | request, |
| 4608 | parent, |
| 4609 | parentPropertyName, |
| 4610 | (value: any), |
| 4611 | ); |
| 4612 | } |
| 4613 | if (value.$$typeof === CONSTRUCTOR_MARKER) { |
| 4614 | const constructor: Function = (value: any).constructor; |
| 4615 | let ref = request.writtenDebugObjects.get(constructor); |
| 4616 | if (ref === undefined) { |
| 4617 | const id = outlineDebugModel(request, counter, constructor); |
| 4618 | ref = serializeByValueID(id); |
| 4619 | } |
| 4620 | return '$P' + ref.slice(1); |
| 4621 | } |
| 4622 | |
| 4623 | if (request.temporaryReferences !== undefined) { |
| 4624 | const tempRef = resolveTemporaryReference( |
| 4625 | request.temporaryReferences, |
| 4626 | value, |
| 4627 | ); |
| 4628 | if (tempRef !== undefined) { |
| 4629 | return serializeTemporaryReference(request, tempRef); |
| 4630 | } |
| 4631 | } |
| 4632 | |
| 4633 | const writtenDebugObjects = request.writtenDebugObjects; |
| 4634 | const existingDebugReference = writtenDebugObjects.get(value); |
| 4635 | if (existingDebugReference !== undefined) { |
| 4636 | if (debugModelRoot === value) { |
| 4637 | // This is the ID we're currently emitting so we need to write it |
| 4638 | // once but if we discover it again, we refer to it by id. |
| 4639 | debugModelRoot = null; |
no test coverage detected