@vesk/vesk-cli 0.2.94 → 0.2.95
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/cli.js +827 -288
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -608,6 +608,14 @@ var init_errors = __esm({
|
|
|
608
608
|
});
|
|
609
609
|
|
|
610
610
|
// ../compiler/src/ir.ts
|
|
611
|
+
function regionMarkerId(node) {
|
|
612
|
+
const ast = node.condition.ast;
|
|
613
|
+
if (ast && typeof ast.start === "number") return `s${ast.start}`;
|
|
614
|
+
const raw2 = node.condition.raw;
|
|
615
|
+
let hash = 5381;
|
|
616
|
+
for (let i = 0; i < raw2.length; i++) hash = (hash << 5) + hash + raw2.charCodeAt(i) | 0;
|
|
617
|
+
return `h${(hash >>> 0).toString(36)}`;
|
|
618
|
+
}
|
|
611
619
|
var Expression, IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentRef, ComponentCall, SlotNode, PropSlot, PropSlotRender, WhileLoop, SwitchCase, SwitchBlock, TryCatch, TrackDecl, RuntimeStatement, BreakSignal, ForLoop, ServerBlock, ClientBlock, HeadBlock;
|
|
612
620
|
var init_ir = __esm({
|
|
613
621
|
"../compiler/src/ir.ts"() {
|
|
@@ -2143,7 +2151,7 @@ function buildRequestInit(options) {
|
|
|
2143
2151
|
function resolveFetchUrl(url) {
|
|
2144
2152
|
if (/^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//")) return url;
|
|
2145
2153
|
const ctx2 = g().__vesk_request;
|
|
2146
|
-
const resolver = ctx2 && typeof ctx2.resolveUrl === "function" ? ctx2.resolveUrl : null;
|
|
2154
|
+
const resolver = ctx2 && typeof ctx2.resolveUrl === "function" ? ctx2.resolveUrl.bind(ctx2) : null;
|
|
2147
2155
|
if (resolver) return resolver(url);
|
|
2148
2156
|
const reqUrl = ctx2?.url;
|
|
2149
2157
|
let base = typeof reqUrl === "string" && /^https?:\/\//i.test(reqUrl) ? reqUrl : globalThis.__vesk_ssr_base_url || "";
|
|
@@ -2434,7 +2442,17 @@ function mutate(key, data2) {
|
|
|
2434
2442
|
}
|
|
2435
2443
|
function createResourceAccessor(handle2) {
|
|
2436
2444
|
const state = handle2.state;
|
|
2437
|
-
const
|
|
2445
|
+
const read = async () => {
|
|
2446
|
+
for (; ; ) {
|
|
2447
|
+
const s = get(state);
|
|
2448
|
+
if (!s.loading) {
|
|
2449
|
+
if (s.error) throw s.error;
|
|
2450
|
+
return s.data;
|
|
2451
|
+
}
|
|
2452
|
+
await handle2.settled;
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
const accessor = new ResourcePromise(read);
|
|
2438
2456
|
Object.defineProperty(accessor, "loading", {
|
|
2439
2457
|
get() {
|
|
2440
2458
|
return get(state).loading;
|
|
@@ -2451,19 +2469,6 @@ function createResourceAccessor(handle2) {
|
|
|
2451
2469
|
}
|
|
2452
2470
|
});
|
|
2453
2471
|
accessor._state = state;
|
|
2454
|
-
const toData = async () => {
|
|
2455
|
-
for (; ; ) {
|
|
2456
|
-
const s = get(state);
|
|
2457
|
-
if (!s.loading) {
|
|
2458
|
-
if (s.error) throw s.error;
|
|
2459
|
-
return s.data;
|
|
2460
|
-
}
|
|
2461
|
-
await handle2.settled;
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
accessor.then = (onFulfilled, onRejected) => toData().then(onFulfilled, onRejected);
|
|
2465
|
-
accessor.catch = (onRejected) => toData().catch(onRejected);
|
|
2466
|
-
accessor.finally = (onFinally) => toData().finally(onFinally);
|
|
2467
2472
|
accessor.refresh = () => revalidate(handle2);
|
|
2468
2473
|
accessor.abort = () => {
|
|
2469
2474
|
if (!isServer()) handle2.controller?.abort();
|
|
@@ -2546,7 +2551,7 @@ async function resolveSsrResources() {
|
|
|
2546
2551
|
delete g().__vsk_ssr_failures;
|
|
2547
2552
|
return data2;
|
|
2548
2553
|
}
|
|
2549
|
-
var HttpError, TimeoutError, g, isServer, ssrSink, DEFAULT_FAILURE_TTL;
|
|
2554
|
+
var HttpError, TimeoutError, g, isServer, ssrSink, DEFAULT_FAILURE_TTL, ResourcePromise;
|
|
2550
2555
|
var init_resource = __esm({
|
|
2551
2556
|
"../runtime/src/resource.ts"() {
|
|
2552
2557
|
"use strict";
|
|
@@ -2572,6 +2577,23 @@ var init_resource = __esm({
|
|
|
2572
2577
|
isServer = () => !!g().__vsk_ssr;
|
|
2573
2578
|
ssrSink = null;
|
|
2574
2579
|
DEFAULT_FAILURE_TTL = 1e4;
|
|
2580
|
+
ResourcePromise = class extends Promise {
|
|
2581
|
+
read;
|
|
2582
|
+
constructor(read) {
|
|
2583
|
+
super(() => {
|
|
2584
|
+
});
|
|
2585
|
+
this.read = read;
|
|
2586
|
+
}
|
|
2587
|
+
then(onfulfilled, onrejected) {
|
|
2588
|
+
return this.read().then(onfulfilled, onrejected);
|
|
2589
|
+
}
|
|
2590
|
+
catch(onrejected) {
|
|
2591
|
+
return this.read().catch(onrejected);
|
|
2592
|
+
}
|
|
2593
|
+
finally(onfinally) {
|
|
2594
|
+
return this.read().finally(onfinally);
|
|
2595
|
+
}
|
|
2596
|
+
};
|
|
2575
2597
|
useFetch.text = (url, options) => useFetch(async () => {
|
|
2576
2598
|
const res = await doFetch(resolveFetchUrl(url), buildRequestInit(options ?? {}));
|
|
2577
2599
|
if (!res.ok) throw new HttpError(res.status, res.statusText);
|
|
@@ -2963,6 +2985,47 @@ function adoptElementRaw(root3, marker, tag) {
|
|
|
2963
2985
|
recordAdopted(root3, el, tag || el.tagName.toLowerCase());
|
|
2964
2986
|
return el;
|
|
2965
2987
|
}
|
|
2988
|
+
function classTokens(value) {
|
|
2989
|
+
const out = [];
|
|
2990
|
+
let token = "";
|
|
2991
|
+
for (let i = 0; i < value.length; i++) {
|
|
2992
|
+
const ch = value[i];
|
|
2993
|
+
if (ch === " " || ch === "\n" || ch === " " || ch === "\r" || ch === "\f") {
|
|
2994
|
+
if (token) {
|
|
2995
|
+
out.push(token);
|
|
2996
|
+
token = "";
|
|
2997
|
+
}
|
|
2998
|
+
} else {
|
|
2999
|
+
token += ch;
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
if (token) out.push(token);
|
|
3003
|
+
return out;
|
|
3004
|
+
}
|
|
3005
|
+
function descriptorMatches(el, descriptor) {
|
|
3006
|
+
if (!descriptor || !descriptor.class) return true;
|
|
3007
|
+
const wanted = classTokens(descriptor.class);
|
|
3008
|
+
if (wanted.length === 0) return true;
|
|
3009
|
+
const actual = el.classList;
|
|
3010
|
+
if (actual) {
|
|
3011
|
+
for (const token of wanted) {
|
|
3012
|
+
if (!actual.contains(token)) return false;
|
|
3013
|
+
}
|
|
3014
|
+
return true;
|
|
3015
|
+
}
|
|
3016
|
+
const raw2 = el.getAttribute("class") ?? el.className ?? "";
|
|
3017
|
+
const present2 = classTokens(String(raw2));
|
|
3018
|
+
for (const token of wanted) {
|
|
3019
|
+
if (!present2.includes(token)) return false;
|
|
3020
|
+
}
|
|
3021
|
+
return true;
|
|
3022
|
+
}
|
|
3023
|
+
function structuralBranchMatches(el, branch2) {
|
|
3024
|
+
const actualTag = el.tagName.toLowerCase();
|
|
3025
|
+
if (branch2.tag && actualTag !== branch2.tag) return false;
|
|
3026
|
+
if (branch2.descriptor) return descriptorMatches(el, branch2.descriptor);
|
|
3027
|
+
return !!branch2.tag;
|
|
3028
|
+
}
|
|
2966
3029
|
function createHydrateWalker(container, markerList) {
|
|
2967
3030
|
const markers = markerList || (container ? collectVskMarkers(container) : []);
|
|
2968
3031
|
if (!markerList && container && markers.length === 0 && container.children.length > 0) {
|
|
@@ -3575,7 +3638,7 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
3575
3638
|
this.inheritOffset = 0;
|
|
3576
3639
|
return n;
|
|
3577
3640
|
}
|
|
3578
|
-
claimAt(tag, skipK, raw2) {
|
|
3641
|
+
claimAt(tag, skipK, raw2, descriptor) {
|
|
3579
3642
|
if (globalThis.__vesk_hydrate_debug) {
|
|
3580
3643
|
console.error("[hyd-dbg] claimAt", tag, "skip=", skipK, "idx=", this.idx, "els=", this.els.length);
|
|
3581
3644
|
}
|
|
@@ -3587,14 +3650,18 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
3587
3650
|
if (target > this.els.length) target = this.idx;
|
|
3588
3651
|
while (target < this.els.length) {
|
|
3589
3652
|
const el = this.els[target];
|
|
3590
|
-
|
|
3653
|
+
const actualTag = el.tagName.toLowerCase();
|
|
3654
|
+
const tagMismatch = !!tag && actualTag !== tag;
|
|
3655
|
+
const descriptorMismatch = !tagMismatch && !descriptorMatches(el, descriptor);
|
|
3656
|
+
if (tagMismatch || descriptorMismatch) {
|
|
3591
3657
|
this.idx = this.advancePastSkippable(target + 1);
|
|
3658
|
+
const expectedTag = tag || "div";
|
|
3592
3659
|
const ghost = {
|
|
3593
3660
|
state: "ghost",
|
|
3594
3661
|
el,
|
|
3595
3662
|
owner: this.root,
|
|
3596
|
-
expectedTag
|
|
3597
|
-
actualTag
|
|
3663
|
+
expectedTag,
|
|
3664
|
+
actualTag,
|
|
3598
3665
|
detached: false
|
|
3599
3666
|
};
|
|
3600
3667
|
recordClaim(this.root, ghost);
|
|
@@ -3605,20 +3672,18 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
3605
3672
|
} catch {
|
|
3606
3673
|
}
|
|
3607
3674
|
}
|
|
3608
|
-
const fresh2 = document.createElement(
|
|
3675
|
+
const fresh2 = document.createElement(expectedTag);
|
|
3609
3676
|
recordClaim(this.root, {
|
|
3610
3677
|
state: "fresh",
|
|
3611
3678
|
el: fresh2,
|
|
3612
3679
|
owner: this.root,
|
|
3613
|
-
expectedTag
|
|
3680
|
+
expectedTag,
|
|
3614
3681
|
actualTag: fresh2.tagName.toLowerCase(),
|
|
3615
3682
|
detached: false
|
|
3616
3683
|
});
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
false
|
|
3621
|
-
);
|
|
3684
|
+
const actualClass = el.getAttribute("class") || "";
|
|
3685
|
+
const detail = descriptorMismatch ? `descriptor wanted <${expectedTag} class="${descriptor?.class || ""}"> but the SSR slot holds <${actualTag} class="${actualClass}">; consumed one slot, detached the local ghost, and rendered fresh.` : `descriptor wanted <${tag}> but the SSR slot holds <${actualTag}>; consumed one slot, detached the local ghost, and rendered fresh.`;
|
|
3686
|
+
reportMiss(descriptorMismatch ? "descriptor-mismatch" : "tag-mismatch", detail, false);
|
|
3622
3687
|
return fresh2;
|
|
3623
3688
|
}
|
|
3624
3689
|
if (this.adopted.has(el)) {
|
|
@@ -3652,11 +3717,74 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
3652
3717
|
);
|
|
3653
3718
|
return fresh;
|
|
3654
3719
|
}
|
|
3655
|
-
nextElement(tag, skipK = 0) {
|
|
3656
|
-
return this.claimAt(tag, skipK, false);
|
|
3720
|
+
nextElement(tag, skipK = 0, descriptor) {
|
|
3721
|
+
return this.claimAt(tag, skipK, false, descriptor);
|
|
3657
3722
|
}
|
|
3658
|
-
claimOnly(tag, skipK = 0) {
|
|
3659
|
-
return this.claimAt(tag, skipK, true);
|
|
3723
|
+
claimOnly(tag, skipK = 0, descriptor) {
|
|
3724
|
+
return this.claimAt(tag, skipK, true, descriptor);
|
|
3725
|
+
}
|
|
3726
|
+
discardStructuralRegion(branches, selected, skipK = 0) {
|
|
3727
|
+
if (!branches || branches.length === 0) return false;
|
|
3728
|
+
let offset2 = skipK || 0;
|
|
3729
|
+
if (!offset2) offset2 = this.inheritOffset;
|
|
3730
|
+
let target = this.advancePastSkippable(this.idx + offset2);
|
|
3731
|
+
if (target > this.els.length) target = this.idx;
|
|
3732
|
+
target = this.advancePastSkippable(target);
|
|
3733
|
+
while (target < this.els.length) {
|
|
3734
|
+
const el = this.els[target];
|
|
3735
|
+
if (this.adopted.has(el)) {
|
|
3736
|
+
target = this.advancePastSkippable(target + 1);
|
|
3737
|
+
continue;
|
|
3738
|
+
}
|
|
3739
|
+
let matchCount = 0;
|
|
3740
|
+
let matchIdx = -1;
|
|
3741
|
+
for (let i = 0; i < branches.length; i++) {
|
|
3742
|
+
if (structuralBranchMatches(el, branches[i])) {
|
|
3743
|
+
matchCount++;
|
|
3744
|
+
matchIdx = i;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
if (matchCount !== 1 || matchIdx === selected) return false;
|
|
3748
|
+
const count = branches[matchIdx].count;
|
|
3749
|
+
if (!count || count < 1) return false;
|
|
3750
|
+
this.inheritOffset = 0;
|
|
3751
|
+
let p = target;
|
|
3752
|
+
let removed = 0;
|
|
3753
|
+
while (removed < count && p < this.els.length) {
|
|
3754
|
+
const candidate = this.els[p];
|
|
3755
|
+
if (this.adopted.has(candidate)) {
|
|
3756
|
+
p = this.advancePastSkippable(p + 1);
|
|
3757
|
+
continue;
|
|
3758
|
+
}
|
|
3759
|
+
const actualTag = candidate.tagName.toLowerCase();
|
|
3760
|
+
const ghost = {
|
|
3761
|
+
state: "ghost",
|
|
3762
|
+
el: candidate,
|
|
3763
|
+
owner: this.root,
|
|
3764
|
+
expectedTag: branches[matchIdx].tag || actualTag,
|
|
3765
|
+
actualTag,
|
|
3766
|
+
detached: false
|
|
3767
|
+
};
|
|
3768
|
+
recordClaim(this.root, ghost);
|
|
3769
|
+
if (this.root && candidate.parentNode === this.root) {
|
|
3770
|
+
try {
|
|
3771
|
+
candidate.remove();
|
|
3772
|
+
ghost.detached = true;
|
|
3773
|
+
} catch {
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
p = this.advancePastSkippable(p + 1);
|
|
3777
|
+
removed++;
|
|
3778
|
+
}
|
|
3779
|
+
this.idx = p;
|
|
3780
|
+
reportMiss(
|
|
3781
|
+
"descriptor-mismatch",
|
|
3782
|
+
`structural region reconciliation removed SSR branch ${matchIdx}; the client selected branch ${selected}.`,
|
|
3783
|
+
false
|
|
3784
|
+
);
|
|
3785
|
+
return true;
|
|
3786
|
+
}
|
|
3787
|
+
return false;
|
|
3660
3788
|
}
|
|
3661
3789
|
subWalker(rootEl) {
|
|
3662
3790
|
if (globalThis.__vesk_hydrate_debug) {
|
|
@@ -5510,6 +5638,19 @@ async function renderErrorPage(router, match, container, error, navToken) {
|
|
|
5510
5638
|
container.innerHTML = dom;
|
|
5511
5639
|
}
|
|
5512
5640
|
}
|
|
5641
|
+
function trackHydration(promise) {
|
|
5642
|
+
const g5 = globalThis;
|
|
5643
|
+
g5.__vesk_hydrated = false;
|
|
5644
|
+
promise.then(
|
|
5645
|
+
() => {
|
|
5646
|
+
g5.__vesk_hydrated = true;
|
|
5647
|
+
},
|
|
5648
|
+
() => {
|
|
5649
|
+
g5.__vesk_hydrated = true;
|
|
5650
|
+
}
|
|
5651
|
+
);
|
|
5652
|
+
return promise;
|
|
5653
|
+
}
|
|
5513
5654
|
async function hydrateInitial(router, match, container, strategy) {
|
|
5514
5655
|
const hydrationNavToken = router._navToken || 0;
|
|
5515
5656
|
const chain = match.matchChain;
|
|
@@ -5821,13 +5962,15 @@ function createRouter(routes, options = {}) {
|
|
|
5821
5962
|
const match = matchRoute(this.routeTree, url.pathname);
|
|
5822
5963
|
if (match) {
|
|
5823
5964
|
match.pathname = url.pathname;
|
|
5824
|
-
hydrateInitial(this, match, container, hydrateStrategy);
|
|
5965
|
+
trackHydration(hydrateInitial(this, match, container, hydrateStrategy));
|
|
5825
5966
|
this._currentMatch = match;
|
|
5826
5967
|
} else {
|
|
5827
5968
|
this.navigate(path, { replace: true });
|
|
5969
|
+
globalThis.__vesk_hydrated = true;
|
|
5828
5970
|
}
|
|
5829
5971
|
} else {
|
|
5830
5972
|
this.navigate(path, { replace: true });
|
|
5973
|
+
globalThis.__vesk_hydrated = true;
|
|
5831
5974
|
}
|
|
5832
5975
|
return this;
|
|
5833
5976
|
},
|
|
@@ -5861,7 +6004,9 @@ function createRouter(routes, options = {}) {
|
|
|
5861
6004
|
const updateUrl = () => {
|
|
5862
6005
|
const fullPath = url.pathname + url.search;
|
|
5863
6006
|
const target = mode ? fullPath.startsWith("/") ? "#" + fullPath : "#" + fullPath : fullPath;
|
|
5864
|
-
|
|
6007
|
+
const liveFull = window.location.pathname + window.location.search + window.location.hash;
|
|
6008
|
+
if (!opts.replace && target === liveFull) {
|
|
6009
|
+
} else if (!opts.replace) {
|
|
5865
6010
|
window.history.pushState({ path: url.pathname }, "", target);
|
|
5866
6011
|
} else {
|
|
5867
6012
|
window.history.replaceState({ path: url.pathname }, "", target);
|
|
@@ -6056,6 +6201,41 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
6056
6201
|
const renderFn = options.render || renderMatch;
|
|
6057
6202
|
const hydrateStrategy = options.hydrate || "full";
|
|
6058
6203
|
const hashMode = options.hash === true;
|
|
6204
|
+
const serverMiddlewareCache = /* @__PURE__ */ new Map();
|
|
6205
|
+
let serverMiddlewareDisabled = false;
|
|
6206
|
+
const runServerMiddleware = async (ctx2, next) => {
|
|
6207
|
+
if (options.serverMiddleware !== true || typeof window === "undefined" || serverMiddlewareDisabled) return next();
|
|
6208
|
+
const path = String(ctx2.url || "/");
|
|
6209
|
+
const cached = serverMiddlewareCache.get(path);
|
|
6210
|
+
if (cached && Date.now() - cached.at < 2500) {
|
|
6211
|
+
if (cached.body && typeof cached.body.redirect === "string" && cached.body.redirect) {
|
|
6212
|
+
return { redirect: cached.body.redirect };
|
|
6213
|
+
}
|
|
6214
|
+
if (cached.body && typeof cached.body.rewrite === "string" && cached.body.rewrite) return next(cached.body.rewrite);
|
|
6215
|
+
return next();
|
|
6216
|
+
}
|
|
6217
|
+
const endpoint = globalThis.__veskServerMiddlewareEndpoint ?? "/_vesk/middleware";
|
|
6218
|
+
try {
|
|
6219
|
+
const res = await fetch(`${endpoint}?path=${encodeURIComponent(path)}`, {
|
|
6220
|
+
credentials: "include",
|
|
6221
|
+
headers: { Accept: "application/json" },
|
|
6222
|
+
cache: "no-store"
|
|
6223
|
+
});
|
|
6224
|
+
if (res.status === 404) {
|
|
6225
|
+
serverMiddlewareDisabled = true;
|
|
6226
|
+
return next();
|
|
6227
|
+
}
|
|
6228
|
+
const body = await res.json().catch(() => null);
|
|
6229
|
+
serverMiddlewareCache.set(path, { at: Date.now(), body });
|
|
6230
|
+
if (body && typeof body.redirect === "string" && body.redirect) {
|
|
6231
|
+
return { redirect: body.redirect };
|
|
6232
|
+
}
|
|
6233
|
+
if (body && typeof body.rewrite === "string" && body.rewrite) return next(body.rewrite);
|
|
6234
|
+
return next();
|
|
6235
|
+
} catch {
|
|
6236
|
+
return next();
|
|
6237
|
+
}
|
|
6238
|
+
};
|
|
6059
6239
|
const router = {
|
|
6060
6240
|
_hydrateStrategy: hydrateStrategy,
|
|
6061
6241
|
routeTree,
|
|
@@ -6168,13 +6348,15 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
6168
6348
|
const match = matchRoute(routeTree, path);
|
|
6169
6349
|
if (match) {
|
|
6170
6350
|
match.pathname = path;
|
|
6171
|
-
hydrateInitial(router, match, container, hydrateStrategy);
|
|
6351
|
+
trackHydration(hydrateInitial(router, match, container, hydrateStrategy));
|
|
6172
6352
|
router._currentMatch = match;
|
|
6173
6353
|
} else {
|
|
6174
6354
|
router.navigate(path, { replace: true });
|
|
6355
|
+
globalThis.__vesk_hydrated = true;
|
|
6175
6356
|
}
|
|
6176
6357
|
} else {
|
|
6177
6358
|
router.navigate(path, { replace: true });
|
|
6359
|
+
globalThis.__vesk_hydrated = true;
|
|
6178
6360
|
}
|
|
6179
6361
|
return router;
|
|
6180
6362
|
},
|
|
@@ -6228,12 +6410,17 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
6228
6410
|
navDebug("navigate", url.pathname, "token=" + router._navToken, "pendingChunks", hasPendingChunks(match.matchChain));
|
|
6229
6411
|
const navToken = router._navToken;
|
|
6230
6412
|
loadingStart();
|
|
6231
|
-
const middlewareFns =
|
|
6413
|
+
const middlewareFns = [
|
|
6414
|
+
...options.serverMiddleware === true ? [runServerMiddleware] : [],
|
|
6415
|
+
...Array.isArray(middleware) ? middleware : middleware ? [middleware] : []
|
|
6416
|
+
];
|
|
6232
6417
|
let firstRenderFailed = false;
|
|
6233
6418
|
const updateUrl = () => {
|
|
6234
6419
|
const fullUrl = url.pathname + url.search;
|
|
6235
6420
|
const target = mode ? fullUrl.startsWith("/") ? "#" + fullUrl : "#" + fullUrl : fullUrl;
|
|
6236
|
-
|
|
6421
|
+
const liveFull = window.location.pathname + window.location.search + window.location.hash;
|
|
6422
|
+
if (!opts.replace && target === liveFull) {
|
|
6423
|
+
} else if (!opts.replace) {
|
|
6237
6424
|
window.history.pushState({ path: fullUrl }, "", target);
|
|
6238
6425
|
} else {
|
|
6239
6426
|
window.history.replaceState({ path: fullUrl }, "", target);
|
|
@@ -32393,6 +32580,17 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
|
|
|
32393
32580
|
}
|
|
32394
32581
|
return null;
|
|
32395
32582
|
}
|
|
32583
|
+
function staticClassDescriptor(node) {
|
|
32584
|
+
const hasDynamicClass = node.children.some(
|
|
32585
|
+
(child) => child instanceof DynamicBinding && child.kind === "attribute" && child.target === "class"
|
|
32586
|
+
);
|
|
32587
|
+
if (hasDynamicClass) return null;
|
|
32588
|
+
const attr = node.attributes.find((a) => a.name === "class");
|
|
32589
|
+
if (!attr) return null;
|
|
32590
|
+
const value = attr.value.trim();
|
|
32591
|
+
if (!value) return null;
|
|
32592
|
+
return JSON.stringify({ class: value });
|
|
32593
|
+
}
|
|
32396
32594
|
function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
|
|
32397
32595
|
const el = ctx2.n();
|
|
32398
32596
|
if (ctx2.hydrate) {
|
|
@@ -32403,7 +32601,11 @@ function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
|
|
|
32403
32601
|
ctx2.rootClaim = false;
|
|
32404
32602
|
const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr(regionBudget, skipK) : skipK;
|
|
32405
32603
|
const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
|
|
32406
|
-
const
|
|
32604
|
+
const wantsDescriptor = ctx2.markerless && ctx2.descriptorClaim;
|
|
32605
|
+
ctx2.descriptorClaim = false;
|
|
32606
|
+
const descriptor = wantsDescriptor && !rootClaim ? staticClassDescriptor(node) : null;
|
|
32607
|
+
const descriptorArg = descriptor ? `, ${descriptor}` : "";
|
|
32608
|
+
const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg}${descriptorArg})`;
|
|
32407
32609
|
ctx2.push(`const ${el} = ${claimedExpr};`);
|
|
32408
32610
|
if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
|
|
32409
32611
|
} else {
|
|
@@ -32787,6 +32989,7 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
|
|
|
32787
32989
|
}
|
|
32788
32990
|
const callArgs = () => plainTarget ? `reactiveProps({ ${propsEntries.join(", ")} })` : `{ ${propsEntries.join(", ")} }`;
|
|
32789
32991
|
if (ctx2.hydrate) {
|
|
32992
|
+
ctx2.descriptorClaim = false;
|
|
32790
32993
|
const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `${ctx2.hydrateRegistry}[${JSON.stringify(node.componentName)}]`);
|
|
32791
32994
|
if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
|
|
32792
32995
|
ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
|
|
@@ -33009,13 +33212,14 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33009
33212
|
const hyd = ctx2.hydrate;
|
|
33010
33213
|
const parent = parentVar || "$root";
|
|
33011
33214
|
const budget = hyd ? regionBudgetVar(ctx2, skipK, regionBudget) : null;
|
|
33215
|
+
const rid = regionMarkerId(node);
|
|
33012
33216
|
const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
|
|
33013
33217
|
if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
|
|
33014
33218
|
const chain = [];
|
|
33015
33219
|
let cur = node;
|
|
33016
33220
|
let finalElse = null;
|
|
33017
33221
|
while (cur) {
|
|
33018
|
-
chain.push({ cond: transformTracked(cur.condition, tracked2), nodes: cur.consequentNodes });
|
|
33222
|
+
chain.push({ cond: transformTracked(cur.condition, tracked2), nodes: cur.consequentNodes, id: regionMarkerId(cur) });
|
|
33019
33223
|
if (cur.alternateNodes.length === 1 && isOpaque(cur.alternateNodes[0])) {
|
|
33020
33224
|
cur = cur.alternateNodes[0];
|
|
33021
33225
|
} else {
|
|
@@ -33039,6 +33243,8 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33039
33243
|
ctx2.push(`const ${rn} = ${fnOpen2}`);
|
|
33040
33244
|
const cl = ctx2.n();
|
|
33041
33245
|
ctx2.push(indent2(`const ${cl} = [];`));
|
|
33246
|
+
const savedDescriptor = ctx2.descriptorClaim;
|
|
33247
|
+
if (hyd && ctx2.markerless) ctx2.descriptorClaim = true;
|
|
33042
33248
|
for (const n of chain[i].nodes) {
|
|
33043
33249
|
const savedClaim = ctx2.claimStatic;
|
|
33044
33250
|
if (hyd) ctx2.claimStatic = true;
|
|
@@ -33046,6 +33252,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33046
33252
|
ctx2.claimStatic = savedClaim;
|
|
33047
33253
|
if (v) ctx2.push(indent2(`${cl}.push(${v});`));
|
|
33048
33254
|
}
|
|
33255
|
+
ctx2.descriptorClaim = savedDescriptor;
|
|
33049
33256
|
ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl}, ${parent});`));
|
|
33050
33257
|
ctx2.push(`};`);
|
|
33051
33258
|
}
|
|
@@ -33055,6 +33262,8 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33055
33262
|
ctx2.push(`const ${finalRender} = ${fnOpen2}`);
|
|
33056
33263
|
const cl2 = ctx2.n();
|
|
33057
33264
|
ctx2.push(indent2(`const ${cl2} = [];`));
|
|
33265
|
+
const savedDescriptor = ctx2.descriptorClaim;
|
|
33266
|
+
if (hyd && ctx2.markerless) ctx2.descriptorClaim = true;
|
|
33058
33267
|
for (const n of finalElse) {
|
|
33059
33268
|
const savedClaim = ctx2.claimStatic;
|
|
33060
33269
|
if (hyd) ctx2.claimStatic = true;
|
|
@@ -33062,23 +33271,34 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33062
33271
|
ctx2.claimStatic = savedClaim;
|
|
33063
33272
|
if (v) ctx2.push(indent2(`${cl2}.push(${v});`));
|
|
33064
33273
|
}
|
|
33274
|
+
ctx2.descriptorClaim = savedDescriptor;
|
|
33065
33275
|
ctx2.push(indent2(`__place(${anchor2}, ${endAnchor2}, ${cl2}, ${parent});`));
|
|
33066
33276
|
ctx2.push(`};`);
|
|
33067
33277
|
}
|
|
33068
|
-
let init = `if (${chain[0].cond}) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
33069
|
-
for (let i = 1; i < chain.length; i++) init += ` else if (${chain[i].cond}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
33070
|
-
if (finalRender) init += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
33071
|
-
ctx2.push(init);
|
|
33072
33278
|
let branchInitFallback = finalRender ? `${chain.length}` : "-1";
|
|
33073
33279
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
33074
33280
|
branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
|
|
33075
33281
|
}
|
|
33076
33282
|
const branchInit = `(${branchInitFallback})`;
|
|
33283
|
+
const branchSnapshot = ctx2.n();
|
|
33284
|
+
ctx2.push(`const ${branchSnapshot} = ${branchInit};`);
|
|
33285
|
+
if (!ctx2.markerless) {
|
|
33286
|
+
for (let i = 0; i < chain.length; i++) {
|
|
33287
|
+
ctx2.push(`if (__hydrate) __reconcileRegion(${parent}, '${chain[i].id}', ${branchSnapshot} === ${i} ? 0 : 1, ${ctx2.walker});`);
|
|
33288
|
+
}
|
|
33289
|
+
} else {
|
|
33290
|
+
const chainBranches = chain.map((c) => c.nodes);
|
|
33291
|
+
if (finalElse) chainBranches.push(finalElse);
|
|
33292
|
+
emitStructuralRegionDiscard(ctx2, chainBranches, branchSnapshot, budget);
|
|
33293
|
+
}
|
|
33294
|
+
let init = `if (${branchSnapshot} === 0) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
33295
|
+
for (let i = 1; i < chain.length; i++) init += ` else if (${branchSnapshot} === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
33296
|
+
if (finalRender) init += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
33297
|
+
ctx2.push(init);
|
|
33077
33298
|
let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
33078
33299
|
for (let i = 1; i < chain.length; i++) effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
33079
33300
|
if (finalRender) effInner += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
33080
33301
|
const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
|
|
33081
|
-
if (__first) { __first = false; __iv = ${branchInit}; return; }
|
|
33082
33302
|
const __new = ${branchInit};
|
|
33083
33303
|
if (__new !== __iv) {
|
|
33084
33304
|
for (const e of ${effectsVar2}) destroy_block(e);
|
|
@@ -33090,14 +33310,12 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33090
33310
|
}, true);`;
|
|
33091
33311
|
if (effTarget) {
|
|
33092
33312
|
ctx2.push(`${effTarget}.push((() => {
|
|
33093
|
-
let __iv = ${
|
|
33094
|
-
let __first = true;
|
|
33313
|
+
let __iv = ${branchSnapshot};
|
|
33095
33314
|
return ${effBody}
|
|
33096
33315
|
})());`);
|
|
33097
33316
|
} else {
|
|
33098
33317
|
ctx2.effects.push(`{
|
|
33099
|
-
let __iv = ${
|
|
33100
|
-
let __first = true;
|
|
33318
|
+
let __iv = ${branchSnapshot};
|
|
33101
33319
|
${effBody}
|
|
33102
33320
|
}`);
|
|
33103
33321
|
}
|
|
@@ -33121,6 +33339,8 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33121
33339
|
const conFrag = ctx2.n();
|
|
33122
33340
|
if (!hyd) ctx2.push(indent2(`const ${conFrag} = document.createDocumentFragment();`));
|
|
33123
33341
|
if (hyd) ctx2.push(indent2(`const __cl = [];`));
|
|
33342
|
+
const savedConDescriptor = ctx2.descriptorClaim;
|
|
33343
|
+
if (hyd && ctx2.markerless) ctx2.descriptorClaim = true;
|
|
33124
33344
|
for (const n of node.consequentNodes) {
|
|
33125
33345
|
const savedClaim = ctx2.claimStatic;
|
|
33126
33346
|
if (hyd) ctx2.claimStatic = true;
|
|
@@ -33131,6 +33351,7 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33131
33351
|
else ctx2.push(indent2(`${conFrag}.appendChild(${v});`));
|
|
33132
33352
|
}
|
|
33133
33353
|
}
|
|
33354
|
+
ctx2.descriptorClaim = savedConDescriptor;
|
|
33134
33355
|
if (hyd) ctx2.push(indent2(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
33135
33356
|
else ctx2.push(indent2(`__p.insertBefore(${conFrag}, ${endAnchor});`));
|
|
33136
33357
|
ctx2.push(`};`);
|
|
@@ -33142,6 +33363,8 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33142
33363
|
const altFrag = ctx2.n();
|
|
33143
33364
|
if (!hyd) ctx2.push(indent2(`const ${altFrag} = document.createDocumentFragment();`));
|
|
33144
33365
|
if (hyd) ctx2.push(indent2(`const __cl = [];`));
|
|
33366
|
+
const savedAltDescriptor = ctx2.descriptorClaim;
|
|
33367
|
+
if (hyd && ctx2.markerless) ctx2.descriptorClaim = true;
|
|
33145
33368
|
for (const n of node.alternateNodes) {
|
|
33146
33369
|
const savedAltClaim = ctx2.claimStatic;
|
|
33147
33370
|
if (hyd) ctx2.claimStatic = true;
|
|
@@ -33152,15 +33375,19 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33152
33375
|
else ctx2.push(indent2(`${altFrag}.appendChild(${v});`));
|
|
33153
33376
|
}
|
|
33154
33377
|
}
|
|
33378
|
+
ctx2.descriptorClaim = savedAltDescriptor;
|
|
33155
33379
|
if (hyd) ctx2.push(indent2(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
33156
33380
|
else ctx2.push(indent2(`__p.insertBefore(${altFrag}, ${endAnchor});`));
|
|
33157
33381
|
ctx2.push(`};`);
|
|
33158
33382
|
}
|
|
33159
33383
|
if (!hyd) ctx2.push(`${parent}.appendChild(${endAnchor});`);
|
|
33160
|
-
|
|
33384
|
+
const condSnapshot = ctx2.n();
|
|
33385
|
+
ctx2.push(`const ${condSnapshot} = ${condExpr};`);
|
|
33386
|
+
if (hyd && !ctx2.markerless) ctx2.push(`if (__hydrate) __reconcileRegion(${parent}, '${rid}', ${condSnapshot} ? 0 : 1, ${ctx2.walker});`);
|
|
33387
|
+
if (hyd && ctx2.markerless) emitStructuralRegionDiscard(ctx2, [node.consequentNodes, node.alternateNodes], hasElse ? `(${condSnapshot} ? 0 : 1)` : `(${condSnapshot} ? 0 : -1)`, budget);
|
|
33388
|
+
ctx2.push(`if (${condSnapshot}) { ${asyncKw}${conRenderName}(); }` + (hasElse ? ` else { ${asyncKw}${altRenderName}(); }` : ""));
|
|
33161
33389
|
const renderBranch = `if (__nv) { ${asyncKw}${conRenderName}(); }` + (hasElse ? ` else { ${asyncKw}${altRenderName}(); }` : "");
|
|
33162
33390
|
const effectBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
|
|
33163
|
-
if (__first) { __first = false; __iv = ${condExpr}; return; }
|
|
33164
33391
|
const __nv = ${condExpr};
|
|
33165
33392
|
if (__nv !== __iv) {
|
|
33166
33393
|
for (const e of ${effectsVar}) destroy_block(e);
|
|
@@ -33173,14 +33400,12 @@ function emitOpaque(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regio
|
|
|
33173
33400
|
if (!isReactiveExpression(node.condition, tracked2)) return null;
|
|
33174
33401
|
if (effTarget) {
|
|
33175
33402
|
ctx2.push(`${effTarget}.push((() => {
|
|
33176
|
-
let __iv = ${
|
|
33177
|
-
let __first = true;
|
|
33403
|
+
let __iv = ${condSnapshot};
|
|
33178
33404
|
return ${effectBody}
|
|
33179
33405
|
})());`);
|
|
33180
33406
|
} else {
|
|
33181
33407
|
ctx2.effects.push(`{
|
|
33182
|
-
let __iv = ${
|
|
33183
|
-
let __first = true;
|
|
33408
|
+
let __iv = ${condSnapshot};
|
|
33184
33409
|
${effectBody}
|
|
33185
33410
|
}`);
|
|
33186
33411
|
}
|
|
@@ -33561,25 +33786,23 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
33561
33786
|
let emptyRenderName = null;
|
|
33562
33787
|
if (node.alternateNodes.length > 0) {
|
|
33563
33788
|
emptyRenderName = ctx2.n();
|
|
33564
|
-
const
|
|
33789
|
+
const emptyClaims = ctx2.hydrate;
|
|
33790
|
+
const emptySig = !emptyClaims ? ctx2.isAsyncScope ? "async () => {" : "() => {" : ctx2.isAsyncScope ? "async (__cl) => {" : "(__cl) => {";
|
|
33565
33791
|
ctx2.push(`const ${emptyRenderName} = ${emptySig}`);
|
|
33566
33792
|
ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
|
|
33567
33793
|
const frag = ctx2.n();
|
|
33568
|
-
if (!
|
|
33794
|
+
if (!emptyClaims) ctx2.push(indent2(`const ${frag} = document.createDocumentFragment();`));
|
|
33569
33795
|
const savedClaim = ctx2.claimStatic;
|
|
33570
|
-
const savedHydrate = ctx2.hydrate;
|
|
33571
|
-
if (hydKeyed) ctx2.hydrate = false;
|
|
33572
33796
|
for (const n of node.alternateNodes) {
|
|
33573
33797
|
ctx2.claimStatic = true;
|
|
33574
|
-
const v = emitNode(ctx2, n, tracked2, effectsVar,
|
|
33798
|
+
const v = emitNode(ctx2, n, tracked2, effectsVar, emptyClaims ? void 0 : frag, "__components", 0, budget || void 0);
|
|
33575
33799
|
if (v) {
|
|
33576
|
-
if (
|
|
33800
|
+
if (emptyClaims) ctx2.push(indent2(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
|
|
33577
33801
|
else ctx2.push(indent2(`${frag}.appendChild(${v});`));
|
|
33578
33802
|
}
|
|
33579
33803
|
}
|
|
33580
33804
|
ctx2.claimStatic = savedClaim;
|
|
33581
|
-
ctx2.
|
|
33582
|
-
if (!hyd) ctx2.push(indent2(`if (${frag}.childNodes.length > 0) __p.insertBefore(${frag}, ${endAnchor});`));
|
|
33805
|
+
if (!emptyClaims) ctx2.push(indent2(`if (${frag}.childNodes.length > 0) __p.insertBefore(${frag}, ${endAnchor});`));
|
|
33583
33806
|
ctx2.push(`};`);
|
|
33584
33807
|
}
|
|
33585
33808
|
if (!hyd && !hydKeyed) ctx2.push(`${parent}.appendChild(${endAnchor});`);
|
|
@@ -33599,8 +33822,11 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
33599
33822
|
}
|
|
33600
33823
|
if (emptyRenderName) {
|
|
33601
33824
|
const isEmptyVar = ctx2.n();
|
|
33825
|
+
const collectVar = hydKeyed ? ctx2.n() : null;
|
|
33602
33826
|
ctx2.push(`let ${isEmptyVar} = !${hasItems}();`);
|
|
33603
|
-
ctx2.push(`
|
|
33827
|
+
if (collectVar) ctx2.push(`const ${collectVar} = [];`);
|
|
33828
|
+
ctx2.push(`if (!${isEmptyVar}) { ${initList}(); } else { ${aw}${emptyRenderName}(${collectVar || ""}); }`);
|
|
33829
|
+
if (collectVar) ctx2.push(`__place(${anchor}, ${endAnchor}, ${collectVar}, ${parent});`);
|
|
33604
33830
|
if (!reactiveSource) return null;
|
|
33605
33831
|
pushEffect(`let __first = true;`, `effect(${effOpen}
|
|
33606
33832
|
const __new = ${hasItems}();
|
|
@@ -33671,7 +33897,7 @@ ${renderAllItems(" ", null)}
|
|
|
33671
33897
|
__cleanup(${anchor}, ${endAnchor});
|
|
33672
33898
|
if (__new) {
|
|
33673
33899
|
${renderAllItems(" ", null)}
|
|
33674
|
-
} else { ${aw}${emptyRenderName}(
|
|
33900
|
+
} else { ${aw}${emptyRenderName}(); }
|
|
33675
33901
|
}, true)`);
|
|
33676
33902
|
} else {
|
|
33677
33903
|
const collectVar = hyd ? ctx2.n() : null;
|
|
@@ -33762,6 +33988,7 @@ function generateComponent(comp, importedNames = /* @__PURE__ */ new Set(), hydr
|
|
|
33762
33988
|
}
|
|
33763
33989
|
}
|
|
33764
33990
|
}
|
|
33991
|
+
if (ctx2.hydrate && ctx2.markerless) ctx2.descriptorClaim = true;
|
|
33765
33992
|
for (const node of comp.body) {
|
|
33766
33993
|
if (node instanceof TrackDecl) {
|
|
33767
33994
|
if (deferredTrackDecls.has(node)) emitNode(ctx2, node, tracked2, null);
|
|
@@ -33842,6 +34069,33 @@ function buildComponentMap(irRoot, hydrate = false, alloc, markerless = true) {
|
|
|
33842
34069
|
const code = generateComponent(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
|
|
33843
34070
|
mapLines.push(`${registry}[${JSON.stringify(comp.name)}] = ${code};`);
|
|
33844
34071
|
}
|
|
34072
|
+
if (hydrate && !markerless) {
|
|
34073
|
+
mapLines.push(`function __reconcileRegion(parent, id, branch, walker) {`);
|
|
34074
|
+
mapLines.push(` if (!parent) return;`);
|
|
34075
|
+
mapLines.push(` let start = null;`);
|
|
34076
|
+
mapLines.push(` let end = null;`);
|
|
34077
|
+
mapLines.push(` for (let n = parent.firstChild; n; n = n.nextSibling) {`);
|
|
34078
|
+
mapLines.push(` if (n.nodeType !== 8) continue;`);
|
|
34079
|
+
mapLines.push(` const text = n.textContent || '';`);
|
|
34080
|
+
mapLines.push(` if (text === 'vesk-r:' + id + ':0' || text === 'vesk-r:' + id + ':1') start = n;`);
|
|
34081
|
+
mapLines.push(` else if (text === 'vesk-r-end:' + id) end = n;`);
|
|
34082
|
+
mapLines.push(` if (start && end) break;`);
|
|
34083
|
+
mapLines.push(` }`);
|
|
34084
|
+
mapLines.push(` if (!start || !end) return;`);
|
|
34085
|
+
mapLines.push(` const ssrBranch = (start.textContent || '').slice(-2) === ':1' ? 1 : 0;`);
|
|
34086
|
+
mapLines.push(` if (ssrBranch !== branch) {`);
|
|
34087
|
+
mapLines.push(` let n = start.nextSibling;`);
|
|
34088
|
+
mapLines.push(` while (n && n !== end) {`);
|
|
34089
|
+
mapLines.push(` const next = n.nextSibling;`);
|
|
34090
|
+
mapLines.push(` n.remove();`);
|
|
34091
|
+
mapLines.push(` n = next;`);
|
|
34092
|
+
mapLines.push(` }`);
|
|
34093
|
+
mapLines.push(` if (walker && walker.retireDetached) walker.retireDetached();`);
|
|
34094
|
+
mapLines.push(` }`);
|
|
34095
|
+
mapLines.push(` start.remove();`);
|
|
34096
|
+
mapLines.push(` end.remove();`);
|
|
34097
|
+
mapLines.push(`}`);
|
|
34098
|
+
}
|
|
33845
34099
|
mapLines.push(`function __cleanup(start, end) {`);
|
|
33846
34100
|
mapLines.push(` let n = start.nextSibling;`);
|
|
33847
34101
|
mapLines.push(` while (n && n !== end) {`);
|
|
@@ -33900,6 +34154,43 @@ function ssrResidueEstimate(node) {
|
|
|
33900
34154
|
}
|
|
33901
34155
|
return 0;
|
|
33902
34156
|
}
|
|
34157
|
+
function firstBranchRoot(nodes) {
|
|
34158
|
+
for (const n of nodes) {
|
|
34159
|
+
if (n instanceof StaticNode) return { tag: n.tag, descriptor: staticClassDescriptor(n) };
|
|
34160
|
+
if (n instanceof ComponentCall || n instanceof ComponentRef) return null;
|
|
34161
|
+
if (n instanceof OpaqueDynamicRegion) return null;
|
|
34162
|
+
if (n instanceof MapRegion || n instanceof ForLoop || n instanceof WhileLoop) {
|
|
34163
|
+
const child = firstBranchRoot(n.bodyTemplate);
|
|
34164
|
+
if (child) return child;
|
|
34165
|
+
}
|
|
34166
|
+
if (n instanceof SwitchBlock) {
|
|
34167
|
+
for (const c of n.cases) {
|
|
34168
|
+
const child = firstBranchRoot(c.body);
|
|
34169
|
+
if (child) return child;
|
|
34170
|
+
}
|
|
34171
|
+
}
|
|
34172
|
+
if (n instanceof TryCatch) {
|
|
34173
|
+
const child = firstBranchRoot(n.bodyTemplate) || firstBranchRoot(n.catchBody);
|
|
34174
|
+
if (child) return child;
|
|
34175
|
+
}
|
|
34176
|
+
}
|
|
34177
|
+
return null;
|
|
34178
|
+
}
|
|
34179
|
+
function structuralRegionMetadata(branches) {
|
|
34180
|
+
const parts = branches.map((nodes) => {
|
|
34181
|
+
const first = firstBranchRoot(nodes);
|
|
34182
|
+
const tag = first ? JSON.stringify(first.tag) : "undefined";
|
|
34183
|
+
const descriptor = first && first.descriptor ? first.descriptor : "null";
|
|
34184
|
+
return `{ tag: ${tag}, descriptor: ${descriptor}, count: ${ssrResidueEstimate(nodes)} }`;
|
|
34185
|
+
});
|
|
34186
|
+
return `[${parts.join(", ")}]`;
|
|
34187
|
+
}
|
|
34188
|
+
function emitStructuralRegionDiscard(ctx2, branches, selectedExpr, budget) {
|
|
34189
|
+
if (!ctx2.hydrate || !ctx2.markerless) return;
|
|
34190
|
+
const offset2 = budget ? `, ${budget}` : "";
|
|
34191
|
+
const consume = budget ? ` ${budget} = 0;` : "";
|
|
34192
|
+
ctx2.push(`if (${ctx2.walker} && typeof ${ctx2.walker}.discardStructuralRegion === 'function' && ${ctx2.walker}.discardStructuralRegion(${structuralRegionMetadata(branches)}, ${selectedExpr}${offset2})) {${consume}}`);
|
|
34193
|
+
}
|
|
33903
34194
|
function isStaticIR(body) {
|
|
33904
34195
|
for (const node of body) {
|
|
33905
34196
|
if (node instanceof StaticNode) {
|
|
@@ -34230,6 +34521,10 @@ var init_client_codegen = __esm({
|
|
|
34230
34521
|
markerless = true;
|
|
34231
34522
|
inTryBody = false;
|
|
34232
34523
|
claimStatic = false;
|
|
34524
|
+
// Markerless only: the next real claim carries a compiler-generated static
|
|
34525
|
+
// class descriptor so a same-tag but structurally different SSR slot is
|
|
34526
|
+
// substituted instead of adopted (e.g. an empty-state <div> vs a list <div>).
|
|
34527
|
+
descriptorClaim = false;
|
|
34233
34528
|
// While set, the next StaticNode claimed in hydrate mode uses `__root` (the
|
|
34234
34529
|
// item element already claimed by key) instead of walking for a new element.
|
|
34235
34530
|
rootClaim = false;
|
|
@@ -35081,15 +35376,19 @@ function dynamicBindingToJS(node, tracked2) {
|
|
|
35081
35376
|
function opaqueRegionToJS(node, isAsync = false, tracked2) {
|
|
35082
35377
|
const lines = [];
|
|
35083
35378
|
const cond = exprJSX(node.condition, tracked2);
|
|
35379
|
+
const rid = regionMarkerId(node);
|
|
35380
|
+
const mark = __vskHydrate && !__vskMarkerless;
|
|
35084
35381
|
lines.push(`if (${cond}) {`);
|
|
35382
|
+
if (mark) lines.push(indent(`__out.push('<!--vesk-r:${rid}:0-->');`));
|
|
35085
35383
|
setVskForceClaim(true);
|
|
35086
35384
|
for (const n of node.consequentNodes) {
|
|
35087
35385
|
const code = irNodeToJS(n, null, isAsync, tracked2);
|
|
35088
35386
|
if (code) lines.push(indent(code));
|
|
35089
35387
|
}
|
|
35090
35388
|
setVskForceClaim(false);
|
|
35389
|
+
lines.push(`} else {`);
|
|
35390
|
+
if (mark) lines.push(indent(`__out.push('<!--vesk-r:${rid}:1-->');`));
|
|
35091
35391
|
if (node.alternateNodes.length > 0) {
|
|
35092
|
-
lines.push(`} else {`);
|
|
35093
35392
|
setVskForceClaim(true);
|
|
35094
35393
|
for (const n of node.alternateNodes) {
|
|
35095
35394
|
const code = irNodeToJS(n, null, isAsync, tracked2);
|
|
@@ -35098,6 +35397,7 @@ function opaqueRegionToJS(node, isAsync = false, tracked2) {
|
|
|
35098
35397
|
setVskForceClaim(false);
|
|
35099
35398
|
}
|
|
35100
35399
|
lines.push(`}`);
|
|
35400
|
+
if (mark) lines.push(`__out.push('<!--vesk-r-end:${rid}-->');`);
|
|
35101
35401
|
return lines.join("\n");
|
|
35102
35402
|
}
|
|
35103
35403
|
function mapRegionToJS(node, isAsync = false, tracked2) {
|
|
@@ -49833,20 +50133,16 @@ interface VeskLocals<T extends object> {
|
|
|
49833
50133
|
all(): T;
|
|
49834
50134
|
}
|
|
49835
50135
|
declare function createLocals<T extends object = Record<string, unknown>>(): VeskLocals<T>;
|
|
49836
|
-
// useFetch returns a
|
|
49837
|
-
//
|
|
49838
|
-
//
|
|
49839
|
-
//
|
|
49840
|
-
interface VeskResource<T> {
|
|
50136
|
+
// useFetch returns a real Promise carrying resource state. In async components
|
|
50137
|
+
// you must \`await\` it before reading/iterating the payload; passing
|
|
50138
|
+
// \`into: <tracked cell>\` writes the payload into the cell and makes awaiting
|
|
50139
|
+
// unnecessary (the return value can be ignored).
|
|
50140
|
+
interface VeskResource<T> extends Promise<T> {
|
|
49841
50141
|
loading: boolean;
|
|
49842
50142
|
error: unknown;
|
|
49843
50143
|
data: T | undefined;
|
|
49844
50144
|
refresh(): void;
|
|
49845
50145
|
abort(): void;
|
|
49846
|
-
then<TResult1 = T, TResult2 = never>(
|
|
49847
|
-
onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
49848
|
-
onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
49849
|
-
): PromiseLike<TResult1 | TResult2>;
|
|
49850
50146
|
}
|
|
49851
50147
|
interface VeskUseFetchOptions<T> {
|
|
49852
50148
|
/** Cache/SSR key \u2014 defaults to the URL string. */
|
|
@@ -51613,7 +51909,10 @@ function __getNotFoundCompiled() { if (!_notFoundCompiled) _notFoundCompiled = $
|
|
|
51613
51909
|
" }"
|
|
51614
51910
|
];
|
|
51615
51911
|
const dataNavWrap = (body) => [
|
|
51616
|
-
|
|
51912
|
+
// Awaited for the same reason as the main render below: the caller restores
|
|
51913
|
+
// `__vesk_request` in a finally, and that must happen only after the async
|
|
51914
|
+
// data render (which reads params through useParams) has fully resolved.
|
|
51915
|
+
" return await withSsrStore(async () => {",
|
|
51617
51916
|
...body.map((l) => l ? " " + l : l),
|
|
51618
51917
|
" });"
|
|
51619
51918
|
];
|
|
@@ -51641,7 +51940,13 @@ function __getNotFoundCompiled() { if (!_notFoundCompiled) _notFoundCompiled = $
|
|
|
51641
51940
|
...dataNavCleanup
|
|
51642
51941
|
]),
|
|
51643
51942
|
" }",
|
|
51644
|
-
|
|
51943
|
+
// Awaited so the surrounding try/finally keeps `__vesk_request` installed
|
|
51944
|
+
// for the whole async render. Without the await the finally restores the
|
|
51945
|
+
// previous context synchronously, while the async page body is still
|
|
51946
|
+
// suspended on its SSR fetches; every render pass after the first `await`
|
|
51947
|
+
// then reads an empty params object and `useParams()`-derived keys/URLs
|
|
51948
|
+
// collapse (e.g. a verify page rendering its not-found branch).
|
|
51949
|
+
" return await __renderHtml(params, url.href);"
|
|
51645
51950
|
].join("\n");
|
|
51646
51951
|
} else {
|
|
51647
51952
|
dataCode = [
|
|
@@ -51662,7 +51967,13 @@ function __getNotFoundCompiled() { if (!_notFoundCompiled) _notFoundCompiled = $
|
|
|
51662
51967
|
...dataNavCleanup
|
|
51663
51968
|
]),
|
|
51664
51969
|
" }",
|
|
51665
|
-
|
|
51970
|
+
// Awaited so the surrounding try/finally keeps `__vesk_request` installed
|
|
51971
|
+
// for the whole async render. Without the await the finally restores the
|
|
51972
|
+
// previous context synchronously, while the async page body is still
|
|
51973
|
+
// suspended on its SSR fetches; every render pass after the first `await`
|
|
51974
|
+
// then reads an empty params object and `useParams()`-derived keys/URLs
|
|
51975
|
+
// collapse (e.g. a verify page rendering its not-found branch).
|
|
51976
|
+
" return await __renderHtml(params, url.href);"
|
|
51666
51977
|
].join("\n");
|
|
51667
51978
|
}
|
|
51668
51979
|
const hasMiddleware = !!middlewareCode;
|
|
@@ -52157,8 +52468,18 @@ function extractMiddlewareParts(src2) {
|
|
|
52157
52468
|
decls.push(src2.slice(stmt.declaration.start, stmt.declaration.end).trim());
|
|
52158
52469
|
}
|
|
52159
52470
|
}
|
|
52471
|
+
const imports = [];
|
|
52472
|
+
for (const stmt of ast.body) {
|
|
52473
|
+
if (stmt.type !== "ImportDeclaration") continue;
|
|
52474
|
+
if (stmt.importKind === "type") continue;
|
|
52475
|
+
const source = stmt.source?.value;
|
|
52476
|
+
if (typeof source !== "string") continue;
|
|
52477
|
+
if (source.startsWith(".") || source.startsWith("/")) continue;
|
|
52478
|
+
const line = src2.slice(stmt.start, stmt.end).trim();
|
|
52479
|
+
if (line && !imports.includes(line)) imports.push(line);
|
|
52480
|
+
}
|
|
52160
52481
|
const bodyWithDecls = decls.length > 0 ? decls.join("\n") + "\n" + body.trim() : body.trim();
|
|
52161
|
-
return { params, body: bodyWithDecls };
|
|
52482
|
+
return { params, body: bodyWithDecls, imports };
|
|
52162
52483
|
} catch {
|
|
52163
52484
|
return fallbackExtractMiddleware(src2);
|
|
52164
52485
|
}
|
|
@@ -52199,7 +52520,7 @@ function fallbackExtractMiddleware(src2) {
|
|
|
52199
52520
|
m++;
|
|
52200
52521
|
}
|
|
52201
52522
|
const body = src2.slice(b + 1, m - 1);
|
|
52202
|
-
return { params, body: body.trim() };
|
|
52523
|
+
return { params, body: body.trim(), imports: [] };
|
|
52203
52524
|
}
|
|
52204
52525
|
return null;
|
|
52205
52526
|
}
|
|
@@ -52221,16 +52542,18 @@ ${parts.body}
|
|
|
52221
52542
|
function extractMiddlewareBody(src2) {
|
|
52222
52543
|
const parts = extractMiddlewareParts(src2);
|
|
52223
52544
|
if (!parts) return null;
|
|
52224
|
-
return { params: parts.params, body: parts.body };
|
|
52545
|
+
return { params: parts.params, body: parts.body, imports: parts.imports };
|
|
52225
52546
|
}
|
|
52226
52547
|
function compileMiddleware(mwChain, _appDir) {
|
|
52227
52548
|
if (mwChain.length === 0) return null;
|
|
52228
52549
|
const parts = [];
|
|
52550
|
+
const imports = [];
|
|
52229
52551
|
for (let i = 0; i < mwChain.length; i++) {
|
|
52230
52552
|
const { sourcePath: sourcePath2 } = mwChain[i];
|
|
52231
52553
|
const src2 = readFileSync10(sourcePath2, "utf-8");
|
|
52232
52554
|
const extracted = extractMiddlewareBody(src2);
|
|
52233
52555
|
if (!extracted) continue;
|
|
52556
|
+
for (const line of extracted.imports) if (!imports.includes(line)) imports.push(line);
|
|
52234
52557
|
parts.push(`async function mw_${i}(${extracted.params}) {
|
|
52235
52558
|
${extracted.body}
|
|
52236
52559
|
}`);
|
|
@@ -52239,6 +52562,8 @@ ${extracted.body}
|
|
|
52239
52562
|
const code = [
|
|
52240
52563
|
"// Auto-generated middleware chain \u2014 do not edit",
|
|
52241
52564
|
"",
|
|
52565
|
+
...imports,
|
|
52566
|
+
...imports.length ? [""] : [],
|
|
52242
52567
|
parts.join("\n\n"),
|
|
52243
52568
|
"",
|
|
52244
52569
|
`const chain = [${parts.map((_, i) => `mw_${i}`).join(", ")}];`,
|
|
@@ -52308,9 +52633,11 @@ ${extracted.body}
|
|
|
52308
52633
|
function compileMiddlewareCode(mwSourceTexts) {
|
|
52309
52634
|
if (!mwSourceTexts || mwSourceTexts.length === 0) return null;
|
|
52310
52635
|
const parts = [];
|
|
52636
|
+
const imports = [];
|
|
52311
52637
|
for (let i = 0; i < mwSourceTexts.length; i++) {
|
|
52312
52638
|
const extracted = extractMiddlewareBody(mwSourceTexts[i]);
|
|
52313
52639
|
if (!extracted) continue;
|
|
52640
|
+
for (const line of extracted.imports) if (!imports.includes(line)) imports.push(line);
|
|
52314
52641
|
parts.push(`async function mw_${i}(${extracted.params}) {
|
|
52315
52642
|
${extracted.body}
|
|
52316
52643
|
}`);
|
|
@@ -52319,6 +52646,8 @@ ${extracted.body}
|
|
|
52319
52646
|
const code = [
|
|
52320
52647
|
"// \u2500\u2500 Middleware chain (inline) \u2500\u2500",
|
|
52321
52648
|
"",
|
|
52649
|
+
...imports,
|
|
52650
|
+
...imports.length ? [""] : [],
|
|
52322
52651
|
parts.join("\n\n"),
|
|
52323
52652
|
"",
|
|
52324
52653
|
`const __mwChain = [${parts.map((_, i) => `mw_${i}`).join(", ")}];`,
|
|
@@ -52695,12 +53024,21 @@ function fileUnchanged(filePath, cached) {
|
|
|
52695
53024
|
return false;
|
|
52696
53025
|
}
|
|
52697
53026
|
}
|
|
52698
|
-
function
|
|
53027
|
+
function hasServerMiddleware(nodes) {
|
|
53028
|
+
for (const node of nodes) {
|
|
53029
|
+
if (node.hasMiddleware) return true;
|
|
53030
|
+
if (node.children?.length && hasServerMiddleware(node.children)) return true;
|
|
53031
|
+
}
|
|
53032
|
+
return false;
|
|
53033
|
+
}
|
|
53034
|
+
function buildRouterOpts(options, serverMiddleware) {
|
|
52699
53035
|
const ttl = options?.routeDataCache;
|
|
53036
|
+
const opts = [];
|
|
53037
|
+
if (serverMiddleware) opts.push("serverMiddleware: true");
|
|
52700
53038
|
if (typeof ttl === "number" && ttl > 0) {
|
|
52701
|
-
|
|
53039
|
+
opts.push(`routeDataCache: ${ttl}`);
|
|
52702
53040
|
}
|
|
52703
|
-
return "";
|
|
53041
|
+
return opts.length ? `, { ${opts.join(", ")} }` : "";
|
|
52704
53042
|
}
|
|
52705
53043
|
function findRuntimeSrc2(appDir) {
|
|
52706
53044
|
const monorepoRoot = resolve10(__dirname3, "..", "..", "..");
|
|
@@ -52748,7 +53086,7 @@ function isAnyImport(node) {
|
|
|
52748
53086
|
return node.type === "ImportDeclaration";
|
|
52749
53087
|
}
|
|
52750
53088
|
function isRuntimePreamble(node) {
|
|
52751
|
-
if (node.type === "FunctionDeclaration" && (node.id?.name === "__cleanup" || node.id?.name === "__place")) {
|
|
53089
|
+
if (node.type === "FunctionDeclaration" && (node.id?.name === "__cleanup" || node.id?.name === "__place" || node.id?.name === "__reconcileRegion")) {
|
|
52752
53090
|
return true;
|
|
52753
53091
|
}
|
|
52754
53092
|
if (node.type === "VariableDeclaration") {
|
|
@@ -53909,12 +54247,13 @@ async function buildMainBundle(routeTree, runtimeDir, codeSplit, mono, hmr, impo
|
|
|
53909
54247
|
` : runtimeCode + "\n";
|
|
53910
54248
|
const cleanupFn = "function __cleanup(start, end) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n}\n";
|
|
53911
54249
|
const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n // Client-surplus nodes (SSR rendered fewer items than the client data)\n // are freshly claimed and still detached \u2014 move them into the region in\n // client order before `end`, instead of stranding them off-parent.\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);\n }\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
|
|
54250
|
+
const reconcileRegionFn = "function __reconcileRegion(parent, id, branch, walker) {\n if (!parent) return;\n let start = null;\n let end = null;\n for (let n = parent.firstChild; n; n = n.nextSibling) {\n if (n.nodeType !== 8) continue;\n const text = n.textContent || '';\n if (text === 'vesk-r:' + id + ':0' || text === 'vesk-r:' + id + ':1') start = n;\n else if (text === 'vesk-r-end:' + id) end = n;\n if (start && end) break;\n }\n if (!start || !end) return;\n const ssrBranch = (start.textContent || '').slice(-2) === ':1' ? 1 : 0;\n if (ssrBranch !== branch) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n if (walker && walker.retireDetached) walker.retireDetached();\n }\n start.remove();\n end.remove();\n}\n";
|
|
53912
54251
|
const updateComponentsFn = "function __updateComponents(nodes) {\n for (const n of nodes) {\n if (n._pageName && __components[n._pageName]) n.page = __components[n._pageName];\n if (n._layoutName && __components[n._layoutName]) n.layout = __components[n._layoutName];\n if (n._errorName && __components[n._errorName]) n.error = __components[n._errorName];\n if (n._notFoundName && __components[n._notFoundName]) n.notFound = __components[n._notFoundName];\n if (n._offlineName && __components[n._offlineName]) n.offline = __components[n._offlineName];\n if (n._networkName && __components[n._networkName]) n.network = __components[n._networkName];\n if (n.children) __updateComponents(n.children);\n }\n}\n";
|
|
53913
54252
|
const routeTreeJson = JSON.stringify(routeTree);
|
|
53914
54253
|
if (codeSplit) {
|
|
53915
54254
|
const resolveNamesFn = "function __resolveNames(nodes) {\n for (const n of nodes) {\n if (n.chunk) n._chunk = n.chunk;\n if (n.chunkError) n._chunkError = n.chunkError;\n if (typeof n.page === 'string') n._pageName = n.page;\n if (typeof n.layout === 'string') n._layoutName = n.layout;\n if (typeof n.error === 'string') n._errorName = n.error;\n if (typeof n.notFound === 'string') n._notFoundName = n.notFound;\n if (typeof n.offline === 'string') n._offlineName = n.offline;\n if (typeof n.network === 'string') n._networkName = n.network;\n if (n.children) __resolveNames(n.children);\n }\n}\n";
|
|
53916
54255
|
const pendCode = "const __pendChunks = [];\nconst __currentPath = typeof window !== 'undefined' ? window.location.pathname : '/';\nif (typeof matchRoute === 'function') {\n const __currentMatch = matchRoute(__routeTree, __currentPath);\n if (__currentMatch) {\n for (const n of __currentMatch.matchChain) {\n if (n._chunk && !__pendChunks.includes(n._chunk)) __pendChunks.push(n._chunk);\n }\n }\n}\n";
|
|
53917
|
-
const routerOpts2 = buildRouterOpts({ routeDataCache });
|
|
54256
|
+
const routerOpts2 = buildRouterOpts({ routeDataCache }, hasServerMiddleware(routeTree));
|
|
53918
54257
|
const startRouterCode = `const __startRouter = function() {
|
|
53919
54258
|
__updateComponents(__routeTree);
|
|
53920
54259
|
const __router = createFileRouter(__routeTree${routerOpts2});
|
|
@@ -53953,14 +54292,14 @@ if (__pendChunks.length > 0 && typeof ensureChunk === 'function') {
|
|
|
53953
54292
|
];
|
|
53954
54293
|
const importedSet = new Set(allRuntimeImports);
|
|
53955
54294
|
const runtimeGlobals2 = globalNames.filter((n) => importedSet.has(n)).map((n) => `globalThis.${n} = ${n};
|
|
53956
|
-
`).join("") + "globalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\n\n";
|
|
54295
|
+
`).join("") + "globalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\nglobalThis.__reconcileRegion = __reconcileRegion;\n\n";
|
|
53957
54296
|
const extraGlobals = [...runtimeImportNames || []].filter((n) => n && n !== "default").map((n) => `globalThis.${n} = ${n};
|
|
53958
54297
|
`).join("");
|
|
53959
54298
|
const code2 = preamble + "const __components = globalThis.__components || (globalThis.__components = {});\nconst __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});\nconst __runtime_comps = __components;\n\n" + runtimeGlobals2 + extraGlobals + // Shared app modules run HERE: after the runtime bindings are published,
|
|
53960
54299
|
// before anything can request a route chunk. Earlier (at the top of the
|
|
53961
54300
|
// bundle) `globalThis.track` was still undefined, so every module-scope
|
|
53962
54301
|
// cell in a store was created against a missing runtime.
|
|
53963
|
-
(sharedModuleBundle ? sharedModuleBundle + "\n" : "") + cleanupFn + placeFn + "globalThis.__components = __components;\n" + resolveNamesFn + updateComponentsFn + "const __routeTree = " + routeTreeJson + ";\n__resolveNames(__routeTree);\n" + pendCode + startRouterCode;
|
|
54302
|
+
(sharedModuleBundle ? sharedModuleBundle + "\n" : "") + cleanupFn + placeFn + reconcileRegionFn + "globalThis.__components = __components;\n" + resolveNamesFn + updateComponentsFn + "const __routeTree = " + routeTreeJson + ";\n__resolveNames(__routeTree);\n" + pendCode + startRouterCode;
|
|
53964
54303
|
return hmr ? appendHmrGlobals(code2) : code2;
|
|
53965
54304
|
}
|
|
53966
54305
|
const componentLines = mono?.componentLines || [];
|
|
@@ -53969,8 +54308,8 @@ if (__pendChunks.length > 0 && typeof ensureChunk === 'function') {
|
|
|
53969
54308
|
const hydratorAliasLines = mono?.hydratorAliasLines || [];
|
|
53970
54309
|
const aliasCode = aliasLines.length > 0 ? aliasLines.join("\n") + "\n" : "";
|
|
53971
54310
|
const hydratorAliasCode = hydratorAliasLines.length > 0 ? hydratorAliasLines.join("\n") + "\n" : "";
|
|
53972
|
-
const routerOpts = buildRouterOpts({ routeDataCache });
|
|
53973
|
-
const code = preamble + "const __components = {};\nconst __hydrators = {};\nconst __runtime_comps = __components;\n\n" + componentLines.join("\n\n") + "\n" + aliasCode + hydratorLines.join("\n\n") + "\n" + hydratorAliasCode + cleanupFn + placeFn + "globalThis.__components = __components;\nglobalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\n" + allRuntimeImports.map((n) => `globalThis.${n} = ${n};
|
|
54311
|
+
const routerOpts = buildRouterOpts({ routeDataCache }, hasServerMiddleware(routeTree));
|
|
54312
|
+
const code = preamble + "const __components = {};\nconst __hydrators = {};\nconst __runtime_comps = __components;\n\n" + componentLines.join("\n\n") + "\n" + aliasCode + hydratorLines.join("\n\n") + "\n" + hydratorAliasCode + cleanupFn + placeFn + reconcileRegionFn + "globalThis.__components = __components;\nglobalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\nglobalThis.__reconcileRegion = __reconcileRegion;\n" + allRuntimeImports.map((n) => `globalThis.${n} = ${n};
|
|
53974
54313
|
`).join("") + "function __resolveNames(nodes) {\n for (const n of nodes) {\n if (typeof n.page === 'string') {\n n._pageName = n.page;\n n.page = __components[n.page];\n }\n if (typeof n.layout === 'string') {\n n._layoutName = n.layout;\n n.layout = __components[n.layout];\n }\n if (typeof n.error === 'string') n.error = __components[n.error];\n if (typeof n.notFound === 'string') n.notFound = __components[n.notFound];\n if (typeof n.offline === 'string') n.offline = __components[n.offline];\n if (typeof n.network === 'string') n.network = __components[n.network];\n if (n.children) __resolveNames(n.children);\n }\n}\n" + updateComponentsFn + "const __routeTree = " + routeTreeJson + `;
|
|
53975
54314
|
__resolveNames(__routeTree);
|
|
53976
54315
|
const __router = createFileRouter(__routeTree${routerOpts});
|
|
@@ -54942,6 +55281,41 @@ async function startProdServer(outDir, options) {
|
|
|
54942
55281
|
}
|
|
54943
55282
|
}
|
|
54944
55283
|
}
|
|
55284
|
+
if (url.pathname === "/_vesk/middleware" && middlewareMod) {
|
|
55285
|
+
const targetPath = url.searchParams.get("path") || "/";
|
|
55286
|
+
const targetUrl = new URL(targetPath, url.origin);
|
|
55287
|
+
const middlewareRequest = new Request(targetUrl.href, {
|
|
55288
|
+
method: "GET",
|
|
55289
|
+
headers: req.headers
|
|
55290
|
+
});
|
|
55291
|
+
const mwEndpointCtx = {
|
|
55292
|
+
request: middlewareRequest,
|
|
55293
|
+
params: {},
|
|
55294
|
+
url: targetUrl,
|
|
55295
|
+
locals: Object.assign({}, globalThis.__vesk_server_ctx || {}),
|
|
55296
|
+
cookies: {},
|
|
55297
|
+
set(key, value) {
|
|
55298
|
+
this.locals[key] = value;
|
|
55299
|
+
},
|
|
55300
|
+
get(key) {
|
|
55301
|
+
return this.locals[key];
|
|
55302
|
+
}
|
|
55303
|
+
};
|
|
55304
|
+
const mwResult = await middlewareMod.execute(mwEndpointCtx);
|
|
55305
|
+
res.writeHead(200, {
|
|
55306
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
55307
|
+
"Cache-Control": "no-store"
|
|
55308
|
+
});
|
|
55309
|
+
if (mwResult.response) {
|
|
55310
|
+
const location = mwResult.response.headers.get("location") || mwResult.response.headers.get("Location");
|
|
55311
|
+
if (location) {
|
|
55312
|
+
res.end(JSON.stringify({ redirect: location }));
|
|
55313
|
+
return;
|
|
55314
|
+
}
|
|
55315
|
+
}
|
|
55316
|
+
res.end(JSON.stringify(mwResult.rewriteUrl ? { rewrite: mwResult.rewriteUrl } : { allow: true }));
|
|
55317
|
+
return;
|
|
55318
|
+
}
|
|
54945
55319
|
let mwCtx;
|
|
54946
55320
|
const serverStore = globalThis.__vesk_server_ctx;
|
|
54947
55321
|
if (middlewareMod) {
|
|
@@ -54991,186 +55365,191 @@ async function startProdServer(outDir, options) {
|
|
|
54991
55365
|
url.pathname = mwResult.rewriteUrl;
|
|
54992
55366
|
}
|
|
54993
55367
|
}
|
|
55368
|
+
const __outerRequest = globalThis.__vesk_request;
|
|
54994
55369
|
globalThis.__vesk_request = mwCtx;
|
|
54995
|
-
|
|
54996
|
-
|
|
54997
|
-
|
|
54998
|
-
|
|
54999
|
-
|
|
55000
|
-
|
|
55001
|
-
|
|
55002
|
-
|
|
55003
|
-
|
|
55004
|
-
|
|
55005
|
-
|
|
55006
|
-
|
|
55370
|
+
try {
|
|
55371
|
+
if (url.pathname.startsWith("/_vesk/action/")) {
|
|
55372
|
+
const actionId = url.pathname.replace("/_vesk/action/", "");
|
|
55373
|
+
const actionEntry = buildConfig.actions && buildConfig.actions.find((a) => a.id === actionId);
|
|
55374
|
+
if (!actionEntry) {
|
|
55375
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
55376
|
+
res.end(JSON.stringify({ ok: false, error: "Action not found" }));
|
|
55377
|
+
return;
|
|
55378
|
+
}
|
|
55379
|
+
const mod = await loadFunction(actionEntry.function);
|
|
55380
|
+
if (!mod || !mod.handleAction) {
|
|
55381
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
55382
|
+
res.end(JSON.stringify({ ok: false, error: "Action not found" }));
|
|
55383
|
+
return;
|
|
55384
|
+
}
|
|
55385
|
+
try {
|
|
55386
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
55387
|
+
const handleAction = mod.handleAction.bind(mod);
|
|
55388
|
+
const response = await withSecurityScope(() => handleAction(webRequest, actionId));
|
|
55389
|
+
await deliverResponse(res, response);
|
|
55390
|
+
} catch (e) {
|
|
55391
|
+
const status = errorStatus(e, 500);
|
|
55392
|
+
const message = status === 500 && process.env.NODE_ENV === "production" ? "Internal Server Error" : e instanceof Error ? e.message : String(e);
|
|
55393
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
55394
|
+
res.end(JSON.stringify({ ok: false, error: message }));
|
|
55395
|
+
}
|
|
55007
55396
|
return;
|
|
55008
55397
|
}
|
|
55009
|
-
|
|
55010
|
-
const
|
|
55011
|
-
|
|
55012
|
-
|
|
55013
|
-
|
|
55014
|
-
|
|
55015
|
-
|
|
55016
|
-
|
|
55017
|
-
|
|
55018
|
-
|
|
55019
|
-
|
|
55020
|
-
|
|
55021
|
-
|
|
55022
|
-
|
|
55023
|
-
|
|
55024
|
-
|
|
55025
|
-
|
|
55026
|
-
|
|
55027
|
-
|
|
55028
|
-
|
|
55029
|
-
|
|
55030
|
-
res.writeHead(
|
|
55031
|
-
res.end(JSON.stringify({ error: "Internal Server Error" }));
|
|
55398
|
+
if (url.pathname.startsWith("/api")) {
|
|
55399
|
+
for (const route of buildConfig.routes) {
|
|
55400
|
+
if (route.type === "api") {
|
|
55401
|
+
const params = matchPath(route.path, url.pathname);
|
|
55402
|
+
if (params) {
|
|
55403
|
+
const mod = await loadFunction(route.function);
|
|
55404
|
+
if (!mod) {
|
|
55405
|
+
if (functionFailure(route.function)) {
|
|
55406
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
55407
|
+
res.end(JSON.stringify({ error: "Internal Server Error" }));
|
|
55408
|
+
return;
|
|
55409
|
+
}
|
|
55410
|
+
continue;
|
|
55411
|
+
}
|
|
55412
|
+
try {
|
|
55413
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
55414
|
+
const response = await withSecurityScope(() => mod.handle(webRequest));
|
|
55415
|
+
await deliverResponse(res, response);
|
|
55416
|
+
return;
|
|
55417
|
+
} catch (e) {
|
|
55418
|
+
const status = errorStatus(e, 500);
|
|
55419
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
55420
|
+
res.end(JSON.stringify({ error: status === 500 ? "Internal Server Error" : e instanceof Error ? e.message : String(e) }));
|
|
55032
55421
|
return;
|
|
55033
55422
|
}
|
|
55034
|
-
continue;
|
|
55035
|
-
}
|
|
55036
|
-
try {
|
|
55037
|
-
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
55038
|
-
const response = await withSecurityScope(() => mod.handle(webRequest));
|
|
55039
|
-
await deliverResponse(res, response);
|
|
55040
|
-
return;
|
|
55041
|
-
} catch (e) {
|
|
55042
|
-
const status = errorStatus(e, 500);
|
|
55043
|
-
res.writeHead(status, { "Content-Type": "application/json" });
|
|
55044
|
-
res.end(JSON.stringify({ error: status === 500 ? "Internal Server Error" : e instanceof Error ? e.message : String(e) }));
|
|
55045
|
-
return;
|
|
55046
55423
|
}
|
|
55047
55424
|
}
|
|
55048
55425
|
}
|
|
55049
55426
|
}
|
|
55050
|
-
|
|
55051
|
-
|
|
55052
|
-
|
|
55053
|
-
|
|
55054
|
-
|
|
55055
|
-
|
|
55056
|
-
|
|
55057
|
-
|
|
55058
|
-
|
|
55059
|
-
|
|
55060
|
-
|
|
55061
|
-
|
|
55062
|
-
|
|
55063
|
-
|
|
55064
|
-
|
|
55065
|
-
|
|
55066
|
-
|
|
55067
|
-
|
|
55068
|
-
|
|
55069
|
-
|
|
55427
|
+
const appDir = resolve14(projectDir, "app");
|
|
55428
|
+
const pageCssUrls = resolveCssUrls({
|
|
55429
|
+
enabled: hasBuiltGlobalCss(outDir)
|
|
55430
|
+
});
|
|
55431
|
+
const boundaryCache = /* @__PURE__ */ new Map();
|
|
55432
|
+
async function renderBoundaryFile(file, pathname, props) {
|
|
55433
|
+
const boundaryPath = resolveBoundaryFileForUrl(pathname, appDir, file);
|
|
55434
|
+
if (!boundaryPath) return null;
|
|
55435
|
+
const key = `${file}:${boundaryPath}`;
|
|
55436
|
+
let html = boundaryCache.has(key) ? boundaryCache.get(key) : null;
|
|
55437
|
+
if (html === null) {
|
|
55438
|
+
try {
|
|
55439
|
+
const runtimePath = resolve14(outDir, "server", "runtime.js");
|
|
55440
|
+
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
55441
|
+
const src2 = readFileSync18(boundaryPath, "utf-8");
|
|
55442
|
+
const compName = resolveComponentName(src2) || (file === "error.vsk" ? "Error" : "NotFound");
|
|
55443
|
+
html = await renderFullPage2(src2, compName, props, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: pageCssUrls, clientScriptUrl: buildConfig?.assets?.client?.url || "/_vesk/static/client.js", clientScriptIntegrity: buildConfig?.assets?.client?.integrity, security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: boundaryPath, headExtra: bakedHeadExtra });
|
|
55444
|
+
} catch {
|
|
55445
|
+
return null;
|
|
55446
|
+
}
|
|
55070
55447
|
}
|
|
55448
|
+
return html;
|
|
55071
55449
|
}
|
|
55072
|
-
|
|
55073
|
-
|
|
55074
|
-
|
|
55075
|
-
|
|
55076
|
-
|
|
55077
|
-
|
|
55078
|
-
|
|
55079
|
-
|
|
55080
|
-
|
|
55081
|
-
|
|
55082
|
-
|
|
55083
|
-
|
|
55084
|
-
|
|
55085
|
-
|
|
55086
|
-
|
|
55087
|
-
|
|
55088
|
-
|
|
55089
|
-
|
|
55090
|
-
input
|
|
55091
|
-
}
|
|
55092
|
-
|
|
55093
|
-
|
|
55094
|
-
|
|
55095
|
-
|
|
55096
|
-
|
|
55097
|
-
|
|
55098
|
-
|
|
55099
|
-
|
|
55100
|
-
|
|
55101
|
-
|
|
55102
|
-
|
|
55103
|
-
|
|
55104
|
-
|
|
55105
|
-
|
|
55106
|
-
|
|
55107
|
-
|
|
55108
|
-
|
|
55109
|
-
|
|
55110
|
-
|
|
55111
|
-
|
|
55112
|
-
|
|
55113
|
-
|
|
55114
|
-
|
|
55115
|
-
|
|
55116
|
-
|
|
55117
|
-
|
|
55118
|
-
|
|
55119
|
-
|
|
55120
|
-
res.
|
|
55121
|
-
|
|
55122
|
-
|
|
55123
|
-
}
|
|
55124
|
-
|
|
55125
|
-
|
|
55126
|
-
|
|
55127
|
-
|
|
55128
|
-
res.end(body);
|
|
55129
|
-
}
|
|
55130
|
-
return;
|
|
55131
|
-
} catch (e) {
|
|
55132
|
-
const err = e instanceof Error ? e : new Error(String(e));
|
|
55133
|
-
if (err.name === "Redirect") {
|
|
55134
|
-
const redirect2 = err;
|
|
55135
|
-
res.writeHead(Number(redirect2.status) || 302, { Location: typeof redirect2.url === "string" ? redirect2.url : "/" });
|
|
55136
|
-
res.end();
|
|
55450
|
+
let notFoundHtml = null;
|
|
55451
|
+
{
|
|
55452
|
+
const rendered = await renderBoundaryFile("not-found.vsk", url.pathname, { params: {}, url: url.pathname });
|
|
55453
|
+
notFoundHtml = rendered;
|
|
55454
|
+
}
|
|
55455
|
+
for (const route of buildConfig.routes) {
|
|
55456
|
+
if (route.type === "ssr") {
|
|
55457
|
+
const params = matchPath(route.path, url.pathname);
|
|
55458
|
+
if (params) {
|
|
55459
|
+
const mod = await loadFunction(route.function);
|
|
55460
|
+
if (mod) {
|
|
55461
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
55462
|
+
const origin = new URL(url.href).origin;
|
|
55463
|
+
const origFetch = globalThis.fetch;
|
|
55464
|
+
globalThis.fetch = async (input, init) => {
|
|
55465
|
+
if (typeof input === "string" && input.startsWith("/")) {
|
|
55466
|
+
input = origin + input;
|
|
55467
|
+
}
|
|
55468
|
+
return origFetch(input, init);
|
|
55469
|
+
};
|
|
55470
|
+
try {
|
|
55471
|
+
let cachedResult = null;
|
|
55472
|
+
if (route.revalidate && route.revalidate > 0) {
|
|
55473
|
+
const { pageIsr: pageIsr2 } = await Promise.resolve().then(() => (init_index_server(), index_server_exports));
|
|
55474
|
+
cachedResult = await pageIsr2(url.pathname, async () => {
|
|
55475
|
+
const response2 = await withSecurityScope(() => mod.handle(webRequest));
|
|
55476
|
+
return { html: await response2.text(), headers: Object.fromEntries(response2.headers) };
|
|
55477
|
+
}, { revalidate: route.revalidate, tags: route.tags || [] });
|
|
55478
|
+
}
|
|
55479
|
+
if (cachedResult) {
|
|
55480
|
+
res.writeHead(200, cachedResult.headers || { "Content-Type": "text/html" });
|
|
55481
|
+
res.end(cachedResult.html);
|
|
55482
|
+
return;
|
|
55483
|
+
}
|
|
55484
|
+
const response = await withSecurityScope(() => mod.handle(webRequest));
|
|
55485
|
+
const headers2 = Object.fromEntries(response.headers);
|
|
55486
|
+
if (!headers2["content-type"] && !headers2["Content-Type"]) headers2["Content-Type"] = "text/html";
|
|
55487
|
+
if (response.body && typeof response.body.getReader === "function") {
|
|
55488
|
+
res.writeHead(response.status, headers2);
|
|
55489
|
+
const reader = response.body.getReader();
|
|
55490
|
+
const pump = () => {
|
|
55491
|
+
reader.read().then(({ done, value }) => {
|
|
55492
|
+
if (done) {
|
|
55493
|
+
res.end();
|
|
55494
|
+
return;
|
|
55495
|
+
}
|
|
55496
|
+
res.write(value);
|
|
55497
|
+
pump();
|
|
55498
|
+
}).catch(() => res.end());
|
|
55499
|
+
};
|
|
55500
|
+
pump();
|
|
55501
|
+
} else {
|
|
55502
|
+
const body = await response.text();
|
|
55503
|
+
res.writeHead(response.status, headers2);
|
|
55504
|
+
res.end(body);
|
|
55505
|
+
}
|
|
55137
55506
|
return;
|
|
55138
|
-
}
|
|
55139
|
-
|
|
55140
|
-
|
|
55141
|
-
|
|
55507
|
+
} catch (e) {
|
|
55508
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
55509
|
+
if (err.name === "Redirect") {
|
|
55510
|
+
const redirect2 = err;
|
|
55511
|
+
res.writeHead(Number(redirect2.status) || 302, { Location: typeof redirect2.url === "string" ? redirect2.url : "/" });
|
|
55512
|
+
res.end();
|
|
55513
|
+
return;
|
|
55514
|
+
}
|
|
55515
|
+
if (err.name === "NotFoundError") {
|
|
55516
|
+
res.writeHead(404, { "Content-Type": "text/html" });
|
|
55517
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
55518
|
+
return;
|
|
55519
|
+
}
|
|
55520
|
+
console.error("vesk ssr error:", err.message);
|
|
55521
|
+
await reportServerError(err, {
|
|
55522
|
+
url: url.pathname + url.search,
|
|
55523
|
+
routePath: route.path,
|
|
55524
|
+
target: "node",
|
|
55525
|
+
status: 500,
|
|
55526
|
+
buildConfig
|
|
55527
|
+
});
|
|
55528
|
+
if (eventsMod) {
|
|
55529
|
+
await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
|
|
55530
|
+
}
|
|
55531
|
+
const expose = process.env.NODE_ENV !== "production";
|
|
55532
|
+
const errorHtml = await renderBoundaryFile("error.vsk", url.pathname, {
|
|
55533
|
+
error: expose ? err.message : "Internal Server Error",
|
|
55534
|
+
stack: expose ? err.stack : "",
|
|
55535
|
+
statusCode: 500,
|
|
55536
|
+
url: url.pathname
|
|
55537
|
+
});
|
|
55538
|
+
res.writeHead(500, { "Content-Type": "text/html" });
|
|
55539
|
+
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== "production" ? err.message : void 0, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
55142
55540
|
return;
|
|
55541
|
+
} finally {
|
|
55542
|
+
globalThis.fetch = origFetch;
|
|
55143
55543
|
}
|
|
55144
|
-
console.error("vesk ssr error:", err.message);
|
|
55145
|
-
await reportServerError(err, {
|
|
55146
|
-
url: url.pathname + url.search,
|
|
55147
|
-
routePath: route.path,
|
|
55148
|
-
target: "node",
|
|
55149
|
-
status: 500,
|
|
55150
|
-
buildConfig
|
|
55151
|
-
});
|
|
55152
|
-
if (eventsMod) {
|
|
55153
|
-
await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
|
|
55154
|
-
}
|
|
55155
|
-
const expose = process.env.NODE_ENV !== "production";
|
|
55156
|
-
const errorHtml = await renderBoundaryFile("error.vsk", url.pathname, {
|
|
55157
|
-
error: expose ? err.message : "Internal Server Error",
|
|
55158
|
-
stack: expose ? err.stack : "",
|
|
55159
|
-
statusCode: 500,
|
|
55160
|
-
url: url.pathname
|
|
55161
|
-
});
|
|
55162
|
-
res.writeHead(500, { "Content-Type": "text/html" });
|
|
55163
|
-
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== "production" ? err.message : void 0, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
55164
|
-
return;
|
|
55165
|
-
} finally {
|
|
55166
|
-
globalThis.fetch = origFetch;
|
|
55167
55544
|
}
|
|
55168
55545
|
}
|
|
55169
55546
|
}
|
|
55170
55547
|
}
|
|
55548
|
+
res.writeHead(404, { "Content-Type": "text/html" });
|
|
55549
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
55550
|
+
} finally {
|
|
55551
|
+
globalThis.__vesk_request = __outerRequest;
|
|
55171
55552
|
}
|
|
55172
|
-
res.writeHead(404, { "Content-Type": "text/html" });
|
|
55173
|
-
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
55174
55553
|
});
|
|
55175
55554
|
try {
|
|
55176
55555
|
await eventsMod?.executeStart?.({ server, port, host });
|
|
@@ -56403,6 +56782,10 @@ var Ctx2 = class {
|
|
|
56403
56782
|
markerless = true;
|
|
56404
56783
|
inTryBody = false;
|
|
56405
56784
|
claimStatic = false;
|
|
56785
|
+
// Markerless only: the next real claim carries a compiler-generated static
|
|
56786
|
+
// class descriptor so a same-tag but structurally different SSR slot is
|
|
56787
|
+
// substituted instead of adopted (e.g. an empty-state <div> vs a list <div>).
|
|
56788
|
+
descriptorClaim = false;
|
|
56406
56789
|
// While set, the next StaticNode claimed in hydrate mode uses `__root` (the
|
|
56407
56790
|
// item element already claimed by key) instead of walking for a new element.
|
|
56408
56791
|
rootClaim = false;
|
|
@@ -56592,6 +56975,18 @@ var PROPERTY_ATTRS2 = {
|
|
|
56592
56975
|
option: /* @__PURE__ */ new Set(["selected"]),
|
|
56593
56976
|
progress: /* @__PURE__ */ new Set(["value"])
|
|
56594
56977
|
};
|
|
56978
|
+
function staticClassDescriptor2(node) {
|
|
56979
|
+
const hasDynamicClass = node.children.some((child) => child instanceof DynamicBinding && child.kind === "attribute" && child.target === "class");
|
|
56980
|
+
if (hasDynamicClass)
|
|
56981
|
+
return null;
|
|
56982
|
+
const attr = node.attributes.find((a) => a.name === "class");
|
|
56983
|
+
if (!attr)
|
|
56984
|
+
return null;
|
|
56985
|
+
const value = attr.value.trim();
|
|
56986
|
+
if (!value)
|
|
56987
|
+
return null;
|
|
56988
|
+
return JSON.stringify({ class: value });
|
|
56989
|
+
}
|
|
56595
56990
|
function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
|
|
56596
56991
|
const el = ctx2.n();
|
|
56597
56992
|
if (ctx2.hydrate) {
|
|
@@ -56603,7 +56998,11 @@ function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget)
|
|
|
56603
56998
|
ctx2.rootClaim = false;
|
|
56604
56999
|
const skipExpr = regionBudget && ctx2.markerless ? markerlessSkipExpr2(regionBudget, skipK) : skipK;
|
|
56605
57000
|
const skipArg = ctx2.markerless ? `, ${skipExpr}` : "";
|
|
56606
|
-
const
|
|
57001
|
+
const wantsDescriptor = ctx2.markerless && ctx2.descriptorClaim;
|
|
57002
|
+
ctx2.descriptorClaim = false;
|
|
57003
|
+
const descriptor = wantsDescriptor && !rootClaim ? staticClassDescriptor2(node) : null;
|
|
57004
|
+
const descriptorArg = descriptor ? `, ${descriptor}` : "";
|
|
57005
|
+
const claimedExpr = rootClaim ? `__root || document.createElement(${JSON.stringify(node.tag)})` : `${ctx2.walker}.nextElement(${JSON.stringify(node.tag)}${skipArg}${descriptorArg})`;
|
|
56607
57006
|
ctx2.push(`const ${el} = ${claimedExpr};`);
|
|
56608
57007
|
if (regionBudget && ctx2.markerless)
|
|
56609
57008
|
ctx2.push(`${regionBudget} = 0;`);
|
|
@@ -57046,6 +57445,7 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
|
|
|
57046
57445
|
}
|
|
57047
57446
|
const callArgs = () => plainTarget ? `reactiveProps({ ${propsEntries.join(", ")} })` : `{ ${propsEntries.join(", ")} }`;
|
|
57048
57447
|
if (ctx2.hydrate) {
|
|
57448
|
+
ctx2.descriptorClaim = false;
|
|
57049
57449
|
const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `${ctx2.hydrateRegistry}[${JSON.stringify(node.componentName)}]`);
|
|
57050
57450
|
if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
|
|
57051
57451
|
ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
|
|
@@ -57287,13 +57687,14 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57287
57687
|
const hyd = ctx2.hydrate;
|
|
57288
57688
|
const parent = parentVar || "$root";
|
|
57289
57689
|
const budget = hyd ? regionBudgetVar2(ctx2, skipK, regionBudget) : null;
|
|
57690
|
+
const rid = regionMarkerId(node);
|
|
57290
57691
|
const isOpaque = (n) => !!n && typeof n.condition !== "undefined";
|
|
57291
57692
|
if (hyd && node.alternateNodes.length === 1 && isOpaque(node.alternateNodes[0])) {
|
|
57292
57693
|
const chain = [];
|
|
57293
57694
|
let cur = node;
|
|
57294
57695
|
let finalElse = null;
|
|
57295
57696
|
while (cur) {
|
|
57296
|
-
chain.push({ cond: transformTracked2(cur.condition, tracked2), nodes: cur.consequentNodes });
|
|
57697
|
+
chain.push({ cond: transformTracked2(cur.condition, tracked2), nodes: cur.consequentNodes, id: regionMarkerId(cur) });
|
|
57297
57698
|
if (cur.alternateNodes.length === 1 && isOpaque(cur.alternateNodes[0])) {
|
|
57298
57699
|
cur = cur.alternateNodes[0];
|
|
57299
57700
|
} else {
|
|
@@ -57317,6 +57718,9 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57317
57718
|
ctx2.push(`const ${rn} = ${fnOpen2}`);
|
|
57318
57719
|
const cl = ctx2.n();
|
|
57319
57720
|
ctx2.push(indent3(`const ${cl} = [];`));
|
|
57721
|
+
const savedDescriptor = ctx2.descriptorClaim;
|
|
57722
|
+
if (hyd && ctx2.markerless)
|
|
57723
|
+
ctx2.descriptorClaim = true;
|
|
57320
57724
|
for (const n of chain[i].nodes) {
|
|
57321
57725
|
const savedClaim = ctx2.claimStatic;
|
|
57322
57726
|
if (hyd)
|
|
@@ -57326,6 +57730,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57326
57730
|
if (v)
|
|
57327
57731
|
ctx2.push(indent3(`${cl}.push(${v});`));
|
|
57328
57732
|
}
|
|
57733
|
+
ctx2.descriptorClaim = savedDescriptor;
|
|
57329
57734
|
ctx2.push(indent3(`__place(${anchor2}, ${endAnchor2}, ${cl}, ${parent});`));
|
|
57330
57735
|
ctx2.push(`};`);
|
|
57331
57736
|
}
|
|
@@ -57335,6 +57740,9 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57335
57740
|
ctx2.push(`const ${finalRender} = ${fnOpen2}`);
|
|
57336
57741
|
const cl2 = ctx2.n();
|
|
57337
57742
|
ctx2.push(indent3(`const ${cl2} = [];`));
|
|
57743
|
+
const savedDescriptor = ctx2.descriptorClaim;
|
|
57744
|
+
if (hyd && ctx2.markerless)
|
|
57745
|
+
ctx2.descriptorClaim = true;
|
|
57338
57746
|
for (const n of finalElse) {
|
|
57339
57747
|
const savedClaim = ctx2.claimStatic;
|
|
57340
57748
|
if (hyd)
|
|
@@ -57344,27 +57752,39 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57344
57752
|
if (v)
|
|
57345
57753
|
ctx2.push(indent3(`${cl2}.push(${v});`));
|
|
57346
57754
|
}
|
|
57755
|
+
ctx2.descriptorClaim = savedDescriptor;
|
|
57347
57756
|
ctx2.push(indent3(`__place(${anchor2}, ${endAnchor2}, ${cl2}, ${parent});`));
|
|
57348
57757
|
ctx2.push(`};`);
|
|
57349
57758
|
}
|
|
57350
|
-
let init = `if (${chain[0].cond}) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
57351
|
-
for (let i = 1; i < chain.length; i++)
|
|
57352
|
-
init += ` else if (${chain[i].cond}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
57353
|
-
if (finalRender)
|
|
57354
|
-
init += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
57355
|
-
ctx2.push(init);
|
|
57356
57759
|
let branchInitFallback = finalRender ? `${chain.length}` : "-1";
|
|
57357
57760
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
57358
57761
|
branchInitFallback = `(${chain[i].cond} ? ${i} : ${branchInitFallback})`;
|
|
57359
57762
|
}
|
|
57360
57763
|
const branchInit = `(${branchInitFallback})`;
|
|
57764
|
+
const branchSnapshot = ctx2.n();
|
|
57765
|
+
ctx2.push(`const ${branchSnapshot} = ${branchInit};`);
|
|
57766
|
+
if (!ctx2.markerless) {
|
|
57767
|
+
for (let i = 0; i < chain.length; i++) {
|
|
57768
|
+
ctx2.push(`if (__hydrate) __reconcileRegion(${parent}, '${chain[i].id}', ${branchSnapshot} === ${i} ? 0 : 1, ${ctx2.walker});`);
|
|
57769
|
+
}
|
|
57770
|
+
} else {
|
|
57771
|
+
const chainBranches = chain.map((c) => c.nodes);
|
|
57772
|
+
if (finalElse)
|
|
57773
|
+
chainBranches.push(finalElse);
|
|
57774
|
+
emitStructuralRegionDiscard2(ctx2, chainBranches, branchSnapshot, budget);
|
|
57775
|
+
}
|
|
57776
|
+
let init = `if (${branchSnapshot} === 0) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
57777
|
+
for (let i = 1; i < chain.length; i++)
|
|
57778
|
+
init += ` else if (${branchSnapshot} === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
57779
|
+
if (finalRender)
|
|
57780
|
+
init += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
57781
|
+
ctx2.push(init);
|
|
57361
57782
|
let effInner = `if (__new === 0) { ${asyncKw2}${renderNames[0]}(); }`;
|
|
57362
57783
|
for (let i = 1; i < chain.length; i++)
|
|
57363
57784
|
effInner += ` else if (__new === ${i}) { ${asyncKw2}${renderNames[i]}(); }`;
|
|
57364
57785
|
if (finalRender)
|
|
57365
57786
|
effInner += ` else { ${asyncKw2}${finalRender}(); }`;
|
|
57366
57787
|
const effBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
|
|
57367
|
-
if (__first) { __first = false; __iv = ${branchInit}; return; }
|
|
57368
57788
|
const __new = ${branchInit};
|
|
57369
57789
|
if (__new !== __iv) {
|
|
57370
57790
|
for (const e of ${effectsVar2}) destroy_block(e);
|
|
@@ -57376,14 +57796,12 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57376
57796
|
}, true);`;
|
|
57377
57797
|
if (effTarget) {
|
|
57378
57798
|
ctx2.push(`${effTarget}.push((() => {
|
|
57379
|
-
let __iv = ${
|
|
57380
|
-
let __first = true;
|
|
57799
|
+
let __iv = ${branchSnapshot};
|
|
57381
57800
|
return ${effBody}
|
|
57382
57801
|
})());`);
|
|
57383
57802
|
} else {
|
|
57384
57803
|
ctx2.effects.push(`{
|
|
57385
|
-
let __iv = ${
|
|
57386
|
-
let __first = true;
|
|
57804
|
+
let __iv = ${branchSnapshot};
|
|
57387
57805
|
${effBody}
|
|
57388
57806
|
}`);
|
|
57389
57807
|
}
|
|
@@ -57411,6 +57829,9 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57411
57829
|
ctx2.push(indent3(`const ${conFrag} = document.createDocumentFragment();`));
|
|
57412
57830
|
if (hyd)
|
|
57413
57831
|
ctx2.push(indent3(`const __cl = [];`));
|
|
57832
|
+
const savedConDescriptor = ctx2.descriptorClaim;
|
|
57833
|
+
if (hyd && ctx2.markerless)
|
|
57834
|
+
ctx2.descriptorClaim = true;
|
|
57414
57835
|
for (const n of node.consequentNodes) {
|
|
57415
57836
|
const savedClaim = ctx2.claimStatic;
|
|
57416
57837
|
if (hyd)
|
|
@@ -57424,6 +57845,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57424
57845
|
ctx2.push(indent3(`${conFrag}.appendChild(${v});`));
|
|
57425
57846
|
}
|
|
57426
57847
|
}
|
|
57848
|
+
ctx2.descriptorClaim = savedConDescriptor;
|
|
57427
57849
|
if (hyd)
|
|
57428
57850
|
ctx2.push(indent3(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
57429
57851
|
else
|
|
@@ -57440,6 +57862,9 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57440
57862
|
ctx2.push(indent3(`const ${altFrag} = document.createDocumentFragment();`));
|
|
57441
57863
|
if (hyd)
|
|
57442
57864
|
ctx2.push(indent3(`const __cl = [];`));
|
|
57865
|
+
const savedAltDescriptor = ctx2.descriptorClaim;
|
|
57866
|
+
if (hyd && ctx2.markerless)
|
|
57867
|
+
ctx2.descriptorClaim = true;
|
|
57443
57868
|
for (const n of node.alternateNodes) {
|
|
57444
57869
|
const savedAltClaim = ctx2.claimStatic;
|
|
57445
57870
|
if (hyd)
|
|
@@ -57453,6 +57878,7 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57453
57878
|
ctx2.push(indent3(`${altFrag}.appendChild(${v});`));
|
|
57454
57879
|
}
|
|
57455
57880
|
}
|
|
57881
|
+
ctx2.descriptorClaim = savedAltDescriptor;
|
|
57456
57882
|
if (hyd)
|
|
57457
57883
|
ctx2.push(indent3(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
57458
57884
|
else
|
|
@@ -57461,10 +57887,15 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57461
57887
|
}
|
|
57462
57888
|
if (!hyd)
|
|
57463
57889
|
ctx2.push(`${parent}.appendChild(${endAnchor});`);
|
|
57464
|
-
|
|
57890
|
+
const condSnapshot = ctx2.n();
|
|
57891
|
+
ctx2.push(`const ${condSnapshot} = ${condExpr};`);
|
|
57892
|
+
if (hyd && !ctx2.markerless)
|
|
57893
|
+
ctx2.push(`if (__hydrate) __reconcileRegion(${parent}, '${rid}', ${condSnapshot} ? 0 : 1, ${ctx2.walker});`);
|
|
57894
|
+
if (hyd && ctx2.markerless)
|
|
57895
|
+
emitStructuralRegionDiscard2(ctx2, [node.consequentNodes, node.alternateNodes], hasElse ? `(${condSnapshot} ? 0 : 1)` : `(${condSnapshot} ? 0 : -1)`, budget);
|
|
57896
|
+
ctx2.push(`if (${condSnapshot}) { ${asyncKw}${conRenderName}(); }` + (hasElse ? ` else { ${asyncKw}${altRenderName}(); }` : ""));
|
|
57465
57897
|
const renderBranch = `if (__nv) { ${asyncKw}${conRenderName}(); }` + (hasElse ? ` else { ${asyncKw}${altRenderName}(); }` : "");
|
|
57466
57898
|
const effectBody = `effect(${ctx2.isAsyncScope ? "async () => {" : "() => {"}
|
|
57467
|
-
if (__first) { __first = false; __iv = ${condExpr}; return; }
|
|
57468
57899
|
const __nv = ${condExpr};
|
|
57469
57900
|
if (__nv !== __iv) {
|
|
57470
57901
|
for (const e of ${effectsVar}) destroy_block(e);
|
|
@@ -57478,14 +57909,12 @@ function emitOpaque2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regi
|
|
|
57478
57909
|
return null;
|
|
57479
57910
|
if (effTarget) {
|
|
57480
57911
|
ctx2.push(`${effTarget}.push((() => {
|
|
57481
|
-
let __iv = ${
|
|
57482
|
-
let __first = true;
|
|
57912
|
+
let __iv = ${condSnapshot};
|
|
57483
57913
|
return ${effectBody}
|
|
57484
57914
|
})());`);
|
|
57485
57915
|
} else {
|
|
57486
57916
|
ctx2.effects.push(`{
|
|
57487
|
-
let __iv = ${
|
|
57488
|
-
let __first = true;
|
|
57917
|
+
let __iv = ${condSnapshot};
|
|
57489
57918
|
${effectBody}
|
|
57490
57919
|
}`);
|
|
57491
57920
|
}
|
|
@@ -57920,29 +58349,26 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
57920
58349
|
let emptyRenderName = null;
|
|
57921
58350
|
if (node.alternateNodes.length > 0) {
|
|
57922
58351
|
emptyRenderName = ctx2.n();
|
|
57923
|
-
const
|
|
58352
|
+
const emptyClaims = ctx2.hydrate;
|
|
58353
|
+
const emptySig = !emptyClaims ? ctx2.isAsyncScope ? "async () => {" : "() => {" : ctx2.isAsyncScope ? "async (__cl) => {" : "(__cl) => {";
|
|
57924
58354
|
ctx2.push(`const ${emptyRenderName} = ${emptySig}`);
|
|
57925
58355
|
ctx2.push(indent3(`const __p = ${anchor}.parentNode;`));
|
|
57926
58356
|
const frag = ctx2.n();
|
|
57927
|
-
if (!
|
|
58357
|
+
if (!emptyClaims)
|
|
57928
58358
|
ctx2.push(indent3(`const ${frag} = document.createDocumentFragment();`));
|
|
57929
58359
|
const savedClaim = ctx2.claimStatic;
|
|
57930
|
-
const savedHydrate = ctx2.hydrate;
|
|
57931
|
-
if (hydKeyed)
|
|
57932
|
-
ctx2.hydrate = false;
|
|
57933
58360
|
for (const n of node.alternateNodes) {
|
|
57934
58361
|
ctx2.claimStatic = true;
|
|
57935
|
-
const v = emitNode2(ctx2, n, tracked2, effectsVar,
|
|
58362
|
+
const v = emitNode2(ctx2, n, tracked2, effectsVar, emptyClaims ? void 0 : frag, "__components", 0, budget || void 0);
|
|
57936
58363
|
if (v) {
|
|
57937
|
-
if (
|
|
58364
|
+
if (emptyClaims)
|
|
57938
58365
|
ctx2.push(indent3(`if (__cl) __cl.push(${v}); else __p.insertBefore(${v}, ${endAnchor});`));
|
|
57939
58366
|
else
|
|
57940
58367
|
ctx2.push(indent3(`${frag}.appendChild(${v});`));
|
|
57941
58368
|
}
|
|
57942
58369
|
}
|
|
57943
58370
|
ctx2.claimStatic = savedClaim;
|
|
57944
|
-
|
|
57945
|
-
if (!hyd)
|
|
58371
|
+
if (!emptyClaims)
|
|
57946
58372
|
ctx2.push(indent3(`if (${frag}.childNodes.length > 0) __p.insertBefore(${frag}, ${endAnchor});`));
|
|
57947
58373
|
ctx2.push(`};`);
|
|
57948
58374
|
}
|
|
@@ -57964,8 +58390,13 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
57964
58390
|
}
|
|
57965
58391
|
if (emptyRenderName) {
|
|
57966
58392
|
const isEmptyVar = ctx2.n();
|
|
58393
|
+
const collectVar = hydKeyed ? ctx2.n() : null;
|
|
57967
58394
|
ctx2.push(`let ${isEmptyVar} = !${hasItems}();`);
|
|
57968
|
-
|
|
58395
|
+
if (collectVar)
|
|
58396
|
+
ctx2.push(`const ${collectVar} = [];`);
|
|
58397
|
+
ctx2.push(`if (!${isEmptyVar}) { ${initList}(); } else { ${aw}${emptyRenderName}(${collectVar || ""}); }`);
|
|
58398
|
+
if (collectVar)
|
|
58399
|
+
ctx2.push(`__place(${anchor}, ${endAnchor}, ${collectVar}, ${parent});`);
|
|
57969
58400
|
if (!reactiveSource)
|
|
57970
58401
|
return null;
|
|
57971
58402
|
pushEffect(`let __first = true;`, `effect(${effOpen}
|
|
@@ -58044,7 +58475,7 @@ ${renderAllItems(" ", null)}
|
|
|
58044
58475
|
__cleanup(${anchor}, ${endAnchor});
|
|
58045
58476
|
if (__new) {
|
|
58046
58477
|
${renderAllItems(" ", null)}
|
|
58047
|
-
} else { ${aw}${emptyRenderName}(
|
|
58478
|
+
} else { ${aw}${emptyRenderName}(); }
|
|
58048
58479
|
}, true)`);
|
|
58049
58480
|
} else {
|
|
58050
58481
|
const collectVar = hyd ? ctx2.n() : null;
|
|
@@ -58137,6 +58568,8 @@ function generateComponent2(comp, importedNames = /* @__PURE__ */ new Set(), hyd
|
|
|
58137
58568
|
}
|
|
58138
58569
|
}
|
|
58139
58570
|
}
|
|
58571
|
+
if (ctx2.hydrate && ctx2.markerless)
|
|
58572
|
+
ctx2.descriptorClaim = true;
|
|
58140
58573
|
for (const node of comp.body) {
|
|
58141
58574
|
if (node instanceof TrackDecl) {
|
|
58142
58575
|
if (deferredTrackDecls.has(node))
|
|
@@ -58227,6 +58660,33 @@ function buildComponentMap3(irRoot, hydrate = false, alloc, markerless = true) {
|
|
|
58227
58660
|
const code = generateComponent2(comp, directNames, hydrate, asyncComps, linkNames, selfClaimNames, alloc, markerless);
|
|
58228
58661
|
mapLines.push(`${registry}[${JSON.stringify(comp.name)}] = ${code};`);
|
|
58229
58662
|
}
|
|
58663
|
+
if (hydrate && !markerless) {
|
|
58664
|
+
mapLines.push(`function __reconcileRegion(parent, id, branch, walker) {`);
|
|
58665
|
+
mapLines.push(` if (!parent) return;`);
|
|
58666
|
+
mapLines.push(` let start = null;`);
|
|
58667
|
+
mapLines.push(` let end = null;`);
|
|
58668
|
+
mapLines.push(` for (let n = parent.firstChild; n; n = n.nextSibling) {`);
|
|
58669
|
+
mapLines.push(` if (n.nodeType !== 8) continue;`);
|
|
58670
|
+
mapLines.push(` const text = n.textContent || '';`);
|
|
58671
|
+
mapLines.push(` if (text === 'vesk-r:' + id + ':0' || text === 'vesk-r:' + id + ':1') start = n;`);
|
|
58672
|
+
mapLines.push(` else if (text === 'vesk-r-end:' + id) end = n;`);
|
|
58673
|
+
mapLines.push(` if (start && end) break;`);
|
|
58674
|
+
mapLines.push(` }`);
|
|
58675
|
+
mapLines.push(` if (!start || !end) return;`);
|
|
58676
|
+
mapLines.push(` const ssrBranch = (start.textContent || '').slice(-2) === ':1' ? 1 : 0;`);
|
|
58677
|
+
mapLines.push(` if (ssrBranch !== branch) {`);
|
|
58678
|
+
mapLines.push(` let n = start.nextSibling;`);
|
|
58679
|
+
mapLines.push(` while (n && n !== end) {`);
|
|
58680
|
+
mapLines.push(` const next = n.nextSibling;`);
|
|
58681
|
+
mapLines.push(` n.remove();`);
|
|
58682
|
+
mapLines.push(` n = next;`);
|
|
58683
|
+
mapLines.push(` }`);
|
|
58684
|
+
mapLines.push(` if (walker && walker.retireDetached) walker.retireDetached();`);
|
|
58685
|
+
mapLines.push(` }`);
|
|
58686
|
+
mapLines.push(` start.remove();`);
|
|
58687
|
+
mapLines.push(` end.remove();`);
|
|
58688
|
+
mapLines.push(`}`);
|
|
58689
|
+
}
|
|
58230
58690
|
mapLines.push(`function __cleanup(start, end) {`);
|
|
58231
58691
|
mapLines.push(` let n = start.nextSibling;`);
|
|
58232
58692
|
mapLines.push(` while (n && n !== end) {`);
|
|
@@ -58291,6 +58751,50 @@ function ssrResidueEstimate2(node) {
|
|
|
58291
58751
|
}
|
|
58292
58752
|
return 0;
|
|
58293
58753
|
}
|
|
58754
|
+
function firstBranchRoot2(nodes) {
|
|
58755
|
+
for (const n of nodes) {
|
|
58756
|
+
if (n instanceof StaticNode)
|
|
58757
|
+
return { tag: n.tag, descriptor: staticClassDescriptor2(n) };
|
|
58758
|
+
if (n instanceof ComponentCall || n instanceof ComponentRef)
|
|
58759
|
+
return null;
|
|
58760
|
+
if (n instanceof OpaqueDynamicRegion)
|
|
58761
|
+
return null;
|
|
58762
|
+
if (n instanceof MapRegion || n instanceof ForLoop || n instanceof WhileLoop) {
|
|
58763
|
+
const child = firstBranchRoot2(n.bodyTemplate);
|
|
58764
|
+
if (child)
|
|
58765
|
+
return child;
|
|
58766
|
+
}
|
|
58767
|
+
if (n instanceof SwitchBlock) {
|
|
58768
|
+
for (const c of n.cases) {
|
|
58769
|
+
const child = firstBranchRoot2(c.body);
|
|
58770
|
+
if (child)
|
|
58771
|
+
return child;
|
|
58772
|
+
}
|
|
58773
|
+
}
|
|
58774
|
+
if (n instanceof TryCatch) {
|
|
58775
|
+
const child = firstBranchRoot2(n.bodyTemplate) || firstBranchRoot2(n.catchBody);
|
|
58776
|
+
if (child)
|
|
58777
|
+
return child;
|
|
58778
|
+
}
|
|
58779
|
+
}
|
|
58780
|
+
return null;
|
|
58781
|
+
}
|
|
58782
|
+
function structuralRegionMetadata2(branches) {
|
|
58783
|
+
const parts = branches.map((nodes) => {
|
|
58784
|
+
const first = firstBranchRoot2(nodes);
|
|
58785
|
+
const tag = first ? JSON.stringify(first.tag) : "undefined";
|
|
58786
|
+
const descriptor = first && first.descriptor ? first.descriptor : "null";
|
|
58787
|
+
return `{ tag: ${tag}, descriptor: ${descriptor}, count: ${ssrResidueEstimate2(nodes)} }`;
|
|
58788
|
+
});
|
|
58789
|
+
return `[${parts.join(", ")}]`;
|
|
58790
|
+
}
|
|
58791
|
+
function emitStructuralRegionDiscard2(ctx2, branches, selectedExpr, budget) {
|
|
58792
|
+
if (!ctx2.hydrate || !ctx2.markerless)
|
|
58793
|
+
return;
|
|
58794
|
+
const offset2 = budget ? `, ${budget}` : "";
|
|
58795
|
+
const consume = budget ? ` ${budget} = 0;` : "";
|
|
58796
|
+
ctx2.push(`if (${ctx2.walker} && typeof ${ctx2.walker}.discardStructuralRegion === 'function' && ${ctx2.walker}.discardStructuralRegion(${structuralRegionMetadata2(branches)}, ${selectedExpr}${offset2})) {${consume}}`);
|
|
58797
|
+
}
|
|
58294
58798
|
function isStaticIR2(body) {
|
|
58295
58799
|
for (const node of body) {
|
|
58296
58800
|
if (node instanceof StaticNode) {
|
|
@@ -59903,12 +60407,24 @@ function fileUnchanged2(filePath, cached) {
|
|
|
59903
60407
|
return false;
|
|
59904
60408
|
}
|
|
59905
60409
|
}
|
|
59906
|
-
function
|
|
60410
|
+
function hasServerMiddleware2(nodes) {
|
|
60411
|
+
for (const node of nodes) {
|
|
60412
|
+
if (node.hasMiddleware)
|
|
60413
|
+
return true;
|
|
60414
|
+
if (node.children?.length && hasServerMiddleware2(node.children))
|
|
60415
|
+
return true;
|
|
60416
|
+
}
|
|
60417
|
+
return false;
|
|
60418
|
+
}
|
|
60419
|
+
function buildRouterOpts2(options, serverMiddleware) {
|
|
59907
60420
|
const ttl = options?.routeDataCache;
|
|
60421
|
+
const opts = [];
|
|
60422
|
+
if (serverMiddleware)
|
|
60423
|
+
opts.push("serverMiddleware: true");
|
|
59908
60424
|
if (typeof ttl === "number" && ttl > 0) {
|
|
59909
|
-
|
|
60425
|
+
opts.push(`routeDataCache: ${ttl}`);
|
|
59910
60426
|
}
|
|
59911
|
-
return "";
|
|
60427
|
+
return opts.length ? `, { ${opts.join(", ")} }` : "";
|
|
59912
60428
|
}
|
|
59913
60429
|
function findRuntimeSrc3(appDir) {
|
|
59914
60430
|
const monorepoRoot = resolve24(__dirname7, "..", "..", "..");
|
|
@@ -59964,7 +60480,7 @@ function isAnyImport2(node) {
|
|
|
59964
60480
|
return node.type === "ImportDeclaration";
|
|
59965
60481
|
}
|
|
59966
60482
|
function isRuntimePreamble2(node) {
|
|
59967
|
-
if (node.type === "FunctionDeclaration" && (node.id?.name === "__cleanup" || node.id?.name === "__place")) {
|
|
60483
|
+
if (node.type === "FunctionDeclaration" && (node.id?.name === "__cleanup" || node.id?.name === "__place" || node.id?.name === "__reconcileRegion")) {
|
|
59968
60484
|
return true;
|
|
59969
60485
|
}
|
|
59970
60486
|
if (node.type === "VariableDeclaration") {
|
|
@@ -61198,12 +61714,13 @@ async function buildMainBundle2(routeTree, runtimeDir, codeSplit, mono, hmr, imp
|
|
|
61198
61714
|
` : runtimeCode + "\n";
|
|
61199
61715
|
const cleanupFn = "function __cleanup(start, end) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n}\n";
|
|
61200
61716
|
const placeFn = "function __place(start, end, nodes, fallback) {\n if (start.parentNode !== null) {\n const p = start.parentNode;\n for (let i = 0; i < nodes.length; i++) p.insertBefore(nodes[i], end);\n return;\n }\n if (nodes.length > 0 && nodes[0].parentNode) {\n const p = nodes[0].parentNode;\n p.insertBefore(start, nodes[0]);\n p.insertBefore(end, nodes[nodes.length - 1].nextSibling);\n // Client-surplus nodes (SSR rendered fewer items than the client data)\n // are freshly claimed and still detached \u2014 move them into the region in\n // client order before `end`, instead of stranding them off-parent.\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].parentNode === null) p.insertBefore(nodes[i], end);\n }\n return;\n }\n fallback.appendChild(start);\n fallback.appendChild(end);\n for (let i = 0; i < nodes.length; i++) fallback.insertBefore(nodes[i], end);\n}\n";
|
|
61717
|
+
const reconcileRegionFn = "function __reconcileRegion(parent, id, branch, walker) {\n if (!parent) return;\n let start = null;\n let end = null;\n for (let n = parent.firstChild; n; n = n.nextSibling) {\n if (n.nodeType !== 8) continue;\n const text = n.textContent || '';\n if (text === 'vesk-r:' + id + ':0' || text === 'vesk-r:' + id + ':1') start = n;\n else if (text === 'vesk-r-end:' + id) end = n;\n if (start && end) break;\n }\n if (!start || !end) return;\n const ssrBranch = (start.textContent || '').slice(-2) === ':1' ? 1 : 0;\n if (ssrBranch !== branch) {\n let n = start.nextSibling;\n while (n && n !== end) {\n const next = n.nextSibling;\n n.remove();\n n = next;\n }\n if (walker && walker.retireDetached) walker.retireDetached();\n }\n start.remove();\n end.remove();\n}\n";
|
|
61201
61718
|
const updateComponentsFn = "function __updateComponents(nodes) {\n for (const n of nodes) {\n if (n._pageName && __components[n._pageName]) n.page = __components[n._pageName];\n if (n._layoutName && __components[n._layoutName]) n.layout = __components[n._layoutName];\n if (n._errorName && __components[n._errorName]) n.error = __components[n._errorName];\n if (n._notFoundName && __components[n._notFoundName]) n.notFound = __components[n._notFoundName];\n if (n._offlineName && __components[n._offlineName]) n.offline = __components[n._offlineName];\n if (n._networkName && __components[n._networkName]) n.network = __components[n._networkName];\n if (n.children) __updateComponents(n.children);\n }\n}\n";
|
|
61202
61719
|
const routeTreeJson = JSON.stringify(routeTree);
|
|
61203
61720
|
if (codeSplit) {
|
|
61204
61721
|
const resolveNamesFn = "function __resolveNames(nodes) {\n for (const n of nodes) {\n if (n.chunk) n._chunk = n.chunk;\n if (n.chunkError) n._chunkError = n.chunkError;\n if (typeof n.page === 'string') n._pageName = n.page;\n if (typeof n.layout === 'string') n._layoutName = n.layout;\n if (typeof n.error === 'string') n._errorName = n.error;\n if (typeof n.notFound === 'string') n._notFoundName = n.notFound;\n if (typeof n.offline === 'string') n._offlineName = n.offline;\n if (typeof n.network === 'string') n._networkName = n.network;\n if (n.children) __resolveNames(n.children);\n }\n}\n";
|
|
61205
61722
|
const pendCode = "const __pendChunks = [];\nconst __currentPath = typeof window !== 'undefined' ? window.location.pathname : '/';\nif (typeof matchRoute === 'function') {\n const __currentMatch = matchRoute(__routeTree, __currentPath);\n if (__currentMatch) {\n for (const n of __currentMatch.matchChain) {\n if (n._chunk && !__pendChunks.includes(n._chunk)) __pendChunks.push(n._chunk);\n }\n }\n}\n";
|
|
61206
|
-
const routerOpts2 = buildRouterOpts2({ routeDataCache });
|
|
61723
|
+
const routerOpts2 = buildRouterOpts2({ routeDataCache }, hasServerMiddleware2(routeTree));
|
|
61207
61724
|
const startRouterCode = `const __startRouter = function() {
|
|
61208
61725
|
__updateComponents(__routeTree);
|
|
61209
61726
|
const __router = createFileRouter(__routeTree${routerOpts2});
|
|
@@ -61242,14 +61759,14 @@ if (__pendChunks.length > 0 && typeof ensureChunk === 'function') {
|
|
|
61242
61759
|
];
|
|
61243
61760
|
const importedSet = new Set(allRuntimeImports);
|
|
61244
61761
|
const runtimeGlobals2 = globalNames.filter((n) => importedSet.has(n)).map((n) => `globalThis.${n} = ${n};
|
|
61245
|
-
`).join("") + "globalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\n\n";
|
|
61762
|
+
`).join("") + "globalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\nglobalThis.__reconcileRegion = __reconcileRegion;\n\n";
|
|
61246
61763
|
const extraGlobals = [...runtimeImportNames || []].filter((n) => n && n !== "default").map((n) => `globalThis.${n} = ${n};
|
|
61247
61764
|
`).join("");
|
|
61248
61765
|
const code2 = preamble + "const __components = globalThis.__components || (globalThis.__components = {});\nconst __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});\nconst __runtime_comps = __components;\n\n" + runtimeGlobals2 + extraGlobals + // Shared app modules run HERE: after the runtime bindings are published,
|
|
61249
61766
|
// before anything can request a route chunk. Earlier (at the top of the
|
|
61250
61767
|
// bundle) `globalThis.track` was still undefined, so every module-scope
|
|
61251
61768
|
// cell in a store was created against a missing runtime.
|
|
61252
|
-
(sharedModuleBundle ? sharedModuleBundle + "\n" : "") + cleanupFn + placeFn + "globalThis.__components = __components;\n" + resolveNamesFn + updateComponentsFn + "const __routeTree = " + routeTreeJson + ";\n__resolveNames(__routeTree);\n" + pendCode + startRouterCode;
|
|
61769
|
+
(sharedModuleBundle ? sharedModuleBundle + "\n" : "") + cleanupFn + placeFn + reconcileRegionFn + "globalThis.__components = __components;\n" + resolveNamesFn + updateComponentsFn + "const __routeTree = " + routeTreeJson + ";\n__resolveNames(__routeTree);\n" + pendCode + startRouterCode;
|
|
61253
61770
|
return hmr ? appendHmrGlobals2(code2) : code2;
|
|
61254
61771
|
}
|
|
61255
61772
|
const componentLines = mono?.componentLines || [];
|
|
@@ -61258,8 +61775,8 @@ if (__pendChunks.length > 0 && typeof ensureChunk === 'function') {
|
|
|
61258
61775
|
const hydratorAliasLines = mono?.hydratorAliasLines || [];
|
|
61259
61776
|
const aliasCode = aliasLines.length > 0 ? aliasLines.join("\n") + "\n" : "";
|
|
61260
61777
|
const hydratorAliasCode = hydratorAliasLines.length > 0 ? hydratorAliasLines.join("\n") + "\n" : "";
|
|
61261
|
-
const routerOpts = buildRouterOpts2({ routeDataCache });
|
|
61262
|
-
const code = preamble + "const __components = {};\nconst __hydrators = {};\nconst __runtime_comps = __components;\n\n" + componentLines.join("\n\n") + "\n" + aliasCode + hydratorLines.join("\n\n") + "\n" + hydratorAliasCode + cleanupFn + placeFn + "globalThis.__components = __components;\nglobalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\n" + allRuntimeImports.map((n) => `globalThis.${n} = ${n};
|
|
61778
|
+
const routerOpts = buildRouterOpts2({ routeDataCache }, hasServerMiddleware2(routeTree));
|
|
61779
|
+
const code = preamble + "const __components = {};\nconst __hydrators = {};\nconst __runtime_comps = __components;\n\n" + componentLines.join("\n\n") + "\n" + aliasCode + hydratorLines.join("\n\n") + "\n" + hydratorAliasCode + cleanupFn + placeFn + reconcileRegionFn + "globalThis.__components = __components;\nglobalThis.__runtime_comps = __runtime_comps;\nglobalThis.__cleanup = __cleanup;\nglobalThis.__place = __place;\nglobalThis.__reconcileRegion = __reconcileRegion;\n" + allRuntimeImports.map((n) => `globalThis.${n} = ${n};
|
|
61263
61780
|
`).join("") + "function __resolveNames(nodes) {\n for (const n of nodes) {\n if (typeof n.page === 'string') {\n n._pageName = n.page;\n n.page = __components[n.page];\n }\n if (typeof n.layout === 'string') {\n n._layoutName = n.layout;\n n.layout = __components[n.layout];\n }\n if (typeof n.error === 'string') n.error = __components[n.error];\n if (typeof n.notFound === 'string') n.notFound = __components[n.notFound];\n if (typeof n.offline === 'string') n.offline = __components[n.offline];\n if (typeof n.network === 'string') n.network = __components[n.network];\n if (n.children) __resolveNames(n.children);\n }\n}\n" + updateComponentsFn + "const __routeTree = " + routeTreeJson + `;
|
|
61264
61781
|
__resolveNames(__routeTree);
|
|
61265
61782
|
const __router = createFileRouter(__routeTree${routerOpts});
|
|
@@ -68827,6 +69344,28 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
68827
69344
|
if (await handleActionRequest(req, res, { url, appDirPath, routeTree, security, maxBodyBytes, plugins: getActiveDevPlugins() })) {
|
|
68828
69345
|
return;
|
|
68829
69346
|
}
|
|
69347
|
+
if (url.pathname === "/_vesk/middleware") {
|
|
69348
|
+
const targetPath = url.searchParams.get("path") || "/";
|
|
69349
|
+
const targetUrl = new URL(targetPath, "http://localhost");
|
|
69350
|
+
const targetChain = collectMiddlewareChain(routeTree, targetUrl.pathname, appDirPath);
|
|
69351
|
+
const rawHeaders = {};
|
|
69352
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
69353
|
+
rawHeaders[k] = Array.isArray(v) ? v.join(", ") : v || "";
|
|
69354
|
+
}
|
|
69355
|
+
const mwReq = new Request(targetUrl.href, { headers: rawHeaders, method: "GET" });
|
|
69356
|
+
const mwResult = await executeMiddlewareChain(targetChain, mwReq, {}, {
|
|
69357
|
+
plugins: getActiveDevPlugins(),
|
|
69358
|
+
onLast: async () => null
|
|
69359
|
+
});
|
|
69360
|
+
res.writeHead(200, { "Content-Type": "application/json; charset=utf-8", "Cache-Control": "no-store" });
|
|
69361
|
+
if (mwResult.response) {
|
|
69362
|
+
const location = mwResult.response.headers.get("location") || mwResult.response.headers.get("Location");
|
|
69363
|
+
res.end(JSON.stringify(location ? { redirect: location } : { allow: true }));
|
|
69364
|
+
return;
|
|
69365
|
+
}
|
|
69366
|
+
res.end(JSON.stringify(mwResult.rewriteUrl ? { rewrite: mwResult.rewriteUrl } : { allow: true }));
|
|
69367
|
+
return;
|
|
69368
|
+
}
|
|
68830
69369
|
const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
|
|
68831
69370
|
const apiDirPath = join28(appDirPath, "api");
|
|
68832
69371
|
if (url.pathname.startsWith("/api") && existsSync44(apiDirPath)) {
|