Player: explicitly override Engine arguments

This commit is contained in:
He4eT 2023-05-28 13:26:22 +03:00 committed by Alexey
commit 2fdc39c1f0
2 changed files with 10 additions and 4 deletions

View file

@ -20,17 +20,18 @@ const INITIAL_STATUS = {
const runMachine = ({ engine: Engine, wasmBinary, storyfile, handlers }) => {
const { Dialog, GlkOte, send } = CheapGlkOte(handlers)
const vm = new Engine()
const instance = new Engine()
vm.init(storyfile, {
instance.init(storyfile, {
Dialog,
GlkOte,
Glk: {},
wasmBinary,
arguments: ['storyfile'],
})
vm.start()
instance.start()
return { send, instance: vm }
return { send, instance }
}
export default function Player ({
@ -68,6 +69,7 @@ export default function Player ({
window.addEventListener('unhandledrejection', rejectionHandler)
return () => {
setVm(null)
window.removeEventListener('unhandledrejection', rejectionHandler)
}
}, [storyfile, engine, wasmBinary])
@ -76,6 +78,8 @@ export default function Player ({
setSendMessage(() => vm
? vm.send
: null)
return () => setSendMessage(null)
}, [vm])
const textWindow = (inbox) => (currentWindow) => {