File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 StreamActions ,
1616 StreamMessage ,
1717 StreamSource ,
18+ TurboHistory ,
1819 Visit ,
1920 visit ,
2021 VisitOptions ,
@@ -289,3 +290,29 @@ StreamMessage.contentType;
289290
290291// $ExpectType StreamMessage
291292StreamMessage . wrap ( "<turbo-stream></turbo-stream>" ) ;
293+
294+ // Test TurboHistory via session.history
295+ // $ExpectType TurboHistory
296+ session . history ;
297+ // $ExpectType TurboHistory
298+ Turbo . session . history ;
299+
300+ session . history . push ( new URL ( "https://example.com" ) ) ;
301+ session . history . push ( new URL ( "https://example.com" ) , "abc-123" ) ;
302+ session . history . replace ( new URL ( "https://example.com" ) ) ;
303+ session . history . replace ( new URL ( "https://example.com" ) , "abc-123" ) ;
304+
305+ // $ExpectType URL
306+ session . history . location ;
307+ // $ExpectType string
308+ session . history . restorationIdentifier ;
309+
310+ // Test session getters
311+ // $ExpectType URL
312+ session . location ;
313+ // $ExpectType string
314+ session . restorationIdentifier ;
315+ // $ExpectType boolean
316+ session . started ;
317+ // $ExpectType boolean
318+ session . enabled ;
Original file line number Diff line number Diff line change @@ -277,12 +277,26 @@ export function disconnectStreamSource(source: StreamSource): void;
277277 */
278278export function renderStreamMessage ( message : StreamMessage | string ) : void ;
279279
280+ export interface TurboHistory {
281+ readonly location : URL ;
282+ readonly restorationIdentifier : string ;
283+ push ( location : URL , restorationIdentifier ?: string ) : void ;
284+ replace ( location : URL , restorationIdentifier ?: string ) : void ;
285+ }
286+
280287export interface TurboSession {
288+ readonly history : TurboHistory ;
289+ adapter : Adapter ;
290+ readonly enabled : boolean ;
291+ readonly started : boolean ;
292+
281293 connectStreamSource ( source : StreamSource ) : void ;
282294 disconnectStreamSource ( source : StreamSource ) : void ;
283295 renderStreamMessage ( message : StreamMessage | string ) : void ;
296+
284297 drive : boolean ;
285- adapter : Adapter ;
298+ readonly location : URL ;
299+ readonly restorationIdentifier : string ;
286300}
287301
288302export const StreamActions : {
You can’t perform that action at this time.
0 commit comments