@@ -1580,6 +1580,48 @@ export const VersionedHostRequestResourceAllocationResponse: S.Codec<VersionedHo
15801580 } ) ,
15811581 ) ;
15821582
1583+ /** Versioned envelope for [`HostSessionLifecycleSubscribeError`]. */
1584+ export type VersionedHostSessionLifecycleSubscribeError = {
1585+ tag : "V1" ;
1586+ value : HostSessionLifecycleSubscribeError ;
1587+ } ;
1588+
1589+ export const VersionedHostSessionLifecycleSubscribeError : S . Codec < VersionedHostSessionLifecycleSubscribeError > =
1590+ S . lazy (
1591+ ( ) : S . Codec < VersionedHostSessionLifecycleSubscribeError > =>
1592+ S . indexedTaggedUnion ( {
1593+ V1 : [ 0 , HostSessionLifecycleSubscribeError ] as const ,
1594+ } ) ,
1595+ ) ;
1596+
1597+ /** Versioned envelope for [`HostSessionLifecycleSubscribeItem`]. */
1598+ export type VersionedHostSessionLifecycleSubscribeItem = {
1599+ tag : "V1" ;
1600+ value : HostSessionLifecycleSubscribeItem ;
1601+ } ;
1602+
1603+ export const VersionedHostSessionLifecycleSubscribeItem : S . Codec < VersionedHostSessionLifecycleSubscribeItem > =
1604+ S . lazy (
1605+ ( ) : S . Codec < VersionedHostSessionLifecycleSubscribeItem > =>
1606+ S . indexedTaggedUnion ( {
1607+ V1 : [ 0 , HostSessionLifecycleSubscribeItem ] as const ,
1608+ } ) ,
1609+ ) ;
1610+
1611+ /** Versioned envelope for [`HostSessionLifecycleSubscribeRequest`]. */
1612+ export type VersionedHostSessionLifecycleSubscribeRequest = {
1613+ tag : "V1" ;
1614+ value : HostSessionLifecycleSubscribeRequest ;
1615+ } ;
1616+
1617+ export const VersionedHostSessionLifecycleSubscribeRequest : S . Codec < VersionedHostSessionLifecycleSubscribeRequest > =
1618+ S . lazy (
1619+ ( ) : S . Codec < VersionedHostSessionLifecycleSubscribeRequest > =>
1620+ S . indexedTaggedUnion ( {
1621+ V1 : [ 0 , HostSessionLifecycleSubscribeRequest ] as const ,
1622+ } ) ,
1623+ ) ;
1624+
15831625/** Versioned envelope for [`HostSignPayloadError`]. */
15841626export type VersionedHostSignPayloadError = {
15851627 tag : "V1" ;
@@ -2743,6 +2785,53 @@ export const RuntimeType: S.Codec<RuntimeType> = S.lazy(
27432785 } ) ,
27442786) ;
27452787
2788+ /** Host-assigned stable identifier for one lifecycle event. */
2789+ export type SessionLifecycleEventId = string ;
2790+
2791+ export const SessionLifecycleEventId : S . Codec < SessionLifecycleEventId > = S . lazy (
2792+ ( ) : S . Codec < SessionLifecycleEventId > => S . str ,
2793+ ) ;
2794+
2795+ /** Reason for a lifecycle checkpoint request. */
2796+ export type SessionLifecycleReason =
2797+ | "AppSwitcher"
2798+ | "HostBackgrounded"
2799+ | "HostTerminating"
2800+ | "MemoryPressure"
2801+ | "UserClosedProduct"
2802+ | "HostPolicy" ;
2803+
2804+ export const SessionLifecycleReason : S . Codec < SessionLifecycleReason > = S . lazy (
2805+ ( ) : S . Codec < SessionLifecycleReason > =>
2806+ S . Status (
2807+ "AppSwitcher" ,
2808+ "HostBackgrounded" ,
2809+ "HostTerminating" ,
2810+ "MemoryPressure" ,
2811+ "UserClosedProduct" ,
2812+ "HostPolicy" ,
2813+ ) ,
2814+ ) ;
2815+
2816+ /** Details for a single lifecycle checkpoint request. */
2817+ export interface SessionLifecycleRequest {
2818+ /** Host-assigned event id for de-duplicating repeated notifications. */
2819+ eventId : SessionLifecycleEventId ;
2820+ /** Reason the host is asking the product to checkpoint state. */
2821+ reason : SessionLifecycleReason ;
2822+ /** Best-effort deadline for checkpoint completion. */
2823+ deadlineMs ?: TimestampMs ;
2824+ }
2825+
2826+ export const SessionLifecycleRequest : S . Codec < SessionLifecycleRequest > = S . lazy (
2827+ ( ) : S . Codec < SessionLifecycleRequest > =>
2828+ S . Struct ( {
2829+ eventId : SessionLifecycleEventId ,
2830+ reason : SessionLifecycleReason ,
2831+ deadlineMs : S . Option ( TimestampMs ) ,
2832+ } ) as S . Codec < SessionLifecycleRequest > ,
2833+ ) ;
2834+
27462835/** Shape for borders and backgrounds. */
27472836export type Shape =
27482837 /** Border radius value. */
@@ -2946,6 +3035,13 @@ export const Theme: S.Codec<Theme> = S.lazy(
29463035 ( ) : S . Codec < Theme > => S . Status ( "Light" , "Dark" ) ,
29473036) ;
29483037
3038+ /** Milliseconds since the Unix epoch. */
3039+ export type TimestampMs = bigint ;
3040+
3041+ export const TimestampMs : S . Codec < TimestampMs > = S . lazy (
3042+ ( ) : S . Codec < TimestampMs > => S . u64 ,
3043+ ) ;
3044+
29493045/** 32-byte statement topic. */
29503046export type Topic = HexString ;
29513047
@@ -3993,6 +4089,52 @@ export const HostRequestResourceAllocationResponse: S.Codec<HostRequestResourceA
39934089 } ) as S . Codec < HostRequestResourceAllocationResponse > ,
39944090 ) ;
39954091
4092+ /** Error from session lifecycle subscription setup. */
4093+ export type HostSessionLifecycleSubscribeError =
4094+ /** The host does not support product session lifecycle events. */
4095+ | { tag : "Unsupported" ; value ?: undefined }
4096+ /** Catch-all. */
4097+ | { tag : "Unknown" ; value : GenericErr } ;
4098+
4099+ export const HostSessionLifecycleSubscribeError : S . Codec < HostSessionLifecycleSubscribeError > =
4100+ S . lazy (
4101+ ( ) : S . Codec < HostSessionLifecycleSubscribeError > =>
4102+ S . TaggedUnion ( { Unsupported : S . _void , Unknown : GenericErr } ) ,
4103+ ) ;
4104+
4105+ /** Lifecycle event emitted by the host before a product transition. */
4106+ export type HostSessionLifecycleSubscribeItem =
4107+ /** The product should checkpoint state before it is suspended. */
4108+ | { tag : "WillSuspend" ; value : SessionLifecycleRequest }
4109+ /** The product should checkpoint state before its WebView may be evicted. */
4110+ | { tag : "WillEvict" ; value : SessionLifecycleRequest }
4111+ /** The product should checkpoint state before it is closed. */
4112+ | { tag : "WillClose" ; value : SessionLifecycleRequest } ;
4113+
4114+ export const HostSessionLifecycleSubscribeItem : S . Codec < HostSessionLifecycleSubscribeItem > =
4115+ S . lazy (
4116+ ( ) : S . Codec < HostSessionLifecycleSubscribeItem > =>
4117+ S . TaggedUnion ( {
4118+ WillSuspend : SessionLifecycleRequest ,
4119+ WillEvict : SessionLifecycleRequest ,
4120+ WillClose : SessionLifecycleRequest ,
4121+ } ) ,
4122+ ) ;
4123+
4124+ /** Request to subscribe to host session lifecycle events. */
4125+ export interface HostSessionLifecycleSubscribeRequest {
4126+ /** Ask the host to replay the current lifecycle state when one is active. */
4127+ replayCurrentState : boolean ;
4128+ }
4129+
4130+ export const HostSessionLifecycleSubscribeRequest : S . Codec < HostSessionLifecycleSubscribeRequest > =
4131+ S . lazy (
4132+ ( ) : S . Codec < HostSessionLifecycleSubscribeRequest > =>
4133+ S . Struct ( {
4134+ replayCurrentState : S . bool ,
4135+ } ) as S . Codec < HostSessionLifecycleSubscribeRequest > ,
4136+ ) ;
4137+
39964138export type HostSignPayloadError =
39974139 | { tag : "FailedToDecode" ; value ?: undefined }
39984140 | { tag : "Rejected" ; value ?: undefined }
0 commit comments