2024-12-08 17:20:34 +08:00
|
|
|
import {
|
2024-12-08 22:32:18 +08:00
|
|
|
currentInstance,
|
2024-12-08 17:20:34 +08:00
|
|
|
popWarningContext,
|
|
|
|
pushWarningContext,
|
2024-12-08 22:32:18 +08:00
|
|
|
simpleSetCurrentInstance,
|
2024-12-08 17:20:34 +08:00
|
|
|
} from '@vue/runtime-core'
|
|
|
|
import { normalizeBlock } from './block'
|
|
|
|
import { type VaporComponentInstance, devRender } from './component'
|
|
|
|
import { insert, remove } from './dom/node'
|
|
|
|
|
|
|
|
export function hmrRerender(instance: VaporComponentInstance): void {
|
|
|
|
const normalized = normalizeBlock(instance.block)
|
|
|
|
const parent = normalized[0].parentNode!
|
|
|
|
const anchor = normalized[normalized.length - 1].nextSibling
|
|
|
|
remove(instance.block, parent)
|
2024-12-08 22:32:18 +08:00
|
|
|
const prev = currentInstance
|
|
|
|
simpleSetCurrentInstance(instance)
|
2024-12-08 17:20:34 +08:00
|
|
|
pushWarningContext(instance)
|
|
|
|
devRender(instance)
|
|
|
|
popWarningContext()
|
2024-12-08 22:32:18 +08:00
|
|
|
simpleSetCurrentInstance(prev, instance)
|
2024-12-08 17:20:34 +08:00
|
|
|
insert(instance.block, parent, anchor)
|
|
|
|
}
|
2024-12-08 21:22:51 +08:00
|
|
|
|
|
|
|
export function hmrReload(instance: VaporComponentInstance): void {
|
|
|
|
// in parent block, find the corresponding block of this instance
|
|
|
|
// create new instance, replace
|
|
|
|
}
|