1/**2 * Preact binding for the schema-compatibility gate: the live compatibility3 * state, for apps that render their own surface in place of the framework's4 * default read-only banner.5 *6 * @module7 */89import { useEffect, useState } from "preact/hooks";10import {11 getSchemaCompatState,12 type SchemaCompatState,13 subscribeSchemaCompat,14} from "../runtime/schema-compat.ts";1516export type { SchemaCompatReason, SchemaCompatState } from "../runtime/schema-compat.ts";1718/**19 * Subscribes a Preact component to the schema-compatibility gate, so apps can20 * render their own read-only banner in place of the framework default21 * (suppress the default with `pwa: { updateBanner: "none" }` in22 * `defineLofiApp`).23 *24 * @example25 * ```tsx26 * import { useSchemaCompat } from "@nzip/lofi/preact";27 *28 * const compat = useSchemaCompat();29 * if (compat.state === "data-ahead") return <ReadOnlyBanner message={compat.message} />;30 * ```31 *32 * @returns The current compatibility state, kept live via subscription.33 */34export function useSchemaCompat(): SchemaCompatState {35 const [state, setState] = useState<SchemaCompatState>(getSchemaCompatState());36 useEffect(() => subscribeSchemaCompat(setState), []);37 return state;38}