@@ -8,7 +8,10 @@ import store from './useLoaderStore';
88export default function useReg ( ) {
99 const { options } = useOptions ( ) ;
1010 const ws = `${ location . protocol == 'http:' ? 'ws:' : 'wss:' } //${ location . host } /wisp/` ;
11- const sws = [
11+ const sws = isStaticBuild ? [
12+ { path : new URL ( './sw.js' , location . href ) . href , scope : new URL ( './portal/k12/' , location . href ) . href } ,
13+ { path : new URL ( './s_sw.js' , location . href ) . href , scope : new URL ( './ham/' , location . href ) . href }
14+ ] : [
1215 { path : new URL ( '/sw.js' , location . origin ) . href , scope : new URL ( '/portal/k12/' , location . origin ) . href } ,
1316 { path : new URL ( '/s_sw.js' , location . origin ) . href , scope : new URL ( '/ham/' , location . origin ) . href }
1417 ] ;
@@ -18,7 +21,9 @@ export default function useReg() {
1821 const init = async ( ) => {
1922 if ( ! window . scr ) {
2023 const script = document . createElement ( 'script' ) ;
21- script . src = '/eggs/scramjet.all.js' ;
24+ script . src = isStaticBuild
25+ ? new URL ( './eggs/scramjet.all.js' , location . href ) . pathname
26+ : '/eggs/scramjet.all.js' ;
2227 await new Promise ( ( resolve , reject ) => {
2328 script . onload = resolve ;
2429 script . onerror = reject ;
@@ -28,12 +33,19 @@ export default function useReg() {
2833
2934 const { ScramjetController } = $scramjetLoadController ( ) ;
3035
36+ const hamPrefix = isStaticBuild
37+ ? new URL ( './ham/' , location . href ) . pathname
38+ : '/ham/' ;
39+ const eggsPath = isStaticBuild
40+ ? new URL ( './eggs/' , location . href ) . pathname
41+ : '/eggs/' ;
42+
3143 window . scr = new ScramjetController ( {
32- prefix : "/ham/" ,
44+ prefix : hamPrefix ,
3345 files : {
34- wasm : '/eggs/ scramjet.wasm.wasm',
35- all : '/eggs/ scramjet.all.js',
36- sync : '/eggs/ scramjet.sync.js',
46+ wasm : eggsPath + ' scramjet.wasm.wasm',
47+ all : eggsPath + ' scramjet.all.js',
48+ sync : eggsPath + ' scramjet.sync.js',
3749 } ,
3850 flags : { rewriterLogs : false , scramitize : false , cleanErrors : true , sourcemaps : true } ,
3951 codec : makecodec ( )
@@ -52,7 +64,10 @@ export default function useReg() {
5264 }
5365 }
5466
55- const connection = new BareMuxConnection ( new URL ( '/baremux/worker.js' , location . href ) . href ) ;
67+ const baremuxPath = isStaticBuild
68+ ? new URL ( './baremux/worker.js' , location . href ) . href
69+ : new URL ( '/baremux/worker.js' , location . origin ) . href ;
70+ const connection = new BareMuxConnection ( baremuxPath ) ;
5671 isStaticBuild && setWispStatus ( 'init' ) ;
5772 let socket = null ;
5873 try {
@@ -62,7 +77,10 @@ export default function useReg() {
6277 }
6378 isStaticBuild && ( ! socket ? setWispStatus ( false ) : setWispStatus ( true ) ) ;
6479
65- await connection . setTransport ( '/libcurl/index.mjs' , [
80+ const libcurlPath = isStaticBuild
81+ ? new URL ( './libcurl/index.mjs' , location . href ) . pathname
82+ : '/libcurl/index.mjs' ;
83+ await connection . setTransport ( libcurlPath , [
6684 {
6785 wisp :
6886 options . wServer != null && options . wServer !== ''
0 commit comments