mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-12-25 19:31:50 +03:00
404aacfa46
* Switch to `bracketSpacing: false`. * Add prettier-ignore in one case.
25 lines
617 B
TypeScript
25 lines
617 B
TypeScript
import {h, render} from 'preact'
|
|
import {Application} from './application'
|
|
|
|
let app: Application | null = null
|
|
const retained = (window as any)['__retained__'] as any
|
|
declare const module: any
|
|
if (module.hot) {
|
|
module.hot.dispose(() => {
|
|
if (app) {
|
|
;(window as any)['__retained__'] = app.serialize()
|
|
}
|
|
})
|
|
module.hot.accept()
|
|
}
|
|
|
|
function ref(instance: Application | null) {
|
|
app = instance
|
|
if (instance && retained) {
|
|
console.log('rehydrating: ', retained)
|
|
instance.rehydrate(retained)
|
|
}
|
|
}
|
|
|
|
render(<Application ref={ref} />, document.body, document.body.lastElementChild || undefined)
|