@vesk/runtime 0.2.36 → 0.2.38
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/hydrate.d.ts +22 -1
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.js +231 -42
- package/dist/reconcile.d.ts +1 -1
- package/dist/reconcile.d.ts.map +1 -1
- package/dist/reconcile.js +26 -2
- package/dist/router-components.d.ts.map +1 -1
- package/dist/router-components.js +47 -17
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +25 -3
- package/package.json +2 -2
package/dist/hydrate.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface ClaimByKeyOptions {
|
|
|
10
10
|
* twin rots.
|
|
11
11
|
*/
|
|
12
12
|
relocate?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Markerless structural walks: the number of unconsumed SSR slots before the
|
|
15
|
+
* region's next item (keyed regions carry no compile-time residue, so this
|
|
16
|
+
* is accepted for symmetry with the marker engine and stays 0 in practice).
|
|
17
|
+
*/
|
|
18
|
+
skipK?: number;
|
|
13
19
|
}
|
|
14
20
|
export interface HydrateWalker {
|
|
15
21
|
root: HTMLElement | null;
|
|
@@ -62,8 +68,23 @@ export interface HydrateWalker {
|
|
|
62
68
|
* owner's following claim. Falls back to the walker root's end when there is
|
|
63
69
|
* no live marker (region is the last fragment child). Returns false when no
|
|
64
70
|
* host is available (detached subtree).
|
|
71
|
+
*
|
|
72
|
+
* Markers are per-region, so `offset` (the caller's first-claim budget — SSR
|
|
73
|
+
* slots past the cursor) is ignored by marker-based engines and only carries
|
|
74
|
+
* meaning for the structural (markerless) walker, where the fence must sit
|
|
75
|
+
* exactly where the region's first claim will land (`idx + budget`).
|
|
76
|
+
*/
|
|
77
|
+
insertBeforeNextClaim?(node: Node, offset?: number): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Markerless value-thread offset (Phase 3.c): a caller deposits the residue
|
|
80
|
+
* that precedes a compiled component call so the callee's FIRST top-level
|
|
81
|
+
* claim skips it (its own `topPendingSkip` starts at zero and the shared
|
|
82
|
+
* walker cursor has not advanced over the caller's static leftovers). The
|
|
83
|
+
* deposit is transient — `takeSkipK` reads and consumes it once. Marker-based
|
|
84
|
+
* engines never receive the deposit and no-op.
|
|
65
85
|
*/
|
|
66
|
-
|
|
86
|
+
injectSkipK?(n: number): void;
|
|
87
|
+
takeSkipK?(): number;
|
|
67
88
|
}
|
|
68
89
|
interface HydrateIdleOptions {
|
|
69
90
|
chunkSize?: number;
|
package/dist/hydrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,OAAO,CAAC;CACZ;AAED,MAAM,WAAW,iBAAiB;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,OAAO,CAAC;CACZ;AAED,MAAM,WAAW,iBAAiB;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC;IAChB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC;;;;OAIG;IACH,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,IAAI,CAAC;IACxB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;IAC9C;;;;;;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ChC,iBAAiB,CAkCnB;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAK9D;AAED,MAAM,WAAW,2BAA4B,SAAQ,yBAAyB,EAAE,wBAAwB;CAAG;AAE3G,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,WAAW,EACtB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,EAC/G,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE,2BAAgC,GACvC,aAAa,CAoCf;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,WAAW,GAAG,MAAM,CAU7D;AAED,wBAAgB,cAAc,CAC7B,SAAS,EAAE,WAAW,EACtB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,EAC/G,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAIN"}
|
package/dist/hydrate.js
CHANGED
|
@@ -784,7 +784,7 @@ class WalkerEngine {
|
|
|
784
784
|
}
|
|
785
785
|
return null;
|
|
786
786
|
}
|
|
787
|
-
insertBeforeNextClaim(node) {
|
|
787
|
+
insertBeforeNextClaim(node, _offset = 0) {
|
|
788
788
|
// Find the next marker the positional cursor would consume: exactly the
|
|
789
789
|
// slot a region occupying this source position would have occupied in
|
|
790
790
|
// the SSR DOM.
|
|
@@ -805,53 +805,242 @@ class WalkerEngine {
|
|
|
805
805
|
return false;
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
+
injectSkipK(_n) {
|
|
809
|
+
// Marker-based walks are positioned by the marker stream; the offset
|
|
810
|
+
// value-thread is a markerless construct.
|
|
811
|
+
}
|
|
812
|
+
takeSkipK() {
|
|
813
|
+
return 0;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
// ---------------------------------------------------------------------------
|
|
817
|
+
// Structural (markerless) walker
|
|
818
|
+
//
|
|
819
|
+
// Marker-based hydration walks comment markers + their SSR elements. The
|
|
820
|
+
// markerless design walks PLAIN server HTML: a per-parent stack of element
|
|
821
|
+
// lists, claimed positionally by `skipK` (the number of source siblings the
|
|
822
|
+
// caller already consumed — static residues it retrieved from `__vsk_ssrEls`)
|
|
823
|
+
// and by tag. The compiler emits `nextElement(tag, skipK)` claims with the
|
|
824
|
+
// descriptor implicit in the tag; divergence follows §2.2 step 4: a tag
|
|
825
|
+
// mismatch consumes exactly one slot, reports, and hands back a fresh element
|
|
826
|
+
// that the caller mounts — the SSR node is never bound, never deleted.
|
|
827
|
+
//
|
|
828
|
+
// The same engine backs `createHydrateChildWalker`, so runtime components that
|
|
829
|
+
// claim offspring positionally (loading stubs, slot content) keep working with
|
|
830
|
+
// identical semantics.
|
|
831
|
+
// ---------------------------------------------------------------------------
|
|
832
|
+
class StructuralWalker {
|
|
833
|
+
root;
|
|
834
|
+
// Snapshot taken at construction, so fresh nodes mounted during the render
|
|
835
|
+
// are never re-claimed and claims stay aligned to the SSR source list.
|
|
836
|
+
els;
|
|
837
|
+
idx = 0;
|
|
838
|
+
adopted = new WeakSet();
|
|
839
|
+
constructor(root, els) {
|
|
840
|
+
this.root = root;
|
|
841
|
+
this.els = els || (root ? Array.prototype.slice.call(root.children) : []);
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Non-claimable framework preamble elements that the SSR renderer may emit
|
|
845
|
+
* as real DOM nodes ahead of a component's first claimable element (scoped
|
|
846
|
+
* `<style>` blocks, the loader title). The marker stream tracked them
|
|
847
|
+
* implicitly; the structural walker must step PAST them without consuming a
|
|
848
|
+
* claim slot, otherwise every subsequent positional claim shifts by one and
|
|
849
|
+
* the whole subtree falls back to fresh-node building.
|
|
850
|
+
*/
|
|
851
|
+
static skipTags = new Set(['style', 'script', 'template', 'title', 'meta', 'link', 'base']);
|
|
852
|
+
static isSkippable(el) {
|
|
853
|
+
return StructuralWalker.skipTags.has(el.tagName.toLowerCase());
|
|
854
|
+
}
|
|
855
|
+
advancePastSkippable(index) {
|
|
856
|
+
while (index < this.els.length && StructuralWalker.isSkippable(this.els[index]))
|
|
857
|
+
index++;
|
|
858
|
+
return index;
|
|
859
|
+
}
|
|
860
|
+
done() {
|
|
861
|
+
return this.idx >= this.els.length;
|
|
862
|
+
}
|
|
863
|
+
remainingCount() {
|
|
864
|
+
return this.els.length - this.idx;
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Insert `node` immediately before the `offset`-th unconsumed SSR element
|
|
868
|
+
* after the `skipK` cursor slot. Falls back to appending at the end of the
|
|
869
|
+
* root. Used by root-level dynamic regions whose branch had no SSR content:
|
|
870
|
+
* the fence anchors at the region's source position instead of the root's
|
|
871
|
+
* end. `offset` carries the region's first-claim budget (SSR slots past the
|
|
872
|
+
* cursor): a region that follows static residue must anchor after those
|
|
873
|
+
* residue slots, at exactly where its own first claim will land — otherwise
|
|
874
|
+
* fences wrap the WRONG slot and `__place` relocates the claimed content
|
|
875
|
+
* (e.g. a try/catch whose preceding h2/p/style residue pushes its slot to
|
|
876
|
+
* `idx + 3`).
|
|
877
|
+
*/
|
|
878
|
+
insertBeforeCursor(node, offset = 0) {
|
|
879
|
+
const host = this.root;
|
|
880
|
+
if (host === null || host === undefined)
|
|
881
|
+
return false;
|
|
882
|
+
try {
|
|
883
|
+
let n = this.advancePastSkippable(this.idx + (offset || 0));
|
|
884
|
+
while (n < this.els.length && this.els[n].parentNode !== host)
|
|
885
|
+
n++;
|
|
886
|
+
if (n < this.els.length)
|
|
887
|
+
host.insertBefore(node, this.els[n]);
|
|
888
|
+
else
|
|
889
|
+
host.appendChild(node);
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
catch {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
// Markerless value-thread offset (Phase 3.c): a transient residue deposit for
|
|
897
|
+
// a compiled component's first top-level claim. `injectSkipK` is emitted by
|
|
898
|
+
// the CALLER before invoking a self-claiming child (which cannot see the
|
|
899
|
+
// caller's compile-time skipK); `takeSkipK` is read exactly once at the
|
|
900
|
+
// callee's first claim and resets the deposit so later claims stay
|
|
901
|
+
// positional against the advancing cursor. Consumed synchronously on the
|
|
902
|
+
// same walker reference the call was made through.
|
|
903
|
+
inheritOffset = 0;
|
|
904
|
+
injectSkipK(n) {
|
|
905
|
+
this.inheritOffset = n;
|
|
906
|
+
}
|
|
907
|
+
takeSkipK() {
|
|
908
|
+
const n = this.inheritOffset;
|
|
909
|
+
this.inheritOffset = 0;
|
|
910
|
+
return n;
|
|
911
|
+
}
|
|
912
|
+
claimAt(tag, skipK, raw) {
|
|
913
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
914
|
+
// eslint-disable-next-line no-console
|
|
915
|
+
console.error('[hyd-dbg] claimAt', tag, 'skip=', skipK, 'idx=', this.idx, 'els=', this.els.length);
|
|
916
|
+
}
|
|
917
|
+
let target = this.advancePastSkippable(this.idx + (skipK || 0));
|
|
918
|
+
// The caller's residue accounting may overshoot (region estimates use
|
|
919
|
+
// max over branches); back off to the cursor rather than past the list.
|
|
920
|
+
if (target > this.els.length)
|
|
921
|
+
target = this.idx;
|
|
922
|
+
while (target < this.els.length) {
|
|
923
|
+
const el = this.els[target];
|
|
924
|
+
if (tag && el.tagName.toLowerCase() !== tag) {
|
|
925
|
+
// §2.2 step 4: descriptor failed. Consume exactly ONE slot and
|
|
926
|
+
// hand back a fresh element — the SSR node is never bound, never
|
|
927
|
+
// deleted. The caller detaches the fresh node when provably safe
|
|
928
|
+
// or leaves it inert for the sweep.
|
|
929
|
+
this.idx = this.advancePastSkippable(target + 1);
|
|
930
|
+
reportMiss('tag-mismatch', `descriptor wanted <${tag}> but the SSR slot holds <${el.tagName.toLowerCase()}>; consuming one slot and rendering fresh.`, false);
|
|
931
|
+
return document.createElement(tag || 'div');
|
|
932
|
+
}
|
|
933
|
+
if (this.adopted.has(el)) {
|
|
934
|
+
// Double-claim guard: a node already adopted (cross-position
|
|
935
|
+
// move) is a consumed slot; skip past it and keep walking.
|
|
936
|
+
target = this.advancePastSkippable(target + 1);
|
|
937
|
+
continue;
|
|
938
|
+
}
|
|
939
|
+
this.idx = this.advancePastSkippable(target + 1);
|
|
940
|
+
this.adopted.add(el);
|
|
941
|
+
if (!raw)
|
|
942
|
+
stripDirectTextNodes(el);
|
|
943
|
+
captureSsrElementChildren(el);
|
|
944
|
+
stampClaimed(el);
|
|
945
|
+
return el;
|
|
946
|
+
}
|
|
947
|
+
this.idx = this.els.length;
|
|
948
|
+
reportMiss('exhausted', `hydration claim missed <${tag || 'element'}>; the client rendered more or different content than SSR.`,
|
|
949
|
+
// Not loud: an exhausted walker is the normal post-hydration
|
|
950
|
+
// re-render shape (every further claim legitimately builds fresh
|
|
951
|
+
// nodes) — telemetry-only, mirroring the marker engine.
|
|
952
|
+
false);
|
|
953
|
+
return document.createElement(tag || 'div');
|
|
954
|
+
}
|
|
955
|
+
nextElement(tag, skipK = 0) {
|
|
956
|
+
return this.claimAt(tag, skipK, false);
|
|
957
|
+
}
|
|
958
|
+
claimOnly(tag, skipK = 0) {
|
|
959
|
+
return this.claimAt(tag, skipK, true);
|
|
960
|
+
}
|
|
961
|
+
subWalker(rootEl) {
|
|
962
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
963
|
+
// eslint-disable-next-line no-console
|
|
964
|
+
console.error('[hyd-dbg] subWalker over <' + (rootEl && rootEl.tagName) + '> kids=' + (rootEl ? rootEl.children.length : -1));
|
|
965
|
+
}
|
|
966
|
+
return new StructuralWalker(rootEl);
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Markerless region scope (Phase 3.e): keyed lists claim their items from a
|
|
970
|
+
* walker over their OWN container, not the top-level walker — the top
|
|
971
|
+
* walker's positional cursor would otherwise adopt the region container's
|
|
972
|
+
* siblings. The scoped walker snapshots the region's children and SHARES
|
|
973
|
+
* the adoption ledger, so sibling regions in the same container never
|
|
974
|
+
* double-claim (skip `adopted`) and top-level claims never re-adopt a node
|
|
975
|
+
* the region already claimed.
|
|
976
|
+
*/
|
|
977
|
+
scopeToRegion(rootEl) {
|
|
978
|
+
const w = new StructuralWalker(rootEl);
|
|
979
|
+
w.adopted = this.adopted;
|
|
980
|
+
return w;
|
|
981
|
+
}
|
|
982
|
+
retireDetached() {
|
|
983
|
+
// Structural walks hold no marker list; nothing to sweep.
|
|
984
|
+
}
|
|
985
|
+
takeMarkers(_comments) {
|
|
986
|
+
// Structural walks hold no markers; nothing to transfer.
|
|
987
|
+
}
|
|
988
|
+
claimByKey(_key, _options) {
|
|
989
|
+
// Keyed identity, markerless (Phase 3.c/d2). Keys never live on the DOM,
|
|
990
|
+
// so a keyed item adopts the next unconsumed SSR region slot POSITIONALLY
|
|
991
|
+
// (region order == client order on first paint; every map template has
|
|
992
|
+
// one per-item static structure, so a fingerprint cannot distinguish
|
|
993
|
+
// keys within a region — §2.5 tier 2). Identity is preserved for the
|
|
994
|
+
// order-matching case, the anchor/`marker` bookkeeping in reconcile.ts
|
|
995
|
+
// pins the adopted element (`c.el`), and a first-paint reorder is
|
|
996
|
+
// corrected on the first reactive update via the JS key map — the
|
|
997
|
+
// documented, non-silent contract. An exhausted region yields null so
|
|
998
|
+
// `reconcileHydrated` renders the surplus client items fresh at the
|
|
999
|
+
// region tail (never duplicated). `skipK` is accepted for symmetry with
|
|
1000
|
+
// the marker engine but keyed regions have no compile-time residue.
|
|
1001
|
+
const k = (_options && _options.skipK) || 0;
|
|
1002
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
1003
|
+
// eslint-disable-next-line no-console
|
|
1004
|
+
console.error('[hyd-dbg] claimByKey key=', _key, 'idx=', this.idx, 'els=', this.els.length, 'root=<', this.root ? this.root.tagName : '-', '>');
|
|
1005
|
+
}
|
|
1006
|
+
let target = this.advancePastSkippable(this.idx + k);
|
|
1007
|
+
if (target > this.els.length)
|
|
1008
|
+
target = this.idx;
|
|
1009
|
+
while (target < this.els.length) {
|
|
1010
|
+
const el = this.els[target];
|
|
1011
|
+
if (this.adopted.has(el)) {
|
|
1012
|
+
target = this.advancePastSkippable(target + 1);
|
|
1013
|
+
continue;
|
|
1014
|
+
}
|
|
1015
|
+
this.idx = this.advancePastSkippable(target + 1);
|
|
1016
|
+
this.adopted.add(el);
|
|
1017
|
+
stripDirectTextNodes(el);
|
|
1018
|
+
captureSsrElementChildren(el);
|
|
1019
|
+
stampClaimed(el);
|
|
1020
|
+
return { el };
|
|
1021
|
+
}
|
|
1022
|
+
this.idx = this.els.length;
|
|
1023
|
+
return null;
|
|
1024
|
+
}
|
|
1025
|
+
peekKey(_key) {
|
|
1026
|
+
return null;
|
|
1027
|
+
}
|
|
1028
|
+
insertBeforeNextClaim(node, offset = 0) {
|
|
1029
|
+
return this.insertBeforeCursor(node, offset);
|
|
1030
|
+
}
|
|
808
1031
|
}
|
|
809
1032
|
export function createHydrateWalker(container, markerList) {
|
|
810
1033
|
const markers = markerList || (container ? collectVskMarkers(container) : []);
|
|
1034
|
+
// Markerless automatic detection: a container whose SSR output carries NO
|
|
1035
|
+
// hydration comments is plain server HTML → walk it structurally. Explicit
|
|
1036
|
+
// marker lists (deferred-strategy slices) always stay marker-based.
|
|
1037
|
+
if (!markerList && container && markers.length === 0 && container.children.length > 0) {
|
|
1038
|
+
return new StructuralWalker(container);
|
|
1039
|
+
}
|
|
811
1040
|
return new WalkerEngine(container, markers);
|
|
812
1041
|
}
|
|
813
1042
|
export function createHydrateChildWalker(parentEl) {
|
|
814
|
-
|
|
815
|
-
const children = parentEl ? parentEl.children : [];
|
|
816
|
-
return {
|
|
817
|
-
root: parentEl,
|
|
818
|
-
done() {
|
|
819
|
-
return childIdx >= children.length;
|
|
820
|
-
},
|
|
821
|
-
nextElement(tag) {
|
|
822
|
-
while (childIdx < children.length) {
|
|
823
|
-
const child = children[childIdx++];
|
|
824
|
-
if (!tag || child.tagName.toLowerCase() === tag) {
|
|
825
|
-
stripDirectTextNodes(child);
|
|
826
|
-
captureSsrElementChildren(child);
|
|
827
|
-
stampClaimed(child);
|
|
828
|
-
return child;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
return document.createElement(tag || 'div');
|
|
832
|
-
},
|
|
833
|
-
claimOnly(tag) {
|
|
834
|
-
while (childIdx < children.length) {
|
|
835
|
-
const child = children[childIdx++];
|
|
836
|
-
if (!tag || child.tagName.toLowerCase() === tag) {
|
|
837
|
-
captureSsrElementChildren(child);
|
|
838
|
-
stampClaimed(child);
|
|
839
|
-
return child;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return document.createElement(tag || 'div');
|
|
843
|
-
},
|
|
844
|
-
subWalker(rootEl) {
|
|
845
|
-
return createHydrateChildWalker(rootEl);
|
|
846
|
-
},
|
|
847
|
-
retireDetached() {
|
|
848
|
-
// Child-walkers hold no marker list; nothing to sweep.
|
|
849
|
-
},
|
|
850
|
-
takeMarkers(_comments) {
|
|
851
|
-
// Child-walkers hold no marker list; nothing to transfer. The
|
|
852
|
-
// layout slot contract falls back to the shared walk.
|
|
853
|
-
},
|
|
854
|
-
};
|
|
1043
|
+
return new StructuralWalker(parentEl);
|
|
855
1044
|
}
|
|
856
1045
|
export function hydrate(container, componentFn, props) {
|
|
857
1046
|
const walker = createHydrateWalker(container);
|
package/dist/reconcile.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export declare function reconcile<T>(anchor: Node, endAnchor: Node, items: T[],
|
|
|
19
19
|
* client order (node identity preserved — no content swapping, no twins);
|
|
20
20
|
* only genuinely missing keys render fresh. RULE: NO DUPLICATION.
|
|
21
21
|
*/
|
|
22
|
-
export declare function reconcileHydrated<T>(anchor: Node, endAnchor: Node, items: T[], keyFn: (item: T, index: number) => string, createItem: (item: T, index: number, effs: Block[], root: Element | null) => void, walker: KeyedHydrateWalker, parent: Node): (newItems: T[]) => void;
|
|
22
|
+
export declare function reconcileHydrated<T>(anchor: Node, endAnchor: Node, items: T[], keyFn: (item: T, index: number) => string, createItem: (item: T, index: number, effs: Block[], root: Element | null) => void, walker: KeyedHydrateWalker, parent: Node, skipK?: number): (newItems: T[]) => void;
|
|
23
23
|
//# sourceMappingURL=reconcile.d.ts.map
|
package/dist/reconcile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../src/reconcile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAOnE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAChG,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,CAAC,EAC1B,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,EACzC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,EACjF,KAAK,CAAC,EAAE,YAA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,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,EACjF,KAAK,CAAC,EAAE,YAAY,GAClB,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,IAAI,CAkDzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAClC,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,EACzC,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,EACjF,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,IAAI,EACZ,KAAK,SAAI,GACP,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,IAAI,CA0DzB"}
|
package/dist/reconcile.js
CHANGED
|
@@ -58,18 +58,42 @@ export function reconcile(anchor, endAnchor, items, keyFn, createItem, claim) {
|
|
|
58
58
|
* client order (node identity preserved — no content swapping, no twins);
|
|
59
59
|
* only genuinely missing keys render fresh. RULE: NO DUPLICATION.
|
|
60
60
|
*/
|
|
61
|
-
export function reconcileHydrated(anchor, endAnchor, items, keyFn, createItem, walker, parent) {
|
|
61
|
+
export function reconcileHydrated(anchor, endAnchor, items, keyFn, createItem, walker, parent, skipK = 0) {
|
|
62
62
|
// Phase 1: adopt every item by key up front. Relocate moves out-of-order
|
|
63
63
|
// nodes to the cursor, so afterwards adopted elements stand contiguous in
|
|
64
64
|
// client order with node identity preserved. Anchors must be placed AFTER
|
|
65
65
|
// this (phase 2): placing them first would strand moved nodes outside the
|
|
66
66
|
// region and corrupt every later range operation.
|
|
67
|
+
//
|
|
68
|
+
// Markerless regions scope claim-by-key to their own container: the
|
|
69
|
+
// structural walker's positional cursor sits on the top-level container, so
|
|
70
|
+
// keyed items nested under a region element would otherwise steal that
|
|
71
|
+
// element's siblings. `scopeToRegion` also shares the adoption ledger, so a
|
|
72
|
+
// later sibling region (or a top-level claim) skips already-adopted nodes.
|
|
73
|
+
// A CONTAINERLESS keyed region (items are direct children of the walker's
|
|
74
|
+
// OWN root — e.g. a statement-mode keyed `for` beside static siblings in a
|
|
75
|
+
// page) must NOT re-scope: a fresh walker over the root from index 0 would
|
|
76
|
+
// positionally adopt the root's unrelated siblings (headings, nav) as the
|
|
77
|
+
// region's items. It claims from the live walker's cursor instead, where
|
|
78
|
+
// `skipK` (the compile-time static residue standing between the cursor and
|
|
79
|
+
// the region's first SSR item) aligns the first claim to the right slot.
|
|
80
|
+
let claimWalker = walker;
|
|
81
|
+
const layout = walker;
|
|
82
|
+
const scope = layout.scopeToRegion;
|
|
83
|
+
const parentIsElement = parent && parent.nodeType === 1;
|
|
84
|
+
if (scope && parentIsElement && layout.root !== parent) {
|
|
85
|
+
claimWalker = scope.call(walker, parent);
|
|
86
|
+
}
|
|
87
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.error('[hyd-dbg] reconcileHydrated items=', items.length, 'scoped=', claimWalker !== walker, 'parent=<', parent && parent.nodeName, '>', 'hasClaim=', !!claimWalker.claimByKey, 'walkerType=', walker.constructor && walker.constructor.name);
|
|
90
|
+
}
|
|
67
91
|
const claimed = new Map();
|
|
68
92
|
for (let i = 0; i < items.length; i++) {
|
|
69
93
|
const key = keyFn(items[i], i);
|
|
70
94
|
if (claimed.has(key))
|
|
71
95
|
continue;
|
|
72
|
-
const c =
|
|
96
|
+
const c = claimWalker.claimByKey ? claimWalker.claimByKey(key, { relocate: true, skipK: i === 0 ? skipK : 0 }) : null;
|
|
73
97
|
if (c)
|
|
74
98
|
claimed.set(key, c.el);
|
|
75
99
|
}
|
|
@@ -1 +1 @@
|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AC5D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC;IAC3D,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B,CAmEA"}
|
|
@@ -144,8 +144,17 @@ export function handleScroll(pathname, isReplace, scrollBehavior) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
const HEAD_MARKER = 'data-vesk-head';
|
|
147
|
+
function applyHeadAttrs(el, raw) {
|
|
148
|
+
for (const attrMatch of raw.matchAll(/([a-zA-Z0-9\-:]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) {
|
|
149
|
+
const name = attrMatch[1];
|
|
150
|
+
const value = attrMatch[3] ?? attrMatch[4] ?? '';
|
|
151
|
+
if (name.toLowerCase() === 'charset')
|
|
152
|
+
continue;
|
|
153
|
+
el.setAttribute(name, value);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
147
156
|
export function applyHead(headHtml) {
|
|
148
|
-
if (typeof document === 'undefined'
|
|
157
|
+
if (typeof document === 'undefined')
|
|
149
158
|
return;
|
|
150
159
|
const head = document.head;
|
|
151
160
|
if (!head)
|
|
@@ -153,32 +162,46 @@ export function applyHead(headHtml) {
|
|
|
153
162
|
for (const el of Array.from(head.querySelectorAll('[' + HEAD_MARKER + ']'))) {
|
|
154
163
|
el.remove();
|
|
155
164
|
}
|
|
165
|
+
if (!headHtml)
|
|
166
|
+
return;
|
|
156
167
|
const titleMatch = headHtml.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
|
|
157
168
|
if (titleMatch) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const t = document.createElement('title');
|
|
163
|
-
t.textContent = titleMatch[1];
|
|
164
|
-
head.appendChild(t);
|
|
165
|
-
}
|
|
169
|
+
const t = document.createElement('title');
|
|
170
|
+
t.textContent = titleMatch[1];
|
|
171
|
+
t.setAttribute(HEAD_MARKER, '');
|
|
172
|
+
head.appendChild(t);
|
|
166
173
|
}
|
|
167
174
|
for (const m of headHtml.matchAll(/<meta\b([^>]*)>/gi)) {
|
|
168
175
|
const meta = document.createElement('meta');
|
|
169
|
-
|
|
170
|
-
for (const attrMatch of raw.matchAll(/([a-zA-Z0-9\-:]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) {
|
|
171
|
-
const name = attrMatch[1];
|
|
172
|
-
const value = attrMatch[3] ?? attrMatch[4] ?? '';
|
|
173
|
-
if (name.toLowerCase() === 'charset')
|
|
174
|
-
continue;
|
|
175
|
-
meta.setAttribute(name, value);
|
|
176
|
-
}
|
|
176
|
+
applyHeadAttrs(meta, m[1] || '');
|
|
177
177
|
if (!meta.hasAttributes())
|
|
178
178
|
continue;
|
|
179
179
|
meta.setAttribute(HEAD_MARKER, '');
|
|
180
180
|
head.appendChild(meta);
|
|
181
181
|
}
|
|
182
|
+
for (const m of headHtml.matchAll(/<link\b([^>]*)>/gi)) {
|
|
183
|
+
const link = document.createElement('link');
|
|
184
|
+
applyHeadAttrs(link, m[1] || '');
|
|
185
|
+
if (!link.hasAttributes())
|
|
186
|
+
continue;
|
|
187
|
+
link.setAttribute(HEAD_MARKER, '');
|
|
188
|
+
head.appendChild(link);
|
|
189
|
+
}
|
|
190
|
+
const baseMatch = headHtml.match(/<base\b([^>]*)>/i);
|
|
191
|
+
if (baseMatch) {
|
|
192
|
+
const base = document.createElement('base');
|
|
193
|
+
applyHeadAttrs(base, baseMatch[1] || '');
|
|
194
|
+
if (base.hasAttributes()) {
|
|
195
|
+
base.setAttribute(HEAD_MARKER, '');
|
|
196
|
+
head.appendChild(base);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const m of headHtml.matchAll(/<style\b([^>]*)>([\s\S]*?)<\/style>/gi)) {
|
|
200
|
+
const style = document.createElement('style');
|
|
201
|
+
style.textContent = m[2];
|
|
202
|
+
style.setAttribute(HEAD_MARKER, '');
|
|
203
|
+
head.appendChild(style);
|
|
204
|
+
}
|
|
182
205
|
}
|
|
183
206
|
export function Outlet(props) {
|
|
184
207
|
const router = RouterCtx.get();
|
|
@@ -265,6 +288,13 @@ export function Link(props, registry, hydrate) {
|
|
|
265
288
|
// eats it, and cascades into fresh-node fallback. Keyed
|
|
266
289
|
// (`c:Link`) — no bare markers; the call-site marker carries the
|
|
267
290
|
// caller name while this one names the self-rendered anchor.
|
|
291
|
+
// Markerless SSR (the default) drops the self-prefix entirely:
|
|
292
|
+
// the compiler emits no call-site marker in that mode, so the
|
|
293
|
+
// anchor is claimed positionally.
|
|
294
|
+
const markerlessSsr = globalThis.__vsk_ssr_markerless === true;
|
|
295
|
+
if (markerlessSsr) {
|
|
296
|
+
return `<a ${attrs}>${childStr}</a>`;
|
|
297
|
+
}
|
|
268
298
|
return `<!--vsk:c:Link--><a ${attrs}>${childStr}</a>`;
|
|
269
299
|
}
|
|
270
300
|
const a = document.createElement('a');
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAMN,MAAM,E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CpD;AA0qCD,KAAK,OAAO,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;AAEpG,wBAAgB,YAAY,CAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC9C,OAAO,GAAE,aAAkB,GACzB,cAAc,CAsVhB;AAED,UAAU,iBAAkB,SAAQ,aAAa;IAChD,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,KAAK,IAAI,CAAC;CACrF;AAED,UAAU,kBAAmB,SAAQ,cAAc;IAClD,gBAAgB,EAAE,MAAM,CAAC;IACzB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,iBAAsB,GAAG,kBAAkB,CAwa5G;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEpF;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CA2CpE"}
|
package/dist/router.js
CHANGED
|
@@ -509,10 +509,10 @@ async function applyRouteData(router, match, data, container, render = renderMat
|
|
|
509
509
|
pageNode._dataPath = pathname;
|
|
510
510
|
pageNode._dataFetchedAt = Date.now();
|
|
511
511
|
}
|
|
512
|
-
if (data
|
|
513
|
-
applyHead(data.head);
|
|
512
|
+
if (data && 'head' in data) {
|
|
513
|
+
applyHead(data.head || '');
|
|
514
514
|
if (pageNode)
|
|
515
|
-
pageNode._head = data.head;
|
|
515
|
+
pageNode._head = data.head || '';
|
|
516
516
|
}
|
|
517
517
|
const hasRealProps = data.props
|
|
518
518
|
? Object.keys(data.props).some(k => k !== 'params')
|
|
@@ -1042,6 +1042,16 @@ async function hydrateInitial(router, match, container, strategy) {
|
|
|
1042
1042
|
return;
|
|
1043
1043
|
}
|
|
1044
1044
|
const layoutNodes = chain.filter(n => n.layout);
|
|
1045
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
1046
|
+
// eslint-disable-next-line no-console
|
|
1047
|
+
console.error('[hyd-dbg] hydrateInitial', {
|
|
1048
|
+
pageName: pageNode._pageName,
|
|
1049
|
+
pageType: typeof pageNode.page,
|
|
1050
|
+
layoutNames: layoutNodes.map(n => n._layoutName),
|
|
1051
|
+
hydratorKeys: router.__hydrators ? Object.keys(router.__hydrators) : null,
|
|
1052
|
+
containerKids: container.children.length,
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1045
1055
|
const hydrators = router.__hydrators;
|
|
1046
1056
|
if (!pageNode.page && !(hydrators && pageNode._pageName && hydrators[pageNode._pageName])) {
|
|
1047
1057
|
// The route's component chunk failed to load or compile. While
|
|
@@ -1131,6 +1141,10 @@ async function hydrateInitial(router, match, container, strategy) {
|
|
|
1131
1141
|
const childHydrator = renderLayoutChain(index + 1);
|
|
1132
1142
|
return (walker) => {
|
|
1133
1143
|
const layoutProps = { children: childHydrator, params: paramValues };
|
|
1144
|
+
if (globalThis.__vesk_hydrate_debug && index === 0) {
|
|
1145
|
+
// eslint-disable-next-line no-console
|
|
1146
|
+
console.error('[hyd-dbg] invoking outer layout', node._layoutName, typeof hydLayout, 'pageChild=', typeof childHydrator);
|
|
1147
|
+
}
|
|
1134
1148
|
const result = hydLayout(layoutProps, new Map(), walker);
|
|
1135
1149
|
storeLayoutInstance(router, node, layoutProps, result);
|
|
1136
1150
|
return result;
|
|
@@ -1154,6 +1168,14 @@ async function hydrateInitial(router, match, container, strategy) {
|
|
|
1154
1168
|
}
|
|
1155
1169
|
catch (error) {
|
|
1156
1170
|
setIsHydrating(false);
|
|
1171
|
+
if (globalThis.__vesk_hydrate_debug) {
|
|
1172
|
+
// eslint-disable-next-line no-console
|
|
1173
|
+
console.error('[hyd-dbg] hydrateInitial FAILED:', error);
|
|
1174
|
+
if (error instanceof Error && error.stack) {
|
|
1175
|
+
// eslint-disable-next-line no-console
|
|
1176
|
+
console.error('[hyd-dbg] hydrateInitial stack:', error.stack.split('\n').slice(0, 12).join('\n'));
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1157
1179
|
// Hydration failed — most often the page component throwing on the
|
|
1158
1180
|
// client after a clean SSR. Re-render through renderMatch so the error
|
|
1159
1181
|
// component replaces just the page slot and the layout/nav survives.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk runtime — reactivity, blocks, DOM operations, hydration",
|
|
6
6
|
"main": "./dist/index-client.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vesk/compiler": "^0.2.
|
|
54
|
+
"@vesk/compiler": "^0.2.38"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"typecheck": "tsc --noEmit",
|