- Loading...
+
diff --git a/src/components/Player/Player.jsx b/src/components/Player/Player.jsx
index 83b9a95..f53daf7 100644
--- a/src/components/Player/Player.jsx
+++ b/src/components/Player/Player.jsx
@@ -9,12 +9,13 @@ import CheapGlkOte from 'cheap-glkote'
import TextBuffer from './TextBuffer'
import InputBox from './InputBox'
+import Status from './Status'
import './player.css'
const INITIAL_STATUS = {
stage: 'loading',
- details: 'Preparing...'
+ details: ['Preparing']
}
const runMachine = ({ Engine, file, handlers }) => {
@@ -104,7 +105,7 @@ export default function ({ vmParts: { file, engine } }) {
}, [vm])
return status.stage !== 'ready'
- ? (
+
Loading
{status.details}
)
+ ? (
+
+
+)
+
+const loading = details => (
+ Error
+ {details.map(x => ({x}
))} ++
+ {details.map(x => (
+)
+
+export default ({ stage, details }) =>
+ ({fail, loading})[stage](details)
diff --git a/src/components/Player/UrlPlayer.jsx b/src/components/Player/UrlPlayer.jsx
index f71f1f0..7997855 100644
--- a/src/components/Player/UrlPlayer.jsx
+++ b/src/components/Player/UrlPlayer.jsx
@@ -4,33 +4,34 @@ import { useState, useEffect } from 'preact/hooks'
import { engineByFilename } from './common/engines'
import Player from './Player'
+import Status from './Status'
const INITIAL_STATUS = {
stage: 'loading',
- details: 'Loading...'
+ details: ['Loading']
}
const prepareVM = ({ url, setStatus, setParts }) => {
const st = (stage, details) => args => {
- setStatus({ stage, details })
+ setStatus({ stage, details: [details] })
return args
}
return Promise.resolve()
- .then(st('loading', 'Downloading file...'))
+ .then(st('loading', 'Downloading file'))
.then(_ => fetch(url))
- .then(st('loading', 'Processing file...'))
+ .then(st('loading', 'Processing file'))
.then(response => response.arrayBuffer())
.then(arrayBuffer => new Uint8Array(arrayBuffer))
- .then(st('loading', 'Downloading engine...'))
+ .then(st('loading', 'Downloading engine'))
.then(file => setParts({
file,
engine: engineByFilename(url)
}))
- .then(st('loading', 'Running...'))
+ .then(st('loading', 'Running'))
.catch(e => {
console.error(e)
- setStatus({ stage: 'fail', details: e.message })
+ setStatus({ stage: 'fail', details: [e.message, url] })
})
}
@@ -47,5 +48,5 @@ export default function ({ url }) {
return vmParts
? ({x}
))}
+ {status.details}
)
+ : (