mirror of
https://github.com/He4eT/cheap-glkote.git
synced 2026-05-05 00:47:28 +00:00
35 lines
667 B
JavaScript
35 lines
667 B
JavaScript
const FakeDialog = require('./fakeDialog')
|
|
const CheapGlkOte = require('./cheapGlkOte')
|
|
|
|
const noop = () => void null
|
|
|
|
const noopHandlers = [
|
|
'onInit',
|
|
'onUpdateContent',
|
|
'onDisable',
|
|
'onUpdateInputs',
|
|
'onFileNameRequest',
|
|
'onFileRead',
|
|
'onFileWrite',
|
|
'onExit',
|
|
'setSend'
|
|
].reduce((acc, x) => ((acc[x] = noop), acc), {})
|
|
|
|
module.exports = handlers_ => {
|
|
const handlers =
|
|
Object.assign({}, noopHandlers, handlers_)
|
|
|
|
const Dialog = new FakeDialog(handlers)
|
|
const GlkOte = new CheapGlkOte(handlers)
|
|
|
|
const sendFn = GlkOte.sendFn.bind(GlkOte)
|
|
|
|
return {
|
|
sendFn,
|
|
glkInterface: {
|
|
Dialog,
|
|
GlkOte,
|
|
Glk: {}
|
|
}
|
|
}
|
|
}
|