File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
sandpack-client/src/clients/runtime
sandpack-react/src/presets Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -195,14 +195,18 @@ export class SandpackRuntime extends SandpackClient {
195195 }
196196 } ;
197197
198- this . iframe . onload = ( ) => {
198+ const sendMessage = ( ) => {
199199 const initMsg = {
200200 $channel : CHANNEL_NAME ,
201201 $type : "preview/init" ,
202202 } ;
203203
204204 iframeContentWindow . postMessage ( initMsg , "*" , [ channel . port2 ] ) ;
205+
206+ this . iframe . removeEventListener ( "load" , sendMessage ) ;
205207 } ;
208+
209+ this . iframe . addEventListener ( "load" , sendMessage ) ;
206210 }
207211
208212 private handleWorkerRequest (
@@ -362,6 +366,10 @@ export class SandpackRuntime extends SandpackClient {
362366 */
363367 if ( message . type === "refresh" ) {
364368 this . setLocationURLIntoIFrame ( ) ;
369+
370+ if ( this . options . experimental_enableServiceWorker ) {
371+ this . serviceWorkerHandshake ( ) ;
372+ }
365373 }
366374
367375 this . iframeProtocol . dispatch ( message ) ;
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ export const ExperimentalServiceWorker: React.FC = () => {
5555 ` ,
5656 } }
5757 options = { {
58+ bundlerURL : "https://nqfrns-3000.csb.app/" ,
5859 experimental_enableServiceWorker : true ,
5960 } }
6061 template = "react"
You can’t perform that action at this time.
0 commit comments