@torpor/view 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compile.cjs +7 -0
- package/dist/compile.mjs +7 -0
- package/dist/compile.mjs.map +1 -1
- package/dist/index.cjs +39 -3
- package/dist/index.d.cts +9 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +39 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -430,7 +430,12 @@ function $peek(fn) {
|
|
|
430
430
|
*/
|
|
431
431
|
function flushMountEffects() {
|
|
432
432
|
if (context.mountEffects.length === 0) return;
|
|
433
|
-
|
|
433
|
+
const activeRegion = context.activeRegion;
|
|
434
|
+
for (let effect of context.mountEffects) {
|
|
435
|
+
context.activeRegion = effect.region;
|
|
436
|
+
$run(() => runMountCallback(effect.fn), void 0, { isMountEffect: true });
|
|
437
|
+
}
|
|
438
|
+
context.activeRegion = activeRegion;
|
|
434
439
|
context.mountEffects.length = 0;
|
|
435
440
|
}
|
|
436
441
|
function runMountCallback(fn) {
|
|
@@ -902,6 +907,28 @@ function fillLayoutSlot(component, slot, parent, anchor, $props, $context) {
|
|
|
902
907
|
return region;
|
|
903
908
|
}
|
|
904
909
|
//#endregion
|
|
910
|
+
//#region src/render/firstInsideNode.ts
|
|
911
|
+
/**
|
|
912
|
+
* During hydration, `nodeAnchor` finds the first node inside a hydration
|
|
913
|
+
* block and removes the start/end marker comments. Generated code for
|
|
914
|
+
* `@html` needs that first node later (to adopt the server-rendered nodes
|
|
915
|
+
* as the region's bounds), but by then the markers are gone — so the only
|
|
916
|
+
* reliable way to recover it is to stash it here, keyed by the anchor node
|
|
917
|
+
* that `nodeAnchor` returns.
|
|
918
|
+
*/
|
|
919
|
+
const firstInsideNodes = /* @__PURE__ */ new WeakMap();
|
|
920
|
+
function setFirstInsideNode(anchor, node) {
|
|
921
|
+
firstInsideNodes.set(anchor, node);
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Gets the first node that was inside the hydration block for the given
|
|
925
|
+
* anchor node, or `undefined` if the anchor wasn't hydrated through
|
|
926
|
+
* hydration markers.
|
|
927
|
+
*/
|
|
928
|
+
function firstInsideNode(anchor) {
|
|
929
|
+
return firstInsideNodes.get(anchor);
|
|
930
|
+
}
|
|
931
|
+
//#endregion
|
|
905
932
|
//#region src/render/getFragment.ts
|
|
906
933
|
function getFragment(document, array, index, html, ns) {
|
|
907
934
|
if (array[index] === void 0) if (ns === true) {
|
|
@@ -1117,6 +1144,7 @@ function nodeAnchor(node) {
|
|
|
1117
1144
|
if (context.hydrationNode === currentNode) context.hydrationNode = endNode;
|
|
1118
1145
|
const region = context.activeRegion;
|
|
1119
1146
|
if (region.startNode === null && firstInside !== null) region.startNode = firstInside;
|
|
1147
|
+
setFirstInsideNode(endNode, firstInside);
|
|
1120
1148
|
return endNode;
|
|
1121
1149
|
}
|
|
1122
1150
|
}
|
|
@@ -2631,7 +2659,10 @@ function $cache(fn) {
|
|
|
2631
2659
|
* @param fn The function to run, which may return a cleanup function
|
|
2632
2660
|
*/
|
|
2633
2661
|
function $onmount(fn) {
|
|
2634
|
-
context.mountEffects.push(
|
|
2662
|
+
context.mountEffects.push({
|
|
2663
|
+
region: context.activeRegion,
|
|
2664
|
+
fn
|
|
2665
|
+
});
|
|
2635
2666
|
}
|
|
2636
2667
|
//#endregion
|
|
2637
2668
|
//#region src/watch/$pending.ts
|
|
@@ -2790,7 +2821,7 @@ function $refresh(fn, options) {
|
|
|
2790
2821
|
* every event (only the last event in a burst is handled).
|
|
2791
2822
|
*/
|
|
2792
2823
|
function $stream(source, handler, options) {
|
|
2793
|
-
|
|
2824
|
+
const fn = () => {
|
|
2794
2825
|
let timer;
|
|
2795
2826
|
$run(() => {
|
|
2796
2827
|
const unsub = source((value) => {
|
|
@@ -2804,6 +2835,10 @@ function $stream(source, handler, options) {
|
|
|
2804
2835
|
clearTimeout(timer);
|
|
2805
2836
|
};
|
|
2806
2837
|
});
|
|
2838
|
+
};
|
|
2839
|
+
context.mountEffects.push({
|
|
2840
|
+
region: context.activeRegion,
|
|
2841
|
+
fn
|
|
2807
2842
|
});
|
|
2808
2843
|
}
|
|
2809
2844
|
//#endregion
|
|
@@ -2836,6 +2871,7 @@ exports.t_child = nodeChild;
|
|
|
2836
2871
|
exports.t_class = require_fromWebSocket.buildClasses;
|
|
2837
2872
|
exports.t_dynamic = setDynamicElement;
|
|
2838
2873
|
exports.t_event = addEvent;
|
|
2874
|
+
exports.t_first_inside = firstInsideNode;
|
|
2839
2875
|
exports.t_fmt = require_fromWebSocket.formatText;
|
|
2840
2876
|
exports.t_fragment = getFragment;
|
|
2841
2877
|
exports.t_fragment_el = getElementFragment;
|
package/dist/index.d.cts
CHANGED
|
@@ -73,6 +73,14 @@ declare function fillLayoutSlot(component: Component, slot: SlotRender, parent:
|
|
|
73
73
|
//#region src/render/formatText.d.ts
|
|
74
74
|
declare function formatText(value: any): string;
|
|
75
75
|
//#endregion
|
|
76
|
+
//#region src/render/firstInsideNode.d.ts
|
|
77
|
+
/**
|
|
78
|
+
* Gets the first node that was inside the hydration block for the given
|
|
79
|
+
* anchor node, or `undefined` if the anchor wasn't hydrated through
|
|
80
|
+
* hydration markers.
|
|
81
|
+
*/
|
|
82
|
+
declare function firstInsideNode(anchor: ChildNode): ChildNode | null | undefined;
|
|
83
|
+
//#endregion
|
|
76
84
|
//#region src/render/getFragment.d.ts
|
|
77
85
|
declare function getFragment(document: Document, array: DocumentFragment[], index: number, html: string, ns?: boolean): DocumentFragment;
|
|
78
86
|
//#endregion
|
|
@@ -710,5 +718,5 @@ interface WatchOptions {
|
|
|
710
718
|
*/
|
|
711
719
|
declare function $watch<T extends object>(object: T, options?: WatchOptions): T;
|
|
712
720
|
//#endregion
|
|
713
|
-
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, type Animation, type Bindable, type ClassValue, type Component, type ListItem, type ListItemSpec, type SlotRender, type StreamSource, type StyleValue, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
721
|
+
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, type Animation, type Bindable, type ClassValue, type Component, type ListItem, type ListItemSpec, type SlotRender, type StreamSource, type StyleValue, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, firstInsideNode as t_first_inside, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
714
722
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;iBCiBJ,WAAW,MAAM,SAAS,QAAQ,YAAY,QAAQ;;;iBCnBtD,YACvB,UAAU,kBACV,QAAQ,YACR,QAAQ,aACR,UAAU,WACV,YAAY;;;iBCLW,WACvB,IAAI,SACJ,OAAO,iCACP;;;;;;;;;;iBCKuB,gBAAgB,QAAQ;;;;;;;;;;;;;;;;;;iBCYxB,eACvB,WAAW,WACX,MAAM,YACN,QAAQ,YACR,QAAQ,aACR,SAAS,OAAO,mBAChB,WAAW,OAAO,oBAChB;;;iBC5BqB,WAAW;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/firstInsideNode.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iB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B,SAAS,eAAe,UAAU;;;;;;;;;;iBChDlC,KACvB,UAAU,gBACV,eACA,UAAU,KAAK,0CACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCqBqB,QAAQ,GAC/B,QAAQ,aAAa,IACrB,UAAU,OAAO,YACjB;EAAY;;;;;;;;;iBCrCW,QAAQ,UAAU,OAAO,mBAAmB,QAAQ,IAAI;;;;;;UCJvD;;;;EAIxB;;;;;;;;;;;;;iBCoBuB,OAAO,kBAAkB,QAAQ,GAAG,UAAU,eAAe"}
|
package/dist/index.d.mts
CHANGED
|
@@ -73,6 +73,14 @@ declare function fillLayoutSlot(component: Component, slot: SlotRender, parent:
|
|
|
73
73
|
//#region src/render/formatText.d.ts
|
|
74
74
|
declare function formatText(value: any): string;
|
|
75
75
|
//#endregion
|
|
76
|
+
//#region src/render/firstInsideNode.d.ts
|
|
77
|
+
/**
|
|
78
|
+
* Gets the first node that was inside the hydration block for the given
|
|
79
|
+
* anchor node, or `undefined` if the anchor wasn't hydrated through
|
|
80
|
+
* hydration markers.
|
|
81
|
+
*/
|
|
82
|
+
declare function firstInsideNode(anchor: ChildNode): ChildNode | null | undefined;
|
|
83
|
+
//#endregion
|
|
76
84
|
//#region src/render/getFragment.d.ts
|
|
77
85
|
declare function getFragment(document: Document, array: DocumentFragment[], index: number, html: string, ns?: boolean): DocumentFragment;
|
|
78
86
|
//#endregion
|
|
@@ -710,5 +718,5 @@ interface WatchOptions {
|
|
|
710
718
|
*/
|
|
711
719
|
declare function $watch<T extends object>(object: T, options?: WatchOptions): T;
|
|
712
720
|
//#endregion
|
|
713
|
-
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, type Animation, type Bindable, type ClassValue, type Component, type ListItem, type ListItemSpec, type SlotRender, type StreamSource, type StyleValue, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
721
|
+
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, type Animation, type Bindable, type ClassValue, type Component, type ListItem, type ListItemSpec, type SlotRender, type StreamSource, type StyleValue, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, firstInsideNode as t_first_inside, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
714
722
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;iBCiBJ,WAAW,MAAM,SAAS,QAAQ,YAAY,QAAQ;;;iBCnBtD,YACvB,UAAU,kBACV,QAAQ,YACR,QAAQ,aACR,UAAU,WACV,YAAY;;;iBCLW,WACvB,IAAI,SACJ,OAAO,iCACP;;;;;;;;;;iBCKuB,gBAAgB,QAAQ;;;;;;;;;;;;;;;;;;iBCYxB,eACvB,WAAW,WACX,MAAM,YACN,QAAQ,YACR,QAAQ,aACR,SAAS,OAAO,mBAChB,WAAW,OAAO,oBAChB;;;iBC5BqB,WAAW;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/Animation.ts","../src/render/addAnimation.ts","../src/render/addEvent.ts","../src/render/addElement.ts","../src/render/addFragment.ts","../src/render/applyProps.ts","../src/render/clearLayoutSlot.ts","../src/render/fillLayoutSlot.ts","../src/render/formatText.ts","../src/render/firstInsideNode.ts","../src/render/getFragment.ts","../src/render/getElementFragment.ts","../src/render/hydrate.ts","../src/render/mount.ts","../src/render/unmount.ts","../src/types/ListItemSpec.ts","../src/types/ListItem.ts","../src/render/newListItem.ts","../src/render/newRegion.ts","../src/render/nodeAnchor.ts","../src/render/nodeChild.ts","../src/render/nodeNext.ts","../src/render/nodeRootElement.ts","../src/render/nodeRoot.ts","../src/render/nodeSkip.ts","../src/render/popRegion.ts","../src/render/pushRegion.ts","../src/render/rerunRegionEffects.ts","../src/render/restoreHydration.ts","../src/render/runControl.ts","../src/render/runControlBranch.ts","../src/render/runList.ts","../src/render/runAwait.ts","../src/render/runTry.ts","../src/render/saveHydration.ts","../src/render/setAttribute.ts","../src/render/setDynamicElement.ts","../src/types/Bindable.ts","../src/watch/$batch.ts","../src/watch/$async.ts","../src/watch/$bind.ts","../src/watch/$cache.ts","../src/watch/$onmount.ts","../src/watch/$peek.ts","../src/watch/$pending.ts","../src/watch/$refresh.ts","../src/watch/$run.ts","../src/watch/$stream.ts","../src/watch/$unwrap.ts","../src/types/WatchOptions.ts","../src/watch/$watch.ts"],"mappings":";;;;;UAAyB;EACxB,WAAW,aAAa;EACxB,mBAAmB;;;;iBCCI,aAAa,IAAI,aAAa,QAAQ,WAAW,OAAO;;;iBCDxD,SACvB,IAAI,SACJ,cACA,YAAA,MAAkB,SAAS;;;;;;;;;;;;;;;;;;;;;;iBCiBJ,WAAW,MAAM,SAAS,QAAQ,YAAY,QAAQ;;;iBCnBtD,YACvB,UAAU,kBACV,QAAQ,YACR,QAAQ,aACR,UAAU,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,YACjB;EAAY;;;;;;;;;iBCrCW,QAAQ,UAAU,OAAO,mBAAmB,QAAQ,IAAI;;;;;;UCJvD;;;;EAIxB;;;;;;;;;;;;;iBCoBuB,OAAO,kBAAkB,QAAQ,GAAG,UAAU,eAAe"}
|
package/dist/index.mjs
CHANGED
|
@@ -429,7 +429,12 @@ function $peek(fn) {
|
|
|
429
429
|
*/
|
|
430
430
|
function flushMountEffects() {
|
|
431
431
|
if (context.mountEffects.length === 0) return;
|
|
432
|
-
|
|
432
|
+
const activeRegion = context.activeRegion;
|
|
433
|
+
for (let effect of context.mountEffects) {
|
|
434
|
+
context.activeRegion = effect.region;
|
|
435
|
+
$run(() => runMountCallback(effect.fn), void 0, { isMountEffect: true });
|
|
436
|
+
}
|
|
437
|
+
context.activeRegion = activeRegion;
|
|
433
438
|
context.mountEffects.length = 0;
|
|
434
439
|
}
|
|
435
440
|
function runMountCallback(fn) {
|
|
@@ -901,6 +906,28 @@ function fillLayoutSlot(component, slot, parent, anchor, $props, $context) {
|
|
|
901
906
|
return region;
|
|
902
907
|
}
|
|
903
908
|
//#endregion
|
|
909
|
+
//#region src/render/firstInsideNode.ts
|
|
910
|
+
/**
|
|
911
|
+
* During hydration, `nodeAnchor` finds the first node inside a hydration
|
|
912
|
+
* block and removes the start/end marker comments. Generated code for
|
|
913
|
+
* `@html` needs that first node later (to adopt the server-rendered nodes
|
|
914
|
+
* as the region's bounds), but by then the markers are gone — so the only
|
|
915
|
+
* reliable way to recover it is to stash it here, keyed by the anchor node
|
|
916
|
+
* that `nodeAnchor` returns.
|
|
917
|
+
*/
|
|
918
|
+
const firstInsideNodes = /* @__PURE__ */ new WeakMap();
|
|
919
|
+
function setFirstInsideNode(anchor, node) {
|
|
920
|
+
firstInsideNodes.set(anchor, node);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Gets the first node that was inside the hydration block for the given
|
|
924
|
+
* anchor node, or `undefined` if the anchor wasn't hydrated through
|
|
925
|
+
* hydration markers.
|
|
926
|
+
*/
|
|
927
|
+
function firstInsideNode(anchor) {
|
|
928
|
+
return firstInsideNodes.get(anchor);
|
|
929
|
+
}
|
|
930
|
+
//#endregion
|
|
904
931
|
//#region src/render/getFragment.ts
|
|
905
932
|
function getFragment(document, array, index, html, ns) {
|
|
906
933
|
if (array[index] === void 0) if (ns === true) {
|
|
@@ -1116,6 +1143,7 @@ function nodeAnchor(node) {
|
|
|
1116
1143
|
if (context.hydrationNode === currentNode) context.hydrationNode = endNode;
|
|
1117
1144
|
const region = context.activeRegion;
|
|
1118
1145
|
if (region.startNode === null && firstInside !== null) region.startNode = firstInside;
|
|
1146
|
+
setFirstInsideNode(endNode, firstInside);
|
|
1119
1147
|
return endNode;
|
|
1120
1148
|
}
|
|
1121
1149
|
}
|
|
@@ -2630,7 +2658,10 @@ function $cache(fn) {
|
|
|
2630
2658
|
* @param fn The function to run, which may return a cleanup function
|
|
2631
2659
|
*/
|
|
2632
2660
|
function $onmount(fn) {
|
|
2633
|
-
context.mountEffects.push(
|
|
2661
|
+
context.mountEffects.push({
|
|
2662
|
+
region: context.activeRegion,
|
|
2663
|
+
fn
|
|
2664
|
+
});
|
|
2634
2665
|
}
|
|
2635
2666
|
//#endregion
|
|
2636
2667
|
//#region src/watch/$pending.ts
|
|
@@ -2789,7 +2820,7 @@ function $refresh(fn, options) {
|
|
|
2789
2820
|
* every event (only the last event in a burst is handled).
|
|
2790
2821
|
*/
|
|
2791
2822
|
function $stream(source, handler, options) {
|
|
2792
|
-
|
|
2823
|
+
const fn = () => {
|
|
2793
2824
|
let timer;
|
|
2794
2825
|
$run(() => {
|
|
2795
2826
|
const unsub = source((value) => {
|
|
@@ -2803,9 +2834,13 @@ function $stream(source, handler, options) {
|
|
|
2803
2834
|
clearTimeout(timer);
|
|
2804
2835
|
};
|
|
2805
2836
|
});
|
|
2837
|
+
};
|
|
2838
|
+
context.mountEffects.push({
|
|
2839
|
+
region: context.activeRegion,
|
|
2840
|
+
fn
|
|
2806
2841
|
});
|
|
2807
2842
|
}
|
|
2808
2843
|
//#endregion
|
|
2809
|
-
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
2844
|
+
export { $async, $batch, $bind, $cache, $onmount, $peek, $pending, $refresh, $run, $stream, $unwrap, $watch, clearLayoutSlot, fillLayoutSlot, fromElement, fromServer, fromWebSocket, hydrate, mount, addElement as t_add_element, addFragment as t_add_fragment, nodeAnchor as t_anchor, addAnimation as t_animate, applyProps as t_apply_props, setAttribute as t_attribute, nodeChild as t_child, buildClasses as t_class, setDynamicElement as t_dynamic, addEvent as t_event, firstInsideNode as t_first_inside, formatText as t_fmt, getFragment as t_fragment, getElementFragment as t_fragment_el, newListItem as t_list_item, nodeNext as t_next, popRegion as t_pop_region, pushRegion as t_push_region, newRegion as t_region, rerunRegionEffects as t_rerun_region_effects, restoreHydration as t_restore_hydration, nodeRoot as t_root, nodeRootElement as t_root_el, runAwait as t_run_await, runControlBranch as t_run_branch, runControl as t_run_control, runList as t_run_list, runTry as t_run_try, saveHydration as t_save_hydration, nodeSkip as t_skip, buildStyles as t_style, unmount };
|
|
2810
2845
|
|
|
2811
2846
|
//# sourceMappingURL=index.mjs.map
|