@@ -29,6 +29,59 @@ const col = css`
2929
3030connection . setTransport ( store . transport , [ { wisp : store . wispurl } ] ) ;
3131
32+ let signedinr ;
33+ let signedin = new Promise ( ( resolve ) => ( signedinr = resolve ) ) ;
34+
35+ function SignIn ( ) {
36+ this . css = `
37+ transition: opacity 0.4s ease;
38+ :modal[open] {
39+ animation: fade 0.4s ease normal;
40+ }
41+
42+ :modal::backdrop {
43+ backdrop-filter: blur(3px);
44+ }
45+ ` ;
46+ this . status = "" ;
47+
48+ function handleModalClose ( modal ) {
49+ modal . style . opacity = 0 ;
50+ setTimeout ( ( ) => {
51+ modal . close ( ) ;
52+ modal . style . opacity = 1 ;
53+ } , 250 ) ;
54+ }
55+
56+ const signin = async ( ) => {
57+ this . status = "Signing in..." ;
58+ console . log ( "??" ) ;
59+ try {
60+ await puter . auth . signIn ( ) ;
61+ this . status = "Signed in successfully!" ;
62+ signedinr ( ) ;
63+ handleModalClose ( this . root ) ;
64+ } catch ( e ) {
65+ console . log ( e ) ;
66+ this . status = "Error signing in: " + e . message ;
67+ return ;
68+ }
69+ } ;
70+
71+ return html `
72+ < dialog
73+ class ="signin "
74+ style ="background-color: #121212; color: white; border-radius: 8px; "
75+ >
76+ < h1 > Sign In</ h1 >
77+ < p > Sign in with Puter to accses Scramjet Browser</ p >
78+
79+ < button on:click =${ signin } > Sign In</ button >
80+ < p > ${ use ( this . status ) } </ p >
81+ </ dialog >
82+ ` ;
83+ }
84+
3285function Config ( ) {
3386 this . css = `
3487 transition: opacity 0.4s ease;
@@ -197,6 +250,18 @@ function BrowserApp() {
197250
198251 const frame = scramjet . createFrame ( ) ;
199252
253+ this . mount = async ( ) => {
254+ if ( ! puter . auth . isSignedIn ( ) ) {
255+ const signin = h ( SignIn ) ;
256+ document . body . appendChild ( signin ) ;
257+ signin . showModal ( ) ;
258+ await signedin ;
259+ }
260+
261+ let wisp = await puter . net . generateWispV1URL ( ) ;
262+ console . log ( wisp ) ;
263+ } ;
264+
200265 frame . addEventListener ( "urlchange" , ( e ) => {
201266 if ( ! e . url ) return ;
202267 this . url = e . url ;
@@ -225,7 +290,7 @@ function BrowserApp() {
225290 < button on:click =${ ( ) => frame . forward ( ) } > -></ button >
226291 < button on:click =${ ( ) => frame . reload ( ) } > ↻</ button >
227292
228- < input class ="bar " autocomplete ="off " autocapitalize ="off " autocorrect ="off "
293+ < input class ="bar " autocomplete ="off " autocapitalize ="off " autocorrect ="off "
229294 bind:value =${ use ( this . url ) } on:input =${ ( e ) => {
230295 this . url = e . target . value ;
231296 } } on:keyup=${ ( e ) => e . keyCode == 13 && ( store . url = this . url ) && handleSubmit ( ) } > </ input >
0 commit comments