git ssb

16+

Dominic / patchbay



Tree: 2d581d5e26ada49ca088f855fb0c84c4a6f129c6

Files: 2d581d5e26ada49ca088f855fb0c84c4a6f129c6 / modules_core / app.js

1311 bytesRaw
1const fs = require('fs')
2const h = require('../h')
3const { Value } = require('mutant')
4const insertCss = require('insert-css')
5
6exports.needs = {
7 screen_view: 'first',
8 styles: 'first'
9}
10
11exports.gives = {
12 app: true,
13 mcss: true
14}
15
16exports.create = function (api) {
17 return {
18 app,
19 mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
20 }
21
22 function app () {
23 process.nextTick(() => insertCss(api.styles()))
24
25 var view = Value(getView())
26 var screen = h('App', view)
27
28 window.onhashchange = () => view.set(getView())
29 document.body.appendChild(screen)
30
31 // tabs (another core module) currently handles this
32 // window.addEventListener('error', window.onError = displayError)
33
34 return screen
35 }
36
37 function getView () {
38 const view = window.location.hash.substring(1) || 'tabs'
39 return api.screen_view(view)
40 }
41}
42
43// function displayError (e) {
44// document.body.querySelector('.content').appendChild(
45// h('div.page', [
46// h('Error', { title: e.message }, [
47// h('h1', e.message),
48// h('big', [
49// h('code', e.filename + ':' + e.lineno)
50// ]),
51// h('pre', e.error
52// ? (e.error.stack || e.error.toString())
53// : e.toString()
54// )
55// ])
56// ])
57// )
58// }
59
60

Built with git-ssb-web