mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 22:14:25 +03:00
24 lines
613 B
TypeScript
24 lines
613 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) |