Experimental integration of cheap-glkote with emglken

This commit is contained in:
He4eT 2021-02-23 21:17:26 +05:00
commit 5c5839fb44

View file

@ -2,6 +2,13 @@ import { h } from 'preact'
import { getFileExtension } from '~/src/utils/utils.routing' import { getFileExtension } from '~/src/utils/utils.routing'
import CheapGlkOte from 'cheap-glkote'
import engine from 'emglken/src/tads.js'
const blobToFile = fileName => theBlob =>{
return new File([theBlob], fileName)
}
export default function ({setTheme, theme, encodedUrl}) { export default function ({setTheme, theme, encodedUrl}) {
setTheme(theme) setTheme(theme)
@ -11,7 +18,19 @@ export default function ({setTheme, theme, encodedUrl}) {
const fetchGameFile = fetch(url) const fetchGameFile = fetch(url)
.then(response => (console.log(response), response)) .then(response => (console.log(response), response))
.then(response => response.blob()) .then(response => response.blob())
.then(console.log) .then(blob => new Response(blob).arrayBuffer())
.then(buffer => new Uint8Array(buffer))
.then(file => {
console.log(file)
const {glkInterface, sendFn} = CheapGlkOte({
onUpdateContent: messages => console.log(messages)
})
window.send = sendFn
const vm = new engine()
vm.prepare(file, glkInterface)
vm.start()
})
.catch(console.log) .catch(console.log)
return ( return (