diff --git a/src/main/app/application-controller.ts b/src/main/app/application-controller.ts index 65b8d0f..efd0b28 100644 --- a/src/main/app/application-controller.ts +++ b/src/main/app/application-controller.ts @@ -13,6 +13,7 @@ export type ApplicationWindow = { isDestroyed: () => boolean; isMinimized: () => boolean; loadURL: (url: string) => Promise; + loadFile: (filePath: string) => Promise; restore: () => void; show: () => void; }; @@ -119,6 +120,13 @@ export function createApplicationController({ deps.setAppUserModelId(appConfig.userModelId); } + mainWindow = deps.createMainWindow(); + loadingWindow = deps.createLoadingWindow(); + + await loadingWindow.loadFile(paths.staticLoadingHtmlPath); + loadingWindow.show(); + await sleep(50); + state = "preparing"; const preparedRuntime = deps.prepareRuntime({ sourceRuntimePath: paths.sourceNodecgRuntimePath, @@ -131,11 +139,6 @@ export function createApplicationController({ nodecgManager = deps.createNodecgProcessManager(preparedRuntime.runtimePath); - mainWindow = deps.createMainWindow(); - loadingWindow = deps.createLoadingWindow(); - - loadingWindow.show(); - state = "starting"; await startNodecg(); diff --git a/src/main/app/paths.ts b/src/main/app/paths.ts index 97034a1..0303462 100644 --- a/src/main/app/paths.ts +++ b/src/main/app/paths.ts @@ -9,6 +9,7 @@ export type ApplicationPaths = { nodecgBaseUrl: string; mainDashboardUrl: string; loadingDashboardUrl: string; + staticLoadingHtmlPath: string; }; export function getRootPath(isDev: boolean, compiledMainDir: string, resourcesPath: string): string { @@ -78,5 +79,6 @@ export function getApplicationPaths({ nodecgBaseUrl: getNodecgBaseUrl(appConfig.nodecgPort), mainDashboardUrl: getDashboardUrl(appConfig.nodecgPort, appConfig.bundleName, appConfig.mainDashboardRoute), loadingDashboardUrl: getDashboardUrl(appConfig.nodecgPort, appConfig.bundleName, appConfig.loadingDashboardRoute), + staticLoadingHtmlPath: path.join(rootPath, "static", "loading.html"), }; } diff --git a/src/tests/application-controller.test.ts b/src/tests/application-controller.test.ts index 9f6c5b9..ef1b586 100644 --- a/src/tests/application-controller.test.ts +++ b/src/tests/application-controller.test.ts @@ -35,6 +35,10 @@ class MockWindow implements ApplicationWindow { this.events.push(`${this.name}:load:${url}`); } + async loadFile(filePath: string): Promise { + this.events.push(`${this.name}:loadFile:${filePath}`); + } + restore(): void { this.events.push(`${this.name}:restore`); this.minimized = false; @@ -87,6 +91,7 @@ test("ApplicationController preserves startup ordering and schedules updates aft nodecgBaseUrl: "http://127.0.0.1:9090", mainDashboardUrl: "http://localhost:9090/bundles/scoreko-dev/dashboard/main.html?standalone=true", loadingDashboardUrl: "http://localhost:9090/bundles/scoreko-dev/dashboard/loading/main.html?standalone=true", + staticLoadingHtmlPath: "/app/static/loading.html", }; const controller = createApplicationController({ @@ -129,11 +134,13 @@ test("ApplicationController preserves startup ordering and schedules updates aft assert.equal(controller.getState(), "ready"); assert.deepEqual(events, [ "set-app-user-model-id", - "prepare-runtime", - "create-manager", "create-main", "create-loading", + `loading:loadFile:${paths.staticLoadingHtmlPath}`, "loading:show", + "sleep:50", + "prepare-runtime", + "create-manager", "start-nodecg", "wait-nodecg", `loading:load:${paths.loadingDashboardUrl}`, @@ -158,6 +165,7 @@ test("ApplicationController directly launches packaged app after runtime install nodecgBaseUrl: "http://127.0.0.1:9090", mainDashboardUrl: "http://localhost:9090/main", loadingDashboardUrl: "http://localhost:9090/loading", + staticLoadingHtmlPath: "/app/static/loading.html", }, deps: { createLoadingWindow: () => { @@ -189,10 +197,12 @@ test("ApplicationController directly launches packaged app after runtime install assert.equal(controller.getState(), "ready"); assert.deepEqual(events, [ - "create-manager", "create-main", "create-loading", + "loading:loadFile:/app/static/loading.html", "loading:show", + "sleep:50", + "create-manager", "start-nodecg", "wait-nodecg", "loading:load:http://localhost:9090/loading", @@ -217,6 +227,7 @@ test("ApplicationController activation before readiness routes through launch", nodecgBaseUrl: "http://127.0.0.1:9090", mainDashboardUrl: "http://localhost:9090/main", loadingDashboardUrl: "http://localhost:9090/loading", + staticLoadingHtmlPath: "/app/static/loading.html", }, deps: { createLoadingWindow: () => new MockWindow("loading", events), @@ -257,6 +268,7 @@ test("ApplicationController shutdown is idempotent", async () => { nodecgBaseUrl: "http://127.0.0.1:9090", mainDashboardUrl: "http://localhost:9090/main", loadingDashboardUrl: "http://localhost:9090/loading", + staticLoadingHtmlPath: "/app/static/loading.html", }, deps: { createLoadingWindow: () => new MockWindow("loading", events), diff --git a/static/loading.html b/static/loading.html new file mode 100644 index 0000000..9121945 --- /dev/null +++ b/static/loading.html @@ -0,0 +1,43 @@ + + + + + Scoreko + + + +
+

Preparando Scoreko...

+ +