@open-matrix/hosting-browser (0.1.7)

Published 2026-09-03 18:26:31 +00:00 by hivecast-admin

Installation

@open-matrix:registry=
npm install @open-matrix/hosting-browser@0.1.7
"@open-matrix/hosting-browser": "0.1.7"

About this package

@open-matrix/hosting-browser

Browser execution-environment adapters for @open-matrix/hosting.

Browser page lifetime

import { Host } from '@open-matrix/hosting';
import { AddBrowserPageLifetime } from '@open-matrix/hosting-browser';

const builder = Host.CreateApplicationBuilder({
  ApplicationName: 'matrix-browser-runtime',
});

AddBrowserPageLifetime(builder.Services);

await using host = builder.Build();
await host.RunAsync();

BrowserPageLifetime observes pagehide and beforeunload, requests IHostApplicationLifetime.StopApplication(), and removes its listeners during host shutdown.

The event callback itself never waits for asynchronous cleanup. Browser termination is not process shutdown: the platform may terminate the page before transport drain, departure publication or telemetry flush completes.

Correct distributed behavior therefore requires:

  • renewable presence/registry leases;
  • server-side lease expiration;
  • best-effort departure;
  • idempotent reacquisition;
  • a newly built host after BFCache restoration.

visibilitychange is intentionally not treated as shutdown. A hidden page is not a stopped application.

Testing and embedding

Inject IBrowserLifecycleSource to test the lifetime without a real window or to adapt an embedded browser shell. WindowBrowserLifecycleSource fails clearly when constructed in a non-browser environment rather than silently pretending that page events exist.

Dependencies

Dependencies

ID Version
@open-matrix/hosting 0.1.7

Development Dependencies

ID Version
@types/node ^25.0.10
typescript ^5.7.0
Details
npm
2026-09-03 18:26:31 +00:00
1
MIT
latest
6.5 KiB
Assets (1)
Versions (5) View all
0.1.7 2026-09-03
0.1.5 2026-08-18
0.1.4 2026-08-18
0.1.3 2026-08-17
0.1.2 2026-08-16