Implementation:Microsoft Playwright NodePlatform
Overview
NodePlatform implements the Platform interface for Node.js environments, providing platform-specific implementations of crypto, filesystem, zone management, and other runtime services.
Description
This module provides the Node.js-specific implementation of Playwright's platform abstraction layer. Key implementations:
NodeZone-- wraps the zone-based async context tracking system- Platform methods for crypto operations (SHA1, GUID), filesystem access, color output, environment variables
- Zod schema conversion utilities for MCP (Model Context Protocol) tool definitions
- Stream pipeline utilities for data transfer
- Debug mode and test detection helpers
This abstraction allows Playwright's client code to work across different JavaScript runtimes by delegating platform-specific operations.
Usage
Instantiated once and provided to the Playwright client as the platform implementation for Node.js environments.
Code Reference
Source Location
packages/playwright-core/src/server/utils/nodePlatform.ts (183 lines)
Key Signatures
class NodeZone implements Zone {
push<T>(data: T): NodeZone
pop(): NodeZone
run<R>(func: () => R): R
data<T>(): T | undefined
}
// Platform implementation provides:
// - calculateSha1(), createGuid()
// - fs operations
// - environment access
// - color support detection
// - Zod schema conversion
Import
import { nodePlatform } from './server/utils/nodePlatform';
I/O Contract
Inputs
- Platform-specific environment (Node.js process, filesystem, crypto)
Outputs
- Uniform
Platforminterface for cross-runtime compatibility - Zone-based async context management
Related Pages
- Microsoft_Playwright_CryptoUtils -- Crypto operations delegated by platform
- Microsoft_Playwright_DebugLogger -- Debug support from platform
- Microsoft_Playwright_FileUtils -- File operations