11import { createState } from "dreamland/core" ;
22import { StatefulClass } from "./StatefulClass" ;
33import { scramjet } from "./main" ;
4- import { History , injectHistoryEmulation } from "./history" ;
4+ import {
5+ addHistoryListeners ,
6+ History ,
7+ injectHistoryEmulation ,
8+ } from "./history" ;
9+ import { NewTab } from "./pages/NewTab" ;
510
611let id = 0 ;
712export class Tab extends StatefulClass {
@@ -22,12 +27,15 @@ export class Tab extends StatefulClass {
2227 canGoForward : boolean = false ;
2328 canGoBack : boolean = false ;
2429
30+ internalpage : HTMLElement | null ;
31+
2532 constructor ( public url : URL = new URL ( "puter://newtab" ) ) {
2633 super ( createState ( Object . create ( Tab . prototype ) ) ) ;
2734
2835 this . id = id ++ ;
2936
3037 this . title = null ;
38+ this . internalpage = null ;
3139
3240 this . history = new History ( this ) ;
3341 this . history . push ( this . url , undefined ) ;
@@ -41,7 +49,10 @@ export class Tab extends StatefulClass {
4149 this . pos = 0 ;
4250
4351 const frame = scramjet . createFrame ( ) ;
44- injectHistoryEmulation ( frame , this ) ;
52+ addHistoryListeners ( frame , this ) ;
53+ frame . addEventListener ( "contextInit" , ( ctx ) => {
54+ injectHistoryEmulation ( ctx . client , this ) ;
55+ } ) ;
4556
4657 this . frame = frame ;
4758 }
@@ -53,8 +64,10 @@ export class Tab extends StatefulClass {
5364 switch ( url . host ) {
5465 case "newtab" :
5566 this . title = "New Tab" ;
67+ this . internalpage = < NewTab tab = { this } /> ;
5668 }
5769 } else {
70+ this . internalpage = null ;
5871 this . frame . go ( url ) ;
5972 }
6073 }
0 commit comments