Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright BidiDeserializer

From Leeroopedia
Knowledge Sources
Domains BiDi, Serialization
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for deserializing WebDriver BiDi remote values back into JavaScript objects provided by the Playwright library.

Description

The `deserializeBidiValue` function converts `bidi.Script.RemoteValue` objects returned by BiDi protocol commands into native JavaScript values. It handles all BiDi remote value types including primitives (undefined, null, number, boolean, string, bigint), complex types (array, object, map, set, regexp, date, error), and special types (node, nodelist, htmlcollection, promise, proxy, generator, weakmap, weakset, arraybuffer, typedarray, weakref). An internal ID map tracks previously deserialized objects to handle shared references.

Usage

Use BidiDeserializer when processing return values from BiDi `script.evaluate` or `script.callFunction` commands to convert the protocol response into usable JavaScript values.

Code Reference

Source Location

Signature

export function deserializeBidiValue(
  result: bidi.Script.RemoteValue,
  internalIdMap?: Map<bidi.Script.InternalId, any>
): any;

Import

import { deserializeBidiValue } from '../server/bidi/bidiDeserializer';

I/O Contract

Inputs

Name Type Required Description
result bidi.Script.RemoteValue Yes The BiDi remote value to deserialize
internalIdMap Map<bidi.Script.InternalId, any> No Map for tracking shared references (defaults to empty map)

Outputs

Name Type Description
value any The deserialized JavaScript value

Usage Examples

import { deserializeBidiValue } from '../server/bidi/bidiDeserializer';

// Deserialize a string remote value
const str = deserializeBidiValue({ type: 'string', value: 'hello' }); // 'hello'

// Deserialize a number remote value
const num = deserializeBidiValue({ type: 'number', value: 42 }); // 42

// Deserialize an array remote value
const arr = deserializeBidiValue({ type: 'array', value: [
  { type: 'number', value: 1 },
  { type: 'string', value: 'two' }
] });

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment