|
|
@ -5,15 +5,26 @@ import { get } from '../runtime.js';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @template {(anchor: Comment, props: any) => any} Component
|
|
|
|
* @template {(anchor: Comment, props: any) => any} Component
|
|
|
|
* @param {{ source: import("#client").Source<Component>; wrapper: Component; }} data
|
|
|
|
* @param {{ components: Map<string, { source: import("#client").Source<Component>; wrapper: null | Component; }> }} hot_data
|
|
|
|
|
|
|
|
* @param {string} key
|
|
|
|
* @param {Component} component
|
|
|
|
* @param {Component} component
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function hmr(data, component) {
|
|
|
|
export function hmr(hot_data, component, key) {
|
|
|
|
if (data.source) {
|
|
|
|
var components = (hot_data.components ??= new Map());
|
|
|
|
set(data.source, component);
|
|
|
|
var data = components.get(key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data === undefined) {
|
|
|
|
|
|
|
|
components.set(
|
|
|
|
|
|
|
|
key,
|
|
|
|
|
|
|
|
(data = {
|
|
|
|
|
|
|
|
source: source(component),
|
|
|
|
|
|
|
|
wrapper: null
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
data.source = source(component);
|
|
|
|
set(data.source, component);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const component_source = data.source;
|
|
|
|
|
|
|
|
|
|
|
|
return (data.wrapper ??= /** @type {Component} */ (
|
|
|
|
return (data.wrapper ??= /** @type {Component} */ (
|
|
|
|
(anchor, props) => {
|
|
|
|
(anchor, props) => {
|
|
|
@ -23,7 +34,7 @@ export function hmr(data, component) {
|
|
|
|
let effect;
|
|
|
|
let effect;
|
|
|
|
|
|
|
|
|
|
|
|
block(() => {
|
|
|
|
block(() => {
|
|
|
|
const component = get(data.source);
|
|
|
|
const component = get(component_source);
|
|
|
|
|
|
|
|
|
|
|
|
if (effect) {
|
|
|
|
if (effect) {
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|