File tree Expand file tree Collapse file tree 5 files changed +42
-14
lines changed Expand file tree Collapse file tree 5 files changed +42
-14
lines changed Original file line number Diff line number Diff line change 55 < link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > Vite + TS</ title >
8+
9+ < script src ="/scram/scramjet.controller.js "> </ script >
810 </ head >
911
1012 < body >
Original file line number Diff line number Diff line change 1515 "dependencies" : {
1616 "@iconify/types" : " ^2.0.0" ,
1717 "@ktibow/iconset-material-symbols" : " ^0.0.1749705809" ,
18+ "@mercuryworkshop/epoxy-transport" : " ^2.1.27" ,
19+ "@mercuryworkshop/scramjet" : " workspace:scramjet" ,
1820 "dreamland" : " workspace:dreamland" ,
19- "@mercuryworkshop/scramjet " : " workspace:scramjet "
21+ "vite-plugin-static-copy " : " ^3.1.0 "
2022 }
2123}
Original file line number Diff line number Diff line change 1+ importScripts ( "/scram/scramjet.shared.js" , "/scram/scramjet.worker.js" ) ;
2+
3+ const scramjet = new ScramjetServiceWorker ( ) ;
4+
5+ async function handleRequest ( event ) {
6+ await scramjet . loadConfig ( ) ;
7+ if ( scramjet . route ( event ) ) {
8+ return scramjet . fetch ( event ) ;
9+ }
10+
11+ return fetch ( event . request ) ;
12+ }
13+
14+ self . addEventListener ( "fetch" , ( event ) => {
15+ event . respondWith ( handleRequest ( event ) ) ;
16+ } ) ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const scramjet = new ScramjetController({
3333
3434scramjet . init ( ) ;
3535navigator . serviceWorker . register ( "./sw.js" ) ;
36+ let frame = scramjet . createFrame ( ) ;
3637
3738let browser = createBrowser ( ) ;
3839( self as any ) . browser = browser ;
Original file line number Diff line number Diff line change 11import { defineConfig } from "vite" ;
22import { epoxyPath } from "@mercuryworkshop/epoxy-transport" ;
3+ import { scramjetPath } from "@mercuryworkshop/scramjet" ;
34import { baremuxPath } from "@mercuryworkshop/bare-mux/node" ;
5+
6+ import { viteStaticCopy } from "vite-plugin-static-copy" ;
47console . log ( epoxyPath , baremuxPath ) ;
58
69export default defineConfig ( {
710 plugins : [
8- {
9- name : "static-files" ,
10- configureServer ( server ) {
11- server . middlewares . use ( ( req , res , next ) => {
12- if ( req . url . startsWith ( "/epoxy/" ) ) {
13- req . url = req . url . replace ( "/epoxy/" , epoxyPath + "/" ) ;
14- } else if ( req . url . startsWith ( "/baremux/" ) ) {
15- req . url = req . url . replace ( "/baremux/" , baremuxPath + "/" ) ;
16- }
17- next ( ) ;
18- } ) ;
19- } ,
20- } ,
11+ viteStaticCopy ( {
12+ structured : false ,
13+ targets : [
14+ {
15+ src : epoxyPath + "/*" ,
16+ dest : "epoxy/" ,
17+ } ,
18+ {
19+ src : baremuxPath + "/*" ,
20+ dest : "baremux/" ,
21+ } ,
22+ {
23+ src : scramjetPath + "/*" ,
24+ dest : "scram/" ,
25+ } ,
26+ ] ,
27+ } ) ,
2128 ] ,
2229} ) ;
You can’t perform that action at this time.
0 commit comments