fix(virtualstream): Expose transport localData to handlers via TypedTools; improve VirtualStream payload encode/decode to preserve built-ins and handle nested arrays/objects
This commit is contained in:
@@ -82,7 +82,7 @@ export class VirtualStream<T = Uint8Array> implements plugins.typedRequestInterf
|
||||
}
|
||||
|
||||
public static decodePayloadFromNetwork(objectPayload: any, commFunctions: ICommFunctions): any {
|
||||
|
||||
|
||||
if (
|
||||
plugins.smartbuffer.isBufferLike(objectPayload)
|
||||
|| objectPayload instanceof TypedRouter
|
||||
@@ -90,6 +90,18 @@ export class VirtualStream<T = Uint8Array> implements plugins.typedRequestInterf
|
||||
return objectPayload;
|
||||
}
|
||||
if (objectPayload !== null && typeof objectPayload === 'object') {
|
||||
// Preserve built-in objects that shouldn't be transformed
|
||||
if (
|
||||
objectPayload instanceof Set ||
|
||||
objectPayload instanceof Map ||
|
||||
objectPayload instanceof Date ||
|
||||
objectPayload instanceof RegExp ||
|
||||
objectPayload instanceof Error ||
|
||||
objectPayload instanceof Promise ||
|
||||
typeof objectPayload.then === 'function'
|
||||
) {
|
||||
return objectPayload;
|
||||
}
|
||||
if (objectPayload._isVirtualStream) {
|
||||
const virtualStream = new VirtualStream();
|
||||
virtualStream.streamId = objectPayload.streamId;
|
||||
|
||||
Reference in New Issue
Block a user