File tree Expand file tree Collapse file tree 3 files changed +43
-22
lines changed
sandpack-client/src/clients/runtime Expand file tree Collapse file tree 3 files changed +43
-22
lines changed Original file line number Diff line number Diff line change @@ -106,4 +106,20 @@ export type SandpackRuntimeMessage = BaseSandpackMessage &
106106 | SandboxTestMessage
107107 | { type : "sign-in" ; teamId : string }
108108 | { type : "sign-out" }
109+ | {
110+ type : "dependencies" ;
111+ data :
112+ | {
113+ state : "downloading_manifest" ;
114+ }
115+ | {
116+ state : "downloaded_module" ;
117+ name : string ;
118+ total : number ;
119+ progress : number ;
120+ }
121+ | {
122+ state : "starting" ;
123+ } ;
124+ }
109125 ) ;
Original file line number Diff line number Diff line change @@ -11,30 +11,20 @@ export const Basic: React.FC = () => {
1111 return (
1212 < div style = { { height : "400vh" } } >
1313 < Sandpack
14- files = { {
15- "/App.js" : `export default function TodoList() {
16- return (
17- // This doesn't quite work!
18- <h1>Hedy Lamarr's Todos</h1>
19- <img
20- src="https://i.imgur.com/yXOvdOSs.jpg"
21- alt="Hedy Lamarr"
22- class="photo"
23- >
24- <ul>
25- <li>Invent new traffic lights
26- <li>Rehearse a movie scene
27- <li>Improve spectrum technology
28- </ul>
29- );
30- }
31- ` ,
32- } }
3314 options = { {
34- initMode : "user-visible" ,
35- bundlerURL : "https://786946de.sandpack-bundler-4bw.pages.dev" ,
15+ bundlerURL : "https://ymxnqs-3000.csb.app" ,
3616 } }
3717 template = "react"
18+ customSetup = { {
19+ dependencies : {
20+ "react-content-loader" : "latest" ,
21+ "radix-ui" : "latest" ,
22+ "styled-components" : "latest" ,
23+ "react-dom" : "latest" ,
24+ react : "latest" ,
25+ "react-table" : "latest" ,
26+ } ,
27+ } }
3828 />
3929 </ div >
4030 ) ;
Original file line number Diff line number Diff line change @@ -56,7 +56,22 @@ export const useSandpackPreviewProgress = (
5656 } , timeout ) ;
5757 }
5858
59- if ( message . type === "shell/progress" && ! isReady ) {
59+ if ( message . type === "dependencies" ) {
60+ setLoadingMessage ( ( ) => {
61+ switch ( message . data . state ) {
62+ case "downloading_manifest" :
63+ return "[1/3] Downloading manifest" ;
64+
65+ case "downloaded_module" :
66+ return `[2/3] Downloaded ${ message . data . name } (${ message . data . progress } /${ message . data . total } )` ;
67+
68+ case "starting" :
69+ return "[3/3] Starting" ;
70+ }
71+
72+ return null ;
73+ } ) ;
74+ } else if ( message . type === "shell/progress" && ! isReady ) {
6075 if ( ! totalDependencies && message . data . state === "downloaded_module" ) {
6176 setTotalDependencies ( message . data . totalPending ) ;
6277 }
You can’t perform that action at this time.
0 commit comments