@vesk/vesk-cli 0.2.60 → 0.2.61
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 +440 -29
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -495,7 +495,7 @@ ${this.code}`;
|
|
|
495
495
|
});
|
|
496
496
|
|
|
497
497
|
// ../compiler/src/ir.ts
|
|
498
|
-
var Expression, IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentRef, ComponentCall, SlotNode, PropSlot, PropSlotRender, WhileLoop, SwitchCase, SwitchBlock, TryCatch, TrackDecl, RuntimeStatement, ForLoop, ServerBlock, ClientBlock, HeadBlock;
|
|
498
|
+
var Expression, IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentRef, ComponentCall, SlotNode, PropSlot, PropSlotRender, WhileLoop, SwitchCase, SwitchBlock, TryCatch, TrackDecl, RuntimeStatement, BreakSignal, ForLoop, ServerBlock, ClientBlock, HeadBlock;
|
|
499
499
|
var init_ir = __esm({
|
|
500
500
|
"../compiler/src/ir.ts"() {
|
|
501
501
|
"use strict";
|
|
@@ -742,6 +742,10 @@ var init_ir = __esm({
|
|
|
742
742
|
this.source = source;
|
|
743
743
|
}
|
|
744
744
|
};
|
|
745
|
+
BreakSignal = class {
|
|
746
|
+
constructor() {
|
|
747
|
+
}
|
|
748
|
+
};
|
|
745
749
|
ForLoop = class {
|
|
746
750
|
init;
|
|
747
751
|
condition;
|
|
@@ -4839,7 +4843,7 @@ async function renderNotFound(router, match, container) {
|
|
|
4839
4843
|
}
|
|
4840
4844
|
if (container.replaceChildren) container.replaceChildren();
|
|
4841
4845
|
else container.innerHTML = "";
|
|
4842
|
-
container.innerHTML =
|
|
4846
|
+
container.innerHTML = defaultErrorHtml(404, "Not Found");
|
|
4843
4847
|
router._currentMatch = match;
|
|
4844
4848
|
}
|
|
4845
4849
|
function defaultOfflineHtml(url) {
|
|
@@ -4848,6 +4852,9 @@ function defaultOfflineHtml(url) {
|
|
|
4848
4852
|
function escapeOfflineUrl(url) {
|
|
4849
4853
|
return String(url).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
4850
4854
|
}
|
|
4855
|
+
function defaultErrorHtml(status, message) {
|
|
4856
|
+
return '<div data-vesk-default-error="' + status + '" style="display:flex;align-items:center;justify-content:center;min-height:50vh;padding:32px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:inherit"><div style="display:flex;align-items:center"><span style="font-size:24px;font-weight:500;line-height:49px;padding-right:23px;margin-right:20px;border-right:1px solid currentColor;opacity:.85">' + status + '</span><span style="font-size:14px;line-height:49px;opacity:.7">' + message + "</span></div></div>";
|
|
4857
|
+
}
|
|
4851
4858
|
async function renderOfflinePage(router, match, container) {
|
|
4852
4859
|
const url = match.pathname || (typeof window !== "undefined" ? window.location.pathname : "");
|
|
4853
4860
|
const chain = match.matchChain;
|
|
@@ -5136,7 +5143,7 @@ function renderMatch(router, match, container, navToken) {
|
|
|
5136
5143
|
} else {
|
|
5137
5144
|
container.innerHTML = "";
|
|
5138
5145
|
}
|
|
5139
|
-
container.innerHTML =
|
|
5146
|
+
container.innerHTML = defaultErrorHtml(404, "Not Found");
|
|
5140
5147
|
return;
|
|
5141
5148
|
}
|
|
5142
5149
|
if (pageNode._pageName && (!pageNode.page || typeof pageNode.page === "string")) {
|
|
@@ -5324,7 +5331,7 @@ async function renderErrorPage(router, match, container, error) {
|
|
|
5324
5331
|
if (!errorFn) {
|
|
5325
5332
|
if (container.replaceChildren) container.replaceChildren();
|
|
5326
5333
|
else container.innerHTML = "";
|
|
5327
|
-
container.innerHTML =
|
|
5334
|
+
container.innerHTML = defaultErrorHtml(500, "Internal Server Error");
|
|
5328
5335
|
return;
|
|
5329
5336
|
}
|
|
5330
5337
|
const layoutNodes = chain.filter((n) => n.layout);
|
|
@@ -5388,7 +5395,7 @@ async function hydrateInitial(router, match, container, strategy) {
|
|
|
5388
5395
|
});
|
|
5389
5396
|
return;
|
|
5390
5397
|
}
|
|
5391
|
-
container.innerHTML =
|
|
5398
|
+
container.innerHTML = defaultErrorHtml(404, "Not Found");
|
|
5392
5399
|
return;
|
|
5393
5400
|
}
|
|
5394
5401
|
const ssrErrorMarker = (() => {
|
|
@@ -6045,7 +6052,7 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
6045
6052
|
}
|
|
6046
6053
|
})();
|
|
6047
6054
|
} else {
|
|
6048
|
-
container.innerHTML =
|
|
6055
|
+
container.innerHTML = defaultErrorHtml(404, "Not Found");
|
|
6049
6056
|
}
|
|
6050
6057
|
return;
|
|
6051
6058
|
}
|
|
@@ -21555,6 +21562,7 @@ function processJSXCallbackBody(source, body) {
|
|
|
21555
21562
|
for (const c of body.children) nodes.push(...processJSXChildren(source, [c]));
|
|
21556
21563
|
return nodes;
|
|
21557
21564
|
}
|
|
21565
|
+
if (body.type === "BlockStatement") return processStatementModeBody(source, body.body);
|
|
21558
21566
|
if (body.type === "ParenthesizedExpression") return exprToIR(source, body.expression);
|
|
21559
21567
|
return exprToIR(source, body);
|
|
21560
21568
|
}
|
|
@@ -21713,6 +21721,29 @@ function getReturnStatement(node) {
|
|
|
21713
21721
|
}
|
|
21714
21722
|
return null;
|
|
21715
21723
|
}
|
|
21724
|
+
function containsLoopControl(node) {
|
|
21725
|
+
if (!node) return false;
|
|
21726
|
+
if (node.type === "ContinueStatement" || node.type === "BreakStatement") return true;
|
|
21727
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") return false;
|
|
21728
|
+
if (node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "WhileStatement" || node.type === "DoWhileStatement") return false;
|
|
21729
|
+
if (node.type === "BlockStatement") return node.body.some(containsLoopControl);
|
|
21730
|
+
if (node.type === "IfStatement") return containsLoopControl(node.consequent) || containsLoopControl(node.alternate);
|
|
21731
|
+
if (node.type === "SwitchStatement") return node.cases.some((c) => (c.consequent || []).some(containsLoopControl));
|
|
21732
|
+
if (node.type === "TryStatement") {
|
|
21733
|
+
return containsLoopControl(node.block) || containsLoopControl(node.handler) || containsLoopControl(node.finalizer);
|
|
21734
|
+
}
|
|
21735
|
+
if (node.type === "CatchClause") return containsLoopControl(node.body);
|
|
21736
|
+
if (node.type === "LabeledStatement") return containsLoopControl(node.body);
|
|
21737
|
+
return false;
|
|
21738
|
+
}
|
|
21739
|
+
function getLoopControlGuard(consequent, kind) {
|
|
21740
|
+
const stmts = consequent.type === "BlockStatement" ? consequent.body : [consequent];
|
|
21741
|
+
if (stmts.length === 0) return null;
|
|
21742
|
+
const want = kind === "continue" ? "ContinueStatement" : "BreakStatement";
|
|
21743
|
+
const last = stmts[stmts.length - 1];
|
|
21744
|
+
if (!last || last.type !== want) return null;
|
|
21745
|
+
return { pre: stmts.slice(0, -1), node: last };
|
|
21746
|
+
}
|
|
21716
21747
|
function isStatementMode(bodyStmts) {
|
|
21717
21748
|
if (bodyStmts.some((s) => s.type === "JSXElement" || s.type === "JSXExpressionContainer" || s.type === "JSXFragment")) return true;
|
|
21718
21749
|
for (const stmt of bodyStmts) {
|
|
@@ -21751,6 +21782,9 @@ function processIfStatement(source, stmt) {
|
|
|
21751
21782
|
return [new OpaqueDynamicRegion(condExpr, consequent, alternate)];
|
|
21752
21783
|
}
|
|
21753
21784
|
function processForStatement(source, stmt, alternate = []) {
|
|
21785
|
+
if (stmt.body && !hasJSXInSubtree(stmt.body) && containsLoopControl(stmt.body)) {
|
|
21786
|
+
return [new RuntimeStatement(getSource(source, stmt), stmt, source)];
|
|
21787
|
+
}
|
|
21754
21788
|
if (stmt.type === "ForOfStatement") {
|
|
21755
21789
|
const left = stmt.left;
|
|
21756
21790
|
let itemVar = "item";
|
|
@@ -21784,6 +21818,9 @@ function processForStatement(source, stmt, alternate = []) {
|
|
|
21784
21818
|
return [];
|
|
21785
21819
|
}
|
|
21786
21820
|
function processWhileStatement(source, stmt) {
|
|
21821
|
+
if (stmt.body && !hasJSXInSubtree(stmt.body) && containsLoopControl(stmt.body)) {
|
|
21822
|
+
return [new RuntimeStatement(getSource(source, stmt), stmt, source)];
|
|
21823
|
+
}
|
|
21787
21824
|
const condition = toExpression(source, stmt.test);
|
|
21788
21825
|
const bodyTemplate = processBlockBody(source, stmt.body);
|
|
21789
21826
|
const isDoWhile = stmt.type === "DoWhileStatement";
|
|
@@ -21849,6 +21886,18 @@ function processStatementModeBody(source, bodyStmts, filename) {
|
|
|
21849
21886
|
nodes.push(new OpaqueDynamicRegion(toExpression(source, stmt.test), consequent, alternate));
|
|
21850
21887
|
break;
|
|
21851
21888
|
}
|
|
21889
|
+
if (!stmt.alternate) {
|
|
21890
|
+
const guardContinue = getLoopControlGuard(stmt.consequent, "continue");
|
|
21891
|
+
const guardBreak = guardContinue ? null : getLoopControlGuard(stmt.consequent, "break");
|
|
21892
|
+
const guard = guardContinue || guardBreak;
|
|
21893
|
+
if (guard) {
|
|
21894
|
+
const consequent = guard.pre.length ? processStatementModeBody(source, guard.pre, filename) : [];
|
|
21895
|
+
if (guardBreak) consequent.push(new BreakSignal());
|
|
21896
|
+
const alternate = processStatementModeBody(source, bodyStmts.slice(i + 1), filename);
|
|
21897
|
+
nodes.push(new OpaqueDynamicRegion(toExpression(source, stmt.test), consequent, alternate));
|
|
21898
|
+
break;
|
|
21899
|
+
}
|
|
21900
|
+
}
|
|
21852
21901
|
nodes.push(...processIfStatement(source, stmt));
|
|
21853
21902
|
} else if (stmt.type === "ForOfStatement") {
|
|
21854
21903
|
let alternate = [];
|
|
@@ -21886,6 +21935,11 @@ function processStatementModeBody(source, bodyStmts, filename) {
|
|
|
21886
21935
|
} else if (stmt.type === "ClassDeclaration") {
|
|
21887
21936
|
const { line, column } = offsetToLineCol2(source, stmt.start ?? 0);
|
|
21888
21937
|
throw VeskError.classDecl({ file: filename || "", line, column, code: codeFrame(source, line, column) });
|
|
21938
|
+
} else if (stmt.type === "ContinueStatement") {
|
|
21939
|
+
break;
|
|
21940
|
+
} else if (stmt.type === "BreakStatement") {
|
|
21941
|
+
nodes.push(new BreakSignal());
|
|
21942
|
+
break;
|
|
21889
21943
|
} else {
|
|
21890
21944
|
const raw2 = getSource(source, stmt);
|
|
21891
21945
|
if (raw2) nodes.push(new RuntimeStatement(raw2, stmt, source));
|
|
@@ -22017,6 +22071,7 @@ function warnStaleConstBindings(comp, file) {
|
|
|
22017
22071
|
if (d.id?.type !== "Identifier" || !d.init) continue;
|
|
22018
22072
|
if (reactive.has(d.id.name)) continue;
|
|
22019
22073
|
if (d.init.type === "ArrowFunctionExpression" || d.init.type === "FunctionExpression") continue;
|
|
22074
|
+
if (isReactiveFactoryCall(d.init)) continue;
|
|
22020
22075
|
if (d.init.type === "Identifier" && reactive.has(d.init.name)) continue;
|
|
22021
22076
|
const seen = /* @__PURE__ */ new Set();
|
|
22022
22077
|
collectIdentifiers(d.init, seen);
|
|
@@ -22057,6 +22112,16 @@ function warnStaleConstBindings(comp, file) {
|
|
|
22057
22112
|
}
|
|
22058
22113
|
});
|
|
22059
22114
|
}
|
|
22115
|
+
function isReactiveFactoryCall(node) {
|
|
22116
|
+
if (!node || node.type !== "CallExpression") return false;
|
|
22117
|
+
const callee = node.callee;
|
|
22118
|
+
if (!callee) return false;
|
|
22119
|
+
if (callee.type === "Identifier") return callee.name === "derived";
|
|
22120
|
+
if (callee.type === "MemberExpression" && !callee.computed) {
|
|
22121
|
+
return callee.property?.type === "Identifier" && callee.property.name === "derived";
|
|
22122
|
+
}
|
|
22123
|
+
return false;
|
|
22124
|
+
}
|
|
22060
22125
|
function collectIdentifiers(node, into) {
|
|
22061
22126
|
if (!node || typeof node !== "object") return;
|
|
22062
22127
|
if (Array.isArray(node)) {
|
|
@@ -22064,6 +22129,15 @@ function collectIdentifiers(node, into) {
|
|
|
22064
22129
|
return;
|
|
22065
22130
|
}
|
|
22066
22131
|
if (typeof node.type !== "string") return;
|
|
22132
|
+
if (node.type === "MemberExpression" && !node.computed) {
|
|
22133
|
+
collectIdentifiers(node.object, into);
|
|
22134
|
+
if (node.property?.type === "MemberExpression") collectIdentifiers(node.property, into);
|
|
22135
|
+
return;
|
|
22136
|
+
}
|
|
22137
|
+
if ((node.type === "Property" || node.type === "PropertyDefinition" || node.type === "MethodDefinition") && !node.computed) {
|
|
22138
|
+
collectIdentifiers(node.value, into);
|
|
22139
|
+
return;
|
|
22140
|
+
}
|
|
22067
22141
|
if (node.type === "Identifier" && typeof node.name === "string") into.add(node.name);
|
|
22068
22142
|
for (const key of Object.keys(node)) {
|
|
22069
22143
|
if (key === "loc" || key === "range" || key === "start" || key === "end") continue;
|
|
@@ -30395,14 +30469,36 @@ function transformTracked(irNode, tracked2) {
|
|
|
30395
30469
|
}
|
|
30396
30470
|
function collectTrackedNames(body) {
|
|
30397
30471
|
const names = /* @__PURE__ */ new Map();
|
|
30472
|
+
collectTrackedNamesInto(body, names);
|
|
30473
|
+
return names;
|
|
30474
|
+
}
|
|
30475
|
+
function collectTrackedNamesInto(body, names) {
|
|
30398
30476
|
for (const node of body) {
|
|
30399
30477
|
if (node instanceof TrackDecl) {
|
|
30400
30478
|
const cellName = node.rawName || node.name;
|
|
30401
30479
|
names.set(node.name, { cellName, kind: "virtual" });
|
|
30402
30480
|
if (node.rawName) names.set(node.rawName, { cellName, kind: "cell" });
|
|
30481
|
+
} else if (node instanceof StaticNode || node instanceof ServerBlock || node instanceof ClientBlock || node instanceof HeadBlock) {
|
|
30482
|
+
collectTrackedNamesInto(node.children, names);
|
|
30483
|
+
} else if (node instanceof ComponentCall) {
|
|
30484
|
+
collectTrackedNamesInto(node.children, names);
|
|
30485
|
+
} else if (node instanceof PropSlot) {
|
|
30486
|
+
collectTrackedNamesInto(node.body, names);
|
|
30487
|
+
} else if (node instanceof MapRegion) {
|
|
30488
|
+
collectTrackedNamesInto(node.bodyTemplate, names);
|
|
30489
|
+
collectTrackedNamesInto(node.alternateNodes, names);
|
|
30490
|
+
} else if (node instanceof OpaqueDynamicRegion) {
|
|
30491
|
+
collectTrackedNamesInto(node.consequentNodes, names);
|
|
30492
|
+
collectTrackedNamesInto(node.alternateNodes, names);
|
|
30493
|
+
} else if (node instanceof WhileLoop || node instanceof ForLoop) {
|
|
30494
|
+
collectTrackedNamesInto(node.bodyTemplate, names);
|
|
30495
|
+
} else if (node instanceof TryCatch) {
|
|
30496
|
+
collectTrackedNamesInto(node.bodyTemplate, names);
|
|
30497
|
+
collectTrackedNamesInto(node.catchBody, names);
|
|
30498
|
+
} else if (node instanceof SwitchBlock) {
|
|
30499
|
+
for (const c of node.cases) collectTrackedNamesInto(c.body, names);
|
|
30403
30500
|
}
|
|
30404
30501
|
}
|
|
30405
|
-
return names;
|
|
30406
30502
|
}
|
|
30407
30503
|
function collectTrackedDeps(value, tracked2) {
|
|
30408
30504
|
const ast = value?.ast;
|
|
@@ -30488,6 +30584,10 @@ function emitNode(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__c
|
|
|
30488
30584
|
ctx2.push(semicolonizeStatement(transformTracked(node, tracked2)));
|
|
30489
30585
|
return null;
|
|
30490
30586
|
}
|
|
30587
|
+
if (node instanceof BreakSignal) {
|
|
30588
|
+
if (ctx2.breakFlag) ctx2.push(`${ctx2.breakFlag} = true;`);
|
|
30589
|
+
return null;
|
|
30590
|
+
}
|
|
30491
30591
|
if (node instanceof SlotNode) {
|
|
30492
30592
|
if (!parentVar) {
|
|
30493
30593
|
if (ctx2.hydrate) {
|
|
@@ -31294,12 +31394,18 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
31294
31394
|
ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
|
|
31295
31395
|
emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
|
|
31296
31396
|
const renderLoop = ctx2.n();
|
|
31397
|
+
const hasBreak = bodyHasBreak(node.bodyTemplate);
|
|
31398
|
+
const breakVar = hasBreak ? ctx2.n() : null;
|
|
31297
31399
|
ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
|
|
31298
31400
|
if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
|
|
31299
31401
|
if (!hyd) ctx2.push(indent2(`const __b = document.createDocumentFragment();`));
|
|
31300
31402
|
if (hyd) ctx2.push(indent2(`const __cl = [];`));
|
|
31403
|
+
if (breakVar) ctx2.push(indent2(`let ${breakVar} = false;`));
|
|
31404
|
+
const savedBreakFlag = ctx2.breakFlag;
|
|
31405
|
+
ctx2.breakFlag = breakVar;
|
|
31301
31406
|
if (node.isDoWhile) {
|
|
31302
31407
|
ctx2.push(indent2(`do {`));
|
|
31408
|
+
if (breakVar) ctx2.push(indent2(indent2(`if (${breakVar}) break;`)));
|
|
31303
31409
|
for (const n of node.bodyTemplate) {
|
|
31304
31410
|
const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
31305
31411
|
if (v) {
|
|
@@ -31310,6 +31416,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
31310
31416
|
ctx2.push(indent2(`} while (${condExpr});`));
|
|
31311
31417
|
} else {
|
|
31312
31418
|
ctx2.push(indent2(`while (${condExpr}) {`));
|
|
31419
|
+
if (breakVar) ctx2.push(indent2(indent2(`if (${breakVar}) break;`)));
|
|
31313
31420
|
for (const n of node.bodyTemplate) {
|
|
31314
31421
|
const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
31315
31422
|
if (v) {
|
|
@@ -31319,6 +31426,7 @@ function emitWhileLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
31319
31426
|
}
|
|
31320
31427
|
ctx2.push(indent2(`}`));
|
|
31321
31428
|
}
|
|
31429
|
+
ctx2.breakFlag = savedBreakFlag;
|
|
31322
31430
|
if (!hyd) ctx2.push(indent2(`__p.insertBefore(__b, ${endAnchor});`));
|
|
31323
31431
|
if (hyd) ctx2.push(indent2(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
31324
31432
|
ctx2.push(`};`);
|
|
@@ -31358,13 +31466,19 @@ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
|
|
|
31358
31466
|
ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
|
|
31359
31467
|
emitHydrateFenceAnchoring(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
|
|
31360
31468
|
const renderLoop = ctx2.n();
|
|
31469
|
+
const forHasBreak = bodyHasBreak(node.bodyTemplate);
|
|
31470
|
+
const forBreakVar = forHasBreak ? ctx2.n() : null;
|
|
31361
31471
|
ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
|
|
31362
31472
|
if (!hyd) ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
|
|
31363
31473
|
if (!hyd) ctx2.push(indent2(`const __b = document.createDocumentFragment();`));
|
|
31364
31474
|
if (hyd) ctx2.push(indent2(`const __cl = [];`));
|
|
31475
|
+
if (forBreakVar) ctx2.push(indent2(`let ${forBreakVar} = false;`));
|
|
31476
|
+
const savedForBreakFlag = ctx2.breakFlag;
|
|
31477
|
+
ctx2.breakFlag = forBreakVar;
|
|
31365
31478
|
if (node.kind === "for-in") {
|
|
31366
31479
|
const srcExpr = transformTracked(node.condition, tracked2);
|
|
31367
31480
|
ctx2.push(indent2(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
|
|
31481
|
+
if (forBreakVar) ctx2.push(indent2(indent2(`if (${forBreakVar}) break;`)));
|
|
31368
31482
|
for (const n of node.bodyTemplate) {
|
|
31369
31483
|
const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
31370
31484
|
if (v) {
|
|
@@ -31381,6 +31495,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
|
|
|
31381
31495
|
if (updatePart.endsWith(";")) updatePart = updatePart.slice(0, -1).trim();
|
|
31382
31496
|
const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
|
|
31383
31497
|
ctx2.push(indent2(`for (${head}; ${updatePart}) {`));
|
|
31498
|
+
if (forBreakVar) ctx2.push(indent2(indent2(`if (${forBreakVar}) break;`)));
|
|
31384
31499
|
for (const n of node.bodyTemplate) {
|
|
31385
31500
|
const v = emitNode(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
31386
31501
|
if (v) {
|
|
@@ -31390,6 +31505,7 @@ function emitForLoop(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget) {
|
|
|
31390
31505
|
}
|
|
31391
31506
|
ctx2.push(indent2(`}`));
|
|
31392
31507
|
}
|
|
31508
|
+
ctx2.breakFlag = savedForBreakFlag;
|
|
31393
31509
|
if (!hyd) ctx2.push(indent2(`__p.insertBefore(__b, ${endAnchor});`));
|
|
31394
31510
|
if (hyd) ctx2.push(indent2(`__place(${anchor}, ${endAnchor}, __cl, ${parent});`));
|
|
31395
31511
|
ctx2.push(`};`);
|
|
@@ -31550,6 +31666,27 @@ function emitSwitchBlock(ctx2, node, tracked2, parentVar, skipK = 0, regionBudge
|
|
|
31550
31666
|
}`);
|
|
31551
31667
|
return null;
|
|
31552
31668
|
}
|
|
31669
|
+
function bodyHasBreak(nodes) {
|
|
31670
|
+
for (const n of nodes) {
|
|
31671
|
+
if (n instanceof BreakSignal) return true;
|
|
31672
|
+
if (n instanceof OpaqueDynamicRegion) {
|
|
31673
|
+
if (bodyHasBreak([...n.consequentNodes, ...n.alternateNodes])) return true;
|
|
31674
|
+
} else if (n instanceof SwitchBlock) {
|
|
31675
|
+
for (const c of n.cases) if (bodyHasBreak(c.body)) return true;
|
|
31676
|
+
} else if (n instanceof TryCatch) {
|
|
31677
|
+
if (bodyHasBreak([...n.bodyTemplate, ...n.catchBody])) return true;
|
|
31678
|
+
} else if (n instanceof StaticNode) {
|
|
31679
|
+
if (bodyHasBreak(n.children)) return true;
|
|
31680
|
+
} else if (n instanceof ComponentCall) {
|
|
31681
|
+
if (bodyHasBreak(n.children)) return true;
|
|
31682
|
+
} else if (n instanceof ServerBlock || n instanceof ClientBlock || n instanceof HeadBlock) {
|
|
31683
|
+
if (bodyHasBreak(n.children)) return true;
|
|
31684
|
+
} else if (n instanceof PropSlot) {
|
|
31685
|
+
if (bodyHasBreak(n.body)) return true;
|
|
31686
|
+
}
|
|
31687
|
+
}
|
|
31688
|
+
return false;
|
|
31689
|
+
}
|
|
31553
31690
|
function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
|
|
31554
31691
|
const arrExpr = transformTracked(node.expression, tracked2);
|
|
31555
31692
|
const itemVar = node.itemVariable;
|
|
@@ -31582,9 +31719,13 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31582
31719
|
ctx2.push(`let ${effectsVar} = [];`);
|
|
31583
31720
|
ctx2.push(`const ${endAnchor} = document.createComment('map-end');`);
|
|
31584
31721
|
const renderItem = ctx2.n();
|
|
31722
|
+
const hasBreak = bodyHasBreak(node.bodyTemplate);
|
|
31723
|
+
const breakVar = hasBreak ? ctx2.n() : null;
|
|
31724
|
+
if (breakVar) ctx2.push(`let ${breakVar} = false;`);
|
|
31585
31725
|
const indexParam = node.indexVariable ? ", __i" : "";
|
|
31586
31726
|
ctx2.push(`const ${renderItem} = ${ctx2.isAsyncScope ? "async " : ""}(${itemVar}${indexParam}, __e, __r${hyd ? ", __cl" : ""}${hydKeyed ? ", __root" : ""}) => {`);
|
|
31587
31727
|
ctx2.push(indent2(`__r = __r || ${endAnchor};`));
|
|
31728
|
+
if (breakVar) ctx2.push(indent2(`if (${breakVar}) return;`));
|
|
31588
31729
|
if (node.indexVariable) ctx2.push(indent2(`const ${node.indexVariable} = __i;`));
|
|
31589
31730
|
if (hyd) {
|
|
31590
31731
|
ctx2.push(indent2(`const __p = ${anchor}.parentNode;`));
|
|
@@ -31593,6 +31734,8 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31593
31734
|
ctx2.push(indent2(`const __it = document.createDocumentFragment();`));
|
|
31594
31735
|
}
|
|
31595
31736
|
if (hydKeyed) ctx2.rootClaim = true;
|
|
31737
|
+
const savedMapBreak = ctx2.breakFlag;
|
|
31738
|
+
ctx2.breakFlag = breakVar;
|
|
31596
31739
|
for (const n of node.bodyTemplate) {
|
|
31597
31740
|
const v = emitNode(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
|
|
31598
31741
|
if (v) {
|
|
@@ -31605,6 +31748,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31605
31748
|
}
|
|
31606
31749
|
}
|
|
31607
31750
|
}
|
|
31751
|
+
ctx2.breakFlag = savedMapBreak;
|
|
31608
31752
|
if (hydKeyed) ctx2.rootClaim = false;
|
|
31609
31753
|
if (!hyd) ctx2.push(indent2(`if (__it.childNodes.length > 0) __p.insertBefore(__it, __r);`));
|
|
31610
31754
|
ctx2.push(`};`);
|
|
@@ -31640,11 +31784,12 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31640
31784
|
const keyFnSrc = `(${itemVar}${node.indexVariable ? `, ${node.indexVariable}` : ""}) => ${keyExpr}`;
|
|
31641
31785
|
const reconciler = ctx2.n();
|
|
31642
31786
|
const initList = ctx2.n();
|
|
31787
|
+
const breakReset = breakVar ? `${breakVar} = false; ` : "";
|
|
31643
31788
|
ctx2.push(`let ${reconciler} = () => {};`);
|
|
31644
31789
|
if (hydKeyed) {
|
|
31645
|
-
ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
|
|
31790
|
+
ctx2.push(`const ${initList} = () => { ${breakReset}${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
|
|
31646
31791
|
} else {
|
|
31647
|
-
ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
|
|
31792
|
+
ctx2.push(`const ${initList} = () => { ${breakReset}${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
|
|
31648
31793
|
}
|
|
31649
31794
|
if (emptyRenderName) {
|
|
31650
31795
|
const isEmptyVar = ctx2.n();
|
|
@@ -31655,7 +31800,7 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31655
31800
|
const __new = ${hasItems}();
|
|
31656
31801
|
if (__first) { __first = false; __new; return; }
|
|
31657
31802
|
if (__new !== ${isEmptyVar}) {
|
|
31658
|
-
if (__new) ${reconciler}(${arrExpr});
|
|
31803
|
+
if (__new) {${breakVar ? ` ${breakVar} = false;` : ""} ${reconciler}(${arrExpr}); }
|
|
31659
31804
|
return;
|
|
31660
31805
|
}
|
|
31661
31806
|
${isEmptyVar} = !__new;
|
|
@@ -31669,22 +31814,25 @@ function emitMap(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBu
|
|
|
31669
31814
|
if (!reactiveSource) return null;
|
|
31670
31815
|
pushEffect(`let __first = true;`, `effect(() => {
|
|
31671
31816
|
const __nv = ${arrExpr};
|
|
31672
|
-
if (__first) { __first = false; __nv; ${reconciler}(${arrExpr}); return; }
|
|
31673
|
-
${reconciler}(${arrExpr});
|
|
31817
|
+
if (__first) { __first = false; __nv; ${breakReset}${reconciler}(${arrExpr}); return; }
|
|
31818
|
+
${breakVar ? `if (${breakVar}) ${breakVar} = false;` : ""}${reconciler}(${arrExpr});
|
|
31674
31819
|
})`);
|
|
31675
31820
|
}
|
|
31676
31821
|
} else {
|
|
31677
31822
|
const renderAllItems = (ind, collect) => {
|
|
31678
31823
|
const lines = [];
|
|
31824
|
+
if (breakVar) lines.push(`${ind}${breakVar} = false;`);
|
|
31679
31825
|
if (node.indexVariable) {
|
|
31680
31826
|
lines.push(`${ind}let __i = 0;`);
|
|
31681
31827
|
lines.push(`${ind}for (const ${itemVar} of ${arrExpr}) {`);
|
|
31682
31828
|
lines.push(`${ind} ${aw}${renderItem}(${itemVar}, __i, ${effectsVar}${collect ? `, null, ${collect}` : ""});`);
|
|
31683
31829
|
lines.push(`${ind} __i++;`);
|
|
31830
|
+
if (breakVar) lines.push(`${ind} if (${breakVar}) break;`);
|
|
31684
31831
|
lines.push(`${ind}}`);
|
|
31685
31832
|
} else {
|
|
31686
31833
|
lines.push(`${ind}for (const ${itemVar} of ${arrExpr}) {`);
|
|
31687
31834
|
lines.push(`${ind} ${aw}${renderItem}(${itemVar}, ${effectsVar}${collect ? `, null, ${collect}` : ""});`);
|
|
31835
|
+
if (breakVar) lines.push(`${ind} if (${breakVar}) break;`);
|
|
31688
31836
|
lines.push(`${ind}}`);
|
|
31689
31837
|
}
|
|
31690
31838
|
return lines.join("\n");
|
|
@@ -32257,6 +32405,9 @@ var init_client_codegen = __esm({
|
|
|
32257
32405
|
walker = "__hydrate";
|
|
32258
32406
|
asyncComps = /* @__PURE__ */ new Set();
|
|
32259
32407
|
isAsyncScope = false;
|
|
32408
|
+
// While emitting a loop body, names the boolean flag a `break` sets (see
|
|
32409
|
+
// BreakSignal). Null outside a break-capable loop body.
|
|
32410
|
+
breakFlag = null;
|
|
32260
32411
|
constructor(alloc) {
|
|
32261
32412
|
this.alloc = alloc ?? { c: 0 };
|
|
32262
32413
|
}
|
|
@@ -32978,6 +33129,7 @@ function irNodeToJS(node, importedNames, isAsync = false, tracked2) {
|
|
|
32978
33129
|
}
|
|
32979
33130
|
return semicolonizeStatement(transformTracked(node, tracked2 || /* @__PURE__ */ new Map()));
|
|
32980
33131
|
}
|
|
33132
|
+
if (node instanceof BreakSignal) return `break;`;
|
|
32981
33133
|
if (node instanceof SlotNode) {
|
|
32982
33134
|
if (__vskMarkerless) return `__out.push(props.children || '');`;
|
|
32983
33135
|
const sid = `s${nextVskId()}`;
|
|
@@ -33128,14 +33280,15 @@ function mapRegionToJS(node, isAsync = false, tracked2) {
|
|
|
33128
33280
|
}
|
|
33129
33281
|
const loopArr = arrVar || arr;
|
|
33130
33282
|
if (node.indexVariable) {
|
|
33131
|
-
|
|
33283
|
+
const counter = `__i${nextVskId()}`;
|
|
33284
|
+
lines.push(`let ${counter} = 0;`);
|
|
33132
33285
|
lines.push(`for (const ${item} of ${loopArr}) {`);
|
|
33133
|
-
lines.push(indent(`const ${node.indexVariable} =
|
|
33286
|
+
lines.push(indent(`const ${node.indexVariable} = ${counter};`));
|
|
33134
33287
|
for (const n of bodyForItem) {
|
|
33135
33288
|
const code = irNodeToJS(n, null, isAsync, tracked2);
|
|
33136
33289
|
if (code) lines.push(indent(code));
|
|
33137
33290
|
}
|
|
33138
|
-
lines.push(indent(
|
|
33291
|
+
lines.push(indent(`${counter}++;`));
|
|
33139
33292
|
lines.push(`}`);
|
|
33140
33293
|
} else {
|
|
33141
33294
|
lines.push(`for (const ${item} of ${loopArr}) {`);
|
|
@@ -34218,6 +34371,94 @@ var init_server_render = __esm({
|
|
|
34218
34371
|
}
|
|
34219
34372
|
});
|
|
34220
34373
|
|
|
34374
|
+
// ../adapter/src/default-pages.ts
|
|
34375
|
+
function escapeDefaultPageHtml(value) {
|
|
34376
|
+
return String(value ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
34377
|
+
}
|
|
34378
|
+
function renderDefaultPage(opts = {}) {
|
|
34379
|
+
const status = opts.status ?? 404;
|
|
34380
|
+
const title = escapeDefaultPageHtml(opts.title ?? `${status} \u2014 Vesk`);
|
|
34381
|
+
const message = escapeDefaultPageHtml(opts.message ?? "This page could not be found.");
|
|
34382
|
+
const url = opts.url ? escapeDefaultPageHtml(opts.url) : "";
|
|
34383
|
+
const headExtra = opts.headExtra || "";
|
|
34384
|
+
const homeHref = opts.homeHref === void 0 ? "/" : opts.homeHref;
|
|
34385
|
+
const homeLabel = escapeDefaultPageHtml(opts.homeLabel ?? "Back to home");
|
|
34386
|
+
const variant = `vsk-page${opts.accentStatus ? " vsk-page--error" : ""}`;
|
|
34387
|
+
const action = homeHref === null ? "" : `<a class="vsk-page__btn" href="${escapeDefaultPageHtml(homeHref)}">${homeLabel}</a>`;
|
|
34388
|
+
return `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="noindex"><title>${title}</title><style>${DEFAULT_PAGE_CSS}</style>` + headExtra + `</head><body><main class="${variant}" data-vesk-default-page="${status}"><div class="vsk-page__card"><p class="vsk-page__brand"><b>Vesk</b> \xB7 built-in error page</p><div class="vsk-page__row"><span class="vsk-page__status">${status}</span><span class="vsk-page__msg">${message}</span></div>` + (url ? `<p class="vsk-page__detail">${url}</p>` : "") + (action ? `<div class="vsk-page__actions">${action}</div>` : "") + "</div></main></body></html>";
|
|
34389
|
+
}
|
|
34390
|
+
function renderDefaultNotFoundPage(opts = {}) {
|
|
34391
|
+
return renderDefaultPage({
|
|
34392
|
+
status: 404,
|
|
34393
|
+
title: "404 \u2014 Not Found",
|
|
34394
|
+
message: "This page could not be found.",
|
|
34395
|
+
url: opts.url,
|
|
34396
|
+
headExtra: opts.headExtra
|
|
34397
|
+
});
|
|
34398
|
+
}
|
|
34399
|
+
function renderDefaultErrorPage(opts = {}) {
|
|
34400
|
+
const status = opts.status ?? 500;
|
|
34401
|
+
return renderDefaultPage({
|
|
34402
|
+
status,
|
|
34403
|
+
title: `${status} \u2014 Internal Server Error`,
|
|
34404
|
+
message: opts.message || "Internal Server Error",
|
|
34405
|
+
url: opts.url,
|
|
34406
|
+
headExtra: opts.headExtra,
|
|
34407
|
+
accentStatus: true,
|
|
34408
|
+
homeHref: null
|
|
34409
|
+
});
|
|
34410
|
+
}
|
|
34411
|
+
function renderDefaultErrorFragment(opts = {}) {
|
|
34412
|
+
const status = opts.status ?? 500;
|
|
34413
|
+
const message = escapeDefaultPageHtml(opts.message || "Internal Server Error");
|
|
34414
|
+
return '<div data-vesk-default-error-fragment="' + status + '" style="display:flex;align-items:center;justify-content:center;min-height:60vh;padding:32px"><div style="display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace"><div style="display:flex;align-items:center"><span style="font-size:24px;font-weight:500;line-height:49px;padding-right:23px;margin-right:20px;border-right:1px solid currentColor;opacity:.85">' + status + '</span><span style="font-size:14px;line-height:49px;opacity:.7">' + message + "</span></div></div></div>";
|
|
34415
|
+
}
|
|
34416
|
+
var DEFAULT_PAGE_CSS;
|
|
34417
|
+
var init_default_pages = __esm({
|
|
34418
|
+
"../adapter/src/default-pages.ts"() {
|
|
34419
|
+
"use strict";
|
|
34420
|
+
DEFAULT_PAGE_CSS = [
|
|
34421
|
+
":root{color-scheme:light;",
|
|
34422
|
+
"--vsk-bg:oklch(0.941 0.014 88);",
|
|
34423
|
+
"--vsk-fg:oklch(0.185 0.008 62);",
|
|
34424
|
+
"--vsk-surface:oklch(0.965 0.012 88);",
|
|
34425
|
+
"--vsk-muted:oklch(0.475 0.014 72);",
|
|
34426
|
+
"--vsk-accent:oklch(0.560 0.140 42);",
|
|
34427
|
+
"--vsk-border:oklch(0.86 0.012 82);",
|
|
34428
|
+
"--vsk-border-strong:oklch(0.72 0.014 80);",
|
|
34429
|
+
'--vsk-font:"Space Grotesk",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;',
|
|
34430
|
+
'--vsk-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}',
|
|
34431
|
+
"@media (prefers-color-scheme:dark){:root{color-scheme:dark;",
|
|
34432
|
+
"--vsk-bg:oklch(0.155 0.006 60);",
|
|
34433
|
+
"--vsk-fg:oklch(0.931 0.014 88);",
|
|
34434
|
+
"--vsk-surface:oklch(0.196 0.008 70);",
|
|
34435
|
+
"--vsk-muted:oklch(0.618 0.016 80);",
|
|
34436
|
+
"--vsk-accent:oklch(0.632 0.132 45);",
|
|
34437
|
+
"--vsk-border:oklch(0.29 0.009 75);",
|
|
34438
|
+
"--vsk-border-strong:oklch(0.40 0.011 75);}}",
|
|
34439
|
+
"*{box-sizing:border-box}",
|
|
34440
|
+
"html,body{margin:0;min-height:100%}",
|
|
34441
|
+
"body{background:var(--vsk-bg);color:var(--vsk-fg);font-family:var(--vsk-font);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}",
|
|
34442
|
+
".vsk-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}",
|
|
34443
|
+
".vsk-page__card{width:100%;max-width:540px;border:1px solid var(--vsk-border);background:var(--vsk-surface);padding:clamp(28px,6vw,44px);text-align:center}",
|
|
34444
|
+
"@supports (background:color-mix(in oklab,red,red)){.vsk-page__card{background:color-mix(in oklab,var(--vsk-surface) 60%,transparent)}}",
|
|
34445
|
+
".vsk-page__brand{margin:0 0 26px;font-family:var(--vsk-mono);font-size:10px;line-height:1;letter-spacing:.24em;text-transform:uppercase;color:var(--vsk-muted)}",
|
|
34446
|
+
".vsk-page__brand b{color:var(--vsk-fg);font-weight:600}",
|
|
34447
|
+
".vsk-page__row{display:flex;align-items:center;justify-content:center;gap:0;flex-wrap:wrap}",
|
|
34448
|
+
".vsk-page__status{font-size:clamp(34px,9vw,46px);font-weight:600;line-height:1;letter-spacing:-.03em;padding-right:22px;margin-right:22px;border-right:1px solid var(--vsk-border-strong)}",
|
|
34449
|
+
".vsk-page--error .vsk-page__status{color:var(--vsk-accent)}",
|
|
34450
|
+
".vsk-page__msg{font-family:var(--vsk-mono);font-size:13px;line-height:1.5;color:var(--vsk-muted);text-align:left;max-width:270px}",
|
|
34451
|
+
"@media (max-width:440px){.vsk-page__row{flex-direction:column}.vsk-page__status{padding:0 0 16px;margin:0 0 16px;border-right:0;border-bottom:1px solid var(--vsk-border-strong)}.vsk-page__msg{text-align:center}}",
|
|
34452
|
+
".vsk-page__detail{margin:20px 0 0;font-family:var(--vsk-mono);font-size:11px;line-height:1.6;color:var(--vsk-muted);word-break:break-all}",
|
|
34453
|
+
".vsk-page__actions{margin-top:30px;display:flex;justify-content:center;gap:10px;flex-wrap:wrap}",
|
|
34454
|
+
".vsk-page__btn{display:inline-block;padding:11px 22px;font-size:13px;font-weight:500;line-height:1;text-decoration:none;border:1px solid var(--vsk-fg);background:var(--vsk-fg);color:var(--vsk-bg);transition:opacity .18s cubic-bezier(.2,0,0,1)}",
|
|
34455
|
+
".vsk-page__btn:hover{opacity:.86}",
|
|
34456
|
+
".vsk-page__btn--ghost{background:transparent;color:var(--vsk-fg);border-color:var(--vsk-border-strong)}",
|
|
34457
|
+
".vsk-page__btn--ghost:hover{background:var(--vsk-fg);color:var(--vsk-bg);border-color:var(--vsk-fg);opacity:1}"
|
|
34458
|
+
].join("");
|
|
34459
|
+
}
|
|
34460
|
+
});
|
|
34461
|
+
|
|
34221
34462
|
// ../adapter/src/paths.ts
|
|
34222
34463
|
import { resolve as resolve11, sep as sep2 } from "node:path";
|
|
34223
34464
|
import { existsSync as existsSync12, statSync as statSync4, readFileSync as readFileSync12 } from "node:fs";
|
|
@@ -35804,6 +36045,7 @@ function generatePlatformHandlerSource(input) {
|
|
|
35804
36045
|
const prerenderedList = prerenderedPaths.length > 0 ? `const __prerendered = new Set(${JSON.stringify(prerenderedPaths)});
|
|
35805
36046
|
` : "const __prerendered = new Set();\n";
|
|
35806
36047
|
const isrCache = "const __isrCache = new Map();";
|
|
36048
|
+
const defaultNotFoundLine = `const __defaultNotFoundHtml = ${JSON.stringify(renderDefaultNotFoundPage())};`;
|
|
35807
36049
|
const serverStoreLine = hasEvents ? "const __serverStore = globalThis.__vesk_server_ctx || {};" : "";
|
|
35808
36050
|
const eventsStartLine = hasEvents ? " await __eventsStart({ server: null });" : "";
|
|
35809
36051
|
const eventsRequestLine = hasEvents ? " await __eventsRequest(mwCtx);" : "";
|
|
@@ -35817,6 +36059,7 @@ ${mwImport}
|
|
|
35817
36059
|
${eventsImport}
|
|
35818
36060
|
${prerenderedList}
|
|
35819
36061
|
${isrCache}
|
|
36062
|
+
${defaultNotFoundLine}
|
|
35820
36063
|
const __routes = [${routeEntries.join(",\n")}];
|
|
35821
36064
|
|
|
35822
36065
|
async function __invokeRoute(route, request) {
|
|
@@ -35830,7 +36073,7 @@ async function __invokeRoute(route, request) {
|
|
|
35830
36073
|
});
|
|
35831
36074
|
}
|
|
35832
36075
|
if (e && typeof e === 'object' && e.name === 'NotFoundError') {
|
|
35833
|
-
return new Response(
|
|
36076
|
+
return new Response(__defaultNotFoundHtml, {
|
|
35834
36077
|
status: 404,
|
|
35835
36078
|
headers: { 'Content-Type': 'text/html' },
|
|
35836
36079
|
});
|
|
@@ -35957,7 +36200,7 @@ ${eventsRequestLine}
|
|
|
35957
36200
|
return response;
|
|
35958
36201
|
}
|
|
35959
36202
|
|
|
35960
|
-
return new Response(
|
|
36203
|
+
return new Response(__defaultNotFoundHtml, {
|
|
35961
36204
|
status: 404,
|
|
35962
36205
|
headers: { 'Content-Type': 'text/html' },
|
|
35963
36206
|
});
|
|
@@ -36052,6 +36295,7 @@ var __dirname5;
|
|
|
36052
36295
|
var init_platform_handler = __esm({
|
|
36053
36296
|
"../adapter/src/platform-handler.ts"() {
|
|
36054
36297
|
"use strict";
|
|
36298
|
+
init_default_pages();
|
|
36055
36299
|
__dirname5 = dirname13(fileURLToPath4(import.meta.url));
|
|
36056
36300
|
}
|
|
36057
36301
|
});
|
|
@@ -48501,6 +48745,7 @@ function resolveCssUrls(opts) {
|
|
|
48501
48745
|
}
|
|
48502
48746
|
|
|
48503
48747
|
// ../adapter/src/ssr-function.ts
|
|
48748
|
+
init_default_pages();
|
|
48504
48749
|
function resolveErrorFile(sourceDir, appDir) {
|
|
48505
48750
|
const rel = relative(appDir, sourceDir).split("/").filter(Boolean);
|
|
48506
48751
|
for (let depth = rel.length; depth >= 0; depth--) {
|
|
@@ -48701,7 +48946,7 @@ ${layoutDecls.map((d) => " " + d.compiled + ",").join("\n")}
|
|
|
48701
48946
|
" const result = await renderPage('', _errorComp, props, __componentRegistry, { hydrate: true, cached: _errorCompiled });",
|
|
48702
48947
|
" return result.body;",
|
|
48703
48948
|
" } catch {",
|
|
48704
|
-
|
|
48949
|
+
` return ${JSON.stringify(renderDefaultErrorFragment())};`,
|
|
48705
48950
|
" }",
|
|
48706
48951
|
"}",
|
|
48707
48952
|
"",
|
|
@@ -50907,6 +51152,7 @@ async function loadVeskConfig2(projectDir) {
|
|
|
50907
51152
|
}
|
|
50908
51153
|
|
|
50909
51154
|
// ../adapter/src/prod-server.ts
|
|
51155
|
+
init_default_pages();
|
|
50910
51156
|
var __dirname4 = dirname10(fileURLToPath3(import.meta.url));
|
|
50911
51157
|
async function deliverResponse(res, response) {
|
|
50912
51158
|
res.writeHead(response.status, Object.fromEntries(response.headers));
|
|
@@ -51367,7 +51613,7 @@ async function startProdServer(outDir, options) {
|
|
|
51367
51613
|
}
|
|
51368
51614
|
if (err.name === "NotFoundError") {
|
|
51369
51615
|
res.writeHead(404, { "Content-Type": "text/html" });
|
|
51370
|
-
res.end(notFoundHtml ||
|
|
51616
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
51371
51617
|
return;
|
|
51372
51618
|
}
|
|
51373
51619
|
console.error("vesk ssr error:", err.message);
|
|
@@ -51395,7 +51641,7 @@ async function startProdServer(outDir, options) {
|
|
|
51395
51641
|
}
|
|
51396
51642
|
}
|
|
51397
51643
|
res.writeHead(500, { "Content-Type": "text/html" });
|
|
51398
|
-
res.end(errorHtml || "
|
|
51644
|
+
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== "production" ? err.message : void 0, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
51399
51645
|
return;
|
|
51400
51646
|
}
|
|
51401
51647
|
}
|
|
@@ -51403,7 +51649,7 @@ async function startProdServer(outDir, options) {
|
|
|
51403
51649
|
}
|
|
51404
51650
|
}
|
|
51405
51651
|
res.writeHead(404, { "Content-Type": "text/html" });
|
|
51406
|
-
res.end(notFoundHtml ||
|
|
51652
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage({ url: url.pathname, headExtra: bakedHeadExtra }));
|
|
51407
51653
|
});
|
|
51408
51654
|
try {
|
|
51409
51655
|
await eventsMod?.executeStart?.({ server, port, host });
|
|
@@ -52421,15 +52667,38 @@ function transformTracked2(irNode, tracked2) {
|
|
|
52421
52667
|
}
|
|
52422
52668
|
function collectTrackedNames2(body) {
|
|
52423
52669
|
const names = /* @__PURE__ */ new Map();
|
|
52670
|
+
collectTrackedNamesInto2(body, names);
|
|
52671
|
+
return names;
|
|
52672
|
+
}
|
|
52673
|
+
function collectTrackedNamesInto2(body, names) {
|
|
52424
52674
|
for (const node of body) {
|
|
52425
52675
|
if (node instanceof TrackDecl) {
|
|
52426
52676
|
const cellName = node.rawName || node.name;
|
|
52427
52677
|
names.set(node.name, { cellName, kind: "virtual" });
|
|
52428
52678
|
if (node.rawName)
|
|
52429
52679
|
names.set(node.rawName, { cellName, kind: "cell" });
|
|
52680
|
+
} else if (node instanceof StaticNode || node instanceof ServerBlock || node instanceof ClientBlock || node instanceof HeadBlock) {
|
|
52681
|
+
collectTrackedNamesInto2(node.children, names);
|
|
52682
|
+
} else if (node instanceof ComponentCall) {
|
|
52683
|
+
collectTrackedNamesInto2(node.children, names);
|
|
52684
|
+
} else if (node instanceof PropSlot) {
|
|
52685
|
+
collectTrackedNamesInto2(node.body, names);
|
|
52686
|
+
} else if (node instanceof MapRegion) {
|
|
52687
|
+
collectTrackedNamesInto2(node.bodyTemplate, names);
|
|
52688
|
+
collectTrackedNamesInto2(node.alternateNodes, names);
|
|
52689
|
+
} else if (node instanceof OpaqueDynamicRegion) {
|
|
52690
|
+
collectTrackedNamesInto2(node.consequentNodes, names);
|
|
52691
|
+
collectTrackedNamesInto2(node.alternateNodes, names);
|
|
52692
|
+
} else if (node instanceof WhileLoop || node instanceof ForLoop) {
|
|
52693
|
+
collectTrackedNamesInto2(node.bodyTemplate, names);
|
|
52694
|
+
} else if (node instanceof TryCatch) {
|
|
52695
|
+
collectTrackedNamesInto2(node.bodyTemplate, names);
|
|
52696
|
+
collectTrackedNamesInto2(node.catchBody, names);
|
|
52697
|
+
} else if (node instanceof SwitchBlock) {
|
|
52698
|
+
for (const c of node.cases)
|
|
52699
|
+
collectTrackedNamesInto2(c.body, names);
|
|
52430
52700
|
}
|
|
52431
52701
|
}
|
|
52432
|
-
return names;
|
|
52433
52702
|
}
|
|
52434
52703
|
function collectTrackedDeps2(value, tracked2) {
|
|
52435
52704
|
const ast = value?.ast;
|
|
@@ -52544,6 +52813,9 @@ var Ctx2 = class {
|
|
|
52544
52813
|
walker = "__hydrate";
|
|
52545
52814
|
asyncComps = /* @__PURE__ */ new Set();
|
|
52546
52815
|
isAsyncScope = false;
|
|
52816
|
+
// While emitting a loop body, names the boolean flag a `break` sets (see
|
|
52817
|
+
// BreakSignal). Null outside a break-capable loop body.
|
|
52818
|
+
breakFlag = null;
|
|
52547
52819
|
constructor(alloc) {
|
|
52548
52820
|
this.alloc = alloc ?? { c: 0 };
|
|
52549
52821
|
}
|
|
@@ -52631,6 +52903,11 @@ function emitNode2(ctx2, node, tracked2, effectsVar, parentVar, compPrefix = "__
|
|
|
52631
52903
|
ctx2.push(semicolonizeStatement2(transformTracked2(node, tracked2)));
|
|
52632
52904
|
return null;
|
|
52633
52905
|
}
|
|
52906
|
+
if (node instanceof BreakSignal) {
|
|
52907
|
+
if (ctx2.breakFlag)
|
|
52908
|
+
ctx2.push(`${ctx2.breakFlag} = true;`);
|
|
52909
|
+
return null;
|
|
52910
|
+
}
|
|
52634
52911
|
if (node instanceof SlotNode) {
|
|
52635
52912
|
if (!parentVar) {
|
|
52636
52913
|
if (ctx2.hydrate) {
|
|
@@ -53543,6 +53820,8 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget
|
|
|
53543
53820
|
ctx2.push(`const ${endAnchor} = document.createComment('while-end');`);
|
|
53544
53821
|
emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
|
|
53545
53822
|
const renderLoop = ctx2.n();
|
|
53823
|
+
const hasBreak = bodyHasBreak2(node.bodyTemplate);
|
|
53824
|
+
const breakVar = hasBreak ? ctx2.n() : null;
|
|
53546
53825
|
ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
|
|
53547
53826
|
if (!hyd)
|
|
53548
53827
|
ctx2.push(indent3(`const __p = ${anchor}.parentNode;`));
|
|
@@ -53550,8 +53829,14 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget
|
|
|
53550
53829
|
ctx2.push(indent3(`const __b = document.createDocumentFragment();`));
|
|
53551
53830
|
if (hyd)
|
|
53552
53831
|
ctx2.push(indent3(`const __cl = [];`));
|
|
53832
|
+
if (breakVar)
|
|
53833
|
+
ctx2.push(indent3(`let ${breakVar} = false;`));
|
|
53834
|
+
const savedBreakFlag = ctx2.breakFlag;
|
|
53835
|
+
ctx2.breakFlag = breakVar;
|
|
53553
53836
|
if (node.isDoWhile) {
|
|
53554
53837
|
ctx2.push(indent3(`do {`));
|
|
53838
|
+
if (breakVar)
|
|
53839
|
+
ctx2.push(indent3(indent3(`if (${breakVar}) break;`)));
|
|
53555
53840
|
for (const n of node.bodyTemplate) {
|
|
53556
53841
|
const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
53557
53842
|
if (v) {
|
|
@@ -53564,6 +53849,8 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget
|
|
|
53564
53849
|
ctx2.push(indent3(`} while (${condExpr});`));
|
|
53565
53850
|
} else {
|
|
53566
53851
|
ctx2.push(indent3(`while (${condExpr}) {`));
|
|
53852
|
+
if (breakVar)
|
|
53853
|
+
ctx2.push(indent3(indent3(`if (${breakVar}) break;`)));
|
|
53567
53854
|
for (const n of node.bodyTemplate) {
|
|
53568
53855
|
const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
53569
53856
|
if (v) {
|
|
@@ -53575,6 +53862,7 @@ function emitWhileLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget
|
|
|
53575
53862
|
}
|
|
53576
53863
|
ctx2.push(indent3(`}`));
|
|
53577
53864
|
}
|
|
53865
|
+
ctx2.breakFlag = savedBreakFlag;
|
|
53578
53866
|
if (!hyd)
|
|
53579
53867
|
ctx2.push(indent3(`__p.insertBefore(__b, ${endAnchor});`));
|
|
53580
53868
|
if (hyd)
|
|
@@ -53618,6 +53906,8 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
53618
53906
|
ctx2.push(`const ${endAnchor} = document.createComment('for-end');`);
|
|
53619
53907
|
emitHydrateFenceAnchoring2(ctx2, anchor, endAnchor, parent === "$root", budget || void 0);
|
|
53620
53908
|
const renderLoop = ctx2.n();
|
|
53909
|
+
const forHasBreak = bodyHasBreak2(node.bodyTemplate);
|
|
53910
|
+
const forBreakVar = forHasBreak ? ctx2.n() : null;
|
|
53621
53911
|
ctx2.push(`const ${renderLoop} = ${ctx2.isAsyncScope ? "async () => {" : "() => {"}`);
|
|
53622
53912
|
if (!hyd)
|
|
53623
53913
|
ctx2.push(indent3(`const __p = ${anchor}.parentNode;`));
|
|
@@ -53625,9 +53915,15 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
53625
53915
|
ctx2.push(indent3(`const __b = document.createDocumentFragment();`));
|
|
53626
53916
|
if (hyd)
|
|
53627
53917
|
ctx2.push(indent3(`const __cl = [];`));
|
|
53918
|
+
if (forBreakVar)
|
|
53919
|
+
ctx2.push(indent3(`let ${forBreakVar} = false;`));
|
|
53920
|
+
const savedForBreakFlag = ctx2.breakFlag;
|
|
53921
|
+
ctx2.breakFlag = forBreakVar;
|
|
53628
53922
|
if (node.kind === "for-in") {
|
|
53629
53923
|
const srcExpr = transformTracked2(node.condition, tracked2);
|
|
53630
53924
|
ctx2.push(indent3(`for (${node.init} of (Array.isArray(${srcExpr}) ? ${srcExpr} : (${srcExpr} == null ? [] : Object.keys(${srcExpr})))) {`));
|
|
53925
|
+
if (forBreakVar)
|
|
53926
|
+
ctx2.push(indent3(indent3(`if (${forBreakVar}) break;`)));
|
|
53631
53927
|
for (const n of node.bodyTemplate) {
|
|
53632
53928
|
const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
53633
53929
|
if (v) {
|
|
@@ -53648,6 +53944,8 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
53648
53944
|
updatePart = updatePart.slice(0, -1).trim();
|
|
53649
53945
|
const head = initPart ? `${initPart}; ${condExpr}` : `; ${condExpr}`;
|
|
53650
53946
|
ctx2.push(indent3(`for (${head}; ${updatePart}) {`));
|
|
53947
|
+
if (forBreakVar)
|
|
53948
|
+
ctx2.push(indent3(indent3(`if (${forBreakVar}) break;`)));
|
|
53651
53949
|
for (const n of node.bodyTemplate) {
|
|
53652
53950
|
const v = emitNode2(ctx2, n, tracked2, effectsVar, hyd ? parentVar : "__b", "__components", 0, budget || void 0);
|
|
53653
53951
|
if (v) {
|
|
@@ -53659,6 +53957,7 @@ function emitForLoop2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudget)
|
|
|
53659
53957
|
}
|
|
53660
53958
|
ctx2.push(indent3(`}`));
|
|
53661
53959
|
}
|
|
53960
|
+
ctx2.breakFlag = savedForBreakFlag;
|
|
53662
53961
|
if (!hyd)
|
|
53663
53962
|
ctx2.push(indent3(`__p.insertBefore(__b, ${endAnchor});`));
|
|
53664
53963
|
if (hyd)
|
|
@@ -53830,6 +54129,36 @@ function emitSwitchBlock2(ctx2, node, tracked2, parentVar, skipK = 0, regionBudg
|
|
|
53830
54129
|
}`);
|
|
53831
54130
|
return null;
|
|
53832
54131
|
}
|
|
54132
|
+
function bodyHasBreak2(nodes) {
|
|
54133
|
+
for (const n of nodes) {
|
|
54134
|
+
if (n instanceof BreakSignal)
|
|
54135
|
+
return true;
|
|
54136
|
+
if (n instanceof OpaqueDynamicRegion) {
|
|
54137
|
+
if (bodyHasBreak2([...n.consequentNodes, ...n.alternateNodes]))
|
|
54138
|
+
return true;
|
|
54139
|
+
} else if (n instanceof SwitchBlock) {
|
|
54140
|
+
for (const c of n.cases)
|
|
54141
|
+
if (bodyHasBreak2(c.body))
|
|
54142
|
+
return true;
|
|
54143
|
+
} else if (n instanceof TryCatch) {
|
|
54144
|
+
if (bodyHasBreak2([...n.bodyTemplate, ...n.catchBody]))
|
|
54145
|
+
return true;
|
|
54146
|
+
} else if (n instanceof StaticNode) {
|
|
54147
|
+
if (bodyHasBreak2(n.children))
|
|
54148
|
+
return true;
|
|
54149
|
+
} else if (n instanceof ComponentCall) {
|
|
54150
|
+
if (bodyHasBreak2(n.children))
|
|
54151
|
+
return true;
|
|
54152
|
+
} else if (n instanceof ServerBlock || n instanceof ClientBlock || n instanceof HeadBlock) {
|
|
54153
|
+
if (bodyHasBreak2(n.children))
|
|
54154
|
+
return true;
|
|
54155
|
+
} else if (n instanceof PropSlot) {
|
|
54156
|
+
if (bodyHasBreak2(n.body))
|
|
54157
|
+
return true;
|
|
54158
|
+
}
|
|
54159
|
+
}
|
|
54160
|
+
return false;
|
|
54161
|
+
}
|
|
53833
54162
|
function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionBudget) {
|
|
53834
54163
|
const arrExpr = transformTracked2(node.expression, tracked2);
|
|
53835
54164
|
const itemVar = node.itemVariable;
|
|
@@ -53863,9 +54192,15 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53863
54192
|
ctx2.push(`let ${effectsVar} = [];`);
|
|
53864
54193
|
ctx2.push(`const ${endAnchor} = document.createComment('map-end');`);
|
|
53865
54194
|
const renderItem = ctx2.n();
|
|
54195
|
+
const hasBreak = bodyHasBreak2(node.bodyTemplate);
|
|
54196
|
+
const breakVar = hasBreak ? ctx2.n() : null;
|
|
54197
|
+
if (breakVar)
|
|
54198
|
+
ctx2.push(`let ${breakVar} = false;`);
|
|
53866
54199
|
const indexParam = node.indexVariable ? ", __i" : "";
|
|
53867
54200
|
ctx2.push(`const ${renderItem} = ${ctx2.isAsyncScope ? "async " : ""}(${itemVar}${indexParam}, __e, __r${hyd ? ", __cl" : ""}${hydKeyed ? ", __root" : ""}) => {`);
|
|
53868
54201
|
ctx2.push(indent3(`__r = __r || ${endAnchor};`));
|
|
54202
|
+
if (breakVar)
|
|
54203
|
+
ctx2.push(indent3(`if (${breakVar}) return;`));
|
|
53869
54204
|
if (node.indexVariable)
|
|
53870
54205
|
ctx2.push(indent3(`const ${node.indexVariable} = __i;`));
|
|
53871
54206
|
if (hyd) {
|
|
@@ -53876,6 +54211,8 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53876
54211
|
}
|
|
53877
54212
|
if (hydKeyed)
|
|
53878
54213
|
ctx2.rootClaim = true;
|
|
54214
|
+
const savedMapBreak = ctx2.breakFlag;
|
|
54215
|
+
ctx2.breakFlag = breakVar;
|
|
53879
54216
|
for (const n of node.bodyTemplate) {
|
|
53880
54217
|
const v = emitNode2(ctx2, n, tracked2, "__e", hyd ? void 0 : "__it", "__components", 0, budget || void 0);
|
|
53881
54218
|
if (v) {
|
|
@@ -53888,6 +54225,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53888
54225
|
}
|
|
53889
54226
|
}
|
|
53890
54227
|
}
|
|
54228
|
+
ctx2.breakFlag = savedMapBreak;
|
|
53891
54229
|
if (hydKeyed)
|
|
53892
54230
|
ctx2.rootClaim = false;
|
|
53893
54231
|
if (!hyd)
|
|
@@ -53931,11 +54269,12 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53931
54269
|
const keyFnSrc = `(${itemVar}${node.indexVariable ? `, ${node.indexVariable}` : ""}) => ${keyExpr}`;
|
|
53932
54270
|
const reconciler = ctx2.n();
|
|
53933
54271
|
const initList = ctx2.n();
|
|
54272
|
+
const breakReset = breakVar ? `${breakVar} = false; ` : "";
|
|
53934
54273
|
ctx2.push(`let ${reconciler} = () => {};`);
|
|
53935
54274
|
if (hydKeyed) {
|
|
53936
|
-
ctx2.push(`const ${initList} = () => { ${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
|
|
54275
|
+
ctx2.push(`const ${initList} = () => { ${breakReset}${reconciler} = reconcileHydrated(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e, __root) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"}, null, __root), __hydrate, ${parent}, ${skipK}); };`);
|
|
53937
54276
|
} else {
|
|
53938
|
-
ctx2.push(`const ${initList} = () => { ${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
|
|
54277
|
+
ctx2.push(`const ${initList} = () => { ${breakReset}${reconciler} = reconcile(${anchor}, ${endAnchor}, ${arrExpr}, ${keyFnSrc}, (${itemVar}, __i, __e) => ${renderItem}(${itemVar}${indexParam ? ", __i, __e" : ", __e"})); };`);
|
|
53939
54278
|
}
|
|
53940
54279
|
if (emptyRenderName) {
|
|
53941
54280
|
const isEmptyVar = ctx2.n();
|
|
@@ -53947,7 +54286,7 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53947
54286
|
const __new = ${hasItems}();
|
|
53948
54287
|
if (__first) { __first = false; __new; return; }
|
|
53949
54288
|
if (__new !== ${isEmptyVar}) {
|
|
53950
|
-
if (__new) ${reconciler}(${arrExpr});
|
|
54289
|
+
if (__new) {${breakVar ? ` ${breakVar} = false;` : ""} ${reconciler}(${arrExpr}); }
|
|
53951
54290
|
return;
|
|
53952
54291
|
}
|
|
53953
54292
|
${isEmptyVar} = !__new;
|
|
@@ -53962,22 +54301,28 @@ function emitMap2(ctx2, node, tracked2, effTarget, parentVar, skipK = 0, regionB
|
|
|
53962
54301
|
return null;
|
|
53963
54302
|
pushEffect(`let __first = true;`, `effect(() => {
|
|
53964
54303
|
const __nv = ${arrExpr};
|
|
53965
|
-
if (__first) { __first = false; __nv; ${reconciler}(${arrExpr}); return; }
|
|
53966
|
-
${reconciler}(${arrExpr});
|
|
54304
|
+
if (__first) { __first = false; __nv; ${breakReset}${reconciler}(${arrExpr}); return; }
|
|
54305
|
+
${breakVar ? `if (${breakVar}) ${breakVar} = false;` : ""}${reconciler}(${arrExpr});
|
|
53967
54306
|
})`);
|
|
53968
54307
|
}
|
|
53969
54308
|
} else {
|
|
53970
54309
|
const renderAllItems = (ind, collect) => {
|
|
53971
54310
|
const lines = [];
|
|
54311
|
+
if (breakVar)
|
|
54312
|
+
lines.push(`${ind}${breakVar} = false;`);
|
|
53972
54313
|
if (node.indexVariable) {
|
|
53973
54314
|
lines.push(`${ind}let __i = 0;`);
|
|
53974
54315
|
lines.push(`${ind}for (const ${itemVar} of ${arrExpr}) {`);
|
|
53975
54316
|
lines.push(`${ind} ${aw}${renderItem}(${itemVar}, __i, ${effectsVar}${collect ? `, null, ${collect}` : ""});`);
|
|
53976
54317
|
lines.push(`${ind} __i++;`);
|
|
54318
|
+
if (breakVar)
|
|
54319
|
+
lines.push(`${ind} if (${breakVar}) break;`);
|
|
53977
54320
|
lines.push(`${ind}}`);
|
|
53978
54321
|
} else {
|
|
53979
54322
|
lines.push(`${ind}for (const ${itemVar} of ${arrExpr}) {`);
|
|
53980
54323
|
lines.push(`${ind} ${aw}${renderItem}(${itemVar}, ${effectsVar}${collect ? `, null, ${collect}` : ""});`);
|
|
54324
|
+
if (breakVar)
|
|
54325
|
+
lines.push(`${ind} if (${breakVar}) break;`);
|
|
53981
54326
|
lines.push(`${ind}}`);
|
|
53982
54327
|
}
|
|
53983
54328
|
return lines.join("\n");
|
|
@@ -61847,6 +62192,71 @@ function createVeskTools(deps) {
|
|
|
61847
62192
|
return tools;
|
|
61848
62193
|
}
|
|
61849
62194
|
|
|
62195
|
+
// ../adapter/dist/default-pages.js
|
|
62196
|
+
function escapeDefaultPageHtml2(value) {
|
|
62197
|
+
return String(value ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
62198
|
+
}
|
|
62199
|
+
var DEFAULT_PAGE_CSS2 = [
|
|
62200
|
+
":root{color-scheme:light;",
|
|
62201
|
+
"--vsk-bg:oklch(0.941 0.014 88);",
|
|
62202
|
+
"--vsk-fg:oklch(0.185 0.008 62);",
|
|
62203
|
+
"--vsk-surface:oklch(0.965 0.012 88);",
|
|
62204
|
+
"--vsk-muted:oklch(0.475 0.014 72);",
|
|
62205
|
+
"--vsk-accent:oklch(0.560 0.140 42);",
|
|
62206
|
+
"--vsk-border:oklch(0.86 0.012 82);",
|
|
62207
|
+
"--vsk-border-strong:oklch(0.72 0.014 80);",
|
|
62208
|
+
'--vsk-font:"Space Grotesk",ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;',
|
|
62209
|
+
'--vsk-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}',
|
|
62210
|
+
"@media (prefers-color-scheme:dark){:root{color-scheme:dark;",
|
|
62211
|
+
"--vsk-bg:oklch(0.155 0.006 60);",
|
|
62212
|
+
"--vsk-fg:oklch(0.931 0.014 88);",
|
|
62213
|
+
"--vsk-surface:oklch(0.196 0.008 70);",
|
|
62214
|
+
"--vsk-muted:oklch(0.618 0.016 80);",
|
|
62215
|
+
"--vsk-accent:oklch(0.632 0.132 45);",
|
|
62216
|
+
"--vsk-border:oklch(0.29 0.009 75);",
|
|
62217
|
+
"--vsk-border-strong:oklch(0.40 0.011 75);}}",
|
|
62218
|
+
"*{box-sizing:border-box}",
|
|
62219
|
+
"html,body{margin:0;min-height:100%}",
|
|
62220
|
+
"body{background:var(--vsk-bg);color:var(--vsk-fg);font-family:var(--vsk-font);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}",
|
|
62221
|
+
".vsk-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}",
|
|
62222
|
+
".vsk-page__card{width:100%;max-width:540px;border:1px solid var(--vsk-border);background:var(--vsk-surface);padding:clamp(28px,6vw,44px);text-align:center}",
|
|
62223
|
+
"@supports (background:color-mix(in oklab,red,red)){.vsk-page__card{background:color-mix(in oklab,var(--vsk-surface) 60%,transparent)}}",
|
|
62224
|
+
".vsk-page__brand{margin:0 0 26px;font-family:var(--vsk-mono);font-size:10px;line-height:1;letter-spacing:.24em;text-transform:uppercase;color:var(--vsk-muted)}",
|
|
62225
|
+
".vsk-page__brand b{color:var(--vsk-fg);font-weight:600}",
|
|
62226
|
+
".vsk-page__row{display:flex;align-items:center;justify-content:center;gap:0;flex-wrap:wrap}",
|
|
62227
|
+
".vsk-page__status{font-size:clamp(34px,9vw,46px);font-weight:600;line-height:1;letter-spacing:-.03em;padding-right:22px;margin-right:22px;border-right:1px solid var(--vsk-border-strong)}",
|
|
62228
|
+
".vsk-page--error .vsk-page__status{color:var(--vsk-accent)}",
|
|
62229
|
+
".vsk-page__msg{font-family:var(--vsk-mono);font-size:13px;line-height:1.5;color:var(--vsk-muted);text-align:left;max-width:270px}",
|
|
62230
|
+
"@media (max-width:440px){.vsk-page__row{flex-direction:column}.vsk-page__status{padding:0 0 16px;margin:0 0 16px;border-right:0;border-bottom:1px solid var(--vsk-border-strong)}.vsk-page__msg{text-align:center}}",
|
|
62231
|
+
".vsk-page__detail{margin:20px 0 0;font-family:var(--vsk-mono);font-size:11px;line-height:1.6;color:var(--vsk-muted);word-break:break-all}",
|
|
62232
|
+
".vsk-page__actions{margin-top:30px;display:flex;justify-content:center;gap:10px;flex-wrap:wrap}",
|
|
62233
|
+
".vsk-page__btn{display:inline-block;padding:11px 22px;font-size:13px;font-weight:500;line-height:1;text-decoration:none;border:1px solid var(--vsk-fg);background:var(--vsk-fg);color:var(--vsk-bg);transition:opacity .18s cubic-bezier(.2,0,0,1)}",
|
|
62234
|
+
".vsk-page__btn:hover{opacity:.86}",
|
|
62235
|
+
".vsk-page__btn--ghost{background:transparent;color:var(--vsk-fg);border-color:var(--vsk-border-strong)}",
|
|
62236
|
+
".vsk-page__btn--ghost:hover{background:var(--vsk-fg);color:var(--vsk-bg);border-color:var(--vsk-fg);opacity:1}"
|
|
62237
|
+
].join("");
|
|
62238
|
+
function renderDefaultPage2(opts = {}) {
|
|
62239
|
+
const status = opts.status ?? 404;
|
|
62240
|
+
const title = escapeDefaultPageHtml2(opts.title ?? `${status} \u2014 Vesk`);
|
|
62241
|
+
const message = escapeDefaultPageHtml2(opts.message ?? "This page could not be found.");
|
|
62242
|
+
const url = opts.url ? escapeDefaultPageHtml2(opts.url) : "";
|
|
62243
|
+
const headExtra = opts.headExtra || "";
|
|
62244
|
+
const homeHref = opts.homeHref === void 0 ? "/" : opts.homeHref;
|
|
62245
|
+
const homeLabel = escapeDefaultPageHtml2(opts.homeLabel ?? "Back to home");
|
|
62246
|
+
const variant = `vsk-page${opts.accentStatus ? " vsk-page--error" : ""}`;
|
|
62247
|
+
const action = homeHref === null ? "" : `<a class="vsk-page__btn" href="${escapeDefaultPageHtml2(homeHref)}">${homeLabel}</a>`;
|
|
62248
|
+
return `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="robots" content="noindex"><title>${title}</title><style>${DEFAULT_PAGE_CSS2}</style>` + headExtra + `</head><body><main class="${variant}" data-vesk-default-page="${status}"><div class="vsk-page__card"><p class="vsk-page__brand"><b>Vesk</b> \xB7 built-in error page</p><div class="vsk-page__row"><span class="vsk-page__status">${status}</span><span class="vsk-page__msg">${message}</span></div>` + (url ? `<p class="vsk-page__detail">${url}</p>` : "") + (action ? `<div class="vsk-page__actions">${action}</div>` : "") + "</div></main></body></html>";
|
|
62249
|
+
}
|
|
62250
|
+
function renderDefaultNotFoundPage2(opts = {}) {
|
|
62251
|
+
return renderDefaultPage2({
|
|
62252
|
+
status: 404,
|
|
62253
|
+
title: "404 \u2014 Not Found",
|
|
62254
|
+
message: "This page could not be found.",
|
|
62255
|
+
url: opts.url,
|
|
62256
|
+
headExtra: opts.headExtra
|
|
62257
|
+
});
|
|
62258
|
+
}
|
|
62259
|
+
|
|
61850
62260
|
// ../adapter/dist/css.js
|
|
61851
62261
|
import { readFileSync as readFileSync33, existsSync as existsSync37 } from "node:fs";
|
|
61852
62262
|
import { resolve as resolve33 } from "node:path";
|
|
@@ -61878,6 +62288,7 @@ import { WebSocketServer } from "ws";
|
|
|
61878
62288
|
import { readFileSync as readFileSync34, existsSync as existsSync38, writeFileSync as writeFileSync19 } from "node:fs";
|
|
61879
62289
|
import { resolve as resolve34, dirname as dirname24 } from "node:path";
|
|
61880
62290
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
62291
|
+
init_default_pages();
|
|
61881
62292
|
init_paths();
|
|
61882
62293
|
|
|
61883
62294
|
// ../adapter/src/error-codeframe.ts
|
|
@@ -64276,7 +64687,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
64276
64687
|
}
|
|
64277
64688
|
logRequest(404);
|
|
64278
64689
|
res.writeHead(404, { "Content-Type": "text/html" });
|
|
64279
|
-
res.end(notFoundHtml ||
|
|
64690
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage2({ url: url.pathname }));
|
|
64280
64691
|
return;
|
|
64281
64692
|
}
|
|
64282
64693
|
const urlParts = url.pathname.split("/").filter(Boolean);
|
|
@@ -64575,7 +64986,7 @@ ${prettifyHtml(body)}
|
|
|
64575
64986
|
}
|
|
64576
64987
|
logRequest(404);
|
|
64577
64988
|
res.writeHead(404, { "Content-Type": "text/html" });
|
|
64578
|
-
res.end(notFoundHtml ||
|
|
64989
|
+
res.end(notFoundHtml || renderDefaultNotFoundPage2({ url: url.pathname }));
|
|
64579
64990
|
} else {
|
|
64580
64991
|
let devPayload = null;
|
|
64581
64992
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.61",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
|
|
6
6
|
"bin": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/cli.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@vesk/adapter": "^0.2.
|
|
12
|
-
"@vesk/compiler": "^0.2.
|
|
13
|
-
"@vesk/plugin-tailwind": "^0.2.
|
|
14
|
-
"@vesk/runtime": "^0.2.
|
|
11
|
+
"@vesk/adapter": "^0.2.61",
|
|
12
|
+
"@vesk/compiler": "^0.2.61",
|
|
13
|
+
"@vesk/plugin-tailwind": "^0.2.61",
|
|
14
|
+
"@vesk/runtime": "^0.2.61",
|
|
15
15
|
"esrap": "^2.3.0",
|
|
16
16
|
"typescript": "^5.8.0",
|
|
17
17
|
"ws": "^8.18.0",
|