@@ -6,7 +6,14 @@ import { createLocationProxy } from "@client/location";
66import { createWrapFn } from "@client/shared/wrap" ;
77import { NavigateEvent } from "@client/events" ;
88import { rewriteUrl , unrewriteUrl , type URLMeta } from "@rewriters/url" ;
9- import { bareTransport , config , flagEnabled } from "@/shared" ;
9+ import {
10+ bareTransport ,
11+ ClientRPCDefs ,
12+ config ,
13+ flagEnabled ,
14+ ScramjetContext ,
15+ ScramjetInterface ,
16+ } from "@/shared" ;
1017import { CookieJar } from "@/shared/cookie" ;
1118import { iswindow } from "./entry" ;
1219import { SingletonBox } from "./singletonbox" ;
@@ -100,6 +107,8 @@ export class ScramjetClient {
100107 locationProxy : any ;
101108 serviceWorker : ServiceWorkerContainer ;
102109 bare : BareClient ;
110+ context : ScramjetContext ;
111+ rpc : ClientRPCDefs ;
103112
104113 natives : NativeStore ;
105114 descriptors : DescriptorStore ;
@@ -356,7 +365,6 @@ export class ScramjetClient {
356365 return frame . name ;
357366 }
358367 } ,
359- prefix : new URL ( location . origin + config . prefix ) ,
360368 } ;
361369 this . locationProxy = createLocationProxy ( this , global ) ;
362370
@@ -437,7 +445,7 @@ export class ScramjetClient {
437445 }
438446
439447 get url ( ) : URL {
440- return new URL ( unrewriteUrl ( this . global . location . href , this . meta ) ) ;
448+ return new URL ( unrewriteUrl ( this . global . location . href , this . context ) ) ;
441449 }
442450
443451 set url ( url : URL | string ) {
@@ -449,7 +457,7 @@ export class ScramjetClient {
449457 }
450458 if ( ev . defaultPrevented ) return ;
451459
452- this . global . location . href = rewriteUrl ( ev . url , this . meta ) ;
460+ this . global . location . href = rewriteUrl ( ev . url , this . context , this . meta ) ;
453461 }
454462
455463 // below are the utilities for proxying and trapping dom APIs
@@ -547,10 +555,11 @@ export class ScramjetClient {
547555
548556 const pst = Error . prepareStackTrace ;
549557
558+ let client = this ;
550559 Error . prepareStackTrace = function ( err , s ) {
551560 if (
552561 s [ 0 ] . getFileName ( ) &&
553- ! s [ 0 ] . getFileName ( ) . startsWith ( location . origin + config . prefix )
562+ ! s [ 0 ] . getFileName ( ) . startsWith ( client . context . prefix . href )
554563 ) {
555564 return { stack : err . stack } ;
556565 }
0 commit comments