Skip to content

toolmark-monorepo / @toolmark/inertia / inertiaPages

Function: inertiaPages() ​

inertiaPages(o): (tm) => () => void

Defined in: packages/inertia/src/pages.ts:52

Keeps server-declared tools (spec §10.1, §12.4, D23) in sync with the current Inertia page. Holds one transparent page scope (tool names are exactly the server's): on attach it registers initialPage.props[propsKey]; on every navigate event it reads e.detail.page.props[propsKey], disposes the page scope and registers the new entries (see propsTools for validation — malformed entries and collisions are events, never thrown). An unchanged entry list (Inertia fires navigate on the initial load and after preserveState visits) keeps the current scope and registrations, so it causes no revision bump; a changed list bumps rev once. A navigation does not cancel in-flight props calls (a props tool's own visit swaps the page before its onSuccess); only the returned disposer does. Register navigationTool at the root scope, never in this page scope. At most one inertiaPages consumer may be attached to a registry at a time: a second one does nothing and emits an error event duplicate_name ("inertiaPages already attached"), in development and production alike.

Parameters ​

o ​

InertiaPagesOptions

The router, the initial page and an optional propsKey (default 'toolmark').

Returns ​

A consumer for tm.use(...); its disposer removes the page tools, unsubscribes from the router and resolves every in-flight props call as cancelled signal. Under SSR it does nothing.

(tm) => () => void