@vesk/vesk-cli 0.2.27 → 0.2.29
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 +1035 -570
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1796,7 +1796,7 @@ async function runFetcher(handle2, timeout) {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
1798
|
function sleep(ms) {
|
|
1799
|
-
return new Promise((
|
|
1799
|
+
return new Promise((resolve41) => setTimeout(resolve41, ms));
|
|
1800
1800
|
}
|
|
1801
1801
|
function streamText(res, into, onChunk) {
|
|
1802
1802
|
const decoder = new TextDecoder();
|
|
@@ -2174,6 +2174,13 @@ function runInHydrateBlock(fn) {
|
|
|
2174
2174
|
throw error;
|
|
2175
2175
|
}
|
|
2176
2176
|
}
|
|
2177
|
+
function reportHydrationIssue(issue) {
|
|
2178
|
+
if (!__mismatchHandler) return;
|
|
2179
|
+
try {
|
|
2180
|
+
__mismatchHandler(issue);
|
|
2181
|
+
} catch {
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2177
2184
|
function devWarn(message) {
|
|
2178
2185
|
if (__hydrateDevMode && typeof console !== "undefined") {
|
|
2179
2186
|
console.warn("[vesk-hydrate] " + message);
|
|
@@ -2476,12 +2483,12 @@ function hydrateViewport(container, componentFn, props, rootMargin = 500, option
|
|
|
2476
2483
|
let cancelled = false;
|
|
2477
2484
|
let cancelFn = () => {
|
|
2478
2485
|
};
|
|
2479
|
-
const promise = new Promise((
|
|
2486
|
+
const promise = new Promise((resolve41) => {
|
|
2480
2487
|
const finish = () => {
|
|
2481
2488
|
cancelled = true;
|
|
2482
2489
|
cancelFn = () => {
|
|
2483
2490
|
};
|
|
2484
|
-
|
|
2491
|
+
resolve41();
|
|
2485
2492
|
};
|
|
2486
2493
|
cancelFn = finish;
|
|
2487
2494
|
if (!batchAlive(container, epoch, isCurrent)) return finish();
|
|
@@ -2818,6 +2825,22 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
2818
2825
|
if (this.idx > this.markers.length) this.idx = this.markers.length;
|
|
2819
2826
|
return new _WalkerEngine(rootEl, owned.map((m) => m.comment));
|
|
2820
2827
|
}
|
|
2828
|
+
// Ownership transfer for an explicit marker subset (layout slot contract).
|
|
2829
|
+
// The listed markers are marked claimed here without advancing the cursor:
|
|
2830
|
+
// positional claims skip them, and a scoped walker built over the same
|
|
2831
|
+
// comments owns them exclusively. Exactly one engine owns each marker.
|
|
2832
|
+
takeMarkers(comments) {
|
|
2833
|
+
let owned;
|
|
2834
|
+
try {
|
|
2835
|
+
owned = new Set(comments);
|
|
2836
|
+
} catch {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (owned.size === 0) return;
|
|
2840
|
+
for (const tm of this.markers) {
|
|
2841
|
+
if (tm.state !== "claimed" && owned.has(tm.comment)) tm.state = "claimed";
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2821
2844
|
// Retire every unclaimed marker in the whole walk that points at `el`.
|
|
2822
2845
|
// Used after a cross-position adopt (relocate): the adopted node moves to
|
|
2823
2846
|
// the cursor, so alias markers stacked at its old station would otherwise
|
|
@@ -2912,6 +2935,92 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
|
|
|
2912
2935
|
}
|
|
2913
2936
|
});
|
|
2914
2937
|
|
|
2938
|
+
// ../runtime/src/layout.ts
|
|
2939
|
+
function slotIdentity(text, prefix) {
|
|
2940
|
+
if (text === prefix) return { id: "" };
|
|
2941
|
+
if (typeof text !== "string") return null;
|
|
2942
|
+
const want = prefix + ":";
|
|
2943
|
+
if (text.length > want.length && text.startsWith(want)) return { id: text.slice(want.length) };
|
|
2944
|
+
return null;
|
|
2945
|
+
}
|
|
2946
|
+
function slotOpenId(text) {
|
|
2947
|
+
return slotIdentity(text, LAYOUT_SLOT_OPEN);
|
|
2948
|
+
}
|
|
2949
|
+
function slotCloseId(text) {
|
|
2950
|
+
return slotIdentity(text, LAYOUT_SLOT_CLOSE);
|
|
2951
|
+
}
|
|
2952
|
+
function auditLayoutSlots(container) {
|
|
2953
|
+
let unbalanced = 0;
|
|
2954
|
+
let leftoverInSlot = 0;
|
|
2955
|
+
try {
|
|
2956
|
+
const walker = document.createTreeWalker(container, _SHOW_COMMENT2, {
|
|
2957
|
+
acceptNode: (node) => {
|
|
2958
|
+
const t = node.textContent;
|
|
2959
|
+
if (slotOpenId(t) !== null || slotCloseId(t) !== null || isVskMarkerText(t)) return _FILTER_ACCEPT2;
|
|
2960
|
+
return _FILTER_SKIP2;
|
|
2961
|
+
}
|
|
2962
|
+
});
|
|
2963
|
+
const stack = [];
|
|
2964
|
+
while (walker.nextNode()) {
|
|
2965
|
+
const c = walker.currentNode;
|
|
2966
|
+
const t = c.textContent;
|
|
2967
|
+
const open = slotOpenId(t);
|
|
2968
|
+
if (open !== null) {
|
|
2969
|
+
stack.push(open.id);
|
|
2970
|
+
continue;
|
|
2971
|
+
}
|
|
2972
|
+
const close = slotCloseId(t);
|
|
2973
|
+
if (close !== null) {
|
|
2974
|
+
if (stack.length === 0) {
|
|
2975
|
+
unbalanced++;
|
|
2976
|
+
reportHydrationIssue({
|
|
2977
|
+
kind: "marker-skew",
|
|
2978
|
+
detail: "layout slot close without a matching open \u2014 SSR/client slot structure diverges; slot content may misorder."
|
|
2979
|
+
});
|
|
2980
|
+
continue;
|
|
2981
|
+
}
|
|
2982
|
+
const top = stack.pop();
|
|
2983
|
+
if (top !== "" && close.id !== "" && top !== close.id) {
|
|
2984
|
+
unbalanced++;
|
|
2985
|
+
reportHydrationIssue({
|
|
2986
|
+
kind: "marker-skew",
|
|
2987
|
+
detail: `layout slot id mismatch: open "${top}" closed by "${close.id}" \u2014 SSR/client slot structure diverges; slot content may misorder.`
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
continue;
|
|
2991
|
+
}
|
|
2992
|
+
if (stack.length > 0 && isVskMarkerText(t)) leftoverInSlot++;
|
|
2993
|
+
}
|
|
2994
|
+
if (stack.length > 0) {
|
|
2995
|
+
unbalanced++;
|
|
2996
|
+
reportHydrationIssue({
|
|
2997
|
+
kind: "marker-skew",
|
|
2998
|
+
detail: "layout slot open without a matching close \u2014 SSR/client slot structure diverges; slot content may misorder."
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
if (leftoverInSlot > 0) {
|
|
3002
|
+
reportHydrationIssue({
|
|
3003
|
+
kind: "leftover-marker",
|
|
3004
|
+
detail: `${leftoverInSlot} hydration marker(s) survived inside a layout slot region; the page rendered differently than SSR \u2014 duplication risk.`
|
|
3005
|
+
});
|
|
3006
|
+
}
|
|
3007
|
+
} catch {
|
|
3008
|
+
}
|
|
3009
|
+
return { ok: unbalanced === 0 && leftoverInSlot === 0, unbalanced, leftoverInSlot };
|
|
3010
|
+
}
|
|
3011
|
+
var LAYOUT_SLOT_OPEN, LAYOUT_SLOT_CLOSE, _SHOW_COMMENT2, _FILTER_ACCEPT2, _FILTER_SKIP2;
|
|
3012
|
+
var init_layout = __esm({
|
|
3013
|
+
"../runtime/src/layout.ts"() {
|
|
3014
|
+
"use strict";
|
|
3015
|
+
init_hydrate();
|
|
3016
|
+
LAYOUT_SLOT_OPEN = "vsk-slot";
|
|
3017
|
+
LAYOUT_SLOT_CLOSE = "vsk-slot-end";
|
|
3018
|
+
_SHOW_COMMENT2 = 128;
|
|
3019
|
+
_FILTER_ACCEPT2 = 1;
|
|
3020
|
+
_FILTER_SKIP2 = 2;
|
|
3021
|
+
}
|
|
3022
|
+
});
|
|
3023
|
+
|
|
2915
3024
|
// ../runtime/src/router-match.ts
|
|
2916
3025
|
function flattenLayoutChain(tree, pathParts, result = []) {
|
|
2917
3026
|
for (let i = 0; i < tree.length; i++) {
|
|
@@ -3769,7 +3878,7 @@ function ensureChunk(chunkUrl) {
|
|
|
3769
3878
|
if (typeof document === "undefined" || typeof document.createElement !== "function") {
|
|
3770
3879
|
return Promise.resolve();
|
|
3771
3880
|
}
|
|
3772
|
-
const promise = new Promise((
|
|
3881
|
+
const promise = new Promise((resolve41, reject) => {
|
|
3773
3882
|
const s = document.createElement("script");
|
|
3774
3883
|
s.src = chunkUrl;
|
|
3775
3884
|
let settled = false;
|
|
@@ -3788,7 +3897,7 @@ function ensureChunk(chunkUrl) {
|
|
|
3788
3897
|
loadedChunks.add(chunkUrl);
|
|
3789
3898
|
inFlightChunks.delete(chunkUrl);
|
|
3790
3899
|
failedChunks.delete(chunkUrl);
|
|
3791
|
-
|
|
3900
|
+
resolve41();
|
|
3792
3901
|
};
|
|
3793
3902
|
s.onerror = () => {
|
|
3794
3903
|
fail(new Error(`Failed to load chunk: ${chunkUrl}`));
|
|
@@ -4656,6 +4765,12 @@ async function hydrateInitial(router, match, container, strategy) {
|
|
|
4656
4765
|
setIsHydrating(true);
|
|
4657
4766
|
const walker = createHydrateWalker(container);
|
|
4658
4767
|
await runInBlockWindow(() => renderLayoutChain2(0)(walker));
|
|
4768
|
+
if (!strategy || strategy === "full") {
|
|
4769
|
+
try {
|
|
4770
|
+
auditLayoutSlots(container);
|
|
4771
|
+
} catch {
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4659
4774
|
setIsHydrating(false);
|
|
4660
4775
|
} catch (error) {
|
|
4661
4776
|
setIsHydrating(false);
|
|
@@ -5473,6 +5588,7 @@ var init_router = __esm({
|
|
|
5473
5588
|
init_ripple_runtime();
|
|
5474
5589
|
init_ripple_blocks();
|
|
5475
5590
|
init_hydrate();
|
|
5591
|
+
init_layout();
|
|
5476
5592
|
init_router_match();
|
|
5477
5593
|
init_router_components();
|
|
5478
5594
|
init_network();
|
|
@@ -17843,32 +17959,6 @@ function tokenizeCode(code) {
|
|
|
17843
17959
|
return null;
|
|
17844
17960
|
}
|
|
17845
17961
|
}
|
|
17846
|
-
function collectCalledIdentifiers(code) {
|
|
17847
|
-
const tokens = tokenizeCode(code);
|
|
17848
|
-
if (tokens !== null) {
|
|
17849
|
-
const result = /* @__PURE__ */ new Set();
|
|
17850
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
17851
|
-
const t = tokens[i];
|
|
17852
|
-
if (t.label !== "name") continue;
|
|
17853
|
-
const prev = i > 0 ? tokens[i - 1] : null;
|
|
17854
|
-
if (prev && (prev.label === "." || prev.label === "?.")) {
|
|
17855
|
-
const obj = i >= 2 ? tokens[i - 2] : null;
|
|
17856
|
-
const next2 = tokens[i + 1];
|
|
17857
|
-
if (obj && obj.label === "name" && next2) {
|
|
17858
|
-
const nextCh2 = code[next2.start];
|
|
17859
|
-
if (nextCh2 === "(" || nextCh2 === "<") result.add(obj.value);
|
|
17860
|
-
}
|
|
17861
|
-
continue;
|
|
17862
|
-
}
|
|
17863
|
-
const next = tokens[i + 1];
|
|
17864
|
-
if (!next) continue;
|
|
17865
|
-
const nextCh = code[next.start];
|
|
17866
|
-
if (nextCh === "(" || nextCh === "<") result.add(t.value);
|
|
17867
|
-
}
|
|
17868
|
-
return result;
|
|
17869
|
-
}
|
|
17870
|
-
return manualCollectCalledIdentifiers(code);
|
|
17871
|
-
}
|
|
17872
17962
|
function containsIdentifier(code, name) {
|
|
17873
17963
|
const tokens = tokenizeCode(code);
|
|
17874
17964
|
if (tokens !== null) {
|
|
@@ -17944,44 +18034,6 @@ function importModuleTarget(importText) {
|
|
|
17944
18034
|
}
|
|
17945
18035
|
return null;
|
|
17946
18036
|
}
|
|
17947
|
-
function manualCollectCalledIdentifiers(code) {
|
|
17948
|
-
const result = /* @__PURE__ */ new Set();
|
|
17949
|
-
let i = 0;
|
|
17950
|
-
let prevIdent = null;
|
|
17951
|
-
while (i < code.length) {
|
|
17952
|
-
const c = code[i];
|
|
17953
|
-
if (c === '"' || c === "'" || c === "`") {
|
|
17954
|
-
i = skipString(code, i);
|
|
17955
|
-
continue;
|
|
17956
|
-
}
|
|
17957
|
-
if (c === "/" && (code[i + 1] === "/" || code[i + 1] === "*")) {
|
|
17958
|
-
i = skipComment(code, i);
|
|
17959
|
-
continue;
|
|
17960
|
-
}
|
|
17961
|
-
if (isIdentStart(c)) {
|
|
17962
|
-
let j = i + 1;
|
|
17963
|
-
while (j < code.length && isIdentChar(code[j])) j++;
|
|
17964
|
-
const before = i === 0 ? "" : code[i - 1];
|
|
17965
|
-
if (before !== "." && !isIdentChar(before)) {
|
|
17966
|
-
let k = skipWhitespace(code, j);
|
|
17967
|
-
if (code[k] === "<") k = skipTrackGeneric(code, k);
|
|
17968
|
-
if (code[k] === "(") result.add(code.slice(i, j));
|
|
17969
|
-
} else if (before === "." && prevIdent) {
|
|
17970
|
-
let p = i - 1;
|
|
17971
|
-
while (p > prevIdent[1] && (code[p] === "." || code[p] === "?" || code[p] === "\n" || code[p] === " " || code[p] === " ")) p--;
|
|
17972
|
-
if (p === prevIdent[1]) {
|
|
17973
|
-
let k = skipWhitespace(code, j);
|
|
17974
|
-
if (code[k] === "(") result.add(code.slice(prevIdent[0], prevIdent[1]));
|
|
17975
|
-
}
|
|
17976
|
-
}
|
|
17977
|
-
prevIdent = [i, j];
|
|
17978
|
-
i = j;
|
|
17979
|
-
continue;
|
|
17980
|
-
}
|
|
17981
|
-
i++;
|
|
17982
|
-
}
|
|
17983
|
-
return result;
|
|
17984
|
-
}
|
|
17985
18037
|
function manualContainsIdentifier(code, name) {
|
|
17986
18038
|
let i = 0;
|
|
17987
18039
|
while (i < code.length) {
|
|
@@ -19216,6 +19268,65 @@ function estreeCallsFetch(ast) {
|
|
|
19216
19268
|
}
|
|
19217
19269
|
return false;
|
|
19218
19270
|
}
|
|
19271
|
+
function memberReceiverName(obj) {
|
|
19272
|
+
if (!obj || typeof obj !== "object") return null;
|
|
19273
|
+
const rec = obj;
|
|
19274
|
+
if (rec.type === "Identifier" && typeof rec.name === "string") return rec.name;
|
|
19275
|
+
const prop = rec.type === "MemberExpression" && !rec.computed ? rec.property : null;
|
|
19276
|
+
if (prop && typeof prop === "object" && prop.type === "Identifier") {
|
|
19277
|
+
const propName = prop.name;
|
|
19278
|
+
if (typeof propName === "string") return propName;
|
|
19279
|
+
}
|
|
19280
|
+
return null;
|
|
19281
|
+
}
|
|
19282
|
+
function collectCallAndJsxTargets(ast) {
|
|
19283
|
+
const targets = /* @__PURE__ */ new Set();
|
|
19284
|
+
const stack = [ast];
|
|
19285
|
+
while (stack.length > 0) {
|
|
19286
|
+
const candidate = stack.pop();
|
|
19287
|
+
if (!candidate || typeof candidate !== "object") continue;
|
|
19288
|
+
const node = candidate;
|
|
19289
|
+
if (typeof node.type === "string") {
|
|
19290
|
+
if (node.type === "CallExpression" || node.type === "NewExpression") {
|
|
19291
|
+
const callee = node.callee;
|
|
19292
|
+
if (callee && typeof callee === "object") {
|
|
19293
|
+
const c = callee;
|
|
19294
|
+
if (c.type === "Identifier" && typeof c.name === "string" && node.optional !== true) {
|
|
19295
|
+
targets.add(c.name);
|
|
19296
|
+
} else if (c.type === "MemberExpression" && !c.computed && node.optional !== true) {
|
|
19297
|
+
const receiverName = memberReceiverName(c.object);
|
|
19298
|
+
if (receiverName) targets.add(receiverName);
|
|
19299
|
+
}
|
|
19300
|
+
}
|
|
19301
|
+
} else if (node.type === "JSXElement") {
|
|
19302
|
+
const opening = node.openingElement;
|
|
19303
|
+
const tag = opening && typeof opening === "object" ? opening.name : null;
|
|
19304
|
+
if (tag && typeof tag === "object") {
|
|
19305
|
+
const t = tag;
|
|
19306
|
+
if (t.type === "JSXIdentifier" && typeof t.name === "string") {
|
|
19307
|
+
targets.add(t.name);
|
|
19308
|
+
} else if (t.type === "JSXMemberExpression") {
|
|
19309
|
+
const prop = t.property;
|
|
19310
|
+
if (prop && typeof prop === "object" && prop.type === "JSXIdentifier") {
|
|
19311
|
+
const propName = prop.name;
|
|
19312
|
+
if (typeof propName === "string") targets.add(propName);
|
|
19313
|
+
}
|
|
19314
|
+
}
|
|
19315
|
+
}
|
|
19316
|
+
}
|
|
19317
|
+
for (const key of Object.keys(node)) {
|
|
19318
|
+
if (key === "parent" || key === "loc" || key === "start" || key === "end" || key === "range") continue;
|
|
19319
|
+
const value = node[key];
|
|
19320
|
+
if (Array.isArray(value)) {
|
|
19321
|
+
for (const item of value) stack.push(item);
|
|
19322
|
+
} else {
|
|
19323
|
+
stack.push(value);
|
|
19324
|
+
}
|
|
19325
|
+
}
|
|
19326
|
+
}
|
|
19327
|
+
}
|
|
19328
|
+
return targets;
|
|
19329
|
+
}
|
|
19219
19330
|
function componentUsesFetch(nodes) {
|
|
19220
19331
|
for (const node of nodes) {
|
|
19221
19332
|
if (node instanceof ServerBlock || node instanceof ClientBlock) {
|
|
@@ -20207,9 +20318,9 @@ function generateIR(ast, source, filename) {
|
|
|
20207
20318
|
const asyncNames = new Set(components.filter((c) => c.isAsync || c.ssrAwait).map((c) => c.name));
|
|
20208
20319
|
for (const comp of components) {
|
|
20209
20320
|
if (asyncNames.has(comp.name)) continue;
|
|
20210
|
-
const
|
|
20211
|
-
collectComponentCalls(comp.body,
|
|
20212
|
-
for (const [childName, start] of
|
|
20321
|
+
const called2 = /* @__PURE__ */ new Map();
|
|
20322
|
+
collectComponentCalls(comp.body, called2);
|
|
20323
|
+
for (const [childName, start] of called2) {
|
|
20213
20324
|
if (!asyncNames.has(childName)) continue;
|
|
20214
20325
|
const { line, column } = offsetToLineCol2(source, start >= 0 ? start : 0);
|
|
20215
20326
|
throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, code: codeFrame(source, line, column) });
|
|
@@ -20270,74 +20381,11 @@ function generateIR(ast, source, filename) {
|
|
|
20270
20381
|
"Switch",
|
|
20271
20382
|
"Match"
|
|
20272
20383
|
];
|
|
20384
|
+
const called = collectCallAndJsxTargets(ast);
|
|
20273
20385
|
const usedFunctions = /* @__PURE__ */ new Set();
|
|
20274
|
-
const
|
|
20275
|
-
|
|
20276
|
-
for (const fn of autoImportable) {
|
|
20277
|
-
if (called.has(fn)) usedFunctions.add(fn);
|
|
20278
|
-
}
|
|
20279
|
-
};
|
|
20280
|
-
for (const code of topLevelCode) addUsedFrom(code);
|
|
20281
|
-
for (const code of [loadFn, staticProps]) {
|
|
20282
|
-
if (code) addUsedFrom(code);
|
|
20386
|
+
for (const fn of autoImportable) {
|
|
20387
|
+
if (called.has(fn)) usedFunctions.add(fn);
|
|
20283
20388
|
}
|
|
20284
|
-
function scanForAutoImport(nodes) {
|
|
20285
|
-
for (const node of nodes) {
|
|
20286
|
-
if (node instanceof RuntimeStatement && node.raw) {
|
|
20287
|
-
addUsedFrom(node.raw);
|
|
20288
|
-
}
|
|
20289
|
-
if (node instanceof TrackDecl && node.init) {
|
|
20290
|
-
addUsedFrom(node.init);
|
|
20291
|
-
}
|
|
20292
|
-
if (node instanceof ForLoop) {
|
|
20293
|
-
if (node.init) addUsedFrom(node.init);
|
|
20294
|
-
if (node.update) addUsedFrom(node.update);
|
|
20295
|
-
if (node.condition && node.condition.raw) addUsedFrom(node.condition.raw);
|
|
20296
|
-
scanForAutoImport(node.bodyTemplate);
|
|
20297
|
-
}
|
|
20298
|
-
if (node instanceof WhileLoop) {
|
|
20299
|
-
if (node.condition && node.condition.raw) addUsedFrom(node.condition.raw);
|
|
20300
|
-
scanForAutoImport(node.bodyTemplate);
|
|
20301
|
-
}
|
|
20302
|
-
if (node instanceof SwitchBlock) {
|
|
20303
|
-
if (node.discriminant && node.discriminant.raw) addUsedFrom(node.discriminant.raw);
|
|
20304
|
-
for (const c of node.cases) {
|
|
20305
|
-
if (c.test && c.test.raw) addUsedFrom(c.test.raw);
|
|
20306
|
-
scanForAutoImport(c.body);
|
|
20307
|
-
}
|
|
20308
|
-
}
|
|
20309
|
-
if (node instanceof TryCatch) {
|
|
20310
|
-
scanForAutoImport(node.bodyTemplate);
|
|
20311
|
-
scanForAutoImport(node.catchBody);
|
|
20312
|
-
}
|
|
20313
|
-
if (node instanceof ComponentCall) {
|
|
20314
|
-
if (autoImportable.includes(node.componentName)) {
|
|
20315
|
-
usedFunctions.add(node.componentName);
|
|
20316
|
-
}
|
|
20317
|
-
for (const prop of node.props) {
|
|
20318
|
-
if (prop.value && prop.value.raw) {
|
|
20319
|
-
addUsedFrom(prop.value.raw);
|
|
20320
|
-
}
|
|
20321
|
-
}
|
|
20322
|
-
scanForAutoImport(node.children);
|
|
20323
|
-
}
|
|
20324
|
-
if (node instanceof MapRegion) {
|
|
20325
|
-
scanForAutoImport(node.bodyTemplate);
|
|
20326
|
-
scanForAutoImport(node.alternateNodes);
|
|
20327
|
-
}
|
|
20328
|
-
if (node instanceof OpaqueDynamicRegion) {
|
|
20329
|
-
scanForAutoImport(node.consequentNodes);
|
|
20330
|
-
scanForAutoImport(node.alternateNodes);
|
|
20331
|
-
}
|
|
20332
|
-
if (node instanceof DynamicBinding && node.expression && node.expression.raw) {
|
|
20333
|
-
addUsedFrom(node.expression.raw);
|
|
20334
|
-
}
|
|
20335
|
-
if (node instanceof StaticNode || node instanceof ServerBlock || node instanceof ClientBlock || node instanceof HeadBlock) {
|
|
20336
|
-
scanForAutoImport(node.children);
|
|
20337
|
-
}
|
|
20338
|
-
}
|
|
20339
|
-
}
|
|
20340
|
-
scanForAutoImport(components.flatMap((c) => c.body));
|
|
20341
20389
|
if (usedFunctions.size > 0) {
|
|
20342
20390
|
const existing = /* @__PURE__ */ new Set();
|
|
20343
20391
|
for (const imp of imports) {
|
|
@@ -26350,7 +26398,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26350
26398
|
let latestResultPromise;
|
|
26351
26399
|
let provideLatestResult;
|
|
26352
26400
|
if (isContext)
|
|
26353
|
-
requestCallbacks["on-end"] = (id, request2) => new Promise((
|
|
26401
|
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve41) => {
|
|
26354
26402
|
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
|
26355
26403
|
const response = {
|
|
26356
26404
|
errors: onEndErrors,
|
|
@@ -26360,7 +26408,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26360
26408
|
latestResultPromise = void 0;
|
|
26361
26409
|
provideLatestResult = void 0;
|
|
26362
26410
|
sendResponse(id, response);
|
|
26363
|
-
|
|
26411
|
+
resolve41();
|
|
26364
26412
|
});
|
|
26365
26413
|
});
|
|
26366
26414
|
sendRequest(refs, request, (error, response) => {
|
|
@@ -26377,10 +26425,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26377
26425
|
let didDispose = false;
|
|
26378
26426
|
const result = {
|
|
26379
26427
|
rebuild: () => {
|
|
26380
|
-
if (!latestResultPromise) latestResultPromise = new Promise((
|
|
26428
|
+
if (!latestResultPromise) latestResultPromise = new Promise((resolve41, reject) => {
|
|
26381
26429
|
let settlePromise;
|
|
26382
26430
|
provideLatestResult = (err, result2) => {
|
|
26383
|
-
if (!settlePromise) settlePromise = () => err ? reject(err) :
|
|
26431
|
+
if (!settlePromise) settlePromise = () => err ? reject(err) : resolve41(result2);
|
|
26384
26432
|
};
|
|
26385
26433
|
const triggerAnotherBuild = () => {
|
|
26386
26434
|
const request2 = {
|
|
@@ -26401,7 +26449,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26401
26449
|
});
|
|
26402
26450
|
return latestResultPromise;
|
|
26403
26451
|
},
|
|
26404
|
-
watch: (options2 = {}) => new Promise((
|
|
26452
|
+
watch: (options2 = {}) => new Promise((resolve41, reject) => {
|
|
26405
26453
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "watch" API in this environment`);
|
|
26406
26454
|
const keys = {};
|
|
26407
26455
|
const delay = getFlag(options2, keys, "delay", mustBeInteger);
|
|
@@ -26413,10 +26461,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26413
26461
|
if (delay) request2.delay = delay;
|
|
26414
26462
|
sendRequest(refs, request2, (error2) => {
|
|
26415
26463
|
if (error2) reject(new Error(error2));
|
|
26416
|
-
else
|
|
26464
|
+
else resolve41(void 0);
|
|
26417
26465
|
});
|
|
26418
26466
|
}),
|
|
26419
|
-
serve: (options2 = {}) => new Promise((
|
|
26467
|
+
serve: (options2 = {}) => new Promise((resolve41, reject) => {
|
|
26420
26468
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
|
|
26421
26469
|
const keys = {};
|
|
26422
26470
|
const port = getFlag(options2, keys, "port", mustBeValidPortNumber);
|
|
@@ -26454,28 +26502,28 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26454
26502
|
sendResponse(id, {});
|
|
26455
26503
|
};
|
|
26456
26504
|
}
|
|
26457
|
-
|
|
26505
|
+
resolve41(response2);
|
|
26458
26506
|
});
|
|
26459
26507
|
}),
|
|
26460
|
-
cancel: () => new Promise((
|
|
26461
|
-
if (didDispose) return
|
|
26508
|
+
cancel: () => new Promise((resolve41) => {
|
|
26509
|
+
if (didDispose) return resolve41();
|
|
26462
26510
|
const request2 = {
|
|
26463
26511
|
command: "cancel",
|
|
26464
26512
|
key: buildKey
|
|
26465
26513
|
};
|
|
26466
26514
|
sendRequest(refs, request2, () => {
|
|
26467
|
-
|
|
26515
|
+
resolve41();
|
|
26468
26516
|
});
|
|
26469
26517
|
}),
|
|
26470
|
-
dispose: () => new Promise((
|
|
26471
|
-
if (didDispose) return
|
|
26518
|
+
dispose: () => new Promise((resolve41) => {
|
|
26519
|
+
if (didDispose) return resolve41();
|
|
26472
26520
|
didDispose = true;
|
|
26473
26521
|
const request2 = {
|
|
26474
26522
|
command: "dispose",
|
|
26475
26523
|
key: buildKey
|
|
26476
26524
|
};
|
|
26477
26525
|
sendRequest(refs, request2, () => {
|
|
26478
|
-
|
|
26526
|
+
resolve41();
|
|
26479
26527
|
scheduleOnDisposeCallbacks();
|
|
26480
26528
|
refs.unref();
|
|
26481
26529
|
});
|
|
@@ -26514,7 +26562,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26514
26562
|
onLoad: []
|
|
26515
26563
|
};
|
|
26516
26564
|
i++;
|
|
26517
|
-
let
|
|
26565
|
+
let resolve41 = (path3, options = {}) => {
|
|
26518
26566
|
if (!isSetupDone) throw new Error('Cannot call "resolve" before plugin setup has completed');
|
|
26519
26567
|
if (typeof path3 !== "string") throw new Error(`The path to resolve must be a string`);
|
|
26520
26568
|
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
@@ -26558,7 +26606,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
26558
26606
|
};
|
|
26559
26607
|
let promise = setup({
|
|
26560
26608
|
initialOptions,
|
|
26561
|
-
resolve:
|
|
26609
|
+
resolve: resolve41,
|
|
26562
26610
|
onStart(callback) {
|
|
26563
26611
|
let registeredText = `This error came from the "onStart" callback registered here:`;
|
|
26564
26612
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
|
@@ -27251,46 +27299,46 @@ More information: The file containing the code for esbuild's JavaScript API (${_
|
|
|
27251
27299
|
}
|
|
27252
27300
|
};
|
|
27253
27301
|
longLivedService = {
|
|
27254
|
-
build: (options) => new Promise((
|
|
27302
|
+
build: (options) => new Promise((resolve41, reject) => {
|
|
27255
27303
|
service.buildOrContext({
|
|
27256
27304
|
callName: "build",
|
|
27257
27305
|
refs,
|
|
27258
27306
|
options,
|
|
27259
27307
|
isTTY: isTTY(),
|
|
27260
27308
|
defaultWD,
|
|
27261
|
-
callback: (err, res) => err ? reject(err) :
|
|
27309
|
+
callback: (err, res) => err ? reject(err) : resolve41(res)
|
|
27262
27310
|
});
|
|
27263
27311
|
}),
|
|
27264
|
-
context: (options) => new Promise((
|
|
27312
|
+
context: (options) => new Promise((resolve41, reject) => service.buildOrContext({
|
|
27265
27313
|
callName: "context",
|
|
27266
27314
|
refs,
|
|
27267
27315
|
options,
|
|
27268
27316
|
isTTY: isTTY(),
|
|
27269
27317
|
defaultWD,
|
|
27270
|
-
callback: (err, res) => err ? reject(err) :
|
|
27318
|
+
callback: (err, res) => err ? reject(err) : resolve41(res)
|
|
27271
27319
|
})),
|
|
27272
|
-
transform: (input, options) => new Promise((
|
|
27320
|
+
transform: (input, options) => new Promise((resolve41, reject) => service.transform({
|
|
27273
27321
|
callName: "transform",
|
|
27274
27322
|
refs,
|
|
27275
27323
|
input,
|
|
27276
27324
|
options: options || {},
|
|
27277
27325
|
isTTY: isTTY(),
|
|
27278
27326
|
fs: fsAsync,
|
|
27279
|
-
callback: (err, res) => err ? reject(err) :
|
|
27327
|
+
callback: (err, res) => err ? reject(err) : resolve41(res)
|
|
27280
27328
|
})),
|
|
27281
|
-
formatMessages: (messages, options) => new Promise((
|
|
27329
|
+
formatMessages: (messages, options) => new Promise((resolve41, reject) => service.formatMessages({
|
|
27282
27330
|
callName: "formatMessages",
|
|
27283
27331
|
refs,
|
|
27284
27332
|
messages,
|
|
27285
27333
|
options,
|
|
27286
|
-
callback: (err, res) => err ? reject(err) :
|
|
27334
|
+
callback: (err, res) => err ? reject(err) : resolve41(res)
|
|
27287
27335
|
})),
|
|
27288
|
-
analyzeMetafile: (metafile, options) => new Promise((
|
|
27336
|
+
analyzeMetafile: (metafile, options) => new Promise((resolve41, reject) => service.analyzeMetafile({
|
|
27289
27337
|
callName: "analyzeMetafile",
|
|
27290
27338
|
refs,
|
|
27291
27339
|
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
27292
27340
|
options,
|
|
27293
|
-
callback: (err, res) => err ? reject(err) :
|
|
27341
|
+
callback: (err, res) => err ? reject(err) : resolve41(res)
|
|
27294
27342
|
}))
|
|
27295
27343
|
};
|
|
27296
27344
|
return longLivedService;
|
|
@@ -27368,13 +27416,13 @@ error: ${text}`);
|
|
|
27368
27416
|
worker.postMessage(msg);
|
|
27369
27417
|
let status = Atomics.wait(sharedBufferView, 0, 0);
|
|
27370
27418
|
if (status !== "ok" && status !== "not-equal") throw new Error("Internal error: Atomics.wait() failed: " + status);
|
|
27371
|
-
let { message: { id: id2, resolve:
|
|
27419
|
+
let { message: { id: id2, resolve: resolve41, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
|
27372
27420
|
if (id !== id2) throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
|
27373
27421
|
if (reject) {
|
|
27374
27422
|
applyProperties(reject, properties);
|
|
27375
27423
|
throw reject;
|
|
27376
27424
|
}
|
|
27377
|
-
return
|
|
27425
|
+
return resolve41;
|
|
27378
27426
|
};
|
|
27379
27427
|
worker.unref();
|
|
27380
27428
|
return {
|
|
@@ -28231,8 +28279,9 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
|
|
|
28231
28279
|
if (ctx2.hydrate) {
|
|
28232
28280
|
ctx2.push(`if (props.children !== undefined && props.children !== null) {`);
|
|
28233
28281
|
ctx2.push(` if (typeof props.children === 'function') {`);
|
|
28234
|
-
ctx2.push(` const
|
|
28235
|
-
ctx2.push(`
|
|
28282
|
+
ctx2.push(` const __slot = createLayoutSlot(${ctx2.walker}, ${parentVar});`);
|
|
28283
|
+
ctx2.push(` const __child = props.children(__slot.walker);`);
|
|
28284
|
+
ctx2.push(` if (__child && typeof __child.then === 'function') __pendingChild = __slot.track(__child);`);
|
|
28236
28285
|
ctx2.push(` } else {`);
|
|
28237
28286
|
ctx2.push(` ${parentVar}.appendChild(props.children);`);
|
|
28238
28287
|
ctx2.push(` }`);
|
|
@@ -28312,7 +28361,58 @@ function emitStatic(ctx2, node, tracked2, effectsVar) {
|
|
|
28312
28361
|
let residueBefore = 0;
|
|
28313
28362
|
for (const child of children) {
|
|
28314
28363
|
let childVar;
|
|
28315
|
-
|
|
28364
|
+
const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR(child.children);
|
|
28365
|
+
if (isPureStaticChild) {
|
|
28366
|
+
const ssrEl = `${el}.__vsk_ssrEls[${residueBefore}]`;
|
|
28367
|
+
childVar = ssrEl;
|
|
28368
|
+
const dynAttrs2 = [];
|
|
28369
|
+
const staticChildren = [];
|
|
28370
|
+
for (const c of child.children) {
|
|
28371
|
+
if (c instanceof DynamicBinding && c.kind === "attribute") {
|
|
28372
|
+
dynAttrs2.push(c);
|
|
28373
|
+
} else {
|
|
28374
|
+
staticChildren.push(c);
|
|
28375
|
+
}
|
|
28376
|
+
}
|
|
28377
|
+
for (const attr of dynAttrs2) {
|
|
28378
|
+
const target = attr.target || "";
|
|
28379
|
+
const isEvent2 = target.startsWith("on") && target.length > 2;
|
|
28380
|
+
if (target === "ref") {
|
|
28381
|
+
const expr = transformTracked(attr.expression, tracked2);
|
|
28382
|
+
ctx2.push(`(${expr})(${ssrEl});`);
|
|
28383
|
+
} else if (isEvent2) {
|
|
28384
|
+
const eventName = target.slice(2).toLowerCase();
|
|
28385
|
+
const handler = transformTracked(attr.expression, tracked2);
|
|
28386
|
+
if (NON_BUBBLING_EVENTS.has(eventName)) {
|
|
28387
|
+
ctx2.directEvents.add(eventName);
|
|
28388
|
+
ctx2.push(`${ssrEl}.addEventListener(${JSON.stringify(eventName)}, ${handler});`);
|
|
28389
|
+
} else {
|
|
28390
|
+
const prop = `__evh_${eventName}`;
|
|
28391
|
+
ctx2.delegatedEvents.add(eventName);
|
|
28392
|
+
ctx2.push(`${ssrEl}.${prop} = ${handler};`);
|
|
28393
|
+
}
|
|
28394
|
+
ctx2.push(`${ssrEl}.setAttribute('data-vsk-ev', '');`);
|
|
28395
|
+
} else if (target === "style") {
|
|
28396
|
+
const expr = transformTracked(attr.expression, tracked2);
|
|
28397
|
+
const eff = `effect(() => { applyStyle(${ssrEl}, ${expr}); })`;
|
|
28398
|
+
if (effectsVar) {
|
|
28399
|
+
ctx2.push(`${effectsVar}.push(${eff});`);
|
|
28400
|
+
} else {
|
|
28401
|
+
ctx2.effects.push(`${eff};`);
|
|
28402
|
+
}
|
|
28403
|
+
} else {
|
|
28404
|
+
const expr = transformTracked(attr.expression, tracked2);
|
|
28405
|
+
const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
|
|
28406
|
+
const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
|
|
28407
|
+
if (effectsVar) {
|
|
28408
|
+
ctx2.push(`${effectsVar}.push(${eff});`);
|
|
28409
|
+
} else {
|
|
28410
|
+
ctx2.effects.push(`${eff};`);
|
|
28411
|
+
}
|
|
28412
|
+
}
|
|
28413
|
+
}
|
|
28414
|
+
childVar = ssrEl;
|
|
28415
|
+
} else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
|
|
28316
28416
|
childVar = emitDynamicBinding(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
|
|
28317
28417
|
} else {
|
|
28318
28418
|
childVar = emitNode(ctx2, child, tracked2, effectsVar, el);
|
|
@@ -29615,7 +29715,7 @@ function emitClientFromIR(ir, options) {
|
|
|
29615
29715
|
if (ir.components.some((c) => hasKeyedMap(c.body))) runtimeNames.push("reconcile");
|
|
29616
29716
|
if (options.hydrate && ir.components.some((c) => hasKeyedMap(c.body))) runtimeNames.push("reconcileHydrated");
|
|
29617
29717
|
if (options.hydrate) {
|
|
29618
|
-
const hydrateNames = ["hydrate", "hydrateViewport", "hydrateIdle", "hydrateOnInteraction", "needsHydration", "createHydrateWalker", "collectVskMarkers", "reactiveProps"];
|
|
29718
|
+
const hydrateNames = ["hydrate", "hydrateViewport", "hydrateIdle", "hydrateOnInteraction", "needsHydration", "createHydrateWalker", "collectVskMarkers", "reactiveProps", "createLayoutSlot"];
|
|
29619
29719
|
for (const name of hydrateNames) {
|
|
29620
29720
|
if (!runtimeNames.includes(name)) runtimeNames.push(name);
|
|
29621
29721
|
}
|
|
@@ -29649,11 +29749,11 @@ function compileClient(source, _componentName, options = {}) {
|
|
|
29649
29749
|
const ir = generateIR(ast, source, options.sourcePath);
|
|
29650
29750
|
return emitClientFromIR(ir, { ...options, nameAllocator: options.nameAllocator ?? nameAllocFor(options.sourcePath) });
|
|
29651
29751
|
}
|
|
29652
|
-
function compileClientBoth(source, _componentName, sourcePath2) {
|
|
29752
|
+
function compileClientBoth(source, _componentName, sourcePath2, opts) {
|
|
29653
29753
|
const ast = parse4(source, sourcePath2 ? { filename: sourcePath2 } : {});
|
|
29654
|
-
const hydAst = structuredClone(ast);
|
|
29754
|
+
const hydAst = opts?.skipHyd ? null : structuredClone(ast);
|
|
29655
29755
|
const ir = generateIR(ast, source, sourcePath2);
|
|
29656
|
-
const irHyd = generateIR(hydAst, source, sourcePath2);
|
|
29756
|
+
const irHyd = opts?.skipHyd ? null : generateIR(hydAst, source, sourcePath2);
|
|
29657
29757
|
const defaultComp = ir.components.find((c) => c.defaultExport);
|
|
29658
29758
|
let name = null;
|
|
29659
29759
|
if (defaultComp) name = defaultComp.name;
|
|
@@ -29663,8 +29763,10 @@ function compileClientBoth(source, _componentName, sourcePath2) {
|
|
|
29663
29763
|
if (exportedComp) name = exportedComp.name;
|
|
29664
29764
|
}
|
|
29665
29765
|
const alloc = nameAllocFor(sourcePath2);
|
|
29766
|
+
const comp = emitClientFromIR(ir, { forceClient: true, nameAllocator: alloc });
|
|
29767
|
+
if (opts?.skipHyd) return { comp, hyd: "", name };
|
|
29666
29768
|
return {
|
|
29667
|
-
comp
|
|
29769
|
+
comp,
|
|
29668
29770
|
hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
|
|
29669
29771
|
name
|
|
29670
29772
|
};
|
|
@@ -29797,7 +29899,7 @@ function irNodeToJS(node, importedNames, isAsync = false, tracked2) {
|
|
|
29797
29899
|
if (node instanceof StaticNode) return staticNodeToJS(node, isAsync, tracked2);
|
|
29798
29900
|
if (node instanceof TextNode) {
|
|
29799
29901
|
if (!node.value) return "";
|
|
29800
|
-
return `__out.push(${JSON.stringify(node.value)});`;
|
|
29902
|
+
return `__out.push(${JSON.stringify(escapeHtml(node.value))});`;
|
|
29801
29903
|
}
|
|
29802
29904
|
if (node instanceof DynamicBinding) return dynamicBindingToJS(node, tracked2);
|
|
29803
29905
|
if (node instanceof OpaqueDynamicRegion) return opaqueRegionToJS(node, isAsync, tracked2);
|
|
@@ -29837,7 +29939,10 @@ function irNodeToJS(node, importedNames, isAsync = false, tracked2) {
|
|
|
29837
29939
|
].join("\n");
|
|
29838
29940
|
}
|
|
29839
29941
|
if (node instanceof RuntimeStatement) return semicolonizeStatement(transformTracked(node, tracked2 || /* @__PURE__ */ new Map()));
|
|
29840
|
-
if (node instanceof SlotNode)
|
|
29942
|
+
if (node instanceof SlotNode) {
|
|
29943
|
+
const sid = `s${nextVskId()}`;
|
|
29944
|
+
return `__out.push('<!--vsk-slot:${sid}-->');__out.push(props.children || '');__out.push('<!--vsk-slot-end:${sid}-->');`;
|
|
29945
|
+
}
|
|
29841
29946
|
if (node instanceof PropSlotRender) return `__out.push(props.${node.propName} || '');`;
|
|
29842
29947
|
if (node instanceof PropSlot) return "";
|
|
29843
29948
|
return "";
|
|
@@ -37040,8 +37145,8 @@ __export(typecheck_exports, {
|
|
|
37040
37145
|
formatTypecheckWarnings: () => formatTypecheckWarnings,
|
|
37041
37146
|
typecheckProject: () => typecheckProject
|
|
37042
37147
|
});
|
|
37043
|
-
import { readFileSync as
|
|
37044
|
-
import { join as
|
|
37148
|
+
import { readFileSync as readFileSync39, readdirSync as readdirSync14, statSync as statSync22 } from "node:fs";
|
|
37149
|
+
import { join as join25, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
|
|
37045
37150
|
import * as ts8 from "typescript";
|
|
37046
37151
|
function walkProjectFiles(projectRoot) {
|
|
37047
37152
|
const code = [];
|
|
@@ -37054,7 +37159,7 @@ function walkProjectFiles(projectRoot) {
|
|
|
37054
37159
|
return;
|
|
37055
37160
|
}
|
|
37056
37161
|
for (const e of entries) {
|
|
37057
|
-
const p =
|
|
37162
|
+
const p = join25(dir, e);
|
|
37058
37163
|
let st;
|
|
37059
37164
|
try {
|
|
37060
37165
|
st = statSync22(p);
|
|
@@ -37082,8 +37187,8 @@ function walkProjectFiles(projectRoot) {
|
|
|
37082
37187
|
return { code, js };
|
|
37083
37188
|
}
|
|
37084
37189
|
function isUnder(dir, file) {
|
|
37085
|
-
const base =
|
|
37086
|
-
const abs =
|
|
37190
|
+
const base = resolve39(dir);
|
|
37191
|
+
const abs = resolve39(file);
|
|
37087
37192
|
return abs === base || abs.startsWith(base + sep7);
|
|
37088
37193
|
}
|
|
37089
37194
|
function structureWarning(rel, message) {
|
|
@@ -37109,8 +37214,8 @@ function checkStructureFile(appDir, file) {
|
|
|
37109
37214
|
return null;
|
|
37110
37215
|
}
|
|
37111
37216
|
function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
37112
|
-
const ambientPath =
|
|
37113
|
-
const overridePath =
|
|
37217
|
+
const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
|
|
37218
|
+
const overridePath = join25(appDir, "__vesk_runtime_override.d.ts");
|
|
37114
37219
|
const cached = /* @__PURE__ */ new Map();
|
|
37115
37220
|
const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
|
|
37116
37221
|
const host = {
|
|
@@ -37180,7 +37285,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
37180
37285
|
directoryExists: (dir) => ts8.sys.directoryExists(dir),
|
|
37181
37286
|
getDirectories: (dir) => {
|
|
37182
37287
|
try {
|
|
37183
|
-
return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) =>
|
|
37288
|
+
return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join25(dir, d.name));
|
|
37184
37289
|
} catch {
|
|
37185
37290
|
return [];
|
|
37186
37291
|
}
|
|
@@ -37191,7 +37296,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
37191
37296
|
resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options) {
|
|
37192
37297
|
return moduleLiterals.map(({ text }) => {
|
|
37193
37298
|
if (text.endsWith(".vsk")) {
|
|
37194
|
-
const abs = normalize(
|
|
37299
|
+
const abs = normalize(join25(dirname27(containingFile), text));
|
|
37195
37300
|
return {
|
|
37196
37301
|
resolvedModule: {
|
|
37197
37302
|
resolvedFileName: abs + ".d.ts",
|
|
@@ -37202,7 +37307,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
37202
37307
|
};
|
|
37203
37308
|
}
|
|
37204
37309
|
if (text.endsWith(".css")) {
|
|
37205
|
-
const abs = normalize(
|
|
37310
|
+
const abs = normalize(join25(dirname27(containingFile), text));
|
|
37206
37311
|
return {
|
|
37207
37312
|
resolvedModule: {
|
|
37208
37313
|
resolvedFileName: abs + ".d.ts",
|
|
@@ -37220,7 +37325,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
37220
37325
|
return host;
|
|
37221
37326
|
}
|
|
37222
37327
|
function typecheckProject(projectRoot, opts = {}) {
|
|
37223
|
-
const appDir = opts.appDir ??
|
|
37328
|
+
const appDir = opts.appDir ?? join25(projectRoot, "app");
|
|
37224
37329
|
const vskFiles = /* @__PURE__ */ new Map();
|
|
37225
37330
|
const parseErrors = [];
|
|
37226
37331
|
const warnings = [];
|
|
@@ -37242,7 +37347,7 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
37242
37347
|
}
|
|
37243
37348
|
}
|
|
37244
37349
|
if (f.endsWith(".vsk")) {
|
|
37245
|
-
const src2 =
|
|
37350
|
+
const src2 = readFileSync39(f, "utf-8");
|
|
37246
37351
|
try {
|
|
37247
37352
|
parse4(src2);
|
|
37248
37353
|
} catch (e) {
|
|
@@ -37259,8 +37364,8 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
37259
37364
|
}
|
|
37260
37365
|
rootNames.push(f);
|
|
37261
37366
|
}
|
|
37262
|
-
const ambientPath =
|
|
37263
|
-
const overridePath =
|
|
37367
|
+
const ambientPath = join25(appDir, "__vesk_ambient.d.ts");
|
|
37368
|
+
const overridePath = join25(appDir, "__vesk_runtime_override.d.ts");
|
|
37264
37369
|
rootNames.push(ambientPath);
|
|
37265
37370
|
rootNames.push(overridePath);
|
|
37266
37371
|
const options = {
|
|
@@ -37824,8 +37929,8 @@ declare module '@vesk/runtime' {
|
|
|
37824
37929
|
});
|
|
37825
37930
|
|
|
37826
37931
|
// src/index.ts
|
|
37827
|
-
import { readFileSync as
|
|
37828
|
-
import { resolve as
|
|
37932
|
+
import { readFileSync as readFileSync40, writeFileSync as writeFileSync21, mkdirSync as mkdirSync18, existsSync as existsSync43 } from "fs";
|
|
37933
|
+
import { resolve as resolve40, join as join26 } from "path";
|
|
37829
37934
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
37830
37935
|
|
|
37831
37936
|
// ../adapter/dist/load-config.js
|
|
@@ -39719,6 +39824,10 @@ function isComponentExport(node) {
|
|
|
39719
39824
|
}
|
|
39720
39825
|
return false;
|
|
39721
39826
|
}
|
|
39827
|
+
function isSnippetDrop(node) {
|
|
39828
|
+
if (isAnyImport(node) || isComponentExport(node) || isRuntimePreamble(node)) return true;
|
|
39829
|
+
return node.type === "VariableDeclaration" && (node.declarations?.[0]?.id?.name === "__components" || node.declarations?.[0]?.id?.name === "__hydrators");
|
|
39830
|
+
}
|
|
39722
39831
|
function extractCompiledNodes(code, isTarget) {
|
|
39723
39832
|
let ast;
|
|
39724
39833
|
try {
|
|
@@ -39909,12 +40018,42 @@ function scopeFileContribution(code) {
|
|
|
39909
40018
|
return code;
|
|
39910
40019
|
}
|
|
39911
40020
|
}
|
|
40021
|
+
function stripAndDemoteInOnePass(code) {
|
|
40022
|
+
let ast;
|
|
40023
|
+
try {
|
|
40024
|
+
ast = parse4(code);
|
|
40025
|
+
} catch {
|
|
40026
|
+
return code;
|
|
40027
|
+
}
|
|
40028
|
+
const body = ast.body ?? [];
|
|
40029
|
+
const edits = [];
|
|
40030
|
+
for (const raw2 of body) {
|
|
40031
|
+
const node = raw2;
|
|
40032
|
+
if (typeof node.start !== "number" || typeof node.end !== "number") continue;
|
|
40033
|
+
const isExport = node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration";
|
|
40034
|
+
if (isSnippetDrop(node)) {
|
|
40035
|
+
let cut = node.end;
|
|
40036
|
+
if (code[cut] === ";") cut++;
|
|
40037
|
+
if (code.startsWith("\r\n", cut)) cut += 2;
|
|
40038
|
+
else if (code[cut] === "\n" || code[cut] === "\r") cut++;
|
|
40039
|
+
edits.push({ start: node.start, end: cut });
|
|
40040
|
+
} else if (isExport && node.type === "ExportNamedDeclaration" && node.declaration && typeof node.declaration.start === "number" && typeof node.declaration.end === "number") {
|
|
40041
|
+
edits.push({ start: node.start, end: node.end, text: code.slice(node.declaration.start, node.declaration.end) });
|
|
40042
|
+
} else if (isExport) {
|
|
40043
|
+
let cut = node.end;
|
|
40044
|
+
if (code[cut] === ";") cut++;
|
|
40045
|
+
edits.push({ start: node.start, end: cut });
|
|
40046
|
+
}
|
|
40047
|
+
}
|
|
40048
|
+
if (edits.length === 0) return code;
|
|
40049
|
+
edits.sort((a, b) => b.start - a.start);
|
|
40050
|
+
for (const e of edits) {
|
|
40051
|
+
code = code.slice(0, e.start) + (e.text ?? "") + code.slice(e.end);
|
|
40052
|
+
}
|
|
40053
|
+
return code;
|
|
40054
|
+
}
|
|
39912
40055
|
function buildHmrEvalSnippet(code) {
|
|
39913
|
-
const
|
|
39914
|
-
if (isAnyImport(node) || isComponentExport(node) || isRuntimePreamble(node)) return true;
|
|
39915
|
-
return node.type === "VariableDeclaration" && (node.declarations?.[0]?.id?.name === "__components" || node.declarations?.[0]?.id?.name === "__hydrators");
|
|
39916
|
-
};
|
|
39917
|
-
const body = demoteExports(removeCompiledNodes(code, isSnippetDrop)).trim();
|
|
40056
|
+
const body = stripAndDemoteInOnePass(code).trim();
|
|
39918
40057
|
if (!body) return "";
|
|
39919
40058
|
const scoped = `{
|
|
39920
40059
|
${body}
|
|
@@ -41457,8 +41596,8 @@ vesk build: done (${outDir})`);
|
|
|
41457
41596
|
init_seo_audit();
|
|
41458
41597
|
|
|
41459
41598
|
// src/dev-server.ts
|
|
41460
|
-
import { readFileSync as
|
|
41461
|
-
import { resolve as
|
|
41599
|
+
import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
|
|
41600
|
+
import { resolve as resolve38, extname as extname8, join as join24, dirname as dirname26 } from "node:path";
|
|
41462
41601
|
import { createServer as createServer2 } from "node:http";
|
|
41463
41602
|
import { WebSocketServer as WebSocketServer2 } from "ws";
|
|
41464
41603
|
|
|
@@ -42054,8 +42193,9 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
|
|
|
42054
42193
|
if (ctx2.hydrate) {
|
|
42055
42194
|
ctx2.push(`if (props.children !== undefined && props.children !== null) {`);
|
|
42056
42195
|
ctx2.push(` if (typeof props.children === 'function') {`);
|
|
42057
|
-
ctx2.push(` const
|
|
42058
|
-
ctx2.push(`
|
|
42196
|
+
ctx2.push(` const __slot = createLayoutSlot(${ctx2.walker}, ${parentVar});`);
|
|
42197
|
+
ctx2.push(` const __child = props.children(__slot.walker);`);
|
|
42198
|
+
ctx2.push(` if (__child && typeof __child.then === 'function') __pendingChild = __slot.track(__child);`);
|
|
42059
42199
|
ctx2.push(` } else {`);
|
|
42060
42200
|
ctx2.push(` ${parentVar}.appendChild(props.children);`);
|
|
42061
42201
|
ctx2.push(` }`);
|
|
@@ -42153,7 +42293,58 @@ function emitStatic2(ctx2, node, tracked2, effectsVar) {
|
|
|
42153
42293
|
let residueBefore = 0;
|
|
42154
42294
|
for (const child of children) {
|
|
42155
42295
|
let childVar;
|
|
42156
|
-
|
|
42296
|
+
const isPureStaticChild = ctx2.hydrate && child instanceof StaticNode && isStaticIR2(child.children);
|
|
42297
|
+
if (isPureStaticChild) {
|
|
42298
|
+
const ssrEl = `${el}.__vsk_ssrEls[${residueBefore}]`;
|
|
42299
|
+
childVar = ssrEl;
|
|
42300
|
+
const dynAttrs2 = [];
|
|
42301
|
+
const staticChildren = [];
|
|
42302
|
+
for (const c of child.children) {
|
|
42303
|
+
if (c instanceof DynamicBinding && c.kind === "attribute") {
|
|
42304
|
+
dynAttrs2.push(c);
|
|
42305
|
+
} else {
|
|
42306
|
+
staticChildren.push(c);
|
|
42307
|
+
}
|
|
42308
|
+
}
|
|
42309
|
+
for (const attr of dynAttrs2) {
|
|
42310
|
+
const target = attr.target || "";
|
|
42311
|
+
const isEvent2 = target.startsWith("on") && target.length > 2;
|
|
42312
|
+
if (target === "ref") {
|
|
42313
|
+
const expr = transformTracked2(attr.expression, tracked2);
|
|
42314
|
+
ctx2.push(`(${expr})(${ssrEl});`);
|
|
42315
|
+
} else if (isEvent2) {
|
|
42316
|
+
const eventName = target.slice(2).toLowerCase();
|
|
42317
|
+
const handler = transformTracked2(attr.expression, tracked2);
|
|
42318
|
+
if (NON_BUBBLING_EVENTS2.has(eventName)) {
|
|
42319
|
+
ctx2.directEvents.add(eventName);
|
|
42320
|
+
ctx2.push(`${ssrEl}.addEventListener(${JSON.stringify(eventName)}, ${handler});`);
|
|
42321
|
+
} else {
|
|
42322
|
+
const prop = `__evh_${eventName}`;
|
|
42323
|
+
ctx2.delegatedEvents.add(eventName);
|
|
42324
|
+
ctx2.push(`${ssrEl}.${prop} = ${handler};`);
|
|
42325
|
+
}
|
|
42326
|
+
ctx2.push(`${ssrEl}.setAttribute('data-vsk-ev', '');`);
|
|
42327
|
+
} else if (target === "style") {
|
|
42328
|
+
const expr = transformTracked2(attr.expression, tracked2);
|
|
42329
|
+
const eff = `effect(() => { applyStyle(${ssrEl}, ${expr}); })`;
|
|
42330
|
+
if (effectsVar) {
|
|
42331
|
+
ctx2.push(`${effectsVar}.push(${eff});`);
|
|
42332
|
+
} else {
|
|
42333
|
+
ctx2.effects.push(`${eff};`);
|
|
42334
|
+
}
|
|
42335
|
+
} else {
|
|
42336
|
+
const expr = transformTracked2(attr.expression, tracked2);
|
|
42337
|
+
const useProp = PROPERTY_ATTRS2[node.tag]?.has(target);
|
|
42338
|
+
const eff = useProp ? `effect(() => { ${ssrEl}.${target} = ${expr}; })` : `effect(() => { const __v = ${expr}; if (__v != null && __v !== false) ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
|
|
42339
|
+
if (effectsVar) {
|
|
42340
|
+
ctx2.push(`${effectsVar}.push(${eff});`);
|
|
42341
|
+
} else {
|
|
42342
|
+
ctx2.effects.push(`${eff};`);
|
|
42343
|
+
}
|
|
42344
|
+
}
|
|
42345
|
+
}
|
|
42346
|
+
childVar = ssrEl;
|
|
42347
|
+
} else if (singleReactiveText && child instanceof DynamicBinding && child.kind === "text") {
|
|
42157
42348
|
childVar = emitDynamicBinding2(ctx2, child, tracked2, effectsVar, `${el}.__vsk_ssrText`);
|
|
42158
42349
|
} else {
|
|
42159
42350
|
childVar = emitNode2(ctx2, child, tracked2, effectsVar, el);
|
|
@@ -43632,7 +43823,7 @@ function emitClientFromIR2(ir, options) {
|
|
|
43632
43823
|
if (options.hydrate && ir.components.some((c) => hasKeyedMap2(c.body)))
|
|
43633
43824
|
runtimeNames.push("reconcileHydrated");
|
|
43634
43825
|
if (options.hydrate) {
|
|
43635
|
-
const hydrateNames = ["hydrate", "hydrateViewport", "hydrateIdle", "hydrateOnInteraction", "needsHydration", "createHydrateWalker", "collectVskMarkers", "reactiveProps"];
|
|
43826
|
+
const hydrateNames = ["hydrate", "hydrateViewport", "hydrateIdle", "hydrateOnInteraction", "needsHydration", "createHydrateWalker", "collectVskMarkers", "reactiveProps", "createLayoutSlot"];
|
|
43636
43827
|
for (const name of hydrateNames) {
|
|
43637
43828
|
if (!runtimeNames.includes(name))
|
|
43638
43829
|
runtimeNames.push(name);
|
|
@@ -43668,6 +43859,32 @@ function compileClient2(source, _componentName, options = {}) {
|
|
|
43668
43859
|
const ir = generateIR(ast, source, options.sourcePath);
|
|
43669
43860
|
return emitClientFromIR2(ir, { ...options, nameAllocator: options.nameAllocator ?? nameAllocFor2(options.sourcePath) });
|
|
43670
43861
|
}
|
|
43862
|
+
function compileClientBoth2(source, _componentName, sourcePath2, opts) {
|
|
43863
|
+
const ast = parse4(source, sourcePath2 ? { filename: sourcePath2 } : {});
|
|
43864
|
+
const hydAst = opts?.skipHyd ? null : structuredClone(ast);
|
|
43865
|
+
const ir = generateIR(ast, source, sourcePath2);
|
|
43866
|
+
const irHyd = opts?.skipHyd ? null : generateIR(hydAst, source, sourcePath2);
|
|
43867
|
+
const defaultComp = ir.components.find((c) => c.defaultExport);
|
|
43868
|
+
let name = null;
|
|
43869
|
+
if (defaultComp)
|
|
43870
|
+
name = defaultComp.name;
|
|
43871
|
+
else if (ir.components.length > 0)
|
|
43872
|
+
name = ir.components[0].name;
|
|
43873
|
+
else {
|
|
43874
|
+
const exportedComp = ir.components.find((c) => c.exported);
|
|
43875
|
+
if (exportedComp)
|
|
43876
|
+
name = exportedComp.name;
|
|
43877
|
+
}
|
|
43878
|
+
const alloc = nameAllocFor2(sourcePath2);
|
|
43879
|
+
const comp = emitClientFromIR2(ir, { forceClient: true, nameAllocator: alloc });
|
|
43880
|
+
if (opts?.skipHyd)
|
|
43881
|
+
return { comp, hyd: "", name };
|
|
43882
|
+
return {
|
|
43883
|
+
comp,
|
|
43884
|
+
hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc }),
|
|
43885
|
+
name
|
|
43886
|
+
};
|
|
43887
|
+
}
|
|
43671
43888
|
|
|
43672
43889
|
// ../compiler/dist/router.js
|
|
43673
43890
|
init_parser();
|
|
@@ -44698,9 +44915,115 @@ async function runEventHandlers(handlers, name, ctx2) {
|
|
|
44698
44915
|
await fn(ctx2);
|
|
44699
44916
|
}
|
|
44700
44917
|
|
|
44918
|
+
// ../compiler/dist/md-inline.js
|
|
44919
|
+
import { readFileSync as readFileSync23, existsSync as existsSync27 } from "node:fs";
|
|
44920
|
+
import { dirname as dirname17, join as join17, resolve as resolve23 } from "node:path";
|
|
44921
|
+
var MD_EXT_MARKER2 = ".md";
|
|
44922
|
+
function looksLikeMarkdownPath2(value) {
|
|
44923
|
+
const v = value.trim();
|
|
44924
|
+
if (v.length === 0 || v.length > 4096)
|
|
44925
|
+
return false;
|
|
44926
|
+
if (v.includes("\n") || v.includes("\r"))
|
|
44927
|
+
return false;
|
|
44928
|
+
const lower = v.toLowerCase();
|
|
44929
|
+
return lower.endsWith(MD_EXT_MARKER2) || lower.endsWith(".markdown");
|
|
44930
|
+
}
|
|
44931
|
+
function isRelativeSpecifier2(v) {
|
|
44932
|
+
return v.startsWith("./") || v.startsWith("../");
|
|
44933
|
+
}
|
|
44934
|
+
function inlineMdContentAttrs2(source, importerDir, mdRoots = []) {
|
|
44935
|
+
if (!source.includes("content=") && !source.includes("content ="))
|
|
44936
|
+
return source;
|
|
44937
|
+
if (!importerDir && mdRoots.length === 0)
|
|
44938
|
+
return source;
|
|
44939
|
+
let out = "";
|
|
44940
|
+
let i = 0;
|
|
44941
|
+
const n = source.length;
|
|
44942
|
+
let counter = 0;
|
|
44943
|
+
const decls = [];
|
|
44944
|
+
const prefix = "content=";
|
|
44945
|
+
while (i < n) {
|
|
44946
|
+
if (source.startsWith(prefix, i)) {
|
|
44947
|
+
const prev = i > 0 ? source[i - 1] : " ";
|
|
44948
|
+
if (prev === " " || prev === " " || prev === "\n" || prev === "\r") {
|
|
44949
|
+
let j = i + prefix.length;
|
|
44950
|
+
const quote = source[j];
|
|
44951
|
+
if (quote === '"' || quote === "'") {
|
|
44952
|
+
j++;
|
|
44953
|
+
const valStart = j;
|
|
44954
|
+
while (j < n && source[j] !== quote)
|
|
44955
|
+
j++;
|
|
44956
|
+
if (j < n) {
|
|
44957
|
+
const value = source.slice(valStart, j);
|
|
44958
|
+
if (looksLikeMarkdownPath2(value)) {
|
|
44959
|
+
const abs = resolveMdPath2(value, importerDir, mdRoots);
|
|
44960
|
+
if (abs !== null) {
|
|
44961
|
+
let contents;
|
|
44962
|
+
try {
|
|
44963
|
+
contents = readFileSync23(abs, "utf-8");
|
|
44964
|
+
} catch {
|
|
44965
|
+
out += source[i];
|
|
44966
|
+
i++;
|
|
44967
|
+
continue;
|
|
44968
|
+
}
|
|
44969
|
+
const varName = `__vesk_md_${counter++}`;
|
|
44970
|
+
decls.push(`const ${varName} = ${JSON.stringify(contents)};`);
|
|
44971
|
+
out += `${prefix}{${varName}}`;
|
|
44972
|
+
i = j + 1;
|
|
44973
|
+
continue;
|
|
44974
|
+
}
|
|
44975
|
+
}
|
|
44976
|
+
}
|
|
44977
|
+
}
|
|
44978
|
+
}
|
|
44979
|
+
}
|
|
44980
|
+
out += source[i];
|
|
44981
|
+
i++;
|
|
44982
|
+
}
|
|
44983
|
+
if (decls.length === 0)
|
|
44984
|
+
return source;
|
|
44985
|
+
return decls.join("\n") + "\n" + out;
|
|
44986
|
+
}
|
|
44987
|
+
function resolveMdPath2(specifier, importerDir, roots) {
|
|
44988
|
+
const spec = specifier.trim();
|
|
44989
|
+
if (isRelativeSpecifier2(spec)) {
|
|
44990
|
+
if (!importerDir)
|
|
44991
|
+
return null;
|
|
44992
|
+
const abs = resolve23(importerDir, spec);
|
|
44993
|
+
return existsSync27(abs) ? abs : null;
|
|
44994
|
+
}
|
|
44995
|
+
if (spec.startsWith("/")) {
|
|
44996
|
+
for (const root3 of roots) {
|
|
44997
|
+
const pub = join17(root3, "public", spec);
|
|
44998
|
+
if (existsSync27(pub))
|
|
44999
|
+
return pub;
|
|
45000
|
+
const direct = join17(root3, spec);
|
|
45001
|
+
if (existsSync27(direct))
|
|
45002
|
+
return direct;
|
|
45003
|
+
}
|
|
45004
|
+
}
|
|
45005
|
+
return null;
|
|
45006
|
+
}
|
|
45007
|
+
function guessProjectRoots2(dir) {
|
|
45008
|
+
if (!dir)
|
|
45009
|
+
return [];
|
|
45010
|
+
const roots = [];
|
|
45011
|
+
let cur = dir;
|
|
45012
|
+
for (let i = 0; i < 6; i++) {
|
|
45013
|
+
roots.push(cur);
|
|
45014
|
+
if (existsSync27(join17(cur, "package.json")))
|
|
45015
|
+
break;
|
|
45016
|
+
const parent = dirname17(cur);
|
|
45017
|
+
if (parent === cur)
|
|
45018
|
+
break;
|
|
45019
|
+
cur = parent;
|
|
45020
|
+
}
|
|
45021
|
+
return roots;
|
|
45022
|
+
}
|
|
45023
|
+
|
|
44701
45024
|
// ../adapter/dist/client-bundle.js
|
|
44702
|
-
import { readFileSync as
|
|
44703
|
-
import { resolve as
|
|
45025
|
+
import { readFileSync as readFileSync24, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync14, rmSync as rmSync4, mkdtempSync as mkdtempSync2 } from "node:fs";
|
|
45026
|
+
import { resolve as resolve24, join as join18, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
|
|
44704
45027
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
44705
45028
|
|
|
44706
45029
|
// ../adapter/dist/esbuild-fallback.js
|
|
@@ -44757,7 +45080,7 @@ init_client_codegen();
|
|
|
44757
45080
|
init_vsk_imports();
|
|
44758
45081
|
init_md_inline();
|
|
44759
45082
|
init_module_imports();
|
|
44760
|
-
var __dirname7 =
|
|
45083
|
+
var __dirname7 = dirname18(fileURLToPath6(import.meta.url));
|
|
44761
45084
|
function fileUnchanged2(filePath, cached) {
|
|
44762
45085
|
try {
|
|
44763
45086
|
const st = statSync14(filePath);
|
|
@@ -44774,15 +45097,15 @@ function buildRouterOpts2(options) {
|
|
|
44774
45097
|
return "";
|
|
44775
45098
|
}
|
|
44776
45099
|
function findRuntimeSrc3(appDir) {
|
|
44777
|
-
const monorepoRoot =
|
|
45100
|
+
const monorepoRoot = resolve24(__dirname7, "..", "..", "..");
|
|
44778
45101
|
const candidates = [
|
|
44779
|
-
|
|
44780
|
-
|
|
44781
|
-
|
|
45102
|
+
resolve24(monorepoRoot, "packages", "runtime", "dist"),
|
|
45103
|
+
resolve24(appDir, "..", "node_modules", "@vesk/runtime"),
|
|
45104
|
+
resolve24(appDir, "node_modules", "@vesk/runtime")
|
|
44782
45105
|
];
|
|
44783
45106
|
for (const base of candidates) {
|
|
44784
|
-
for (const dir of [base,
|
|
44785
|
-
if (
|
|
45107
|
+
for (const dir of [base, join18(base, "dist")]) {
|
|
45108
|
+
if (existsSync28(join18(dir, "index-client.js")))
|
|
44786
45109
|
return dir;
|
|
44787
45110
|
}
|
|
44788
45111
|
}
|
|
@@ -44849,6 +45172,11 @@ function isComponentExport2(node) {
|
|
|
44849
45172
|
}
|
|
44850
45173
|
return false;
|
|
44851
45174
|
}
|
|
45175
|
+
function isSnippetDrop2(node) {
|
|
45176
|
+
if (isAnyImport2(node) || isComponentExport2(node) || isRuntimePreamble2(node))
|
|
45177
|
+
return true;
|
|
45178
|
+
return node.type === "VariableDeclaration" && (node.declarations?.[0]?.id?.name === "__components" || node.declarations?.[0]?.id?.name === "__hydrators");
|
|
45179
|
+
}
|
|
44852
45180
|
function extractCompiledNodes2(code, isTarget) {
|
|
44853
45181
|
let ast;
|
|
44854
45182
|
try {
|
|
@@ -44931,7 +45259,7 @@ var ChunkImports2 = class {
|
|
|
44931
45259
|
const src2 = node.source?.value;
|
|
44932
45260
|
if (typeof src2 !== "string")
|
|
44933
45261
|
continue;
|
|
44934
|
-
const resolved = resolveImportPath(src2,
|
|
45262
|
+
const resolved = resolveImportPath(src2, dirname18(filePath));
|
|
44935
45263
|
for (const spec of node.specifiers ?? []) {
|
|
44936
45264
|
const s = spec;
|
|
44937
45265
|
const local = s.local?.name;
|
|
@@ -45057,13 +45385,48 @@ function scopeFileContribution2(code) {
|
|
|
45057
45385
|
return code;
|
|
45058
45386
|
}
|
|
45059
45387
|
}
|
|
45388
|
+
function stripAndDemoteInOnePass2(code) {
|
|
45389
|
+
let ast;
|
|
45390
|
+
try {
|
|
45391
|
+
ast = parse4(code);
|
|
45392
|
+
} catch {
|
|
45393
|
+
return code;
|
|
45394
|
+
}
|
|
45395
|
+
const body = ast.body ?? [];
|
|
45396
|
+
const edits = [];
|
|
45397
|
+
for (const raw2 of body) {
|
|
45398
|
+
const node = raw2;
|
|
45399
|
+
if (typeof node.start !== "number" || typeof node.end !== "number")
|
|
45400
|
+
continue;
|
|
45401
|
+
const isExport = node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration";
|
|
45402
|
+
if (isSnippetDrop2(node)) {
|
|
45403
|
+
let cut = node.end;
|
|
45404
|
+
if (code[cut] === ";")
|
|
45405
|
+
cut++;
|
|
45406
|
+
if (code.startsWith("\r\n", cut))
|
|
45407
|
+
cut += 2;
|
|
45408
|
+
else if (code[cut] === "\n" || code[cut] === "\r")
|
|
45409
|
+
cut++;
|
|
45410
|
+
edits.push({ start: node.start, end: cut });
|
|
45411
|
+
} else if (isExport && node.type === "ExportNamedDeclaration" && node.declaration && typeof node.declaration.start === "number" && typeof node.declaration.end === "number") {
|
|
45412
|
+
edits.push({ start: node.start, end: node.end, text: code.slice(node.declaration.start, node.declaration.end) });
|
|
45413
|
+
} else if (isExport) {
|
|
45414
|
+
let cut = node.end;
|
|
45415
|
+
if (code[cut] === ";")
|
|
45416
|
+
cut++;
|
|
45417
|
+
edits.push({ start: node.start, end: cut });
|
|
45418
|
+
}
|
|
45419
|
+
}
|
|
45420
|
+
if (edits.length === 0)
|
|
45421
|
+
return code;
|
|
45422
|
+
edits.sort((a, b) => b.start - a.start);
|
|
45423
|
+
for (const e of edits) {
|
|
45424
|
+
code = code.slice(0, e.start) + (e.text ?? "") + code.slice(e.end);
|
|
45425
|
+
}
|
|
45426
|
+
return code;
|
|
45427
|
+
}
|
|
45060
45428
|
function buildHmrEvalSnippet2(code) {
|
|
45061
|
-
const
|
|
45062
|
-
if (isAnyImport2(node) || isComponentExport2(node) || isRuntimePreamble2(node))
|
|
45063
|
-
return true;
|
|
45064
|
-
return node.type === "VariableDeclaration" && (node.declarations?.[0]?.id?.name === "__components" || node.declarations?.[0]?.id?.name === "__hydrators");
|
|
45065
|
-
};
|
|
45066
|
-
const body = demoteExports2(removeCompiledNodes2(code, isSnippetDrop)).trim();
|
|
45429
|
+
const body = stripAndDemoteInOnePass2(code).trim();
|
|
45067
45430
|
if (!body)
|
|
45068
45431
|
return "";
|
|
45069
45432
|
const scoped = `{
|
|
@@ -45132,11 +45495,11 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
45132
45495
|
return removeCompiledNodes2(code, isVskImport2);
|
|
45133
45496
|
}
|
|
45134
45497
|
function resolveVskImports(filePath, compile) {
|
|
45135
|
-
const src2 =
|
|
45498
|
+
const src2 = readFileSync24(filePath, "utf-8");
|
|
45136
45499
|
const resolved = [];
|
|
45137
45500
|
for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
|
|
45138
45501
|
try {
|
|
45139
|
-
|
|
45502
|
+
readFileSync24(importPath);
|
|
45140
45503
|
} catch {
|
|
45141
45504
|
continue;
|
|
45142
45505
|
}
|
|
@@ -45196,9 +45559,9 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
45196
45559
|
return;
|
|
45197
45560
|
}
|
|
45198
45561
|
compiledFiles++;
|
|
45199
|
-
let src2 =
|
|
45562
|
+
let src2 = readFileSync24(filePath, "utf-8");
|
|
45200
45563
|
if (/content=["'][^"']*\.md["']/i.test(src2)) {
|
|
45201
|
-
src2 = inlineMdContentAttrs(src2,
|
|
45564
|
+
src2 = inlineMdContentAttrs(src2, dirname18(filePath), guessProjectRoots(appDir));
|
|
45202
45565
|
}
|
|
45203
45566
|
const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
|
|
45204
45567
|
const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
|
|
@@ -45269,32 +45632,32 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
45269
45632
|
seen = /* @__PURE__ */ new Set();
|
|
45270
45633
|
const chunkCode = [];
|
|
45271
45634
|
const chunkImports = new ChunkImports2();
|
|
45272
|
-
const pagePath =
|
|
45273
|
-
if (node.page &&
|
|
45635
|
+
const pagePath = resolve24(appDir, node.sourceDir, "page.vsk");
|
|
45636
|
+
if (node.page && existsSync28(pagePath)) {
|
|
45274
45637
|
compileFile2(pagePath, node.page, chunkCode, chunkImports);
|
|
45275
45638
|
}
|
|
45276
|
-
const layoutPath =
|
|
45277
|
-
if (node.layout &&
|
|
45639
|
+
const layoutPath = resolve24(appDir, node.sourceDir, "layout.vsk");
|
|
45640
|
+
if (node.layout && existsSync28(layoutPath)) {
|
|
45278
45641
|
compileFile2(layoutPath, node.layout, chunkCode, chunkImports);
|
|
45279
45642
|
}
|
|
45280
|
-
const errorPath =
|
|
45281
|
-
if (node.error &&
|
|
45643
|
+
const errorPath = resolve24(appDir, node.sourceDir, "error.vsk");
|
|
45644
|
+
if (node.error && existsSync28(errorPath)) {
|
|
45282
45645
|
compileFile2(errorPath, node.error, chunkCode, chunkImports);
|
|
45283
45646
|
}
|
|
45284
|
-
const notFoundPath =
|
|
45285
|
-
if (node.notFound &&
|
|
45647
|
+
const notFoundPath = resolve24(appDir, node.sourceDir, "not-found.vsk");
|
|
45648
|
+
if (node.notFound && existsSync28(notFoundPath)) {
|
|
45286
45649
|
compileFile2(notFoundPath, node.notFound, chunkCode, chunkImports);
|
|
45287
45650
|
}
|
|
45288
|
-
const offlinePath =
|
|
45289
|
-
if (node.offline &&
|
|
45651
|
+
const offlinePath = resolve24(appDir, node.sourceDir, "offline.vsk");
|
|
45652
|
+
if (node.offline && existsSync28(offlinePath)) {
|
|
45290
45653
|
compileFile2(offlinePath, node.offline, chunkCode, chunkImports);
|
|
45291
45654
|
}
|
|
45292
|
-
const networkPath =
|
|
45293
|
-
if (node.network &&
|
|
45655
|
+
const networkPath = resolve24(appDir, node.sourceDir, "network.vsk");
|
|
45656
|
+
if (node.network && existsSync28(networkPath)) {
|
|
45294
45657
|
compileFile2(networkPath, node.network, chunkCode, chunkImports);
|
|
45295
45658
|
}
|
|
45296
|
-
const loadingPath =
|
|
45297
|
-
if (node.loading &&
|
|
45659
|
+
const loadingPath = resolve24(appDir, node.sourceDir, "loading.vsk");
|
|
45660
|
+
if (node.loading && existsSync28(loadingPath)) {
|
|
45298
45661
|
compileFile2(loadingPath, node.loading, chunkCode, chunkImports);
|
|
45299
45662
|
}
|
|
45300
45663
|
if (chunkCode.length > 0) {
|
|
@@ -45344,8 +45707,8 @@ ${body}
|
|
|
45344
45707
|
continue;
|
|
45345
45708
|
let finalCode;
|
|
45346
45709
|
if (entry.imports) {
|
|
45347
|
-
const tmpBase = mkdtempSync2(
|
|
45348
|
-
const tmpFile =
|
|
45710
|
+
const tmpBase = mkdtempSync2(join18(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
|
|
45711
|
+
const tmpFile = join18(tmpBase, "entry.js");
|
|
45349
45712
|
const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
|
|
45350
45713
|
const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
|
|
45351
45714
|
${entry.code}
|
|
@@ -45401,7 +45764,7 @@ ${entry.code}
|
|
|
45401
45764
|
if (seen.has(filePath))
|
|
45402
45765
|
return;
|
|
45403
45766
|
seen.add(filePath);
|
|
45404
|
-
const src2 =
|
|
45767
|
+
const src2 = readFileSync24(filePath, "utf-8");
|
|
45405
45768
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
45406
45769
|
const monoAlloc = nameAllocFor(filePath);
|
|
45407
45770
|
const compCode = compileClient(src2, null, { forceClient: true, sourcePath: filePath, nameAllocator: monoAlloc });
|
|
@@ -45422,26 +45785,26 @@ ${entry.code}
|
|
|
45422
45785
|
}
|
|
45423
45786
|
}, walkMono2 = function(nodes) {
|
|
45424
45787
|
for (const node of nodes) {
|
|
45425
|
-
const pagePath =
|
|
45426
|
-
if (node.page &&
|
|
45788
|
+
const pagePath = resolve24(appDir, node.sourceDir, "page.vsk");
|
|
45789
|
+
if (node.page && existsSync28(pagePath))
|
|
45427
45790
|
compileFileMono2(pagePath, node.page);
|
|
45428
|
-
const layoutPath =
|
|
45429
|
-
if (node.layout &&
|
|
45791
|
+
const layoutPath = resolve24(appDir, node.sourceDir, "layout.vsk");
|
|
45792
|
+
if (node.layout && existsSync28(layoutPath))
|
|
45430
45793
|
compileFileMono2(layoutPath, node.layout);
|
|
45431
|
-
const errorPath =
|
|
45432
|
-
if (node.error &&
|
|
45794
|
+
const errorPath = resolve24(appDir, node.sourceDir, "error.vsk");
|
|
45795
|
+
if (node.error && existsSync28(errorPath))
|
|
45433
45796
|
compileFileMono2(errorPath, node.error);
|
|
45434
|
-
const notFoundPath =
|
|
45435
|
-
if (node.notFound &&
|
|
45797
|
+
const notFoundPath = resolve24(appDir, node.sourceDir, "not-found.vsk");
|
|
45798
|
+
if (node.notFound && existsSync28(notFoundPath))
|
|
45436
45799
|
compileFileMono2(notFoundPath, node.notFound);
|
|
45437
|
-
const offlinePath =
|
|
45438
|
-
if (node.offline &&
|
|
45800
|
+
const offlinePath = resolve24(appDir, node.sourceDir, "offline.vsk");
|
|
45801
|
+
if (node.offline && existsSync28(offlinePath))
|
|
45439
45802
|
compileFileMono2(offlinePath, node.offline);
|
|
45440
|
-
const networkPath =
|
|
45441
|
-
if (node.network &&
|
|
45803
|
+
const networkPath = resolve24(appDir, node.sourceDir, "network.vsk");
|
|
45804
|
+
if (node.network && existsSync28(networkPath))
|
|
45442
45805
|
compileFileMono2(networkPath, node.network);
|
|
45443
|
-
const loadingPath =
|
|
45444
|
-
if (node.loading &&
|
|
45806
|
+
const loadingPath = resolve24(appDir, node.sourceDir, "loading.vsk");
|
|
45807
|
+
if (node.loading && existsSync28(loadingPath))
|
|
45445
45808
|
compileFileMono2(loadingPath, node.loading);
|
|
45446
45809
|
walkMono2(node.children || []);
|
|
45447
45810
|
}
|
|
@@ -45491,9 +45854,9 @@ function buildRuntimeCode2(runtimeDir) {
|
|
|
45491
45854
|
];
|
|
45492
45855
|
let code = "";
|
|
45493
45856
|
for (const f of runtimeFiles) {
|
|
45494
|
-
const p =
|
|
45495
|
-
if (
|
|
45496
|
-
let src2 =
|
|
45857
|
+
const p = join18(runtimeDir, f);
|
|
45858
|
+
if (existsSync28(p)) {
|
|
45859
|
+
let src2 = readFileSync24(p, "utf-8");
|
|
45497
45860
|
src2 = stripTypes2(src2);
|
|
45498
45861
|
src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
45499
45862
|
src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
@@ -45505,7 +45868,7 @@ ${src2}
|
|
|
45505
45868
|
`;
|
|
45506
45869
|
}
|
|
45507
45870
|
}
|
|
45508
|
-
const indexSrc =
|
|
45871
|
+
const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
|
|
45509
45872
|
const exportNames = stripTypes2(indexSrc).match(/export\s*\{\s*([^}]+)\s*\}\s*from/g)?.flatMap((m) => m.replace(/export\s*\{\s*|\s*\}\s*from/g, "").split(",").map((s) => s.trim())) || [];
|
|
45510
45873
|
code += "// --- exports ---\n";
|
|
45511
45874
|
for (const name of [...new Set(exportNames)]) {
|
|
@@ -45516,7 +45879,7 @@ ${src2}
|
|
|
45516
45879
|
return code;
|
|
45517
45880
|
}
|
|
45518
45881
|
function runtimeExportNames2(runtimeDir) {
|
|
45519
|
-
const indexSrc =
|
|
45882
|
+
const indexSrc = readFileSync24(join18(runtimeDir, "index-client.js"), "utf-8");
|
|
45520
45883
|
const names = /* @__PURE__ */ new Set();
|
|
45521
45884
|
for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
|
|
45522
45885
|
for (const raw2 of m[1].split(",")) {
|
|
@@ -45536,7 +45899,7 @@ async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
|
|
|
45536
45899
|
console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
|
|
45537
45900
|
return buildRuntimeCode2(runtimeDir);
|
|
45538
45901
|
}
|
|
45539
|
-
const entry =
|
|
45902
|
+
const entry = join18(runtimeDir, RUNTIME_ENTRY2);
|
|
45540
45903
|
try {
|
|
45541
45904
|
try {
|
|
45542
45905
|
rmSync4(entry);
|
|
@@ -45673,18 +46036,18 @@ if (typeof document !== 'undefined') __router.start();
|
|
|
45673
46036
|
}
|
|
45674
46037
|
|
|
45675
46038
|
// ../adapter/dist/paths.js
|
|
45676
|
-
import { resolve as
|
|
45677
|
-
import { existsSync as
|
|
46039
|
+
import { resolve as resolve25, sep as sep4 } from "node:path";
|
|
46040
|
+
import { existsSync as existsSync29, statSync as statSync15, readFileSync as readFileSync25 } from "node:fs";
|
|
45678
46041
|
function resolveWithin2(baseDir, relPath) {
|
|
45679
|
-
const base =
|
|
45680
|
-
const target =
|
|
46042
|
+
const base = resolve25(baseDir);
|
|
46043
|
+
const target = resolve25(baseDir, relPath);
|
|
45681
46044
|
const prefix = base + sep4;
|
|
45682
46045
|
if (!target.startsWith(prefix))
|
|
45683
46046
|
return null;
|
|
45684
46047
|
return target;
|
|
45685
46048
|
}
|
|
45686
46049
|
function installMdReadHook2(publicDirs) {
|
|
45687
|
-
const dirs = publicDirs.map((d) =>
|
|
46050
|
+
const dirs = publicDirs.map((d) => resolve25(d));
|
|
45688
46051
|
globalThis.__vsk_md_read_file = (p) => {
|
|
45689
46052
|
for (const dir of dirs) {
|
|
45690
46053
|
try {
|
|
@@ -45697,8 +46060,8 @@ function installMdReadHook2(publicDirs) {
|
|
|
45697
46060
|
const lower = abs.toLowerCase();
|
|
45698
46061
|
if (!lower.endsWith(".md") && !lower.endsWith(".markdown"))
|
|
45699
46062
|
continue;
|
|
45700
|
-
if (
|
|
45701
|
-
return
|
|
46063
|
+
if (existsSync29(abs) && statSync15(abs).isFile())
|
|
46064
|
+
return readFileSync25(abs, "utf8");
|
|
45702
46065
|
} catch {
|
|
45703
46066
|
}
|
|
45704
46067
|
}
|
|
@@ -45765,13 +46128,13 @@ function urlAuthority3(url) {
|
|
|
45765
46128
|
}
|
|
45766
46129
|
|
|
45767
46130
|
// ../adapter/dist/dev-api.js
|
|
45768
|
-
import { readFileSync as
|
|
45769
|
-
import { resolve as
|
|
46131
|
+
import { readFileSync as readFileSync28, statSync as statSync17, existsSync as existsSync32, readdirSync as readdirSync9 } from "node:fs";
|
|
46132
|
+
import { resolve as resolve28 } from "node:path";
|
|
45770
46133
|
|
|
45771
46134
|
// ../adapter/dist/plugins.js
|
|
45772
46135
|
init_paths();
|
|
45773
|
-
import { readFileSync as
|
|
45774
|
-
import { resolve as
|
|
46136
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync11, statSync as statSync16 } from "node:fs";
|
|
46137
|
+
import { resolve as resolve26, dirname as dirname19, join as join19, extname as extname7, basename as basename5 } from "node:path";
|
|
45775
46138
|
import { createRequire as createRequire5 } from "node:module";
|
|
45776
46139
|
import { spawn as spawn2 } from "node:child_process";
|
|
45777
46140
|
var PLUGIN_STATE_FILENAME2 = "plugins.json";
|
|
@@ -45786,15 +46149,15 @@ function eqIgnoreCase2(a, b) {
|
|
|
45786
46149
|
return String(a || "").toLowerCase() === String(b || "").toLowerCase();
|
|
45787
46150
|
}
|
|
45788
46151
|
function stateFilePath2(veskDir) {
|
|
45789
|
-
return
|
|
46152
|
+
return resolve26(veskDir, PLUGIN_STATE_FILENAME2);
|
|
45790
46153
|
}
|
|
45791
46154
|
function readPluginState2(veskDir) {
|
|
45792
46155
|
const file = stateFilePath2(veskDir);
|
|
45793
|
-
if (!
|
|
46156
|
+
if (!existsSync30(file))
|
|
45794
46157
|
return defaultState2();
|
|
45795
46158
|
let raw2;
|
|
45796
46159
|
try {
|
|
45797
|
-
raw2 = JSON.parse(
|
|
46160
|
+
raw2 = JSON.parse(readFileSync26(file, "utf-8"));
|
|
45798
46161
|
} catch {
|
|
45799
46162
|
return defaultState2();
|
|
45800
46163
|
}
|
|
@@ -45812,13 +46175,13 @@ function readPluginState2(veskDir) {
|
|
|
45812
46175
|
}
|
|
45813
46176
|
function writePluginState2(veskDir, state) {
|
|
45814
46177
|
const file = stateFilePath2(veskDir);
|
|
45815
|
-
const dir =
|
|
45816
|
-
if (!
|
|
46178
|
+
const dir = dirname19(file);
|
|
46179
|
+
if (!existsSync30(dir))
|
|
45817
46180
|
mkdirSync11(dir, { recursive: true });
|
|
45818
46181
|
writeFileSync14(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
|
|
45819
46182
|
}
|
|
45820
46183
|
function resolvePackage2(appDir, pkg) {
|
|
45821
|
-
const require3 = createRequire5(
|
|
46184
|
+
const require3 = createRequire5(resolve26(appDir, "package.json"));
|
|
45822
46185
|
let entryPath = null;
|
|
45823
46186
|
let pkgJsonPath = null;
|
|
45824
46187
|
let pkgJson = null;
|
|
@@ -45827,16 +46190,16 @@ function resolvePackage2(appDir, pkg) {
|
|
|
45827
46190
|
} catch {
|
|
45828
46191
|
try {
|
|
45829
46192
|
entryPath = require3.resolve(pkg);
|
|
45830
|
-
let cur =
|
|
46193
|
+
let cur = dirname19(entryPath);
|
|
45831
46194
|
const seen = /* @__PURE__ */ new Set();
|
|
45832
|
-
while (cur && cur !==
|
|
46195
|
+
while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
|
|
45833
46196
|
seen.add(cur);
|
|
45834
|
-
const candidate =
|
|
45835
|
-
if (
|
|
46197
|
+
const candidate = join19(cur, "package.json");
|
|
46198
|
+
if (existsSync30(candidate)) {
|
|
45836
46199
|
pkgJsonPath = candidate;
|
|
45837
46200
|
break;
|
|
45838
46201
|
}
|
|
45839
|
-
const parent =
|
|
46202
|
+
const parent = dirname19(cur);
|
|
45840
46203
|
if (parent !== cur && basename5(cur) === "node_modules")
|
|
45841
46204
|
break;
|
|
45842
46205
|
cur = parent;
|
|
@@ -45844,15 +46207,15 @@ function resolvePackage2(appDir, pkg) {
|
|
|
45844
46207
|
} catch {
|
|
45845
46208
|
}
|
|
45846
46209
|
}
|
|
45847
|
-
if (pkgJsonPath &&
|
|
46210
|
+
if (pkgJsonPath && existsSync30(pkgJsonPath)) {
|
|
45848
46211
|
pkgJson = readJsonFile2(pkgJsonPath);
|
|
45849
46212
|
const main = pkgJson?.main || pkgJson?.module || "index.js";
|
|
45850
|
-
entryPath =
|
|
46213
|
+
entryPath = resolve26(dirname19(pkgJsonPath), main);
|
|
45851
46214
|
}
|
|
45852
46215
|
let localPath = localDir2(appDir, pkg);
|
|
45853
46216
|
if (!localPath) {
|
|
45854
46217
|
for (const sub of ["src/plugins", "plugins", "lib/plugins"]) {
|
|
45855
|
-
const candidate = localDir2(
|
|
46218
|
+
const candidate = localDir2(resolve26(appDir, sub), pkg);
|
|
45856
46219
|
if (candidate) {
|
|
45857
46220
|
localPath = candidate;
|
|
45858
46221
|
break;
|
|
@@ -45860,33 +46223,33 @@ function resolvePackage2(appDir, pkg) {
|
|
|
45860
46223
|
}
|
|
45861
46224
|
}
|
|
45862
46225
|
if (localPath) {
|
|
45863
|
-
const localJson =
|
|
46226
|
+
const localJson = join19(localPath, "package.json");
|
|
45864
46227
|
let json = null;
|
|
45865
|
-
if (
|
|
46228
|
+
if (existsSync30(localJson)) {
|
|
45866
46229
|
json = readJsonFile2(localJson);
|
|
45867
46230
|
}
|
|
45868
46231
|
return { installed: true, path: localPath, dir: localPath, packageJson: json ?? pkgJson };
|
|
45869
46232
|
}
|
|
45870
|
-
const installed2 = !!pkgJsonPath &&
|
|
45871
|
-
return { installed: installed2, path: entryPath, dir: installed2 ?
|
|
46233
|
+
const installed2 = !!pkgJsonPath && existsSync30(pkgJsonPath);
|
|
46234
|
+
return { installed: installed2, path: entryPath, dir: installed2 ? dirname19(pkgJsonPath) : null, packageJson: pkgJson };
|
|
45872
46235
|
}
|
|
45873
46236
|
function localDir2(base, pkg) {
|
|
45874
46237
|
if (pkg.startsWith("@")) {
|
|
45875
46238
|
const parts = pkg.split("/");
|
|
45876
|
-
const p2 =
|
|
45877
|
-
if (
|
|
46239
|
+
const p2 = resolve26(base, parts[0], parts[1] ?? "");
|
|
46240
|
+
if (existsSync30(p2))
|
|
45878
46241
|
return p2;
|
|
45879
46242
|
return null;
|
|
45880
46243
|
}
|
|
45881
|
-
const p =
|
|
45882
|
-
if (
|
|
46244
|
+
const p = resolve26(base, pkg);
|
|
46245
|
+
if (existsSync30(p))
|
|
45883
46246
|
return p;
|
|
45884
46247
|
return null;
|
|
45885
46248
|
}
|
|
45886
46249
|
function readJsonFile2(file) {
|
|
45887
46250
|
try {
|
|
45888
|
-
if (
|
|
45889
|
-
return JSON.parse(
|
|
46251
|
+
if (existsSync30(file))
|
|
46252
|
+
return JSON.parse(readFileSync26(file, "utf-8"));
|
|
45890
46253
|
} catch {
|
|
45891
46254
|
}
|
|
45892
46255
|
return null;
|
|
@@ -45932,7 +46295,7 @@ function repositoryToString2(r) {
|
|
|
45932
46295
|
function assemblePluginMeta2(probe) {
|
|
45933
46296
|
const pkgJson = probe.packageJson || {};
|
|
45934
46297
|
const dir = probe.dir;
|
|
45935
|
-
const meta = dir ? readJsonFile2(
|
|
46298
|
+
const meta = dir ? readJsonFile2(resolve26(dir, "vesk.meta.json")) : null;
|
|
45936
46299
|
const hasMeta = !!meta && Object.keys(meta).length > 0;
|
|
45937
46300
|
const m = meta || {};
|
|
45938
46301
|
const metaSource = hasMeta ? "vesk.meta.json" : probe.packageJson ? "package.json" : "none";
|
|
@@ -46169,12 +46532,12 @@ function findIconFile2(dir, meta) {
|
|
|
46169
46532
|
const explicit = str2(meta?.icon);
|
|
46170
46533
|
if (explicit) {
|
|
46171
46534
|
const p = resolveWithin(dir, explicit);
|
|
46172
|
-
if (p &&
|
|
46535
|
+
if (p && existsSync30(p) && statSync16(p).isFile())
|
|
46173
46536
|
return p;
|
|
46174
46537
|
}
|
|
46175
46538
|
for (const name of ["icon.png", "icon.ico"]) {
|
|
46176
|
-
const p =
|
|
46177
|
-
if (
|
|
46539
|
+
const p = resolve26(dir, name);
|
|
46540
|
+
if (existsSync30(p) && statSync16(p).isFile())
|
|
46178
46541
|
return p;
|
|
46179
46542
|
}
|
|
46180
46543
|
return null;
|
|
@@ -46184,7 +46547,7 @@ function findPluginIcon2(appDir, name) {
|
|
|
46184
46547
|
const dir = probe.dir;
|
|
46185
46548
|
if (!dir)
|
|
46186
46549
|
return null;
|
|
46187
|
-
const meta = readJsonFile2(
|
|
46550
|
+
const meta = readJsonFile2(resolve26(dir, "vesk.meta.json"));
|
|
46188
46551
|
const iconPath = findIconFile2(dir, meta);
|
|
46189
46552
|
if (!iconPath)
|
|
46190
46553
|
return null;
|
|
@@ -46259,7 +46622,7 @@ function resolveDtsPath2(probe, pkgJson) {
|
|
|
46259
46622
|
if (!rel)
|
|
46260
46623
|
continue;
|
|
46261
46624
|
const abs = resolveWithin(dir, rel);
|
|
46262
|
-
if (abs &&
|
|
46625
|
+
if (abs && existsSync30(abs) && statSync16(abs).isFile())
|
|
46263
46626
|
return abs;
|
|
46264
46627
|
}
|
|
46265
46628
|
return null;
|
|
@@ -46608,7 +46971,7 @@ function introspectPlugin2(appDir, name) {
|
|
|
46608
46971
|
const pkgName = str2(pkgJson.name) ?? name;
|
|
46609
46972
|
const exportsMap = flattenPackageExports2(pkgJson.exports);
|
|
46610
46973
|
const dtsPath = resolveDtsPath2(probe, pkgJson);
|
|
46611
|
-
const dtsExports = dtsPath ? parseDtsExports2(
|
|
46974
|
+
const dtsExports = dtsPath ? parseDtsExports2(readFileSync26(dtsPath, "utf-8")) : [];
|
|
46612
46975
|
return {
|
|
46613
46976
|
ok: true,
|
|
46614
46977
|
name: pkgName,
|
|
@@ -46746,16 +47109,16 @@ var __internals2 = {
|
|
|
46746
47109
|
};
|
|
46747
47110
|
|
|
46748
47111
|
// ../adapter/dist/dev-config.js
|
|
46749
|
-
import { existsSync as
|
|
47112
|
+
import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
|
|
46750
47113
|
import { tmpdir } from "node:os";
|
|
46751
|
-
import { resolve as
|
|
47114
|
+
import { resolve as resolve27, dirname as dirname20, join as join20 } from "node:path";
|
|
46752
47115
|
init_parser();
|
|
46753
47116
|
function findConfigFile2(projectDir) {
|
|
46754
|
-
const ts9 =
|
|
46755
|
-
if (
|
|
47117
|
+
const ts9 = resolve27(projectDir, "vesk.config.ts");
|
|
47118
|
+
if (existsSync31(ts9))
|
|
46756
47119
|
return { path: ts9, isTs: true };
|
|
46757
|
-
const js =
|
|
46758
|
-
if (
|
|
47120
|
+
const js = resolve27(projectDir, "vesk.config.js");
|
|
47121
|
+
if (existsSync31(js))
|
|
46759
47122
|
return { path: js, isTs: false };
|
|
46760
47123
|
return { path: null, isTs: false };
|
|
46761
47124
|
}
|
|
@@ -46776,9 +47139,9 @@ async function parseConfigSource(source, isTs, projectDir) {
|
|
|
46776
47139
|
js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
|
|
46777
47140
|
` + js;
|
|
46778
47141
|
}
|
|
46779
|
-
const base = projectDir ? (mkdirSync12(
|
|
46780
|
-
const dir = base ? mkdtempSync3(
|
|
46781
|
-
const tmpFile =
|
|
47142
|
+
const base = projectDir ? (mkdirSync12(join20(projectDir, ".vesk"), { recursive: true }), join20(projectDir, ".vesk")) : void 0;
|
|
47143
|
+
const dir = base ? mkdtempSync3(join20(base, "cfg-")) : mkdtempSync3(join20(tmpdir(), "vesk-cfg-"));
|
|
47144
|
+
const tmpFile = join20(dir, "config.mjs");
|
|
46782
47145
|
try {
|
|
46783
47146
|
writeFileSync15(tmpFile, js, "utf-8");
|
|
46784
47147
|
globalThis.__vesk_inject = {
|
|
@@ -46805,15 +47168,15 @@ async function readConfig2(projectDir) {
|
|
|
46805
47168
|
const { path, isTs } = findConfigFile2(projectDir);
|
|
46806
47169
|
if (!path)
|
|
46807
47170
|
return { path: null, exists: false, source: "", config: {} };
|
|
46808
|
-
const source =
|
|
47171
|
+
const source = readFileSync27(path, "utf-8");
|
|
46809
47172
|
const config = await parseConfigSource(source, isTs, projectDir);
|
|
46810
47173
|
return { path, exists: true, source, config };
|
|
46811
47174
|
}
|
|
46812
47175
|
async function writeConfigSource2(projectDir, source) {
|
|
46813
47176
|
const { path, isTs } = findConfigFile2(projectDir);
|
|
46814
|
-
const target = path ||
|
|
47177
|
+
const target = path || resolve27(projectDir, "vesk.config.ts");
|
|
46815
47178
|
await parseConfigSource(source, isTs, projectDir);
|
|
46816
|
-
mkdirSync12(
|
|
47179
|
+
mkdirSync12(dirname20(target), { recursive: true });
|
|
46817
47180
|
writeFileSync15(target, source, "utf-8");
|
|
46818
47181
|
const config = await parseConfigSource(source, isTs, projectDir);
|
|
46819
47182
|
return { path: target, exists: true, source, config };
|
|
@@ -47643,11 +48006,11 @@ export default defineConfig({
|
|
|
47643
48006
|
]
|
|
47644
48007
|
})
|
|
47645
48008
|
`;
|
|
47646
|
-
target =
|
|
48009
|
+
target = resolve27(projectDir, "vesk.config.ts");
|
|
47647
48010
|
await writeConfigSource2(projectDir, source);
|
|
47648
48011
|
return;
|
|
47649
48012
|
}
|
|
47650
|
-
source =
|
|
48013
|
+
source = readFileSync27(path, "utf-8");
|
|
47651
48014
|
const existingImport = findPluginImportAst(source, pkg);
|
|
47652
48015
|
let importName;
|
|
47653
48016
|
if (existingImport) {
|
|
@@ -47727,7 +48090,7 @@ async function removePluginFromConfig2(projectDir, pkg) {
|
|
|
47727
48090
|
const { path } = findConfigFile2(projectDir);
|
|
47728
48091
|
if (!path)
|
|
47729
48092
|
return false;
|
|
47730
|
-
let source =
|
|
48093
|
+
let source = readFileSync27(path, "utf-8");
|
|
47731
48094
|
const original = source;
|
|
47732
48095
|
const existingImport = findPluginImportAst(source, pkg);
|
|
47733
48096
|
let importName = existingImport ? existingImport.name : null;
|
|
@@ -47805,7 +48168,7 @@ function jsonStatus(status, data2) {
|
|
|
47805
48168
|
function createDevApiRouter2(opts) {
|
|
47806
48169
|
const veskDir = opts.veskDir;
|
|
47807
48170
|
const caps = new CapabilityTable2(opts.caps, opts.commandAllowlist);
|
|
47808
|
-
const projectDir = opts.projectDir ||
|
|
48171
|
+
const projectDir = opts.projectDir || resolve28(opts.appDir, "..");
|
|
47809
48172
|
const getState = opts.getHmrState || (() => ({ status: "up", lastCompileMs: null, error: null, hasError: false, componentCount: 0 }));
|
|
47810
48173
|
function denied2(cap) {
|
|
47811
48174
|
return jsonStatus(403, { error: `capability denied: ${cap}` });
|
|
@@ -47848,7 +48211,7 @@ function createDevApiRouter2(opts) {
|
|
|
47848
48211
|
return badRequest2("no vesk.config file to edit");
|
|
47849
48212
|
if (!isTs)
|
|
47850
48213
|
return badRequest2("single-key toggle edits only apply to vesk.config.ts (use the source editor for .js)");
|
|
47851
|
-
const patched = applyConfigToggle2(
|
|
48214
|
+
const patched = applyConfigToggle2(readFileSync28(path, "utf-8"), b.key, b.value);
|
|
47852
48215
|
if (patched === null)
|
|
47853
48216
|
return badRequest2("could not safely edit the config object; use the source editor");
|
|
47854
48217
|
const cfg = await writeConfigSource2(projectDir, patched);
|
|
@@ -47887,14 +48250,14 @@ function createDevApiRouter2(opts) {
|
|
|
47887
48250
|
const resolved = resolveWithin2(projectDir, target);
|
|
47888
48251
|
if (!resolved)
|
|
47889
48252
|
return jsonStatus(403, { error: "path escapes project root" });
|
|
47890
|
-
if (!
|
|
48253
|
+
if (!existsSync32(resolved))
|
|
47891
48254
|
return jsonStatus(404, { error: "not found" });
|
|
47892
48255
|
if (statSync17(resolved).isDirectory()) {
|
|
47893
48256
|
const entries = readdirSync9(resolved, { withFileTypes: true }).map((e) => e.name);
|
|
47894
48257
|
return jsonStatus(200, { ok: true, path: target, directory: true, entries });
|
|
47895
48258
|
}
|
|
47896
48259
|
if (statSync17(resolved).isFile()) {
|
|
47897
|
-
return jsonStatus(200, { ok: true, path: target, directory: false, content:
|
|
48260
|
+
return jsonStatus(200, { ok: true, path: target, directory: false, content: readFileSync28(resolved, "utf-8") });
|
|
47898
48261
|
}
|
|
47899
48262
|
return badRequest2("unsupported file type");
|
|
47900
48263
|
} catch (e) {
|
|
@@ -48030,7 +48393,7 @@ function createDevApiRouter2(opts) {
|
|
|
48030
48393
|
return {
|
|
48031
48394
|
status: 200,
|
|
48032
48395
|
headers: { "Content-Type": icon.mime, "Cache-Control": "private, max-age=60" },
|
|
48033
|
-
body:
|
|
48396
|
+
body: readFileSync28(icon.file).toString("base64"),
|
|
48034
48397
|
encoding: "base64"
|
|
48035
48398
|
};
|
|
48036
48399
|
}
|
|
@@ -48087,8 +48450,8 @@ function produceDiagnostics(input) {
|
|
|
48087
48450
|
}
|
|
48088
48451
|
|
|
48089
48452
|
// ../agentic/dist/checkpoints.js
|
|
48090
|
-
import { existsSync as
|
|
48091
|
-
import { join as
|
|
48453
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync13, readFileSync as readFileSync29, writeFileSync as writeFileSync16, statSync as statSync18, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
|
|
48454
|
+
import { join as join21, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
|
|
48092
48455
|
import { randomUUID as nodeRandomUUID } from "node:crypto";
|
|
48093
48456
|
function generateId() {
|
|
48094
48457
|
try {
|
|
@@ -48221,25 +48584,25 @@ var CheckpointManager = class {
|
|
|
48221
48584
|
}
|
|
48222
48585
|
};
|
|
48223
48586
|
function getAgenticDir(projectDir) {
|
|
48224
|
-
return
|
|
48587
|
+
return join21(resolve29(projectDir), ".vesk", "agentic");
|
|
48225
48588
|
}
|
|
48226
48589
|
function getHistoryPath(projectDir) {
|
|
48227
|
-
return
|
|
48590
|
+
return join21(getAgenticDir(projectDir), "history.json");
|
|
48228
48591
|
}
|
|
48229
48592
|
function getCheckpointDir(projectDir, id) {
|
|
48230
|
-
return
|
|
48593
|
+
return join21(getAgenticDir(projectDir), "checkpoints", id);
|
|
48231
48594
|
}
|
|
48232
48595
|
function getCheckpointPath(projectDir, id) {
|
|
48233
|
-
return
|
|
48596
|
+
return join21(getCheckpointDir(projectDir, id), "checkpoint.json");
|
|
48234
48597
|
}
|
|
48235
48598
|
function ensureDir(dir) {
|
|
48236
48599
|
mkdirSync13(dir, { recursive: true });
|
|
48237
48600
|
}
|
|
48238
48601
|
function readJson(filePath, fallback) {
|
|
48239
48602
|
try {
|
|
48240
|
-
if (!
|
|
48603
|
+
if (!existsSync33(filePath))
|
|
48241
48604
|
return fallback;
|
|
48242
|
-
const raw2 =
|
|
48605
|
+
const raw2 = readFileSync29(filePath, "utf-8");
|
|
48243
48606
|
if (raw2.trim() === "")
|
|
48244
48607
|
return fallback;
|
|
48245
48608
|
return JSON.parse(raw2);
|
|
@@ -48248,7 +48611,7 @@ function readJson(filePath, fallback) {
|
|
|
48248
48611
|
}
|
|
48249
48612
|
}
|
|
48250
48613
|
function writeJsonAtomic(filePath, data2) {
|
|
48251
|
-
ensureDir(
|
|
48614
|
+
ensureDir(dirname21(filePath));
|
|
48252
48615
|
const tmp = `${filePath}.tmp`;
|
|
48253
48616
|
writeFileSync16(tmp, JSON.stringify(data2, null, 2), "utf-8");
|
|
48254
48617
|
try {
|
|
@@ -48310,7 +48673,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
|
|
|
48310
48673
|
};
|
|
48311
48674
|
const agenticDir = getAgenticDir(projectDir);
|
|
48312
48675
|
ensureDir(agenticDir);
|
|
48313
|
-
ensureDir(
|
|
48676
|
+
ensureDir(join21(agenticDir, "checkpoints"));
|
|
48314
48677
|
const cpDir = getCheckpointDir(projectDir, id);
|
|
48315
48678
|
ensureDir(cpDir);
|
|
48316
48679
|
writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
|
|
@@ -48331,14 +48694,14 @@ function rollback(projectDir, id) {
|
|
|
48331
48694
|
const cp = getCheckpoint(projectDir, id);
|
|
48332
48695
|
if (!cp)
|
|
48333
48696
|
return null;
|
|
48334
|
-
const projectRoot =
|
|
48697
|
+
const projectRoot = resolve29(projectDir);
|
|
48335
48698
|
for (const f of cp.files) {
|
|
48336
48699
|
if (!f.path || !f.path.trim())
|
|
48337
48700
|
continue;
|
|
48338
|
-
const abs =
|
|
48701
|
+
const abs = resolve29(projectRoot, f.path);
|
|
48339
48702
|
if (f.before === null) {
|
|
48340
48703
|
try {
|
|
48341
|
-
if (
|
|
48704
|
+
if (existsSync33(abs)) {
|
|
48342
48705
|
const s = statSync18(abs);
|
|
48343
48706
|
if (s.isDirectory())
|
|
48344
48707
|
rmSync6(abs, { recursive: true, force: true });
|
|
@@ -48349,7 +48712,7 @@ function rollback(projectDir, id) {
|
|
|
48349
48712
|
}
|
|
48350
48713
|
} else {
|
|
48351
48714
|
try {
|
|
48352
|
-
ensureDir(
|
|
48715
|
+
ensureDir(dirname21(abs));
|
|
48353
48716
|
writeFileSync16(abs, f.before, "utf-8");
|
|
48354
48717
|
} catch {
|
|
48355
48718
|
}
|
|
@@ -48359,8 +48722,8 @@ function rollback(projectDir, id) {
|
|
|
48359
48722
|
}
|
|
48360
48723
|
|
|
48361
48724
|
// ../agentic/dist/config.js
|
|
48362
|
-
import { readFileSync as
|
|
48363
|
-
import { resolve as
|
|
48725
|
+
import { readFileSync as readFileSync30, writeFileSync as writeFileSync17, existsSync as existsSync34, mkdirSync as mkdirSync14, chmodSync } from "node:fs";
|
|
48726
|
+
import { resolve as resolve30, dirname as dirname22 } from "node:path";
|
|
48364
48727
|
var DEFAULT_CONFIG = {
|
|
48365
48728
|
provider: "openai",
|
|
48366
48729
|
model: "",
|
|
@@ -48379,10 +48742,10 @@ var SUPPORTED_PROVIDERS = [
|
|
|
48379
48742
|
"custom"
|
|
48380
48743
|
];
|
|
48381
48744
|
function configPath(projectDir) {
|
|
48382
|
-
return
|
|
48745
|
+
return resolve30(projectDir, ".vesk", "agentic", "config.json");
|
|
48383
48746
|
}
|
|
48384
48747
|
function keysDir(projectDir) {
|
|
48385
|
-
return
|
|
48748
|
+
return resolve30(projectDir, ".vesk", "agentic", "keys");
|
|
48386
48749
|
}
|
|
48387
48750
|
function sanitizeProvider(provider) {
|
|
48388
48751
|
const p = provider.trim().toLowerCase();
|
|
@@ -48394,21 +48757,21 @@ function normalizeProvider(provider) {
|
|
|
48394
48757
|
return provider.trim().toLowerCase();
|
|
48395
48758
|
}
|
|
48396
48759
|
function providerKeyPath(projectDir, provider) {
|
|
48397
|
-
return
|
|
48760
|
+
return resolve30(keysDir(projectDir), `${sanitizeProvider(provider)}.key`);
|
|
48398
48761
|
}
|
|
48399
48762
|
function providerDotenvVar(provider) {
|
|
48400
48763
|
const prov = sanitizeProvider(provider);
|
|
48401
48764
|
return `VK_${prov.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_KEY`;
|
|
48402
48765
|
}
|
|
48403
48766
|
function dotenvPath(projectDir) {
|
|
48404
|
-
return
|
|
48767
|
+
return resolve30(projectDir, ".env.local");
|
|
48405
48768
|
}
|
|
48406
48769
|
function readDotenvValue(projectDir, key, def = null) {
|
|
48407
48770
|
try {
|
|
48408
48771
|
const p = dotenvPath(projectDir);
|
|
48409
|
-
if (!
|
|
48772
|
+
if (!existsSync34(p))
|
|
48410
48773
|
return def;
|
|
48411
|
-
const content =
|
|
48774
|
+
const content = readFileSync30(p, "utf-8");
|
|
48412
48775
|
for (const rawLine of content.split("\n")) {
|
|
48413
48776
|
const line = rawLine.trim();
|
|
48414
48777
|
if (!line || line.startsWith("#"))
|
|
@@ -48435,8 +48798,8 @@ function writeDotenvValue(projectDir, key, value) {
|
|
|
48435
48798
|
try {
|
|
48436
48799
|
let out = "";
|
|
48437
48800
|
let replaced = false;
|
|
48438
|
-
if (
|
|
48439
|
-
const lines =
|
|
48801
|
+
if (existsSync34(p)) {
|
|
48802
|
+
const lines = readFileSync30(p, "utf-8").split("\n");
|
|
48440
48803
|
for (const rawLine of lines) {
|
|
48441
48804
|
const trimmed = rawLine.trim();
|
|
48442
48805
|
const eq = trimmed.indexOf("=");
|
|
@@ -48465,8 +48828,8 @@ function loadAgenticConfig(projectDir) {
|
|
|
48465
48828
|
const p = configPath(projectDir);
|
|
48466
48829
|
let cfg = { ...DEFAULT_CONFIG };
|
|
48467
48830
|
try {
|
|
48468
|
-
if (
|
|
48469
|
-
cfg = { ...cfg, ...JSON.parse(
|
|
48831
|
+
if (existsSync34(p))
|
|
48832
|
+
cfg = { ...cfg, ...JSON.parse(readFileSync30(p, "utf-8")) };
|
|
48470
48833
|
} catch {
|
|
48471
48834
|
}
|
|
48472
48835
|
let hasKey = false;
|
|
@@ -48489,7 +48852,7 @@ function saveAgenticConfig(projectDir, patch) {
|
|
|
48489
48852
|
if (next.baseUrl)
|
|
48490
48853
|
toWrite.baseUrl = next.baseUrl;
|
|
48491
48854
|
try {
|
|
48492
|
-
mkdirSync14(
|
|
48855
|
+
mkdirSync14(dirname22(p), { recursive: true });
|
|
48493
48856
|
writeFileSync17(p, JSON.stringify(toWrite, null, 2), "utf-8");
|
|
48494
48857
|
} catch {
|
|
48495
48858
|
}
|
|
@@ -48508,8 +48871,8 @@ function getProviderSpecificKey(projectDir, provider) {
|
|
|
48508
48871
|
return dotenvFile.trim();
|
|
48509
48872
|
try {
|
|
48510
48873
|
const pp2 = providerKeyPath(projectDir, prov);
|
|
48511
|
-
if (
|
|
48512
|
-
const v =
|
|
48874
|
+
if (existsSync34(pp2)) {
|
|
48875
|
+
const v = readFileSync30(pp2, "utf-8").trim();
|
|
48513
48876
|
if (v)
|
|
48514
48877
|
return v;
|
|
48515
48878
|
}
|
|
@@ -48556,8 +48919,8 @@ function getApiKey(projectDir, provider) {
|
|
|
48556
48919
|
}
|
|
48557
48920
|
try {
|
|
48558
48921
|
const pp2 = providerKeyPath(projectDir, prov);
|
|
48559
|
-
if (
|
|
48560
|
-
const v =
|
|
48922
|
+
if (existsSync34(pp2)) {
|
|
48923
|
+
const v = readFileSync30(pp2, "utf-8").trim();
|
|
48561
48924
|
if (v)
|
|
48562
48925
|
return v;
|
|
48563
48926
|
}
|
|
@@ -48580,8 +48943,8 @@ function getApiKey(projectDir, provider) {
|
|
|
48580
48943
|
}
|
|
48581
48944
|
|
|
48582
48945
|
// ../agentic/dist/dev-api.js
|
|
48583
|
-
import { existsSync as
|
|
48584
|
-
import { resolve as
|
|
48946
|
+
import { existsSync as existsSync35, readFileSync as readFileSync31 } from "node:fs";
|
|
48947
|
+
import { resolve as resolve31 } from "node:path";
|
|
48585
48948
|
|
|
48586
48949
|
// ../agentic/dist/providers/openai.js
|
|
48587
48950
|
var OPENAI_FALLBACK_MODELS = ["gpt-4o-mini", "gpt-4o", "gpt-3.5-turbo"];
|
|
@@ -48951,9 +49314,9 @@ function getPerProviderKeyRaw(projectDir, provider) {
|
|
|
48951
49314
|
} catch {
|
|
48952
49315
|
}
|
|
48953
49316
|
try {
|
|
48954
|
-
const p =
|
|
48955
|
-
if (
|
|
48956
|
-
const v =
|
|
49317
|
+
const p = resolve31(projectDir, ".vesk", "agentic", "keys", `${sanitizeProviderName(prov)}.key`);
|
|
49318
|
+
if (existsSync35(p)) {
|
|
49319
|
+
const v = readFileSync31(p, "utf-8").trim();
|
|
48957
49320
|
if (v)
|
|
48958
49321
|
return v;
|
|
48959
49322
|
}
|
|
@@ -49814,11 +50177,11 @@ var Agent = class {
|
|
|
49814
50177
|
};
|
|
49815
50178
|
|
|
49816
50179
|
// ../agentic/dist/tools/vesk.js
|
|
49817
|
-
import { existsSync as
|
|
49818
|
-
import { resolve as
|
|
50180
|
+
import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync15, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
|
|
50181
|
+
import { resolve as resolve32, join as join22, dirname as dirname23, sep as sep6 } from "node:path";
|
|
49819
50182
|
function resolveWithin3(baseDir, relPath) {
|
|
49820
|
-
const base =
|
|
49821
|
-
const target =
|
|
50183
|
+
const base = resolve32(baseDir);
|
|
50184
|
+
const target = resolve32(baseDir, relPath);
|
|
49822
50185
|
const prefix = base + sep6;
|
|
49823
50186
|
if (target === base || !target.startsWith(prefix))
|
|
49824
50187
|
return null;
|
|
@@ -49826,14 +50189,14 @@ function resolveWithin3(baseDir, relPath) {
|
|
|
49826
50189
|
}
|
|
49827
50190
|
var PLUGIN_STATE_FILENAME3 = "plugins.json";
|
|
49828
50191
|
function stateFilePath3(veskDir) {
|
|
49829
|
-
return
|
|
50192
|
+
return resolve32(veskDir, PLUGIN_STATE_FILENAME3);
|
|
49830
50193
|
}
|
|
49831
50194
|
function readPluginState3(veskDir) {
|
|
49832
50195
|
const file = stateFilePath3(veskDir);
|
|
49833
|
-
if (!
|
|
50196
|
+
if (!existsSync36(file))
|
|
49834
50197
|
return { version: 1, plugins: [] };
|
|
49835
50198
|
try {
|
|
49836
|
-
const raw2 = JSON.parse(
|
|
50199
|
+
const raw2 = JSON.parse(readFileSync32(file, "utf-8"));
|
|
49837
50200
|
if (!raw2 || typeof raw2 !== "object")
|
|
49838
50201
|
return { version: 1, plugins: [] };
|
|
49839
50202
|
if (raw2.version !== 1)
|
|
@@ -49848,7 +50211,7 @@ function readPluginState3(veskDir) {
|
|
|
49848
50211
|
}
|
|
49849
50212
|
function writePluginState3(veskDir, state) {
|
|
49850
50213
|
const file = stateFilePath3(veskDir);
|
|
49851
|
-
mkdirSync15(
|
|
50214
|
+
mkdirSync15(dirname23(file), { recursive: true });
|
|
49852
50215
|
writeFileSync18(file, JSON.stringify(state, null, 2) + "\n", "utf-8");
|
|
49853
50216
|
}
|
|
49854
50217
|
function eqIgnoreCase3(a, b) {
|
|
@@ -49868,16 +50231,16 @@ function validatePackageSpec3(pkg) {
|
|
|
49868
50231
|
return null;
|
|
49869
50232
|
}
|
|
49870
50233
|
function findConfigFile3(projectDir) {
|
|
49871
|
-
const ts9 =
|
|
49872
|
-
if (
|
|
50234
|
+
const ts9 = resolve32(projectDir, "vesk.config.ts");
|
|
50235
|
+
if (existsSync36(ts9))
|
|
49873
50236
|
return { path: ts9, isTs: true };
|
|
49874
|
-
const js =
|
|
49875
|
-
if (
|
|
50237
|
+
const js = resolve32(projectDir, "vesk.config.js");
|
|
50238
|
+
if (existsSync36(js))
|
|
49876
50239
|
return { path: js, isTs: false };
|
|
49877
50240
|
return { path: null, isTs: false };
|
|
49878
50241
|
}
|
|
49879
50242
|
function checkpointDir(veskDir) {
|
|
49880
|
-
return
|
|
50243
|
+
return join22(resolve32(veskDir), "checkpoints");
|
|
49881
50244
|
}
|
|
49882
50245
|
function findMatchingBrace2(src2, openIdx) {
|
|
49883
50246
|
let inStr = null;
|
|
@@ -50006,9 +50369,9 @@ function jsonError(message, extra) {
|
|
|
50006
50369
|
return JSON.stringify({ ok: false, error: message, ...extra || {} });
|
|
50007
50370
|
}
|
|
50008
50371
|
function createVeskTools(deps) {
|
|
50009
|
-
const projectDir =
|
|
50010
|
-
const appDir =
|
|
50011
|
-
const veskDir =
|
|
50372
|
+
const projectDir = resolve32(deps.projectDir);
|
|
50373
|
+
const appDir = resolve32(deps.appDir);
|
|
50374
|
+
const veskDir = resolve32(deps.veskDir);
|
|
50012
50375
|
const tools = [
|
|
50013
50376
|
// 1. vesk.inspectProject
|
|
50014
50377
|
{
|
|
@@ -50021,28 +50384,28 @@ function createVeskTools(deps) {
|
|
|
50021
50384
|
},
|
|
50022
50385
|
async execute(_args) {
|
|
50023
50386
|
try {
|
|
50024
|
-
const projExists =
|
|
50387
|
+
const projExists = existsSync36(projectDir);
|
|
50025
50388
|
const projEntries = projExists ? readdirSync10(projectDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
50026
|
-
const appExists =
|
|
50389
|
+
const appExists = existsSync36(appDir);
|
|
50027
50390
|
const appEntries = appExists ? readdirSync10(appDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
50028
|
-
const veskExists =
|
|
50391
|
+
const veskExists = existsSync36(veskDir);
|
|
50029
50392
|
const veskEntries = veskExists ? readdirSync10(veskDir, { withFileTypes: true }).map((e) => e.isDirectory() ? e.name + "/" : e.name) : [];
|
|
50030
50393
|
const cfgInfo = findConfigFile3(projectDir);
|
|
50031
50394
|
let configSource = null;
|
|
50032
50395
|
let configExists = false;
|
|
50033
|
-
if (cfgInfo.path &&
|
|
50396
|
+
if (cfgInfo.path && existsSync36(cfgInfo.path)) {
|
|
50034
50397
|
configExists = true;
|
|
50035
50398
|
try {
|
|
50036
|
-
configSource =
|
|
50399
|
+
configSource = readFileSync32(cfgInfo.path, "utf-8").slice(0, 8e3);
|
|
50037
50400
|
} catch {
|
|
50038
50401
|
configSource = null;
|
|
50039
50402
|
}
|
|
50040
50403
|
}
|
|
50041
50404
|
let packageJson = null;
|
|
50042
|
-
const pkgPath =
|
|
50043
|
-
if (
|
|
50405
|
+
const pkgPath = resolve32(projectDir, "package.json");
|
|
50406
|
+
if (existsSync36(pkgPath)) {
|
|
50044
50407
|
try {
|
|
50045
|
-
packageJson = JSON.parse(
|
|
50408
|
+
packageJson = JSON.parse(readFileSync32(pkgPath, "utf-8"));
|
|
50046
50409
|
} catch {
|
|
50047
50410
|
packageJson = null;
|
|
50048
50411
|
}
|
|
@@ -50122,7 +50485,7 @@ function createVeskTools(deps) {
|
|
|
50122
50485
|
resolved = resolveWithin3(appDir, rel);
|
|
50123
50486
|
if (!resolved)
|
|
50124
50487
|
return jsonError("path escapes project root", { path: rel });
|
|
50125
|
-
if (!
|
|
50488
|
+
if (!existsSync36(resolved))
|
|
50126
50489
|
return jsonError("not found", { path: rel });
|
|
50127
50490
|
const st = statSync19(resolved);
|
|
50128
50491
|
if (st.isDirectory()) {
|
|
@@ -50130,7 +50493,7 @@ function createVeskTools(deps) {
|
|
|
50130
50493
|
return jsonOk({ ok: true, path: rel, directory: true, entries: entries.slice(0, 200) });
|
|
50131
50494
|
}
|
|
50132
50495
|
if (st.isFile()) {
|
|
50133
|
-
const content =
|
|
50496
|
+
const content = readFileSync32(resolved, "utf-8");
|
|
50134
50497
|
const capped = content.length > 2e4 ? content.slice(0, 2e4) + "\n/* truncated */" : content;
|
|
50135
50498
|
return jsonOk({ ok: true, path: rel, directory: false, content: capped, size: content.length });
|
|
50136
50499
|
}
|
|
@@ -50163,10 +50526,10 @@ function createVeskTools(deps) {
|
|
|
50163
50526
|
}
|
|
50164
50527
|
}
|
|
50165
50528
|
const info = findConfigFile3(projectDir);
|
|
50166
|
-
if (!info.path || !
|
|
50529
|
+
if (!info.path || !existsSync36(info.path)) {
|
|
50167
50530
|
return jsonOk({ ok: true, path: null, exists: false, source: "", config: {} });
|
|
50168
50531
|
}
|
|
50169
|
-
const source =
|
|
50532
|
+
const source = readFileSync32(info.path, "utf-8");
|
|
50170
50533
|
return jsonOk({ ok: true, path: info.path, exists: true, source, config: null });
|
|
50171
50534
|
} catch (e) {
|
|
50172
50535
|
return jsonError(e instanceof Error ? e.message : String(e));
|
|
@@ -50199,16 +50562,16 @@ function createVeskTools(deps) {
|
|
|
50199
50562
|
target = info.path;
|
|
50200
50563
|
const rel = target.startsWith(projectDir + sep6) ? target.slice(projectDir.length + 1) : "vesk.config.ts";
|
|
50201
50564
|
const contained = resolveWithin3(projectDir, rel);
|
|
50202
|
-
if (!contained && target !==
|
|
50565
|
+
if (!contained && target !== resolve32(projectDir, "vesk.config.ts") && target !== resolve32(projectDir, "vesk.config.js")) {
|
|
50203
50566
|
return jsonError("path escapes project root");
|
|
50204
50567
|
}
|
|
50205
50568
|
} else {
|
|
50206
|
-
target =
|
|
50569
|
+
target = resolve32(projectDir, "vesk.config.ts");
|
|
50207
50570
|
const contained = resolveWithin3(projectDir, "vesk.config.ts");
|
|
50208
50571
|
if (!contained)
|
|
50209
50572
|
return jsonError("path escapes project root");
|
|
50210
50573
|
}
|
|
50211
|
-
mkdirSync15(
|
|
50574
|
+
mkdirSync15(dirname23(target), { recursive: true });
|
|
50212
50575
|
writeFileSync18(target, source, "utf-8");
|
|
50213
50576
|
return jsonOk({ ok: true, path: target, source });
|
|
50214
50577
|
}
|
|
@@ -50224,7 +50587,7 @@ function createVeskTools(deps) {
|
|
|
50224
50587
|
const contained = resolveWithin3(projectDir, info.path.slice(projectDir.length + 1));
|
|
50225
50588
|
if (!contained)
|
|
50226
50589
|
return jsonError("path escapes project root");
|
|
50227
|
-
const current2 =
|
|
50590
|
+
const current2 = readFileSync32(info.path, "utf-8");
|
|
50228
50591
|
const patched = applySimpleConfigToggle(current2, key, a.value);
|
|
50229
50592
|
if (patched === null)
|
|
50230
50593
|
return jsonError("could not safely edit the config object; use the source editor");
|
|
@@ -50492,7 +50855,7 @@ function createVeskTools(deps) {
|
|
|
50492
50855
|
const dir = checkpointDir(veskDir);
|
|
50493
50856
|
mkdirSync15(dir, { recursive: true });
|
|
50494
50857
|
const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
50495
|
-
const file =
|
|
50858
|
+
const file = join22(dir, `${id}.json`);
|
|
50496
50859
|
const check = resolveWithin3(dir, `${id}.json`);
|
|
50497
50860
|
if (!check)
|
|
50498
50861
|
return jsonError("path escapes project root");
|
|
@@ -50541,13 +50904,13 @@ function createVeskTools(deps) {
|
|
|
50541
50904
|
} catch {
|
|
50542
50905
|
}
|
|
50543
50906
|
const dir = checkpointDir(veskDir);
|
|
50544
|
-
const file =
|
|
50907
|
+
const file = join22(dir, `${checkpointId}.json`);
|
|
50545
50908
|
const contained = resolveWithin3(dir, `${checkpointId}.json`);
|
|
50546
50909
|
if (!contained)
|
|
50547
50910
|
return jsonError("path escapes project root");
|
|
50548
|
-
if (!
|
|
50911
|
+
if (!existsSync36(file))
|
|
50549
50912
|
return jsonError(`checkpoint not found: ${checkpointId}`, { checkpointId });
|
|
50550
|
-
const raw2 =
|
|
50913
|
+
const raw2 = readFileSync32(file, "utf-8");
|
|
50551
50914
|
let data2;
|
|
50552
50915
|
try {
|
|
50553
50916
|
data2 = JSON.parse(raw2);
|
|
@@ -50565,15 +50928,15 @@ function createVeskTools(deps) {
|
|
|
50565
50928
|
}
|
|
50566
50929
|
|
|
50567
50930
|
// ../adapter/dist/css.js
|
|
50568
|
-
import { readFileSync as
|
|
50569
|
-
import { resolve as
|
|
50931
|
+
import { readFileSync as readFileSync33, existsSync as existsSync37 } from "node:fs";
|
|
50932
|
+
import { resolve as resolve33 } from "node:path";
|
|
50570
50933
|
var GLOBAL_CSS_URL2 = "/_vesk/static/global.css";
|
|
50571
50934
|
function resolveUserCssPath2(appDir) {
|
|
50572
|
-
const cssSrc =
|
|
50573
|
-
if (
|
|
50935
|
+
const cssSrc = resolve33(appDir, "..", "src", "global.css");
|
|
50936
|
+
if (existsSync37(cssSrc))
|
|
50574
50937
|
return cssSrc;
|
|
50575
|
-
const altCssSrc =
|
|
50576
|
-
if (
|
|
50938
|
+
const altCssSrc = resolve33(appDir, "..", "src", "app.css");
|
|
50939
|
+
if (existsSync37(altCssSrc))
|
|
50577
50940
|
return altCssSrc;
|
|
50578
50941
|
return null;
|
|
50579
50942
|
}
|
|
@@ -50589,8 +50952,8 @@ function resolveCssUrls2(opts) {
|
|
|
50589
50952
|
// ../adapter/dist/hmr.js
|
|
50590
50953
|
init_client_codegen();
|
|
50591
50954
|
import { WebSocketServer } from "ws";
|
|
50592
|
-
import { readFileSync as
|
|
50593
|
-
import { resolve as
|
|
50955
|
+
import { readFileSync as readFileSync34, existsSync as existsSync38, writeFileSync as writeFileSync19 } from "node:fs";
|
|
50956
|
+
import { resolve as resolve34, dirname as dirname24 } from "node:path";
|
|
50594
50957
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
50595
50958
|
init_paths();
|
|
50596
50959
|
|
|
@@ -50797,7 +51160,7 @@ function suggestFor(message) {
|
|
|
50797
51160
|
}
|
|
50798
51161
|
|
|
50799
51162
|
// ../adapter/dist/hmr.js
|
|
50800
|
-
var __dirname8 =
|
|
51163
|
+
var __dirname8 = dirname24(fileURLToPath7(import.meta.url));
|
|
50801
51164
|
function buildErrorPayload(error, filename, opts = {}) {
|
|
50802
51165
|
const file = typeof filename === "string" && filename ? filename : "unknown";
|
|
50803
51166
|
const parsed = parseCompilerError(error, file);
|
|
@@ -50820,19 +51183,19 @@ function buildErrorPayload(error, filename, opts = {}) {
|
|
|
50820
51183
|
if (file.startsWith("/")) {
|
|
50821
51184
|
candidates.push(file);
|
|
50822
51185
|
} else {
|
|
50823
|
-
candidates.push(
|
|
51186
|
+
candidates.push(resolve34(opts.appDir, file));
|
|
50824
51187
|
if (file.startsWith("app/")) {
|
|
50825
|
-
candidates.push(
|
|
50826
|
-
candidates.push(
|
|
51188
|
+
candidates.push(resolve34(opts.appDir, file.slice(4)));
|
|
51189
|
+
candidates.push(resolve34(opts.appDir, "..", file));
|
|
50827
51190
|
} else {
|
|
50828
|
-
candidates.push(
|
|
51191
|
+
candidates.push(resolve34(opts.appDir, "..", file));
|
|
50829
51192
|
}
|
|
50830
|
-
candidates.push(
|
|
51193
|
+
candidates.push(resolve34(file));
|
|
50831
51194
|
}
|
|
50832
51195
|
for (const absPath of candidates) {
|
|
50833
51196
|
try {
|
|
50834
|
-
if (
|
|
50835
|
-
src2 =
|
|
51197
|
+
if (existsSync38(absPath)) {
|
|
51198
|
+
src2 = readFileSync34(absPath, "utf-8");
|
|
50836
51199
|
resolvedAbsPath = absPath;
|
|
50837
51200
|
break;
|
|
50838
51201
|
}
|
|
@@ -50848,7 +51211,7 @@ function buildErrorPayload(error, filename, opts = {}) {
|
|
|
50848
51211
|
}
|
|
50849
51212
|
}
|
|
50850
51213
|
const tipsData = suggestFor(message);
|
|
50851
|
-
const filePath = resolvedAbsPath ?? (typeof opts.appDir === "string" ?
|
|
51214
|
+
const filePath = resolvedAbsPath ?? (typeof opts.appDir === "string" ? resolve34(opts.appDir, file) : void 0);
|
|
50852
51215
|
const errorCode = parsed && typeof parsed.code === "string" && parsed.code ? parsed.code : error?.code ? String(error.code) : void 0;
|
|
50853
51216
|
const cleanMessage = filePath && message.endsWith(` in ${filePath}`) ? message.slice(0, -` in ${filePath}`.length).trim() : message.endsWith(` in ${file}`) ? message.slice(0, -` in ${file}`.length).trim() : message;
|
|
50854
51217
|
const payload = {
|
|
@@ -50880,8 +51243,8 @@ function buildErrorPayload(error, filename, opts = {}) {
|
|
|
50880
51243
|
}
|
|
50881
51244
|
|
|
50882
51245
|
// ../adapter/dist/ssr-error.js
|
|
50883
|
-
import { existsSync as
|
|
50884
|
-
import { relative as relative7, resolve as
|
|
51246
|
+
import { existsSync as existsSync39, readFileSync as readFileSync35 } from "node:fs";
|
|
51247
|
+
import { relative as relative7, resolve as resolve35 } from "node:path";
|
|
50885
51248
|
|
|
50886
51249
|
// ../adapter/dist/error-codeframe.js
|
|
50887
51250
|
function buildCodeframe2(src2, line, column, context = 5) {
|
|
@@ -51065,7 +51428,7 @@ function firstSourceFileFrame(stack, projectRoot) {
|
|
|
51065
51428
|
if (!isInsideRoot(p, projectRoot))
|
|
51066
51429
|
continue;
|
|
51067
51430
|
try {
|
|
51068
|
-
if (!
|
|
51431
|
+
if (!existsSync39(p))
|
|
51069
51432
|
continue;
|
|
51070
51433
|
} catch {
|
|
51071
51434
|
continue;
|
|
@@ -51096,7 +51459,7 @@ function findIdentifierUsage(src2, name) {
|
|
|
51096
51459
|
return null;
|
|
51097
51460
|
}
|
|
51098
51461
|
function projectOf(ctx2) {
|
|
51099
|
-
return ctx2.projectDir ||
|
|
51462
|
+
return ctx2.projectDir || resolve35(ctx2.appDir, "..");
|
|
51100
51463
|
}
|
|
51101
51464
|
function displayPath(absPath, ctx2) {
|
|
51102
51465
|
const appRel = relative7(ctx2.appDir, absPath);
|
|
@@ -51109,9 +51472,9 @@ function displayPath(absPath, ctx2) {
|
|
|
51109
51472
|
}
|
|
51110
51473
|
function readIfFile(absPath) {
|
|
51111
51474
|
try {
|
|
51112
|
-
if (!
|
|
51475
|
+
if (!existsSync39(absPath))
|
|
51113
51476
|
return null;
|
|
51114
|
-
return
|
|
51477
|
+
return readFileSync35(absPath, "utf-8");
|
|
51115
51478
|
} catch {
|
|
51116
51479
|
return null;
|
|
51117
51480
|
}
|
|
@@ -51119,13 +51482,13 @@ function readIfFile(absPath) {
|
|
|
51119
51482
|
function resolveComponentFile(name, ctx2) {
|
|
51120
51483
|
const fromRoutes = ctx2.routeSources?.get(name);
|
|
51121
51484
|
if (fromRoutes) {
|
|
51122
|
-
const abs =
|
|
51485
|
+
const abs = resolve35(ctx2.appDir, fromRoutes);
|
|
51123
51486
|
if (readIfFile(abs) !== null)
|
|
51124
51487
|
return abs;
|
|
51125
51488
|
}
|
|
51126
51489
|
const fromShared = ctx2.componentMap?.get(name);
|
|
51127
51490
|
if (fromShared) {
|
|
51128
|
-
const abs =
|
|
51491
|
+
const abs = resolve35(projectOf(ctx2), fromShared);
|
|
51129
51492
|
if (readIfFile(abs) !== null)
|
|
51130
51493
|
return abs;
|
|
51131
51494
|
if (readIfFile(fromShared) !== null)
|
|
@@ -51259,13 +51622,13 @@ function renderDevErrorPage(payload, opts) {
|
|
|
51259
51622
|
|
|
51260
51623
|
// src/build-packages.ts
|
|
51261
51624
|
import { spawnSync } from "node:child_process";
|
|
51262
|
-
import { cpSync as cpSync2, existsSync as
|
|
51625
|
+
import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync16, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
|
|
51263
51626
|
import { createRequire as createRequire6 } from "node:module";
|
|
51264
|
-
import { dirname as
|
|
51627
|
+
import { dirname as dirname25, join as join23, resolve as resolve36 } from "node:path";
|
|
51265
51628
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
51266
51629
|
var require2 = createRequire6(import.meta.url);
|
|
51267
|
-
var __dirname9 =
|
|
51268
|
-
var root2 =
|
|
51630
|
+
var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
|
|
51631
|
+
var root2 = resolve36(__dirname9, "..", "..", "..");
|
|
51269
51632
|
var PACKAGES = {
|
|
51270
51633
|
// types first — it is a dependency-free leaf that compiler and adapter
|
|
51271
51634
|
// import for their shared type definitions.
|
|
@@ -51290,7 +51653,7 @@ var PACKAGES = {
|
|
|
51290
51653
|
function newestSourceMtime(srcDir) {
|
|
51291
51654
|
let newest = 0;
|
|
51292
51655
|
for (const name of readdirSync11(srcDir)) {
|
|
51293
|
-
const p =
|
|
51656
|
+
const p = join23(srcDir, name);
|
|
51294
51657
|
const st = statSync20(p);
|
|
51295
51658
|
if (st.isDirectory()) {
|
|
51296
51659
|
newest = Math.max(newest, newestSourceMtime(p));
|
|
@@ -51301,11 +51664,11 @@ function newestSourceMtime(srcDir) {
|
|
|
51301
51664
|
return newest;
|
|
51302
51665
|
}
|
|
51303
51666
|
function distStale(pkgDir, entry) {
|
|
51304
|
-
const distIndex =
|
|
51305
|
-
if (!
|
|
51306
|
-
const distPkg =
|
|
51307
|
-
const distStamp = Math.max(statSync20(distIndex).mtimeMs,
|
|
51308
|
-
return newestSourceMtime(
|
|
51667
|
+
const distIndex = join23(pkgDir, "dist", `${entry}.js`);
|
|
51668
|
+
if (!existsSync40(distIndex)) return true;
|
|
51669
|
+
const distPkg = join23(pkgDir, "dist", "package.json");
|
|
51670
|
+
const distStamp = Math.max(statSync20(distIndex).mtimeMs, existsSync40(distPkg) ? statSync20(distPkg).mtimeMs : 0);
|
|
51671
|
+
return newestSourceMtime(join23(pkgDir, "src")) > distStamp;
|
|
51309
51672
|
}
|
|
51310
51673
|
function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
51311
51674
|
const exports = {
|
|
@@ -51328,24 +51691,24 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
|
51328
51691
|
}
|
|
51329
51692
|
function buildPackages(force = false) {
|
|
51330
51693
|
for (const [pkg, cfg] of Object.entries(PACKAGES)) {
|
|
51331
|
-
const pkgDir =
|
|
51332
|
-
if (!
|
|
51694
|
+
const pkgDir = resolve36(root2, "packages", pkg);
|
|
51695
|
+
if (!existsSync40(join23(pkgDir, "src"))) continue;
|
|
51333
51696
|
if (!force && !distStale(pkgDir, cfg.entry)) continue;
|
|
51334
51697
|
console.log(`[build] ${cfg.name} -> tsc`);
|
|
51335
51698
|
const tscBin = require2.resolve("typescript/bin/tsc");
|
|
51336
|
-
const result = spawnSync(process.execPath, [tscBin, "-p",
|
|
51699
|
+
const result = spawnSync(process.execPath, [tscBin, "-p", join23(pkgDir, "tsconfig.build.json")], {
|
|
51337
51700
|
stdio: "inherit"
|
|
51338
51701
|
});
|
|
51339
51702
|
if (result.status !== 0) {
|
|
51340
51703
|
throw new Error(`tsc failed for ${cfg.name}`);
|
|
51341
51704
|
}
|
|
51342
|
-
const distDir =
|
|
51705
|
+
const distDir = join23(pkgDir, "dist");
|
|
51343
51706
|
for (const c of cfg.copy || []) {
|
|
51344
|
-
const to =
|
|
51345
|
-
mkdirSync16(
|
|
51346
|
-
cpSync2(
|
|
51707
|
+
const to = join23(distDir, c.to);
|
|
51708
|
+
mkdirSync16(dirname25(to), { recursive: true });
|
|
51709
|
+
cpSync2(join23(pkgDir, c.from), to, { recursive: true });
|
|
51347
51710
|
}
|
|
51348
|
-
const srcPkg = JSON.parse(
|
|
51711
|
+
const srcPkg = JSON.parse(readFileSync36(join23(pkgDir, "package.json"), "utf-8"));
|
|
51349
51712
|
if (pkg === "lucide-vesk") {
|
|
51350
51713
|
const lucideDistPkg = {
|
|
51351
51714
|
name: srcPkg.name,
|
|
@@ -51359,9 +51722,9 @@ function buildPackages(force = false) {
|
|
|
51359
51722
|
"./package.json": "./package.json"
|
|
51360
51723
|
}
|
|
51361
51724
|
};
|
|
51362
|
-
writeFileSync20(
|
|
51725
|
+
writeFileSync20(join23(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
|
|
51363
51726
|
} else {
|
|
51364
|
-
writeFileSync20(
|
|
51727
|
+
writeFileSync20(join23(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
|
|
51365
51728
|
}
|
|
51366
51729
|
console.log(`[build] ${cfg.name} -> dist`);
|
|
51367
51730
|
}
|
|
@@ -51369,13 +51732,13 @@ function buildPackages(force = false) {
|
|
|
51369
51732
|
function ensurePackagesBuilt() {
|
|
51370
51733
|
buildPackages(false);
|
|
51371
51734
|
}
|
|
51372
|
-
if (process.argv[1] &&
|
|
51735
|
+
if (process.argv[1] && resolve36(process.argv[1]) === fileURLToPath8(import.meta.url)) {
|
|
51373
51736
|
buildPackages(process.argv.includes("--force"));
|
|
51374
51737
|
}
|
|
51375
51738
|
|
|
51376
51739
|
// src/action-handler.ts
|
|
51377
|
-
import { existsSync as
|
|
51378
|
-
import { resolve as
|
|
51740
|
+
import { existsSync as existsSync41, readFileSync as readFileSync37, readdirSync as readdirSync12 } from "node:fs";
|
|
51741
|
+
import { resolve as resolve37 } from "node:path";
|
|
51379
51742
|
|
|
51380
51743
|
// ../compiler/dist/server-cookies.js
|
|
51381
51744
|
function parseCookies3(str3) {
|
|
@@ -51458,8 +51821,8 @@ function pageSourcesFor(appDirPath, routeTree) {
|
|
|
51458
51821
|
const out = [];
|
|
51459
51822
|
function walk7(nodes) {
|
|
51460
51823
|
for (const node of nodes) {
|
|
51461
|
-
if (node.page) out.push(
|
|
51462
|
-
if (node.layout) out.push(
|
|
51824
|
+
if (node.page) out.push(resolve37(appDirPath, node.sourceDir, "page.vsk"));
|
|
51825
|
+
if (node.layout) out.push(resolve37(appDirPath, node.sourceDir, "layout.vsk"));
|
|
51463
51826
|
walk7(node.children);
|
|
51464
51827
|
}
|
|
51465
51828
|
}
|
|
@@ -51467,7 +51830,7 @@ function pageSourcesFor(appDirPath, routeTree) {
|
|
|
51467
51830
|
return out;
|
|
51468
51831
|
}
|
|
51469
51832
|
function walkVskFiles(dir, out, seen) {
|
|
51470
|
-
if (!
|
|
51833
|
+
if (!existsSync41(dir)) return;
|
|
51471
51834
|
let entries;
|
|
51472
51835
|
try {
|
|
51473
51836
|
entries = readdirSync12(dir, { withFileTypes: true });
|
|
@@ -51475,7 +51838,7 @@ function walkVskFiles(dir, out, seen) {
|
|
|
51475
51838
|
return;
|
|
51476
51839
|
}
|
|
51477
51840
|
for (const entry of entries) {
|
|
51478
|
-
const full =
|
|
51841
|
+
const full = resolve37(dir, entry.name);
|
|
51479
51842
|
if (seen.has(full)) continue;
|
|
51480
51843
|
seen.add(full);
|
|
51481
51844
|
if (entry.isDirectory()) {
|
|
@@ -51495,16 +51858,16 @@ function candidateSources(appDirPath, routeTree) {
|
|
|
51495
51858
|
seen.add(src2);
|
|
51496
51859
|
out.push(src2);
|
|
51497
51860
|
}
|
|
51498
|
-
const projectRoot =
|
|
51499
|
-
for (const dir of [
|
|
51861
|
+
const projectRoot = resolve37(appDirPath, "..");
|
|
51862
|
+
for (const dir of [resolve37(projectRoot, "components"), appDirPath, projectRoot]) {
|
|
51500
51863
|
walkVskFiles(dir, out, seen);
|
|
51501
51864
|
}
|
|
51502
51865
|
return out;
|
|
51503
51866
|
}
|
|
51504
51867
|
function registerSource(sourcePath2) {
|
|
51505
|
-
if (!
|
|
51868
|
+
if (!existsSync41(sourcePath2)) return;
|
|
51506
51869
|
try {
|
|
51507
|
-
compileFile(
|
|
51870
|
+
compileFile(readFileSync37(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
|
|
51508
51871
|
} catch {
|
|
51509
51872
|
}
|
|
51510
51873
|
}
|
|
@@ -51513,8 +51876,8 @@ function ensureActionRegistered(actionId, pagePathname, appDirPath, routeTree) {
|
|
|
51513
51876
|
const match = matchUrl(routeTree, pagePathname);
|
|
51514
51877
|
if (match) {
|
|
51515
51878
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
51516
|
-
registerSource(
|
|
51517
|
-
registerSource(
|
|
51879
|
+
registerSource(resolve37(appDirPath, match.nodes[i].sourceDir, "page.vsk"));
|
|
51880
|
+
registerSource(resolve37(appDirPath, match.nodes[i].sourceDir, "layout.vsk"));
|
|
51518
51881
|
}
|
|
51519
51882
|
}
|
|
51520
51883
|
if (getAction2(actionId)) return;
|
|
@@ -51540,24 +51903,24 @@ async function renderPageHtml(pagePathname, params, ctx2) {
|
|
|
51540
51903
|
let head = "";
|
|
51541
51904
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
51542
51905
|
const node = chain[i];
|
|
51543
|
-
const pageFilePath =
|
|
51544
|
-
const layoutFilePath =
|
|
51545
|
-
if (i === chain.length - 1 && node.page &&
|
|
51546
|
-
const src3 =
|
|
51906
|
+
const pageFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "page.vsk");
|
|
51907
|
+
const layoutFilePath = resolve37(ctx2.appDirPath, node.sourceDir, "layout.vsk");
|
|
51908
|
+
if (i === chain.length - 1 && node.page && existsSync41(pageFilePath)) {
|
|
51909
|
+
const src3 = readFileSync37(pageFilePath, "utf-8");
|
|
51547
51910
|
const compName2 = resolveComponentName(src3) || node.page;
|
|
51548
51911
|
const result = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
51549
51912
|
body = result.body;
|
|
51550
51913
|
head = result.head || "";
|
|
51551
51914
|
}
|
|
51552
|
-
if (node.layout &&
|
|
51553
|
-
const src3 =
|
|
51915
|
+
if (node.layout && existsSync41(layoutFilePath)) {
|
|
51916
|
+
const src3 = readFileSync37(layoutFilePath, "utf-8");
|
|
51554
51917
|
const compName2 = resolveComponentName(src3) || node.layout;
|
|
51555
51918
|
const result = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
51556
51919
|
body = result.body;
|
|
51557
51920
|
head = (result.head || "") + head;
|
|
51558
51921
|
}
|
|
51559
51922
|
}
|
|
51560
|
-
const hasLayout = chain.some((n) => n.layout &&
|
|
51923
|
+
const hasLayout = chain.some((n) => n.layout && existsSync41(resolve37(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
|
|
51561
51924
|
if (hasLayout) {
|
|
51562
51925
|
const secMeta = securityMeta(ctx2.security);
|
|
51563
51926
|
const headBlock = await applyHeadInjects(
|
|
@@ -51581,9 +51944,9 @@ ${prettifyHtml(body)}
|
|
|
51581
51944
|
}
|
|
51582
51945
|
const leaf = chain.find((n) => n.page);
|
|
51583
51946
|
if (!leaf) return null;
|
|
51584
|
-
const src2 =
|
|
51947
|
+
const src2 = readFileSync37(resolve37(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
51585
51948
|
const compName = resolveComponentName(src2) || leaf.page;
|
|
51586
|
-
const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: actionCssUrls(ctx2.appDirPath), security: ctx2.security, sourcePath:
|
|
51949
|
+
const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: actionCssUrls(ctx2.appDirPath), security: ctx2.security, sourcePath: resolve37(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), plugins: ctx2.plugins });
|
|
51587
51950
|
return applyHtmlPlugins(html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>'), ctx2.plugins, { sourcePath: ctx2.url.pathname });
|
|
51588
51951
|
}
|
|
51589
51952
|
async function handleActionRequest(req, res, ctx2) {
|
|
@@ -51748,7 +52111,7 @@ function buildDevErrorPayload(input) {
|
|
|
51748
52111
|
payload.column = colMatch ? parseInt(colMatch[1], 10) : 1;
|
|
51749
52112
|
if (fileExists && payload.line > 0) {
|
|
51750
52113
|
try {
|
|
51751
|
-
const src2 =
|
|
52114
|
+
const src2 = readFileSync38(fullPath, "utf-8");
|
|
51752
52115
|
const cf = buildCodeframe2(src2, payload.line, payload.column);
|
|
51753
52116
|
if (cf) {
|
|
51754
52117
|
cf.file = payload.file || filename;
|
|
@@ -51766,14 +52129,14 @@ function resolveDevErrorReport(report, ctx2) {
|
|
|
51766
52129
|
let componentMap;
|
|
51767
52130
|
let routeSources;
|
|
51768
52131
|
try {
|
|
51769
|
-
componentMap = scanComponents(
|
|
52132
|
+
componentMap = scanComponents(resolve38(ctx2.projectDir, "components"));
|
|
51770
52133
|
} catch {
|
|
51771
52134
|
componentMap = void 0;
|
|
51772
52135
|
}
|
|
51773
52136
|
try {
|
|
51774
52137
|
routeSources = /* @__PURE__ */ new Map();
|
|
51775
52138
|
for (const [name, rel] of collectSources(ctx2.routeTree || [])) {
|
|
51776
|
-
routeSources.set(name,
|
|
52139
|
+
routeSources.set(name, resolve38(ctx2.appDir, rel));
|
|
51777
52140
|
}
|
|
51778
52141
|
} catch {
|
|
51779
52142
|
routeSources = void 0;
|
|
@@ -51804,9 +52167,9 @@ function devErrorContextForMatch(match, appDir, projectDir, routeTree) {
|
|
|
51804
52167
|
for (const kind of ["page.vsk", "layout.vsk", "error.vsk"]) {
|
|
51805
52168
|
for (const node of nodes) {
|
|
51806
52169
|
if (!node || typeof node.sourceDir !== "string") continue;
|
|
51807
|
-
const p =
|
|
52170
|
+
const p = resolve38(appDir, node.sourceDir, kind);
|
|
51808
52171
|
try {
|
|
51809
|
-
if (
|
|
52172
|
+
if (existsSync42(p) && !routeFiles.includes(p)) routeFiles.push(p);
|
|
51810
52173
|
} catch {
|
|
51811
52174
|
}
|
|
51812
52175
|
}
|
|
@@ -51816,14 +52179,14 @@ function devErrorContextForMatch(match, appDir, projectDir, routeTree) {
|
|
|
51816
52179
|
let componentMap;
|
|
51817
52180
|
let routeSources;
|
|
51818
52181
|
try {
|
|
51819
|
-
componentMap = scanComponents(
|
|
52182
|
+
componentMap = scanComponents(resolve38(projectDir, "components"));
|
|
51820
52183
|
} catch {
|
|
51821
52184
|
componentMap = void 0;
|
|
51822
52185
|
}
|
|
51823
52186
|
try {
|
|
51824
52187
|
routeSources = /* @__PURE__ */ new Map();
|
|
51825
52188
|
for (const [name, rel] of collectSources(routeTree || [])) {
|
|
51826
|
-
routeSources.set(name,
|
|
52189
|
+
routeSources.set(name, resolve38(appDir, rel));
|
|
51827
52190
|
}
|
|
51828
52191
|
} catch {
|
|
51829
52192
|
routeSources = void 0;
|
|
@@ -51833,14 +52196,14 @@ function devErrorContextForMatch(match, appDir, projectDir, routeTree) {
|
|
|
51833
52196
|
function resolveRuntimeDir(projectDir) {
|
|
51834
52197
|
const candidates = [
|
|
51835
52198
|
// installed app layout
|
|
51836
|
-
|
|
52199
|
+
resolve38(projectDir, "node_modules", "@vesk", "runtime"),
|
|
51837
52200
|
// monorepo checkout (tests/probes run from the repo root)
|
|
51838
|
-
|
|
52201
|
+
resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
|
|
51839
52202
|
];
|
|
51840
52203
|
for (const dir of candidates) {
|
|
51841
|
-
if (
|
|
51842
|
-
const distDir =
|
|
51843
|
-
if (
|
|
52204
|
+
if (existsSync42(join24(dir, "ripple-runtime.js"))) return dir;
|
|
52205
|
+
const distDir = join24(dir, "dist");
|
|
52206
|
+
if (existsSync42(join24(distDir, "ripple-runtime.js"))) return distDir;
|
|
51844
52207
|
}
|
|
51845
52208
|
return null;
|
|
51846
52209
|
}
|
|
@@ -51967,6 +52330,46 @@ function writeDevPanelResponse(res, response) {
|
|
|
51967
52330
|
}
|
|
51968
52331
|
var ssrDataStore = /* @__PURE__ */ new Map();
|
|
51969
52332
|
var HMR_DEBOUNCE_MS = 12;
|
|
52333
|
+
var ROUTE_STRUCTURAL_VSK = /* @__PURE__ */ new Set([
|
|
52334
|
+
"page.vsk",
|
|
52335
|
+
"layout.vsk",
|
|
52336
|
+
"loading.vsk",
|
|
52337
|
+
"error.vsk",
|
|
52338
|
+
"not-found.vsk",
|
|
52339
|
+
"offline.vsk",
|
|
52340
|
+
"network.vsk"
|
|
52341
|
+
]);
|
|
52342
|
+
var HMR_SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".vesk", "tarballs", ".git"]);
|
|
52343
|
+
var HMR_SKIP_MARKERS = ["node_modules/", ".vesk/", "tmp-vesk-chunk-"];
|
|
52344
|
+
var HMR_SCRIPT_EXTS = [".mts", ".ts", ".tsx", ".mjs", ".js", ".cjs"];
|
|
52345
|
+
var HMR_CONFIG_NAMES = /* @__PURE__ */ new Set([
|
|
52346
|
+
"vesk.config.ts",
|
|
52347
|
+
"vesk.config.js",
|
|
52348
|
+
"vesk.config.mjs",
|
|
52349
|
+
"vesk.config.mts",
|
|
52350
|
+
"postcss.config.js",
|
|
52351
|
+
"postcss.config.ts",
|
|
52352
|
+
"tailwind.config.js",
|
|
52353
|
+
"tailwind.config.ts",
|
|
52354
|
+
"tsconfig.json",
|
|
52355
|
+
"package.json"
|
|
52356
|
+
]);
|
|
52357
|
+
function classifyHmrWatchPath(relPath) {
|
|
52358
|
+
const first = relPath.split("/")[0];
|
|
52359
|
+
if (HMR_SKIP_DIRS.has(first) || HMR_SKIP_MARKERS.some((m) => relPath.includes(m))) return "ignored";
|
|
52360
|
+
const name = relPath.slice(relPath.lastIndexOf("/") + 1);
|
|
52361
|
+
if (relPath.endsWith(".vsk") || relPath.endsWith(".md") || relPath.endsWith(".markdown")) return "vsk";
|
|
52362
|
+
if (relPath.endsWith(".css")) return "css";
|
|
52363
|
+
if (name === "_events.ts" || name === "_events.js") return "events";
|
|
52364
|
+
if (HMR_CONFIG_NAMES.has(name)) return "config";
|
|
52365
|
+
if (HMR_SCRIPT_EXTS.some((ext) => relPath.endsWith(ext))) return "script";
|
|
52366
|
+
return "ignored";
|
|
52367
|
+
}
|
|
52368
|
+
function shouldRescanRoutes(relPath, eventType) {
|
|
52369
|
+
if (eventType === "rename") return true;
|
|
52370
|
+
const name = relPath.slice(relPath.lastIndexOf("/") + 1);
|
|
52371
|
+
return relPath.endsWith(".vsk") && ROUTE_STRUCTURAL_VSK.has(name);
|
|
52372
|
+
}
|
|
51970
52373
|
function storeDataScript(payload) {
|
|
51971
52374
|
if (!payload.props && !payload.ssrData) return null;
|
|
51972
52375
|
if (ssrDataStore.size >= 100) {
|
|
@@ -51999,10 +52402,10 @@ function collectRoutePaths(nodes, out = []) {
|
|
|
51999
52402
|
return out;
|
|
52000
52403
|
}
|
|
52001
52404
|
function countFilesNamed(dir, name) {
|
|
52002
|
-
if (!
|
|
52405
|
+
if (!existsSync42(dir)) return 0;
|
|
52003
52406
|
let n = 0;
|
|
52004
52407
|
for (const entry of readdirSync13(dir, { withFileTypes: true })) {
|
|
52005
|
-
const p =
|
|
52408
|
+
const p = join24(dir, entry.name);
|
|
52006
52409
|
if (entry.isDirectory()) n += countFilesNamed(p, name);
|
|
52007
52410
|
else if (entry.name === name) n++;
|
|
52008
52411
|
}
|
|
@@ -52013,8 +52416,8 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
52013
52416
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "development";
|
|
52014
52417
|
const secCfg = config.security || {};
|
|
52015
52418
|
const maxBodyBytes = (typeof secCfg.maxBodyBytes === "number" ? secCfg.maxBodyBytes : void 0) || DEFAULT_MAX_BODY_BYTES;
|
|
52016
|
-
const appDirPath =
|
|
52017
|
-
const publicDir =
|
|
52419
|
+
const appDirPath = join24(projectDir, "app");
|
|
52420
|
+
const publicDir = join24(projectDir, "public");
|
|
52018
52421
|
installMdReadHook2([publicDir]);
|
|
52019
52422
|
try {
|
|
52020
52423
|
ensurePackagesBuilt();
|
|
@@ -52027,7 +52430,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
52027
52430
|
process.exit(1);
|
|
52028
52431
|
}
|
|
52029
52432
|
const runtimeDir = runtimeDirUnchecked;
|
|
52030
|
-
const veskStateDir =
|
|
52433
|
+
const veskStateDir = join24(projectDir, ".vesk");
|
|
52031
52434
|
const configPluginsRaw = config.plugins || [];
|
|
52032
52435
|
const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
|
|
52033
52436
|
const rawDevPlugins = config.plugins || [];
|
|
@@ -52126,14 +52529,14 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
52126
52529
|
}
|
|
52127
52530
|
let devGlobalCssContent = "";
|
|
52128
52531
|
let lastServedCssGlobal = "";
|
|
52129
|
-
const srcDir =
|
|
52130
|
-
const cssPath =
|
|
52131
|
-
const altCssPath =
|
|
52532
|
+
const srcDir = join24(projectDir, "src");
|
|
52533
|
+
const cssPath = join24(srcDir, "global.css");
|
|
52534
|
+
const altCssPath = join24(srcDir, "app.css");
|
|
52132
52535
|
let rawCss = "";
|
|
52133
|
-
if (
|
|
52134
|
-
rawCss =
|
|
52135
|
-
} else if (
|
|
52136
|
-
rawCss =
|
|
52536
|
+
if (existsSync42(cssPath)) {
|
|
52537
|
+
rawCss = readFileSync38(cssPath, "utf-8");
|
|
52538
|
+
} else if (existsSync42(altCssPath)) {
|
|
52539
|
+
rawCss = readFileSync38(altCssPath, "utf-8");
|
|
52137
52540
|
}
|
|
52138
52541
|
if (rawCss) {
|
|
52139
52542
|
const activeAtStart = getActiveDevPlugins();
|
|
@@ -52364,63 +52767,110 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
52364
52767
|
}
|
|
52365
52768
|
}
|
|
52366
52769
|
const apiWatchCache = /* @__PURE__ */ new Map();
|
|
52770
|
+
const lastSeenContent = /* @__PURE__ */ new Map();
|
|
52771
|
+
let chunkRefresh = Promise.resolve();
|
|
52772
|
+
const queueClientChunksRefresh = (fullPath, filename, fileExists) => {
|
|
52773
|
+
chunkRefresh = chunkRefresh.then(async () => {
|
|
52774
|
+
try {
|
|
52775
|
+
const hot = await buildClientChunks(fullPath);
|
|
52776
|
+
if (hot.err) {
|
|
52777
|
+
const payload = buildDevErrorPayload({
|
|
52778
|
+
err: hot.err,
|
|
52779
|
+
errorMessage: hot.err.message,
|
|
52780
|
+
filename,
|
|
52781
|
+
fullPath,
|
|
52782
|
+
appDir: appDirPath,
|
|
52783
|
+
fileExists
|
|
52784
|
+
});
|
|
52785
|
+
const displayFile = payload.file || filename || "";
|
|
52786
|
+
LOG.err(`[vsk:error] ${displayFile}${payload.line ? `:${payload.line}:${payload.column || 1}` : ""} \u2014 ${payload.message}`);
|
|
52787
|
+
devLastError = payload;
|
|
52788
|
+
recordDiagnostic({
|
|
52789
|
+
severity: "error",
|
|
52790
|
+
code: "HMR_CHUNK",
|
|
52791
|
+
file: displayFile || null,
|
|
52792
|
+
line: payload.line,
|
|
52793
|
+
column: payload.column,
|
|
52794
|
+
message: payload.message,
|
|
52795
|
+
hint: payload.tips && payload.tips[0] || null
|
|
52796
|
+
});
|
|
52797
|
+
const broadcast = globalThis.__vesk_broadcastHmr;
|
|
52798
|
+
if (typeof broadcast === "function") broadcast({ type: "error", ...payload });
|
|
52799
|
+
}
|
|
52800
|
+
} catch (e) {
|
|
52801
|
+
LOG.err(`chunk refresh error:`, e.message);
|
|
52802
|
+
}
|
|
52803
|
+
});
|
|
52804
|
+
};
|
|
52367
52805
|
try {
|
|
52368
52806
|
let debounceTimer = null;
|
|
52369
52807
|
let cssDebounceTimer = null;
|
|
52370
|
-
const skipDirs = /* @__PURE__ */ new Set(["node_modules", ".vesk", "tarballs"]);
|
|
52371
52808
|
const watchDir = projectDir;
|
|
52372
52809
|
watch(watchDir, { recursive: true }, (eventType, filename) => {
|
|
52373
52810
|
if (!filename) return;
|
|
52374
|
-
|
|
52375
|
-
|
|
52376
|
-
const
|
|
52377
|
-
const
|
|
52378
|
-
const
|
|
52379
|
-
|
|
52380
|
-
|
|
52381
|
-
|
|
52382
|
-
if (
|
|
52811
|
+
const kind = classifyHmrWatchPath(filename);
|
|
52812
|
+
if (kind === "ignored") return;
|
|
52813
|
+
const fullPath = filename.startsWith("/") ? filename : join24(watchDir, filename);
|
|
52814
|
+
const fileExists = existsSync42(fullPath);
|
|
52815
|
+
const bcast = (msg) => {
|
|
52816
|
+
const f = globalThis.__vesk_broadcastHmr;
|
|
52817
|
+
if (typeof f === "function") f(msg);
|
|
52818
|
+
};
|
|
52819
|
+
if (kind === "events") {
|
|
52383
52820
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
52384
52821
|
debounceTimer = setTimeout(async () => {
|
|
52385
52822
|
try {
|
|
52386
52823
|
await runAppStop(false);
|
|
52387
52824
|
await reloadAppEvents();
|
|
52388
52825
|
await runAppStart(false);
|
|
52389
|
-
const
|
|
52390
|
-
if (typeof
|
|
52826
|
+
const bcastLocal = globalThis.__vesk_broadcastHmr;
|
|
52827
|
+
if (typeof bcastLocal === "function") bcastLocal({ type: "reload" });
|
|
52391
52828
|
LOG.info(`events reloaded (${filename})`);
|
|
52392
52829
|
} catch (e) {
|
|
52393
52830
|
LOG.err(`events reload error: ${e.message}`);
|
|
52394
52831
|
}
|
|
52395
52832
|
}, HMR_DEBOUNCE_MS);
|
|
52396
|
-
} else if (
|
|
52833
|
+
} else if (kind === "vsk") {
|
|
52397
52834
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
52398
52835
|
debounceTimer = setTimeout(async () => {
|
|
52399
52836
|
const t0 = Date.now();
|
|
52400
52837
|
try {
|
|
52838
|
+
const current2 = fileExists ? readFileSync38(fullPath, "utf-8") : null;
|
|
52839
|
+
if (eventType !== "rename" && current2 !== null && lastSeenContent.get(fullPath) === current2) {
|
|
52840
|
+
LOG.info(`skipped unchanged (${filename})`);
|
|
52841
|
+
return;
|
|
52842
|
+
}
|
|
52843
|
+
lastSeenContent.set(fullPath, current2);
|
|
52401
52844
|
if (typeof globalThis.__vesk_broadcastHmr === "function") {
|
|
52402
52845
|
globalThis.__vesk_broadcastHmr({ type: "compiling" });
|
|
52403
52846
|
}
|
|
52404
52847
|
const stripAnnots = (t) => JSON.stringify(t, (k, v) => k === "chunk" || k === "chunkError" ? void 0 : v);
|
|
52848
|
+
const needsRescan = shouldRescanRoutes(filename, eventType);
|
|
52405
52849
|
const prevTree = stripAnnots(routeTree);
|
|
52406
|
-
|
|
52407
|
-
|
|
52850
|
+
if (needsRescan) {
|
|
52851
|
+
routeTree = scanRoutes(appDirPath);
|
|
52852
|
+
updateSourceMapping();
|
|
52853
|
+
}
|
|
52408
52854
|
const changedComponents = sourceToComponents.get(fullPath) || [];
|
|
52409
|
-
const treeChanged = prevTree !== stripAnnots(routeTree);
|
|
52855
|
+
const treeChanged = needsRescan && prevTree !== stripAnnots(routeTree);
|
|
52410
52856
|
const isOutsideApp = !fullPath.startsWith(appDirPath + "/") && fullPath !== appDirPath;
|
|
52857
|
+
const fileDeleted = eventType === "rename" && !fileExists;
|
|
52411
52858
|
const cssPromise = rebuildTailwindCss();
|
|
52412
52859
|
let bundleError = null;
|
|
52413
52860
|
let hotEditedSource = null;
|
|
52414
52861
|
let hotActualName = null;
|
|
52415
52862
|
try {
|
|
52416
|
-
if (treeChanged || isOutsideApp) {
|
|
52863
|
+
if (treeChanged || isOutsideApp || fileDeleted) {
|
|
52417
52864
|
await buildClientBundle();
|
|
52418
52865
|
await bundleRuntime2();
|
|
52419
|
-
} else {
|
|
52420
|
-
|
|
52421
|
-
|
|
52422
|
-
|
|
52423
|
-
|
|
52866
|
+
} else if (fileExists && current2 !== null) {
|
|
52867
|
+
let source = current2;
|
|
52868
|
+
if (/content=["'][^"']*\.md["']/i.test(source)) {
|
|
52869
|
+
source = inlineMdContentAttrs2(source, dirname26(fullPath), guessProjectRoots2(appDirPath));
|
|
52870
|
+
}
|
|
52871
|
+
const { comp, name } = compileClientBoth2(source, null, fullPath, { skipHyd: true });
|
|
52872
|
+
hotEditedSource = buildHmrEvalSnippet2(comp);
|
|
52873
|
+
hotActualName = name;
|
|
52424
52874
|
}
|
|
52425
52875
|
} catch (e) {
|
|
52426
52876
|
bundleError = e;
|
|
@@ -52443,7 +52893,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52443
52893
|
if (compCode.trim()) fnSources = { _raw: compCode };
|
|
52444
52894
|
} else if (fileExists && !bundleError) {
|
|
52445
52895
|
try {
|
|
52446
|
-
const src2 =
|
|
52896
|
+
const src2 = readFileSync38(fullPath, "utf-8");
|
|
52447
52897
|
let compCode = buildHmrEvalSnippet2(
|
|
52448
52898
|
compileClient2(src2, null, { forceClient: true, sourcePath: fullPath, mdRoots: [projectDir] })
|
|
52449
52899
|
);
|
|
@@ -52465,11 +52915,11 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52465
52915
|
}
|
|
52466
52916
|
if (fnSources) {
|
|
52467
52917
|
devLastError = null;
|
|
52468
|
-
const
|
|
52918
|
+
const bcast2 = globalThis.__vesk_broadcastHmr;
|
|
52469
52919
|
if (hadErrorState) {
|
|
52470
|
-
|
|
52920
|
+
bcast2({ type: "reload" });
|
|
52471
52921
|
} else {
|
|
52472
|
-
|
|
52922
|
+
bcast2({
|
|
52473
52923
|
type: "update",
|
|
52474
52924
|
time: Date.now() - t0,
|
|
52475
52925
|
components: Object.fromEntries(changedComponents.map((name) => [name, true])),
|
|
@@ -52510,6 +52960,9 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52510
52960
|
globalThis.__vesk_broadcastHmr({ type: "reload" });
|
|
52511
52961
|
}
|
|
52512
52962
|
}
|
|
52963
|
+
if (!treeChanged && !isOutsideApp && !fileDeleted && fileExists && !bundleError) {
|
|
52964
|
+
queueClientChunksRefresh(fullPath, filename, fileExists);
|
|
52965
|
+
}
|
|
52513
52966
|
const cssChanged = await cssPromise;
|
|
52514
52967
|
if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
|
|
52515
52968
|
globalThis.__vesk_broadcastHmr({ type: "css-update" });
|
|
@@ -52519,12 +52972,12 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52519
52972
|
LOG.err(`rebuild error:`, e.message);
|
|
52520
52973
|
}
|
|
52521
52974
|
}, HMR_DEBOUNCE_MS);
|
|
52522
|
-
} else if (
|
|
52975
|
+
} else if (kind === "css") {
|
|
52523
52976
|
if (cssDebounceTimer) clearTimeout(cssDebounceTimer);
|
|
52524
52977
|
cssDebounceTimer = setTimeout(async () => {
|
|
52525
52978
|
try {
|
|
52526
52979
|
if (fileExists) {
|
|
52527
|
-
rawCss =
|
|
52980
|
+
rawCss = readFileSync38(fullPath, "utf-8");
|
|
52528
52981
|
}
|
|
52529
52982
|
const cssChanged = await rebuildTailwindCss();
|
|
52530
52983
|
if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
|
|
@@ -52535,11 +52988,23 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52535
52988
|
LOG.err(`CSS rebuild error:`, e.message);
|
|
52536
52989
|
}
|
|
52537
52990
|
}, HMR_DEBOUNCE_MS);
|
|
52538
|
-
} else if (
|
|
52991
|
+
} else if (kind === "config" || kind === "script") {
|
|
52539
52992
|
const isInApi = fullPath.includes("/api/");
|
|
52540
|
-
if (isInApi
|
|
52541
|
-
apiWatchCache.set(fullPath, Date.now());
|
|
52993
|
+
if (isInApi) {
|
|
52994
|
+
if (fileExists) apiWatchCache.set(fullPath, Date.now());
|
|
52995
|
+
return;
|
|
52542
52996
|
}
|
|
52997
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
52998
|
+
debounceTimer = setTimeout(async () => {
|
|
52999
|
+
const t0 = Date.now();
|
|
53000
|
+
try {
|
|
53001
|
+
bcast({ type: "compiling" });
|
|
53002
|
+
await fullRebuild();
|
|
53003
|
+
LOG.info(`${kind === "config" ? "config" : "script"} changed, full rebuild + reload (${filename}) \u2014 ${Date.now() - t0}ms`);
|
|
53004
|
+
} catch (e) {
|
|
53005
|
+
LOG.err(`rebuild error:`, e.message);
|
|
53006
|
+
}
|
|
53007
|
+
}, HMR_DEBOUNCE_MS);
|
|
52543
53008
|
}
|
|
52544
53009
|
});
|
|
52545
53010
|
} catch (e) {
|
|
@@ -52558,9 +53023,9 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52558
53023
|
".json": "application/json",
|
|
52559
53024
|
".webmanifest": "application/manifest+json"
|
|
52560
53025
|
};
|
|
52561
|
-
const hmrJsPath =
|
|
52562
|
-
const hmrTsPath =
|
|
52563
|
-
const hmrClientPath =
|
|
53026
|
+
const hmrJsPath = join24(runtimeDir, "hmr-client.js");
|
|
53027
|
+
const hmrTsPath = join24(runtimeDir, "hmr-client.ts");
|
|
53028
|
+
const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
|
|
52564
53029
|
function extractCompName2(src2) {
|
|
52565
53030
|
return resolveComponentName(src2);
|
|
52566
53031
|
}
|
|
@@ -52656,7 +53121,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52656
53121
|
}
|
|
52657
53122
|
if (url.pathname === "/_vesk/hmr" || url.pathname === "/_vesk/hmr.js") {
|
|
52658
53123
|
if (hmrClientPath) {
|
|
52659
|
-
let hmrContent =
|
|
53124
|
+
let hmrContent = readFileSync38(hmrClientPath, "utf-8");
|
|
52660
53125
|
if (hmrClientPath.endsWith(".ts")) {
|
|
52661
53126
|
hmrContent = stripCodeTypes2(hmrContent);
|
|
52662
53127
|
}
|
|
@@ -52704,10 +53169,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52704
53169
|
}
|
|
52705
53170
|
if (url.pathname !== "/") {
|
|
52706
53171
|
const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
|
|
52707
|
-
if (staticPath &&
|
|
53172
|
+
if (staticPath && existsSync42(staticPath) && statSync21(staticPath).isFile()) {
|
|
52708
53173
|
const ext = extname8(staticPath);
|
|
52709
53174
|
res.writeHead(200, { "Content-Type": MIME3[ext] || "application/octet-stream" });
|
|
52710
|
-
res.end(
|
|
53175
|
+
res.end(readFileSync38(staticPath));
|
|
52711
53176
|
return;
|
|
52712
53177
|
}
|
|
52713
53178
|
}
|
|
@@ -52731,8 +53196,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52731
53196
|
return;
|
|
52732
53197
|
}
|
|
52733
53198
|
const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
|
|
52734
|
-
const apiDirPath =
|
|
52735
|
-
if (url.pathname.startsWith("/api") &&
|
|
53199
|
+
const apiDirPath = join24(appDirPath, "api");
|
|
53200
|
+
if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
|
|
52736
53201
|
const apiRoutes = await scanApiRoutes(apiDirPath);
|
|
52737
53202
|
const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
|
|
52738
53203
|
if (apiMatch) {
|
|
@@ -52807,10 +53272,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52807
53272
|
const rootNode = routeTree.find((n) => n.fullPath === "/");
|
|
52808
53273
|
let notFoundHtml = null;
|
|
52809
53274
|
if (rootNode && rootNode.notFound) {
|
|
52810
|
-
const nfPath =
|
|
52811
|
-
if (
|
|
53275
|
+
const nfPath = resolve38(appDirPath, rootNode.sourceDir, "not-found.vsk");
|
|
53276
|
+
if (existsSync42(nfPath)) {
|
|
52812
53277
|
try {
|
|
52813
|
-
const nfSrc =
|
|
53278
|
+
const nfSrc = readFileSync38(nfPath, "utf-8");
|
|
52814
53279
|
const nfCompName = extractCompName2(nfSrc) || rootNode.notFound;
|
|
52815
53280
|
notFoundHtml = await renderFullPage(nfSrc, nfCompName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: nfPath, plugins: getActiveDevPlugins() });
|
|
52816
53281
|
} catch {
|
|
@@ -52852,18 +53317,18 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52852
53317
|
let props;
|
|
52853
53318
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
52854
53319
|
const node = chain[i];
|
|
52855
|
-
const pageFilePath =
|
|
52856
|
-
const layoutFilePath =
|
|
52857
|
-
if (i === chain.length - 1 && node.page &&
|
|
52858
|
-
const src2 =
|
|
53320
|
+
const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
|
|
53321
|
+
const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
|
|
53322
|
+
if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
|
|
53323
|
+
const src2 = readFileSync38(pageFilePath, "utf-8");
|
|
52859
53324
|
const compName = extractCompName2(src2) || node.page;
|
|
52860
53325
|
const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
52861
53326
|
body = result.body;
|
|
52862
53327
|
head = result.head || "";
|
|
52863
53328
|
props = result.props;
|
|
52864
53329
|
}
|
|
52865
|
-
if (node.layout &&
|
|
52866
|
-
const src2 =
|
|
53330
|
+
if (node.layout && existsSync42(layoutFilePath)) {
|
|
53331
|
+
const src2 = readFileSync38(layoutFilePath, "utf-8");
|
|
52867
53332
|
const compName = extractCompName2(src2) || node.layout;
|
|
52868
53333
|
const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
52869
53334
|
body = result.body;
|
|
@@ -52873,7 +53338,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
52873
53338
|
if (forData) {
|
|
52874
53339
|
return { html: "", props: props || { params: matched.params }, head };
|
|
52875
53340
|
}
|
|
52876
|
-
const hasLayout = chain.some((n) => n.layout &&
|
|
53341
|
+
const hasLayout = chain.some((n) => n.layout && existsSync42(resolve38(appDirPath, n.sourceDir, "layout.vsk")));
|
|
52877
53342
|
let html;
|
|
52878
53343
|
if (hasLayout) {
|
|
52879
53344
|
const ssrData = currentSsrData();
|
|
@@ -52908,9 +53373,9 @@ ${prettifyHtml(body)}
|
|
|
52908
53373
|
} else {
|
|
52909
53374
|
const leaf = chain.find((n) => n.page);
|
|
52910
53375
|
if (leaf) {
|
|
52911
|
-
const src2 =
|
|
53376
|
+
const src2 = readFileSync38(resolve38(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
52912
53377
|
const compName = extractCompName2(src2) || leaf.page;
|
|
52913
|
-
html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath:
|
|
53378
|
+
html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf.sourceDir, "page.vsk"), plugins: getActiveDevPlugins() });
|
|
52914
53379
|
html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
|
|
52915
53380
|
html = await applyHtmlPlugins(html, getActiveDevPlugins(), { sourcePath: url.pathname });
|
|
52916
53381
|
} else {
|
|
@@ -52934,13 +53399,13 @@ ${prettifyHtml(body)}
|
|
|
52934
53399
|
sst.__vsk_ssr_data = {};
|
|
52935
53400
|
async function* raw2() {
|
|
52936
53401
|
const chain = cleanChain;
|
|
52937
|
-
const hasLayout = chain.some((n) => n.layout &&
|
|
53402
|
+
const hasLayout = chain.some((n) => n.layout && existsSync42(resolve38(appDirPath, n.sourceDir, "layout.vsk")));
|
|
52938
53403
|
if (!hasLayout) {
|
|
52939
53404
|
const leaf = chain.find((n) => n.page);
|
|
52940
53405
|
if (leaf) {
|
|
52941
|
-
const src2 =
|
|
53406
|
+
const src2 = readFileSync38(resolve38(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
52942
53407
|
const compName = extractCompName2(src2) || leaf.page;
|
|
52943
|
-
yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath:
|
|
53408
|
+
yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf.sourceDir, "page.vsk"), plugins: getActiveDevPlugins() });
|
|
52944
53409
|
} else {
|
|
52945
53410
|
throw new Error("No page or layout matched");
|
|
52946
53411
|
}
|
|
@@ -52951,18 +53416,18 @@ ${prettifyHtml(body)}
|
|
|
52951
53416
|
let props;
|
|
52952
53417
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
52953
53418
|
const node = chain[i];
|
|
52954
|
-
const pageFilePath =
|
|
52955
|
-
const layoutFilePath =
|
|
52956
|
-
if (i === chain.length - 1 && node.page &&
|
|
52957
|
-
const src2 =
|
|
53419
|
+
const pageFilePath = resolve38(appDirPath, node.sourceDir, "page.vsk");
|
|
53420
|
+
const layoutFilePath = resolve38(appDirPath, node.sourceDir, "layout.vsk");
|
|
53421
|
+
if (i === chain.length - 1 && node.page && existsSync42(pageFilePath)) {
|
|
53422
|
+
const src2 = readFileSync38(pageFilePath, "utf-8");
|
|
52958
53423
|
const compName = extractCompName2(src2) || node.page;
|
|
52959
53424
|
const result = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
52960
53425
|
body = result.body;
|
|
52961
53426
|
head = result.head || "";
|
|
52962
53427
|
props = result.props;
|
|
52963
53428
|
}
|
|
52964
|
-
if (node.layout &&
|
|
52965
|
-
const src2 =
|
|
53429
|
+
if (node.layout && existsSync42(layoutFilePath)) {
|
|
53430
|
+
const src2 = readFileSync38(layoutFilePath, "utf-8");
|
|
52966
53431
|
const compName = extractCompName2(src2) || node.layout;
|
|
52967
53432
|
const result = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
52968
53433
|
body = result.body;
|
|
@@ -53099,10 +53564,10 @@ ${prettifyHtml(body)}
|
|
|
53099
53564
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
53100
53565
|
const node = match.nodes[i];
|
|
53101
53566
|
if (node.notFound) {
|
|
53102
|
-
const nfPath =
|
|
53103
|
-
if (
|
|
53567
|
+
const nfPath = resolve38(appDirPath, node.sourceDir, "not-found.vsk");
|
|
53568
|
+
if (existsSync42(nfPath)) {
|
|
53104
53569
|
try {
|
|
53105
|
-
const nfSrc =
|
|
53570
|
+
const nfSrc = readFileSync38(nfPath, "utf-8");
|
|
53106
53571
|
const nfCompName = extractCompName2(nfSrc) || node.notFound;
|
|
53107
53572
|
const html = await renderFullPage(nfSrc, nfCompName, { params: match.params, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: nfPath, plugins: getActiveDevPlugins() });
|
|
53108
53573
|
notFoundHtml = injectDevScripts(html);
|
|
@@ -53145,10 +53610,10 @@ ${prettifyHtml(body)}
|
|
|
53145
53610
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
53146
53611
|
const node = match.nodes[i];
|
|
53147
53612
|
if (node.error) {
|
|
53148
|
-
const errPath =
|
|
53149
|
-
if (
|
|
53613
|
+
const errPath = resolve38(appDirPath, node.sourceDir, "error.vsk");
|
|
53614
|
+
if (existsSync42(errPath)) {
|
|
53150
53615
|
try {
|
|
53151
|
-
const errSrc =
|
|
53616
|
+
const errSrc = readFileSync38(errPath, "utf-8");
|
|
53152
53617
|
const errCompName = extractCompName2(errSrc) || node.error;
|
|
53153
53618
|
const errProps = {
|
|
53154
53619
|
error: err.message,
|
|
@@ -53220,7 +53685,7 @@ ${prettifyHtml(body)}
|
|
|
53220
53685
|
LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
|
|
53221
53686
|
const routes = collectRoutePaths(routeTree);
|
|
53222
53687
|
const pageCount = countPages(routeTree);
|
|
53223
|
-
const apiCount = countFilesNamed(
|
|
53688
|
+
const apiCount = countFilesNamed(join24(appDirPath, "api"), "route.ts");
|
|
53224
53689
|
LOG.info(`${projectDir}`);
|
|
53225
53690
|
LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
|
|
53226
53691
|
if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
|
|
@@ -53476,7 +53941,7 @@ init_action();
|
|
|
53476
53941
|
|
|
53477
53942
|
// src/index.ts
|
|
53478
53943
|
var __filename2 = fileURLToPath9(import.meta.url);
|
|
53479
|
-
var __dirname10 =
|
|
53944
|
+
var __dirname10 = resolve40(__filename2, "..");
|
|
53480
53945
|
var args = process.argv.slice(2);
|
|
53481
53946
|
var cmd = args[0];
|
|
53482
53947
|
function usage(code = 0) {
|
|
@@ -53519,12 +53984,12 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
|
53519
53984
|
}
|
|
53520
53985
|
function loadEnvFiles(projectDir) {
|
|
53521
53986
|
const files = [
|
|
53522
|
-
|
|
53523
|
-
|
|
53987
|
+
join26(projectDir, ".env"),
|
|
53988
|
+
join26(projectDir, ".env.local")
|
|
53524
53989
|
];
|
|
53525
53990
|
for (const filePath of files) {
|
|
53526
|
-
if (!
|
|
53527
|
-
const content =
|
|
53991
|
+
if (!existsSync43(filePath)) continue;
|
|
53992
|
+
const content = readFileSync40(filePath, "utf-8");
|
|
53528
53993
|
for (const line of content.split("\n")) {
|
|
53529
53994
|
const trimmed = line.trim();
|
|
53530
53995
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -53556,9 +54021,9 @@ async function loadConfig(projectDir) {
|
|
|
53556
54021
|
}
|
|
53557
54022
|
if (cmd === "build") {
|
|
53558
54023
|
const projectDir = process.cwd();
|
|
53559
|
-
const appDirPath =
|
|
53560
|
-
const publicDir =
|
|
53561
|
-
if (!
|
|
54024
|
+
const appDirPath = join26(projectDir, "app");
|
|
54025
|
+
const publicDir = join26(projectDir, "public");
|
|
54026
|
+
if (!existsSync43(appDirPath)) {
|
|
53562
54027
|
console.error(`vesk build: no app/ directory found in ${projectDir}`);
|
|
53563
54028
|
process.exit(1);
|
|
53564
54029
|
}
|
|
@@ -53628,8 +54093,8 @@ ${code}`;
|
|
|
53628
54093
|
}
|
|
53629
54094
|
if (cmd === "seo") {
|
|
53630
54095
|
const projectDir = process.cwd();
|
|
53631
|
-
const appDirPath =
|
|
53632
|
-
if (!
|
|
54096
|
+
const appDirPath = join26(projectDir, "app");
|
|
54097
|
+
if (!existsSync43(appDirPath)) {
|
|
53633
54098
|
console.error(`vesk seo: no app/ directory found in ${projectDir}`);
|
|
53634
54099
|
process.exit(1);
|
|
53635
54100
|
}
|
|
@@ -53643,8 +54108,8 @@ if (cmd === "seo") {
|
|
|
53643
54108
|
}
|
|
53644
54109
|
if (cmd === "typecheck") {
|
|
53645
54110
|
const projectDir = process.cwd();
|
|
53646
|
-
const appDirPath =
|
|
53647
|
-
if (!
|
|
54111
|
+
const appDirPath = join26(projectDir, "app");
|
|
54112
|
+
if (!existsSync43(appDirPath)) {
|
|
53648
54113
|
console.error(`vesk typecheck: no app/ directory found in ${projectDir}`);
|
|
53649
54114
|
process.exit(1);
|
|
53650
54115
|
}
|
|
@@ -53668,7 +54133,7 @@ if (cmd === "typecheck") {
|
|
|
53668
54133
|
}
|
|
53669
54134
|
if (cmd === "start") {
|
|
53670
54135
|
const projectDir = process.cwd();
|
|
53671
|
-
const outDir =
|
|
54136
|
+
const outDir = join26(projectDir, ".vesk");
|
|
53672
54137
|
const port = parsePortArg(args);
|
|
53673
54138
|
const host = parseHostArg(args);
|
|
53674
54139
|
startProdServer(outDir, { port, host });
|
|
@@ -53677,9 +54142,9 @@ if (cmd === "start") {
|
|
|
53677
54142
|
}
|
|
53678
54143
|
if (cmd === "init") {
|
|
53679
54144
|
const projectDir = process.cwd();
|
|
53680
|
-
const srcDir =
|
|
53681
|
-
const target =
|
|
53682
|
-
if (
|
|
54145
|
+
const srcDir = join26(projectDir, "src");
|
|
54146
|
+
const target = join26(srcDir, "global.css");
|
|
54147
|
+
if (existsSync43(target)) {
|
|
53683
54148
|
console.error(`vesk init: ${target} already exists \u2014 skipping`);
|
|
53684
54149
|
process.exit(0);
|
|
53685
54150
|
}
|
|
@@ -53697,10 +54162,10 @@ if (cmd === "init") {
|
|
|
53697
54162
|
}
|
|
53698
54163
|
if (cmd === "dev") {
|
|
53699
54164
|
const projectDir = process.cwd();
|
|
53700
|
-
const appDirPath =
|
|
54165
|
+
const appDirPath = join26(projectDir, "app");
|
|
53701
54166
|
const port = parsePortArg(args);
|
|
53702
54167
|
const host = parseHostArg(args);
|
|
53703
|
-
if (!
|
|
54168
|
+
if (!existsSync43(appDirPath)) {
|
|
53704
54169
|
console.error(`vesk: no app/ directory found in ${projectDir}`);
|
|
53705
54170
|
console.error('Run "npx create-vesk@latest <project-name>" first');
|
|
53706
54171
|
process.exit(1);
|