@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
44 lines • 1.59 kB
TypeScript
/**
* Runtime detection utilities. Kept out of the `utils` barrel on purpose —
* these are internal implementation details used to populate the
* `x-aptos-client` telemetry header and are not part of the public SDK API.
*
* Consumers that need to branch on the current runtime should inspect
* `globalThis` themselves (e.g. `typeof Bun !== "undefined"`) rather than
* relying on these helpers.
*
* @internal
*/
/**
* Identifier for the JavaScript runtime the SDK is currently running in.
* Used for telemetry (e.g. the `x-aptos-client` header).
*
* @internal
*/
export type RuntimePlatform = "node" | "browser" | "bun" | "deno" | "react-native" | "unknown";
/**
* Detects the JavaScript runtime the SDK is currently running in.
*
* Detection precedence (most specific first): react-native, deno, bun, browser, node.
* Falls back to "unknown" if detection fails or the environment is hostile.
*
* @internal
*/
export declare function getRuntimePlatform(): RuntimePlatform;
/**
* Returns a compact runtime tag for the `x-aptos-client` telemetry header.
* Node, Bun, and Deno expose their engine version cheaply and synchronously;
* browsers do not (userAgent is already forwarded as `User-Agent`), and React
* Native's JS-engine version is not reachable from `src/` without a
* platform-specific import.
*
* Shape examples:
* - "node/22.12.0"
* - "bun/1.1.38"
* - "deno/2.1.4"
* - "browser" | "react-native" | "unknown" (no version suffix)
*
* @internal
*/
export declare function getRuntimePlatformTag(): string;
//# sourceMappingURL=runtime.d.ts.map