@@ -4,6 +4,7 @@ import { Terminal } from "xterm";
44import { FitAddon } from "xterm-addon-fit" ;
55import "xterm/css/xterm.css" ;
66import { Progress , PROGRESS_STATES } from "./Progress.jsx" ;
7+ import { Spec } from "../spec.js" ;
78
89/**
910 *
@@ -12,8 +13,6 @@ import { Progress, PROGRESS_STATES } from "./Progress.jsx";
1213 * @param {string } urlPath
1314 */
1415function redirectToRunningServer ( serverUrl , token , urlPath ) {
15- // Make sure urlPath doesn't start with a `/`
16- urlPath = urlPath . replace ( / ^ \/ / , "" ) ;
1716 const redirectUrl = new URL ( urlPath , serverUrl ) ;
1817 redirectUrl . searchParams . append ( "token" , token ) ;
1918 window . location . href = redirectUrl . toString ( ) ;
@@ -22,10 +21,9 @@ function redirectToRunningServer(serverUrl, token, urlPath) {
2221/**
2322 *
2423 * @param {URL } baseUrl
25- * @param {string } spec
24+ * @param {Spec } spec
2625 * @param {Terminal } term
2726 * @param {FitAddon } fitAddon
28- * @param {string } urlPath
2927 * @param {(l: boolean) => void } setIsLaunching
3028 * @param {(p: PROGRESS_STATES) => void } setProgressState
3129 * @param {(e: boolean) => void } setEnsureLogsVisible
@@ -35,13 +33,12 @@ async function buildImage(
3533 spec ,
3634 term ,
3735 fitAddon ,
38- urlPath ,
3936 setIsLaunching ,
4037 setProgressState ,
4138 setEnsureLogsVisible ,
4239) {
4340 const buildEndPointURL = new URL ( "build/" , baseUrl ) ;
44- const image = new BinderRepository ( spec , buildEndPointURL ) ;
41+ const image = new BinderRepository ( spec . buildSpec , buildEndPointURL ) ;
4542 // Clear the last line written, so we start from scratch
4643 term . write ( "\x1b[2K\r" ) ;
4744 fitAddon . fit ( ) ;
@@ -67,7 +64,11 @@ async function buildImage(
6764 case "ready" : {
6865 setProgressState ( PROGRESS_STATES . SUCCESS ) ;
6966 image . close ( ) ;
70- redirectToRunningServer ( data . url , data . token , urlPath ) ;
67+ redirectToRunningServer (
68+ data . url ,
69+ data . token ,
70+ spec . runtimeParams . urlPath ,
71+ ) ;
7172 console . log ( data ) ;
7273 break ;
7374 }
@@ -158,8 +159,7 @@ function ImageLogs({ setTerm, setFitAddon, logsVisible, setLogsVisible }) {
158159/**
159160 * @typedef {object } BuildLauncherProps
160161 * @prop {URL } baseUrl
161- * @prop {string } spec
162- * @prop {string } urlPath
162+ * @prop {Spec } spec
163163 * @prop {boolean } isLaunching
164164 * @prop {(l: boolean) => void } setIsLaunching
165165 * @prop {PROGRESS_STATES } progressState
@@ -171,7 +171,6 @@ function ImageLogs({ setTerm, setFitAddon, logsVisible, setLogsVisible }) {
171171export function BuilderLauncher ( {
172172 baseUrl,
173173 spec,
174- urlPath,
175174 isLaunching,
176175 setIsLaunching,
177176 progressState,
@@ -188,7 +187,6 @@ export function BuilderLauncher({
188187 spec ,
189188 term ,
190189 fitAddon ,
191- urlPath ,
192190 setIsLaunching ,
193191 setProgressState ,
194192 setLogsVisible ,
0 commit comments