Core Infrastructure
Configuration, capability detection, and SSR-safe utilities.
Previous: Session core · Back to: Overview
Playground
Open Configuration playground → — tweak options and inspect capabilities.
Problem → approach
| Typical pain | Core infrastructure |
|---|---|
document is not defined during SSR | Capability probes run before modules attach |
| Silent failures when APIs are missing | supportsVisibility() and friends gate optional behavior |
| Invalid config discovered at runtime | createBrowserLifecycleConfig() validates options up front |
import { createBrowserLifecycleConfig, supportsVisibility } from "@jayoncode/browser-lifecycle";
const config = createBrowserLifecycleConfig({ autoStart: true });
if (supportsVisibility()) {
/* safe to rely on visibility events */
}Technical reference
This document covers the public exports introduced in Phase 2.2.0.
Configuration
createBrowserLifecycleConfig(input?)
Validates and resolves configuration into an immutable object.
getDefaultBrowserLifecycleConfig()
Returns a fresh immutable copy of the package defaults.
mergeBrowserLifecycleConfig(base?, override?)
Merges two configuration objects, validates the result, and returns the resolved immutable config.
validateBrowserLifecycleConfig(input)
Validates unknown input and throws ConfigurationError when the shape is invalid.
getPluginIds(config)
Returns the configured plugin ids from a resolved configuration.
Feature Detection
detectBrowserLifecycleCapabilities(environment?)
Returns the capability snapshot used by the package's infrastructure layer.
supportsVisibility(environment?)
Returns whether the environment supports the Page Visibility API.
supportsBroadcastChannel(environment?)
Returns whether the environment supports BroadcastChannel.
supportsPageLifecycle(environment?)
Returns whether the environment exposes pagehide and pageshow hooks.
supportsRequestIdleCallback(environment?)
Returns whether the environment supports requestIdleCallback.
supportsAbortController(environment?)
Returns whether the environment supports AbortController.
Utilities
assert(condition, message)
Throws when a condition is falsy.
noop()
No-op helper for optional callbacks and defaults.
isBrowser()
Returns whether the current runtime looks like a browser environment.
isFunction(value)
Returns whether a value is callable.
isObject(value)
Returns whether a value is a non-null object.
deepFreeze(value)
Recursively freezes an object tree and returns a readonly view.
mergeObjects(base, override)
Recursively merges plain objects while replacing arrays and scalar values.
Errors
BrowserLifecycleError
Base error for the public infrastructure surface.
ConfigurationError
Thrown for invalid configuration input.
UnsupportedFeatureError
Thrown when a required feature is unavailable.
InitializationError
Thrown when initialization cannot proceed.
PluginError
Placeholder plugin error for the pre-plugin milestone.
Exported Types
The root package currently exports:
BrowserFeatureEnvironmentBrowserLifecycleCapabilitiesBrowserLifecycleConfigBrowserLifecycleCrossTabConfigBrowserLifecycleCrossTabConfigInputBrowserLifecycleErrorCodeBrowserLifecyclePluginResolvedBrowserLifecycleConfig
