@vesk/vesk-cli 0.2.8 → 0.2.9
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 +1429 -524
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1666,7 +1666,7 @@ async function runFetcher(handle2, timeout) {
|
|
|
1666
1666
|
}
|
|
1667
1667
|
}
|
|
1668
1668
|
function sleep(ms) {
|
|
1669
|
-
return new Promise((
|
|
1669
|
+
return new Promise((resolve27) => setTimeout(resolve27, ms));
|
|
1670
1670
|
}
|
|
1671
1671
|
function settle(handle2, data2) {
|
|
1672
1672
|
if (handle2.block !== null && is_destroyed(handle2.block)) return;
|
|
@@ -2032,10 +2032,10 @@ function createHydrateWalker(container, markerList) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
function hydrateViewport(container, componentFn, props, rootMargin = 500) {
|
|
2034
2034
|
if (document.readyState !== "complete") {
|
|
2035
|
-
return new Promise((
|
|
2035
|
+
return new Promise((resolve27) => {
|
|
2036
2036
|
const onLoad = () => {
|
|
2037
2037
|
window.removeEventListener("load", onLoad);
|
|
2038
|
-
|
|
2038
|
+
resolve27(hydrateViewport(container, componentFn, props, rootMargin));
|
|
2039
2039
|
};
|
|
2040
2040
|
window.addEventListener("load", onLoad);
|
|
2041
2041
|
});
|
|
@@ -2062,7 +2062,7 @@ function hydrateViewport(container, componentFn, props, rootMargin = 500) {
|
|
|
2062
2062
|
const viewportWalker = createHydrateWalker(container, viewportMarkers);
|
|
2063
2063
|
componentFn(props || {}, /* @__PURE__ */ new Map(), viewportWalker);
|
|
2064
2064
|
if (deferredMarkers.length > 0) {
|
|
2065
|
-
return new Promise((
|
|
2065
|
+
return new Promise((resolve27) => {
|
|
2066
2066
|
const observer = new IntersectionObserver((entries) => {
|
|
2067
2067
|
const toHydrate = [];
|
|
2068
2068
|
for (const entry of entries) {
|
|
@@ -2085,7 +2085,7 @@ function hydrateViewport(container, componentFn, props, rootMargin = 500) {
|
|
|
2085
2085
|
}
|
|
2086
2086
|
if (observer._observed === 0) {
|
|
2087
2087
|
observer.disconnect();
|
|
2088
|
-
|
|
2088
|
+
resolve27();
|
|
2089
2089
|
}
|
|
2090
2090
|
}, { rootMargin: `${rootMargin}px` });
|
|
2091
2091
|
observer._observed = deferredMarkers.length;
|
|
@@ -2308,9 +2308,9 @@ function startProgress() {
|
|
|
2308
2308
|
const step = () => {
|
|
2309
2309
|
rafId = null;
|
|
2310
2310
|
if (!animating || isServer2()) return;
|
|
2311
|
-
const
|
|
2312
|
-
if (startTimeStamp === null) startTimeStamp =
|
|
2313
|
-
const pct = globalOpts.estimatedProgress(globalOpts.duration,
|
|
2311
|
+
const ts9 = now();
|
|
2312
|
+
if (startTimeStamp === null) startTimeStamp = ts9;
|
|
2313
|
+
const pct = globalOpts.estimatedProgress(globalOpts.duration, ts9 - startTimeStamp);
|
|
2314
2314
|
set(progressCell, Math.max(0, Math.min(100, pct)));
|
|
2315
2315
|
rafId = setTimeout(step, 16);
|
|
2316
2316
|
};
|
|
@@ -2948,12 +2948,12 @@ function ensureChunk(chunkUrl) {
|
|
|
2948
2948
|
if (typeof document === "undefined" || typeof document.createElement !== "function") {
|
|
2949
2949
|
return Promise.resolve();
|
|
2950
2950
|
}
|
|
2951
|
-
return new Promise((
|
|
2951
|
+
return new Promise((resolve27, reject) => {
|
|
2952
2952
|
const s = document.createElement("script");
|
|
2953
2953
|
s.src = chunkUrl;
|
|
2954
2954
|
s.onload = () => {
|
|
2955
2955
|
failedChunks.delete(chunkUrl);
|
|
2956
|
-
|
|
2956
|
+
resolve27();
|
|
2957
2957
|
};
|
|
2958
2958
|
s.onerror = () => {
|
|
2959
2959
|
loadedChunks.delete(chunkUrl);
|
|
@@ -15289,6 +15289,15 @@ function isIdentStartCode(code) {
|
|
|
15289
15289
|
function isIdentCharCode(code) {
|
|
15290
15290
|
return isIdentStartCode(code) || code >= 48 && code <= 57;
|
|
15291
15291
|
}
|
|
15292
|
+
function getQualifiedJSXName2(object) {
|
|
15293
|
+
if (!object) return object;
|
|
15294
|
+
if (object.type === "JSXIdentifier") return object.name;
|
|
15295
|
+
if (object.type === "JSXNamespacedName") return object.namespace.name + ":" + object.name.name;
|
|
15296
|
+
if (object.type === "JSXMemberExpression") {
|
|
15297
|
+
return getQualifiedJSXName2(object.object) + "." + getQualifiedJSXName2(object.property);
|
|
15298
|
+
}
|
|
15299
|
+
return null;
|
|
15300
|
+
}
|
|
15292
15301
|
function looksLikeGenericArrowAt(input, pos) {
|
|
15293
15302
|
let i = pos + 1;
|
|
15294
15303
|
while (i < input.length && isWsChar(input.charCodeAt(i))) i++;
|
|
@@ -15372,6 +15381,9 @@ function VeskParserPlugin(config = {}) {
|
|
|
15372
15381
|
#closeTagName = null;
|
|
15373
15382
|
#jsxStartsStatement = false;
|
|
15374
15383
|
#inTSTypeDecl = false;
|
|
15384
|
+
#pendingChildStatement = false;
|
|
15385
|
+
/** per-statement context-stack depths (LIFO — child statements may nest) */
|
|
15386
|
+
#jsxChildDepthStack = [];
|
|
15375
15387
|
constructor(options2, input) {
|
|
15376
15388
|
super(options2, input);
|
|
15377
15389
|
}
|
|
@@ -15379,7 +15391,231 @@ function VeskParserPlugin(config = {}) {
|
|
|
15379
15391
|
const ctx2 = this.curContext();
|
|
15380
15392
|
return ctx2 && (ctx2.token === "{" || ctx2.token === "function");
|
|
15381
15393
|
}
|
|
15394
|
+
#isJsxChildrenContext() {
|
|
15395
|
+
const ctx2 = this.curContext();
|
|
15396
|
+
return !!ctx2 && ctx2.token === "<tag>...</tag>";
|
|
15397
|
+
}
|
|
15398
|
+
/**
|
|
15399
|
+
* Determines whether the text starting at `this.pos` opens a
|
|
15400
|
+
* statement-mode control-flow header (`if (`, `for (`, `while (`,
|
|
15401
|
+
* `switch (`, `try {`, `do {`) among JSX children. Scans chars only —
|
|
15402
|
+
* the paren body must balance and be followed by a `{` block.
|
|
15403
|
+
*/
|
|
15404
|
+
#scansChildStatement() {
|
|
15405
|
+
const input = this.input;
|
|
15406
|
+
let i = this.pos;
|
|
15407
|
+
while (i < input.length && isWsChar(input.charCodeAt(i))) i++;
|
|
15408
|
+
if (i >= input.length || !isIdentStartCode(input.charCodeAt(i))) return false;
|
|
15409
|
+
const wordStart = i;
|
|
15410
|
+
while (i < input.length && isIdentCharCode(input.charCodeAt(i))) i++;
|
|
15411
|
+
const word = input.slice(wordStart, i);
|
|
15412
|
+
if (word === "const" || word === "let" || word === "var") {
|
|
15413
|
+
let depth2 = 0;
|
|
15414
|
+
let seenAssign = false;
|
|
15415
|
+
let q2 = i;
|
|
15416
|
+
while (q2 < input.length) {
|
|
15417
|
+
const c = input.charCodeAt(q2);
|
|
15418
|
+
if (c === 34 || c === 39 || c === 96) {
|
|
15419
|
+
const quote = c;
|
|
15420
|
+
let tplDepth = 0;
|
|
15421
|
+
q2++;
|
|
15422
|
+
while (q2 < input.length) {
|
|
15423
|
+
const ch = input.charCodeAt(q2);
|
|
15424
|
+
if (ch === 92) {
|
|
15425
|
+
q2 += 2;
|
|
15426
|
+
continue;
|
|
15427
|
+
}
|
|
15428
|
+
if (quote === 96 && ch === 36 && input.charCodeAt(q2 + 1) === 123) {
|
|
15429
|
+
tplDepth++;
|
|
15430
|
+
q2 += 2;
|
|
15431
|
+
continue;
|
|
15432
|
+
}
|
|
15433
|
+
if (quote === 96 && ch === 125 && tplDepth > 0) {
|
|
15434
|
+
tplDepth--;
|
|
15435
|
+
q2++;
|
|
15436
|
+
continue;
|
|
15437
|
+
}
|
|
15438
|
+
if (ch === quote && tplDepth === 0) {
|
|
15439
|
+
q2++;
|
|
15440
|
+
break;
|
|
15441
|
+
}
|
|
15442
|
+
q2++;
|
|
15443
|
+
}
|
|
15444
|
+
continue;
|
|
15445
|
+
}
|
|
15446
|
+
if (c === 60 && input.charCodeAt(q2 + 1) === 47) return false;
|
|
15447
|
+
if (c === 40 || c === 91 || c === 123) depth2++;
|
|
15448
|
+
else if (c === 41 || c === 93 || c === 125) depth2--;
|
|
15449
|
+
else if (c === 61 && depth2 === 0) {
|
|
15450
|
+
const n2 = input.charCodeAt(q2 + 1);
|
|
15451
|
+
const n1 = q2 > 0 ? input.charCodeAt(q2 - 1) : 0;
|
|
15452
|
+
if (n2 !== 61 && n2 !== 62 && n1 !== 33 && n1 !== 60 && n1 !== 61) seenAssign = true;
|
|
15453
|
+
} else if (c === 59 && depth2 === 0) return true;
|
|
15454
|
+
else if ((c === 10 || c === 13) && depth2 === 0 && seenAssign) return true;
|
|
15455
|
+
q2++;
|
|
15456
|
+
}
|
|
15457
|
+
return false;
|
|
15458
|
+
}
|
|
15459
|
+
if (isIdentStartCode(input.charCodeAt(wordStart))) {
|
|
15460
|
+
let q2 = i;
|
|
15461
|
+
while (q2 < input.length) {
|
|
15462
|
+
const c = input.charCodeAt(q2);
|
|
15463
|
+
if (c === 46) {
|
|
15464
|
+
q2++;
|
|
15465
|
+
} else if (c === 63 && input.charCodeAt(q2 + 1) === 46) {
|
|
15466
|
+
q2 += 2;
|
|
15467
|
+
} else break;
|
|
15468
|
+
if (q2 >= input.length || !isIdentStartCode(input.charCodeAt(q2))) return false;
|
|
15469
|
+
q2++;
|
|
15470
|
+
while (q2 < input.length && isIdentCharCode(input.charCodeAt(q2))) q2++;
|
|
15471
|
+
}
|
|
15472
|
+
if (input.charCodeAt(q2) === 40) {
|
|
15473
|
+
let depth2 = 0;
|
|
15474
|
+
let callClosed = false;
|
|
15475
|
+
let s = q2;
|
|
15476
|
+
while (s < input.length) {
|
|
15477
|
+
const c = input.charCodeAt(s);
|
|
15478
|
+
if (c === 34 || c === 39 || c === 96) {
|
|
15479
|
+
const quote = c;
|
|
15480
|
+
let tplDepth = 0;
|
|
15481
|
+
s++;
|
|
15482
|
+
while (s < input.length) {
|
|
15483
|
+
const ch = input.charCodeAt(s);
|
|
15484
|
+
if (ch === 92) {
|
|
15485
|
+
s += 2;
|
|
15486
|
+
continue;
|
|
15487
|
+
}
|
|
15488
|
+
if (quote === 96 && ch === 36 && input.charCodeAt(s + 1) === 123) {
|
|
15489
|
+
tplDepth++;
|
|
15490
|
+
s += 2;
|
|
15491
|
+
continue;
|
|
15492
|
+
}
|
|
15493
|
+
if (quote === 96 && ch === 125 && tplDepth > 0) {
|
|
15494
|
+
tplDepth--;
|
|
15495
|
+
s++;
|
|
15496
|
+
continue;
|
|
15497
|
+
}
|
|
15498
|
+
if (ch === quote && tplDepth === 0) {
|
|
15499
|
+
s++;
|
|
15500
|
+
break;
|
|
15501
|
+
}
|
|
15502
|
+
s++;
|
|
15503
|
+
}
|
|
15504
|
+
continue;
|
|
15505
|
+
}
|
|
15506
|
+
if (c === 60 && input.charCodeAt(s + 1) === 47) return false;
|
|
15507
|
+
if (c === 40 || c === 91 || c === 123) depth2++;
|
|
15508
|
+
else if (c === 41 || c === 93 || c === 125) {
|
|
15509
|
+
depth2--;
|
|
15510
|
+
if (c === 41 && depth2 === 0) {
|
|
15511
|
+
callClosed = true;
|
|
15512
|
+
s++;
|
|
15513
|
+
break;
|
|
15514
|
+
}
|
|
15515
|
+
}
|
|
15516
|
+
s++;
|
|
15517
|
+
}
|
|
15518
|
+
if (!callClosed) return false;
|
|
15519
|
+
let d = 0;
|
|
15520
|
+
for (; ; ) {
|
|
15521
|
+
if (s >= input.length) return false;
|
|
15522
|
+
const c = input.charCodeAt(s);
|
|
15523
|
+
if (c === 60 && input.charCodeAt(s + 1) === 47) return false;
|
|
15524
|
+
if (c === 34 || c === 39 || c === 96) {
|
|
15525
|
+
const quote = c;
|
|
15526
|
+
let tplDepth = 0;
|
|
15527
|
+
s++;
|
|
15528
|
+
while (s < input.length) {
|
|
15529
|
+
const ch = input.charCodeAt(s);
|
|
15530
|
+
if (ch === 92) {
|
|
15531
|
+
s += 2;
|
|
15532
|
+
continue;
|
|
15533
|
+
}
|
|
15534
|
+
if (quote === 96 && ch === 36 && input.charCodeAt(s + 1) === 123) {
|
|
15535
|
+
tplDepth++;
|
|
15536
|
+
s += 2;
|
|
15537
|
+
continue;
|
|
15538
|
+
}
|
|
15539
|
+
if (quote === 96 && ch === 125 && tplDepth > 0) {
|
|
15540
|
+
tplDepth--;
|
|
15541
|
+
s++;
|
|
15542
|
+
continue;
|
|
15543
|
+
}
|
|
15544
|
+
if (ch === quote && tplDepth === 0) {
|
|
15545
|
+
s++;
|
|
15546
|
+
break;
|
|
15547
|
+
}
|
|
15548
|
+
s++;
|
|
15549
|
+
}
|
|
15550
|
+
continue;
|
|
15551
|
+
}
|
|
15552
|
+
if (c === 40 || c === 91 || c === 123) d++;
|
|
15553
|
+
else if (c === 41 || c === 93 || c === 125) d--;
|
|
15554
|
+
else if (c === 59 && d === 0) return true;
|
|
15555
|
+
else if ((c === 10 || c === 13) && d === 0) return true;
|
|
15556
|
+
else if (c === 46) {
|
|
15557
|
+
s++;
|
|
15558
|
+
while (s < input.length && isIdentCharCode(input.charCodeAt(s))) s++;
|
|
15559
|
+
continue;
|
|
15560
|
+
} else if (isIdentCharCode(c) || isIdentStartCode(c)) return false;
|
|
15561
|
+
s++;
|
|
15562
|
+
}
|
|
15563
|
+
}
|
|
15564
|
+
}
|
|
15565
|
+
if (word !== "if" && word !== "for" && word !== "while" && word !== "switch" && word !== "try" && word !== "do") return false;
|
|
15566
|
+
let p = i;
|
|
15567
|
+
while (p < input.length && isWsChar(input.charCodeAt(p))) p++;
|
|
15568
|
+
if (word === "try" || word === "do") {
|
|
15569
|
+
return input.charCodeAt(p) === 123;
|
|
15570
|
+
}
|
|
15571
|
+
if (input.charCodeAt(p) !== 40) return false;
|
|
15572
|
+
let depth = 1;
|
|
15573
|
+
let q = p + 1;
|
|
15574
|
+
while (q < input.length) {
|
|
15575
|
+
const c = input.charCodeAt(q);
|
|
15576
|
+
if (c === 34 || c === 39 || c === 96) {
|
|
15577
|
+
const quote = c;
|
|
15578
|
+
q++;
|
|
15579
|
+
while (q < input.length) {
|
|
15580
|
+
const ch = input.charCodeAt(q);
|
|
15581
|
+
if (ch === 92) {
|
|
15582
|
+
q += 2;
|
|
15583
|
+
continue;
|
|
15584
|
+
}
|
|
15585
|
+
if (ch === quote) {
|
|
15586
|
+
q++;
|
|
15587
|
+
break;
|
|
15588
|
+
}
|
|
15589
|
+
q++;
|
|
15590
|
+
}
|
|
15591
|
+
continue;
|
|
15592
|
+
}
|
|
15593
|
+
if (c === 40 || c === 91 || c === 123) depth++;
|
|
15594
|
+
else if (c === 41 || c === 93 || c === 125) {
|
|
15595
|
+
depth--;
|
|
15596
|
+
if (c === 41 && depth === 0) break;
|
|
15597
|
+
}
|
|
15598
|
+
q++;
|
|
15599
|
+
}
|
|
15600
|
+
if (q >= input.length) return false;
|
|
15601
|
+
let r = q + 1;
|
|
15602
|
+
while (r < input.length && isWsChar(input.charCodeAt(r))) r++;
|
|
15603
|
+
return input.charCodeAt(r) === 123;
|
|
15604
|
+
}
|
|
15382
15605
|
readToken(code) {
|
|
15606
|
+
if (this.#componentDepth > 0 && this.#isJsxChildrenContext() && this.#scansChildStatement()) {
|
|
15607
|
+
this.#pendingChildStatement = true;
|
|
15608
|
+
this.#jsxChildDepthStack.push(this.context.length);
|
|
15609
|
+
this.context.push(types.b_stat);
|
|
15610
|
+
if (isWsChar(code)) {
|
|
15611
|
+
this.skipSpace();
|
|
15612
|
+
this.start = this.pos;
|
|
15613
|
+
if (this.options.locations && typeof this.curPosition === "function") {
|
|
15614
|
+
this.startLoc = this.curPosition();
|
|
15615
|
+
}
|
|
15616
|
+
}
|
|
15617
|
+
return super.readToken(this.input.codePointAt(this.pos));
|
|
15618
|
+
}
|
|
15383
15619
|
if (this.#componentDepth > 0 && code === 60 && this.#isBlockContext()) {
|
|
15384
15620
|
const next = this.input.charCodeAt(this.pos + 1);
|
|
15385
15621
|
if (next === 47 || next >= 65 && next <= 90 || next >= 97 && next <= 122) {
|
|
@@ -15692,7 +15928,68 @@ function VeskParserPlugin(config = {}) {
|
|
|
15692
15928
|
if (prefix.startsWith("<style") && isStyleBoundary(prefix.charCodeAt(6))) {
|
|
15693
15929
|
return this.parseStyleElement(startPos, startLoc);
|
|
15694
15930
|
}
|
|
15695
|
-
return
|
|
15931
|
+
return this.#parseElementWithStatements(startPos, startLoc);
|
|
15932
|
+
}
|
|
15933
|
+
/**
|
|
15934
|
+
* Parses an entire JSX element (or fragment) starting after `<`,
|
|
15935
|
+
* mirroring the vendored acorn-jsx `jsx_parseElementAt` with an added
|
|
15936
|
+
* statement-mode branch: when `#pendingChildStatement` is set (a
|
|
15937
|
+
* control-flow header like `if (…) {` appeared where JSX children
|
|
15938
|
+
* expect text), a real statement is parsed into the children array.
|
|
15939
|
+
*/
|
|
15940
|
+
#parseElementWithStatements(startPos, startLoc) {
|
|
15941
|
+
const node = this.startNodeAt(startPos, startLoc);
|
|
15942
|
+
const children = [];
|
|
15943
|
+
const openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
|
|
15944
|
+
let closingElement = null;
|
|
15945
|
+
if (!openingElement.selfClosing) {
|
|
15946
|
+
contents: for (; ; ) {
|
|
15947
|
+
if (this.#pendingChildStatement) {
|
|
15948
|
+
this.#pendingChildStatement = false;
|
|
15949
|
+
const stmt = this.parseStatement(null);
|
|
15950
|
+
children.push(stmt);
|
|
15951
|
+
this.context.length = this.#jsxChildDepthStack.pop() ?? this.context.length;
|
|
15952
|
+
this.exprAllowed = true;
|
|
15953
|
+
this.pos = this.start;
|
|
15954
|
+
this.next();
|
|
15955
|
+
continue;
|
|
15956
|
+
}
|
|
15957
|
+
switch (this.type) {
|
|
15958
|
+
case tstt?.jsxTagStart:
|
|
15959
|
+
startPos = this.start;
|
|
15960
|
+
startLoc = this.startLoc;
|
|
15961
|
+
this.next();
|
|
15962
|
+
if (this.eat(tt.slash)) {
|
|
15963
|
+
closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
|
|
15964
|
+
break contents;
|
|
15965
|
+
}
|
|
15966
|
+
children.push(this.jsx_parseElementAt(startPos, startLoc));
|
|
15967
|
+
break;
|
|
15968
|
+
case tstt?.jsxText:
|
|
15969
|
+
children.push(this.parseExprAtom());
|
|
15970
|
+
break;
|
|
15971
|
+
case tt.braceL:
|
|
15972
|
+
children.push(this.jsx_parseExpressionContainer());
|
|
15973
|
+
break;
|
|
15974
|
+
default:
|
|
15975
|
+
this.unexpected();
|
|
15976
|
+
}
|
|
15977
|
+
}
|
|
15978
|
+
if (getQualifiedJSXName2(closingElement.name) !== getQualifiedJSXName2(openingElement.name)) {
|
|
15979
|
+
this.raise(
|
|
15980
|
+
closingElement.start,
|
|
15981
|
+
"Expected corresponding JSX closing tag for <" + getQualifiedJSXName2(openingElement.name) + ">"
|
|
15982
|
+
);
|
|
15983
|
+
}
|
|
15984
|
+
}
|
|
15985
|
+
const fragmentOrElement = openingElement.name ? "Element" : "Fragment";
|
|
15986
|
+
node["opening" + fragmentOrElement] = openingElement;
|
|
15987
|
+
node["closing" + fragmentOrElement] = closingElement;
|
|
15988
|
+
node.children = children;
|
|
15989
|
+
if (this.type === tt.relational && this.value === "<") {
|
|
15990
|
+
this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
|
|
15991
|
+
}
|
|
15992
|
+
return this.finishNode(node, "JSX" + fragmentOrElement);
|
|
15696
15993
|
}
|
|
15697
15994
|
jsx_parseOpeningElementAt(startPos, startLoc) {
|
|
15698
15995
|
const node = this.startNodeAt(startPos, startLoc);
|
|
@@ -16505,7 +16802,15 @@ function collectCalledIdentifiers(code) {
|
|
|
16505
16802
|
const t = tokens[i];
|
|
16506
16803
|
if (t.label !== "name") continue;
|
|
16507
16804
|
const prev = i > 0 ? tokens[i - 1] : null;
|
|
16508
|
-
if (prev && (prev.label === "." || prev.label === "?."))
|
|
16805
|
+
if (prev && (prev.label === "." || prev.label === "?.")) {
|
|
16806
|
+
const obj = i >= 2 ? tokens[i - 2] : null;
|
|
16807
|
+
const next2 = tokens[i + 1];
|
|
16808
|
+
if (obj && obj.label === "name" && next2) {
|
|
16809
|
+
const nextCh2 = code[next2.start];
|
|
16810
|
+
if (nextCh2 === "(" || nextCh2 === "<") result2.add(obj.value);
|
|
16811
|
+
}
|
|
16812
|
+
continue;
|
|
16813
|
+
}
|
|
16509
16814
|
const next = tokens[i + 1];
|
|
16510
16815
|
if (!next) continue;
|
|
16511
16816
|
const nextCh = code[next.start];
|
|
@@ -16593,6 +16898,7 @@ function importModuleTarget(importText) {
|
|
|
16593
16898
|
function manualCollectCalledIdentifiers(code) {
|
|
16594
16899
|
const result2 = /* @__PURE__ */ new Set();
|
|
16595
16900
|
let i = 0;
|
|
16901
|
+
let prevIdent = null;
|
|
16596
16902
|
while (i < code.length) {
|
|
16597
16903
|
const c = code[i];
|
|
16598
16904
|
if (c === '"' || c === "'" || c === "`") {
|
|
@@ -16611,7 +16917,15 @@ function manualCollectCalledIdentifiers(code) {
|
|
|
16611
16917
|
let k = skipWhitespace(code, j);
|
|
16612
16918
|
if (code[k] === "<") k = skipTrackGeneric(code, k);
|
|
16613
16919
|
if (code[k] === "(") result2.add(code.slice(i, j));
|
|
16920
|
+
} else if (before === "." && prevIdent) {
|
|
16921
|
+
let p = i - 1;
|
|
16922
|
+
while (p > prevIdent[1] && (code[p] === "." || code[p] === "?" || code[p] === "\n" || code[p] === " " || code[p] === " ")) p--;
|
|
16923
|
+
if (p === prevIdent[1]) {
|
|
16924
|
+
let k = skipWhitespace(code, j);
|
|
16925
|
+
if (code[k] === "(") result2.add(code.slice(prevIdent[0], prevIdent[1]));
|
|
16926
|
+
}
|
|
16614
16927
|
}
|
|
16928
|
+
prevIdent = [i, j];
|
|
16615
16929
|
i = j;
|
|
16616
16930
|
continue;
|
|
16617
16931
|
}
|
|
@@ -16829,7 +17143,7 @@ function stripTypeImport(importSrc) {
|
|
|
16829
17143
|
if (isTypeOnlyImport(stmt)) return null;
|
|
16830
17144
|
const specs = stmt.specifiers || [];
|
|
16831
17145
|
const kept = specs.filter((s) => s.importKind !== "type");
|
|
16832
|
-
if (kept.length === 0) return null;
|
|
17146
|
+
if (specs.length > 0 && kept.length === 0) return null;
|
|
16833
17147
|
if (kept.length === specs.length) return importSrc;
|
|
16834
17148
|
try {
|
|
16835
17149
|
const rewritten = { ...stmt, specifiers: kept };
|
|
@@ -16846,6 +17160,505 @@ var init_vsk_imports = __esm({
|
|
|
16846
17160
|
}
|
|
16847
17161
|
});
|
|
16848
17162
|
|
|
17163
|
+
// ../compiler/src/module-imports.ts
|
|
17164
|
+
import { readFileSync, realpathSync, statSync } from "node:fs";
|
|
17165
|
+
import { createRequire } from "node:module";
|
|
17166
|
+
import { dirname as dirname2, extname, isAbsolute, join, resolve as resolve2 } from "node:path";
|
|
17167
|
+
import { print as print3 } from "esrap";
|
|
17168
|
+
import ts3 from "esrap/languages/ts";
|
|
17169
|
+
function cacheModule(p, val) {
|
|
17170
|
+
MODULE_CACHE.delete(p);
|
|
17171
|
+
MODULE_CACHE.set(p, val);
|
|
17172
|
+
if (MODULE_CACHE.size > MAX_CACHE_ENTRIES) {
|
|
17173
|
+
MODULE_CACHE.delete(MODULE_CACHE.keys().next().value);
|
|
17174
|
+
}
|
|
17175
|
+
}
|
|
17176
|
+
function isCompilerOwnedTarget(target) {
|
|
17177
|
+
if (target === "@vesk/runtime" || target === "@vesk/reactivity") return true;
|
|
17178
|
+
for (const prefix of RUNTIME_PREFIXES) {
|
|
17179
|
+
if (target.startsWith(prefix)) return true;
|
|
17180
|
+
}
|
|
17181
|
+
return false;
|
|
17182
|
+
}
|
|
17183
|
+
function isValueLessTarget(target) {
|
|
17184
|
+
return target.endsWith(".vsk") || target.endsWith(".css") || target.endsWith(".md") || target.endsWith(".markdown");
|
|
17185
|
+
}
|
|
17186
|
+
function importBindingPairs(imp) {
|
|
17187
|
+
const pairs = [];
|
|
17188
|
+
let ast = null;
|
|
17189
|
+
try {
|
|
17190
|
+
ast = parse4(imp, { filename: "import.mjs" });
|
|
17191
|
+
} catch {
|
|
17192
|
+
ast = null;
|
|
17193
|
+
}
|
|
17194
|
+
if (!ast) return pairs;
|
|
17195
|
+
const stmt = (ast.body || []).find((n) => n.type === "ImportDeclaration");
|
|
17196
|
+
if (!stmt) return pairs;
|
|
17197
|
+
const specifiers = stmt.specifiers || [];
|
|
17198
|
+
for (const spec of specifiers) {
|
|
17199
|
+
if (spec.importKind === "type") continue;
|
|
17200
|
+
const local = spec.local?.name;
|
|
17201
|
+
if (!local) continue;
|
|
17202
|
+
if (spec.type === "ImportDefaultSpecifier") {
|
|
17203
|
+
pairs.push({ local, imported: "default" });
|
|
17204
|
+
} else if (spec.type === "ImportNamespaceSpecifier") {
|
|
17205
|
+
pairs.push({ local, imported: "*" });
|
|
17206
|
+
} else {
|
|
17207
|
+
const importedSpec = spec.imported || spec.local;
|
|
17208
|
+
const imported = importedSpec.name ?? importedSpec.value;
|
|
17209
|
+
if (imported) pairs.push({ local, imported });
|
|
17210
|
+
}
|
|
17211
|
+
}
|
|
17212
|
+
return pairs;
|
|
17213
|
+
}
|
|
17214
|
+
function localValueImportNames(importStrs) {
|
|
17215
|
+
const names = [];
|
|
17216
|
+
for (const imp of importStrs) {
|
|
17217
|
+
const target = importModuleTarget(imp);
|
|
17218
|
+
if (!target || isCompilerOwnedTarget(target) || isValueLessTarget(target)) continue;
|
|
17219
|
+
for (const pair of importBindingPairs(imp)) names.push(pair.local);
|
|
17220
|
+
}
|
|
17221
|
+
return names;
|
|
17222
|
+
}
|
|
17223
|
+
function applyLocalModuleImports(__vesk, importStrs, sourcePath2) {
|
|
17224
|
+
if (!sourcePath2) return;
|
|
17225
|
+
const fromDir = dirname2(sourcePath2);
|
|
17226
|
+
for (const imp of importStrs) {
|
|
17227
|
+
const target = importModuleTarget(imp);
|
|
17228
|
+
if (!target || isCompilerOwnedTarget(target) || isValueLessTarget(target)) continue;
|
|
17229
|
+
const resolved = resolveSsrModule(target, fromDir);
|
|
17230
|
+
if (!resolved) {
|
|
17231
|
+
console.warn(`[vesk] SSR: cannot resolve "${target}" imported by ${sourcePath2} \u2014 the imported name will be undefined during server render.`);
|
|
17232
|
+
continue;
|
|
17233
|
+
}
|
|
17234
|
+
const mod = loadSsrModule(resolved);
|
|
17235
|
+
if (!mod || typeof mod !== "object") continue;
|
|
17236
|
+
for (const pair of importBindingPairs(imp)) {
|
|
17237
|
+
if (pair.imported === "*") {
|
|
17238
|
+
__vesk[pair.local] = mod;
|
|
17239
|
+
} else if (pair.imported in mod) {
|
|
17240
|
+
__vesk[pair.local] = mod[pair.imported];
|
|
17241
|
+
}
|
|
17242
|
+
}
|
|
17243
|
+
}
|
|
17244
|
+
}
|
|
17245
|
+
function nativeRequireFallback(absPath) {
|
|
17246
|
+
try {
|
|
17247
|
+
const req = createRequire(absPath);
|
|
17248
|
+
const loaded = req(absPath);
|
|
17249
|
+
if (loaded && typeof loaded === "object") return loaded;
|
|
17250
|
+
if (loaded !== null && loaded !== void 0) return { default: loaded };
|
|
17251
|
+
return null;
|
|
17252
|
+
} catch {
|
|
17253
|
+
return null;
|
|
17254
|
+
}
|
|
17255
|
+
}
|
|
17256
|
+
function loadSsrModule(absPath) {
|
|
17257
|
+
if (isBuiltinPath(absPath)) {
|
|
17258
|
+
return loadBuiltin(absPath.slice(BUILTIN_PREFIX.length));
|
|
17259
|
+
}
|
|
17260
|
+
let mtimeMs = 0;
|
|
17261
|
+
try {
|
|
17262
|
+
mtimeMs = statSync(absPath).mtimeMs;
|
|
17263
|
+
} catch {
|
|
17264
|
+
return null;
|
|
17265
|
+
}
|
|
17266
|
+
const inFlight = EVALUATING.get(absPath);
|
|
17267
|
+
if (inFlight !== void 0) return inFlight;
|
|
17268
|
+
const cachedVal = MODULE_CACHE.get(absPath);
|
|
17269
|
+
if (cachedVal && cachedVal.mtimeMs === mtimeMs && depsFresh(cachedVal)) return cachedVal.exports;
|
|
17270
|
+
const frame = /* @__PURE__ */ new Set();
|
|
17271
|
+
depStack.push(frame);
|
|
17272
|
+
try {
|
|
17273
|
+
let exportsObj = null;
|
|
17274
|
+
if (absPath.endsWith(".json")) {
|
|
17275
|
+
try {
|
|
17276
|
+
exportsObj = JSON.parse(readFileSync(absPath, "utf-8"));
|
|
17277
|
+
if (exportsObj && typeof exportsObj === "object" && !("default" in exportsObj)) {
|
|
17278
|
+
exportsObj.default = exportsObj;
|
|
17279
|
+
}
|
|
17280
|
+
} catch {
|
|
17281
|
+
exportsObj = null;
|
|
17282
|
+
}
|
|
17283
|
+
} else {
|
|
17284
|
+
exportsObj = {};
|
|
17285
|
+
EVALUATING.set(absPath, exportsObj);
|
|
17286
|
+
const ran = evaluateModuleFile(absPath, exportsObj);
|
|
17287
|
+
if (!ran) exportsObj = null;
|
|
17288
|
+
}
|
|
17289
|
+
if (exportsObj === null) {
|
|
17290
|
+
exportsObj = nativeRequireFallback(absPath);
|
|
17291
|
+
}
|
|
17292
|
+
if (exportsObj === null) return null;
|
|
17293
|
+
cacheModule(absPath, { mtimeMs, deps: captureClosure(frame), exports: exportsObj });
|
|
17294
|
+
return exportsObj;
|
|
17295
|
+
} finally {
|
|
17296
|
+
depStack.pop();
|
|
17297
|
+
EVALUATING.delete(absPath);
|
|
17298
|
+
}
|
|
17299
|
+
}
|
|
17300
|
+
function captureClosure(frame) {
|
|
17301
|
+
const deps = [];
|
|
17302
|
+
for (const dep of frame) {
|
|
17303
|
+
try {
|
|
17304
|
+
deps.push({ path: dep, mtimeMs: statSync(dep).mtimeMs });
|
|
17305
|
+
} catch {
|
|
17306
|
+
deps.push({ path: dep, mtimeMs: -1 });
|
|
17307
|
+
}
|
|
17308
|
+
}
|
|
17309
|
+
return deps;
|
|
17310
|
+
}
|
|
17311
|
+
function depsFresh(cachedVal) {
|
|
17312
|
+
for (const dep of cachedVal.deps) {
|
|
17313
|
+
try {
|
|
17314
|
+
if (statSync(dep.path).mtimeMs !== dep.mtimeMs) return false;
|
|
17315
|
+
} catch {
|
|
17316
|
+
return false;
|
|
17317
|
+
}
|
|
17318
|
+
}
|
|
17319
|
+
return true;
|
|
17320
|
+
}
|
|
17321
|
+
function evaluateModuleFile(absPath, exportsObj) {
|
|
17322
|
+
let raw2;
|
|
17323
|
+
try {
|
|
17324
|
+
raw2 = readFileSync(absPath, "utf-8");
|
|
17325
|
+
} catch (err) {
|
|
17326
|
+
console.warn(`[vesk] SSR: failed to read ${absPath}: ${err?.message ?? String(err)}`);
|
|
17327
|
+
return false;
|
|
17328
|
+
}
|
|
17329
|
+
let ast = null;
|
|
17330
|
+
try {
|
|
17331
|
+
ast = parse4(raw2, { filename: absPath });
|
|
17332
|
+
} catch {
|
|
17333
|
+
ast = null;
|
|
17334
|
+
}
|
|
17335
|
+
if (!ast) {
|
|
17336
|
+
try {
|
|
17337
|
+
const fn = new Function("require", "module", "exports", "__dirname", "__filename", raw2);
|
|
17338
|
+
fn(createModuleRequire(dirname2(absPath)), { exports: exportsObj }, exportsObj, dirname2(absPath), absPath);
|
|
17339
|
+
} catch (err) {
|
|
17340
|
+
console.warn(`[vesk] SSR: failed to load ${absPath}: ${err?.message ?? String(err)}`);
|
|
17341
|
+
return false;
|
|
17342
|
+
}
|
|
17343
|
+
return true;
|
|
17344
|
+
}
|
|
17345
|
+
const unsupported = findUnsupportedEsm(ast.body);
|
|
17346
|
+
if (unsupported) {
|
|
17347
|
+
throw new Error(
|
|
17348
|
+
`${absPath} uses ${unsupported} \u2014 not representable in the SSR module loader. Split it out of the module or avoid ${unsupported} in .vsk-imported code.`
|
|
17349
|
+
);
|
|
17350
|
+
}
|
|
17351
|
+
let stripped = ast;
|
|
17352
|
+
if (hasTsSyntax(ast)) stripped = stripTsTypes(ast);
|
|
17353
|
+
stripped.body = (stripped.body || []).filter((n) => {
|
|
17354
|
+
if (!n) return false;
|
|
17355
|
+
return !isTypeOnlyStatement(n);
|
|
17356
|
+
});
|
|
17357
|
+
const body = esmToCjs(stripped.body);
|
|
17358
|
+
try {
|
|
17359
|
+
const fn = new Function("require", "module", "exports", "__dirname", "__filename", "'use strict';\n" + body);
|
|
17360
|
+
fn(createModuleRequire(dirname2(absPath)), { exports: exportsObj }, exportsObj, dirname2(absPath), absPath);
|
|
17361
|
+
} catch (err) {
|
|
17362
|
+
console.warn(`[vesk] SSR: failed to load ${absPath}: ${err?.message ?? String(err)}`);
|
|
17363
|
+
return false;
|
|
17364
|
+
}
|
|
17365
|
+
return true;
|
|
17366
|
+
}
|
|
17367
|
+
function findUnsupportedEsm(body) {
|
|
17368
|
+
for (const stmt of body) {
|
|
17369
|
+
const hit = scanUnsupportedNode(stmt);
|
|
17370
|
+
if (hit) return hit;
|
|
17371
|
+
}
|
|
17372
|
+
return null;
|
|
17373
|
+
}
|
|
17374
|
+
function scanUnsupportedNode(node, inFunction = false) {
|
|
17375
|
+
if (!node || typeof node !== "object") return null;
|
|
17376
|
+
const n = node;
|
|
17377
|
+
const t = n.type;
|
|
17378
|
+
if (t === "MetaProperty" || t === "MetaProperty" && n.meta?.name === "import") {
|
|
17379
|
+
return "import.meta";
|
|
17380
|
+
}
|
|
17381
|
+
if (!inFunction && t === "AwaitExpression") return "top-level await";
|
|
17382
|
+
if (t === "FunctionDeclaration" || t === "FunctionExpression" || t === "ArrowFunctionExpression" || t === "ClassDeclaration" || t === "ClassExpression") {
|
|
17383
|
+
return null;
|
|
17384
|
+
}
|
|
17385
|
+
for (const key of Object.keys(n)) {
|
|
17386
|
+
const val = n[key];
|
|
17387
|
+
if (Array.isArray(val)) {
|
|
17388
|
+
for (const item of val) {
|
|
17389
|
+
if (item && typeof item === "object") {
|
|
17390
|
+
const sub = scanUnsupportedNode(item, inFunction);
|
|
17391
|
+
if (sub) return sub;
|
|
17392
|
+
}
|
|
17393
|
+
}
|
|
17394
|
+
} else if (val && typeof val === "object") {
|
|
17395
|
+
const sub = scanUnsupportedNode(val, inFunction);
|
|
17396
|
+
if (sub) return sub;
|
|
17397
|
+
}
|
|
17398
|
+
}
|
|
17399
|
+
return null;
|
|
17400
|
+
}
|
|
17401
|
+
function createModuleRequire(fromDir) {
|
|
17402
|
+
return (specifier) => {
|
|
17403
|
+
const resolved = resolveSsrModule(specifier, fromDir);
|
|
17404
|
+
if (!resolved) throw new Error(`Cannot find module '${specifier}'`);
|
|
17405
|
+
for (const frame of depStack) frame.add(resolved);
|
|
17406
|
+
const loaded = loadSsrModule(resolved);
|
|
17407
|
+
if (loaded === null) throw new Error(`Cannot load module '${specifier}'`);
|
|
17408
|
+
return loaded;
|
|
17409
|
+
};
|
|
17410
|
+
}
|
|
17411
|
+
function resolveSsrModule(specifier, fromDir) {
|
|
17412
|
+
let resolved = null;
|
|
17413
|
+
if (specifier === "." || specifier === ".." || isAbsolute(specifier)) {
|
|
17414
|
+
resolved = probeFile(resolve2(specifier));
|
|
17415
|
+
} else if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
17416
|
+
resolved = probeFile(resolve2(fromDir, specifier));
|
|
17417
|
+
} else {
|
|
17418
|
+
const native = nativeResolve(specifier, fromDir);
|
|
17419
|
+
if (native) return native;
|
|
17420
|
+
let dir = fromDir;
|
|
17421
|
+
for (let depth = 0; depth < 64; depth++) {
|
|
17422
|
+
const base = join(dir, "node_modules", specifier);
|
|
17423
|
+
const found = probeFile(base);
|
|
17424
|
+
if (found) {
|
|
17425
|
+
resolved = found;
|
|
17426
|
+
break;
|
|
17427
|
+
}
|
|
17428
|
+
const parent = dirname2(dir);
|
|
17429
|
+
if (parent === dir) break;
|
|
17430
|
+
dir = parent;
|
|
17431
|
+
}
|
|
17432
|
+
}
|
|
17433
|
+
return resolved ? toRealPath(resolved) : null;
|
|
17434
|
+
}
|
|
17435
|
+
function toRealPath(p) {
|
|
17436
|
+
try {
|
|
17437
|
+
return realpathSync(p);
|
|
17438
|
+
} catch {
|
|
17439
|
+
return p;
|
|
17440
|
+
}
|
|
17441
|
+
}
|
|
17442
|
+
function nativeResolve(specifier, fromDir) {
|
|
17443
|
+
try {
|
|
17444
|
+
const req = createRequire(join(fromDir, "__vesk_resolve__.js"));
|
|
17445
|
+
const resolved = req.resolve(specifier);
|
|
17446
|
+
if (isAbsolute(resolved)) return toRealPath(resolved);
|
|
17447
|
+
return builtinMarker(resolved);
|
|
17448
|
+
} catch {
|
|
17449
|
+
return null;
|
|
17450
|
+
}
|
|
17451
|
+
}
|
|
17452
|
+
function builtinMarker(name) {
|
|
17453
|
+
return BUILTIN_PREFIX + name;
|
|
17454
|
+
}
|
|
17455
|
+
function isBuiltinPath(p) {
|
|
17456
|
+
return p.startsWith(BUILTIN_PREFIX);
|
|
17457
|
+
}
|
|
17458
|
+
function loadBuiltin(name) {
|
|
17459
|
+
const id = name.startsWith("node:") ? name : `node:${name}`;
|
|
17460
|
+
const cachedVal = BUILTIN_CACHE.get(id);
|
|
17461
|
+
if (cachedVal) return cachedVal;
|
|
17462
|
+
try {
|
|
17463
|
+
const req = createRequire(join("/", "__vesk_builtin__.js"));
|
|
17464
|
+
const loaded = req(id);
|
|
17465
|
+
let mod = null;
|
|
17466
|
+
if (loaded && typeof loaded === "object") mod = loaded;
|
|
17467
|
+
else if (loaded !== null && loaded !== void 0) mod = { default: loaded };
|
|
17468
|
+
if (mod) BUILTIN_CACHE.set(id, mod);
|
|
17469
|
+
return mod;
|
|
17470
|
+
} catch {
|
|
17471
|
+
return null;
|
|
17472
|
+
}
|
|
17473
|
+
}
|
|
17474
|
+
function statOrNull(p) {
|
|
17475
|
+
try {
|
|
17476
|
+
return statSync(p);
|
|
17477
|
+
} catch {
|
|
17478
|
+
return null;
|
|
17479
|
+
}
|
|
17480
|
+
}
|
|
17481
|
+
function probeFile(base) {
|
|
17482
|
+
const st = statOrNull(base);
|
|
17483
|
+
if (st && st.isFile()) return base;
|
|
17484
|
+
if (st && st.isDirectory()) {
|
|
17485
|
+
const pkgPath = join(base, "package.json");
|
|
17486
|
+
const pkgSt = statOrNull(pkgPath);
|
|
17487
|
+
if (pkgSt && pkgSt.isFile()) {
|
|
17488
|
+
try {
|
|
17489
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
17490
|
+
if (typeof pkg.main === "string" && pkg.main.length > 0) {
|
|
17491
|
+
const viaMain = probeFile(resolve2(base, pkg.main));
|
|
17492
|
+
if (viaMain) return viaMain;
|
|
17493
|
+
}
|
|
17494
|
+
} catch {
|
|
17495
|
+
}
|
|
17496
|
+
}
|
|
17497
|
+
return probeFile(join(base, "index"));
|
|
17498
|
+
}
|
|
17499
|
+
const ext = extname(base);
|
|
17500
|
+
if (ext.length === 0 || "/\\".includes(base[base.length - 1])) {
|
|
17501
|
+
for (const suffix of EXTENSIONS) {
|
|
17502
|
+
const candidate = base + suffix;
|
|
17503
|
+
const cst = statOrNull(candidate);
|
|
17504
|
+
if (cst && cst.isFile()) return candidate;
|
|
17505
|
+
}
|
|
17506
|
+
}
|
|
17507
|
+
return null;
|
|
17508
|
+
}
|
|
17509
|
+
function astName(node) {
|
|
17510
|
+
if (!node) return "undefined";
|
|
17511
|
+
if (node.type === "Identifier" && typeof node.name === "string") return node.name;
|
|
17512
|
+
return printNode(node);
|
|
17513
|
+
}
|
|
17514
|
+
function printNode(node) {
|
|
17515
|
+
try {
|
|
17516
|
+
return print3(node, ts3()).code.trim();
|
|
17517
|
+
} catch {
|
|
17518
|
+
return "";
|
|
17519
|
+
}
|
|
17520
|
+
}
|
|
17521
|
+
function memberAccess(obj, prop) {
|
|
17522
|
+
if (prop.type === "Identifier" && typeof prop.name === "string") return `${obj}.${prop.name}`;
|
|
17523
|
+
if ((prop.type === "Literal" || prop.type === "StringLiteral") && typeof prop.value === "string") {
|
|
17524
|
+
return `${obj}[${JSON.stringify(prop.value)}]`;
|
|
17525
|
+
}
|
|
17526
|
+
return `${obj}[${astName(prop)}]`;
|
|
17527
|
+
}
|
|
17528
|
+
function exportKeyName(node) {
|
|
17529
|
+
if (!node) return "";
|
|
17530
|
+
if (node.type === "Identifier" && typeof node.name === "string") return node.name;
|
|
17531
|
+
if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
17532
|
+
const printed = printNode(node);
|
|
17533
|
+
return stripOuterQuotes(printed);
|
|
17534
|
+
}
|
|
17535
|
+
function stripOuterQuotes(s) {
|
|
17536
|
+
if (s.length >= 2) {
|
|
17537
|
+
const first = s[0];
|
|
17538
|
+
const last = s[s.length - 1];
|
|
17539
|
+
if ((first === '"' || first === "'" || first === "`") && first === last) return s.slice(1, -1);
|
|
17540
|
+
}
|
|
17541
|
+
return s;
|
|
17542
|
+
}
|
|
17543
|
+
function exportGetter(lines, key, valueExpr) {
|
|
17544
|
+
lines.push(`Object.defineProperty(exports, ${JSON.stringify(key)}, { get: () => ${valueExpr}, enumerable: true });`);
|
|
17545
|
+
}
|
|
17546
|
+
function esmToCjs(body) {
|
|
17547
|
+
const lines = [];
|
|
17548
|
+
for (const stmt of body) {
|
|
17549
|
+
switch (stmt.type) {
|
|
17550
|
+
case "ImportDeclaration": {
|
|
17551
|
+
const source = printNode(stmt.source);
|
|
17552
|
+
const specifiers = stmt.specifiers || [];
|
|
17553
|
+
if (specifiers.length === 0) {
|
|
17554
|
+
lines.push(`require(${source});`);
|
|
17555
|
+
continue;
|
|
17556
|
+
}
|
|
17557
|
+
for (const spec of specifiers) {
|
|
17558
|
+
if (spec.type === "ImportNamespaceSpecifier") {
|
|
17559
|
+
lines.push(`const ${astName(spec.local)} = require(${source});`);
|
|
17560
|
+
} else if (spec.type === "ImportDefaultSpecifier") {
|
|
17561
|
+
lines.push(`const ${astName(spec.local)} = require(${source}).default;`);
|
|
17562
|
+
} else {
|
|
17563
|
+
const local = astName(spec.local);
|
|
17564
|
+
const imported = spec.imported;
|
|
17565
|
+
if (imported && spec.importKind === "type") continue;
|
|
17566
|
+
lines.push(`const ${local} = ${memberAccess(`require(${source})`, imported || spec.local)};`);
|
|
17567
|
+
}
|
|
17568
|
+
}
|
|
17569
|
+
break;
|
|
17570
|
+
}
|
|
17571
|
+
case "ExportNamedDeclaration": {
|
|
17572
|
+
if (stmt.exportKind === "type") continue;
|
|
17573
|
+
const declaration = stmt.declaration;
|
|
17574
|
+
const source = stmt.source ? printNode(stmt.source) : null;
|
|
17575
|
+
if (declaration) {
|
|
17576
|
+
const printed = printNode(declaration);
|
|
17577
|
+
if (printed) {
|
|
17578
|
+
lines.push(printed);
|
|
17579
|
+
if (declaration.type === "VariableDeclaration") {
|
|
17580
|
+
const declarators = declaration.declarations || [];
|
|
17581
|
+
for (const d of declarators) {
|
|
17582
|
+
if (d.id && d.id.type === "Identifier") exportGetter(lines, exportKeyName(d.id), d.id.name ?? "");
|
|
17583
|
+
}
|
|
17584
|
+
} else if (declaration.id) {
|
|
17585
|
+
const name = declaration.id;
|
|
17586
|
+
exportGetter(lines, exportKeyName(name), name.name ?? "");
|
|
17587
|
+
}
|
|
17588
|
+
}
|
|
17589
|
+
} else if (source) {
|
|
17590
|
+
const modVar = `__veskExport${exportCounter++}`;
|
|
17591
|
+
lines.push(`const ${modVar} = require(${source});`);
|
|
17592
|
+
const specifiers = stmt.specifiers || [];
|
|
17593
|
+
for (const spec of specifiers) {
|
|
17594
|
+
if (spec.exportKind === "type") continue;
|
|
17595
|
+
const local = spec.local;
|
|
17596
|
+
const exported = spec.exported;
|
|
17597
|
+
exportGetter(lines, exportKeyName(exported), memberAccess(modVar, local));
|
|
17598
|
+
}
|
|
17599
|
+
} else {
|
|
17600
|
+
const specifiers = stmt.specifiers || [];
|
|
17601
|
+
for (const spec of specifiers) {
|
|
17602
|
+
if (spec.exportKind === "type") continue;
|
|
17603
|
+
const local = spec.local;
|
|
17604
|
+
const exported = spec.exported;
|
|
17605
|
+
exportGetter(lines, exportKeyName(exported), astName(local));
|
|
17606
|
+
}
|
|
17607
|
+
}
|
|
17608
|
+
break;
|
|
17609
|
+
}
|
|
17610
|
+
case "ExportDefaultDeclaration": {
|
|
17611
|
+
const declaration = stmt.declaration;
|
|
17612
|
+
if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") {
|
|
17613
|
+
if (declaration.id) {
|
|
17614
|
+
const name = declaration.id.name;
|
|
17615
|
+
lines.push(printNode(declaration));
|
|
17616
|
+
lines.push(`exports.default = ${name};`);
|
|
17617
|
+
} else {
|
|
17618
|
+
const expr = { ...declaration, type: declaration.type === "FunctionDeclaration" ? "FunctionExpression" : "ClassExpression" };
|
|
17619
|
+
lines.push(`exports.default = ${printNode(expr)};`);
|
|
17620
|
+
}
|
|
17621
|
+
} else {
|
|
17622
|
+
lines.push(`exports.default = ${printNode(declaration)};`);
|
|
17623
|
+
}
|
|
17624
|
+
break;
|
|
17625
|
+
}
|
|
17626
|
+
case "ExportAllDeclaration": {
|
|
17627
|
+
const source = printNode(stmt.source);
|
|
17628
|
+
const modVar = `__veskExport${exportCounter++}`;
|
|
17629
|
+
lines.push(`const ${modVar} = require(${source});`);
|
|
17630
|
+
if (stmt.exported) {
|
|
17631
|
+
lines.push(`exports[${JSON.stringify(exportKeyName(stmt.exported))}] = ${modVar};`);
|
|
17632
|
+
} else {
|
|
17633
|
+
lines.push(`for (const __veskKey in ${modVar}) { if (__veskKey !== 'default' && __veskKey !== '__esModule' && !(__veskKey in exports)) exports[__veskKey] = ${modVar}[__veskKey]; }`);
|
|
17634
|
+
}
|
|
17635
|
+
break;
|
|
17636
|
+
}
|
|
17637
|
+
default:
|
|
17638
|
+
lines.push(printNode(stmt));
|
|
17639
|
+
}
|
|
17640
|
+
}
|
|
17641
|
+
return lines.join("\n");
|
|
17642
|
+
}
|
|
17643
|
+
var RUNTIME_PREFIXES, EXTENSIONS, BUILTIN_PREFIX, BUILTIN_CACHE, MODULE_CACHE, MAX_CACHE_ENTRIES, depStack, EVALUATING, exportCounter;
|
|
17644
|
+
var init_module_imports = __esm({
|
|
17645
|
+
"../compiler/src/module-imports.ts"() {
|
|
17646
|
+
"use strict";
|
|
17647
|
+
init_parser();
|
|
17648
|
+
init_strip_ts();
|
|
17649
|
+
init_tokens();
|
|
17650
|
+
RUNTIME_PREFIXES = ["@vesk/runtime/", "@vesk/reactivity/", "@vesk/types", "@vesk/"];
|
|
17651
|
+
EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".jsx", ".json"];
|
|
17652
|
+
BUILTIN_PREFIX = "\0builtin:";
|
|
17653
|
+
BUILTIN_CACHE = /* @__PURE__ */ new Map();
|
|
17654
|
+
MODULE_CACHE = /* @__PURE__ */ new Map();
|
|
17655
|
+
MAX_CACHE_ENTRIES = 256;
|
|
17656
|
+
depStack = [];
|
|
17657
|
+
EVALUATING = /* @__PURE__ */ new Map();
|
|
17658
|
+
exportCounter = 0;
|
|
17659
|
+
}
|
|
17660
|
+
});
|
|
17661
|
+
|
|
16849
17662
|
// ../compiler/src/ir-generator.ts
|
|
16850
17663
|
function parseExprNode(text) {
|
|
16851
17664
|
try {
|
|
@@ -16918,9 +17731,9 @@ function componentUsesFetch(nodes) {
|
|
|
16918
17731
|
if (node instanceof ServerBlock || node instanceof ClientBlock) {
|
|
16919
17732
|
if (componentUsesFetch(node.children)) return true;
|
|
16920
17733
|
} else if (node instanceof RuntimeStatement) {
|
|
16921
|
-
if (node.raw.includes("useFetch(")) return true;
|
|
17734
|
+
if (node.raw.includes("useFetch(") || node.raw.includes("useFetch.")) return true;
|
|
16922
17735
|
} else if (node instanceof DynamicBinding) {
|
|
16923
|
-
if (node.expression.raw.includes("useFetch(")) return true;
|
|
17736
|
+
if (node.expression.raw.includes("useFetch(") || node.expression.raw.includes("useFetch.")) return true;
|
|
16924
17737
|
} else if (node instanceof MapRegion) {
|
|
16925
17738
|
if (componentUsesFetch(node.bodyTemplate)) return true;
|
|
16926
17739
|
if (componentUsesFetch(node.alternateNodes)) return true;
|
|
@@ -17212,6 +18025,21 @@ function processJSXChildren(source, children) {
|
|
|
17212
18025
|
} else if (child.type === "JSXFragment") {
|
|
17213
18026
|
for (const c of child.children) result2.push(...processJSXChildren(source, [c]));
|
|
17214
18027
|
i++;
|
|
18028
|
+
} else if (child.type === "ForOfStatement") {
|
|
18029
|
+
let alternate = [];
|
|
18030
|
+
let consumed = 1;
|
|
18031
|
+
const emptyText = children[i + 1];
|
|
18032
|
+
const emptyContainer = children[i + 2];
|
|
18033
|
+
if (emptyText && emptyText.type === "JSXText" && ["#empty", "empty"].includes(emptyText.value.trim()) && emptyContainer && emptyContainer.type === "JSXExpressionContainer" && emptyContainer.expression.type !== "JSXEmptyExpression") {
|
|
18034
|
+
alternate = exprToIR(source, emptyContainer.expression);
|
|
18035
|
+
consumed = 3;
|
|
18036
|
+
}
|
|
18037
|
+
result2.push(...processForStatement(source, child, alternate));
|
|
18038
|
+
i += consumed;
|
|
18039
|
+
continue;
|
|
18040
|
+
} else if (child.type === "IfStatement" || child.type === "ForStatement" || child.type === "ForInStatement" || child.type === "WhileStatement" || child.type === "DoWhileStatement" || child.type === "SwitchStatement" || child.type === "TryStatement" || child.type === "VariableDeclaration" || child.type === "ExpressionStatement" || child.type === "ReturnStatement" || child.type === "WithStatement" || child.type === "LabeledStatement") {
|
|
18041
|
+
result2.push(...processStatementModeBody(source, [child]));
|
|
18042
|
+
i++;
|
|
17215
18043
|
} else {
|
|
17216
18044
|
i++;
|
|
17217
18045
|
}
|
|
@@ -17248,6 +18076,19 @@ function exprToIR(source, expr) {
|
|
|
17248
18076
|
}
|
|
17249
18077
|
return [new DynamicBinding(toExpression(source, expr))];
|
|
17250
18078
|
}
|
|
18079
|
+
function isRenderableExpression(expr) {
|
|
18080
|
+
const t = expr.type;
|
|
18081
|
+
if (t === "CallExpression" || t === "NewExpression" || t === "AssignmentExpression" || t === "UpdateExpression" || t === "AwaitExpression" || t === "YieldExpression" || t === "TaggedTemplateExpression" || t === "ImportExpression" || t === "MetaProperty") {
|
|
18082
|
+
return false;
|
|
18083
|
+
}
|
|
18084
|
+
if (t === "UnaryExpression") {
|
|
18085
|
+
return expr.operator !== "delete" && expr.operator !== "void";
|
|
18086
|
+
}
|
|
18087
|
+
if (t === "SequenceExpression") {
|
|
18088
|
+
return isRenderableExpression(expr.expressions[expr.expressions.length - 1]);
|
|
18089
|
+
}
|
|
18090
|
+
return true;
|
|
18091
|
+
}
|
|
17251
18092
|
function processJSXCallbackBody(source, body) {
|
|
17252
18093
|
if (body.type === "JSXElement") return processJSXElement(source, body);
|
|
17253
18094
|
if (body.type === "JSXFragment") {
|
|
@@ -17332,11 +18173,14 @@ function buildGuardChain(source, guardClauses, mainReturn) {
|
|
|
17332
18173
|
const guard = guardClauses[i];
|
|
17333
18174
|
const condExpr = toExpression(source, guard.test);
|
|
17334
18175
|
const consequent = [];
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
18176
|
+
const guardReturn = getReturnArgument(guard.consequent);
|
|
18177
|
+
if (guardReturn) {
|
|
18178
|
+
if (guardReturn.type === "JSXElement") {
|
|
18179
|
+
consequent.push(...processJSXElement(source, guardReturn));
|
|
18180
|
+
} else if (guardReturn.type === "JSXFragment") {
|
|
18181
|
+
for (const c of guardReturn.children) consequent.push(...processJSXChildren(source, [c]));
|
|
17338
18182
|
} else {
|
|
17339
|
-
consequent.push(new DynamicBinding(toExpression(source,
|
|
18183
|
+
consequent.push(new DynamicBinding(toExpression(source, guardReturn)));
|
|
17340
18184
|
}
|
|
17341
18185
|
}
|
|
17342
18186
|
currentAlternate = [new OpaqueDynamicRegion(condExpr, consequent, currentAlternate)];
|
|
@@ -17367,7 +18211,14 @@ function hasJSXInSubtree(node) {
|
|
|
17367
18211
|
return false;
|
|
17368
18212
|
}
|
|
17369
18213
|
function isGuardClause(node) {
|
|
17370
|
-
return node.type === "IfStatement" && node.consequent
|
|
18214
|
+
return node.type === "IfStatement" && !node.alternate && getReturnArgument(node.consequent) !== null && hasJSXInSubtree(node.consequent);
|
|
18215
|
+
}
|
|
18216
|
+
function getReturnArgument(node) {
|
|
18217
|
+
if (node.type === "ReturnStatement") return node.argument ?? null;
|
|
18218
|
+
if (node.type === "BlockStatement" && node.body.length === 1 && node.body[0].type === "ReturnStatement") {
|
|
18219
|
+
return node.body[0].argument ?? null;
|
|
18220
|
+
}
|
|
18221
|
+
return null;
|
|
17371
18222
|
}
|
|
17372
18223
|
function isStatementMode(bodyStmts) {
|
|
17373
18224
|
if (bodyStmts.some((s) => s.type === "JSXElement" || s.type === "JSXExpressionContainer" || s.type === "JSXFragment")) return true;
|
|
@@ -17518,6 +18369,13 @@ function processStatementModeBody(source, bodyStmts) {
|
|
|
17518
18369
|
nodes.push(...processForStatement(source, stmt));
|
|
17519
18370
|
} else if (stmt.type === "ForStatement") {
|
|
17520
18371
|
nodes.push(...processForStatement(source, stmt));
|
|
18372
|
+
} else if (stmt.type === "ExpressionStatement") {
|
|
18373
|
+
if (isRenderableExpression(stmt.expression)) {
|
|
18374
|
+
nodes.push(...exprToIR(source, stmt.expression));
|
|
18375
|
+
} else {
|
|
18376
|
+
const raw2 = getSource(source, stmt);
|
|
18377
|
+
if (raw2) nodes.push(new RuntimeStatement(raw2, stmt, source));
|
|
18378
|
+
}
|
|
17521
18379
|
} else if (stmt.type === "ClassDeclaration") {
|
|
17522
18380
|
throw VeskError.classDecl();
|
|
17523
18381
|
} else {
|
|
@@ -17823,7 +18681,11 @@ function generateIR(ast, source) {
|
|
|
17823
18681
|
if (importModuleTarget(imp) !== "@vesk/runtime") continue;
|
|
17824
18682
|
for (const n of extractImportNames(imp)) existing.add(n);
|
|
17825
18683
|
}
|
|
17826
|
-
const
|
|
18684
|
+
const boundLocally = /* @__PURE__ */ new Set();
|
|
18685
|
+
for (const imp of imports) {
|
|
18686
|
+
for (const pair of importBindingPairs(imp)) boundLocally.add(pair.local);
|
|
18687
|
+
}
|
|
18688
|
+
const missing = [...usedFunctions].filter((f) => !existing.has(f) && !boundLocally.has(f));
|
|
17827
18689
|
if (missing.length > 0) {
|
|
17828
18690
|
imports.push(`import { ${missing.join(", ")} } from '@vesk/runtime';`);
|
|
17829
18691
|
}
|
|
@@ -17840,6 +18702,7 @@ var init_ir_generator = __esm({
|
|
|
17840
18702
|
init_scan();
|
|
17841
18703
|
init_strip_ts();
|
|
17842
18704
|
init_vsk_imports();
|
|
18705
|
+
init_module_imports();
|
|
17843
18706
|
init_tokens();
|
|
17844
18707
|
__vskAnnotations = [];
|
|
17845
18708
|
}
|
|
@@ -23609,7 +24472,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23609
24472
|
let latestResultPromise;
|
|
23610
24473
|
let provideLatestResult;
|
|
23611
24474
|
if (isContext)
|
|
23612
|
-
requestCallbacks["on-end"] = (id, request2) => new Promise((
|
|
24475
|
+
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve27) => {
|
|
23613
24476
|
buildResponseToResult(request2, (err, result2, onEndErrors, onEndWarnings) => {
|
|
23614
24477
|
const response = {
|
|
23615
24478
|
errors: onEndErrors,
|
|
@@ -23619,7 +24482,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23619
24482
|
latestResultPromise = void 0;
|
|
23620
24483
|
provideLatestResult = void 0;
|
|
23621
24484
|
sendResponse(id, response);
|
|
23622
|
-
|
|
24485
|
+
resolve27();
|
|
23623
24486
|
});
|
|
23624
24487
|
});
|
|
23625
24488
|
sendRequest(refs, request, (error, response) => {
|
|
@@ -23636,10 +24499,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23636
24499
|
let didDispose = false;
|
|
23637
24500
|
const result2 = {
|
|
23638
24501
|
rebuild: () => {
|
|
23639
|
-
if (!latestResultPromise) latestResultPromise = new Promise((
|
|
24502
|
+
if (!latestResultPromise) latestResultPromise = new Promise((resolve27, reject) => {
|
|
23640
24503
|
let settlePromise;
|
|
23641
24504
|
provideLatestResult = (err, result22) => {
|
|
23642
|
-
if (!settlePromise) settlePromise = () => err ? reject(err) :
|
|
24505
|
+
if (!settlePromise) settlePromise = () => err ? reject(err) : resolve27(result22);
|
|
23643
24506
|
};
|
|
23644
24507
|
const triggerAnotherBuild = () => {
|
|
23645
24508
|
const request2 = {
|
|
@@ -23660,7 +24523,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23660
24523
|
});
|
|
23661
24524
|
return latestResultPromise;
|
|
23662
24525
|
},
|
|
23663
|
-
watch: (options22 = {}) => new Promise((
|
|
24526
|
+
watch: (options22 = {}) => new Promise((resolve27, reject) => {
|
|
23664
24527
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "watch" API in this environment`);
|
|
23665
24528
|
const keys = {};
|
|
23666
24529
|
const delay = getFlag(options22, keys, "delay", mustBeInteger);
|
|
@@ -23672,10 +24535,10 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23672
24535
|
if (delay) request2.delay = delay;
|
|
23673
24536
|
sendRequest(refs, request2, (error2) => {
|
|
23674
24537
|
if (error2) reject(new Error(error2));
|
|
23675
|
-
else
|
|
24538
|
+
else resolve27(void 0);
|
|
23676
24539
|
});
|
|
23677
24540
|
}),
|
|
23678
|
-
serve: (options22 = {}) => new Promise((
|
|
24541
|
+
serve: (options22 = {}) => new Promise((resolve27, reject) => {
|
|
23679
24542
|
if (!streamIn.hasFS) throw new Error(`Cannot use the "serve" API in this environment`);
|
|
23680
24543
|
const keys = {};
|
|
23681
24544
|
const port2 = getFlag(options22, keys, "port", mustBeValidPortNumber);
|
|
@@ -23713,28 +24576,28 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23713
24576
|
sendResponse(id, {});
|
|
23714
24577
|
};
|
|
23715
24578
|
}
|
|
23716
|
-
|
|
24579
|
+
resolve27(response2);
|
|
23717
24580
|
});
|
|
23718
24581
|
}),
|
|
23719
|
-
cancel: () => new Promise((
|
|
23720
|
-
if (didDispose) return
|
|
24582
|
+
cancel: () => new Promise((resolve27) => {
|
|
24583
|
+
if (didDispose) return resolve27();
|
|
23721
24584
|
const request2 = {
|
|
23722
24585
|
command: "cancel",
|
|
23723
24586
|
key: buildKey
|
|
23724
24587
|
};
|
|
23725
24588
|
sendRequest(refs, request2, () => {
|
|
23726
|
-
|
|
24589
|
+
resolve27();
|
|
23727
24590
|
});
|
|
23728
24591
|
}),
|
|
23729
|
-
dispose: () => new Promise((
|
|
23730
|
-
if (didDispose) return
|
|
24592
|
+
dispose: () => new Promise((resolve27) => {
|
|
24593
|
+
if (didDispose) return resolve27();
|
|
23731
24594
|
didDispose = true;
|
|
23732
24595
|
const request2 = {
|
|
23733
24596
|
command: "dispose",
|
|
23734
24597
|
key: buildKey
|
|
23735
24598
|
};
|
|
23736
24599
|
sendRequest(refs, request2, () => {
|
|
23737
|
-
|
|
24600
|
+
resolve27();
|
|
23738
24601
|
scheduleOnDisposeCallbacks();
|
|
23739
24602
|
refs.unref();
|
|
23740
24603
|
});
|
|
@@ -23773,7 +24636,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23773
24636
|
onLoad: []
|
|
23774
24637
|
};
|
|
23775
24638
|
i++;
|
|
23776
|
-
let
|
|
24639
|
+
let resolve27 = (path3, options2 = {}) => {
|
|
23777
24640
|
if (!isSetupDone) throw new Error('Cannot call "resolve" before plugin setup has completed');
|
|
23778
24641
|
if (typeof path3 !== "string") throw new Error(`The path to resolve must be a string`);
|
|
23779
24642
|
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
@@ -23785,7 +24648,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23785
24648
|
let pluginData = getFlag(options2, keys2, "pluginData", canBeAnything);
|
|
23786
24649
|
let importAttributes = getFlag(options2, keys2, "with", mustBeObject);
|
|
23787
24650
|
checkForInvalidFlags(options2, keys2, "in resolve() call");
|
|
23788
|
-
return new Promise((
|
|
24651
|
+
return new Promise((resolve28, reject) => {
|
|
23789
24652
|
const request = {
|
|
23790
24653
|
command: "resolve",
|
|
23791
24654
|
path: path3,
|
|
@@ -23802,7 +24665,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23802
24665
|
if (importAttributes != null) request.with = sanitizeStringMap(importAttributes, "with");
|
|
23803
24666
|
sendRequest(refs, request, (error, response) => {
|
|
23804
24667
|
if (error !== null) reject(new Error(error));
|
|
23805
|
-
else
|
|
24668
|
+
else resolve28({
|
|
23806
24669
|
errors: replaceDetailsInMessages(response.errors, details),
|
|
23807
24670
|
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
23808
24671
|
path: response.path,
|
|
@@ -23817,7 +24680,7 @@ is not a problem with esbuild. You need to fix your environment instead.
|
|
|
23817
24680
|
};
|
|
23818
24681
|
let promise = setup({
|
|
23819
24682
|
initialOptions,
|
|
23820
|
-
resolve:
|
|
24683
|
+
resolve: resolve27,
|
|
23821
24684
|
onStart(callback) {
|
|
23822
24685
|
let registeredText = `This error came from the "onStart" callback registered here:`;
|
|
23823
24686
|
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
|
@@ -24510,46 +25373,46 @@ More information: The file containing the code for esbuild's JavaScript API (${_
|
|
|
24510
25373
|
}
|
|
24511
25374
|
};
|
|
24512
25375
|
longLivedService = {
|
|
24513
|
-
build: (options2) => new Promise((
|
|
25376
|
+
build: (options2) => new Promise((resolve27, reject) => {
|
|
24514
25377
|
service.buildOrContext({
|
|
24515
25378
|
callName: "build",
|
|
24516
25379
|
refs,
|
|
24517
25380
|
options: options2,
|
|
24518
25381
|
isTTY: isTTY(),
|
|
24519
25382
|
defaultWD,
|
|
24520
|
-
callback: (err, res) => err ? reject(err) :
|
|
25383
|
+
callback: (err, res) => err ? reject(err) : resolve27(res)
|
|
24521
25384
|
});
|
|
24522
25385
|
}),
|
|
24523
|
-
context: (options2) => new Promise((
|
|
25386
|
+
context: (options2) => new Promise((resolve27, reject) => service.buildOrContext({
|
|
24524
25387
|
callName: "context",
|
|
24525
25388
|
refs,
|
|
24526
25389
|
options: options2,
|
|
24527
25390
|
isTTY: isTTY(),
|
|
24528
25391
|
defaultWD,
|
|
24529
|
-
callback: (err, res) => err ? reject(err) :
|
|
25392
|
+
callback: (err, res) => err ? reject(err) : resolve27(res)
|
|
24530
25393
|
})),
|
|
24531
|
-
transform: (input, options2) => new Promise((
|
|
25394
|
+
transform: (input, options2) => new Promise((resolve27, reject) => service.transform({
|
|
24532
25395
|
callName: "transform",
|
|
24533
25396
|
refs,
|
|
24534
25397
|
input,
|
|
24535
25398
|
options: options2 || {},
|
|
24536
25399
|
isTTY: isTTY(),
|
|
24537
25400
|
fs: fsAsync,
|
|
24538
|
-
callback: (err, res) => err ? reject(err) :
|
|
25401
|
+
callback: (err, res) => err ? reject(err) : resolve27(res)
|
|
24539
25402
|
})),
|
|
24540
|
-
formatMessages: (messages, options2) => new Promise((
|
|
25403
|
+
formatMessages: (messages, options2) => new Promise((resolve27, reject) => service.formatMessages({
|
|
24541
25404
|
callName: "formatMessages",
|
|
24542
25405
|
refs,
|
|
24543
25406
|
messages,
|
|
24544
25407
|
options: options2,
|
|
24545
|
-
callback: (err, res) => err ? reject(err) :
|
|
25408
|
+
callback: (err, res) => err ? reject(err) : resolve27(res)
|
|
24546
25409
|
})),
|
|
24547
|
-
analyzeMetafile: (metafile, options2) => new Promise((
|
|
25410
|
+
analyzeMetafile: (metafile, options2) => new Promise((resolve27, reject) => service.analyzeMetafile({
|
|
24548
25411
|
callName: "analyzeMetafile",
|
|
24549
25412
|
refs,
|
|
24550
25413
|
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
24551
25414
|
options: options2,
|
|
24552
|
-
callback: (err, res) => err ? reject(err) :
|
|
25415
|
+
callback: (err, res) => err ? reject(err) : resolve27(res)
|
|
24553
25416
|
}))
|
|
24554
25417
|
};
|
|
24555
25418
|
return longLivedService;
|
|
@@ -24627,13 +25490,13 @@ error: ${text}`);
|
|
|
24627
25490
|
worker.postMessage(msg);
|
|
24628
25491
|
let status = Atomics.wait(sharedBufferView, 0, 0);
|
|
24629
25492
|
if (status !== "ok" && status !== "not-equal") throw new Error("Internal error: Atomics.wait() failed: " + status);
|
|
24630
|
-
let { message: { id: id2, resolve:
|
|
25493
|
+
let { message: { id: id2, resolve: resolve27, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
|
24631
25494
|
if (id !== id2) throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
|
24632
25495
|
if (reject) {
|
|
24633
25496
|
applyProperties(reject, properties);
|
|
24634
25497
|
throw reject;
|
|
24635
25498
|
}
|
|
24636
|
-
return
|
|
25499
|
+
return resolve27;
|
|
24637
25500
|
};
|
|
24638
25501
|
worker.unref();
|
|
24639
25502
|
return {
|
|
@@ -25025,8 +25888,8 @@ var init_server_head = __esm({
|
|
|
25025
25888
|
|
|
25026
25889
|
// ../compiler/src/actions.ts
|
|
25027
25890
|
import { walk as walk2 } from "zimmerframe";
|
|
25028
|
-
import { print as
|
|
25029
|
-
import
|
|
25891
|
+
import { print as print4 } from "esrap";
|
|
25892
|
+
import ts4 from "esrap/languages/ts";
|
|
25030
25893
|
function hashString2(str) {
|
|
25031
25894
|
let h1 = 2166136261;
|
|
25032
25895
|
let h2 = 16777619;
|
|
@@ -25090,7 +25953,7 @@ function printWithTypesStripped(ast, code, hadTs = hasTsSyntax(ast)) {
|
|
|
25090
25953
|
stripped.body = stripped.body.filter((n) => !isTypeOnlyStatement(n));
|
|
25091
25954
|
}
|
|
25092
25955
|
try {
|
|
25093
|
-
return
|
|
25956
|
+
return print4(stripped, ts4()).code;
|
|
25094
25957
|
} catch {
|
|
25095
25958
|
return code;
|
|
25096
25959
|
}
|
|
@@ -25163,8 +26026,8 @@ var init_actions = __esm({
|
|
|
25163
26026
|
});
|
|
25164
26027
|
|
|
25165
26028
|
// ../compiler/src/md-inline.ts
|
|
25166
|
-
import { readFileSync, existsSync as existsSync3 } from "node:fs";
|
|
25167
|
-
import { dirname as
|
|
26029
|
+
import { readFileSync as readFileSync2, existsSync as existsSync3 } from "node:fs";
|
|
26030
|
+
import { dirname as dirname4, join as join3, resolve as resolve4 } from "node:path";
|
|
25168
26031
|
function looksLikeMarkdownPath(value) {
|
|
25169
26032
|
const v = value.trim();
|
|
25170
26033
|
if (v.length === 0 || v.length > 4096) return false;
|
|
@@ -25201,7 +26064,7 @@ function inlineMdContentAttrs(source, importerDir, mdRoots = []) {
|
|
|
25201
26064
|
if (abs !== null) {
|
|
25202
26065
|
let contents;
|
|
25203
26066
|
try {
|
|
25204
|
-
contents =
|
|
26067
|
+
contents = readFileSync2(abs, "utf-8");
|
|
25205
26068
|
} catch {
|
|
25206
26069
|
out += source[i];
|
|
25207
26070
|
i++;
|
|
@@ -25228,14 +26091,14 @@ function resolveMdPath(specifier, importerDir, roots) {
|
|
|
25228
26091
|
const spec = specifier.trim();
|
|
25229
26092
|
if (isRelativeSpecifier(spec)) {
|
|
25230
26093
|
if (!importerDir) return null;
|
|
25231
|
-
const abs =
|
|
26094
|
+
const abs = resolve4(importerDir, spec);
|
|
25232
26095
|
return existsSync3(abs) ? abs : null;
|
|
25233
26096
|
}
|
|
25234
26097
|
if (spec.startsWith("/")) {
|
|
25235
26098
|
for (const root3 of roots) {
|
|
25236
|
-
const pub =
|
|
26099
|
+
const pub = join3(root3, "public", spec);
|
|
25237
26100
|
if (existsSync3(pub)) return pub;
|
|
25238
|
-
const direct =
|
|
26101
|
+
const direct = join3(root3, spec);
|
|
25239
26102
|
if (existsSync3(direct)) return direct;
|
|
25240
26103
|
}
|
|
25241
26104
|
}
|
|
@@ -25247,15 +26110,15 @@ function guessProjectRoots(dir) {
|
|
|
25247
26110
|
let cur = dir;
|
|
25248
26111
|
for (let i = 0; i < 6; i++) {
|
|
25249
26112
|
roots.push(cur);
|
|
25250
|
-
if (existsSync3(
|
|
25251
|
-
const parent =
|
|
26113
|
+
if (existsSync3(join3(cur, "package.json"))) break;
|
|
26114
|
+
const parent = dirname4(cur);
|
|
25252
26115
|
if (parent === cur) break;
|
|
25253
26116
|
cur = parent;
|
|
25254
26117
|
}
|
|
25255
26118
|
return roots;
|
|
25256
26119
|
}
|
|
25257
26120
|
function inlineMdImportsFrom(source, importerFile, mdRoots = []) {
|
|
25258
|
-
const dir = importerFile ?
|
|
26121
|
+
const dir = importerFile ? dirname4(importerFile) : null;
|
|
25259
26122
|
return inlineMdContentAttrs(source, dir, mdRoots.length > 0 ? mdRoots : [dir || process.cwd()]);
|
|
25260
26123
|
}
|
|
25261
26124
|
var MD_EXT_MARKER;
|
|
@@ -25268,8 +26131,8 @@ var init_md_inline = __esm({
|
|
|
25268
26131
|
|
|
25269
26132
|
// ../compiler/src/client-codegen.ts
|
|
25270
26133
|
import { walk as walk3 } from "zimmerframe";
|
|
25271
|
-
import { print as
|
|
25272
|
-
import
|
|
26134
|
+
import { print as print5 } from "esrap";
|
|
26135
|
+
import ts5 from "esrap/languages/ts";
|
|
25273
26136
|
import tsx from "esrap/languages/tsx";
|
|
25274
26137
|
function callExpr(callee, args2 = []) {
|
|
25275
26138
|
return { type: "CallExpression", callee, arguments: args2, optional: false };
|
|
@@ -25306,7 +26169,7 @@ function containsJsx(node, depth = 0) {
|
|
|
25306
26169
|
return false;
|
|
25307
26170
|
}
|
|
25308
26171
|
function printAst(ast) {
|
|
25309
|
-
return
|
|
26172
|
+
return print5(ast, containsJsx(ast) ? tsx() : ts5()).code;
|
|
25310
26173
|
}
|
|
25311
26174
|
function transformTracked(irNode, tracked2) {
|
|
25312
26175
|
const ast = irNode.ast;
|
|
@@ -25390,7 +26253,7 @@ function transformTracked(irNode, tracked2) {
|
|
|
25390
26253
|
return context.next();
|
|
25391
26254
|
}
|
|
25392
26255
|
});
|
|
25393
|
-
return
|
|
26256
|
+
return print5(transformed, containsJsx(transformed) ? tsx() : ts5()).code;
|
|
25394
26257
|
}
|
|
25395
26258
|
function collectTrackedNames(body) {
|
|
25396
26259
|
const names = /* @__PURE__ */ new Map();
|
|
@@ -26471,7 +27334,12 @@ function emitClientFromIR(ir, options2) {
|
|
|
26471
27334
|
runtimeNames.push(name);
|
|
26472
27335
|
}
|
|
26473
27336
|
}
|
|
26474
|
-
const
|
|
27337
|
+
const boundLocally = /* @__PURE__ */ new Set();
|
|
27338
|
+
for (const imp of ir.imports) {
|
|
27339
|
+
for (const pair of importBindingPairs(imp)) boundLocally.add(pair.local);
|
|
27340
|
+
}
|
|
27341
|
+
const shadowedRuntimeNames = runtimeNames.filter((n) => !boundLocally.has(n));
|
|
27342
|
+
const runtimeImport = `import { ${shadowedRuntimeNames.length > 0 ? shadowedRuntimeNames.join(", ") : "destroy_block"} } from '@vesk/runtime';`;
|
|
26475
27343
|
const moduleCode = `
|
|
26476
27344
|
${runtimeImport}
|
|
26477
27345
|
${importLines}
|
|
@@ -26517,6 +27385,7 @@ var init_client_codegen = __esm({
|
|
|
26517
27385
|
init_ir_generator();
|
|
26518
27386
|
init_actions();
|
|
26519
27387
|
init_server_utils();
|
|
27388
|
+
init_module_imports();
|
|
26520
27389
|
init_scan();
|
|
26521
27390
|
init_md_inline();
|
|
26522
27391
|
init_strip_ts();
|
|
@@ -26973,18 +27842,21 @@ function generateFunctionBody(comp, importedNames) {
|
|
|
26973
27842
|
function buildComponentMap2(irRoot, useSharedScope) {
|
|
26974
27843
|
const map = /* @__PURE__ */ new Map();
|
|
26975
27844
|
const runtimeNames = extractRuntimeNames(irRoot.imports);
|
|
26976
|
-
const
|
|
27845
|
+
const localValueNames = localValueImportNames(irRoot.imports);
|
|
27846
|
+
const importedNames = /* @__PURE__ */ new Set([...runtimeNames, ...localValueNames]);
|
|
26977
27847
|
const topNames = extractTopLevelNames(irRoot.topLevelCode);
|
|
26978
27848
|
const hasTracked = irRoot.components.some((c) => c.body.some((n) => n instanceof TrackDecl));
|
|
26979
27849
|
const extraNames = hasTracked ? ["get", "set", "track"] : [];
|
|
26980
|
-
const allNames = [.../* @__PURE__ */ new Set([...runtimeNames, ...topNames, ...extraNames])];
|
|
27850
|
+
const allNames = [.../* @__PURE__ */ new Set([...runtimeNames, ...topNames, ...extraNames, ...localValueNames])];
|
|
26981
27851
|
const scopeDecl = allNames.length > 0 ? `const { ${allNames.join(", ")} } = __vesk;
|
|
26982
27852
|
` : "";
|
|
26983
27853
|
setVskImportedNames(importedNames);
|
|
26984
27854
|
for (const comp of irRoot.components) {
|
|
26985
27855
|
const bodyCode = generateFunctionBody(comp, importedNames);
|
|
26986
27856
|
const paramInit = buildParamInit(comp.paramNames);
|
|
26987
|
-
const
|
|
27857
|
+
const diag = process.env.VESK_SSR_LOG ? `console.error('[SSR-CALL]', ${JSON.stringify(comp.name)}, props ? JSON.stringify(props) : String(props));
|
|
27858
|
+
` : "";
|
|
27859
|
+
const code = `${scopeDecl}${paramInit}${diag}
|
|
26988
27860
|
${bodyCode}`;
|
|
26989
27861
|
let fn;
|
|
26990
27862
|
if (comp.isAsync || comp.ssrAwait) {
|
|
@@ -27007,6 +27879,7 @@ var init_server_jsgen = __esm({
|
|
|
27007
27879
|
init_client_codegen();
|
|
27008
27880
|
init_scan();
|
|
27009
27881
|
init_server_utils();
|
|
27882
|
+
init_module_imports();
|
|
27010
27883
|
__currentCompName = "";
|
|
27011
27884
|
}
|
|
27012
27885
|
});
|
|
@@ -27056,34 +27929,39 @@ __export(server_render_exports, {
|
|
|
27056
27929
|
renderPageStream: () => renderPageStream,
|
|
27057
27930
|
ssg: () => ssg
|
|
27058
27931
|
});
|
|
27059
|
-
import { readFileSync as
|
|
27060
|
-
import { dirname as
|
|
27932
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
27933
|
+
import { dirname as dirname5 } from "node:path";
|
|
27061
27934
|
function compileFile(source, options2) {
|
|
27062
27935
|
return compileFileInternal(source, options2?.sourcePath, /* @__PURE__ */ new Set());
|
|
27063
27936
|
}
|
|
27064
27937
|
function compileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
27065
27938
|
if (sourcePath2) {
|
|
27066
|
-
const dir =
|
|
27939
|
+
const dir = dirname5(sourcePath2);
|
|
27067
27940
|
source = inlineMdImportsFrom(source, sourcePath2, guessProjectRoots(dir));
|
|
27068
27941
|
}
|
|
27069
27942
|
const ast = parse4(source);
|
|
27070
27943
|
const ir = generateIR(ast, source);
|
|
27071
27944
|
const componentMap = buildComponentMap2(ir, true);
|
|
27945
|
+
const __vesk = loadRuntimeImports(ir.imports);
|
|
27946
|
+
applyLocalModuleImports(__vesk, ir.imports, sourcePath2);
|
|
27072
27947
|
if (sourcePath2) {
|
|
27073
27948
|
for (const importPath of collectVskImportPaths(ir.imports, sourcePath2)) {
|
|
27074
27949
|
if (seenImportFiles.has(importPath)) continue;
|
|
27075
27950
|
seenImportFiles.add(importPath);
|
|
27076
27951
|
try {
|
|
27077
|
-
const importedSrc =
|
|
27952
|
+
const importedSrc = readFileSync3(importPath, "utf-8");
|
|
27078
27953
|
const sub = compileFileInternal(importedSrc, importPath, seenImportFiles);
|
|
27079
27954
|
for (const [name, fn] of sub.componentMap) {
|
|
27080
27955
|
if (!componentMap.has(name)) componentMap.set(name, fn);
|
|
27081
27956
|
}
|
|
27957
|
+
for (const key of Object.keys(sub.__vesk)) {
|
|
27958
|
+
if (key in __vesk) continue;
|
|
27959
|
+
__vesk[key] = sub.__vesk[key];
|
|
27960
|
+
}
|
|
27082
27961
|
} catch {
|
|
27083
27962
|
}
|
|
27084
27963
|
}
|
|
27085
27964
|
}
|
|
27086
|
-
const __vesk = loadRuntimeImports(ir.imports);
|
|
27087
27965
|
evalTopLevelCode(transformTopLevelForActions(ir.topLevelCode, "server"), __vesk);
|
|
27088
27966
|
return { ir, componentMap, __vesk };
|
|
27089
27967
|
}
|
|
@@ -27341,7 +28219,11 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
|
|
|
27341
28219
|
const ir = cached ? cached.ir : generateIR(parse4(source), source);
|
|
27342
28220
|
let ssrProps = { ...props };
|
|
27343
28221
|
let serializedProps = null;
|
|
27344
|
-
let __vesk = options2.__vesk || cached?.__vesk ||
|
|
28222
|
+
let __vesk = options2.__vesk || cached?.__vesk || null;
|
|
28223
|
+
if (!__vesk) {
|
|
28224
|
+
__vesk = loadRuntimeImports(ir.imports);
|
|
28225
|
+
applyLocalModuleImports(__vesk, ir.imports, options2.sourcePath || void 0);
|
|
28226
|
+
}
|
|
27345
28227
|
if (ir.loadFn) {
|
|
27346
28228
|
const loadResult = await callLoadFunction(ir.loadFn, props, __vesk);
|
|
27347
28229
|
if (loadResult && typeof loadResult === "object") {
|
|
@@ -27428,14 +28310,15 @@ var init_server_render = __esm({
|
|
|
27428
28310
|
init_vsk_imports();
|
|
27429
28311
|
init_md_inline();
|
|
27430
28312
|
init_ssr_store();
|
|
28313
|
+
init_module_imports();
|
|
27431
28314
|
}
|
|
27432
28315
|
});
|
|
27433
28316
|
|
|
27434
28317
|
// ../adapter/src/paths.ts
|
|
27435
|
-
import { resolve as
|
|
28318
|
+
import { resolve as resolve9, sep as sep2 } from "node:path";
|
|
27436
28319
|
function resolveWithin(baseDir, relPath) {
|
|
27437
|
-
const base =
|
|
27438
|
-
const target =
|
|
28320
|
+
const base = resolve9(baseDir);
|
|
28321
|
+
const target = resolve9(baseDir, relPath);
|
|
27439
28322
|
const prefix = base + sep2;
|
|
27440
28323
|
if (!target.startsWith(prefix)) return null;
|
|
27441
28324
|
return target;
|
|
@@ -27454,10 +28337,10 @@ __export(static_exports, {
|
|
|
27454
28337
|
generateSitemap: () => generateSitemap,
|
|
27455
28338
|
generateSsgRoutes: () => generateSsgRoutes
|
|
27456
28339
|
});
|
|
27457
|
-
import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as
|
|
27458
|
-
import { resolve as
|
|
28340
|
+
import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as statSync6, existsSync as existsSync10, writeFileSync as writeFileSync4, readFileSync as readFileSync11 } from "node:fs";
|
|
28341
|
+
import { resolve as resolve12, join as join7 } from "node:path";
|
|
27459
28342
|
function copyStaticAssets2(publicDir, outDir2) {
|
|
27460
|
-
const targetDir =
|
|
28343
|
+
const targetDir = resolve12(outDir2, "static", "public");
|
|
27461
28344
|
mkdirSync2(targetDir, { recursive: true });
|
|
27462
28345
|
if (!existsSync10(publicDir))
|
|
27463
28346
|
return;
|
|
@@ -27465,9 +28348,9 @@ function copyStaticAssets2(publicDir, outDir2) {
|
|
|
27465
28348
|
mkdirSync2(dest, { recursive: true });
|
|
27466
28349
|
const entries = readdirSync3(src2);
|
|
27467
28350
|
for (const entry of entries) {
|
|
27468
|
-
const srcPath =
|
|
27469
|
-
const destPath =
|
|
27470
|
-
const st =
|
|
28351
|
+
const srcPath = join7(src2, entry);
|
|
28352
|
+
const destPath = join7(dest, entry);
|
|
28353
|
+
const st = statSync6(srcPath);
|
|
27471
28354
|
if (st.isDirectory()) {
|
|
27472
28355
|
copyDir(srcPath, destPath);
|
|
27473
28356
|
} else {
|
|
@@ -27479,7 +28362,7 @@ function copyStaticAssets2(publicDir, outDir2) {
|
|
|
27479
28362
|
}
|
|
27480
28363
|
async function generateSsgRoutes(routeTree, appDir, outDir2) {
|
|
27481
28364
|
const { ssg: ssg2 } = await Promise.resolve().then(() => (init_server_render(), server_render_exports));
|
|
27482
|
-
const prerenderDir =
|
|
28365
|
+
const prerenderDir = resolve12(outDir2, "prerendered");
|
|
27483
28366
|
mkdirSync2(prerenderDir, { recursive: true });
|
|
27484
28367
|
const results = [];
|
|
27485
28368
|
async function evaluateExport(src2, exportName) {
|
|
@@ -27498,8 +28381,8 @@ async function generateSsgRoutes(routeTree, appDir, outDir2) {
|
|
|
27498
28381
|
async function walk6(nodes) {
|
|
27499
28382
|
for (const node of nodes) {
|
|
27500
28383
|
if (node.page) {
|
|
27501
|
-
const pagePath =
|
|
27502
|
-
const src2 =
|
|
28384
|
+
const pagePath = resolve12(appDir, node.sourceDir, "page.vsk");
|
|
28385
|
+
const src2 = readFileSync11(pagePath, "utf-8");
|
|
27503
28386
|
const hasStaticProps = src2.includes("getStaticProps");
|
|
27504
28387
|
const hasStaticPaths = src2.includes("getStaticPaths");
|
|
27505
28388
|
if (hasStaticPaths) {
|
|
@@ -27516,7 +28399,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir2) {
|
|
|
27516
28399
|
console.error(`vesk: SSG path escaped output dir \u2014 skipping ${pagePath} (path: ${urlPath})`);
|
|
27517
28400
|
continue;
|
|
27518
28401
|
}
|
|
27519
|
-
mkdirSync2(
|
|
28402
|
+
mkdirSync2(resolve12(htmlPath, ".."), { recursive: true });
|
|
27520
28403
|
writeFileSync4(htmlPath, result2.html);
|
|
27521
28404
|
results.push({ path: urlPath, html: htmlPath, static: result2.static, params });
|
|
27522
28405
|
} catch (e) {
|
|
@@ -27528,8 +28411,8 @@ async function generateSsgRoutes(routeTree, appDir, outDir2) {
|
|
|
27528
28411
|
} else if (hasStaticProps) {
|
|
27529
28412
|
try {
|
|
27530
28413
|
const result2 = await ssg2(src2, null, void 0, {});
|
|
27531
|
-
const htmlPath =
|
|
27532
|
-
mkdirSync2(
|
|
28414
|
+
const htmlPath = resolve12(prerenderDir, node.fullPath === "/" ? "index.html" : `${node.fullPath.slice(1)}.html`);
|
|
28415
|
+
mkdirSync2(resolve12(htmlPath, ".."), { recursive: true });
|
|
27533
28416
|
writeFileSync4(htmlPath, result2.html);
|
|
27534
28417
|
results.push({ path: node.fullPath, html: htmlPath, static: result2.static });
|
|
27535
28418
|
} catch (e) {
|
|
@@ -27599,15 +28482,15 @@ var image_pipeline_exports = {};
|
|
|
27599
28482
|
__export(image_pipeline_exports, {
|
|
27600
28483
|
optimizeImages: () => optimizeImages
|
|
27601
28484
|
});
|
|
27602
|
-
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5, readFileSync as
|
|
27603
|
-
import { resolve as
|
|
28485
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5, readFileSync as readFileSync12, existsSync as existsSync11, readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
|
|
28486
|
+
import { resolve as resolve13, extname as extname4, dirname as dirname8 } from "node:path";
|
|
27604
28487
|
async function processImage(srcPath, outDir2, baseName) {
|
|
27605
28488
|
const image = sharpFn ? sharpFn(srcPath) : null;
|
|
27606
28489
|
if (!image) {
|
|
27607
|
-
const original =
|
|
28490
|
+
const original = readFileSync12(srcPath);
|
|
27608
28491
|
for (const w of OUTPUT_WIDTHS) {
|
|
27609
|
-
const outputPath =
|
|
27610
|
-
mkdirSync3(
|
|
28492
|
+
const outputPath = resolve13(outDir2, `${baseName}-${w}w`);
|
|
28493
|
+
mkdirSync3(dirname8(outputPath), { recursive: true });
|
|
27611
28494
|
writeFileSync5(outputPath, original);
|
|
27612
28495
|
}
|
|
27613
28496
|
return [];
|
|
@@ -27620,12 +28503,12 @@ async function processImage(srcPath, outDir2, baseName) {
|
|
|
27620
28503
|
continue;
|
|
27621
28504
|
const resized = image.clone().resize({ width: w, withoutEnlargement: true });
|
|
27622
28505
|
const base = `${baseName}-${w}w`;
|
|
27623
|
-
const jpgPath =
|
|
27624
|
-
mkdirSync3(
|
|
28506
|
+
const jpgPath = resolve13(outDir2, `${base}${extname4(srcPath)}`);
|
|
28507
|
+
mkdirSync3(dirname8(jpgPath), { recursive: true });
|
|
27625
28508
|
await resized.toFile(jpgPath);
|
|
27626
28509
|
generated.push(jpgPath);
|
|
27627
28510
|
for (const fmt of FORMATS) {
|
|
27628
|
-
const fmtPath =
|
|
28511
|
+
const fmtPath = resolve13(outDir2, `${base}.${fmt}`);
|
|
27629
28512
|
await resized.toFormat(fmt, { quality: 80 }).toFile(fmtPath);
|
|
27630
28513
|
generated.push(fmtPath);
|
|
27631
28514
|
}
|
|
@@ -27642,14 +28525,14 @@ function collectImageRefs(appDir) {
|
|
|
27642
28525
|
return;
|
|
27643
28526
|
}
|
|
27644
28527
|
for (const entry of entries) {
|
|
27645
|
-
const full =
|
|
27646
|
-
const st =
|
|
28528
|
+
const full = resolve13(dir, entry);
|
|
28529
|
+
const st = statSync7(full);
|
|
27647
28530
|
if (st.isDirectory()) {
|
|
27648
28531
|
if (entry.startsWith("."))
|
|
27649
28532
|
continue;
|
|
27650
28533
|
walk6(full);
|
|
27651
28534
|
} else if (entry === "page.vsk") {
|
|
27652
|
-
const src2 =
|
|
28535
|
+
const src2 = readFileSync12(full, "utf-8");
|
|
27653
28536
|
const imgRegex = /<Image\s+src=["']([^"']+)["']/g;
|
|
27654
28537
|
let m;
|
|
27655
28538
|
while ((m = imgRegex.exec(src2)) !== null) {
|
|
@@ -27662,7 +28545,7 @@ function collectImageRefs(appDir) {
|
|
|
27662
28545
|
return refs;
|
|
27663
28546
|
}
|
|
27664
28547
|
async function optimizeImages(appDir, outDir2) {
|
|
27665
|
-
const imageOutDir =
|
|
28548
|
+
const imageOutDir = resolve13(outDir2, "static", "images");
|
|
27666
28549
|
mkdirSync3(imageOutDir, { recursive: true });
|
|
27667
28550
|
const refs = collectImageRefs(appDir);
|
|
27668
28551
|
if (refs.length === 0) {
|
|
@@ -27672,10 +28555,10 @@ async function optimizeImages(appDir, outDir2) {
|
|
|
27672
28555
|
const results = [];
|
|
27673
28556
|
for (const ref2 of refs) {
|
|
27674
28557
|
const possiblePaths = [
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
|
|
27678
|
-
|
|
28558
|
+
resolve13(appDir, ref2.src),
|
|
28559
|
+
resolve13(appDir, "..", "public", ref2.src.replace(/^\//, "")),
|
|
28560
|
+
resolve13(appDir, "..", "src", ref2.src.replace(/^\//, "")),
|
|
28561
|
+
resolve13(outDir2, "static", "public", ref2.src.replace(/^\//, ""))
|
|
27679
28562
|
];
|
|
27680
28563
|
let srcPath = null;
|
|
27681
28564
|
for (const p of possiblePaths) {
|
|
@@ -27688,12 +28571,12 @@ async function optimizeImages(appDir, outDir2) {
|
|
|
27688
28571
|
console.error(`vesk images: not found \u2014 ${ref2.src} (referenced by ${ref2.source})`);
|
|
27689
28572
|
continue;
|
|
27690
28573
|
}
|
|
27691
|
-
const ext =
|
|
28574
|
+
const ext = extname4(srcPath).toLowerCase();
|
|
27692
28575
|
if (!SUPPORTED.has(ext)) {
|
|
27693
28576
|
console.error(`vesk images: unsupported format \u2014 ${ref2.src} (${ext})`);
|
|
27694
28577
|
continue;
|
|
27695
28578
|
}
|
|
27696
|
-
const baseName = ref2.src.replace(/^\//, "").replace(
|
|
28579
|
+
const baseName = ref2.src.replace(/^\//, "").replace(extname4(ref2.src), "");
|
|
27697
28580
|
const files = await processImage(srcPath, imageOutDir, baseName);
|
|
27698
28581
|
results.push({ src: ref2.src, baseName, files, widths: OUTPUT_WIDTHS });
|
|
27699
28582
|
console.error(`vesk images: ${ref2.src} \u2192 ${files.length} variants`);
|
|
@@ -27726,8 +28609,8 @@ var seo_audit_exports = {};
|
|
|
27726
28609
|
__export(seo_audit_exports, {
|
|
27727
28610
|
runSeoAudit: () => runSeoAudit
|
|
27728
28611
|
});
|
|
27729
|
-
import { readFileSync as
|
|
27730
|
-
import { resolve as
|
|
28612
|
+
import { readFileSync as readFileSync13, existsSync as existsSync12, readdirSync as readdirSync5, statSync as statSync8 } from "node:fs";
|
|
28613
|
+
import { resolve as resolve14 } from "node:path";
|
|
27731
28614
|
function walkFiles(dir) {
|
|
27732
28615
|
const results = [];
|
|
27733
28616
|
let entries;
|
|
@@ -27737,8 +28620,8 @@ function walkFiles(dir) {
|
|
|
27737
28620
|
return results;
|
|
27738
28621
|
}
|
|
27739
28622
|
for (const entry of entries) {
|
|
27740
|
-
const full =
|
|
27741
|
-
const st =
|
|
28623
|
+
const full = resolve14(dir, entry);
|
|
28624
|
+
const st = statSync8(full);
|
|
27742
28625
|
if (st.isDirectory()) {
|
|
27743
28626
|
if (!entry.startsWith("."))
|
|
27744
28627
|
results.push(...walkFiles(full));
|
|
@@ -27752,10 +28635,10 @@ function collectCombinedSource(appDir) {
|
|
|
27752
28635
|
const pages = files.filter((f) => f.endsWith("/page.vsk") || f.endsWith("\\page.vsk"));
|
|
27753
28636
|
const combined = [];
|
|
27754
28637
|
for (const pagePath of pages) {
|
|
27755
|
-
const dir =
|
|
27756
|
-
const layoutPath =
|
|
27757
|
-
const pageSrc =
|
|
27758
|
-
const layoutSrc = existsSync12(layoutPath) ?
|
|
28638
|
+
const dir = resolve14(pagePath, "..");
|
|
28639
|
+
const layoutPath = resolve14(dir, "layout.vsk");
|
|
28640
|
+
const pageSrc = readFileSync13(pagePath, "utf-8");
|
|
28641
|
+
const layoutSrc = existsSync12(layoutPath) ? readFileSync13(layoutPath, "utf-8") : "";
|
|
27759
28642
|
const combinedSrc = layoutSrc ? layoutSrc + "\n" + pageSrc : pageSrc;
|
|
27760
28643
|
combined.push({
|
|
27761
28644
|
path: pagePath,
|
|
@@ -27931,7 +28814,7 @@ var init_platform = __esm({
|
|
|
27931
28814
|
|
|
27932
28815
|
// ../adapter/src/platform-handler.ts
|
|
27933
28816
|
import { existsSync as existsSync13 } from "node:fs";
|
|
27934
|
-
import { resolve as
|
|
28817
|
+
import { resolve as resolve15, dirname as dirname9 } from "node:path";
|
|
27935
28818
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
27936
28819
|
function routeName2(segments) {
|
|
27937
28820
|
const parts = segments.filter(Boolean).map((s) => {
|
|
@@ -27948,7 +28831,7 @@ function toId(s) {
|
|
|
27948
28831
|
return s.replace(/[^a-zA-Z0-9_]/g, "_").replace(/^_/, "");
|
|
27949
28832
|
}
|
|
27950
28833
|
function findCompilerSrc2() {
|
|
27951
|
-
const monorepo =
|
|
28834
|
+
const monorepo = resolve15(__dirname5, "..", "..", "..", "packages", "compiler", "dist");
|
|
27952
28835
|
if (existsSync13(monorepo)) return monorepo;
|
|
27953
28836
|
throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
|
|
27954
28837
|
}
|
|
@@ -27980,7 +28863,7 @@ function generatePlatformHandlerSource(input) {
|
|
|
27980
28863
|
` : "const __prerendered = new Set();\n";
|
|
27981
28864
|
const isrCache = "const __isrCache = new Map();";
|
|
27982
28865
|
const compilerSrc = findCompilerSrc2();
|
|
27983
|
-
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(
|
|
28866
|
+
const parseCookiesImport = hasMiddleware ? `import { parseCookies } from ${JSON.stringify(resolve15(compilerSrc, "server-cookies.js"))};` : "";
|
|
27984
28867
|
return `
|
|
27985
28868
|
${imports}
|
|
27986
28869
|
${parseCookiesImport}
|
|
@@ -28080,7 +28963,7 @@ async function bundlePlatformHandler(options2) {
|
|
|
28080
28963
|
plugins.push({
|
|
28081
28964
|
name: "empty-node-builtins",
|
|
28082
28965
|
setup(build5) {
|
|
28083
|
-
const builtins = /^(node:)?(fs|path|child_process|os|crypto|net|stream|buffer|events|util|url|querystring|http|https|zlib|tty|async_hooks)$/;
|
|
28966
|
+
const builtins = /^(node:)?(fs|module|path|child_process|os|crypto|net|stream|buffer|events|util|url|querystring|http|https|zlib|tty|async_hooks)$/;
|
|
28084
28967
|
build5.onResolve({ filter: builtins }, (args2) => {
|
|
28085
28968
|
return { path: args2.path, namespace: "empty-node" };
|
|
28086
28969
|
});
|
|
@@ -28108,14 +28991,19 @@ export const readFileSync = () => {};
|
|
|
28108
28991
|
export const writeFileSync = () => {};
|
|
28109
28992
|
export const existsSync = () => {};
|
|
28110
28993
|
export const statSync = () => {};
|
|
28994
|
+
export const realpathSync = () => '';
|
|
28111
28995
|
export const readdirSync = () => {};
|
|
28112
28996
|
export const mkdirSync = () => {};
|
|
28113
28997
|
export const unlinkSync = () => {};
|
|
28114
28998
|
export const rmSync = () => {};
|
|
28115
28999
|
export const copyFileSync = () => {};
|
|
28116
29000
|
export const accessSync = () => {};
|
|
29001
|
+
// node:module \u2014 createRequire is server-only dead code in the browser bundle;
|
|
29002
|
+
// the stub keeps esbuild from failing on the named import.
|
|
29003
|
+
export const createRequire = () => () => undefined;
|
|
28117
29004
|
export const join = (...a) => a.join('/');
|
|
28118
29005
|
export const resolve = (...a) => a.join('/');
|
|
29006
|
+
export const isAbsolute = () => false;
|
|
28119
29007
|
export const dirname = () => '';
|
|
28120
29008
|
export const basename = () => '';
|
|
28121
29009
|
export const extname = () => '';
|
|
@@ -28155,7 +29043,7 @@ var __dirname5;
|
|
|
28155
29043
|
var init_platform_handler = __esm({
|
|
28156
29044
|
"../adapter/src/platform-handler.ts"() {
|
|
28157
29045
|
"use strict";
|
|
28158
|
-
__dirname5 =
|
|
29046
|
+
__dirname5 = dirname9(fileURLToPath4(import.meta.url));
|
|
28159
29047
|
}
|
|
28160
29048
|
});
|
|
28161
29049
|
|
|
@@ -28164,13 +29052,13 @@ import {
|
|
|
28164
29052
|
mkdirSync as mkdirSync4,
|
|
28165
29053
|
copyFileSync as copyFileSync3,
|
|
28166
29054
|
readdirSync as readdirSync6,
|
|
28167
|
-
statSync as
|
|
29055
|
+
statSync as statSync9,
|
|
28168
29056
|
existsSync as existsSync14,
|
|
28169
29057
|
writeFileSync as writeFileSync6,
|
|
28170
29058
|
rmSync,
|
|
28171
|
-
readFileSync as
|
|
29059
|
+
readFileSync as readFileSync14
|
|
28172
29060
|
} from "node:fs";
|
|
28173
|
-
import { resolve as
|
|
29061
|
+
import { resolve as resolve16, join as join8, extname as extname5, dirname as dirname10 } from "node:path";
|
|
28174
29062
|
function ensureCleanDir(dir) {
|
|
28175
29063
|
rmSync(dir, { recursive: true, force: true });
|
|
28176
29064
|
mkdirSync4(dir, { recursive: true });
|
|
@@ -28179,44 +29067,44 @@ function copyDirContents(srcDir, destDir) {
|
|
|
28179
29067
|
if (!existsSync14(srcDir)) return;
|
|
28180
29068
|
mkdirSync4(destDir, { recursive: true });
|
|
28181
29069
|
for (const entry of readdirSync6(srcDir)) {
|
|
28182
|
-
const srcPath =
|
|
28183
|
-
const destPath =
|
|
28184
|
-
if (
|
|
29070
|
+
const srcPath = join8(srcDir, entry);
|
|
29071
|
+
const destPath = join8(destDir, entry);
|
|
29072
|
+
if (statSync9(srcPath).isDirectory()) {
|
|
28185
29073
|
copyDirContents(srcPath, destPath);
|
|
28186
29074
|
} else {
|
|
28187
|
-
mkdirSync4(
|
|
29075
|
+
mkdirSync4(dirname10(destPath), { recursive: true });
|
|
28188
29076
|
copyFileSync3(srcPath, destPath);
|
|
28189
29077
|
}
|
|
28190
29078
|
}
|
|
28191
29079
|
}
|
|
28192
29080
|
function writeFile(path, content) {
|
|
28193
|
-
mkdirSync4(
|
|
29081
|
+
mkdirSync4(dirname10(path), { recursive: true });
|
|
28194
29082
|
writeFileSync6(path, content, "utf-8");
|
|
28195
29083
|
}
|
|
28196
29084
|
function writePlatformStatic(buildStaticDir, platformStaticDir) {
|
|
28197
29085
|
mkdirSync4(platformStaticDir, { recursive: true });
|
|
28198
|
-
const publicDir =
|
|
29086
|
+
const publicDir = resolve16(buildStaticDir, "public");
|
|
28199
29087
|
if (existsSync14(publicDir)) {
|
|
28200
29088
|
copyDirContents(publicDir, platformStaticDir);
|
|
28201
29089
|
}
|
|
28202
|
-
const assetsDir =
|
|
29090
|
+
const assetsDir = resolve16(platformStaticDir, "_vesk", "static");
|
|
28203
29091
|
copyDirContents(buildStaticDir, assetsDir);
|
|
28204
|
-
const runtimeAlias =
|
|
28205
|
-
const clientPath =
|
|
29092
|
+
const runtimeAlias = resolve16(platformStaticDir, "_vesk", "runtime.js");
|
|
29093
|
+
const clientPath = resolve16(buildStaticDir, "client.js");
|
|
28206
29094
|
if (existsSync14(clientPath)) {
|
|
28207
|
-
mkdirSync4(
|
|
29095
|
+
mkdirSync4(dirname10(runtimeAlias), { recursive: true });
|
|
28208
29096
|
copyFileSync3(clientPath, runtimeAlias);
|
|
28209
29097
|
}
|
|
28210
29098
|
}
|
|
28211
29099
|
function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
|
|
28212
29100
|
for (const route of prerenderedRoutes) {
|
|
28213
29101
|
if (!existsSync14(route.html)) continue;
|
|
28214
|
-
const content =
|
|
29102
|
+
const content = readFileSync14(route.html);
|
|
28215
29103
|
const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
|
|
28216
|
-
const target =
|
|
29104
|
+
const target = resolve16(platformStaticDir, "_vesk", "static", "public", htmlRel);
|
|
28217
29105
|
writeFile(target, content);
|
|
28218
29106
|
if (route.path !== "/" && route.path.endsWith("/")) {
|
|
28219
|
-
const dirIndex =
|
|
29107
|
+
const dirIndex = resolve16(platformStaticDir, "_vesk", "static", "public", `${route.path.replace(/^\//, "")}index.html`);
|
|
28220
29108
|
writeFile(dirIndex, content);
|
|
28221
29109
|
}
|
|
28222
29110
|
}
|
|
@@ -28226,12 +29114,12 @@ function listStaticDir(dir) {
|
|
|
28226
29114
|
if (!existsSync14(dir)) return out;
|
|
28227
29115
|
function walk6(d, prefix) {
|
|
28228
29116
|
for (const entry of readdirSync6(d)) {
|
|
28229
|
-
const full =
|
|
29117
|
+
const full = join8(d, entry);
|
|
28230
29118
|
const rel = prefix ? `${prefix}/${entry}` : entry;
|
|
28231
|
-
if (
|
|
29119
|
+
if (statSync9(full).isDirectory()) {
|
|
28232
29120
|
walk6(full, rel);
|
|
28233
29121
|
} else {
|
|
28234
|
-
out.push({ rel, buffer:
|
|
29122
|
+
out.push({ rel, buffer: readFileSync14(full) });
|
|
28235
29123
|
}
|
|
28236
29124
|
}
|
|
28237
29125
|
}
|
|
@@ -28239,7 +29127,7 @@ function listStaticDir(dir) {
|
|
|
28239
29127
|
return out;
|
|
28240
29128
|
}
|
|
28241
29129
|
function mimeFor(path) {
|
|
28242
|
-
return MIME2[
|
|
29130
|
+
return MIME2[extname5(path).toLowerCase()] || "application/octet-stream";
|
|
28243
29131
|
}
|
|
28244
29132
|
var MIME2;
|
|
28245
29133
|
var init_platform_output = __esm({
|
|
@@ -28279,7 +29167,7 @@ __export(platform_deploy_exports, {
|
|
|
28279
29167
|
emitPlatformOutput: () => emitPlatformOutput
|
|
28280
29168
|
});
|
|
28281
29169
|
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync5, rmSync as rmSync2, symlinkSync } from "node:fs";
|
|
28282
|
-
import { resolve as
|
|
29170
|
+
import { resolve as resolve17, dirname as dirname11, relative as relative3 } from "node:path";
|
|
28283
29171
|
async function emitPlatformOutput(platform, ctx2) {
|
|
28284
29172
|
if (platform === "node") return null;
|
|
28285
29173
|
const prerenderedPaths = ctx2.prerenderedRoutes.map((r) => r.path);
|
|
@@ -28290,13 +29178,13 @@ async function emitPlatformOutput(platform, ctx2) {
|
|
|
28290
29178
|
hasMiddleware: ctx2.hasMiddleware
|
|
28291
29179
|
});
|
|
28292
29180
|
const shell = shellFor(platform);
|
|
28293
|
-
const projectRoot =
|
|
28294
|
-
const outRoot =
|
|
29181
|
+
const projectRoot = resolve17(ctx2.outDir, "..");
|
|
29182
|
+
const outRoot = resolve17(projectRoot, shell.root);
|
|
28295
29183
|
ensureCleanDir(outRoot);
|
|
28296
|
-
const staticDir2 = shell.staticSubdir === "" ? outRoot :
|
|
28297
|
-
writePlatformStatic(
|
|
29184
|
+
const staticDir2 = shell.staticSubdir === "" ? outRoot : resolve17(outRoot, shell.staticSubdir || "static");
|
|
29185
|
+
writePlatformStatic(resolve17(ctx2.outDir, "static"), staticDir2);
|
|
28298
29186
|
writePrerenderedStatic(ctx2.prerenderedRoutes, staticDir2);
|
|
28299
|
-
const entry =
|
|
29187
|
+
const entry = resolve17(ctx2.outDir, ".platform-entry.mjs");
|
|
28300
29188
|
let source = handler;
|
|
28301
29189
|
if (shell.imports) source = `${shell.imports}
|
|
28302
29190
|
${source}`;
|
|
@@ -28314,24 +29202,24 @@ ${shell.bootstrap}
|
|
|
28314
29202
|
writeFileSync7(entry, source, "utf-8");
|
|
28315
29203
|
let handlerRel;
|
|
28316
29204
|
if (shell.functionFile) {
|
|
28317
|
-
const funcDir =
|
|
29205
|
+
const funcDir = resolve17(outRoot, shell.functionFile.dir);
|
|
28318
29206
|
mkdirSync5(funcDir, { recursive: true });
|
|
28319
29207
|
if (shell.functionConfig) {
|
|
28320
|
-
writeFileSync7(
|
|
29208
|
+
writeFileSync7(resolve17(funcDir, ".vc-config.json"), JSON.stringify(shell.functionConfig, null, 2), "utf-8");
|
|
28321
29209
|
}
|
|
28322
29210
|
handlerRel = `${shell.functionFile.dir}/${shell.functionFile.file}`;
|
|
28323
|
-
await bundlePlatformHandler({ entry, outfile:
|
|
29211
|
+
await bundlePlatformHandler({ entry, outfile: resolve17(funcDir, shell.functionFile.file), nodeBuiltins: shell.nodeBuiltins });
|
|
28324
29212
|
} else {
|
|
28325
29213
|
handlerRel = shell.outfile || "index.js";
|
|
28326
|
-
await bundlePlatformHandler({ entry, outfile:
|
|
29214
|
+
await bundlePlatformHandler({ entry, outfile: resolve17(outRoot, handlerRel), nodeBuiltins: shell.nodeBuiltins });
|
|
28327
29215
|
}
|
|
28328
29216
|
for (const file of shell.extraFiles || []) {
|
|
28329
|
-
writeFileSync7(
|
|
29217
|
+
writeFileSync7(resolve17(outRoot, file.path), file.content, "utf-8");
|
|
28330
29218
|
}
|
|
28331
29219
|
if (platform === "vercel") {
|
|
28332
|
-
writeFileSync7(
|
|
29220
|
+
writeFileSync7(resolve17(outRoot, "config.json"), vercelConfigJson(prerenderedPaths), "utf-8");
|
|
28333
29221
|
}
|
|
28334
|
-
writeFileSync7(
|
|
29222
|
+
writeFileSync7(resolve17(outRoot, "manifest.json"), JSON.stringify({
|
|
28335
29223
|
platform,
|
|
28336
29224
|
runtime: shell.nodeBuiltins ? "node" : "edge",
|
|
28337
29225
|
static: shell.staticMode,
|
|
@@ -28341,11 +29229,11 @@ ${shell.bootstrap}
|
|
|
28341
29229
|
prerendered: prerenderedPaths
|
|
28342
29230
|
}, null, 2), "utf-8");
|
|
28343
29231
|
if (platform === "vercel") {
|
|
28344
|
-
const vercelDir =
|
|
29232
|
+
const vercelDir = resolve17(projectRoot, ".vercel");
|
|
28345
29233
|
mkdirSync5(vercelDir, { recursive: true });
|
|
28346
|
-
const linkPath =
|
|
29234
|
+
const linkPath = resolve17(vercelDir, "output");
|
|
28347
29235
|
rmSync2(linkPath, { recursive: true, force: true });
|
|
28348
|
-
symlinkSync(relative3(
|
|
29236
|
+
symlinkSync(relative3(dirname11(linkPath), outRoot), linkPath, "dir");
|
|
28349
29237
|
}
|
|
28350
29238
|
rmSync2(entry, { force: true });
|
|
28351
29239
|
return outRoot;
|
|
@@ -31466,6 +32354,11 @@ function emitJSXChildren(g2, source, children, opts) {
|
|
|
31466
32354
|
} else if (child.type === "JSXFragment") {
|
|
31467
32355
|
emitJSXFragment(g2, source, child, opts);
|
|
31468
32356
|
i++;
|
|
32357
|
+
} else if (child.type === "IfStatement" || child.type === "ForOfStatement" || child.type === "ForStatement" || child.type === "ForInStatement" || child.type === "WhileStatement" || child.type === "DoWhileStatement" || child.type === "SwitchStatement" || child.type === "TryStatement" || child.type === "VariableDeclaration" || child.type === "ExpressionStatement") {
|
|
32358
|
+
g2.addRaw("{(() => { ");
|
|
32359
|
+
emitBody(g2, source, [child], "", opts);
|
|
32360
|
+
g2.addRaw(" })()}");
|
|
32361
|
+
i++;
|
|
31469
32362
|
} else {
|
|
31470
32363
|
i++;
|
|
31471
32364
|
}
|
|
@@ -31978,9 +32871,9 @@ __export(typecheck_exports, {
|
|
|
31978
32871
|
formatTypecheckWarnings: () => formatTypecheckWarnings,
|
|
31979
32872
|
typecheckProject: () => typecheckProject
|
|
31980
32873
|
});
|
|
31981
|
-
import { readFileSync as
|
|
31982
|
-
import { join as
|
|
31983
|
-
import * as
|
|
32874
|
+
import { readFileSync as readFileSync21, readdirSync as readdirSync12, statSync as statSync15 } from "node:fs";
|
|
32875
|
+
import { join as join14, dirname as dirname15, normalize, relative as relative7, resolve as resolve25, sep as sep5 } from "node:path";
|
|
32876
|
+
import * as ts8 from "typescript";
|
|
31984
32877
|
function walkProjectFiles(projectRoot) {
|
|
31985
32878
|
const code = [];
|
|
31986
32879
|
const js = [];
|
|
@@ -31992,10 +32885,10 @@ function walkProjectFiles(projectRoot) {
|
|
|
31992
32885
|
return;
|
|
31993
32886
|
}
|
|
31994
32887
|
for (const e of entries) {
|
|
31995
|
-
const p =
|
|
32888
|
+
const p = join14(dir, e);
|
|
31996
32889
|
let st;
|
|
31997
32890
|
try {
|
|
31998
|
-
st =
|
|
32891
|
+
st = statSync15(p);
|
|
31999
32892
|
} catch {
|
|
32000
32893
|
continue;
|
|
32001
32894
|
}
|
|
@@ -32020,8 +32913,8 @@ function walkProjectFiles(projectRoot) {
|
|
|
32020
32913
|
return { code, js };
|
|
32021
32914
|
}
|
|
32022
32915
|
function isUnder(dir, file) {
|
|
32023
|
-
const base =
|
|
32024
|
-
const abs =
|
|
32916
|
+
const base = resolve25(dir);
|
|
32917
|
+
const abs = resolve25(file);
|
|
32025
32918
|
return abs === base || abs.startsWith(base + sep5);
|
|
32026
32919
|
}
|
|
32027
32920
|
function structureWarning(rel, message) {
|
|
@@ -32047,10 +32940,10 @@ function checkStructureFile(appDir, file) {
|
|
|
32047
32940
|
return null;
|
|
32048
32941
|
}
|
|
32049
32942
|
function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
32050
|
-
const ambientPath =
|
|
32051
|
-
const overridePath =
|
|
32943
|
+
const ambientPath = join14(appDir, "__vesk_ambient.d.ts");
|
|
32944
|
+
const overridePath = join14(appDir, "__vesk_runtime_override.d.ts");
|
|
32052
32945
|
const cached = /* @__PURE__ */ new Map();
|
|
32053
|
-
const scriptKindFor = (file) => file.endsWith(".vsk") ?
|
|
32946
|
+
const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
|
|
32054
32947
|
const host2 = {
|
|
32055
32948
|
getSourceFile(file, langVersion, onError, shouldCreateNewSourceFile) {
|
|
32056
32949
|
if (!shouldCreateNewSourceFile && cached.has(file))
|
|
@@ -32062,21 +32955,21 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
32062
32955
|
content = RUNTIME_OVERRIDE;
|
|
32063
32956
|
} else if (file.endsWith(".vsk.d.ts")) {
|
|
32064
32957
|
const vskPath = file.slice(0, -".d.ts".length);
|
|
32065
|
-
const src2 = vskFiles.get(vskPath) ?? (
|
|
32958
|
+
const src2 = vskFiles.get(vskPath) ?? (ts8.sys.fileExists(vskPath) ? ts8.sys.readFile(vskPath) : void 0);
|
|
32066
32959
|
content = src2 !== void 0 ? generateVskDts(src2) : void 0;
|
|
32067
32960
|
} else if (file.endsWith(".css.d.ts")) {
|
|
32068
32961
|
content = "";
|
|
32069
32962
|
} else if (vskFiles.has(file)) {
|
|
32070
32963
|
content = vskToTsx(vskFiles.get(file));
|
|
32071
|
-
} else if (
|
|
32072
|
-
content =
|
|
32964
|
+
} else if (ts8.sys.fileExists(file)) {
|
|
32965
|
+
content = ts8.sys.readFile(file);
|
|
32073
32966
|
}
|
|
32074
32967
|
if (content === void 0) {
|
|
32075
32968
|
if (onError)
|
|
32076
32969
|
onError(`File not found: ${file}`);
|
|
32077
32970
|
return void 0;
|
|
32078
32971
|
}
|
|
32079
|
-
const sf =
|
|
32972
|
+
const sf = ts8.createSourceFile(file, content, langVersion, true, scriptKindFor(file));
|
|
32080
32973
|
cached.set(file, sf);
|
|
32081
32974
|
return sf;
|
|
32082
32975
|
},
|
|
@@ -32087,13 +32980,13 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
32087
32980
|
return true;
|
|
32088
32981
|
if (file.endsWith(".vsk.d.ts")) {
|
|
32089
32982
|
const vskPath = file.slice(0, -".d.ts".length);
|
|
32090
|
-
return vskFiles.has(vskPath) ||
|
|
32983
|
+
return vskFiles.has(vskPath) || ts8.sys.fileExists(vskPath);
|
|
32091
32984
|
}
|
|
32092
32985
|
if (file.endsWith(".css.d.ts"))
|
|
32093
32986
|
return true;
|
|
32094
32987
|
if (vskFiles.has(file))
|
|
32095
32988
|
return true;
|
|
32096
|
-
return
|
|
32989
|
+
return ts8.sys.fileExists(file);
|
|
32097
32990
|
},
|
|
32098
32991
|
readFile(file) {
|
|
32099
32992
|
if (file === ambientPath)
|
|
@@ -32102,55 +32995,55 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
32102
32995
|
return RUNTIME_OVERRIDE;
|
|
32103
32996
|
if (file.endsWith(".vsk.d.ts")) {
|
|
32104
32997
|
const vskPath = file.slice(0, -".d.ts".length);
|
|
32105
|
-
const src2 = vskFiles.get(vskPath) ?? (
|
|
32998
|
+
const src2 = vskFiles.get(vskPath) ?? (ts8.sys.fileExists(vskPath) ? ts8.sys.readFile(vskPath) : void 0);
|
|
32106
32999
|
return src2 !== void 0 ? generateVskDts(src2) : void 0;
|
|
32107
33000
|
}
|
|
32108
33001
|
if (file.endsWith(".css.d.ts"))
|
|
32109
33002
|
return "";
|
|
32110
33003
|
if (vskFiles.has(file))
|
|
32111
33004
|
return vskToTsx(vskFiles.get(file));
|
|
32112
|
-
return
|
|
33005
|
+
return ts8.sys.readFile(file);
|
|
32113
33006
|
},
|
|
32114
33007
|
writeFile: () => {
|
|
32115
33008
|
},
|
|
32116
33009
|
getCurrentDirectory: () => projectRoot,
|
|
32117
|
-
getDefaultLibFileName: (o) =>
|
|
32118
|
-
directoryExists: (dir) =>
|
|
33010
|
+
getDefaultLibFileName: (o) => ts8.getDefaultLibFilePath(o),
|
|
33011
|
+
directoryExists: (dir) => ts8.sys.directoryExists(dir),
|
|
32119
33012
|
getDirectories: (dir) => {
|
|
32120
33013
|
try {
|
|
32121
|
-
return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) =>
|
|
33014
|
+
return readdirSync12(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join14(dir, d.name));
|
|
32122
33015
|
} catch {
|
|
32123
33016
|
return [];
|
|
32124
33017
|
}
|
|
32125
33018
|
},
|
|
32126
33019
|
getCanonicalFileName: (f) => normalize(f),
|
|
32127
|
-
useCaseSensitiveFileNames: () =>
|
|
33020
|
+
useCaseSensitiveFileNames: () => ts8.sys.useCaseSensitiveFileNames,
|
|
32128
33021
|
getNewLine: () => "\n",
|
|
32129
33022
|
resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options2) {
|
|
32130
33023
|
return moduleLiterals.map(({ text }) => {
|
|
32131
33024
|
if (text.endsWith(".vsk")) {
|
|
32132
|
-
const abs = normalize(
|
|
33025
|
+
const abs = normalize(join14(dirname15(containingFile), text));
|
|
32133
33026
|
return {
|
|
32134
33027
|
resolvedModule: {
|
|
32135
33028
|
resolvedFileName: abs + ".d.ts",
|
|
32136
|
-
extension:
|
|
33029
|
+
extension: ts8.Extension.Dts,
|
|
32137
33030
|
isExternalLibraryImport: false
|
|
32138
33031
|
},
|
|
32139
33032
|
failedLookupLocations: []
|
|
32140
33033
|
};
|
|
32141
33034
|
}
|
|
32142
33035
|
if (text.endsWith(".css")) {
|
|
32143
|
-
const abs = normalize(
|
|
33036
|
+
const abs = normalize(join14(dirname15(containingFile), text));
|
|
32144
33037
|
return {
|
|
32145
33038
|
resolvedModule: {
|
|
32146
33039
|
resolvedFileName: abs + ".d.ts",
|
|
32147
|
-
extension:
|
|
33040
|
+
extension: ts8.Extension.Dts,
|
|
32148
33041
|
isExternalLibraryImport: false
|
|
32149
33042
|
},
|
|
32150
33043
|
failedLookupLocations: []
|
|
32151
33044
|
};
|
|
32152
33045
|
}
|
|
32153
|
-
const res =
|
|
33046
|
+
const res = ts8.resolveModuleName(text, containingFile, options2, host2);
|
|
32154
33047
|
return { resolvedModule: res.resolvedModule, failedLookupLocations: [] };
|
|
32155
33048
|
});
|
|
32156
33049
|
}
|
|
@@ -32158,7 +33051,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
32158
33051
|
return host2;
|
|
32159
33052
|
}
|
|
32160
33053
|
function typecheckProject(projectRoot, opts = {}) {
|
|
32161
|
-
const appDir = opts.appDir ??
|
|
33054
|
+
const appDir = opts.appDir ?? join14(projectRoot, "app");
|
|
32162
33055
|
const vskFiles = /* @__PURE__ */ new Map();
|
|
32163
33056
|
const parseErrors = [];
|
|
32164
33057
|
const warnings = [];
|
|
@@ -32180,7 +33073,7 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
32180
33073
|
}
|
|
32181
33074
|
}
|
|
32182
33075
|
if (f.endsWith(".vsk")) {
|
|
32183
|
-
const src2 =
|
|
33076
|
+
const src2 = readFileSync21(f, "utf-8");
|
|
32184
33077
|
try {
|
|
32185
33078
|
parse4(src2);
|
|
32186
33079
|
} catch (e) {
|
|
@@ -32197,16 +33090,16 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
32197
33090
|
}
|
|
32198
33091
|
rootNames.push(f);
|
|
32199
33092
|
}
|
|
32200
|
-
const ambientPath =
|
|
32201
|
-
const overridePath =
|
|
33093
|
+
const ambientPath = join14(appDir, "__vesk_ambient.d.ts");
|
|
33094
|
+
const overridePath = join14(appDir, "__vesk_runtime_override.d.ts");
|
|
32202
33095
|
rootNames.push(ambientPath);
|
|
32203
33096
|
rootNames.push(overridePath);
|
|
32204
33097
|
const options2 = {
|
|
32205
|
-
target:
|
|
32206
|
-
module:
|
|
32207
|
-
moduleResolution:
|
|
33098
|
+
target: ts8.ScriptTarget.ES2022,
|
|
33099
|
+
module: ts8.ModuleKind.ESNext,
|
|
33100
|
+
moduleResolution: ts8.ModuleResolutionKind.Bundler,
|
|
32208
33101
|
strict: opts.strict !== false,
|
|
32209
|
-
jsx:
|
|
33102
|
+
jsx: ts8.JsxEmit.Preserve,
|
|
32210
33103
|
noEmit: true,
|
|
32211
33104
|
skipLibCheck: true,
|
|
32212
33105
|
esModuleInterop: true,
|
|
@@ -32219,13 +33112,13 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
32219
33112
|
allowJs: false
|
|
32220
33113
|
};
|
|
32221
33114
|
const host2 = createTypecheckHost(projectRoot, appDir, vskFiles);
|
|
32222
|
-
const program =
|
|
33115
|
+
const program = ts8.createProgram({ rootNames, options: options2, host: host2 });
|
|
32223
33116
|
const rootSet = new Set(rootNames.map(normalize));
|
|
32224
33117
|
const vskSet = /* @__PURE__ */ new Set();
|
|
32225
33118
|
for (const p of vskFiles.keys())
|
|
32226
33119
|
vskSet.add(normalize(p));
|
|
32227
33120
|
const errors = [...parseErrors];
|
|
32228
|
-
for (const diag of
|
|
33121
|
+
for (const diag of ts8.getPreEmitDiagnostics(program)) {
|
|
32229
33122
|
const file = diag.file;
|
|
32230
33123
|
if (!file)
|
|
32231
33124
|
continue;
|
|
@@ -32242,7 +33135,7 @@ function typecheckProject(projectRoot, opts = {}) {
|
|
|
32242
33135
|
line: pos.line + 1,
|
|
32243
33136
|
column: pos.character + 1,
|
|
32244
33137
|
code,
|
|
32245
|
-
message:
|
|
33138
|
+
message: ts8.flattenDiagnosticMessageText(diag.messageText, "\n")
|
|
32246
33139
|
});
|
|
32247
33140
|
}
|
|
32248
33141
|
return { errors, warnings };
|
|
@@ -32675,6 +33568,11 @@ declare function useFetch<T = unknown>(
|
|
|
32675
33568
|
urlOrFn: string | (() => Promise<T>),
|
|
32676
33569
|
options?: VeskUseFetchOptions<T>,
|
|
32677
33570
|
): VeskResource<T>;
|
|
33571
|
+
declare namespace useFetch {
|
|
33572
|
+
function text<T = string>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;
|
|
33573
|
+
function json<T = unknown>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;
|
|
33574
|
+
function arrayBuffer<T = ArrayBuffer>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;
|
|
33575
|
+
}
|
|
32678
33576
|
declare function useRouter(): unknown;
|
|
32679
33577
|
declare function useParams(): Record<string, string>;
|
|
32680
33578
|
declare function usePathname(): string;
|
|
@@ -32757,8 +33655,8 @@ declare module '@vesk/runtime' {
|
|
|
32757
33655
|
});
|
|
32758
33656
|
|
|
32759
33657
|
// src/index.ts
|
|
32760
|
-
import { readFileSync as
|
|
32761
|
-
import { resolve as
|
|
33658
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync11, mkdirSync as mkdirSync9, existsSync as existsSync23 } from "fs";
|
|
33659
|
+
import { resolve as resolve26, join as join15, dirname as dirname16 } from "path";
|
|
32762
33660
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
32763
33661
|
|
|
32764
33662
|
// ../compiler/dist/config.js
|
|
@@ -33257,41 +34155,41 @@ function setRuntimeModule2(mod) {
|
|
|
33257
34155
|
|
|
33258
34156
|
// ../adapter/dist/index.js
|
|
33259
34157
|
init_scan();
|
|
33260
|
-
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync8, existsSync as existsSync15, readFileSync as
|
|
33261
|
-
import { resolve as
|
|
34158
|
+
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync8, existsSync as existsSync15, readFileSync as readFileSync15 } from "node:fs";
|
|
34159
|
+
import { resolve as resolve18, dirname as dirname12, relative as relative4 } from "node:path";
|
|
33262
34160
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
33263
34161
|
|
|
33264
34162
|
// ../adapter/src/runtime-bundle.ts
|
|
33265
34163
|
init_esbuild_fallback();
|
|
33266
34164
|
import { writeFileSync, existsSync as existsSync2, unlinkSync } from "node:fs";
|
|
33267
|
-
import { resolve as
|
|
34165
|
+
import { resolve as resolve3, dirname as dirname3, join as join2 } from "node:path";
|
|
33268
34166
|
import { fileURLToPath } from "node:url";
|
|
33269
34167
|
var buildId = 0;
|
|
33270
|
-
var __dirname2 =
|
|
34168
|
+
var __dirname2 = dirname3(fileURLToPath(import.meta.url));
|
|
33271
34169
|
function findCompilerSrc(appDir) {
|
|
33272
|
-
const monorepoRoot =
|
|
34170
|
+
const monorepoRoot = resolve3(__dirname2, "..", "..", "..");
|
|
33273
34171
|
const candidates = [
|
|
33274
|
-
|
|
33275
|
-
|
|
33276
|
-
|
|
34172
|
+
resolve3(monorepoRoot, "packages", "compiler", "dist"),
|
|
34173
|
+
resolve3(appDir, "..", "node_modules", "@vesk/compiler"),
|
|
34174
|
+
resolve3(appDir, "node_modules", "@vesk/compiler")
|
|
33277
34175
|
];
|
|
33278
34176
|
for (const base of candidates) {
|
|
33279
|
-
for (const dir of [base,
|
|
33280
|
-
if (existsSync2(
|
|
34177
|
+
for (const dir of [base, join2(base, "dist")]) {
|
|
34178
|
+
if (existsSync2(join2(dir, "server-codegen.js"))) return dir;
|
|
33281
34179
|
}
|
|
33282
34180
|
}
|
|
33283
34181
|
throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
|
|
33284
34182
|
}
|
|
33285
34183
|
function findRuntimeSrc(appDir) {
|
|
33286
|
-
const monorepoRoot =
|
|
34184
|
+
const monorepoRoot = resolve3(__dirname2, "..", "..", "..");
|
|
33287
34185
|
const candidates = [
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
34186
|
+
resolve3(monorepoRoot, "packages", "runtime", "dist"),
|
|
34187
|
+
resolve3(appDir, "..", "node_modules", "@vesk/runtime"),
|
|
34188
|
+
resolve3(appDir, "node_modules", "@vesk/runtime")
|
|
33291
34189
|
];
|
|
33292
34190
|
for (const base of candidates) {
|
|
33293
|
-
for (const dir of [base,
|
|
33294
|
-
if (existsSync2(
|
|
34191
|
+
for (const dir of [base, join2(base, "dist")]) {
|
|
34192
|
+
if (existsSync2(join2(dir, "index-server.js"))) return dir;
|
|
33295
34193
|
}
|
|
33296
34194
|
}
|
|
33297
34195
|
throw new Error('@vesk/runtime/dist not found \u2014 run "npm run build" first');
|
|
@@ -33299,11 +34197,11 @@ function findRuntimeSrc(appDir) {
|
|
|
33299
34197
|
async function bundleRuntime(appDir, outDir2) {
|
|
33300
34198
|
const compilerRoot = findCompilerSrc(appDir);
|
|
33301
34199
|
const runtimeRoot = findRuntimeSrc(appDir);
|
|
33302
|
-
const entryFile =
|
|
34200
|
+
const entryFile = resolve3(outDir2, "server", `.runtime-entry-${buildId++}.mjs`);
|
|
33303
34201
|
const entryContent = [
|
|
33304
|
-
`import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, assertSameOrigin } from ${JSON.stringify(
|
|
33305
|
-
`import { parseCookies } from ${JSON.stringify(
|
|
33306
|
-
`import * as __veskRuntime from ${JSON.stringify(
|
|
34202
|
+
`import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, assertSameOrigin } from ${JSON.stringify(resolve3(compilerRoot, "server-codegen.js"))};`,
|
|
34203
|
+
`import { parseCookies } from ${JSON.stringify(resolve3(compilerRoot, "server-cookies.js"))};`,
|
|
34204
|
+
`import * as __veskRuntime from ${JSON.stringify(resolve3(runtimeRoot, "index-server.js"))};`,
|
|
33307
34205
|
"",
|
|
33308
34206
|
"// Inject runtime module so server-codegen can find components like NavLink, Link, etc.",
|
|
33309
34207
|
"setRuntimeModule(__veskRuntime);",
|
|
@@ -33384,8 +34282,8 @@ async function bundleRuntime(appDir, outDir2) {
|
|
|
33384
34282
|
platform: "neutral",
|
|
33385
34283
|
format: "esm",
|
|
33386
34284
|
minify: true,
|
|
33387
|
-
outfile:
|
|
33388
|
-
external: ["fs", "node:fs", "path", "node:path", "node:async_hooks"],
|
|
34285
|
+
outfile: resolve3(outDir2, "server", "runtime.js"),
|
|
34286
|
+
external: ["fs", "node:fs", "path", "node:path", "module", "node:module", "node:async_hooks"],
|
|
33389
34287
|
target: ["es2022"],
|
|
33390
34288
|
treeShaking: true
|
|
33391
34289
|
});
|
|
@@ -33395,7 +34293,7 @@ async function bundleRuntime(appDir, outDir2) {
|
|
|
33395
34293
|
if (result2.warnings.length > 0) {
|
|
33396
34294
|
for (const w of result2.warnings) console.error("vesk build warning:", w.text);
|
|
33397
34295
|
}
|
|
33398
|
-
return
|
|
34296
|
+
return resolve3(outDir2, "server", "runtime.js");
|
|
33399
34297
|
} finally {
|
|
33400
34298
|
try {
|
|
33401
34299
|
unlinkSync(entryFile);
|
|
@@ -33405,8 +34303,8 @@ async function bundleRuntime(appDir, outDir2) {
|
|
|
33405
34303
|
}
|
|
33406
34304
|
|
|
33407
34305
|
// ../adapter/src/ssr-function.ts
|
|
33408
|
-
import { readFileSync as
|
|
33409
|
-
import { resolve as
|
|
34306
|
+
import { readFileSync as readFileSync4, existsSync as existsSync5 } from "node:fs";
|
|
34307
|
+
import { resolve as resolve6, relative, join as join4 } from "node:path";
|
|
33410
34308
|
|
|
33411
34309
|
// ../compiler/src/server-codegen.ts
|
|
33412
34310
|
init_server_utils();
|
|
@@ -33421,8 +34319,8 @@ function escapeSource(src2) {
|
|
|
33421
34319
|
function resolveErrorFile(sourceDir, appDir) {
|
|
33422
34320
|
const rel = relative(appDir, sourceDir).split("/").filter(Boolean);
|
|
33423
34321
|
for (let depth = rel.length; depth >= 0; depth--) {
|
|
33424
|
-
const dir = depth === 0 ? appDir :
|
|
33425
|
-
const p =
|
|
34322
|
+
const dir = depth === 0 ? appDir : join4(appDir, ...rel.slice(0, depth));
|
|
34323
|
+
const p = join4(dir, "error.vsk");
|
|
33426
34324
|
if (existsSync5(p)) return p;
|
|
33427
34325
|
}
|
|
33428
34326
|
return null;
|
|
@@ -33474,27 +34372,27 @@ function buildParamExtraction(node, urlParts) {
|
|
|
33474
34372
|
function generateSsrFunction(routeNode, appDir, outDir2, componentMap, options2) {
|
|
33475
34373
|
const ancestorLayouts = options2?.ancestorLayouts || [];
|
|
33476
34374
|
const middlewareCode = options2?.middlewareCode || null;
|
|
33477
|
-
const pagePath =
|
|
33478
|
-
const layoutPath =
|
|
34375
|
+
const pagePath = resolve6(appDir, routeNode.sourceDir, "page.vsk");
|
|
34376
|
+
const layoutPath = resolve6(appDir, routeNode.sourceDir, "layout.vsk");
|
|
33479
34377
|
const parts = routeNode.fullPath.split("/").filter(Boolean);
|
|
33480
34378
|
const name = routeName(parts);
|
|
33481
|
-
const funcDir =
|
|
33482
|
-
const funcPath =
|
|
33483
|
-
const tailwindPath =
|
|
33484
|
-
const globalCssPath =
|
|
33485
|
-
const altCssPath =
|
|
34379
|
+
const funcDir = resolve6(outDir2, "server", "functions");
|
|
34380
|
+
const funcPath = resolve6(funcDir, `${name}.js`);
|
|
34381
|
+
const tailwindPath = resolve6(outDir2, "static", "_tailwind.css");
|
|
34382
|
+
const globalCssPath = resolve6(appDir, "..", "src", "global.css");
|
|
34383
|
+
const altCssPath = resolve6(appDir, "..", "src", "app.css");
|
|
33486
34384
|
const hasGlobalCss = existsSync5(globalCssPath) || existsSync5(altCssPath);
|
|
33487
|
-
const hasTailwind = existsSync5(tailwindPath) &&
|
|
34385
|
+
const hasTailwind = existsSync5(tailwindPath) && readFileSync4(tailwindPath, "utf-8").trim().length > 0;
|
|
33488
34386
|
const cssUrls = [];
|
|
33489
34387
|
if (hasTailwind) cssUrls.push("/_vesk/static/_tailwind.css");
|
|
33490
34388
|
if (hasGlobalCss) cssUrls.push("/_vesk/static/global.css");
|
|
33491
34389
|
const cssOption = cssUrls.length > 0 ? `, cssUrls: ${JSON.stringify(cssUrls)}` : "";
|
|
33492
34390
|
const hasLayout = !!routeNode.layout;
|
|
33493
34391
|
const hasAncestorLayout = ancestorLayouts.length > 0;
|
|
33494
|
-
const pageSrc =
|
|
34392
|
+
const pageSrc = readFileSync4(pagePath, "utf-8");
|
|
33495
34393
|
const pageComp = extractCompName(pageSrc) || "Page";
|
|
33496
34394
|
const errorPath = resolveErrorFile(routeNode.sourceDir, appDir);
|
|
33497
|
-
const errorSrc = errorPath ?
|
|
34395
|
+
const errorSrc = errorPath ? readFileSync4(errorPath, "utf-8") : null;
|
|
33498
34396
|
const errorComp = errorPath ? extractCompName(errorSrc) || "Error" : null;
|
|
33499
34397
|
const errorVars = errorPath ? `const _errorSrc = \`${escapeSource(errorSrc)}\`;
|
|
33500
34398
|
const _errorComp = ${JSON.stringify(errorComp)};
|
|
@@ -33503,7 +34401,7 @@ const _errorCompiled = (() => { try { setVskHydrate(true); return compileFile(_e
|
|
|
33503
34401
|
` : "const _errorSrc = null;\nconst _errorComp = null;\nconst _errorPath = null;\nconst _errorCompiled = null;\n";
|
|
33504
34402
|
let src2 = "";
|
|
33505
34403
|
if (hasLayout) {
|
|
33506
|
-
const layoutSrc =
|
|
34404
|
+
const layoutSrc = readFileSync4(layoutPath, "utf-8");
|
|
33507
34405
|
const layoutComp = extractCompName(layoutSrc) || "Layout";
|
|
33508
34406
|
src2 = `const _layoutSrc = \`${escapeSource(layoutSrc)}\`;
|
|
33509
34407
|
const _pageSrc = \`${escapeSource(pageSrc)}\`;
|
|
@@ -33521,8 +34419,8 @@ const _pagePath = ${JSON.stringify(pagePath)};
|
|
|
33521
34419
|
src2 += errorVars;
|
|
33522
34420
|
} else if (hasAncestorLayout) {
|
|
33523
34421
|
const outerLayout = ancestorLayouts[0];
|
|
33524
|
-
const outerLayoutPath =
|
|
33525
|
-
const outerLayoutSrc =
|
|
34422
|
+
const outerLayoutPath = resolve6(appDir, outerLayout.sourceDir, "layout.vsk");
|
|
34423
|
+
const outerLayoutSrc = readFileSync4(outerLayoutPath, "utf-8");
|
|
33526
34424
|
const outerLayoutComp = extractCompName(outerLayoutSrc) || "Layout";
|
|
33527
34425
|
src2 = `const _pageSrc = \`${escapeSource(pageSrc)}\`;
|
|
33528
34426
|
`;
|
|
@@ -33563,7 +34461,7 @@ const _comp = ${JSON.stringify(pageComp)};
|
|
|
33563
34461
|
const compRegEntries = [];
|
|
33564
34462
|
const compMap = componentMap || /* @__PURE__ */ new Map();
|
|
33565
34463
|
for (const [compName, compPath] of compMap) {
|
|
33566
|
-
const compSrc =
|
|
34464
|
+
const compSrc = readFileSync4(compPath, "utf-8");
|
|
33567
34465
|
const escapedSrc = escapeSource(compSrc);
|
|
33568
34466
|
compRegEntries.push(` registry.set(${JSON.stringify(compName)}, async (props, __registry, __vesk) => {
|
|
33569
34467
|
const _src = \`${escapedSrc}\`;
|
|
@@ -33859,8 +34757,8 @@ init_actions();
|
|
|
33859
34757
|
|
|
33860
34758
|
// ../adapter/src/api-function.ts
|
|
33861
34759
|
init_strip_ts();
|
|
33862
|
-
import { readFileSync as
|
|
33863
|
-
import { resolve as
|
|
34760
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
34761
|
+
import { resolve as resolve7 } from "node:path";
|
|
33864
34762
|
function apiRouteName(fullPath) {
|
|
33865
34763
|
const parts = fullPath.split("/").filter(Boolean);
|
|
33866
34764
|
return parts.map((s) => s.startsWith(":") ? s.slice(1) || "param" : s).join("_") || "index";
|
|
@@ -33868,10 +34766,10 @@ function apiRouteName(fullPath) {
|
|
|
33868
34766
|
function generateApiFunction(apiNode, _apiDir, outDir2, options2) {
|
|
33869
34767
|
const middlewareCode = options2?.middlewareCode || null;
|
|
33870
34768
|
const name = apiRouteName(apiNode.fullPath);
|
|
33871
|
-
const funcPath =
|
|
34769
|
+
const funcPath = resolve7(outDir2, "server", "api", `${name}.js`);
|
|
33872
34770
|
const routeFilePath = apiNode.filePath;
|
|
33873
34771
|
if (!routeFilePath) throw new Error(`api route ${apiNode.fullPath} has no filePath`);
|
|
33874
|
-
let routeSrc =
|
|
34772
|
+
let routeSrc = readFileSync5(routeFilePath, "utf-8");
|
|
33875
34773
|
routeSrc = routeSrc.replace(/from\s+['"]@vesk\/runtime['"]\s*;?/g, "from '../runtime.js';").replace(/from\s+['"]@vesk\/runtime\/(\w+)['"]\s*;?/g, () => {
|
|
33876
34774
|
return "from '../runtime.js';";
|
|
33877
34775
|
});
|
|
@@ -34039,10 +34937,10 @@ function generateApiFunction(apiNode, _apiDir, outDir2, options2) {
|
|
|
34039
34937
|
}
|
|
34040
34938
|
|
|
34041
34939
|
// ../adapter/src/middleware.ts
|
|
34042
|
-
import { readFileSync as
|
|
34940
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
34043
34941
|
|
|
34044
34942
|
// ../compiler/src/router.ts
|
|
34045
|
-
import { readdirSync, statSync, existsSync as existsSync6, readFileSync as
|
|
34943
|
+
import { readdirSync, statSync as statSync2, existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
|
|
34046
34944
|
init_parser();
|
|
34047
34945
|
init_tokens();
|
|
34048
34946
|
init_scan();
|
|
@@ -34125,7 +35023,7 @@ function fallbackExtractMiddleware(src2) {
|
|
|
34125
35023
|
function extractMiddleware(sourcePath2) {
|
|
34126
35024
|
try {
|
|
34127
35025
|
if (!existsSync6(sourcePath2)) return null;
|
|
34128
|
-
const src2 =
|
|
35026
|
+
const src2 = readFileSync6(sourcePath2, "utf-8");
|
|
34129
35027
|
const parts = extractMiddlewareParts(src2);
|
|
34130
35028
|
if (!parts) return null;
|
|
34131
35029
|
return `async function middleware(${parts.params}) {
|
|
@@ -34147,7 +35045,7 @@ function compileMiddleware(mwChain, _appDir) {
|
|
|
34147
35045
|
const parts = [];
|
|
34148
35046
|
for (let i = 0; i < mwChain.length; i++) {
|
|
34149
35047
|
const { sourcePath: sourcePath2 } = mwChain[i];
|
|
34150
|
-
const src2 =
|
|
35048
|
+
const src2 = readFileSync7(sourcePath2, "utf-8");
|
|
34151
35049
|
const extracted = extractMiddlewareBody(src2);
|
|
34152
35050
|
if (!extracted) continue;
|
|
34153
35051
|
parts.push(`async function mw_${i}(${extracted.params}) {
|
|
@@ -34239,15 +35137,15 @@ ${extracted.body}
|
|
|
34239
35137
|
init_esbuild_fallback();
|
|
34240
35138
|
init_strip_ts();
|
|
34241
35139
|
init_client_codegen();
|
|
34242
|
-
import { readFileSync as
|
|
34243
|
-
import { resolve as
|
|
35140
|
+
import { readFileSync as readFileSync8, existsSync as existsSync7, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2, statSync as statSync3 } from "node:fs";
|
|
35141
|
+
import { resolve as resolve8, join as join5, dirname as dirname6, relative as relative2, sep } from "node:path";
|
|
34244
35142
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34245
35143
|
init_vsk_imports();
|
|
34246
35144
|
init_md_inline();
|
|
34247
|
-
var __dirname3 =
|
|
35145
|
+
var __dirname3 = dirname6(fileURLToPath2(import.meta.url));
|
|
34248
35146
|
function fileUnchanged(filePath, cached) {
|
|
34249
35147
|
try {
|
|
34250
|
-
const st =
|
|
35148
|
+
const st = statSync3(filePath);
|
|
34251
35149
|
return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
|
|
34252
35150
|
} catch {
|
|
34253
35151
|
return false;
|
|
@@ -34261,15 +35159,15 @@ function buildRouterOpts(options2) {
|
|
|
34261
35159
|
return "";
|
|
34262
35160
|
}
|
|
34263
35161
|
function findRuntimeSrc2(appDir) {
|
|
34264
|
-
const monorepoRoot =
|
|
35162
|
+
const monorepoRoot = resolve8(__dirname3, "..", "..", "..");
|
|
34265
35163
|
const candidates = [
|
|
34266
|
-
|
|
34267
|
-
|
|
34268
|
-
|
|
35164
|
+
resolve8(monorepoRoot, "packages", "runtime", "dist"),
|
|
35165
|
+
resolve8(appDir, "..", "node_modules", "@vesk/runtime"),
|
|
35166
|
+
resolve8(appDir, "node_modules", "@vesk/runtime")
|
|
34269
35167
|
];
|
|
34270
35168
|
for (const base of candidates) {
|
|
34271
|
-
for (const dir of [base,
|
|
34272
|
-
if (existsSync7(
|
|
35169
|
+
for (const dir of [base, join5(base, "dist")]) {
|
|
35170
|
+
if (existsSync7(join5(dir, "index-client.js"))) return dir;
|
|
34273
35171
|
}
|
|
34274
35172
|
}
|
|
34275
35173
|
throw new Error('@vesk/runtime/dist not found \u2014 run "npm run build" first');
|
|
@@ -34307,11 +35205,11 @@ async function generateClientBundle(routeTree, appDir, componentMap, options2) {
|
|
|
34307
35205
|
return code.replace(/^import\s*\{[^}]*\}\s*from\s*['"][^'"]*\.vsk['"];?\s*\n?/gm, "");
|
|
34308
35206
|
}
|
|
34309
35207
|
function resolveVskImports(filePath, compile) {
|
|
34310
|
-
const src2 =
|
|
35208
|
+
const src2 = readFileSync8(filePath, "utf-8");
|
|
34311
35209
|
const resolved = [];
|
|
34312
35210
|
for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
|
|
34313
35211
|
try {
|
|
34314
|
-
|
|
35212
|
+
readFileSync8(importPath);
|
|
34315
35213
|
} catch {
|
|
34316
35214
|
continue;
|
|
34317
35215
|
}
|
|
@@ -34351,9 +35249,9 @@ async function generateClientBundle(routeTree, appDir, componentMap, options2) {
|
|
|
34351
35249
|
return;
|
|
34352
35250
|
}
|
|
34353
35251
|
compiledFiles++;
|
|
34354
|
-
let src2 =
|
|
35252
|
+
let src2 = readFileSync8(filePath, "utf-8");
|
|
34355
35253
|
if (/content=["'][^"']*\.md["']/i.test(src2)) {
|
|
34356
|
-
src2 = inlineMdContentAttrs(src2,
|
|
35254
|
+
src2 = inlineMdContentAttrs(src2, dirname6(filePath), guessProjectRoots(appDir));
|
|
34357
35255
|
}
|
|
34358
35256
|
const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
|
|
34359
35257
|
const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n || "", output));
|
|
@@ -34374,7 +35272,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options2) {
|
|
|
34374
35272
|
output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(resolvedName)}, { get: () => __hydrators[${JSON.stringify(actualName)}], configurable: true });`);
|
|
34375
35273
|
}
|
|
34376
35274
|
if (cache2 && namesBefore) {
|
|
34377
|
-
const st =
|
|
35275
|
+
const st = statSync3(filePath);
|
|
34378
35276
|
cache2.files.set(filePath, {
|
|
34379
35277
|
mtimeMs: st.mtimeMs,
|
|
34380
35278
|
size: st.size,
|
|
@@ -34397,31 +35295,31 @@ async function generateClientBundle(routeTree, appDir, componentMap, options2) {
|
|
|
34397
35295
|
let walkSplit2 = function(nodes, _chain) {
|
|
34398
35296
|
for (const node of nodes) {
|
|
34399
35297
|
const chunkCode = [];
|
|
34400
|
-
const pagePath =
|
|
35298
|
+
const pagePath = resolve8(appDir, node.sourceDir, "page.vsk");
|
|
34401
35299
|
if (node.page && existsSync7(pagePath)) {
|
|
34402
35300
|
compileFile2(pagePath, node.page, chunkCode);
|
|
34403
35301
|
}
|
|
34404
|
-
const layoutPath =
|
|
35302
|
+
const layoutPath = resolve8(appDir, node.sourceDir, "layout.vsk");
|
|
34405
35303
|
if (node.layout && existsSync7(layoutPath)) {
|
|
34406
35304
|
compileFile2(layoutPath, node.layout, chunkCode);
|
|
34407
35305
|
}
|
|
34408
|
-
const errorPath =
|
|
35306
|
+
const errorPath = resolve8(appDir, node.sourceDir, "error.vsk");
|
|
34409
35307
|
if (node.error && existsSync7(errorPath)) {
|
|
34410
35308
|
compileFile2(errorPath, node.error, chunkCode);
|
|
34411
35309
|
}
|
|
34412
|
-
const notFoundPath =
|
|
35310
|
+
const notFoundPath = resolve8(appDir, node.sourceDir, "not-found.vsk");
|
|
34413
35311
|
if (node.notFound && existsSync7(notFoundPath)) {
|
|
34414
35312
|
compileFile2(notFoundPath, node.notFound, chunkCode);
|
|
34415
35313
|
}
|
|
34416
|
-
const offlinePath =
|
|
35314
|
+
const offlinePath = resolve8(appDir, node.sourceDir, "offline.vsk");
|
|
34417
35315
|
if (node.offline && existsSync7(offlinePath)) {
|
|
34418
35316
|
compileFile2(offlinePath, node.offline, chunkCode);
|
|
34419
35317
|
}
|
|
34420
|
-
const networkPath =
|
|
35318
|
+
const networkPath = resolve8(appDir, node.sourceDir, "network.vsk");
|
|
34421
35319
|
if (node.network && existsSync7(networkPath)) {
|
|
34422
35320
|
compileFile2(networkPath, node.network, chunkCode);
|
|
34423
35321
|
}
|
|
34424
|
-
const loadingPath =
|
|
35322
|
+
const loadingPath = resolve8(appDir, node.sourceDir, "loading.vsk");
|
|
34425
35323
|
if (node.loading && existsSync7(loadingPath)) {
|
|
34426
35324
|
compileFile2(loadingPath, node.loading, chunkCode);
|
|
34427
35325
|
}
|
|
@@ -34478,7 +35376,7 @@ ${entry.code}
|
|
|
34478
35376
|
let compileFileMono2 = function(filePath, resolvedName) {
|
|
34479
35377
|
if (seen.has(filePath)) return;
|
|
34480
35378
|
seen.add(filePath);
|
|
34481
|
-
const src2 =
|
|
35379
|
+
const src2 = readFileSync8(filePath, "utf-8");
|
|
34482
35380
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
34483
35381
|
const compCode = compileClient(src2, null, { forceClient: true });
|
|
34484
35382
|
if (compCode) {
|
|
@@ -34499,19 +35397,19 @@ ${entry.code}
|
|
|
34499
35397
|
}
|
|
34500
35398
|
}, walkMono2 = function(nodes) {
|
|
34501
35399
|
for (const node of nodes) {
|
|
34502
|
-
const pagePath =
|
|
35400
|
+
const pagePath = resolve8(appDir, node.sourceDir, "page.vsk");
|
|
34503
35401
|
if (node.page && existsSync7(pagePath)) compileFileMono2(pagePath, node.page);
|
|
34504
|
-
const layoutPath =
|
|
35402
|
+
const layoutPath = resolve8(appDir, node.sourceDir, "layout.vsk");
|
|
34505
35403
|
if (node.layout && existsSync7(layoutPath)) compileFileMono2(layoutPath, node.layout);
|
|
34506
|
-
const errorPath =
|
|
35404
|
+
const errorPath = resolve8(appDir, node.sourceDir, "error.vsk");
|
|
34507
35405
|
if (node.error && existsSync7(errorPath)) compileFileMono2(errorPath, node.error);
|
|
34508
|
-
const notFoundPath =
|
|
35406
|
+
const notFoundPath = resolve8(appDir, node.sourceDir, "not-found.vsk");
|
|
34509
35407
|
if (node.notFound && existsSync7(notFoundPath)) compileFileMono2(notFoundPath, node.notFound);
|
|
34510
|
-
const offlinePath =
|
|
35408
|
+
const offlinePath = resolve8(appDir, node.sourceDir, "offline.vsk");
|
|
34511
35409
|
if (node.offline && existsSync7(offlinePath)) compileFileMono2(offlinePath, node.offline);
|
|
34512
|
-
const networkPath =
|
|
35410
|
+
const networkPath = resolve8(appDir, node.sourceDir, "network.vsk");
|
|
34513
35411
|
if (node.network && existsSync7(networkPath)) compileFileMono2(networkPath, node.network);
|
|
34514
|
-
const loadingPath =
|
|
35412
|
+
const loadingPath = resolve8(appDir, node.sourceDir, "loading.vsk");
|
|
34515
35413
|
if (node.loading && existsSync7(loadingPath)) compileFileMono2(loadingPath, node.loading);
|
|
34516
35414
|
walkMono2(node.children || []);
|
|
34517
35415
|
}
|
|
@@ -34561,9 +35459,9 @@ function buildRuntimeCode(runtimeDir) {
|
|
|
34561
35459
|
];
|
|
34562
35460
|
let code = "";
|
|
34563
35461
|
for (const f of runtimeFiles) {
|
|
34564
|
-
const p =
|
|
35462
|
+
const p = join5(runtimeDir, f);
|
|
34565
35463
|
if (existsSync7(p)) {
|
|
34566
|
-
let src2 =
|
|
35464
|
+
let src2 = readFileSync8(p, "utf-8");
|
|
34567
35465
|
src2 = stripTypes(src2);
|
|
34568
35466
|
src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
34569
35467
|
src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
@@ -34575,7 +35473,7 @@ ${src2}
|
|
|
34575
35473
|
`;
|
|
34576
35474
|
}
|
|
34577
35475
|
}
|
|
34578
|
-
const indexSrc =
|
|
35476
|
+
const indexSrc = readFileSync8(join5(runtimeDir, "index-client.js"), "utf-8");
|
|
34579
35477
|
const exportNames = stripTypes(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())) || [];
|
|
34580
35478
|
code += "// --- exports ---\n";
|
|
34581
35479
|
for (const name of [...new Set(exportNames)]) {
|
|
@@ -34585,7 +35483,7 @@ ${src2}
|
|
|
34585
35483
|
return code;
|
|
34586
35484
|
}
|
|
34587
35485
|
function runtimeExportNames(runtimeDir) {
|
|
34588
|
-
const indexSrc =
|
|
35486
|
+
const indexSrc = readFileSync8(join5(runtimeDir, "index-client.js"), "utf-8");
|
|
34589
35487
|
const names = /* @__PURE__ */ new Set();
|
|
34590
35488
|
for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
|
|
34591
35489
|
for (const raw2 of m[1].split(",")) {
|
|
@@ -34604,7 +35502,7 @@ async function buildTreeShakenRuntime(runtimeDir, usedNames) {
|
|
|
34604
35502
|
console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
|
|
34605
35503
|
return buildRuntimeCode(runtimeDir);
|
|
34606
35504
|
}
|
|
34607
|
-
const entry =
|
|
35505
|
+
const entry = join5(runtimeDir, `.runtime-tree-entry-${runtimeEntryId++}.mjs`);
|
|
34608
35506
|
try {
|
|
34609
35507
|
writeFileSync2(entry, `export { ${unique.join(", ")} } from './index-client.js';
|
|
34610
35508
|
`);
|
|
@@ -34776,19 +35674,19 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
|
|
|
34776
35674
|
|
|
34777
35675
|
// ../adapter/src/static.ts
|
|
34778
35676
|
init_paths();
|
|
34779
|
-
import { mkdirSync, copyFileSync, readdirSync as readdirSync2, statSync as
|
|
34780
|
-
import { resolve as
|
|
35677
|
+
import { mkdirSync, copyFileSync, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync8, writeFileSync as writeFileSync3, readFileSync as readFileSync9 } from "node:fs";
|
|
35678
|
+
import { resolve as resolve10, join as join6 } from "node:path";
|
|
34781
35679
|
function copyStaticAssets(publicDir, outDir2) {
|
|
34782
|
-
const targetDir =
|
|
35680
|
+
const targetDir = resolve10(outDir2, "static", "public");
|
|
34783
35681
|
mkdirSync(targetDir, { recursive: true });
|
|
34784
35682
|
if (!existsSync8(publicDir)) return;
|
|
34785
35683
|
function copyDir(src2, dest) {
|
|
34786
35684
|
mkdirSync(dest, { recursive: true });
|
|
34787
35685
|
const entries = readdirSync2(src2);
|
|
34788
35686
|
for (const entry of entries) {
|
|
34789
|
-
const srcPath =
|
|
34790
|
-
const destPath =
|
|
34791
|
-
const st =
|
|
35687
|
+
const srcPath = join6(src2, entry);
|
|
35688
|
+
const destPath = join6(dest, entry);
|
|
35689
|
+
const st = statSync4(srcPath);
|
|
34792
35690
|
if (st.isDirectory()) {
|
|
34793
35691
|
copyDir(srcPath, destPath);
|
|
34794
35692
|
} else {
|
|
@@ -34800,15 +35698,15 @@ function copyStaticAssets(publicDir, outDir2) {
|
|
|
34800
35698
|
}
|
|
34801
35699
|
|
|
34802
35700
|
// ../adapter/src/prod-server.ts
|
|
34803
|
-
import { readFileSync as
|
|
34804
|
-
import { resolve as
|
|
35701
|
+
import { readFileSync as readFileSync10, existsSync as existsSync9, statSync as statSync5 } from "node:fs";
|
|
35702
|
+
import { resolve as resolve11, extname as extname3, dirname as dirname7 } from "node:path";
|
|
34805
35703
|
import { createServer } from "node:http";
|
|
34806
|
-
import { createRequire } from "node:module";
|
|
35704
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
34807
35705
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
34808
35706
|
init_server_utils();
|
|
34809
35707
|
init_paths();
|
|
34810
|
-
var _require =
|
|
34811
|
-
var __dirname4 =
|
|
35708
|
+
var _require = createRequire2(import.meta.url);
|
|
35709
|
+
var __dirname4 = dirname7(fileURLToPath3(import.meta.url));
|
|
34812
35710
|
async function readBody(req, maxBytes = DEFAULT_MAX_BODY_BYTES) {
|
|
34813
35711
|
const chunks = [];
|
|
34814
35712
|
let total = 0;
|
|
@@ -34897,27 +35795,27 @@ async function startProdServer(outDir, options) {
|
|
|
34897
35795
|
const host = options?.host || "127.0.0.1";
|
|
34898
35796
|
const maxBodyBytes = options?.maxBodyBytes || DEFAULT_MAX_BODY_BYTES;
|
|
34899
35797
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
|
|
34900
|
-
const staticDir =
|
|
34901
|
-
const configPath =
|
|
35798
|
+
const staticDir = resolve11(outDir, "static");
|
|
35799
|
+
const configPath = resolve11(outDir, "config.json");
|
|
34902
35800
|
if (!existsSync9(configPath)) {
|
|
34903
35801
|
console.error(`vesk start: no build found at ${outDir}`);
|
|
34904
35802
|
console.error('Run "vesk build" first');
|
|
34905
35803
|
process.exit(1);
|
|
34906
35804
|
}
|
|
34907
|
-
const buildConfig = JSON.parse(
|
|
35805
|
+
const buildConfig = JSON.parse(readFileSync10(configPath, "utf-8"));
|
|
34908
35806
|
console.error(`vesk start: serving from ${outDir}`);
|
|
34909
|
-
const projectDir =
|
|
35807
|
+
const projectDir = resolve11(outDir, "..");
|
|
34910
35808
|
let securityConfig = {};
|
|
34911
35809
|
let mdConfig;
|
|
34912
35810
|
try {
|
|
34913
|
-
const veskConfigPath =
|
|
34914
|
-
const veskConfigTsPath =
|
|
35811
|
+
const veskConfigPath = resolve11(projectDir, "vesk.config.js");
|
|
35812
|
+
const veskConfigTsPath = resolve11(projectDir, "vesk.config.ts");
|
|
34915
35813
|
let rawConfig = {};
|
|
34916
35814
|
if (existsSync9(veskConfigPath)) {
|
|
34917
35815
|
rawConfig = _require(veskConfigPath);
|
|
34918
35816
|
} else if (existsSync9(veskConfigTsPath)) {
|
|
34919
35817
|
const { transpile } = _require("typescript");
|
|
34920
|
-
const src =
|
|
35818
|
+
const src = readFileSync10(veskConfigTsPath, "utf-8");
|
|
34921
35819
|
const result = transpile(src, { module: 99, target: 99 });
|
|
34922
35820
|
rawConfig = eval(`(${result})`);
|
|
34923
35821
|
}
|
|
@@ -34946,7 +35844,7 @@ async function startProdServer(outDir, options) {
|
|
|
34946
35844
|
} catch {
|
|
34947
35845
|
}
|
|
34948
35846
|
let middlewareMod = null;
|
|
34949
|
-
const mwPath =
|
|
35847
|
+
const mwPath = resolve11(outDir, "server", "middleware.js");
|
|
34950
35848
|
if (existsSync9(mwPath)) {
|
|
34951
35849
|
try {
|
|
34952
35850
|
middlewareMod = await import(`${mwPath}?t=${Date.now()}`);
|
|
@@ -34956,7 +35854,7 @@ async function startProdServer(outDir, options) {
|
|
|
34956
35854
|
const functionCache = /* @__PURE__ */ new Map();
|
|
34957
35855
|
async function loadFunction(funcPath) {
|
|
34958
35856
|
if (functionCache.has(funcPath)) return functionCache.get(funcPath);
|
|
34959
|
-
const fullPath =
|
|
35857
|
+
const fullPath = resolve11(outDir, funcPath);
|
|
34960
35858
|
if (!existsSync9(fullPath)) return null;
|
|
34961
35859
|
try {
|
|
34962
35860
|
const mod = await import(`${fullPath}?t=${Date.now()}`);
|
|
@@ -35017,12 +35915,12 @@ async function startProdServer(outDir, options) {
|
|
|
35017
35915
|
}
|
|
35018
35916
|
return origWriteHead(statusCode, headers2);
|
|
35019
35917
|
});
|
|
35020
|
-
const publicDir =
|
|
35918
|
+
const publicDir = resolve11(staticDir, "public");
|
|
35021
35919
|
const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
|
|
35022
|
-
if (rootFile && existsSync9(rootFile) &&
|
|
35023
|
-
const ext =
|
|
35920
|
+
if (rootFile && existsSync9(rootFile) && statSync5(rootFile).isFile()) {
|
|
35921
|
+
const ext = extname3(rootFile);
|
|
35024
35922
|
res.writeHead(200, { "Content-Type": MIME[ext] || "application/octet-stream" });
|
|
35025
|
-
res.end(
|
|
35923
|
+
res.end(readFileSync10(rootFile));
|
|
35026
35924
|
return;
|
|
35027
35925
|
}
|
|
35028
35926
|
if (url.pathname === "/ssr-data.js") {
|
|
@@ -35038,10 +35936,10 @@ async function startProdServer(outDir, options) {
|
|
|
35038
35936
|
return;
|
|
35039
35937
|
}
|
|
35040
35938
|
if (url.pathname === "/_vesk/runtime.js") {
|
|
35041
|
-
const clientPath =
|
|
35939
|
+
const clientPath = resolve11(staticDir, "client.js");
|
|
35042
35940
|
if (existsSync9(clientPath)) {
|
|
35043
35941
|
res.writeHead(200, { "Content-Type": "application/javascript" });
|
|
35044
|
-
res.end(
|
|
35942
|
+
res.end(readFileSync10(clientPath));
|
|
35045
35943
|
return;
|
|
35046
35944
|
}
|
|
35047
35945
|
}
|
|
@@ -35053,20 +35951,20 @@ async function startProdServer(outDir, options) {
|
|
|
35053
35951
|
res.end("Forbidden");
|
|
35054
35952
|
return;
|
|
35055
35953
|
}
|
|
35056
|
-
if (existsSync9(staticPath) &&
|
|
35057
|
-
const ext =
|
|
35954
|
+
if (existsSync9(staticPath) && statSync5(staticPath).isFile()) {
|
|
35955
|
+
const ext = extname3(staticPath);
|
|
35058
35956
|
res.writeHead(200, { "Content-Type": MIME[ext] || "application/octet-stream" });
|
|
35059
|
-
res.end(
|
|
35957
|
+
res.end(readFileSync10(staticPath));
|
|
35060
35958
|
return;
|
|
35061
35959
|
}
|
|
35062
35960
|
}
|
|
35063
35961
|
if (buildConfig.prerendered) {
|
|
35064
35962
|
const prerendered = buildConfig.prerendered.find((r) => r.path === url.pathname);
|
|
35065
35963
|
if (prerendered) {
|
|
35066
|
-
const htmlPath =
|
|
35964
|
+
const htmlPath = resolve11(outDir, prerendered.file);
|
|
35067
35965
|
if (existsSync9(htmlPath)) {
|
|
35068
35966
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
35069
|
-
res.end(
|
|
35967
|
+
res.end(readFileSync10(htmlPath));
|
|
35070
35968
|
return;
|
|
35071
35969
|
}
|
|
35072
35970
|
}
|
|
@@ -35164,14 +36062,14 @@ async function startProdServer(outDir, options) {
|
|
|
35164
36062
|
}
|
|
35165
36063
|
}
|
|
35166
36064
|
}
|
|
35167
|
-
const appDir =
|
|
35168
|
-
const nfPath =
|
|
36065
|
+
const appDir = resolve11(projectDir, "app");
|
|
36066
|
+
const nfPath = resolve11(appDir, "not-found.vsk");
|
|
35169
36067
|
let notFoundHtml = null;
|
|
35170
36068
|
if (existsSync9(nfPath)) {
|
|
35171
36069
|
try {
|
|
35172
|
-
const runtimePath =
|
|
36070
|
+
const runtimePath = resolve11(outDir, "server", "runtime.js");
|
|
35173
36071
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
35174
|
-
const src2 =
|
|
36072
|
+
const src2 = readFileSync10(nfPath, "utf-8");
|
|
35175
36073
|
const compName = resolveComponentName(src2) || "NotFound";
|
|
35176
36074
|
notFoundHtml = await renderFullPage2(src2, compName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: nfPath });
|
|
35177
36075
|
} catch {
|
|
@@ -35229,13 +36127,13 @@ async function startProdServer(outDir, options) {
|
|
|
35229
36127
|
return;
|
|
35230
36128
|
}
|
|
35231
36129
|
console.error("vesk ssr error:", err.message);
|
|
35232
|
-
const errPath =
|
|
36130
|
+
const errPath = resolve11(appDir, "error.vsk");
|
|
35233
36131
|
let errorHtml = null;
|
|
35234
36132
|
if (existsSync9(errPath)) {
|
|
35235
36133
|
try {
|
|
35236
|
-
const runtimePath =
|
|
36134
|
+
const runtimePath = resolve11(outDir, "server", "runtime.js");
|
|
35237
36135
|
const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
|
|
35238
|
-
const src2 =
|
|
36136
|
+
const src2 = readFileSync10(errPath, "utf-8");
|
|
35239
36137
|
const compName = resolveComponentName(src2) || "Error";
|
|
35240
36138
|
const expose = process.env.NODE_ENV !== "production";
|
|
35241
36139
|
errorHtml = await renderFullPage2(src2, compName, { error: expose ? err.message : "Internal Server Error", stack: expose ? err.stack : "", statusCode: 500, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], clientScriptUrl: "/_vesk/static/client.js", security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: errPath });
|
|
@@ -35260,22 +36158,22 @@ async function startProdServer(outDir, options) {
|
|
|
35260
36158
|
}
|
|
35261
36159
|
|
|
35262
36160
|
// ../adapter/dist/index.js
|
|
35263
|
-
var __dirname6 =
|
|
36161
|
+
var __dirname6 = dirname12(fileURLToPath5(import.meta.url));
|
|
35264
36162
|
async function resolveCompilerApi(name) {
|
|
35265
|
-
const monorepoSrc =
|
|
36163
|
+
const monorepoSrc = resolve18(__dirname6, "..", "..", "compiler", "src");
|
|
35266
36164
|
if (existsSync15(monorepoSrc)) {
|
|
35267
|
-
const tsFile =
|
|
36165
|
+
const tsFile = resolve18(monorepoSrc, name.replace(/\.js$/, ".ts"));
|
|
35268
36166
|
if (existsSync15(tsFile)) {
|
|
35269
36167
|
return import(tsFile);
|
|
35270
36168
|
}
|
|
35271
|
-
return import(
|
|
36169
|
+
return import(resolve18(monorepoSrc, name));
|
|
35272
36170
|
}
|
|
35273
36171
|
return import(`@vesk/compiler/src/${name.replace(/\.js$/, "")}`);
|
|
35274
36172
|
}
|
|
35275
36173
|
async function build2(appDir, options2) {
|
|
35276
|
-
appDir =
|
|
35277
|
-
const outDir2 =
|
|
35278
|
-
const publicDir = options2?.publicDir ||
|
|
36174
|
+
appDir = resolve18(appDir);
|
|
36175
|
+
const outDir2 = resolve18(options2?.outDir || resolve18(appDir, "..", ".vesk"));
|
|
36176
|
+
const publicDir = options2?.publicDir || resolve18(appDir, "..", "public");
|
|
35279
36177
|
const plugins = options2?.plugins || [];
|
|
35280
36178
|
if (options2?.md) {
|
|
35281
36179
|
const { configureMd: configureMd3 } = await Promise.resolve().then(() => (init_md(), md_exports));
|
|
@@ -35288,10 +36186,10 @@ async function build2(appDir, options2) {
|
|
|
35288
36186
|
}
|
|
35289
36187
|
console.error(`vesk build: output \u2192 ${outDir2}`);
|
|
35290
36188
|
const dirs = [
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
|
|
35294
|
-
|
|
36189
|
+
resolve18(outDir2, "server", "functions"),
|
|
36190
|
+
resolve18(outDir2, "server", "api"),
|
|
36191
|
+
resolve18(outDir2, "static", "public"),
|
|
36192
|
+
resolve18(outDir2, "prerendered")
|
|
35295
36193
|
];
|
|
35296
36194
|
for (const d of dirs)
|
|
35297
36195
|
mkdirSync6(d, { recursive: true });
|
|
@@ -35303,13 +36201,13 @@ async function build2(appDir, options2) {
|
|
|
35303
36201
|
console.error("vesk build: no routes found in", appDir);
|
|
35304
36202
|
return;
|
|
35305
36203
|
}
|
|
35306
|
-
const projectRoot =
|
|
35307
|
-
const componentsDir =
|
|
36204
|
+
const projectRoot = resolve18(appDir, "..");
|
|
36205
|
+
const componentsDir = resolve18(projectRoot, "components");
|
|
35308
36206
|
const componentMap = scanComponents(componentsDir);
|
|
35309
36207
|
if (componentMap.size > 0) {
|
|
35310
36208
|
console.error(`vesk build: ${componentMap.size} external components found in ${componentsDir}`);
|
|
35311
36209
|
}
|
|
35312
|
-
const apiDir =
|
|
36210
|
+
const apiDir = resolve18(appDir, "api");
|
|
35313
36211
|
const apiTree = existsSync15(apiDir) ? scanApiRoutes2(apiDir) : [];
|
|
35314
36212
|
console.error(`vesk build: ${routeTree.length} root routes, ${apiTree.length} API routes`);
|
|
35315
36213
|
console.error("vesk build: bundling server runtime...");
|
|
@@ -35323,21 +36221,21 @@ async function build2(appDir, options2) {
|
|
|
35323
36221
|
const mwChain2 = collectMiddlewareChain2(routeTree, node.fullPath, appDir);
|
|
35324
36222
|
let mwCode = null;
|
|
35325
36223
|
if (mwChain2.length > 0) {
|
|
35326
|
-
const mwSources = mwChain2.map((m) =>
|
|
36224
|
+
const mwSources = mwChain2.map((m) => readFileSync15(m.sourcePath, "utf-8"));
|
|
35327
36225
|
mwCode = compileMiddlewareCode(mwSources);
|
|
35328
36226
|
}
|
|
35329
36227
|
const { funcPath, funcCode, name } = generateSsrFunction(node, appDir, outDir2, componentMap, { ancestorLayouts, middlewareCode: mwCode });
|
|
35330
36228
|
writeFileSync8(funcPath, funcCode, "utf-8");
|
|
35331
|
-
const pagePath =
|
|
36229
|
+
const pagePath = resolve18(appDir, node.sourceDir, "page.vsk");
|
|
35332
36230
|
if (existsSync15(pagePath)) {
|
|
35333
|
-
const src2 =
|
|
36231
|
+
const src2 = readFileSync15(pagePath, "utf-8");
|
|
35334
36232
|
const actionIds = collectActionIds(src2);
|
|
35335
36233
|
if (node.layout) {
|
|
35336
|
-
const layoutSrc =
|
|
36234
|
+
const layoutSrc = readFileSync15(resolve18(appDir, node.sourceDir, "layout.vsk"), "utf-8");
|
|
35337
36235
|
actionIds.push(...collectActionIds(layoutSrc));
|
|
35338
36236
|
}
|
|
35339
36237
|
for (const a of ancestorLayouts) {
|
|
35340
|
-
const ancestorSrc =
|
|
36238
|
+
const ancestorSrc = readFileSync15(resolve18(appDir, a.sourceDir, "layout.vsk"), "utf-8");
|
|
35341
36239
|
actionIds.push(...collectActionIds(ancestorSrc));
|
|
35342
36240
|
}
|
|
35343
36241
|
for (const id of actionIds) {
|
|
@@ -35377,7 +36275,7 @@ async function build2(appDir, options2) {
|
|
|
35377
36275
|
if (mwChain.length > 0) {
|
|
35378
36276
|
const mwCode = compileMiddleware(mwChain, appDir);
|
|
35379
36277
|
if (mwCode) {
|
|
35380
|
-
writeFileSync8(
|
|
36278
|
+
writeFileSync8(resolve18(outDir2, "server", "middleware.js"), mwCode, "utf-8");
|
|
35381
36279
|
middlewareEnabled = true;
|
|
35382
36280
|
console.error(`vesk build: mw \u2192 server/middleware.js (${mwChain.length} middlewares)`);
|
|
35383
36281
|
}
|
|
@@ -35391,28 +36289,28 @@ async function build2(appDir, options2) {
|
|
|
35391
36289
|
if (options2?.routeDataCache !== void 0)
|
|
35392
36290
|
bundleOpts.routeDataCache = options2.routeDataCache;
|
|
35393
36291
|
const { main, chunks } = await generateClientBundle(routeTree, appDir, componentMap, bundleOpts);
|
|
35394
|
-
writeFileSync8(
|
|
36292
|
+
writeFileSync8(resolve18(outDir2, "static", "client.js"), main, "utf-8");
|
|
35395
36293
|
const mode = chunks.length > 0 ? "code-split" : "monolithic";
|
|
35396
36294
|
console.error(`vesk build: client \u2192 static/client.js (${main.length} bytes, ${mode})`);
|
|
35397
36295
|
if (chunks.length > 0) {
|
|
35398
|
-
const staticDir2 =
|
|
36296
|
+
const staticDir2 = resolve18(outDir2, "static");
|
|
35399
36297
|
for (const chunk of chunks) {
|
|
35400
|
-
writeFileSync8(
|
|
36298
|
+
writeFileSync8(resolve18(staticDir2, chunk.name), chunk.code, "utf-8");
|
|
35401
36299
|
console.error(`vesk build: chunk \u2192 static/${chunk.name} (${chunk.code.length} bytes)`);
|
|
35402
36300
|
}
|
|
35403
36301
|
}
|
|
35404
36302
|
copyStaticAssets(publicDir, outDir2);
|
|
35405
36303
|
console.error("vesk build: static \u2192 static/public/");
|
|
35406
|
-
const srcDir =
|
|
35407
|
-
const cssSrc =
|
|
35408
|
-
const altCssSrc =
|
|
36304
|
+
const srcDir = resolve18(appDir, "..", "src");
|
|
36305
|
+
const cssSrc = resolve18(srcDir, "global.css");
|
|
36306
|
+
const altCssSrc = resolve18(srcDir, "app.css");
|
|
35409
36307
|
let cssContent = null;
|
|
35410
36308
|
let cssSourcePath = null;
|
|
35411
36309
|
if (existsSync15(cssSrc)) {
|
|
35412
|
-
cssContent =
|
|
36310
|
+
cssContent = readFileSync15(cssSrc, "utf-8");
|
|
35413
36311
|
cssSourcePath = cssSrc;
|
|
35414
36312
|
} else if (existsSync15(altCssSrc)) {
|
|
35415
|
-
cssContent =
|
|
36313
|
+
cssContent = readFileSync15(altCssSrc, "utf-8");
|
|
35416
36314
|
cssSourcePath = altCssSrc;
|
|
35417
36315
|
}
|
|
35418
36316
|
function stripTailwindDirectives2(css) {
|
|
@@ -35436,7 +36334,7 @@ async function build2(appDir, options2) {
|
|
|
35436
36334
|
}
|
|
35437
36335
|
if (cssContent !== null) {
|
|
35438
36336
|
const userCss = stripTailwindDirectives2(cssContent);
|
|
35439
|
-
const userCssTarget =
|
|
36337
|
+
const userCssTarget = resolve18(outDir2, "static", "global.css");
|
|
35440
36338
|
writeFileSync8(userCssTarget, userCss, "utf-8");
|
|
35441
36339
|
console.error(`vesk build: css \u2192 static/global.css (${userCss.length} bytes)`);
|
|
35442
36340
|
let twCss = cssContent;
|
|
@@ -35448,7 +36346,7 @@ async function build2(appDir, options2) {
|
|
|
35448
36346
|
}
|
|
35449
36347
|
}
|
|
35450
36348
|
}
|
|
35451
|
-
const twCssTarget =
|
|
36349
|
+
const twCssTarget = resolve18(outDir2, "static", "_tailwind.css");
|
|
35452
36350
|
const hasUnresolvedTailwindImport = /@import\s+['"]tailwindcss['"]/.test(twCss);
|
|
35453
36351
|
if (hasUnresolvedTailwindImport) {
|
|
35454
36352
|
const lines = twCss.split("\n").filter((l) => !/^\s*@import\s+['"]tailwindcss['"]/.test(l));
|
|
@@ -35488,15 +36386,15 @@ async function build2(appDir, options2) {
|
|
|
35488
36386
|
}
|
|
35489
36387
|
{
|
|
35490
36388
|
const { generateSitemap: generateSitemap2, generateRobotsTxt: generateRobotsTxt2 } = await Promise.resolve().then(() => (init_static(), static_exports));
|
|
35491
|
-
const publicDirResolved =
|
|
36389
|
+
const publicDirResolved = resolve18(outDir2, "static", "public");
|
|
35492
36390
|
const siteUrl = options2?.siteUrl || "http://localhost:3000";
|
|
35493
|
-
const sitemapOverride =
|
|
36391
|
+
const sitemapOverride = resolve18(publicDirResolved, "sitemap.xml");
|
|
35494
36392
|
if (!existsSync15(sitemapOverride)) {
|
|
35495
36393
|
const sitemap = generateSitemap2(routeTree, ssrRoutes, prerenderedRoutes, { siteUrl });
|
|
35496
36394
|
writeFileSync8(sitemapOverride, sitemap, "utf-8");
|
|
35497
36395
|
console.error(`vesk build: seo \u2192 static/public/sitemap.xml (${sitemap.length} bytes)`);
|
|
35498
36396
|
}
|
|
35499
|
-
const robotsOverride =
|
|
36397
|
+
const robotsOverride = resolve18(publicDirResolved, "robots.txt");
|
|
35500
36398
|
if (!existsSync15(robotsOverride)) {
|
|
35501
36399
|
const robots = generateRobotsTxt2(siteUrl);
|
|
35502
36400
|
writeFileSync8(robotsOverride, robots, "utf-8");
|
|
@@ -35504,7 +36402,7 @@ async function build2(appDir, options2) {
|
|
|
35504
36402
|
}
|
|
35505
36403
|
}
|
|
35506
36404
|
const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap);
|
|
35507
|
-
writeFileSync8(
|
|
36405
|
+
writeFileSync8(resolve18(outDir2, "config.json"), JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
35508
36406
|
console.error("vesk build: config \u2192 config.json");
|
|
35509
36407
|
{
|
|
35510
36408
|
const { detectPlatform: detectPlatform2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
|
|
@@ -35543,16 +36441,16 @@ vesk build: done (${outDir2})`);
|
|
|
35543
36441
|
init_seo_audit();
|
|
35544
36442
|
|
|
35545
36443
|
// src/dev-server.ts
|
|
35546
|
-
import { readFileSync as
|
|
35547
|
-
import { resolve as
|
|
36444
|
+
import { readFileSync as readFileSync20, watch, statSync as statSync14, existsSync as existsSync22, readdirSync as readdirSync11 } from "node:fs";
|
|
36445
|
+
import { resolve as resolve24, extname as extname6, join as join13 } from "node:path";
|
|
35548
36446
|
import { createServer as createServer2 } from "node:http";
|
|
35549
36447
|
import { WebSocketServer } from "ws";
|
|
35550
36448
|
|
|
35551
36449
|
// ../compiler/dist/strip-ts.js
|
|
35552
36450
|
init_parser();
|
|
35553
36451
|
import { walk as walk4 } from "zimmerframe";
|
|
35554
|
-
import { print as
|
|
35555
|
-
import
|
|
36452
|
+
import { print as print6 } from "esrap";
|
|
36453
|
+
import ts6 from "esrap/languages/ts";
|
|
35556
36454
|
var TS_NODE_TYPES2 = /* @__PURE__ */ new Set([
|
|
35557
36455
|
"TSAsExpression",
|
|
35558
36456
|
"TSSatisfiesExpression",
|
|
@@ -35693,7 +36591,7 @@ function stripCodeTypes2(code) {
|
|
|
35693
36591
|
stripped.body = stripped.body.filter((n) => !isTypeOnlyStatement2(n));
|
|
35694
36592
|
}
|
|
35695
36593
|
try {
|
|
35696
|
-
return
|
|
36594
|
+
return print6(stripped, ts6()).code;
|
|
35697
36595
|
} catch {
|
|
35698
36596
|
return code;
|
|
35699
36597
|
}
|
|
@@ -35742,12 +36640,13 @@ init_parser();
|
|
|
35742
36640
|
init_ir_generator();
|
|
35743
36641
|
init_actions();
|
|
35744
36642
|
init_server_utils();
|
|
36643
|
+
init_module_imports();
|
|
35745
36644
|
init_scan();
|
|
35746
36645
|
init_md_inline();
|
|
35747
36646
|
init_strip_ts();
|
|
35748
36647
|
import { walk as walk5 } from "zimmerframe";
|
|
35749
|
-
import { print as
|
|
35750
|
-
import
|
|
36648
|
+
import { print as print7 } from "esrap";
|
|
36649
|
+
import ts7 from "esrap/languages/ts";
|
|
35751
36650
|
import tsx2 from "esrap/languages/tsx";
|
|
35752
36651
|
function callExpr2(callee, args2 = []) {
|
|
35753
36652
|
return { type: "CallExpression", callee, arguments: args2, optional: false };
|
|
@@ -35792,7 +36691,7 @@ function containsJsx2(node, depth = 0) {
|
|
|
35792
36691
|
return false;
|
|
35793
36692
|
}
|
|
35794
36693
|
function printAst2(ast) {
|
|
35795
|
-
return
|
|
36694
|
+
return print7(ast, containsJsx2(ast) ? tsx2() : ts7()).code;
|
|
35796
36695
|
}
|
|
35797
36696
|
function transformTracked2(irNode, tracked2) {
|
|
35798
36697
|
const ast = irNode.ast;
|
|
@@ -35878,7 +36777,7 @@ function transformTracked2(irNode, tracked2) {
|
|
|
35878
36777
|
return context.next();
|
|
35879
36778
|
}
|
|
35880
36779
|
});
|
|
35881
|
-
return
|
|
36780
|
+
return print7(transformed, containsJsx2(transformed) ? tsx2() : ts7()).code;
|
|
35882
36781
|
}
|
|
35883
36782
|
function collectTrackedNames2(body) {
|
|
35884
36783
|
const names = /* @__PURE__ */ new Map();
|
|
@@ -37201,7 +38100,13 @@ function emitClientFromIR2(ir, options2) {
|
|
|
37201
38100
|
runtimeNames.push(name);
|
|
37202
38101
|
}
|
|
37203
38102
|
}
|
|
37204
|
-
const
|
|
38103
|
+
const boundLocally = /* @__PURE__ */ new Set();
|
|
38104
|
+
for (const imp of ir.imports) {
|
|
38105
|
+
for (const pair of importBindingPairs(imp))
|
|
38106
|
+
boundLocally.add(pair.local);
|
|
38107
|
+
}
|
|
38108
|
+
const shadowedRuntimeNames = runtimeNames.filter((n) => !boundLocally.has(n));
|
|
38109
|
+
const runtimeImport = `import { ${shadowedRuntimeNames.length > 0 ? shadowedRuntimeNames.join(", ") : "destroy_block"} } from '@vesk/runtime';`;
|
|
37205
38110
|
const moduleCode = `
|
|
37206
38111
|
${runtimeImport}
|
|
37207
38112
|
${importLines}
|
|
@@ -37225,8 +38130,8 @@ init_parser();
|
|
|
37225
38130
|
init_tokens();
|
|
37226
38131
|
init_scan();
|
|
37227
38132
|
init_strip_ts();
|
|
37228
|
-
import { readdirSync as readdirSync7, statSync as
|
|
37229
|
-
import { join as
|
|
38133
|
+
import { readdirSync as readdirSync7, statSync as statSync10, existsSync as existsSync16, readFileSync as readFileSync16 } from "fs";
|
|
38134
|
+
import { join as join9, relative as relative5, basename } from "path";
|
|
37230
38135
|
function collapseSlashes2(p) {
|
|
37231
38136
|
let out = "";
|
|
37232
38137
|
let prevSlash = false;
|
|
@@ -37346,10 +38251,10 @@ function scanDirectory(rootDir, dir, parentPath, options2) {
|
|
|
37346
38251
|
segmentCount: isGroup || dir === rootDir ? 0 : 1
|
|
37347
38252
|
};
|
|
37348
38253
|
for (const entry of entries) {
|
|
37349
|
-
const entryPath =
|
|
38254
|
+
const entryPath = join9(dir, entry);
|
|
37350
38255
|
let entryStat;
|
|
37351
38256
|
try {
|
|
37352
|
-
entryStat =
|
|
38257
|
+
entryStat = statSync10(entryPath);
|
|
37353
38258
|
} catch {
|
|
37354
38259
|
continue;
|
|
37355
38260
|
}
|
|
@@ -37398,19 +38303,19 @@ function collectSources(tree) {
|
|
|
37398
38303
|
function walk6(nodes) {
|
|
37399
38304
|
for (const node of nodes) {
|
|
37400
38305
|
if (node.page)
|
|
37401
|
-
map.set(node.page,
|
|
38306
|
+
map.set(node.page, join9(node.sourceDir, "page.vsk"));
|
|
37402
38307
|
if (node.layout)
|
|
37403
|
-
map.set(node.layout,
|
|
38308
|
+
map.set(node.layout, join9(node.sourceDir, "layout.vsk"));
|
|
37404
38309
|
if (node.loading)
|
|
37405
|
-
map.set(node.loading,
|
|
38310
|
+
map.set(node.loading, join9(node.sourceDir, "loading.vsk"));
|
|
37406
38311
|
if (node.error)
|
|
37407
|
-
map.set(node.error,
|
|
38312
|
+
map.set(node.error, join9(node.sourceDir, "error.vsk"));
|
|
37408
38313
|
if (node.notFound)
|
|
37409
|
-
map.set(node.notFound,
|
|
38314
|
+
map.set(node.notFound, join9(node.sourceDir, "not-found.vsk"));
|
|
37410
38315
|
if (node.offline)
|
|
37411
|
-
map.set(node.offline,
|
|
38316
|
+
map.set(node.offline, join9(node.sourceDir, "offline.vsk"));
|
|
37412
38317
|
if (node.network)
|
|
37413
|
-
map.set(node.network,
|
|
38318
|
+
map.set(node.network, join9(node.sourceDir, "network.vsk"));
|
|
37414
38319
|
walk6(node.children);
|
|
37415
38320
|
}
|
|
37416
38321
|
}
|
|
@@ -37496,8 +38401,8 @@ function matchUrl(tree, pathname) {
|
|
|
37496
38401
|
}
|
|
37497
38402
|
|
|
37498
38403
|
// ../compiler/dist/api-routes.js
|
|
37499
|
-
import { readdirSync as readdirSync8, statSync as
|
|
37500
|
-
import { join as
|
|
38404
|
+
import { readdirSync as readdirSync8, statSync as statSync11, existsSync as existsSync17 } from "fs";
|
|
38405
|
+
import { join as join10 } from "path";
|
|
37501
38406
|
init_server_utils();
|
|
37502
38407
|
function basename2(p) {
|
|
37503
38408
|
const idx = p.lastIndexOf("/");
|
|
@@ -37534,10 +38439,10 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
37534
38439
|
return nodes;
|
|
37535
38440
|
if (isRouteGroup) {
|
|
37536
38441
|
for (const entry of entries) {
|
|
37537
|
-
const entryPath =
|
|
38442
|
+
const entryPath = join10(dir, entry);
|
|
37538
38443
|
let entryStat;
|
|
37539
38444
|
try {
|
|
37540
|
-
entryStat =
|
|
38445
|
+
entryStat = statSync11(entryPath);
|
|
37541
38446
|
} catch {
|
|
37542
38447
|
continue;
|
|
37543
38448
|
}
|
|
@@ -37564,14 +38469,14 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
37564
38469
|
fullPath: collapseSlashes(fullPath) || "/",
|
|
37565
38470
|
isDynamic,
|
|
37566
38471
|
isCatchAll,
|
|
37567
|
-
filePath: hasRoute && routeFileName ?
|
|
38472
|
+
filePath: hasRoute && routeFileName ? join10(dir, routeFileName) : null,
|
|
37568
38473
|
children: []
|
|
37569
38474
|
};
|
|
37570
38475
|
for (const entry of entries) {
|
|
37571
|
-
const entryPath =
|
|
38476
|
+
const entryPath = join10(dir, entry);
|
|
37572
38477
|
let entryStat;
|
|
37573
38478
|
try {
|
|
37574
|
-
entryStat =
|
|
38479
|
+
entryStat = statSync11(entryPath);
|
|
37575
38480
|
} catch {
|
|
37576
38481
|
continue;
|
|
37577
38482
|
}
|
|
@@ -37870,7 +38775,7 @@ async function executeRewrite(url, originalRequest) {
|
|
|
37870
38775
|
|
|
37871
38776
|
// ../compiler/dist/middleware.js
|
|
37872
38777
|
import { existsSync as existsSync18 } from "fs";
|
|
37873
|
-
import { resolve as
|
|
38778
|
+
import { resolve as resolve19 } from "path";
|
|
37874
38779
|
|
|
37875
38780
|
// ../compiler/src/api-routes.ts
|
|
37876
38781
|
init_server_utils();
|
|
@@ -37929,7 +38834,7 @@ function collectMiddlewareChain(routeTree, url, appDir) {
|
|
|
37929
38834
|
}
|
|
37930
38835
|
function collectForNode(node) {
|
|
37931
38836
|
if (node.hasMiddleware) {
|
|
37932
|
-
const mwPath2 =
|
|
38837
|
+
const mwPath2 = resolve19(appDir, node.sourceDir, "middleware.ts");
|
|
37933
38838
|
if (existsSync18(mwPath2)) {
|
|
37934
38839
|
chain.push({ sourcePath: mwPath2, node });
|
|
37935
38840
|
}
|
|
@@ -38093,8 +38998,8 @@ async function executeMiddlewareChain(chain, request, params, options2 = {}) {
|
|
|
38093
38998
|
}
|
|
38094
38999
|
|
|
38095
39000
|
// ../adapter/dist/client-bundle.js
|
|
38096
|
-
import { readFileSync as
|
|
38097
|
-
import { resolve as
|
|
39001
|
+
import { readFileSync as readFileSync17, existsSync as existsSync19, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3, statSync as statSync12 } from "node:fs";
|
|
39002
|
+
import { resolve as resolve20, join as join11, dirname as dirname13, relative as relative6, sep as sep3 } from "node:path";
|
|
38098
39003
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
38099
39004
|
|
|
38100
39005
|
// ../adapter/dist/esbuild-fallback.js
|
|
@@ -38149,10 +39054,10 @@ init_strip_ts();
|
|
|
38149
39054
|
init_client_codegen();
|
|
38150
39055
|
init_vsk_imports();
|
|
38151
39056
|
init_md_inline();
|
|
38152
|
-
var __dirname7 =
|
|
39057
|
+
var __dirname7 = dirname13(fileURLToPath6(import.meta.url));
|
|
38153
39058
|
function fileUnchanged2(filePath, cached) {
|
|
38154
39059
|
try {
|
|
38155
|
-
const st =
|
|
39060
|
+
const st = statSync12(filePath);
|
|
38156
39061
|
return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
|
|
38157
39062
|
} catch {
|
|
38158
39063
|
return false;
|
|
@@ -38166,15 +39071,15 @@ function buildRouterOpts2(options2) {
|
|
|
38166
39071
|
return "";
|
|
38167
39072
|
}
|
|
38168
39073
|
function findRuntimeSrc3(appDir) {
|
|
38169
|
-
const monorepoRoot =
|
|
39074
|
+
const monorepoRoot = resolve20(__dirname7, "..", "..", "..");
|
|
38170
39075
|
const candidates = [
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
|
|
39076
|
+
resolve20(monorepoRoot, "packages", "runtime", "dist"),
|
|
39077
|
+
resolve20(appDir, "..", "node_modules", "@vesk/runtime"),
|
|
39078
|
+
resolve20(appDir, "node_modules", "@vesk/runtime")
|
|
38174
39079
|
];
|
|
38175
39080
|
for (const base of candidates) {
|
|
38176
|
-
for (const dir of [base,
|
|
38177
|
-
if (existsSync19(
|
|
39081
|
+
for (const dir of [base, join11(base, "dist")]) {
|
|
39082
|
+
if (existsSync19(join11(dir, "index-client.js")))
|
|
38178
39083
|
return dir;
|
|
38179
39084
|
}
|
|
38180
39085
|
}
|
|
@@ -38214,11 +39119,11 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
|
|
|
38214
39119
|
return code.replace(/^import\s*\{[^}]*\}\s*from\s*['"][^'"]*\.vsk['"];?\s*\n?/gm, "");
|
|
38215
39120
|
}
|
|
38216
39121
|
function resolveVskImports(filePath, compile) {
|
|
38217
|
-
const src2 =
|
|
39122
|
+
const src2 = readFileSync17(filePath, "utf-8");
|
|
38218
39123
|
const resolved = [];
|
|
38219
39124
|
for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
|
|
38220
39125
|
try {
|
|
38221
|
-
|
|
39126
|
+
readFileSync17(importPath);
|
|
38222
39127
|
} catch {
|
|
38223
39128
|
continue;
|
|
38224
39129
|
}
|
|
@@ -38263,9 +39168,9 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
|
|
|
38263
39168
|
return;
|
|
38264
39169
|
}
|
|
38265
39170
|
compiledFiles++;
|
|
38266
|
-
let src2 =
|
|
39171
|
+
let src2 = readFileSync17(filePath, "utf-8");
|
|
38267
39172
|
if (/content=["'][^"']*\.md["']/i.test(src2)) {
|
|
38268
|
-
src2 = inlineMdContentAttrs(src2,
|
|
39173
|
+
src2 = inlineMdContentAttrs(src2, dirname13(filePath), guessProjectRoots(appDir));
|
|
38269
39174
|
}
|
|
38270
39175
|
const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
|
|
38271
39176
|
const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n || "", output));
|
|
@@ -38290,7 +39195,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
|
|
|
38290
39195
|
output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(resolvedName)}, { get: () => __hydrators[${JSON.stringify(actualName)}], configurable: true });`);
|
|
38291
39196
|
}
|
|
38292
39197
|
if (cache2 && namesBefore) {
|
|
38293
|
-
const st =
|
|
39198
|
+
const st = statSync12(filePath);
|
|
38294
39199
|
cache2.files.set(filePath, {
|
|
38295
39200
|
mtimeMs: st.mtimeMs,
|
|
38296
39201
|
size: st.size,
|
|
@@ -38313,31 +39218,31 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
|
|
|
38313
39218
|
let walkSplit2 = function(nodes, _chain) {
|
|
38314
39219
|
for (const node of nodes) {
|
|
38315
39220
|
const chunkCode = [];
|
|
38316
|
-
const pagePath =
|
|
39221
|
+
const pagePath = resolve20(appDir, node.sourceDir, "page.vsk");
|
|
38317
39222
|
if (node.page && existsSync19(pagePath)) {
|
|
38318
39223
|
compileFile2(pagePath, node.page, chunkCode);
|
|
38319
39224
|
}
|
|
38320
|
-
const layoutPath =
|
|
39225
|
+
const layoutPath = resolve20(appDir, node.sourceDir, "layout.vsk");
|
|
38321
39226
|
if (node.layout && existsSync19(layoutPath)) {
|
|
38322
39227
|
compileFile2(layoutPath, node.layout, chunkCode);
|
|
38323
39228
|
}
|
|
38324
|
-
const errorPath =
|
|
39229
|
+
const errorPath = resolve20(appDir, node.sourceDir, "error.vsk");
|
|
38325
39230
|
if (node.error && existsSync19(errorPath)) {
|
|
38326
39231
|
compileFile2(errorPath, node.error, chunkCode);
|
|
38327
39232
|
}
|
|
38328
|
-
const notFoundPath =
|
|
39233
|
+
const notFoundPath = resolve20(appDir, node.sourceDir, "not-found.vsk");
|
|
38329
39234
|
if (node.notFound && existsSync19(notFoundPath)) {
|
|
38330
39235
|
compileFile2(notFoundPath, node.notFound, chunkCode);
|
|
38331
39236
|
}
|
|
38332
|
-
const offlinePath =
|
|
39237
|
+
const offlinePath = resolve20(appDir, node.sourceDir, "offline.vsk");
|
|
38333
39238
|
if (node.offline && existsSync19(offlinePath)) {
|
|
38334
39239
|
compileFile2(offlinePath, node.offline, chunkCode);
|
|
38335
39240
|
}
|
|
38336
|
-
const networkPath =
|
|
39241
|
+
const networkPath = resolve20(appDir, node.sourceDir, "network.vsk");
|
|
38337
39242
|
if (node.network && existsSync19(networkPath)) {
|
|
38338
39243
|
compileFile2(networkPath, node.network, chunkCode);
|
|
38339
39244
|
}
|
|
38340
|
-
const loadingPath =
|
|
39245
|
+
const loadingPath = resolve20(appDir, node.sourceDir, "loading.vsk");
|
|
38341
39246
|
if (node.loading && existsSync19(loadingPath)) {
|
|
38342
39247
|
compileFile2(loadingPath, node.loading, chunkCode);
|
|
38343
39248
|
}
|
|
@@ -38397,7 +39302,7 @@ ${entry.code}
|
|
|
38397
39302
|
if (seen.has(filePath))
|
|
38398
39303
|
return;
|
|
38399
39304
|
seen.add(filePath);
|
|
38400
|
-
const src2 =
|
|
39305
|
+
const src2 = readFileSync17(filePath, "utf-8");
|
|
38401
39306
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
38402
39307
|
const compCode = compileClient(src2, null, { forceClient: true });
|
|
38403
39308
|
if (compCode) {
|
|
@@ -38418,25 +39323,25 @@ ${entry.code}
|
|
|
38418
39323
|
}
|
|
38419
39324
|
}, walkMono2 = function(nodes) {
|
|
38420
39325
|
for (const node of nodes) {
|
|
38421
|
-
const pagePath =
|
|
39326
|
+
const pagePath = resolve20(appDir, node.sourceDir, "page.vsk");
|
|
38422
39327
|
if (node.page && existsSync19(pagePath))
|
|
38423
39328
|
compileFileMono2(pagePath, node.page);
|
|
38424
|
-
const layoutPath =
|
|
39329
|
+
const layoutPath = resolve20(appDir, node.sourceDir, "layout.vsk");
|
|
38425
39330
|
if (node.layout && existsSync19(layoutPath))
|
|
38426
39331
|
compileFileMono2(layoutPath, node.layout);
|
|
38427
|
-
const errorPath =
|
|
39332
|
+
const errorPath = resolve20(appDir, node.sourceDir, "error.vsk");
|
|
38428
39333
|
if (node.error && existsSync19(errorPath))
|
|
38429
39334
|
compileFileMono2(errorPath, node.error);
|
|
38430
|
-
const notFoundPath =
|
|
39335
|
+
const notFoundPath = resolve20(appDir, node.sourceDir, "not-found.vsk");
|
|
38431
39336
|
if (node.notFound && existsSync19(notFoundPath))
|
|
38432
39337
|
compileFileMono2(notFoundPath, node.notFound);
|
|
38433
|
-
const offlinePath =
|
|
39338
|
+
const offlinePath = resolve20(appDir, node.sourceDir, "offline.vsk");
|
|
38434
39339
|
if (node.offline && existsSync19(offlinePath))
|
|
38435
39340
|
compileFileMono2(offlinePath, node.offline);
|
|
38436
|
-
const networkPath =
|
|
39341
|
+
const networkPath = resolve20(appDir, node.sourceDir, "network.vsk");
|
|
38437
39342
|
if (node.network && existsSync19(networkPath))
|
|
38438
39343
|
compileFileMono2(networkPath, node.network);
|
|
38439
|
-
const loadingPath =
|
|
39344
|
+
const loadingPath = resolve20(appDir, node.sourceDir, "loading.vsk");
|
|
38440
39345
|
if (node.loading && existsSync19(loadingPath))
|
|
38441
39346
|
compileFileMono2(loadingPath, node.loading);
|
|
38442
39347
|
walkMono2(node.children || []);
|
|
@@ -38487,9 +39392,9 @@ function buildRuntimeCode2(runtimeDir) {
|
|
|
38487
39392
|
];
|
|
38488
39393
|
let code = "";
|
|
38489
39394
|
for (const f of runtimeFiles) {
|
|
38490
|
-
const p =
|
|
39395
|
+
const p = join11(runtimeDir, f);
|
|
38491
39396
|
if (existsSync19(p)) {
|
|
38492
|
-
let src2 =
|
|
39397
|
+
let src2 = readFileSync17(p, "utf-8");
|
|
38493
39398
|
src2 = stripTypes2(src2);
|
|
38494
39399
|
src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
38495
39400
|
src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
|
|
@@ -38501,7 +39406,7 @@ ${src2}
|
|
|
38501
39406
|
`;
|
|
38502
39407
|
}
|
|
38503
39408
|
}
|
|
38504
|
-
const indexSrc =
|
|
39409
|
+
const indexSrc = readFileSync17(join11(runtimeDir, "index-client.js"), "utf-8");
|
|
38505
39410
|
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())) || [];
|
|
38506
39411
|
code += "// --- exports ---\n";
|
|
38507
39412
|
for (const name of [...new Set(exportNames)]) {
|
|
@@ -38512,7 +39417,7 @@ ${src2}
|
|
|
38512
39417
|
return code;
|
|
38513
39418
|
}
|
|
38514
39419
|
function runtimeExportNames2(runtimeDir) {
|
|
38515
|
-
const indexSrc =
|
|
39420
|
+
const indexSrc = readFileSync17(join11(runtimeDir, "index-client.js"), "utf-8");
|
|
38516
39421
|
const names = /* @__PURE__ */ new Set();
|
|
38517
39422
|
for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
|
|
38518
39423
|
for (const raw2 of m[1].split(",")) {
|
|
@@ -38532,7 +39437,7 @@ async function buildTreeShakenRuntime2(runtimeDir, usedNames) {
|
|
|
38532
39437
|
console.error(`vesk: runtime names not exported \u2014 ${missing.join(", ")}; falling back to full runtime`);
|
|
38533
39438
|
return buildRuntimeCode2(runtimeDir);
|
|
38534
39439
|
}
|
|
38535
|
-
const entry =
|
|
39440
|
+
const entry = join11(runtimeDir, `.runtime-tree-entry-${runtimeEntryId2++}.mjs`);
|
|
38536
39441
|
try {
|
|
38537
39442
|
writeFileSync9(entry, `export { ${unique.join(", ")} } from './index-client.js';
|
|
38538
39443
|
`);
|
|
@@ -38658,10 +39563,10 @@ if (typeof document !== 'undefined') __router.start();
|
|
|
38658
39563
|
}
|
|
38659
39564
|
|
|
38660
39565
|
// ../adapter/dist/paths.js
|
|
38661
|
-
import { resolve as
|
|
39566
|
+
import { resolve as resolve21, sep as sep4 } from "node:path";
|
|
38662
39567
|
function resolveWithin2(baseDir, relPath) {
|
|
38663
|
-
const base =
|
|
38664
|
-
const target =
|
|
39568
|
+
const base = resolve21(baseDir);
|
|
39569
|
+
const target = resolve21(baseDir, relPath);
|
|
38665
39570
|
const prefix = base + sep4;
|
|
38666
39571
|
if (!target.startsWith(prefix))
|
|
38667
39572
|
return null;
|
|
@@ -38728,13 +39633,13 @@ function urlAuthority3(url) {
|
|
|
38728
39633
|
|
|
38729
39634
|
// src/build-packages.ts
|
|
38730
39635
|
import { spawnSync } from "node:child_process";
|
|
38731
|
-
import { cpSync, existsSync as existsSync20, mkdirSync as mkdirSync7, readFileSync as
|
|
38732
|
-
import { createRequire as
|
|
38733
|
-
import { dirname as
|
|
39636
|
+
import { cpSync, existsSync as existsSync20, mkdirSync as mkdirSync7, readFileSync as readFileSync18, readdirSync as readdirSync9, statSync as statSync13, writeFileSync as writeFileSync10 } from "node:fs";
|
|
39637
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
39638
|
+
import { dirname as dirname14, join as join12, resolve as resolve22 } from "node:path";
|
|
38734
39639
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
38735
|
-
var require2 =
|
|
38736
|
-
var __dirname8 =
|
|
38737
|
-
var root2 =
|
|
39640
|
+
var require2 = createRequire3(import.meta.url);
|
|
39641
|
+
var __dirname8 = dirname14(fileURLToPath7(import.meta.url));
|
|
39642
|
+
var root2 = resolve22(__dirname8, "..", "..", "..");
|
|
38738
39643
|
var PACKAGES = {
|
|
38739
39644
|
// types first — it is a dependency-free leaf that compiler and adapter
|
|
38740
39645
|
// import for their shared type definitions.
|
|
@@ -38750,8 +39655,8 @@ var PACKAGES = {
|
|
|
38750
39655
|
function newestSourceMtime(srcDir) {
|
|
38751
39656
|
let newest = 0;
|
|
38752
39657
|
for (const name of readdirSync9(srcDir)) {
|
|
38753
|
-
const p =
|
|
38754
|
-
const st =
|
|
39658
|
+
const p = join12(srcDir, name);
|
|
39659
|
+
const st = statSync13(p);
|
|
38755
39660
|
if (st.isDirectory()) {
|
|
38756
39661
|
newest = Math.max(newest, newestSourceMtime(p));
|
|
38757
39662
|
} else if (st.isFile() && /\.ts$/.test(name) && !name.endsWith(".test.ts")) {
|
|
@@ -38761,11 +39666,11 @@ function newestSourceMtime(srcDir) {
|
|
|
38761
39666
|
return newest;
|
|
38762
39667
|
}
|
|
38763
39668
|
function distStale(pkgDir, entry) {
|
|
38764
|
-
const distIndex =
|
|
39669
|
+
const distIndex = join12(pkgDir, "dist", `${entry}.js`);
|
|
38765
39670
|
if (!existsSync20(distIndex)) return true;
|
|
38766
|
-
const distPkg =
|
|
38767
|
-
const distStamp = Math.max(
|
|
38768
|
-
return newestSourceMtime(
|
|
39671
|
+
const distPkg = join12(pkgDir, "dist", "package.json");
|
|
39672
|
+
const distStamp = Math.max(statSync13(distIndex).mtimeMs, existsSync20(distPkg) ? statSync13(distPkg).mtimeMs : 0);
|
|
39673
|
+
return newestSourceMtime(join12(pkgDir, "src")) > distStamp;
|
|
38769
39674
|
}
|
|
38770
39675
|
function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
38771
39676
|
const exports = {
|
|
@@ -38788,38 +39693,38 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
|
|
|
38788
39693
|
}
|
|
38789
39694
|
function buildPackages(force = false) {
|
|
38790
39695
|
for (const [pkg, cfg] of Object.entries(PACKAGES)) {
|
|
38791
|
-
const pkgDir =
|
|
38792
|
-
if (!existsSync20(
|
|
39696
|
+
const pkgDir = resolve22(root2, "packages", pkg);
|
|
39697
|
+
if (!existsSync20(join12(pkgDir, "src"))) continue;
|
|
38793
39698
|
if (!force && !distStale(pkgDir, cfg.entry)) continue;
|
|
38794
39699
|
console.log(`[build] ${cfg.name} -> tsc`);
|
|
38795
39700
|
const tscBin = require2.resolve("typescript/bin/tsc");
|
|
38796
|
-
const result2 = spawnSync(process.execPath, [tscBin, "-p",
|
|
39701
|
+
const result2 = spawnSync(process.execPath, [tscBin, "-p", join12(pkgDir, "tsconfig.build.json")], {
|
|
38797
39702
|
stdio: "inherit"
|
|
38798
39703
|
});
|
|
38799
39704
|
if (result2.status !== 0) {
|
|
38800
39705
|
throw new Error(`tsc failed for ${cfg.name}`);
|
|
38801
39706
|
}
|
|
38802
|
-
const distDir =
|
|
39707
|
+
const distDir = join12(pkgDir, "dist");
|
|
38803
39708
|
for (const c of cfg.copy || []) {
|
|
38804
|
-
const to =
|
|
38805
|
-
mkdirSync7(
|
|
38806
|
-
cpSync(
|
|
39709
|
+
const to = join12(distDir, c.to);
|
|
39710
|
+
mkdirSync7(dirname14(to), { recursive: true });
|
|
39711
|
+
cpSync(join12(pkgDir, c.from), to, { recursive: true });
|
|
38807
39712
|
}
|
|
38808
|
-
const srcPkg = JSON.parse(
|
|
38809
|
-
writeFileSync10(
|
|
39713
|
+
const srcPkg = JSON.parse(readFileSync18(join12(pkgDir, "package.json"), "utf-8"));
|
|
39714
|
+
writeFileSync10(join12(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
|
|
38810
39715
|
console.log(`[build] ${cfg.name} -> dist`);
|
|
38811
39716
|
}
|
|
38812
39717
|
}
|
|
38813
39718
|
function ensurePackagesBuilt() {
|
|
38814
39719
|
buildPackages(false);
|
|
38815
39720
|
}
|
|
38816
|
-
if (process.argv[1] &&
|
|
39721
|
+
if (process.argv[1] && resolve22(process.argv[1]) === fileURLToPath7(import.meta.url)) {
|
|
38817
39722
|
buildPackages(process.argv.includes("--force"));
|
|
38818
39723
|
}
|
|
38819
39724
|
|
|
38820
39725
|
// src/action-handler.ts
|
|
38821
|
-
import { existsSync as existsSync21, readFileSync as
|
|
38822
|
-
import { resolve as
|
|
39726
|
+
import { existsSync as existsSync21, readFileSync as readFileSync19, readdirSync as readdirSync10 } from "node:fs";
|
|
39727
|
+
import { resolve as resolve23 } from "node:path";
|
|
38823
39728
|
|
|
38824
39729
|
// ../compiler/dist/server-cookies.js
|
|
38825
39730
|
function parseCookies3(str) {
|
|
@@ -38896,8 +39801,8 @@ function pageSourcesFor(appDirPath, routeTree) {
|
|
|
38896
39801
|
const out = [];
|
|
38897
39802
|
function walk6(nodes) {
|
|
38898
39803
|
for (const node of nodes) {
|
|
38899
|
-
if (node.page) out.push(
|
|
38900
|
-
if (node.layout) out.push(
|
|
39804
|
+
if (node.page) out.push(resolve23(appDirPath, node.sourceDir, "page.vsk"));
|
|
39805
|
+
if (node.layout) out.push(resolve23(appDirPath, node.sourceDir, "layout.vsk"));
|
|
38901
39806
|
walk6(node.children);
|
|
38902
39807
|
}
|
|
38903
39808
|
}
|
|
@@ -38913,7 +39818,7 @@ function walkVskFiles(dir, out, seen) {
|
|
|
38913
39818
|
return;
|
|
38914
39819
|
}
|
|
38915
39820
|
for (const entry of entries) {
|
|
38916
|
-
const full =
|
|
39821
|
+
const full = resolve23(dir, entry.name);
|
|
38917
39822
|
if (seen.has(full)) continue;
|
|
38918
39823
|
seen.add(full);
|
|
38919
39824
|
if (entry.isDirectory()) {
|
|
@@ -38933,8 +39838,8 @@ function candidateSources(appDirPath, routeTree) {
|
|
|
38933
39838
|
seen.add(src2);
|
|
38934
39839
|
out.push(src2);
|
|
38935
39840
|
}
|
|
38936
|
-
const projectRoot =
|
|
38937
|
-
for (const dir of [
|
|
39841
|
+
const projectRoot = resolve23(appDirPath, "..");
|
|
39842
|
+
for (const dir of [resolve23(projectRoot, "components"), appDirPath, projectRoot]) {
|
|
38938
39843
|
walkVskFiles(dir, out, seen);
|
|
38939
39844
|
}
|
|
38940
39845
|
return out;
|
|
@@ -38942,7 +39847,7 @@ function candidateSources(appDirPath, routeTree) {
|
|
|
38942
39847
|
function registerSource(sourcePath2) {
|
|
38943
39848
|
if (!existsSync21(sourcePath2)) return;
|
|
38944
39849
|
try {
|
|
38945
|
-
compileFile(
|
|
39850
|
+
compileFile(readFileSync19(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
|
|
38946
39851
|
} catch {
|
|
38947
39852
|
}
|
|
38948
39853
|
}
|
|
@@ -38951,8 +39856,8 @@ function ensureActionRegistered(actionId, pagePathname, appDirPath, routeTree) {
|
|
|
38951
39856
|
const match = matchUrl(routeTree, pagePathname);
|
|
38952
39857
|
if (match) {
|
|
38953
39858
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
38954
|
-
registerSource(
|
|
38955
|
-
registerSource(
|
|
39859
|
+
registerSource(resolve23(appDirPath, match.nodes[i].sourceDir, "page.vsk"));
|
|
39860
|
+
registerSource(resolve23(appDirPath, match.nodes[i].sourceDir, "layout.vsk"));
|
|
38956
39861
|
}
|
|
38957
39862
|
}
|
|
38958
39863
|
if (getAction2(actionId)) return;
|
|
@@ -38978,24 +39883,24 @@ async function renderPageHtml(pagePathname, params, ctx2) {
|
|
|
38978
39883
|
let head = "";
|
|
38979
39884
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
38980
39885
|
const node = chain[i];
|
|
38981
|
-
const pageFilePath =
|
|
38982
|
-
const layoutFilePath =
|
|
39886
|
+
const pageFilePath = resolve23(ctx2.appDirPath, node.sourceDir, "page.vsk");
|
|
39887
|
+
const layoutFilePath = resolve23(ctx2.appDirPath, node.sourceDir, "layout.vsk");
|
|
38983
39888
|
if (i === chain.length - 1 && node.page && existsSync21(pageFilePath)) {
|
|
38984
|
-
const src3 =
|
|
39889
|
+
const src3 = readFileSync19(pageFilePath, "utf-8");
|
|
38985
39890
|
const compName2 = resolveComponentName(src3) || node.page;
|
|
38986
39891
|
const result2 = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
38987
39892
|
body = result2.body;
|
|
38988
39893
|
head = result2.head || "";
|
|
38989
39894
|
}
|
|
38990
39895
|
if (node.layout && existsSync21(layoutFilePath)) {
|
|
38991
|
-
const src3 =
|
|
39896
|
+
const src3 = readFileSync19(layoutFilePath, "utf-8");
|
|
38992
39897
|
const compName2 = resolveComponentName(src3) || node.layout;
|
|
38993
39898
|
const result2 = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
38994
39899
|
body = result2.body;
|
|
38995
39900
|
head = (result2.head || "") + head;
|
|
38996
39901
|
}
|
|
38997
39902
|
}
|
|
38998
|
-
const hasLayout = chain.some((n) => n.layout && existsSync21(
|
|
39903
|
+
const hasLayout = chain.some((n) => n.layout && existsSync21(resolve23(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
|
|
38999
39904
|
if (hasLayout) {
|
|
39000
39905
|
const secMeta = securityMeta(ctx2.security);
|
|
39001
39906
|
return `<!DOCTYPE html>
|
|
@@ -39017,9 +39922,9 @@ ${prettifyHtml(body)}
|
|
|
39017
39922
|
}
|
|
39018
39923
|
const leaf = chain.find((n) => n.page);
|
|
39019
39924
|
if (!leaf) return null;
|
|
39020
|
-
const src2 =
|
|
39925
|
+
const src2 = readFileSync19(resolve23(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
39021
39926
|
const compName = resolveComponentName(src2) || leaf.page;
|
|
39022
|
-
const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security: ctx2.security, sourcePath:
|
|
39927
|
+
const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security: ctx2.security, sourcePath: resolve23(ctx2.appDirPath, leaf.sourceDir, "page.vsk") });
|
|
39023
39928
|
return html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
|
|
39024
39929
|
}
|
|
39025
39930
|
async function handleActionRequest(req, res, ctx2) {
|
|
@@ -39163,14 +40068,14 @@ async function handleActionRequest(req, res, ctx2) {
|
|
|
39163
40068
|
function resolveRuntimeDir(projectDir2) {
|
|
39164
40069
|
const candidates = [
|
|
39165
40070
|
// installed app layout
|
|
39166
|
-
|
|
40071
|
+
resolve24(projectDir2, "node_modules", "@vesk", "runtime"),
|
|
39167
40072
|
// monorepo checkout (tests/probes run from the repo root)
|
|
39168
|
-
|
|
40073
|
+
resolve24(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
|
|
39169
40074
|
];
|
|
39170
40075
|
for (const dir of candidates) {
|
|
39171
|
-
if (existsSync22(
|
|
39172
|
-
const distDir =
|
|
39173
|
-
if (existsSync22(
|
|
40076
|
+
if (existsSync22(join13(dir, "ripple-runtime.js"))) return dir;
|
|
40077
|
+
const distDir = join13(dir, "dist");
|
|
40078
|
+
if (existsSync22(join13(distDir, "ripple-runtime.js"))) return distDir;
|
|
39174
40079
|
}
|
|
39175
40080
|
return null;
|
|
39176
40081
|
}
|
|
@@ -39243,7 +40148,7 @@ function countFilesNamed(dir, name) {
|
|
|
39243
40148
|
if (!existsSync22(dir)) return 0;
|
|
39244
40149
|
let n = 0;
|
|
39245
40150
|
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
39246
|
-
const p =
|
|
40151
|
+
const p = join13(dir, entry.name);
|
|
39247
40152
|
if (entry.isDirectory()) n += countFilesNamed(p, name);
|
|
39248
40153
|
else if (entry.name === name) n++;
|
|
39249
40154
|
}
|
|
@@ -39254,8 +40159,8 @@ async function startDevServer(port2, projectDir2, config, host2) {
|
|
|
39254
40159
|
if (!process.env.NODE_ENV) process.env.NODE_ENV = "development";
|
|
39255
40160
|
const secCfg = config.security || {};
|
|
39256
40161
|
const maxBodyBytes2 = (typeof secCfg.maxBodyBytes === "number" ? secCfg.maxBodyBytes : void 0) || DEFAULT_MAX_BODY_BYTES;
|
|
39257
|
-
const appDirPath =
|
|
39258
|
-
const publicDir =
|
|
40162
|
+
const appDirPath = join13(projectDir2, "app");
|
|
40163
|
+
const publicDir = join13(projectDir2, "public");
|
|
39259
40164
|
try {
|
|
39260
40165
|
ensurePackagesBuilt();
|
|
39261
40166
|
} catch (e) {
|
|
@@ -39272,14 +40177,14 @@ async function startDevServer(port2, projectDir2, config, host2) {
|
|
|
39272
40177
|
let devTailwindCssContent = "";
|
|
39273
40178
|
let lastServedCssGlobal = "";
|
|
39274
40179
|
let lastServedCssTailwind = "";
|
|
39275
|
-
const srcDir =
|
|
39276
|
-
const cssPath =
|
|
39277
|
-
const altCssPath =
|
|
40180
|
+
const srcDir = join13(projectDir2, "src");
|
|
40181
|
+
const cssPath = join13(srcDir, "global.css");
|
|
40182
|
+
const altCssPath = join13(srcDir, "app.css");
|
|
39278
40183
|
let rawCss = "";
|
|
39279
40184
|
if (existsSync22(cssPath)) {
|
|
39280
|
-
rawCss =
|
|
40185
|
+
rawCss = readFileSync20(cssPath, "utf-8");
|
|
39281
40186
|
} else if (existsSync22(altCssPath)) {
|
|
39282
|
-
rawCss =
|
|
40187
|
+
rawCss = readFileSync20(altCssPath, "utf-8");
|
|
39283
40188
|
}
|
|
39284
40189
|
if (rawCss) {
|
|
39285
40190
|
for (const plugin of devPlugins) {
|
|
@@ -39413,7 +40318,7 @@ async function startDevServer(port2, projectDir2, config, host2) {
|
|
|
39413
40318
|
const isCss = filename.endsWith(".css");
|
|
39414
40319
|
const isApiRoute = filename.endsWith(".ts") || filename.endsWith(".js") || filename.endsWith(".tsx");
|
|
39415
40320
|
if (!isVsk && !isCss && !isApiRoute) return;
|
|
39416
|
-
const fullPath = filename.startsWith("/") ? filename :
|
|
40321
|
+
const fullPath = filename.startsWith("/") ? filename : join13(watchDir, filename);
|
|
39417
40322
|
const fileExists = existsSync22(fullPath);
|
|
39418
40323
|
if (isVsk) {
|
|
39419
40324
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
@@ -39463,7 +40368,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39463
40368
|
if (compCode.trim()) fnSources = { _raw: compCode };
|
|
39464
40369
|
} else if (fileExists && !bundleError) {
|
|
39465
40370
|
try {
|
|
39466
|
-
const src2 =
|
|
40371
|
+
const src2 = readFileSync20(fullPath, "utf-8");
|
|
39467
40372
|
let compCode = compileClient2(src2, null, { forceClient: true, sourcePath: fullPath, mdRoots: [projectDir2] });
|
|
39468
40373
|
compCode = compCode.replace(/^import\s*[\s\S]*?from\s*['"][^'"]+['"];?\s*\n?/gm, "");
|
|
39469
40374
|
compCode = compCode.replace(/^const __components = \{\};\s*\n?/m, "");
|
|
@@ -39519,7 +40424,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39519
40424
|
let code = "";
|
|
39520
40425
|
if (line > 0 && fileExists) {
|
|
39521
40426
|
try {
|
|
39522
|
-
const src2 =
|
|
40427
|
+
const src2 = readFileSync20(fullPath, "utf-8");
|
|
39523
40428
|
const lines = src2.split("\n");
|
|
39524
40429
|
const start = Math.max(0, line - 3);
|
|
39525
40430
|
const end = Math.min(lines.length, line + 2);
|
|
@@ -39570,7 +40475,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39570
40475
|
cssDebounceTimer = setTimeout(async () => {
|
|
39571
40476
|
try {
|
|
39572
40477
|
if (fileExists) {
|
|
39573
|
-
rawCss =
|
|
40478
|
+
rawCss = readFileSync20(fullPath, "utf-8");
|
|
39574
40479
|
}
|
|
39575
40480
|
const cssChanged = await rebuildTailwindCss();
|
|
39576
40481
|
if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
|
|
@@ -39602,8 +40507,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39602
40507
|
".html": "text/html",
|
|
39603
40508
|
".json": "application/json"
|
|
39604
40509
|
};
|
|
39605
|
-
const hmrJsPath =
|
|
39606
|
-
const hmrTsPath =
|
|
40510
|
+
const hmrJsPath = join13(runtimeDir, "hmr-client.js");
|
|
40511
|
+
const hmrTsPath = join13(runtimeDir, "hmr-client.ts");
|
|
39607
40512
|
const hmrClientPath = existsSync22(hmrJsPath) ? hmrJsPath : existsSync22(hmrTsPath) ? hmrTsPath : null;
|
|
39608
40513
|
function extractCompName2(src2) {
|
|
39609
40514
|
return resolveComponentName(src2);
|
|
@@ -39705,7 +40610,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39705
40610
|
}
|
|
39706
40611
|
if (url.pathname === "/_vesk/hmr" || url.pathname === "/_vesk/hmr.js") {
|
|
39707
40612
|
if (hmrClientPath) {
|
|
39708
|
-
let hmrContent =
|
|
40613
|
+
let hmrContent = readFileSync20(hmrClientPath, "utf-8");
|
|
39709
40614
|
if (hmrClientPath.endsWith(".ts")) {
|
|
39710
40615
|
hmrContent = stripCodeTypes2(hmrContent);
|
|
39711
40616
|
}
|
|
@@ -39719,15 +40624,15 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39719
40624
|
}
|
|
39720
40625
|
if (url.pathname !== "/") {
|
|
39721
40626
|
const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
|
|
39722
|
-
if (staticPath && existsSync22(staticPath) &&
|
|
39723
|
-
const ext =
|
|
40627
|
+
if (staticPath && existsSync22(staticPath) && statSync14(staticPath).isFile()) {
|
|
40628
|
+
const ext = extname6(staticPath);
|
|
39724
40629
|
res.writeHead(200, { "Content-Type": MIME3[ext] || "application/octet-stream" });
|
|
39725
|
-
res.end(
|
|
40630
|
+
res.end(readFileSync20(staticPath));
|
|
39726
40631
|
return;
|
|
39727
40632
|
}
|
|
39728
40633
|
}
|
|
39729
40634
|
const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
|
|
39730
|
-
const apiDirPath =
|
|
40635
|
+
const apiDirPath = join13(appDirPath, "api");
|
|
39731
40636
|
if (url.pathname.startsWith("/api") && existsSync22(apiDirPath)) {
|
|
39732
40637
|
const apiRoutes = await scanApiRoutes(apiDirPath);
|
|
39733
40638
|
const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
|
|
@@ -39803,10 +40708,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39803
40708
|
const rootNode = routeTree.find((n) => n.fullPath === "/");
|
|
39804
40709
|
let notFoundHtml = null;
|
|
39805
40710
|
if (rootNode && rootNode.notFound) {
|
|
39806
|
-
const nfPath =
|
|
40711
|
+
const nfPath = resolve24(appDirPath, rootNode.sourceDir, "not-found.vsk");
|
|
39807
40712
|
if (existsSync22(nfPath)) {
|
|
39808
40713
|
try {
|
|
39809
|
-
const nfSrc =
|
|
40714
|
+
const nfSrc = readFileSync20(nfPath, "utf-8");
|
|
39810
40715
|
const nfCompName = extractCompName2(nfSrc) || rootNode.notFound;
|
|
39811
40716
|
notFoundHtml = await renderFullPage(nfSrc, nfCompName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: nfPath });
|
|
39812
40717
|
} catch {
|
|
@@ -39843,10 +40748,10 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39843
40748
|
let props;
|
|
39844
40749
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
39845
40750
|
const node = chain[i];
|
|
39846
|
-
const pageFilePath =
|
|
39847
|
-
const layoutFilePath =
|
|
40751
|
+
const pageFilePath = resolve24(appDirPath, node.sourceDir, "page.vsk");
|
|
40752
|
+
const layoutFilePath = resolve24(appDirPath, node.sourceDir, "layout.vsk");
|
|
39848
40753
|
if (i === chain.length - 1 && node.page && existsSync22(pageFilePath)) {
|
|
39849
|
-
const src2 =
|
|
40754
|
+
const src2 = readFileSync20(pageFilePath, "utf-8");
|
|
39850
40755
|
const compName = extractCompName2(src2) || node.page;
|
|
39851
40756
|
const result2 = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
39852
40757
|
body = result2.body;
|
|
@@ -39854,7 +40759,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39854
40759
|
props = result2.props;
|
|
39855
40760
|
}
|
|
39856
40761
|
if (node.layout && existsSync22(layoutFilePath)) {
|
|
39857
|
-
const src2 =
|
|
40762
|
+
const src2 = readFileSync20(layoutFilePath, "utf-8");
|
|
39858
40763
|
const compName = extractCompName2(src2) || node.layout;
|
|
39859
40764
|
const result2 = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
39860
40765
|
body = result2.body;
|
|
@@ -39864,7 +40769,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
39864
40769
|
if (forData) {
|
|
39865
40770
|
return { html: "", props: props || { params: matched.params }, head };
|
|
39866
40771
|
}
|
|
39867
|
-
const hasLayout = chain.some((n) => n.layout && existsSync22(
|
|
40772
|
+
const hasLayout = chain.some((n) => n.layout && existsSync22(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
|
|
39868
40773
|
let html;
|
|
39869
40774
|
if (hasLayout) {
|
|
39870
40775
|
const ssrData = ssrSink3.snapshot();
|
|
@@ -39896,9 +40801,9 @@ ${prettifyHtml(body)}
|
|
|
39896
40801
|
} else {
|
|
39897
40802
|
const leaf = chain.find((n) => n.page);
|
|
39898
40803
|
if (leaf) {
|
|
39899
|
-
const src2 =
|
|
40804
|
+
const src2 = readFileSync20(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
39900
40805
|
const compName = extractCompName2(src2) || leaf.page;
|
|
39901
|
-
html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath:
|
|
40806
|
+
html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: resolve24(appDirPath, leaf.sourceDir, "page.vsk") });
|
|
39902
40807
|
html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
|
|
39903
40808
|
} else {
|
|
39904
40809
|
throw new Error("No page or layout matched");
|
|
@@ -39910,13 +40815,13 @@ ${prettifyHtml(body)}
|
|
|
39910
40815
|
function renderSSRStream() {
|
|
39911
40816
|
async function* raw2() {
|
|
39912
40817
|
const chain = cleanChain;
|
|
39913
|
-
const hasLayout = chain.some((n) => n.layout && existsSync22(
|
|
40818
|
+
const hasLayout = chain.some((n) => n.layout && existsSync22(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
|
|
39914
40819
|
if (!hasLayout) {
|
|
39915
40820
|
const leaf = chain.find((n) => n.page);
|
|
39916
40821
|
if (leaf) {
|
|
39917
|
-
const src2 =
|
|
40822
|
+
const src2 = readFileSync20(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
|
|
39918
40823
|
const compName = extractCompName2(src2) || leaf.page;
|
|
39919
|
-
yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath:
|
|
40824
|
+
yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: resolve24(appDirPath, leaf.sourceDir, "page.vsk") });
|
|
39920
40825
|
} else {
|
|
39921
40826
|
throw new Error("No page or layout matched");
|
|
39922
40827
|
}
|
|
@@ -39927,10 +40832,10 @@ ${prettifyHtml(body)}
|
|
|
39927
40832
|
let props;
|
|
39928
40833
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
39929
40834
|
const node = chain[i];
|
|
39930
|
-
const pageFilePath =
|
|
39931
|
-
const layoutFilePath =
|
|
40835
|
+
const pageFilePath = resolve24(appDirPath, node.sourceDir, "page.vsk");
|
|
40836
|
+
const layoutFilePath = resolve24(appDirPath, node.sourceDir, "layout.vsk");
|
|
39932
40837
|
if (i === chain.length - 1 && node.page && existsSync22(pageFilePath)) {
|
|
39933
|
-
const src2 =
|
|
40838
|
+
const src2 = readFileSync20(pageFilePath, "utf-8");
|
|
39934
40839
|
const compName = extractCompName2(src2) || node.page;
|
|
39935
40840
|
const result2 = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
|
|
39936
40841
|
body = result2.body;
|
|
@@ -39938,7 +40843,7 @@ ${prettifyHtml(body)}
|
|
|
39938
40843
|
props = result2.props;
|
|
39939
40844
|
}
|
|
39940
40845
|
if (node.layout && existsSync22(layoutFilePath)) {
|
|
39941
|
-
const src2 =
|
|
40846
|
+
const src2 = readFileSync20(layoutFilePath, "utf-8");
|
|
39942
40847
|
const compName = extractCompName2(src2) || node.layout;
|
|
39943
40848
|
const result2 = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
|
|
39944
40849
|
body = result2.body;
|
|
@@ -40065,10 +40970,10 @@ ${prettifyHtml(body)}
|
|
|
40065
40970
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
40066
40971
|
const node = match.nodes[i];
|
|
40067
40972
|
if (node.notFound) {
|
|
40068
|
-
const nfPath =
|
|
40973
|
+
const nfPath = resolve24(appDirPath, node.sourceDir, "not-found.vsk");
|
|
40069
40974
|
if (existsSync22(nfPath)) {
|
|
40070
40975
|
try {
|
|
40071
|
-
const nfSrc =
|
|
40976
|
+
const nfSrc = readFileSync20(nfPath, "utf-8");
|
|
40072
40977
|
const nfCompName = extractCompName2(nfSrc) || node.notFound;
|
|
40073
40978
|
const html = await renderFullPage(nfSrc, nfCompName, { params: match.params, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: nfPath });
|
|
40074
40979
|
notFoundHtml = html.replace(
|
|
@@ -40093,10 +40998,10 @@ ${prettifyHtml(body)}
|
|
|
40093
40998
|
for (let i = match.nodes.length - 1; i >= 0; i--) {
|
|
40094
40999
|
const node = match.nodes[i];
|
|
40095
41000
|
if (node.error) {
|
|
40096
|
-
const errPath =
|
|
41001
|
+
const errPath = resolve24(appDirPath, node.sourceDir, "error.vsk");
|
|
40097
41002
|
if (existsSync22(errPath)) {
|
|
40098
41003
|
try {
|
|
40099
|
-
const errSrc =
|
|
41004
|
+
const errSrc = readFileSync20(errPath, "utf-8");
|
|
40100
41005
|
const errCompName = extractCompName2(errSrc) || node.error;
|
|
40101
41006
|
const errProps = { error: err.message, stack: err.stack, statusCode: errorStatusCode(err), url: url.pathname };
|
|
40102
41007
|
const html = await renderFullPage(errSrc, errCompName, errProps, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: errPath });
|
|
@@ -40130,7 +41035,7 @@ ${err.stack}</pre></body></html>`);
|
|
|
40130
41035
|
LOG.ok(`dev server at http://localhost:${port2} (listening on ${bindHost})`);
|
|
40131
41036
|
const routes = collectRoutePaths(routeTree);
|
|
40132
41037
|
const pageCount = countPages(routeTree);
|
|
40133
|
-
const apiCount = countFilesNamed(
|
|
41038
|
+
const apiCount = countFilesNamed(join13(appDirPath, "api"), "route.ts");
|
|
40134
41039
|
LOG.info(`${projectDir2}`);
|
|
40135
41040
|
LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
|
|
40136
41041
|
if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
|
|
@@ -40359,7 +41264,7 @@ init_action();
|
|
|
40359
41264
|
|
|
40360
41265
|
// src/index.ts
|
|
40361
41266
|
var __filename2 = fileURLToPath8(import.meta.url);
|
|
40362
|
-
var __dirname9 =
|
|
41267
|
+
var __dirname9 = resolve26(__filename2, "..");
|
|
40363
41268
|
var args = process.argv.slice(2);
|
|
40364
41269
|
var cmd = args[0];
|
|
40365
41270
|
function usage(code = 0) {
|
|
@@ -40402,12 +41307,12 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
|
40402
41307
|
}
|
|
40403
41308
|
function loadEnvFiles(projectDir2) {
|
|
40404
41309
|
const files = [
|
|
40405
|
-
|
|
40406
|
-
|
|
41310
|
+
join15(projectDir2, ".env"),
|
|
41311
|
+
join15(projectDir2, ".env.local")
|
|
40407
41312
|
];
|
|
40408
41313
|
for (const filePath of files) {
|
|
40409
41314
|
if (!existsSync23(filePath)) continue;
|
|
40410
|
-
const content =
|
|
41315
|
+
const content = readFileSync22(filePath, "utf-8");
|
|
40411
41316
|
for (const line of content.split("\n")) {
|
|
40412
41317
|
const trimmed = line.trim();
|
|
40413
41318
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -40426,8 +41331,8 @@ function loadEnvFiles(projectDir2) {
|
|
|
40426
41331
|
}
|
|
40427
41332
|
async function loadConfig(projectDir2) {
|
|
40428
41333
|
loadEnvFiles(projectDir2);
|
|
40429
|
-
const jsPath =
|
|
40430
|
-
const tsPath =
|
|
41334
|
+
const jsPath = join15(projectDir2, "vesk.config.js");
|
|
41335
|
+
const tsPath = join15(projectDir2, "vesk.config.ts");
|
|
40431
41336
|
let configPath2 = null;
|
|
40432
41337
|
if (existsSync23(jsPath)) configPath2 = jsPath;
|
|
40433
41338
|
else if (existsSync23(tsPath)) configPath2 = tsPath;
|
|
@@ -40435,13 +41340,13 @@ async function loadConfig(projectDir2) {
|
|
|
40435
41340
|
let raw2;
|
|
40436
41341
|
if (configPath2.endsWith(".ts")) {
|
|
40437
41342
|
const { transpile: transpile2 } = await import("typescript");
|
|
40438
|
-
const src2 =
|
|
41343
|
+
const src2 = readFileSync22(configPath2, "utf-8");
|
|
40439
41344
|
let js = transpile2(src2, { module: 99, target: 99 });
|
|
40440
41345
|
js = js.replace(/import\s+\{[^}]*\}\s*from\s+['"]@vesk\/compiler['"]\s*;?\s*/g, "");
|
|
40441
41346
|
js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
|
|
40442
41347
|
` + js;
|
|
40443
|
-
const tmpFile =
|
|
40444
|
-
mkdirSync9(
|
|
41348
|
+
const tmpFile = join15(projectDir2, ".vesk", "config.tmp.js");
|
|
41349
|
+
mkdirSync9(dirname16(tmpFile), { recursive: true });
|
|
40445
41350
|
writeFileSync11(tmpFile, js, "utf-8");
|
|
40446
41351
|
globalThis.__vesk_inject = { defineConfig, definePlugin, preset };
|
|
40447
41352
|
raw2 = (await import(tmpFile)).default;
|
|
@@ -40462,8 +41367,8 @@ async function loadConfig(projectDir2) {
|
|
|
40462
41367
|
}
|
|
40463
41368
|
if (cmd === "build") {
|
|
40464
41369
|
const projectDir2 = process.cwd();
|
|
40465
|
-
const appDirPath =
|
|
40466
|
-
const publicDir =
|
|
41370
|
+
const appDirPath = join15(projectDir2, "app");
|
|
41371
|
+
const publicDir = join15(projectDir2, "public");
|
|
40467
41372
|
if (!existsSync23(appDirPath)) {
|
|
40468
41373
|
console.error(`vesk build: no app/ directory found in ${projectDir2}`);
|
|
40469
41374
|
process.exit(1);
|
|
@@ -40502,7 +41407,7 @@ if (cmd === "build") {
|
|
|
40502
41407
|
}
|
|
40503
41408
|
if (cmd === "seo") {
|
|
40504
41409
|
const projectDir2 = process.cwd();
|
|
40505
|
-
const appDirPath =
|
|
41410
|
+
const appDirPath = join15(projectDir2, "app");
|
|
40506
41411
|
if (!existsSync23(appDirPath)) {
|
|
40507
41412
|
console.error(`vesk seo: no app/ directory found in ${projectDir2}`);
|
|
40508
41413
|
process.exit(1);
|
|
@@ -40517,7 +41422,7 @@ if (cmd === "seo") {
|
|
|
40517
41422
|
}
|
|
40518
41423
|
if (cmd === "typecheck") {
|
|
40519
41424
|
const projectDir2 = process.cwd();
|
|
40520
|
-
const appDirPath =
|
|
41425
|
+
const appDirPath = join15(projectDir2, "app");
|
|
40521
41426
|
if (!existsSync23(appDirPath)) {
|
|
40522
41427
|
console.error(`vesk typecheck: no app/ directory found in ${projectDir2}`);
|
|
40523
41428
|
process.exit(1);
|
|
@@ -40542,7 +41447,7 @@ if (cmd === "typecheck") {
|
|
|
40542
41447
|
}
|
|
40543
41448
|
if (cmd === "start") {
|
|
40544
41449
|
const projectDir2 = process.cwd();
|
|
40545
|
-
const outDir2 =
|
|
41450
|
+
const outDir2 = join15(projectDir2, ".vesk");
|
|
40546
41451
|
const port2 = parsePortArg(args);
|
|
40547
41452
|
const host2 = parseHostArg(args);
|
|
40548
41453
|
startProdServer(outDir2, { port: port2, host: host2 });
|
|
@@ -40551,8 +41456,8 @@ if (cmd === "start") {
|
|
|
40551
41456
|
}
|
|
40552
41457
|
if (cmd === "init") {
|
|
40553
41458
|
const projectDir2 = process.cwd();
|
|
40554
|
-
const srcDir =
|
|
40555
|
-
const target =
|
|
41459
|
+
const srcDir = join15(projectDir2, "src");
|
|
41460
|
+
const target = join15(srcDir, "global.css");
|
|
40556
41461
|
if (existsSync23(target)) {
|
|
40557
41462
|
console.error(`vesk init: ${target} already exists \u2014 skipping`);
|
|
40558
41463
|
process.exit(0);
|
|
@@ -40571,7 +41476,7 @@ if (cmd === "init") {
|
|
|
40571
41476
|
}
|
|
40572
41477
|
if (cmd === "dev") {
|
|
40573
41478
|
const projectDir2 = process.cwd();
|
|
40574
|
-
const appDirPath =
|
|
41479
|
+
const appDirPath = join15(projectDir2, "app");
|
|
40575
41480
|
const port2 = parsePortArg(args);
|
|
40576
41481
|
const host2 = parseHostArg(args);
|
|
40577
41482
|
if (!existsSync23(appDirPath)) {
|