|
|
|
|
@ -3,8 +3,9 @@ import { set, source } from '../reactivity/sources.js';
|
|
|
|
|
import { get } from '../runtime.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {{ source: import("#client").Source<(anchor: Comment, props: any) => any>; wrapper: (anchor: Comment, props: any) => any; }} data
|
|
|
|
|
* @param {(anchor: Comment, props: any) => any} component
|
|
|
|
|
* @template {(anchor: Comment, props: any) => any} Component
|
|
|
|
|
* @param {{ source: import("#client").Source<Component>; wrapper: Component; }} data
|
|
|
|
|
* @param {Component} component
|
|
|
|
|
*/
|
|
|
|
|
export function hmr(data, component) {
|
|
|
|
|
if (data.source) {
|
|
|
|
|
@ -13,24 +14,26 @@ export function hmr(data, component) {
|
|
|
|
|
data.source = source(component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (data.wrapper ??= (/** @type {Comment} */ anchor, /** @type {any} */ props) => {
|
|
|
|
|
let output;
|
|
|
|
|
return (data.wrapper ??= /** @type {Component} */ (
|
|
|
|
|
(anchor, props) => {
|
|
|
|
|
let output;
|
|
|
|
|
|
|
|
|
|
/** @type {import("#client").Effect} */
|
|
|
|
|
let effect;
|
|
|
|
|
/** @type {import("#client").Effect} */
|
|
|
|
|
let effect;
|
|
|
|
|
|
|
|
|
|
block(() => {
|
|
|
|
|
const component = get(data.source);
|
|
|
|
|
block(() => {
|
|
|
|
|
const component = get(data.source);
|
|
|
|
|
|
|
|
|
|
if (effect) {
|
|
|
|
|
pause_effect(effect);
|
|
|
|
|
}
|
|
|
|
|
if (effect) {
|
|
|
|
|
pause_effect(effect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
effect = branch(() => {
|
|
|
|
|
output = component(anchor, props);
|
|
|
|
|
effect = branch(() => {
|
|
|
|
|
output = component(anchor, props);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return output;
|
|
|
|
|
});
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|