/** * Runtime detection helpers for the SSR module. * * Detects whether the current runtime is Bun, Deno, Node.js, a browser, * or a Web-Worker / edge runtime (Cloudflare Workers / `workerd`). * Detection is feature-based and never throws; calling these helpers is * safe in any environment that provides `globalThis`. * * @module bquery/ssr */ /** * Identifier for a recognised JavaScript runtime. */ export type SSRRuntime = 'bun' | 'deno' | 'node' | 'browser' | 'workerd' | 'unknown'; /** * Detects the current runtime via feature checks on `globalThis`. * Order matters: Bun and Deno expose Node compatibility shims, so they are * checked first. * * @returns The detected runtime identifier, or `'unknown'` if none match. * * @example * ```ts * import { detectRuntime } from '@bquery/bquery/ssr'; * * if (detectRuntime() === 'deno') { * // Deno-specific behaviour * } * ``` */ export declare const detectRuntime: () => SSRRuntime; /** * Returns `true` when called inside a server-side runtime (Bun, Deno, Node, * Cloudflare Workers / `workerd`). */ export declare const isServerRuntime: () => boolean; /** * Returns `true` when called inside a browser-like runtime (full DOM available). */ export declare const isBrowserRuntime: () => boolean; /** * Lightweight feature-detection report for runtime capabilities relevant to SSR. */ export interface SSRRuntimeFeatures { /** Whether `Request`/`Response`/`fetch` are available on `globalThis`. */ fetchApi: boolean; /** Whether `ReadableStream` is available on `globalThis`. */ webStreams: boolean; /** Whether `TextEncoder` is available on `globalThis`. */ textEncoder: boolean; /** Whether `crypto.subtle` is available (used for ETag hashing). */ subtleCrypto: boolean; /** Whether `crypto.randomUUID()` is available. */ randomUuid: boolean; /** Whether the global `DOMParser` is available. */ domParser: boolean; } /** * Returns a feature-detection report for the current runtime. All checks are * non-throwing; missing globals yield `false`. */ export declare const getSSRRuntimeFeatures: () => SSRRuntimeFeatures; //# sourceMappingURL=runtime.d.ts.map