@vesk/vesk-cli 0.2.43 → 0.2.45
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 +990 -525
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -184,21 +184,36 @@ var init_errors = __esm({
|
|
|
184
184
|
tip: isBuiltin ? `"${name}" is a Vesk built-in. Use it directly \u2014 no manual import needed.` : ""
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
/**
|
|
188
|
+
* A `.vsk` namespace is resolved at the JSX-tag level: `<ns.Icon />` looks
|
|
189
|
+
* the component up in the registry by its exported name, exactly like
|
|
190
|
+
* `import { Icon }`, and no module object is ever built. The two forms that
|
|
191
|
+
* genuinely need a real module object are reported here.
|
|
192
|
+
*
|
|
193
|
+
* - `nested` — `<ns.Sub.Icon />`. A `.vsk` module's exports are flat
|
|
194
|
+
* component names, so there is no object to walk into.
|
|
195
|
+
* - `value` — `ns.max` read as a value. Component tags resolve; plain value
|
|
196
|
+
* reads do not, because nothing binds `ns` at runtime.
|
|
197
|
+
*/
|
|
198
|
+
static vskNamespaceMember(context = {}) {
|
|
199
|
+
const nested = context.form === "nested";
|
|
188
200
|
return new _VeskError(
|
|
189
|
-
"
|
|
201
|
+
nested ? "A `.vsk` namespace is flat, so `<ns.Sub.Icon />` cannot be resolved." : "A `.vsk` namespace resolves component tags only, so `ns.value` is not available.",
|
|
190
202
|
{
|
|
191
203
|
...context,
|
|
192
204
|
code: context.code || "V0410",
|
|
193
|
-
suggestions: [
|
|
194
|
-
"Import the component by name: import {
|
|
195
|
-
"
|
|
205
|
+
suggestions: nested ? [
|
|
206
|
+
"Import the component by name: import { Icon } from './icons.vsk'",
|
|
207
|
+
"Import from the module that owns Sub: import * as Sub from './sub.vsk'"
|
|
208
|
+
] : [
|
|
209
|
+
"Import the value by name: import { MAX } from './constants.vsk'",
|
|
210
|
+
"Move the value into a .ts module and import it from there \u2014 those are real ES modules with live bindings."
|
|
196
211
|
],
|
|
197
212
|
nextSteps: [
|
|
198
|
-
"A `.vsk`
|
|
199
|
-
"
|
|
213
|
+
"A `.vsk` tag resolves by component name in the global registry, not by module exports, so `import * as ns` + `<ns.Icon />` needs no module object.",
|
|
214
|
+
nested ? "Re-export with a flat name (`export { Icon }`) or import the component directly." : "Re-export the value under a flat name and import it directly, or keep the value in a .ts module."
|
|
200
215
|
],
|
|
201
|
-
tip: "
|
|
216
|
+
tip: "`<ns.Icon />` works; only nested paths and value reads need a real module namespace."
|
|
202
217
|
}
|
|
203
218
|
);
|
|
204
219
|
}
|
|
@@ -1644,11 +1659,11 @@ var init_context = __esm({
|
|
|
1644
1659
|
|
|
1645
1660
|
// ../runtime/src/server-events.ts
|
|
1646
1661
|
function getStore() {
|
|
1647
|
-
const
|
|
1648
|
-
if (!
|
|
1649
|
-
|
|
1662
|
+
const g4 = globalThis;
|
|
1663
|
+
if (!g4.__vesk_server_ctx || typeof g4.__vesk_server_ctx !== "object") {
|
|
1664
|
+
g4.__vesk_server_ctx = {};
|
|
1650
1665
|
}
|
|
1651
|
-
return
|
|
1666
|
+
return g4.__vesk_server_ctx;
|
|
1652
1667
|
}
|
|
1653
1668
|
function server_locals() {
|
|
1654
1669
|
return getStore();
|
|
@@ -2638,9 +2653,9 @@ function createHydrateWalker(container, markerList) {
|
|
|
2638
2653
|
}
|
|
2639
2654
|
function bumpNavEpoch() {
|
|
2640
2655
|
try {
|
|
2641
|
-
const
|
|
2642
|
-
const next = (
|
|
2643
|
-
|
|
2656
|
+
const g4 = globalThis;
|
|
2657
|
+
const next = (g4.__vesk_nav_epoch || 0) + 1;
|
|
2658
|
+
g4.__vesk_nav_epoch = next;
|
|
2644
2659
|
return next;
|
|
2645
2660
|
} catch {
|
|
2646
2661
|
return 0;
|
|
@@ -5320,8 +5335,8 @@ function createRouter(routes, options = {}) {
|
|
|
5320
5335
|
},
|
|
5321
5336
|
_runGuards(to) {
|
|
5322
5337
|
const from = get(_state.path) || window.location.pathname;
|
|
5323
|
-
for (const
|
|
5324
|
-
const d =
|
|
5338
|
+
for (const g4 of this._beforeGuards ?? []) {
|
|
5339
|
+
const d = g4(to, from);
|
|
5325
5340
|
if (d instanceof Promise) {
|
|
5326
5341
|
return d.then((r) => {
|
|
5327
5342
|
if (r === false || typeof r === "string") return r;
|
|
@@ -5647,8 +5662,8 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
5647
5662
|
},
|
|
5648
5663
|
_runGuards(to) {
|
|
5649
5664
|
const from = get(_state.path) || window.location.pathname;
|
|
5650
|
-
for (const
|
|
5651
|
-
const d =
|
|
5665
|
+
for (const g4 of this._beforeGuards ?? []) {
|
|
5666
|
+
const d = g4(to, from);
|
|
5652
5667
|
if (d instanceof Promise) {
|
|
5653
5668
|
return d.then((r) => {
|
|
5654
5669
|
if (r === false || typeof r === "string") return r;
|
|
@@ -20181,17 +20196,125 @@ function jsxTagRootName(nameNode) {
|
|
|
20181
20196
|
while (node && node.type === "JSXMemberExpression") node = node.object;
|
|
20182
20197
|
return node && node.type === "JSXIdentifier" ? node.name : "";
|
|
20183
20198
|
}
|
|
20199
|
+
function jsxTagMemberName(nameNode) {
|
|
20200
|
+
let node = nameNode;
|
|
20201
|
+
while (node && node.type === "JSXMemberExpression") {
|
|
20202
|
+
node = node.property;
|
|
20203
|
+
if (node && node.type === "JSXIdentifier") return node.name;
|
|
20204
|
+
}
|
|
20205
|
+
return "";
|
|
20206
|
+
}
|
|
20207
|
+
function jsxTagDepth(nameNode) {
|
|
20208
|
+
let depth = 0;
|
|
20209
|
+
let node = nameNode;
|
|
20210
|
+
while (node && node.type === "JSXMemberExpression") {
|
|
20211
|
+
depth++;
|
|
20212
|
+
node = node.object;
|
|
20213
|
+
}
|
|
20214
|
+
return depth;
|
|
20215
|
+
}
|
|
20184
20216
|
function collectVskNamespaceLocals(ast) {
|
|
20185
|
-
const
|
|
20217
|
+
const namespaceLocals = /* @__PURE__ */ new Map();
|
|
20186
20218
|
for (const node of ast.body || []) {
|
|
20187
20219
|
if (node.type !== "ImportDeclaration") continue;
|
|
20188
20220
|
if (typeof node.source?.value !== "string" || !node.source.value.endsWith(".vsk")) continue;
|
|
20189
20221
|
for (const spec of node.specifiers || []) {
|
|
20190
|
-
if (spec.type === "ImportNamespaceSpecifier" && spec.local?.name)
|
|
20222
|
+
if (spec.type === "ImportNamespaceSpecifier" && spec.local?.name) {
|
|
20223
|
+
namespaceLocals.set(spec.local.name, { path: node.source.value, shadowed: false });
|
|
20224
|
+
}
|
|
20225
|
+
}
|
|
20226
|
+
}
|
|
20227
|
+
if (namespaceLocals.size === 0) return /* @__PURE__ */ new Set();
|
|
20228
|
+
markShadowedBindings(ast, namespaceLocals);
|
|
20229
|
+
return new Set([...namespaceLocals].filter(([, v]) => !v.shadowed).map(([k]) => k));
|
|
20230
|
+
}
|
|
20231
|
+
function markShadowedBindings(node, namespaceLocals) {
|
|
20232
|
+
if (!node || typeof node !== "object") return;
|
|
20233
|
+
if (Array.isArray(node)) {
|
|
20234
|
+
for (const child of node) markShadowedBindings(child, namespaceLocals);
|
|
20235
|
+
return;
|
|
20236
|
+
}
|
|
20237
|
+
if (typeof node.type === "string") {
|
|
20238
|
+
if (node.type === "ImportNamespaceSpecifier") return;
|
|
20239
|
+
for (const name of declaredBindingNames(node)) {
|
|
20240
|
+
const entry = namespaceLocals.get(name);
|
|
20241
|
+
if (entry) entry.shadowed = true;
|
|
20191
20242
|
}
|
|
20192
20243
|
}
|
|
20244
|
+
for (const key of Object.keys(node)) {
|
|
20245
|
+
if (key === "loc" || key === "range" || key === "start" || key === "end") continue;
|
|
20246
|
+
markShadowedBindings(node[key], namespaceLocals);
|
|
20247
|
+
}
|
|
20248
|
+
}
|
|
20249
|
+
function declaredBindingNames(node) {
|
|
20250
|
+
const out = [];
|
|
20251
|
+
const pushPattern = (id) => {
|
|
20252
|
+
if (!id) return;
|
|
20253
|
+
if (id.type === "Identifier") {
|
|
20254
|
+
out.push(id.name);
|
|
20255
|
+
return;
|
|
20256
|
+
}
|
|
20257
|
+
if (id.type === "ObjectPattern") {
|
|
20258
|
+
for (const prop of id.properties || []) {
|
|
20259
|
+
if (prop.type === "RestElement") pushPattern(prop.argument);
|
|
20260
|
+
else pushPattern(prop.value);
|
|
20261
|
+
}
|
|
20262
|
+
return;
|
|
20263
|
+
}
|
|
20264
|
+
if (id.type === "ArrayPattern") {
|
|
20265
|
+
for (const el of id.elements || []) if (el) pushPattern(el.type === "RestElement" ? el.argument : el);
|
|
20266
|
+
return;
|
|
20267
|
+
}
|
|
20268
|
+
if (id.type === "AssignmentPattern") pushPattern(id.left);
|
|
20269
|
+
if (id.type === "RestElement") pushPattern(id.argument);
|
|
20270
|
+
};
|
|
20271
|
+
switch (node.type) {
|
|
20272
|
+
case "VariableDeclarator":
|
|
20273
|
+
pushPattern(node.id);
|
|
20274
|
+
break;
|
|
20275
|
+
case "FunctionDeclaration":
|
|
20276
|
+
case "FunctionExpression":
|
|
20277
|
+
case "ArrowFunctionExpression":
|
|
20278
|
+
if (node.id) pushPattern(node.id);
|
|
20279
|
+
for (const param of node.params || []) pushPattern(param);
|
|
20280
|
+
break;
|
|
20281
|
+
case "ClassDeclaration":
|
|
20282
|
+
case "ClassExpression":
|
|
20283
|
+
if (node.id) pushPattern(node.id);
|
|
20284
|
+
break;
|
|
20285
|
+
case "CatchClause":
|
|
20286
|
+
pushPattern(node.param);
|
|
20287
|
+
break;
|
|
20288
|
+
default:
|
|
20289
|
+
break;
|
|
20290
|
+
}
|
|
20193
20291
|
return out;
|
|
20194
20292
|
}
|
|
20293
|
+
function assertNoVskNamespaceValue(source, expr) {
|
|
20294
|
+
if (!currentVskNamespaceLocals || currentVskNamespaceLocals.size === 0) return;
|
|
20295
|
+
const hit = findNamespaceValueUse(expr, currentVskNamespaceLocals);
|
|
20296
|
+
if (!hit) return;
|
|
20297
|
+
const { line, column } = offsetToLineCol2(source, hit.start ?? 0);
|
|
20298
|
+
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, code: codeFrame(source, line, column), form: "value" });
|
|
20299
|
+
}
|
|
20300
|
+
function findNamespaceValueUse(node, locals2) {
|
|
20301
|
+
if (!node || typeof node !== "object") return null;
|
|
20302
|
+
if (Array.isArray(node)) {
|
|
20303
|
+
for (const child of node) {
|
|
20304
|
+
const hit = findNamespaceValueUse(child, locals2);
|
|
20305
|
+
if (hit) return hit;
|
|
20306
|
+
}
|
|
20307
|
+
return null;
|
|
20308
|
+
}
|
|
20309
|
+
if (typeof node.type !== "string") return null;
|
|
20310
|
+
if (node.type === "MemberExpression" && node.object?.type === "Identifier" && locals2.has(node.object.name)) return node;
|
|
20311
|
+
for (const key of Object.keys(node)) {
|
|
20312
|
+
if (key === "loc" || key === "range" || key === "start" || key === "end") continue;
|
|
20313
|
+
const hit = findNamespaceValueUse(node[key], locals2);
|
|
20314
|
+
if (hit) return hit;
|
|
20315
|
+
}
|
|
20316
|
+
return null;
|
|
20317
|
+
}
|
|
20195
20318
|
function isHTMLTag(name) {
|
|
20196
20319
|
return name.length > 0 && name[0] === name[0].toLowerCase();
|
|
20197
20320
|
}
|
|
@@ -20199,6 +20322,7 @@ function isMapCall(expr) {
|
|
|
20199
20322
|
return expr.type === "CallExpression" && expr.callee.type === "MemberExpression" && expr.callee.property.name === "map" && expr.arguments.length === 1 && expr.arguments[0].type === "ArrowFunctionExpression";
|
|
20200
20323
|
}
|
|
20201
20324
|
function toExpression(source, expr) {
|
|
20325
|
+
assertNoVskNamespaceValue(source, expr);
|
|
20202
20326
|
return new Expression(getSource(source, expr), [], expr, source);
|
|
20203
20327
|
}
|
|
20204
20328
|
function processAttribute(source, attr) {
|
|
@@ -20561,12 +20685,16 @@ function processJSXElement(source, element) {
|
|
|
20561
20685
|
}
|
|
20562
20686
|
if (nameNode && nameNode.type === "JSXMemberExpression") {
|
|
20563
20687
|
const root3 = jsxTagRootName(nameNode);
|
|
20564
|
-
|
|
20688
|
+
const isVskNamespace = !!currentVskNamespaceLocals && currentVskNamespaceLocals.has(root3);
|
|
20689
|
+
if (isVskNamespace && jsxTagDepth(nameNode) > 1) {
|
|
20565
20690
|
const { line, column } = offsetToLineCol2(source, nameNode.start ?? 0);
|
|
20566
|
-
throw VeskError.
|
|
20691
|
+
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, code: codeFrame(source, line, column), form: "nested" });
|
|
20567
20692
|
}
|
|
20568
20693
|
const { props, spreadProps, slots } = extractProps(source, element);
|
|
20569
20694
|
const children2 = selfClosing ? [] : processJSXChildren(source, element.children || []);
|
|
20695
|
+
if (isVskNamespace) {
|
|
20696
|
+
return [new ComponentCall(jsxTagMemberName(nameNode), props, [...children2, ...slots.map((s) => new PropSlot(s.name, s.nodes))], spreadProps, element.start)];
|
|
20697
|
+
}
|
|
20570
20698
|
return [new ComponentCall(tagName, props, [...children2, ...slots.map((s) => new PropSlot(s.name, s.nodes))], spreadProps, element.start, getSource(source, nameNode))];
|
|
20571
20699
|
}
|
|
20572
20700
|
if (!isHTMLTag(tagName) && selfClosing) {
|
|
@@ -21621,16 +21749,16 @@ function sha256Bytes(msg) {
|
|
|
21621
21749
|
const s1 = rr(w[j - 2], 17) ^ rr(w[j - 2], 19) ^ w[j - 2] >>> 10;
|
|
21622
21750
|
w[j] = w[j - 16] + s0 + w[j - 7] + s1 >>> 0;
|
|
21623
21751
|
}
|
|
21624
|
-
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5,
|
|
21752
|
+
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g4 = h6, h = h7;
|
|
21625
21753
|
for (let j = 0; j < 64; j++) {
|
|
21626
21754
|
const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
|
|
21627
|
-
const ch = e & f ^ ~e &
|
|
21755
|
+
const ch = e & f ^ ~e & g4;
|
|
21628
21756
|
const t1 = h + S1 + ch + SHA_K[j] + w[j] >>> 0;
|
|
21629
21757
|
const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
|
|
21630
21758
|
const maj = a & b ^ a & c ^ b & c;
|
|
21631
21759
|
const t2 = S0 + maj >>> 0;
|
|
21632
|
-
h =
|
|
21633
|
-
|
|
21760
|
+
h = g4;
|
|
21761
|
+
g4 = f;
|
|
21634
21762
|
f = e;
|
|
21635
21763
|
e = d + t1 >>> 0;
|
|
21636
21764
|
d = c;
|
|
@@ -21644,7 +21772,7 @@ function sha256Bytes(msg) {
|
|
|
21644
21772
|
h3 = h3 + d >>> 0;
|
|
21645
21773
|
h4 = h4 + e >>> 0;
|
|
21646
21774
|
h5 = h5 + f >>> 0;
|
|
21647
|
-
h6 = h6 +
|
|
21775
|
+
h6 = h6 + g4 >>> 0;
|
|
21648
21776
|
h7 = h7 + h >>> 0;
|
|
21649
21777
|
}
|
|
21650
21778
|
const out = new Uint8Array(32);
|
|
@@ -22695,23 +22823,23 @@ async function _getImpl() {
|
|
|
22695
22823
|
return _signImpl;
|
|
22696
22824
|
}
|
|
22697
22825
|
async function signCookie2(name, value, host) {
|
|
22698
|
-
const
|
|
22699
|
-
if (
|
|
22826
|
+
const impl3 = await _getImpl();
|
|
22827
|
+
if (impl3.signCookie) return impl3.signCookie(name, value, host);
|
|
22700
22828
|
throw new Error("signCookie: @vesk/compiler not available");
|
|
22701
22829
|
}
|
|
22702
22830
|
async function unsignCookie2(name, signedValue, host) {
|
|
22703
|
-
const
|
|
22704
|
-
if (
|
|
22831
|
+
const impl3 = await _getImpl();
|
|
22832
|
+
if (impl3.unsignCookie) return impl3.unsignCookie(name, signedValue, host);
|
|
22705
22833
|
throw new Error("unsignCookie: @vesk/compiler not available");
|
|
22706
22834
|
}
|
|
22707
22835
|
async function setSignedCookie2(name, value, options = {}, host) {
|
|
22708
|
-
const
|
|
22709
|
-
if (
|
|
22836
|
+
const impl3 = await _getImpl();
|
|
22837
|
+
if (impl3.setSignedCookie) return impl3.setSignedCookie(name, value, options, host);
|
|
22710
22838
|
throw new Error("setSignedCookie: @vesk/compiler not available");
|
|
22711
22839
|
}
|
|
22712
22840
|
async function readSignedCookie2(name, cookieString, host) {
|
|
22713
|
-
const
|
|
22714
|
-
if (
|
|
22841
|
+
const impl3 = await _getImpl();
|
|
22842
|
+
if (impl3.readSignedCookie) return impl3.readSignedCookie(name, cookieString, host);
|
|
22715
22843
|
throw new Error("readSignedCookie: @vesk/compiler not available");
|
|
22716
22844
|
}
|
|
22717
22845
|
var ServerRequest, ServerResponse, DEFAULT_MAX_BODY_BYTES2, PayloadTooLargeError, VeskRequest, _VeskResponse, VeskResponse, _signImpl;
|
|
@@ -26227,9 +26355,9 @@ var init_primitive = __esm({
|
|
|
26227
26355
|
|
|
26228
26356
|
// ../runtime/src/action.ts
|
|
26229
26357
|
function getActionRegistry() {
|
|
26230
|
-
const
|
|
26231
|
-
if (!
|
|
26232
|
-
return
|
|
26358
|
+
const g4 = globalThis;
|
|
26359
|
+
if (!g4[registryKey]) g4[registryKey] = {};
|
|
26360
|
+
return g4[registryKey];
|
|
26233
26361
|
}
|
|
26234
26362
|
function hashString(str3) {
|
|
26235
26363
|
let h1 = 2166136261;
|
|
@@ -26267,8 +26395,8 @@ function getAction(id) {
|
|
|
26267
26395
|
return getActionRegistry()[id] || null;
|
|
26268
26396
|
}
|
|
26269
26397
|
function clearActions() {
|
|
26270
|
-
const
|
|
26271
|
-
|
|
26398
|
+
const g4 = globalThis;
|
|
26399
|
+
g4[registryKey] = {};
|
|
26272
26400
|
}
|
|
26273
26401
|
function isFormAction(action) {
|
|
26274
26402
|
return typeof action === "object" && action !== null && (action.__veskAction === true || typeof action.id === "string" && typeof action.url === "string");
|
|
@@ -30999,15 +31127,23 @@ function compileClientBoth(source, _componentName, sourcePath2, opts) {
|
|
|
30999
31127
|
const comp = emitClientFromIR(ir, { forceClient: true, nameAllocator: alloc });
|
|
31000
31128
|
const aliases = vskRegistryAliases(ir.imports, ir.exportAliases);
|
|
31001
31129
|
const reexportPaths = sourcePath2 ? collectVskReexportPaths(ir.reexportSources, sourcePath2) : [];
|
|
31002
|
-
if (opts?.skipHyd) return { comp, hyd: "", name, aliases, reexportPaths };
|
|
31130
|
+
if (opts?.skipHyd) return { comp, hyd: "", name, aliases, reexportPaths, componentNames: ir.components.map((c) => c.name) };
|
|
31003
31131
|
return {
|
|
31004
31132
|
comp,
|
|
31005
31133
|
hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
|
|
31006
31134
|
name,
|
|
31007
31135
|
aliases,
|
|
31008
|
-
reexportPaths
|
|
31136
|
+
reexportPaths,
|
|
31137
|
+
// Every component NAME this file registers, not just the resolved one —
|
|
31138
|
+
// the bundle needs the full list to spot same-name declarations across
|
|
31139
|
+
// files (see findVskComponentCollisions).
|
|
31140
|
+
componentNames: ir.components.map((c) => c.name)
|
|
31009
31141
|
};
|
|
31010
31142
|
}
|
|
31143
|
+
function vskComponentNames(source, sourcePath2) {
|
|
31144
|
+
const ast = parse4(source, sourcePath2 ? { filename: sourcePath2 } : {});
|
|
31145
|
+
return generateIR(ast, source, sourcePath2).components.map((c) => c.name);
|
|
31146
|
+
}
|
|
31011
31147
|
var BINDING_REF_CALLS, NON_BUBBLING_EVENTS, Ctx, PROPERTY_ATTRS;
|
|
31012
31148
|
var init_client_codegen = __esm({
|
|
31013
31149
|
"../compiler/src/client-codegen.ts"() {
|
|
@@ -31608,35 +31744,159 @@ var init_server_jsgen = __esm({
|
|
|
31608
31744
|
|
|
31609
31745
|
// ../compiler/src/ssr-store.ts
|
|
31610
31746
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
31747
|
+
function newSsrToken() {
|
|
31748
|
+
return Math.random().toString(36).slice(2);
|
|
31749
|
+
}
|
|
31750
|
+
function createSsrStore() {
|
|
31751
|
+
return { token: newSsrToken(), data: {} };
|
|
31752
|
+
}
|
|
31753
|
+
function adoptSsrStore() {
|
|
31754
|
+
return storage.getStore() ?? createSsrStore();
|
|
31755
|
+
}
|
|
31756
|
+
function isThenable(value) {
|
|
31757
|
+
return typeof value?.then === "function";
|
|
31758
|
+
}
|
|
31611
31759
|
function withSsrStore(fn) {
|
|
31612
31760
|
const existing = storage.getStore();
|
|
31613
31761
|
if (existing) return fn();
|
|
31614
|
-
|
|
31762
|
+
const store = createSsrStore();
|
|
31763
|
+
keepSsrSlot(store.token);
|
|
31764
|
+
let result;
|
|
31765
|
+
try {
|
|
31766
|
+
result = storage.run(store, fn);
|
|
31767
|
+
} catch (err) {
|
|
31768
|
+
dropSsrSlot(store.token);
|
|
31769
|
+
throw err;
|
|
31770
|
+
}
|
|
31771
|
+
if (isThenable(result)) {
|
|
31772
|
+
return result.then(
|
|
31773
|
+
(value) => {
|
|
31774
|
+
dropSsrSlot(store.token);
|
|
31775
|
+
return value;
|
|
31776
|
+
},
|
|
31777
|
+
(err) => {
|
|
31778
|
+
dropSsrSlot(store.token);
|
|
31779
|
+
throw err;
|
|
31780
|
+
}
|
|
31781
|
+
);
|
|
31782
|
+
}
|
|
31783
|
+
dropSsrSlot(store.token);
|
|
31784
|
+
return result;
|
|
31615
31785
|
}
|
|
31616
|
-
|
|
31786
|
+
function withSsrStoreOf(store, fn) {
|
|
31787
|
+
return storage.run(store, fn);
|
|
31788
|
+
}
|
|
31789
|
+
function keepSsrSlot(token) {
|
|
31790
|
+
if (!token) return;
|
|
31791
|
+
liveSlots.set(token, (liveSlots.get(token) ?? 0) + 1);
|
|
31792
|
+
}
|
|
31793
|
+
function dropSsrSlot(token) {
|
|
31794
|
+
if (!token) return;
|
|
31795
|
+
const count = liveSlots.get(token);
|
|
31796
|
+
if (count === void 0) return;
|
|
31797
|
+
if (count <= 1) liveSlots.delete(token);
|
|
31798
|
+
else liveSlots.set(token, count - 1);
|
|
31799
|
+
}
|
|
31800
|
+
function isSsrSlotLive(token) {
|
|
31801
|
+
return liveSlots.has(token);
|
|
31802
|
+
}
|
|
31803
|
+
var TOKEN_KEY, IMPL_KEY, g2, impl, storage, liveSlots, ssrSink2;
|
|
31617
31804
|
var init_ssr_store = __esm({
|
|
31618
31805
|
"../compiler/src/ssr-store.ts"() {
|
|
31619
31806
|
"use strict";
|
|
31620
31807
|
init_index_server();
|
|
31621
|
-
|
|
31808
|
+
TOKEN_KEY = "__vsk_ssr_token";
|
|
31809
|
+
IMPL_KEY = "__vsk_ssr_store_impl";
|
|
31810
|
+
g2 = globalThis;
|
|
31811
|
+
impl = g2[IMPL_KEY] ?? (g2[IMPL_KEY] = {
|
|
31812
|
+
storage: new AsyncLocalStorage(),
|
|
31813
|
+
liveSlots: /* @__PURE__ */ new Map(),
|
|
31814
|
+
// Only the copy that created the implementation installs the token
|
|
31815
|
+
// accessor; a later copy must not redefine it over the shared storage.
|
|
31816
|
+
ownsAccessor: true
|
|
31817
|
+
});
|
|
31818
|
+
storage = impl.storage;
|
|
31819
|
+
liveSlots = impl.liveSlots;
|
|
31622
31820
|
ssrSink2 = {
|
|
31623
31821
|
set: (key, value) => {
|
|
31624
31822
|
const store = storage.getStore();
|
|
31625
|
-
if (store) store[key] = value;
|
|
31823
|
+
if (store) store.data[key] = value;
|
|
31626
31824
|
},
|
|
31627
31825
|
get: (key) => {
|
|
31628
31826
|
const store = storage.getStore();
|
|
31629
|
-
return store ? store[key] : void 0;
|
|
31827
|
+
return store ? store.data[key] : void 0;
|
|
31630
31828
|
},
|
|
31631
|
-
snapshot: () => ({ ...storage.getStore() ?? {} }),
|
|
31829
|
+
snapshot: () => ({ ...storage.getStore()?.data ?? {} }),
|
|
31632
31830
|
clear: () => {
|
|
31633
31831
|
const store = storage.getStore();
|
|
31634
31832
|
if (store) {
|
|
31635
|
-
for (const key of Object.keys(store)) delete store[key];
|
|
31833
|
+
for (const key of Object.keys(store.data)) delete store.data[key];
|
|
31636
31834
|
}
|
|
31637
31835
|
}
|
|
31638
31836
|
};
|
|
31639
31837
|
setSsrSink(ssrSink2);
|
|
31838
|
+
if (impl.ownsAccessor) {
|
|
31839
|
+
Object.defineProperty(globalThis, TOKEN_KEY, {
|
|
31840
|
+
configurable: true,
|
|
31841
|
+
get() {
|
|
31842
|
+
return storage.getStore()?.token;
|
|
31843
|
+
},
|
|
31844
|
+
set(value) {
|
|
31845
|
+
const store = storage.getStore();
|
|
31846
|
+
if (store) store.token = value;
|
|
31847
|
+
}
|
|
31848
|
+
});
|
|
31849
|
+
}
|
|
31850
|
+
}
|
|
31851
|
+
});
|
|
31852
|
+
|
|
31853
|
+
// ../compiler/src/vsk-collision.ts
|
|
31854
|
+
var VskComponentOwners, reportedCollisions;
|
|
31855
|
+
var init_vsk_collision = __esm({
|
|
31856
|
+
"../compiler/src/vsk-collision.ts"() {
|
|
31857
|
+
"use strict";
|
|
31858
|
+
VskComponentOwners = class {
|
|
31859
|
+
owners = /* @__PURE__ */ new Map();
|
|
31860
|
+
/** Records that `file` declares a component called `name`. */
|
|
31861
|
+
claim(name, file) {
|
|
31862
|
+
let set2 = this.owners.get(name);
|
|
31863
|
+
if (!set2) {
|
|
31864
|
+
set2 = /* @__PURE__ */ new Set();
|
|
31865
|
+
this.owners.set(name, set2);
|
|
31866
|
+
}
|
|
31867
|
+
set2.add(file);
|
|
31868
|
+
}
|
|
31869
|
+
/** Names declared by more than one file, each with its declaring files. */
|
|
31870
|
+
collisions() {
|
|
31871
|
+
const out = [];
|
|
31872
|
+
for (const [name, files] of this.owners) {
|
|
31873
|
+
if (files.size > 1) out.push({ name, files: [...files] });
|
|
31874
|
+
}
|
|
31875
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
31876
|
+
}
|
|
31877
|
+
/**
|
|
31878
|
+
* Warns once per colliding name. Returns the message per collision so a
|
|
31879
|
+
* caller (or a test) can assert on the text without capturing stderr.
|
|
31880
|
+
*
|
|
31881
|
+
* Deduped by name for the life of the process: the SSR path compiles one
|
|
31882
|
+
* file graph per `compileFile` call, so without this a single build would
|
|
31883
|
+
* repeat the same warning once per entry page.
|
|
31884
|
+
*/
|
|
31885
|
+
report(context) {
|
|
31886
|
+
const collisions = this.collisions();
|
|
31887
|
+
const fresh = [];
|
|
31888
|
+
for (const { name, files } of collisions) {
|
|
31889
|
+
if (reportedCollisions.has(name)) continue;
|
|
31890
|
+
reportedCollisions.add(name);
|
|
31891
|
+
fresh.push(`${name}: ${files.join(", ")}`);
|
|
31892
|
+
console.warn(
|
|
31893
|
+
`[vesk] ${context}: component "${name}" is declared in ${files.length} files and resolves to only one of them \u2014 ${files.join(", ")}. Which one wins depends on compile order, and the client and server registries pick differently, so this can render a different component in the browser than in the SSR HTML. Rename one of them.`
|
|
31894
|
+
);
|
|
31895
|
+
}
|
|
31896
|
+
return fresh;
|
|
31897
|
+
}
|
|
31898
|
+
};
|
|
31899
|
+
reportedCollisions = /* @__PURE__ */ new Set();
|
|
31640
31900
|
}
|
|
31641
31901
|
});
|
|
31642
31902
|
|
|
@@ -31660,9 +31920,12 @@ function scopedVesk(fn, fallback) {
|
|
|
31660
31920
|
return fn.__veskScope || fallback;
|
|
31661
31921
|
}
|
|
31662
31922
|
function compileFile(source, options) {
|
|
31663
|
-
|
|
31923
|
+
const owners = new VskComponentOwners();
|
|
31924
|
+
const result = compileFileInternal(source, options?.sourcePath, /* @__PURE__ */ new Set(), owners);
|
|
31925
|
+
owners.report("SSR");
|
|
31926
|
+
return result;
|
|
31664
31927
|
}
|
|
31665
|
-
function compileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
31928
|
+
function compileFileInternal(source, sourcePath2, seenImportFiles, owners) {
|
|
31666
31929
|
if (sourcePath2) {
|
|
31667
31930
|
const dir = dirname7(sourcePath2);
|
|
31668
31931
|
source = inlineMdImportsFrom(source, sourcePath2, guessProjectRoots(dir));
|
|
@@ -31671,6 +31934,7 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
|
31671
31934
|
const ir = generateIR(ast, source, sourcePath2);
|
|
31672
31935
|
const componentMap = buildComponentMap2(ir, true);
|
|
31673
31936
|
const ownComponentNames = ir.components.map((c) => c.name);
|
|
31937
|
+
if (sourcePath2 && owners) for (const n of ownComponentNames) owners.claim(n, sourcePath2);
|
|
31674
31938
|
const __vesk = loadRuntimeImports(ir.imports);
|
|
31675
31939
|
applyLocalModuleImports(__vesk, ir.imports, sourcePath2);
|
|
31676
31940
|
if (sourcePath2) {
|
|
@@ -31687,7 +31951,7 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
|
31687
31951
|
} catch {
|
|
31688
31952
|
continue;
|
|
31689
31953
|
}
|
|
31690
|
-
const sub = compileFileInternal(importedSrc, importPath, seenImportFiles);
|
|
31954
|
+
const sub = compileFileInternal(importedSrc, importPath, seenImportFiles, owners);
|
|
31691
31955
|
for (const [name, fn] of sub.componentMap) {
|
|
31692
31956
|
if (!componentMap.has(name)) componentMap.set(name, fn);
|
|
31693
31957
|
}
|
|
@@ -31716,29 +31980,32 @@ function render2(source, componentName, props = {}, registry = /* @__PURE__ */ n
|
|
|
31716
31980
|
const targetComp = compiled.ir.components.find((c) => c.name === componentName);
|
|
31717
31981
|
const isAsyncComp = !!(targetComp && (targetComp.isAsync || targetComp.ssrAwait));
|
|
31718
31982
|
globalThis.__vsk_ssr = true;
|
|
31719
|
-
|
|
31720
|
-
|
|
31721
|
-
|
|
31722
|
-
|
|
31723
|
-
|
|
31724
|
-
|
|
31725
|
-
bodyHtml2
|
|
31726
|
-
|
|
31727
|
-
|
|
31728
|
-
|
|
31729
|
-
|
|
31730
|
-
|
|
31731
|
-
|
|
31732
|
-
|
|
31733
|
-
|
|
31734
|
-
|
|
31735
|
-
|
|
31736
|
-
bodyHtml
|
|
31737
|
-
|
|
31738
|
-
|
|
31739
|
-
|
|
31740
|
-
|
|
31741
|
-
|
|
31983
|
+
return withSsrStore(() => {
|
|
31984
|
+
if (!globalThis.__vsk_ssr_token) globalThis.__vsk_ssr_token = Math.random().toString(36).slice(2);
|
|
31985
|
+
const renderToken = globalThis.__vsk_ssr_token;
|
|
31986
|
+
keepSsrSlot(renderToken);
|
|
31987
|
+
if (isAsyncComp) {
|
|
31988
|
+
return (async () => {
|
|
31989
|
+
let bodyHtml2;
|
|
31990
|
+
try {
|
|
31991
|
+
bodyHtml2 = await renderFn(props, fullRegistry, scopedVesk(renderFn, __vesk));
|
|
31992
|
+
} finally {
|
|
31993
|
+
delete globalThis.__vsk_ssr;
|
|
31994
|
+
await settleSsrPromises(renderToken);
|
|
31995
|
+
clearSsrCells(renderToken);
|
|
31996
|
+
}
|
|
31997
|
+
return bodyHtml2;
|
|
31998
|
+
})();
|
|
31999
|
+
}
|
|
32000
|
+
let bodyHtml;
|
|
32001
|
+
try {
|
|
32002
|
+
bodyHtml = renderFn(props, fullRegistry, scopedVesk(renderFn, __vesk));
|
|
32003
|
+
} finally {
|
|
32004
|
+
delete globalThis.__vsk_ssr;
|
|
32005
|
+
clearSsrCells(renderToken);
|
|
32006
|
+
}
|
|
32007
|
+
return bodyHtml;
|
|
32008
|
+
});
|
|
31742
32009
|
}
|
|
31743
32010
|
function renderPage(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
|
|
31744
32011
|
resetVskState(!!options.hydrate, options.markerless !== false);
|
|
@@ -31762,9 +32029,10 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
|
|
|
31762
32029
|
globalThis.__vsk_ssr = true;
|
|
31763
32030
|
if (!globalThis.__vsk_ssr_token) globalThis.__vsk_ssr_token = Math.random().toString(36).slice(2);
|
|
31764
32031
|
const renderToken = globalThis.__vsk_ssr_token;
|
|
32032
|
+
keepSsrSlot(renderToken);
|
|
31765
32033
|
pruneSsrDataSlots();
|
|
31766
32034
|
if (targetComp && (targetComp.isAsync || targetComp.ssrAwait)) {
|
|
31767
|
-
return
|
|
32035
|
+
return (async () => {
|
|
31768
32036
|
let bodyHtml2;
|
|
31769
32037
|
try {
|
|
31770
32038
|
bodyHtml2 = await renderFn(ssrProps, fullRegistry, scopedVesk(renderFn, __vesk));
|
|
@@ -31778,22 +32046,22 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
|
|
|
31778
32046
|
head: renderHeadHtml(targetComp, ssrProps),
|
|
31779
32047
|
props: ssrProps
|
|
31780
32048
|
};
|
|
31781
|
-
})()
|
|
32049
|
+
})();
|
|
31782
32050
|
}
|
|
31783
32051
|
let bodyHtml;
|
|
31784
32052
|
try {
|
|
31785
|
-
bodyHtml =
|
|
32053
|
+
bodyHtml = renderFn(ssrProps, fullRegistry, scopedVesk(renderFn, __vesk));
|
|
31786
32054
|
} finally {
|
|
31787
32055
|
delete globalThis.__vsk_ssr;
|
|
31788
32056
|
}
|
|
31789
32057
|
const headHtml = targetComp ? renderHeadHtml(targetComp, ssrProps) : "";
|
|
31790
32058
|
const pending = globalThis[`__vsk_ssr_promises_${renderToken}`];
|
|
31791
32059
|
if (pending && pending.length > 0) {
|
|
31792
|
-
return
|
|
32060
|
+
return (async () => {
|
|
31793
32061
|
await settleSsrPromises(renderToken);
|
|
31794
32062
|
clearSsrCells(renderToken);
|
|
31795
32063
|
return { body: bodyHtml, head: headHtml, props: ssrProps };
|
|
31796
|
-
})()
|
|
32064
|
+
})();
|
|
31797
32065
|
}
|
|
31798
32066
|
clearSsrCells(renderToken);
|
|
31799
32067
|
return { body: bodyHtml, head: headHtml, props: ssrProps };
|
|
@@ -31817,6 +32085,7 @@ function clearSsrCells(token) {
|
|
|
31817
32085
|
if (!token) return;
|
|
31818
32086
|
delete globalThis[`__vsk_ssr_promises_${token}`];
|
|
31819
32087
|
delete globalThis[`__vsk_ssr_failures_${token}`];
|
|
32088
|
+
dropSsrSlot(token);
|
|
31820
32089
|
const cells = globalThis.__vsk_ssr_cells;
|
|
31821
32090
|
if (!cells || !(cells instanceof Map)) return;
|
|
31822
32091
|
for (const k of cells.keys()) {
|
|
@@ -31825,16 +32094,28 @@ function clearSsrCells(token) {
|
|
|
31825
32094
|
}
|
|
31826
32095
|
async function settleSsrPromises(token) {
|
|
31827
32096
|
if (!token) return;
|
|
31828
|
-
const
|
|
31829
|
-
|
|
31830
|
-
|
|
32097
|
+
const key = `__vsk_ssr_promises_${token}`;
|
|
32098
|
+
for (let round = 0; round < 10; round++) {
|
|
32099
|
+
const pending = globalThis[key];
|
|
32100
|
+
if (!pending || pending.length === 0) return;
|
|
32101
|
+
const before = pending.length;
|
|
32102
|
+
await Promise.allSettled(pending.slice());
|
|
32103
|
+
const after = globalThis[key];
|
|
32104
|
+
if (!after || after.length <= before) return;
|
|
32105
|
+
}
|
|
31831
32106
|
}
|
|
31832
32107
|
function pruneSsrDataSlots() {
|
|
31833
|
-
const
|
|
31834
|
-
const
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
32108
|
+
const g4 = globalThis;
|
|
32109
|
+
const prefix = "__vsk_ssr_data_";
|
|
32110
|
+
const stale = [];
|
|
32111
|
+
for (const k of Object.keys(g4)) {
|
|
32112
|
+
if (typeof k !== "string" || !k.startsWith(prefix)) continue;
|
|
32113
|
+
if (isSsrSlotLive(k.slice(prefix.length))) continue;
|
|
32114
|
+
stale.push(k);
|
|
32115
|
+
}
|
|
32116
|
+
if (stale.length <= 40) return;
|
|
32117
|
+
stale.sort().slice(0, stale.length - 40).forEach((k) => {
|
|
32118
|
+
delete g4[k];
|
|
31838
32119
|
});
|
|
31839
32120
|
}
|
|
31840
32121
|
async function applyHeadPlugins(headHtml, plugins, ctx2) {
|
|
@@ -31964,6 +32245,7 @@ async function renderFullPage(source, componentName, props = {}, registry = /* @
|
|
|
31964
32245
|
globalThis.__vsk_ssr = true;
|
|
31965
32246
|
if (!globalThis.__vsk_ssr_token) globalThis.__vsk_ssr_token = Math.random().toString(36).slice(2);
|
|
31966
32247
|
const renderToken = globalThis.__vsk_ssr_token;
|
|
32248
|
+
keepSsrSlot(renderToken);
|
|
31967
32249
|
pruneSsrDataSlots();
|
|
31968
32250
|
globalThis.__vsk_ssr_data = {};
|
|
31969
32251
|
try {
|
|
@@ -32040,12 +32322,15 @@ ${dataScriptBlock}${clientScript}</body>
|
|
|
32040
32322
|
} finally {
|
|
32041
32323
|
delete globalThis.__vsk_ssr;
|
|
32042
32324
|
delete globalThis[`__vsk_ssr_data_${renderToken}`];
|
|
32043
|
-
|
|
32325
|
+
dropSsrSlot(renderToken);
|
|
32044
32326
|
pruneSsrDataSlots();
|
|
32045
32327
|
}
|
|
32046
32328
|
});
|
|
32047
32329
|
}
|
|
32048
32330
|
function renderPageStream(source, componentName, props = {}, registry = /* @__PURE__ */ new Map(), options = {}) {
|
|
32331
|
+
const streamStore = adoptSsrStore();
|
|
32332
|
+
keepSsrSlot(streamStore.token);
|
|
32333
|
+
const streamToken = streamStore.token;
|
|
32049
32334
|
async function* raw2() {
|
|
32050
32335
|
const cached = options.cached || void 0;
|
|
32051
32336
|
const ir = cached ? cached.ir : generateIR(parse4(source, options.sourcePath ? { filename: options.sourcePath } : {}), source, options.sourcePath);
|
|
@@ -32114,8 +32399,7 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
|
|
|
32114
32399
|
yield '</head>\n<body>\n<div id="root">\n';
|
|
32115
32400
|
globalThis.__vsk_ssr = true;
|
|
32116
32401
|
globalThis.__vsk_ssr_data = {};
|
|
32117
|
-
|
|
32118
|
-
const renderToken = globalThis.__vsk_ssr_token;
|
|
32402
|
+
const renderToken = streamToken;
|
|
32119
32403
|
pruneSsrDataSlots();
|
|
32120
32404
|
let bodyHtml;
|
|
32121
32405
|
try {
|
|
@@ -32135,7 +32419,7 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
|
|
|
32135
32419
|
console.error(`[render-trace] renderPageStream comp=${componentName} keys=${Object.keys(ssrData).join(",") || "\u2205"} slot=${Object.keys(slot).join(",") || "\u2205"} sink=${Object.keys(ssrSink2.snapshot()).join(",") || "\u2205"}`);
|
|
32136
32420
|
}
|
|
32137
32421
|
delete globalThis[`__vsk_ssr_data_${renderToken}`];
|
|
32138
|
-
|
|
32422
|
+
dropSsrSlot(renderToken);
|
|
32139
32423
|
pruneSsrDataSlots();
|
|
32140
32424
|
const dataScripts = buildDataScripts(ssrProps, ssrData, options.externalDataScript);
|
|
32141
32425
|
const dataScriptBlock = dataScripts.length > 0 ? "\n" + dataScripts.join("\n") : "";
|
|
@@ -32148,11 +32432,20 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
|
|
|
32148
32432
|
}
|
|
32149
32433
|
const gen = raw2();
|
|
32150
32434
|
async function* scoped() {
|
|
32151
|
-
|
|
32152
|
-
|
|
32153
|
-
|
|
32154
|
-
|
|
32155
|
-
|
|
32435
|
+
try {
|
|
32436
|
+
let result;
|
|
32437
|
+
do {
|
|
32438
|
+
result = await withSsrStoreOf(streamStore, () => gen.next());
|
|
32439
|
+
if (!result.done) yield result.value;
|
|
32440
|
+
} while (!result.done);
|
|
32441
|
+
} finally {
|
|
32442
|
+
dropSsrSlot(streamToken);
|
|
32443
|
+
delete globalThis[`__vsk_ssr_data_${streamToken}`];
|
|
32444
|
+
delete globalThis[`__vsk_ssr_promises_${streamToken}`];
|
|
32445
|
+
delete globalThis[`__vsk_ssr_failures_${streamToken}`];
|
|
32446
|
+
delete globalThis.__vsk_ssr_data;
|
|
32447
|
+
pruneSsrDataSlots();
|
|
32448
|
+
}
|
|
32156
32449
|
}
|
|
32157
32450
|
return scoped();
|
|
32158
32451
|
}
|
|
@@ -32171,6 +32464,7 @@ var init_server_render = __esm({
|
|
|
32171
32464
|
init_md_inline();
|
|
32172
32465
|
init_ssr_store();
|
|
32173
32466
|
init_module_imports();
|
|
32467
|
+
init_vsk_collision();
|
|
32174
32468
|
}
|
|
32175
32469
|
});
|
|
32176
32470
|
|
|
@@ -33769,7 +34063,7 @@ ${serverStoreLine}
|
|
|
33769
34063
|
// SSR already resolved. Entry is consumed on read (bound store).
|
|
33770
34064
|
if (pathname === '/ssr-data.js') {
|
|
33771
34065
|
const dataToken = url.searchParams.get('t') || '';
|
|
33772
|
-
const dataStore = (globalThis.
|
|
34066
|
+
const dataStore = (globalThis.__vsk_ssr_payload_store || {});
|
|
33773
34067
|
const payload = dataStore[dataToken];
|
|
33774
34068
|
if (payload) delete dataStore[dataToken];
|
|
33775
34069
|
const dataLines = [];
|
|
@@ -37334,19 +37628,34 @@ var init_errors2 = __esm({
|
|
|
37334
37628
|
tip: isBuiltin ? `"${name}" is a Vesk built-in. Use it directly \u2014 no manual import needed.` : ""
|
|
37335
37629
|
});
|
|
37336
37630
|
}
|
|
37337
|
-
|
|
37338
|
-
|
|
37631
|
+
/**
|
|
37632
|
+
* A `.vsk` namespace is resolved at the JSX-tag level: `<ns.Icon />` looks
|
|
37633
|
+
* the component up in the registry by its exported name, exactly like
|
|
37634
|
+
* `import { Icon }`, and no module object is ever built. The two forms that
|
|
37635
|
+
* genuinely need a real module object are reported here.
|
|
37636
|
+
*
|
|
37637
|
+
* - `nested` — `<ns.Sub.Icon />`. A `.vsk` module's exports are flat
|
|
37638
|
+
* component names, so there is no object to walk into.
|
|
37639
|
+
* - `value` — `ns.max` read as a value. Component tags resolve; plain value
|
|
37640
|
+
* reads do not, because nothing binds `ns` at runtime.
|
|
37641
|
+
*/
|
|
37642
|
+
static vskNamespaceMember(context = {}) {
|
|
37643
|
+
const nested = context.form === "nested";
|
|
37644
|
+
return new _VeskError(nested ? "A `.vsk` namespace is flat, so `<ns.Sub.Icon />` cannot be resolved." : "A `.vsk` namespace resolves component tags only, so `ns.value` is not available.", {
|
|
37339
37645
|
...context,
|
|
37340
37646
|
code: context.code || "V0410",
|
|
37341
|
-
suggestions: [
|
|
37342
|
-
"Import the component by name: import {
|
|
37343
|
-
"
|
|
37647
|
+
suggestions: nested ? [
|
|
37648
|
+
"Import the component by name: import { Icon } from './icons.vsk'",
|
|
37649
|
+
"Import from the module that owns Sub: import * as Sub from './sub.vsk'"
|
|
37650
|
+
] : [
|
|
37651
|
+
"Import the value by name: import { MAX } from './constants.vsk'",
|
|
37652
|
+
"Move the value into a .ts module and import it from there \u2014 those are real ES modules with live bindings."
|
|
37344
37653
|
],
|
|
37345
37654
|
nextSteps: [
|
|
37346
|
-
"A `.vsk`
|
|
37347
|
-
"
|
|
37655
|
+
"A `.vsk` tag resolves by component name in the global registry, not by module exports, so `import * as ns` + `<ns.Icon />` needs no module object.",
|
|
37656
|
+
nested ? "Re-export with a flat name (`export { Icon }`) or import the component directly." : "Re-export the value under a flat name and import it directly, or keep the value in a .ts module."
|
|
37348
37657
|
],
|
|
37349
|
-
tip: "
|
|
37658
|
+
tip: "`<ns.Icon />` works; only nested paths and value reads need a real module namespace."
|
|
37350
37659
|
});
|
|
37351
37660
|
}
|
|
37352
37661
|
static classDecl(context = {}) {
|
|
@@ -37538,9 +37847,9 @@ function getJSXTagName2(el) {
|
|
|
37538
37847
|
if (name.type === "JSXNamespacedName") return name.namespace.name + ":" + name.name.name;
|
|
37539
37848
|
return null;
|
|
37540
37849
|
}
|
|
37541
|
-
function emitJSXText(
|
|
37850
|
+
function emitJSXText(g4, text, start, end) {
|
|
37542
37851
|
if (text.indexOf("<") === -1 && text.indexOf(">") === -1 && text.indexOf("&") === -1 && text.indexOf("{") === -1 && text.indexOf("}") === -1) {
|
|
37543
|
-
|
|
37852
|
+
g4.add(text, start, end);
|
|
37544
37853
|
return;
|
|
37545
37854
|
}
|
|
37546
37855
|
let out = "";
|
|
@@ -37553,7 +37862,7 @@ function emitJSXText(g2, text, start, end) {
|
|
|
37553
37862
|
else if (c === "}") out += "}";
|
|
37554
37863
|
else out += c;
|
|
37555
37864
|
}
|
|
37556
|
-
|
|
37865
|
+
g4.add(out, start, end);
|
|
37557
37866
|
}
|
|
37558
37867
|
function collapseWithMap(value) {
|
|
37559
37868
|
let out = "";
|
|
@@ -37710,31 +38019,31 @@ function stripCallTypeArgs(text) {
|
|
|
37710
38019
|
}
|
|
37711
38020
|
return text;
|
|
37712
38021
|
}
|
|
37713
|
-
function emitTrackDeclStatement(
|
|
38022
|
+
function emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts) {
|
|
37714
38023
|
const fullText = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
|
|
37715
38024
|
const text = fullText + (!fullText.endsWith("}") && !isLast ? ";" : "");
|
|
37716
38025
|
const decls = stmt.declarations || [];
|
|
37717
|
-
|
|
38026
|
+
g4.add(indent4);
|
|
37718
38027
|
let prevEnd = stmt.start;
|
|
37719
38028
|
for (let di = 0; di < decls.length; di++) {
|
|
37720
38029
|
const decl = decls[di];
|
|
37721
38030
|
const id = decl.id;
|
|
37722
38031
|
const isLazy = id && id.type === "ArrayPattern" && id.lazy === true && decl.init;
|
|
37723
38032
|
if (!isLazy) {
|
|
37724
|
-
|
|
37725
|
-
|
|
38033
|
+
g4.addRaw(source.slice(prevEnd, decl.start));
|
|
38034
|
+
g4.add(source.slice(decl.start, decl.end), decl.start, decl.end);
|
|
37726
38035
|
prevEnd = decl.end;
|
|
37727
38036
|
continue;
|
|
37728
38037
|
}
|
|
37729
|
-
if (di > 0)
|
|
38038
|
+
if (di > 0) g4.addRaw(source.slice(prevEnd, decl.start));
|
|
37730
38039
|
const ch = text[decl.end - stmt.start] ?? " ";
|
|
37731
38040
|
const elements = id.elements || [];
|
|
37732
38041
|
const names = elements.map((el) => el ? el.name : null).filter((n) => typeof n === "string");
|
|
37733
38042
|
const initText = source.slice(decl.init.start, decl.init.end);
|
|
37734
38043
|
if (names.length === 0) {
|
|
37735
|
-
|
|
37736
|
-
|
|
37737
|
-
if (ch !== ";")
|
|
38044
|
+
g4.add("let _ = ");
|
|
38045
|
+
g4.add(initText, decl.init.start, decl.init.end);
|
|
38046
|
+
if (ch !== ";") g4.addRaw(";");
|
|
37738
38047
|
prevEnd = decl.end;
|
|
37739
38048
|
continue;
|
|
37740
38049
|
}
|
|
@@ -37745,133 +38054,133 @@ function emitTrackDeclStatement(g2, source, stmt, indent4, isLast, opts) {
|
|
|
37745
38054
|
const firstRange = [elements[0].start, elements[0].end];
|
|
37746
38055
|
const dropLastSemi = ch === ";";
|
|
37747
38056
|
if (opts.typedCells) {
|
|
37748
|
-
const cellName =
|
|
37749
|
-
|
|
38057
|
+
const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
|
|
38058
|
+
g4.cellCount++;
|
|
37750
38059
|
if (annotation) {
|
|
37751
|
-
|
|
37752
|
-
|
|
37753
|
-
|
|
38060
|
+
g4.add(`const ${cellName}: Tracked<`);
|
|
38061
|
+
g4.add(annotation, annStart, annEnd);
|
|
38062
|
+
g4.add("> = ");
|
|
37754
38063
|
} else {
|
|
37755
|
-
|
|
38064
|
+
g4.add(`const ${cellName} = `);
|
|
37756
38065
|
}
|
|
37757
38066
|
const cellInit = annotation ? stripCallTypeArgs(initText) : initText;
|
|
37758
|
-
|
|
37759
|
-
|
|
37760
|
-
|
|
37761
|
-
|
|
38067
|
+
g4.add(cellInit, decl.init.start, decl.init.end);
|
|
38068
|
+
g4.add(";");
|
|
38069
|
+
g4.add(" let ");
|
|
38070
|
+
g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
|
|
37762
38071
|
if (annotation) {
|
|
37763
|
-
|
|
37764
|
-
|
|
38072
|
+
g4.add(": ");
|
|
38073
|
+
g4.add(annotation, annStart, annEnd);
|
|
37765
38074
|
}
|
|
37766
|
-
|
|
38075
|
+
g4.add(` = ${cellName}.get();`);
|
|
37767
38076
|
for (let n = 1; n < names.length; n++) {
|
|
37768
|
-
|
|
37769
|
-
|
|
37770
|
-
|
|
38077
|
+
g4.add(" let ");
|
|
38078
|
+
g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
|
|
38079
|
+
g4.add(` = ${cellName};`);
|
|
37771
38080
|
}
|
|
37772
|
-
if (dropLastSemi)
|
|
38081
|
+
if (dropLastSemi) g4.code = g4.code.slice(0, -1);
|
|
37773
38082
|
} else {
|
|
37774
38083
|
if (annotation) {
|
|
37775
|
-
|
|
37776
|
-
|
|
37777
|
-
|
|
37778
|
-
|
|
37779
|
-
|
|
37780
|
-
|
|
37781
|
-
|
|
37782
|
-
|
|
37783
|
-
|
|
38084
|
+
g4.add("let ");
|
|
38085
|
+
g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
|
|
38086
|
+
g4.add(": ");
|
|
38087
|
+
g4.add(annotation, annStart, annEnd);
|
|
38088
|
+
g4.add(" = (");
|
|
38089
|
+
g4.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
|
|
38090
|
+
g4.add(" as unknown as ");
|
|
38091
|
+
g4.add(annotation, annStart, annEnd);
|
|
38092
|
+
g4.add(");");
|
|
37784
38093
|
} else {
|
|
37785
|
-
const cellName =
|
|
37786
|
-
|
|
37787
|
-
|
|
37788
|
-
|
|
37789
|
-
|
|
37790
|
-
|
|
37791
|
-
|
|
38094
|
+
const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
|
|
38095
|
+
g4.cellCount++;
|
|
38096
|
+
g4.add(`const ${cellName} = `);
|
|
38097
|
+
g4.add(initText, decl.init.start, decl.init.end);
|
|
38098
|
+
g4.add("; let ");
|
|
38099
|
+
g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
|
|
38100
|
+
g4.add(` = ${cellName}.get();`);
|
|
37792
38101
|
}
|
|
37793
38102
|
for (let n = 1; n < names.length; n++) {
|
|
37794
|
-
|
|
37795
|
-
|
|
37796
|
-
|
|
37797
|
-
|
|
37798
|
-
|
|
37799
|
-
if (n === names.length - 1 && dropLastSemi)
|
|
38103
|
+
g4.add(" let ");
|
|
38104
|
+
g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
|
|
38105
|
+
g4.add(": any = ");
|
|
38106
|
+
g4.add(first, firstRange[0], firstRange[1]);
|
|
38107
|
+
g4.add(";");
|
|
38108
|
+
if (n === names.length - 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
|
|
37800
38109
|
}
|
|
37801
|
-
if (names.length === 1 && dropLastSemi)
|
|
38110
|
+
if (names.length === 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
|
|
37802
38111
|
}
|
|
37803
38112
|
prevEnd = decl.end;
|
|
37804
38113
|
}
|
|
37805
|
-
if (!isLast)
|
|
38114
|
+
if (!isLast) g4.addRaw(";");
|
|
37806
38115
|
}
|
|
37807
|
-
function emitBlock(
|
|
38116
|
+
function emitBlock(g4, source, body, indent4, opts) {
|
|
37808
38117
|
const stmts = body && body.type === "BlockStatement" ? body.body : body ? Array.isArray(body) ? body : [body] : [];
|
|
37809
|
-
|
|
37810
|
-
emitBody(
|
|
37811
|
-
|
|
37812
|
-
|
|
37813
|
-
|
|
38118
|
+
g4.addRaw("{\n");
|
|
38119
|
+
emitBody(g4, source, stmts, indent4 + " ", opts);
|
|
38120
|
+
g4.addRaw("\n");
|
|
38121
|
+
g4.add(indent4);
|
|
38122
|
+
g4.addRaw("}");
|
|
37814
38123
|
}
|
|
37815
|
-
function emitJSXAttr(
|
|
38124
|
+
function emitJSXAttr(g4, source, attr) {
|
|
37816
38125
|
if (attr.type === "JSXSpreadAttribute") {
|
|
37817
|
-
|
|
38126
|
+
g4.add(source.slice(attr.start, attr.end), attr.start, attr.end);
|
|
37818
38127
|
return;
|
|
37819
38128
|
}
|
|
37820
38129
|
const name = attr.name;
|
|
37821
|
-
|
|
38130
|
+
g4.add(source.slice(name.start, name.end), name.start, name.end);
|
|
37822
38131
|
const v = attr.value;
|
|
37823
38132
|
if (!v) return;
|
|
37824
|
-
|
|
38133
|
+
g4.add(source.slice(name.end, v.start), name.end, v.start);
|
|
37825
38134
|
if (v.type === "JSXExpressionContainer") {
|
|
37826
|
-
|
|
37827
|
-
|
|
37828
|
-
|
|
38135
|
+
g4.add(source.slice(v.start, v.expression.start), v.start, v.expression.start);
|
|
38136
|
+
g4.add(source.slice(v.expression.start, v.expression.end), v.expression.start, v.expression.end);
|
|
38137
|
+
g4.add(source.slice(v.expression.end, v.end), v.expression.end, v.end);
|
|
37829
38138
|
} else {
|
|
37830
|
-
|
|
38139
|
+
g4.add(source.slice(v.start, v.end), v.start, v.end);
|
|
37831
38140
|
}
|
|
37832
38141
|
}
|
|
37833
|
-
function emitJSXElement(
|
|
38142
|
+
function emitJSXElement(g4, source, el, opts, hoist) {
|
|
37834
38143
|
const op = el.openingElement;
|
|
37835
38144
|
const name = op.name;
|
|
37836
38145
|
let prev;
|
|
37837
38146
|
if (name) {
|
|
37838
|
-
|
|
37839
|
-
|
|
38147
|
+
g4.add(source.slice(op.start, name.start), op.start, name.start);
|
|
38148
|
+
g4.add(source.slice(name.start, name.end), name.start, name.end);
|
|
37840
38149
|
prev = name.end;
|
|
37841
38150
|
} else {
|
|
37842
38151
|
prev = op.start + 1;
|
|
37843
38152
|
}
|
|
37844
38153
|
for (const attr of op.attributes ?? []) {
|
|
37845
|
-
|
|
37846
|
-
emitJSXAttr(
|
|
38154
|
+
g4.add(source.slice(prev, attr.start), prev, attr.start);
|
|
38155
|
+
emitJSXAttr(g4, source, attr);
|
|
37847
38156
|
prev = attr.end;
|
|
37848
38157
|
}
|
|
37849
38158
|
const tail = source.slice(prev, op.end);
|
|
37850
38159
|
if (op.selfClosing && !tail.includes("/")) {
|
|
37851
38160
|
const gt = tail.lastIndexOf(">");
|
|
37852
38161
|
const head = gt === -1 ? tail : tail.slice(0, gt);
|
|
37853
|
-
if (head)
|
|
37854
|
-
|
|
38162
|
+
if (head) g4.add(head, prev, prev + head.length);
|
|
38163
|
+
g4.addRaw("/>");
|
|
37855
38164
|
} else {
|
|
37856
|
-
|
|
38165
|
+
g4.add(tail, prev, op.end);
|
|
37857
38166
|
}
|
|
37858
38167
|
if (op.selfClosing) return;
|
|
37859
|
-
emitJSXChildren(
|
|
38168
|
+
emitJSXChildren(g4, source, el.children ?? [], opts, hoist);
|
|
37860
38169
|
if (el.closingElement) {
|
|
37861
|
-
|
|
38170
|
+
g4.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
|
|
37862
38171
|
}
|
|
37863
38172
|
}
|
|
37864
|
-
function emitJSXExprBody(
|
|
37865
|
-
if (expr.type === "JSXElement") return emitJSXElement(
|
|
37866
|
-
if (expr.type === "JSXFragment") return emitJSXFragment(
|
|
37867
|
-
|
|
38173
|
+
function emitJSXExprBody(g4, source, expr, opts) {
|
|
38174
|
+
if (expr.type === "JSXElement") return emitJSXElement(g4, source, expr, opts);
|
|
38175
|
+
if (expr.type === "JSXFragment") return emitJSXFragment(g4, source, expr, opts);
|
|
38176
|
+
g4.add(source.slice(expr.start, expr.end), expr.start, expr.end);
|
|
37868
38177
|
}
|
|
37869
|
-
function emitJSXFragment(
|
|
37870
|
-
|
|
37871
|
-
emitJSXChildren(
|
|
37872
|
-
|
|
38178
|
+
function emitJSXFragment(g4, source, frag, opts, hoist) {
|
|
38179
|
+
g4.addRaw("<>");
|
|
38180
|
+
emitJSXChildren(g4, source, frag.children ?? [], opts, hoist);
|
|
38181
|
+
g4.addRaw("</>");
|
|
37873
38182
|
}
|
|
37874
|
-
function emitForClauseMap(
|
|
38183
|
+
function emitForClauseMap(g4, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
|
|
37875
38184
|
const clauseEnd = findBalancedEnd(text, clauseStart - 1);
|
|
37876
38185
|
const clause = text.slice(clauseStart, clauseEnd);
|
|
37877
38186
|
const ofIdx = findTopLevelSep(clause, "of");
|
|
@@ -37888,38 +38197,38 @@ function emitForClauseMap(g2, source, child, text, map, clauseStart, bodyEmit, e
|
|
|
37888
38197
|
const itemVar = stripDeclKeyword(lhs).trim();
|
|
37889
38198
|
if (ofIdx !== -1) {
|
|
37890
38199
|
if (emptyEmit) {
|
|
37891
|
-
|
|
37892
|
-
|
|
37893
|
-
|
|
38200
|
+
g4.addRaw("{ (() => { const _v = ");
|
|
38201
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38202
|
+
g4.addRaw("; return _v.length === 0 ? (");
|
|
37894
38203
|
emptyEmit();
|
|
37895
|
-
|
|
37896
|
-
|
|
37897
|
-
|
|
38204
|
+
g4.addRaw(") : _v.map((");
|
|
38205
|
+
g4.addRaw(itemVar);
|
|
38206
|
+
g4.addRaw(": (typeof _v)[number]) => (");
|
|
37898
38207
|
bodyEmit();
|
|
37899
|
-
|
|
38208
|
+
g4.addRaw(")); })() }");
|
|
37900
38209
|
} else {
|
|
37901
|
-
|
|
37902
|
-
|
|
37903
|
-
|
|
37904
|
-
|
|
37905
|
-
|
|
37906
|
-
|
|
37907
|
-
|
|
38210
|
+
g4.addRaw("{ ");
|
|
38211
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38212
|
+
g4.addRaw(".map((");
|
|
38213
|
+
g4.addRaw(itemVar);
|
|
38214
|
+
g4.addRaw(": (typeof ");
|
|
38215
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38216
|
+
g4.addRaw(")[number]) => (");
|
|
37908
38217
|
bodyEmit();
|
|
37909
|
-
|
|
38218
|
+
g4.addRaw(")) }");
|
|
37910
38219
|
}
|
|
37911
38220
|
} else {
|
|
37912
|
-
|
|
37913
|
-
|
|
37914
|
-
|
|
37915
|
-
|
|
37916
|
-
|
|
38221
|
+
g4.addRaw("{ Object.keys(");
|
|
38222
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38223
|
+
g4.addRaw(").map((");
|
|
38224
|
+
g4.addRaw(itemVar);
|
|
38225
|
+
g4.addRaw(") => (");
|
|
37917
38226
|
bodyEmit();
|
|
37918
|
-
|
|
38227
|
+
g4.addRaw(")) }");
|
|
37919
38228
|
}
|
|
37920
38229
|
return true;
|
|
37921
38230
|
}
|
|
37922
|
-
function emitJSXChildren(
|
|
38231
|
+
function emitJSXChildren(g4, source, children, opts, hoist) {
|
|
37923
38232
|
let i = 0;
|
|
37924
38233
|
let forPending = false;
|
|
37925
38234
|
while (i < children.length) {
|
|
@@ -37945,46 +38254,46 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
|
|
|
37945
38254
|
const emptyContainer = children[i + 3];
|
|
37946
38255
|
if (emptyTextNode && emptyTextNode.type === "JSXText" && ["#empty", "empty"].includes(emptyTextNode.value.trim()) && emptyContainer && emptyContainer.type === "JSXExpressionContainer" && emptyContainer.expression.type !== "JSXEmptyExpression") {
|
|
37947
38256
|
consumed = 4;
|
|
37948
|
-
emptyEmit = () => emitJSXExprBody(
|
|
38257
|
+
emptyEmit = () => emitJSXExprBody(g4, source, emptyContainer.expression, opts);
|
|
37949
38258
|
}
|
|
37950
38259
|
let matched = false;
|
|
37951
38260
|
if (nextChild.type === "JSXExpressionContainer") {
|
|
37952
38261
|
const exprNode = nextChild.expression;
|
|
37953
38262
|
if (exprNode.type === "JSXEmptyExpression") {
|
|
37954
|
-
|
|
38263
|
+
g4.add(text, child.start, child.end);
|
|
37955
38264
|
i++;
|
|
37956
38265
|
continue;
|
|
37957
38266
|
}
|
|
37958
38267
|
matched = emitForClauseMap(
|
|
37959
|
-
|
|
38268
|
+
g4,
|
|
37960
38269
|
source,
|
|
37961
38270
|
child,
|
|
37962
38271
|
text,
|
|
37963
38272
|
map,
|
|
37964
38273
|
clauseStartCollapsed,
|
|
37965
|
-
() => emitJSXExprBody(
|
|
38274
|
+
() => emitJSXExprBody(g4, source, exprNode, opts),
|
|
37966
38275
|
emptyEmit
|
|
37967
38276
|
);
|
|
37968
38277
|
} else if (nextChild.type === "JSXFragment") {
|
|
37969
38278
|
matched = emitForClauseMap(
|
|
37970
|
-
|
|
38279
|
+
g4,
|
|
37971
38280
|
source,
|
|
37972
38281
|
child,
|
|
37973
38282
|
text,
|
|
37974
38283
|
map,
|
|
37975
38284
|
clauseStartCollapsed,
|
|
37976
|
-
() => emitJSXFragment(
|
|
38285
|
+
() => emitJSXFragment(g4, source, nextChild, opts),
|
|
37977
38286
|
emptyEmit
|
|
37978
38287
|
);
|
|
37979
38288
|
} else {
|
|
37980
38289
|
matched = emitForClauseMap(
|
|
37981
|
-
|
|
38290
|
+
g4,
|
|
37982
38291
|
source,
|
|
37983
38292
|
child,
|
|
37984
38293
|
text,
|
|
37985
38294
|
map,
|
|
37986
38295
|
clauseStartCollapsed,
|
|
37987
|
-
() => emitJSXElement(
|
|
38296
|
+
() => emitJSXElement(g4, source, nextChild, opts),
|
|
37988
38297
|
emptyEmit
|
|
37989
38298
|
);
|
|
37990
38299
|
}
|
|
@@ -38001,184 +38310,184 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
|
|
|
38001
38310
|
continue;
|
|
38002
38311
|
}
|
|
38003
38312
|
forPending = false;
|
|
38004
|
-
emitJSXText(
|
|
38313
|
+
emitJSXText(g4, text, child.start, child.end);
|
|
38005
38314
|
i++;
|
|
38006
38315
|
} else if (child.type === "JSXExpressionContainer") {
|
|
38007
38316
|
if (child.expression.type === "JSXEmptyExpression") {
|
|
38008
38317
|
i++;
|
|
38009
38318
|
continue;
|
|
38010
38319
|
}
|
|
38011
|
-
|
|
38012
|
-
|
|
38013
|
-
|
|
38320
|
+
g4.addRaw("{");
|
|
38321
|
+
g4.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
|
|
38322
|
+
g4.addRaw("}");
|
|
38014
38323
|
i++;
|
|
38015
38324
|
} else if (child.type === "JSXElement") {
|
|
38016
38325
|
if (getJSXTagName2(child) === "style") {
|
|
38017
38326
|
const openEnd = child.openingElement?.end ?? child.start;
|
|
38018
38327
|
const closeStart = child.closingElement?.start ?? child.end;
|
|
38019
|
-
|
|
38328
|
+
g4.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
|
|
38020
38329
|
i++;
|
|
38021
38330
|
continue;
|
|
38022
38331
|
}
|
|
38023
|
-
emitJSXElement(
|
|
38332
|
+
emitJSXElement(g4, source, child, opts, hoist);
|
|
38024
38333
|
i++;
|
|
38025
38334
|
} else if (child.type === "JSXFragment") {
|
|
38026
|
-
emitJSXFragment(
|
|
38335
|
+
emitJSXFragment(g4, source, child, opts, hoist);
|
|
38027
38336
|
i++;
|
|
38028
38337
|
} 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") {
|
|
38029
38338
|
if (hoist && hoist.set.has(child)) {
|
|
38030
38339
|
i++;
|
|
38031
38340
|
continue;
|
|
38032
38341
|
}
|
|
38033
|
-
|
|
38034
|
-
emitBody(
|
|
38035
|
-
|
|
38342
|
+
g4.addRaw("{(() => { ");
|
|
38343
|
+
emitBody(g4, source, [child], "", opts);
|
|
38344
|
+
g4.addRaw(" })()}");
|
|
38036
38345
|
i++;
|
|
38037
38346
|
} else {
|
|
38038
38347
|
i++;
|
|
38039
38348
|
}
|
|
38040
38349
|
}
|
|
38041
38350
|
}
|
|
38042
|
-
function emitIf(
|
|
38043
|
-
|
|
38044
|
-
|
|
38045
|
-
|
|
38046
|
-
|
|
38047
|
-
emitBlock(
|
|
38351
|
+
function emitIf(g4, source, stmt, indent4, opts) {
|
|
38352
|
+
g4.add(indent4);
|
|
38353
|
+
g4.addRaw("if (");
|
|
38354
|
+
g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
|
|
38355
|
+
g4.addRaw(") ");
|
|
38356
|
+
emitBlock(g4, source, stmt.consequent, indent4, opts);
|
|
38048
38357
|
if (stmt.alternate) {
|
|
38049
|
-
|
|
38050
|
-
emitBlock(
|
|
38358
|
+
g4.addRaw(" else ");
|
|
38359
|
+
emitBlock(g4, source, stmt.alternate, indent4, opts);
|
|
38051
38360
|
}
|
|
38052
38361
|
}
|
|
38053
|
-
function emitLoopVariable(
|
|
38362
|
+
function emitLoopVariable(g4, source, left) {
|
|
38054
38363
|
if (left && left.type === "Identifier") {
|
|
38055
|
-
|
|
38056
|
-
|
|
38364
|
+
g4.addRaw("const ");
|
|
38365
|
+
g4.add(source.slice(left.start, left.end), left.start, left.end);
|
|
38057
38366
|
return;
|
|
38058
38367
|
}
|
|
38059
|
-
|
|
38060
|
-
}
|
|
38061
|
-
function emitForOf(
|
|
38062
|
-
|
|
38063
|
-
|
|
38064
|
-
emitLoopVariable(
|
|
38065
|
-
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
emitBlock(
|
|
38069
|
-
}
|
|
38070
|
-
function emitForIn(
|
|
38071
|
-
|
|
38072
|
-
|
|
38073
|
-
emitLoopVariable(
|
|
38074
|
-
|
|
38075
|
-
|
|
38076
|
-
|
|
38077
|
-
emitBlock(
|
|
38078
|
-
}
|
|
38079
|
-
function emitFor(
|
|
38080
|
-
|
|
38081
|
-
|
|
38082
|
-
if (stmt.init)
|
|
38083
|
-
|
|
38084
|
-
if (stmt.test)
|
|
38085
|
-
|
|
38086
|
-
if (stmt.update)
|
|
38087
|
-
|
|
38088
|
-
emitBlock(
|
|
38089
|
-
}
|
|
38090
|
-
function emitWhile(
|
|
38091
|
-
|
|
38092
|
-
|
|
38093
|
-
|
|
38094
|
-
|
|
38095
|
-
emitBlock(
|
|
38096
|
-
}
|
|
38097
|
-
function emitDoWhile(
|
|
38098
|
-
|
|
38099
|
-
|
|
38100
|
-
emitBlock(
|
|
38101
|
-
|
|
38102
|
-
|
|
38103
|
-
|
|
38104
|
-
}
|
|
38105
|
-
function emitSwitch(
|
|
38106
|
-
|
|
38107
|
-
|
|
38108
|
-
|
|
38109
|
-
|
|
38368
|
+
g4.add(source.slice(left.start, left.end), left.start, left.end);
|
|
38369
|
+
}
|
|
38370
|
+
function emitForOf(g4, source, stmt, indent4, opts) {
|
|
38371
|
+
g4.add(indent4);
|
|
38372
|
+
g4.addRaw("for (");
|
|
38373
|
+
emitLoopVariable(g4, source, stmt.left);
|
|
38374
|
+
g4.addRaw(" of ");
|
|
38375
|
+
g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
|
|
38376
|
+
g4.addRaw(") ");
|
|
38377
|
+
emitBlock(g4, source, stmt.body, indent4, opts);
|
|
38378
|
+
}
|
|
38379
|
+
function emitForIn(g4, source, stmt, indent4, opts) {
|
|
38380
|
+
g4.add(indent4);
|
|
38381
|
+
g4.addRaw("for (");
|
|
38382
|
+
emitLoopVariable(g4, source, stmt.left);
|
|
38383
|
+
g4.addRaw(" in ");
|
|
38384
|
+
g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
|
|
38385
|
+
g4.addRaw(") ");
|
|
38386
|
+
emitBlock(g4, source, stmt.body, indent4, opts);
|
|
38387
|
+
}
|
|
38388
|
+
function emitFor(g4, source, stmt, indent4, opts) {
|
|
38389
|
+
g4.add(indent4);
|
|
38390
|
+
g4.addRaw("for (");
|
|
38391
|
+
if (stmt.init) g4.add(source.slice(stmt.init.start, stmt.init.end), stmt.init.start, stmt.init.end);
|
|
38392
|
+
g4.addRaw("; ");
|
|
38393
|
+
if (stmt.test) g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
|
|
38394
|
+
g4.addRaw("; ");
|
|
38395
|
+
if (stmt.update) g4.add(source.slice(stmt.update.start, stmt.update.end), stmt.update.start, stmt.update.end);
|
|
38396
|
+
g4.addRaw(") ");
|
|
38397
|
+
emitBlock(g4, source, stmt.body, indent4, opts);
|
|
38398
|
+
}
|
|
38399
|
+
function emitWhile(g4, source, stmt, indent4, opts) {
|
|
38400
|
+
g4.add(indent4);
|
|
38401
|
+
g4.addRaw("while (");
|
|
38402
|
+
g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
|
|
38403
|
+
g4.addRaw(") ");
|
|
38404
|
+
emitBlock(g4, source, stmt.body, indent4, opts);
|
|
38405
|
+
}
|
|
38406
|
+
function emitDoWhile(g4, source, stmt, indent4, opts) {
|
|
38407
|
+
g4.add(indent4);
|
|
38408
|
+
g4.addRaw("do ");
|
|
38409
|
+
emitBlock(g4, source, stmt.body, indent4, opts);
|
|
38410
|
+
g4.addRaw(" while (");
|
|
38411
|
+
g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
|
|
38412
|
+
g4.addRaw(");");
|
|
38413
|
+
}
|
|
38414
|
+
function emitSwitch(g4, source, stmt, indent4, opts) {
|
|
38415
|
+
g4.add(indent4);
|
|
38416
|
+
g4.addRaw("switch (");
|
|
38417
|
+
g4.add(source.slice(stmt.discriminant.start, stmt.discriminant.end), stmt.discriminant.start, stmt.discriminant.end);
|
|
38418
|
+
g4.addRaw(") {");
|
|
38110
38419
|
let firstCase = true;
|
|
38111
38420
|
for (const c of stmt.cases ?? []) {
|
|
38112
|
-
|
|
38421
|
+
g4.addRaw(firstCase ? "\n" : "\n");
|
|
38113
38422
|
firstCase = false;
|
|
38114
|
-
|
|
38115
|
-
|
|
38423
|
+
g4.add(indent4);
|
|
38424
|
+
g4.addRaw(" ");
|
|
38116
38425
|
if (c.test) {
|
|
38117
|
-
|
|
38118
|
-
|
|
38119
|
-
|
|
38426
|
+
g4.addRaw("case ");
|
|
38427
|
+
g4.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
|
|
38428
|
+
g4.addRaw(":");
|
|
38120
38429
|
} else {
|
|
38121
|
-
|
|
38430
|
+
g4.addRaw("default:");
|
|
38122
38431
|
}
|
|
38123
|
-
const before =
|
|
38124
|
-
emitBody(
|
|
38125
|
-
if (
|
|
38432
|
+
const before = g4.code.length;
|
|
38433
|
+
emitBody(g4, source, c.consequent, indent4 + " ", opts);
|
|
38434
|
+
if (g4.code.length > before) g4.addRaw("\n");
|
|
38126
38435
|
}
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
|
|
38436
|
+
g4.addRaw("\n");
|
|
38437
|
+
g4.add(indent4);
|
|
38438
|
+
g4.addRaw("}");
|
|
38130
38439
|
}
|
|
38131
|
-
function emitTry(
|
|
38132
|
-
|
|
38133
|
-
|
|
38134
|
-
emitBlock(
|
|
38440
|
+
function emitTry(g4, source, stmt, indent4, opts) {
|
|
38441
|
+
g4.add(indent4);
|
|
38442
|
+
g4.addRaw("try ");
|
|
38443
|
+
emitBlock(g4, source, stmt.block, indent4, opts);
|
|
38135
38444
|
if (stmt.handler) {
|
|
38136
|
-
|
|
38445
|
+
g4.addRaw(" catch");
|
|
38137
38446
|
if (stmt.handler.param) {
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
|
|
38447
|
+
g4.addRaw(" (");
|
|
38448
|
+
g4.add(source.slice(stmt.handler.param.start, stmt.handler.param.end), stmt.handler.param.start, stmt.handler.param.end);
|
|
38449
|
+
g4.addRaw(")");
|
|
38141
38450
|
}
|
|
38142
|
-
|
|
38143
|
-
emitBlock(
|
|
38451
|
+
g4.addRaw(" ");
|
|
38452
|
+
emitBlock(g4, source, stmt.handler.body, indent4, opts);
|
|
38144
38453
|
}
|
|
38145
38454
|
if (stmt.finalizer) {
|
|
38146
|
-
|
|
38147
|
-
emitBlock(
|
|
38455
|
+
g4.addRaw(" finally ");
|
|
38456
|
+
emitBlock(g4, source, stmt.finalizer, indent4, opts);
|
|
38148
38457
|
}
|
|
38149
38458
|
}
|
|
38150
|
-
function emitPlainStatement(
|
|
38459
|
+
function emitPlainStatement(g4, source, stmt, indent4, isLast) {
|
|
38151
38460
|
let text = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
|
|
38152
38461
|
if (text === "") return;
|
|
38153
|
-
|
|
38154
|
-
|
|
38155
|
-
if (!text.endsWith("}") && !isLast)
|
|
38462
|
+
g4.add(indent4);
|
|
38463
|
+
g4.add(text, stmt.start, stmt.end);
|
|
38464
|
+
if (!text.endsWith("}") && !isLast) g4.addRaw(";");
|
|
38156
38465
|
}
|
|
38157
|
-
function emitStatement(
|
|
38466
|
+
function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
|
|
38158
38467
|
switch (stmt.type) {
|
|
38159
38468
|
case "JSXElement":
|
|
38160
38469
|
if (getJSXTagName2(stmt) === "style") {
|
|
38161
38470
|
const openEnd = stmt.openingElement?.end ?? stmt.start;
|
|
38162
38471
|
const closeStart = stmt.closingElement?.start ?? stmt.end;
|
|
38163
|
-
|
|
38472
|
+
g4.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
|
|
38164
38473
|
return;
|
|
38165
38474
|
}
|
|
38166
|
-
|
|
38167
|
-
emitJSXElement(
|
|
38168
|
-
if (!isLast)
|
|
38475
|
+
g4.add(indent4);
|
|
38476
|
+
emitJSXElement(g4, source, stmt, opts, hoist);
|
|
38477
|
+
if (!isLast) g4.addRaw(";");
|
|
38169
38478
|
return;
|
|
38170
38479
|
case "JSXFragment":
|
|
38171
|
-
|
|
38172
|
-
emitJSXFragment(
|
|
38173
|
-
if (!isLast)
|
|
38480
|
+
g4.add(indent4);
|
|
38481
|
+
emitJSXFragment(g4, source, stmt, opts, hoist);
|
|
38482
|
+
if (!isLast) g4.addRaw(";");
|
|
38174
38483
|
return;
|
|
38175
38484
|
case "JSXExpressionContainer": {
|
|
38176
38485
|
if (stmt.expression.type === "JSXEmptyExpression") return;
|
|
38177
|
-
|
|
38178
|
-
|
|
38179
|
-
|
|
38180
|
-
|
|
38181
|
-
if (!isLast)
|
|
38486
|
+
g4.add(indent4);
|
|
38487
|
+
g4.addRaw("{");
|
|
38488
|
+
g4.add(source.slice(stmt.expression.start, stmt.expression.end), stmt.expression.start, stmt.expression.end);
|
|
38489
|
+
g4.addRaw("}");
|
|
38490
|
+
if (!isLast) g4.addRaw(";");
|
|
38182
38491
|
return;
|
|
38183
38492
|
}
|
|
38184
38493
|
case "VeskBlock": {
|
|
@@ -38186,10 +38495,10 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
|
|
|
38186
38495
|
const innerStmts = stmt.body ?? [];
|
|
38187
38496
|
let firstLine = true;
|
|
38188
38497
|
for (let i = 0; i < innerStmts.length; i++) {
|
|
38189
|
-
const before =
|
|
38190
|
-
emitStatement(
|
|
38191
|
-
if (
|
|
38192
|
-
if (!firstLine)
|
|
38498
|
+
const before = g4.code.length;
|
|
38499
|
+
emitStatement(g4, source, innerStmts[i], indent4, isLast && i === innerStmts.length - 1, opts, hoist);
|
|
38500
|
+
if (g4.code.length > before) {
|
|
38501
|
+
if (!firstLine) g4.addRaw("\n");
|
|
38193
38502
|
firstLine = false;
|
|
38194
38503
|
}
|
|
38195
38504
|
}
|
|
@@ -38197,38 +38506,38 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
|
|
|
38197
38506
|
}
|
|
38198
38507
|
case "VariableDeclaration":
|
|
38199
38508
|
if (isTrackDeclStatement(stmt)) {
|
|
38200
|
-
emitTrackDeclStatement(
|
|
38509
|
+
emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts);
|
|
38201
38510
|
return;
|
|
38202
38511
|
}
|
|
38203
|
-
return emitPlainStatement(
|
|
38512
|
+
return emitPlainStatement(g4, source, stmt, indent4, isLast);
|
|
38204
38513
|
case "IfStatement":
|
|
38205
|
-
return emitIf(
|
|
38514
|
+
return emitIf(g4, source, stmt, indent4, opts);
|
|
38206
38515
|
case "ForOfStatement":
|
|
38207
|
-
return emitForOf(
|
|
38516
|
+
return emitForOf(g4, source, stmt, indent4, opts);
|
|
38208
38517
|
case "ForInStatement":
|
|
38209
|
-
return emitForIn(
|
|
38518
|
+
return emitForIn(g4, source, stmt, indent4, opts);
|
|
38210
38519
|
case "ForStatement":
|
|
38211
|
-
return emitFor(
|
|
38520
|
+
return emitFor(g4, source, stmt, indent4, opts);
|
|
38212
38521
|
case "WhileStatement":
|
|
38213
|
-
return emitWhile(
|
|
38522
|
+
return emitWhile(g4, source, stmt, indent4, opts);
|
|
38214
38523
|
case "DoWhileStatement":
|
|
38215
|
-
return emitDoWhile(
|
|
38524
|
+
return emitDoWhile(g4, source, stmt, indent4, opts);
|
|
38216
38525
|
case "SwitchStatement":
|
|
38217
|
-
return emitSwitch(
|
|
38526
|
+
return emitSwitch(g4, source, stmt, indent4, opts);
|
|
38218
38527
|
case "TryStatement":
|
|
38219
|
-
return emitTry(
|
|
38528
|
+
return emitTry(g4, source, stmt, indent4, opts);
|
|
38220
38529
|
case "LabeledStatement": {
|
|
38221
|
-
|
|
38222
|
-
|
|
38223
|
-
|
|
38224
|
-
emitStatement(
|
|
38530
|
+
g4.add(indent4);
|
|
38531
|
+
g4.add(stmt.label.name, stmt.label.start, stmt.label.end);
|
|
38532
|
+
g4.addRaw(":\n");
|
|
38533
|
+
emitStatement(g4, source, stmt.body, indent4, isLast, opts);
|
|
38225
38534
|
return;
|
|
38226
38535
|
}
|
|
38227
38536
|
default:
|
|
38228
|
-
return emitPlainStatement(
|
|
38537
|
+
return emitPlainStatement(g4, source, stmt, indent4, isLast);
|
|
38229
38538
|
}
|
|
38230
38539
|
}
|
|
38231
|
-
function emitBody(
|
|
38540
|
+
function emitBody(g4, source, stmts, indent4, opts, hoist) {
|
|
38232
38541
|
let firstLine = true;
|
|
38233
38542
|
let i = 0;
|
|
38234
38543
|
while (i < stmts.length) {
|
|
@@ -38236,34 +38545,34 @@ function emitBody(g2, source, stmts, indent4, opts, hoist) {
|
|
|
38236
38545
|
const isLast = i === stmts.length - 1;
|
|
38237
38546
|
if (stmt.type === "ForOfStatement" && stmts[i + 1] && stmts[i + 1].type === "VeskBlock" && stmts[i + 1].tag === "empty") {
|
|
38238
38547
|
const empty2 = stmts[i + 1];
|
|
38239
|
-
if (!firstLine)
|
|
38548
|
+
if (!firstLine) g4.addRaw("\n");
|
|
38240
38549
|
firstLine = false;
|
|
38241
|
-
emitForOf(
|
|
38550
|
+
emitForOf(g4, source, stmt, indent4, opts);
|
|
38242
38551
|
const inner = empty2.body ?? [];
|
|
38243
38552
|
if (inner.length > 0) {
|
|
38244
|
-
|
|
38245
|
-
|
|
38246
|
-
|
|
38247
|
-
|
|
38248
|
-
|
|
38249
|
-
emitBody(
|
|
38250
|
-
|
|
38251
|
-
|
|
38252
|
-
|
|
38553
|
+
g4.addRaw("\n");
|
|
38554
|
+
g4.add(indent4);
|
|
38555
|
+
g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
|
|
38556
|
+
g4.addRaw(".length === 0 && (() => {");
|
|
38557
|
+
g4.addRaw("\n");
|
|
38558
|
+
emitBody(g4, source, inner, indent4 + " ", opts);
|
|
38559
|
+
g4.addRaw("\n");
|
|
38560
|
+
g4.add(indent4);
|
|
38561
|
+
g4.addRaw("})();");
|
|
38253
38562
|
}
|
|
38254
38563
|
i += 2;
|
|
38255
38564
|
continue;
|
|
38256
38565
|
}
|
|
38257
|
-
const before =
|
|
38258
|
-
emitStatement(
|
|
38259
|
-
if (
|
|
38260
|
-
if (!firstLine)
|
|
38566
|
+
const before = g4.code.length;
|
|
38567
|
+
emitStatement(g4, source, stmt, indent4, isLast, opts, hoist);
|
|
38568
|
+
if (g4.code.length > before) {
|
|
38569
|
+
if (!firstLine) g4.addRaw("\n");
|
|
38261
38570
|
firstLine = false;
|
|
38262
38571
|
}
|
|
38263
38572
|
i++;
|
|
38264
38573
|
}
|
|
38265
38574
|
}
|
|
38266
|
-
function emitChunkMapped(
|
|
38575
|
+
function emitChunkMapped(g4, source, start, end) {
|
|
38267
38576
|
if (end <= start) return;
|
|
38268
38577
|
let pos = start;
|
|
38269
38578
|
let i = start;
|
|
@@ -38275,8 +38584,8 @@ function emitChunkMapped(g2, source, start, end) {
|
|
|
38275
38584
|
if (openEnd !== -1 && openEnd <= end) {
|
|
38276
38585
|
const closeIdx = source.indexOf("</style>", openEnd);
|
|
38277
38586
|
if (closeIdx !== -1 && closeIdx + 8 <= end) {
|
|
38278
|
-
|
|
38279
|
-
|
|
38587
|
+
g4.add(source.slice(pos, i), pos, i);
|
|
38588
|
+
g4.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
|
|
38280
38589
|
pos = closeIdx + 8;
|
|
38281
38590
|
i = closeIdx + 8;
|
|
38282
38591
|
continue;
|
|
@@ -38286,20 +38595,20 @@ function emitChunkMapped(g2, source, start, end) {
|
|
|
38286
38595
|
}
|
|
38287
38596
|
i++;
|
|
38288
38597
|
}
|
|
38289
|
-
|
|
38598
|
+
g4.add(source.slice(pos, end), pos, end);
|
|
38290
38599
|
}
|
|
38291
|
-
function emitReturn(
|
|
38292
|
-
|
|
38600
|
+
function emitReturn(g4, source, stmt, opts) {
|
|
38601
|
+
g4.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
|
|
38293
38602
|
const arg = stmt.argument;
|
|
38294
38603
|
if (!arg) {
|
|
38295
|
-
emitChunkMapped(
|
|
38604
|
+
emitChunkMapped(g4, source, stmt.start + 6, stmt.end);
|
|
38296
38605
|
return;
|
|
38297
38606
|
}
|
|
38298
|
-
emitChunkMapped(
|
|
38299
|
-
if (arg.type === "JSXElement") emitJSXElement(
|
|
38300
|
-
else if (arg.type === "JSXFragment") emitJSXFragment(
|
|
38301
|
-
else emitChunkMapped(
|
|
38302
|
-
emitChunkMapped(
|
|
38607
|
+
emitChunkMapped(g4, source, stmt.start + 6, arg.start);
|
|
38608
|
+
if (arg.type === "JSXElement") emitJSXElement(g4, source, arg, opts);
|
|
38609
|
+
else if (arg.type === "JSXFragment") emitJSXFragment(g4, source, arg, opts);
|
|
38610
|
+
else emitChunkMapped(g4, source, arg.start, arg.end);
|
|
38611
|
+
emitChunkMapped(g4, source, arg.end, stmt.end);
|
|
38303
38612
|
}
|
|
38304
38613
|
function collectHoistEligible(children, set2, list) {
|
|
38305
38614
|
for (const child of children ?? []) {
|
|
@@ -38319,7 +38628,7 @@ function collectHoistEligible(children, set2, list) {
|
|
|
38319
38628
|
}
|
|
38320
38629
|
}
|
|
38321
38630
|
}
|
|
38322
|
-
function emitBodyCore(
|
|
38631
|
+
function emitBodyCore(g4, source, stmts, opts) {
|
|
38323
38632
|
const hoistSet = /* @__PURE__ */ new Set();
|
|
38324
38633
|
const byRoot = /* @__PURE__ */ new Map();
|
|
38325
38634
|
const collectRoot = (root3) => {
|
|
@@ -38370,107 +38679,107 @@ function emitBodyCore(g2, source, stmts, opts) {
|
|
|
38370
38679
|
byRoot.delete(u.node);
|
|
38371
38680
|
const n = list.length;
|
|
38372
38681
|
for (let k = 0; k < n; k++) {
|
|
38373
|
-
const before2 =
|
|
38374
|
-
emitStatement(
|
|
38375
|
-
if (
|
|
38682
|
+
const before2 = g4.code.length;
|
|
38683
|
+
emitStatement(g4, source, list[k], "", false, opts, ctx2);
|
|
38684
|
+
if (g4.code.length > before2) g4.addRaw("\n");
|
|
38376
38685
|
}
|
|
38377
38686
|
}
|
|
38378
38687
|
}
|
|
38379
38688
|
if (u.empty !== void 0) {
|
|
38380
|
-
emitForOf(
|
|
38689
|
+
emitForOf(g4, source, u.node, "", opts);
|
|
38381
38690
|
const inner = u.empty.body ?? [];
|
|
38382
38691
|
if (inner.length > 0) {
|
|
38383
|
-
|
|
38384
|
-
|
|
38385
|
-
|
|
38692
|
+
g4.addRaw("\n");
|
|
38693
|
+
g4.add("");
|
|
38694
|
+
g4.add(
|
|
38386
38695
|
source.slice(u.node.right.start, u.node.right.end),
|
|
38387
38696
|
u.node.right.start,
|
|
38388
38697
|
u.node.right.end
|
|
38389
38698
|
);
|
|
38390
|
-
|
|
38391
|
-
|
|
38392
|
-
emitBody(
|
|
38393
|
-
|
|
38394
|
-
|
|
38395
|
-
|
|
38699
|
+
g4.addRaw(".length === 0 && (() => {");
|
|
38700
|
+
g4.addRaw("\n");
|
|
38701
|
+
emitBody(g4, source, inner, " ", opts);
|
|
38702
|
+
g4.addRaw("\n");
|
|
38703
|
+
g4.add("");
|
|
38704
|
+
g4.addRaw("})();");
|
|
38396
38705
|
}
|
|
38397
38706
|
return;
|
|
38398
38707
|
}
|
|
38399
|
-
const before =
|
|
38400
|
-
emitStatement(
|
|
38401
|
-
if (
|
|
38708
|
+
const before = g4.code.length;
|
|
38709
|
+
emitStatement(g4, source, u.node, "", isLast, opts, ctx2);
|
|
38710
|
+
if (g4.code.length > before && !isLast) g4.addRaw("\n");
|
|
38402
38711
|
};
|
|
38403
38712
|
for (let i = 0; i < units.length; i++) {
|
|
38404
38713
|
emitUnit(units[i], i === units.length - 1);
|
|
38405
38714
|
}
|
|
38406
38715
|
}
|
|
38407
|
-
function emitExpressionBody(
|
|
38716
|
+
function emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts) {
|
|
38408
38717
|
let pos = coreStart;
|
|
38409
38718
|
for (const stmt of stmts) {
|
|
38410
38719
|
if (!stmt) continue;
|
|
38411
|
-
emitChunkMapped(
|
|
38720
|
+
emitChunkMapped(g4, source, pos, stmt.start);
|
|
38412
38721
|
pos = stmt.start;
|
|
38413
38722
|
if (isTrackDeclStatement(stmt)) {
|
|
38414
|
-
emitTrackDeclStatement(
|
|
38723
|
+
emitTrackDeclStatement(g4, source, stmt, "", true, opts);
|
|
38415
38724
|
} else if (stmt.type === "ReturnStatement") {
|
|
38416
|
-
emitReturn(
|
|
38725
|
+
emitReturn(g4, source, stmt, opts);
|
|
38417
38726
|
} else {
|
|
38418
|
-
emitChunkMapped(
|
|
38727
|
+
emitChunkMapped(g4, source, stmt.start, stmt.end);
|
|
38419
38728
|
}
|
|
38420
38729
|
pos = stmt.end;
|
|
38421
38730
|
}
|
|
38422
|
-
emitChunkMapped(
|
|
38731
|
+
emitChunkMapped(g4, source, pos, coreEnd);
|
|
38423
38732
|
}
|
|
38424
|
-
function emitRestMapped(
|
|
38733
|
+
function emitRestMapped(g4, text, base, end) {
|
|
38425
38734
|
let i = 0;
|
|
38426
38735
|
while (i < text.length && !isIdentStart(text[i])) i++;
|
|
38427
38736
|
if (i >= text.length) {
|
|
38428
|
-
|
|
38737
|
+
g4.add(text, base, end);
|
|
38429
38738
|
return;
|
|
38430
38739
|
}
|
|
38431
38740
|
let j = i + 1;
|
|
38432
38741
|
while (j < text.length && isIdentChar(text[j])) j++;
|
|
38433
|
-
|
|
38434
|
-
|
|
38435
|
-
|
|
38742
|
+
g4.add(text.slice(0, i), base, base + i);
|
|
38743
|
+
g4.add(text.slice(i, j), base + i, base + j);
|
|
38744
|
+
g4.add(text.slice(j), base + j, end);
|
|
38436
38745
|
}
|
|
38437
|
-
function emitComponentHeader(
|
|
38746
|
+
function emitComponentHeader(g4, source, start, bodyStart) {
|
|
38438
38747
|
const h = source.slice(start, bodyStart);
|
|
38439
38748
|
const k = findFirstKeyword(h, "component");
|
|
38440
38749
|
if (k === -1) {
|
|
38441
38750
|
const { text, end: end2 } = stripTrailingClientRange(h);
|
|
38442
38751
|
if (!text.includes("(")) {
|
|
38443
38752
|
const trimmed = text.trimEnd();
|
|
38444
|
-
|
|
38445
|
-
|
|
38753
|
+
g4.add(trimmed, start, start + end2 - (text.length - trimmed.length));
|
|
38754
|
+
g4.addRaw("() ");
|
|
38446
38755
|
} else {
|
|
38447
|
-
|
|
38756
|
+
g4.add(text, start, start + end2);
|
|
38448
38757
|
}
|
|
38449
38758
|
return;
|
|
38450
38759
|
}
|
|
38451
|
-
|
|
38452
|
-
|
|
38760
|
+
g4.add(h.slice(0, k), start, start + k);
|
|
38761
|
+
g4.add("function", start + k, start + k + "component".length);
|
|
38453
38762
|
const restBase = start + k + "component".length;
|
|
38454
38763
|
const { text: rest, end } = stripTrailingClientRange(h.slice(k + "component".length));
|
|
38455
38764
|
const transformed = h.slice(0, k) + "function" + rest;
|
|
38456
38765
|
if (!transformed.includes("(")) {
|
|
38457
38766
|
const trimmed = rest.trimEnd();
|
|
38458
|
-
emitRestMapped(
|
|
38459
|
-
|
|
38767
|
+
emitRestMapped(g4, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
|
|
38768
|
+
g4.addRaw("() ");
|
|
38460
38769
|
} else {
|
|
38461
|
-
emitRestMapped(
|
|
38770
|
+
emitRestMapped(g4, rest, restBase, restBase + end);
|
|
38462
38771
|
}
|
|
38463
38772
|
}
|
|
38464
|
-
function emitComponent(
|
|
38773
|
+
function emitComponent(g4, source, node, start, opts) {
|
|
38465
38774
|
const body = node.body;
|
|
38466
38775
|
if (!body || body.start == null || body.end == null) return;
|
|
38467
|
-
emitComponentHeader(
|
|
38776
|
+
emitComponentHeader(g4, source, start, body.start);
|
|
38468
38777
|
const statementMode = isStatementMode2(node);
|
|
38469
38778
|
const stmts = body.body ?? [];
|
|
38470
38779
|
if (statementMode) {
|
|
38471
|
-
|
|
38472
|
-
emitBodyCore(
|
|
38473
|
-
|
|
38780
|
+
g4.addRaw("{ ");
|
|
38781
|
+
emitBodyCore(g4, source, stmts, opts);
|
|
38782
|
+
g4.addRaw(" }");
|
|
38474
38783
|
} else {
|
|
38475
38784
|
const raw2 = source.slice(body.start, body.end);
|
|
38476
38785
|
const rawLen = raw2.length;
|
|
@@ -38490,9 +38799,9 @@ function emitComponent(g2, source, node, start, opts) {
|
|
|
38490
38799
|
}
|
|
38491
38800
|
while (coreStart < coreEnd && isWhitespaceChar(source[coreStart])) coreStart++;
|
|
38492
38801
|
while (coreEnd > coreStart && isWhitespaceChar(source[coreEnd - 1])) coreEnd--;
|
|
38493
|
-
if (hasBraces)
|
|
38494
|
-
emitExpressionBody(
|
|
38495
|
-
if (hasBraces)
|
|
38802
|
+
if (hasBraces) g4.addRaw("{ ");
|
|
38803
|
+
emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts);
|
|
38804
|
+
if (hasBraces) g4.addRaw(" }");
|
|
38496
38805
|
}
|
|
38497
38806
|
}
|
|
38498
38807
|
function isModuleAst(ast) {
|
|
@@ -38522,26 +38831,26 @@ function compileVskCodegen(source, opts = {}) {
|
|
|
38522
38831
|
};
|
|
38523
38832
|
}
|
|
38524
38833
|
const clean = blankForClauses(source, ast);
|
|
38525
|
-
const
|
|
38834
|
+
const g4 = new VskGen();
|
|
38526
38835
|
const components = getComponents(ast).sort((a, b) => a.start - b.start);
|
|
38527
38836
|
let pos = 0;
|
|
38528
38837
|
for (const { node, start } of components) {
|
|
38529
38838
|
const body = node.body;
|
|
38530
38839
|
if (!body || body.start == null || body.end == null) continue;
|
|
38531
|
-
|
|
38532
|
-
emitComponent(
|
|
38840
|
+
g4.add(clean.slice(pos, start), pos, start);
|
|
38841
|
+
emitComponent(g4, clean, node, start, opts);
|
|
38533
38842
|
pos = body.end;
|
|
38534
38843
|
}
|
|
38535
|
-
|
|
38536
|
-
let code =
|
|
38844
|
+
g4.add(clean.slice(pos), pos, source.length);
|
|
38845
|
+
let code = g4.code;
|
|
38537
38846
|
if (isModuleAst(ast) && containsIdentifier(code, "Head") && !isIdentifierImported(code, "Head")) {
|
|
38538
|
-
|
|
38539
|
-
code =
|
|
38847
|
+
g4.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
|
|
38848
|
+
code = g4.code;
|
|
38540
38849
|
}
|
|
38541
38850
|
if (!isModuleAst(ast)) {
|
|
38542
38851
|
code += "\nexport {};\n";
|
|
38543
38852
|
}
|
|
38544
|
-
return { code, mappings:
|
|
38853
|
+
return { code, mappings: g4.mappings, styleRegions: g4.styleRegions, errors: [] };
|
|
38545
38854
|
}
|
|
38546
38855
|
function isTypeDecl(stmt) {
|
|
38547
38856
|
return stmt.type === "TSInterfaceDeclaration" || stmt.type === "TSTypeAliasDeclaration" || stmt.type === "ExportNamedDeclaration" && (stmt.declaration?.type === "TSInterfaceDeclaration" || stmt.declaration?.type === "TSTypeAliasDeclaration");
|
|
@@ -40154,7 +40463,7 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40154
40463
|
const runtimeRoot = findRuntimeSrc(appDir);
|
|
40155
40464
|
const entryFile = resolve3(outDir, "server", `.runtime-entry-${buildId++}.mjs`);
|
|
40156
40465
|
const entryContent = [
|
|
40157
|
-
`import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, hydratePrecompile, assertSameOrigin } from ${JSON.stringify(resolve3(compilerRoot, "server-codegen.js"))};`,
|
|
40466
|
+
`import { renderPage, renderFullPage, renderPageStream, compileFile, setRuntimeModule, setVskHydrate, hydratePrecompile, assertSameOrigin, withSsrStore } from ${JSON.stringify(resolve3(compilerRoot, "server-codegen.js"))};`,
|
|
40158
40467
|
`import { parseCookies } from ${JSON.stringify(resolve3(compilerRoot, "server-cookies.js"))};`,
|
|
40159
40468
|
`import * as __veskRuntime from ${JSON.stringify(resolve3(runtimeRoot, "index-server.js"))};`,
|
|
40160
40469
|
"",
|
|
@@ -40193,7 +40502,7 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40193
40502
|
"}",
|
|
40194
40503
|
"",
|
|
40195
40504
|
"export { renderPage, renderFullPage, renderPageStream, compileFile, setVskHydrate, hydratePrecompile, parseCookies, assertSameOrigin };",
|
|
40196
|
-
|
|
40505
|
+
"export { withSsrStore };",
|
|
40197
40506
|
"",
|
|
40198
40507
|
"// Deliver hydration data as an origin-served script so strict CSP (no unsafe-inline)",
|
|
40199
40508
|
"// does not block it. The prod server serves /ssr-data.js from the global store.",
|
|
@@ -40205,7 +40514,11 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40205
40514
|
" let tk = '';",
|
|
40206
40515
|
" for (const b of bytes) tk += b.toString(16).padStart(2, '0');",
|
|
40207
40516
|
" const token = tk;",
|
|
40208
|
-
"
|
|
40517
|
+
" // Named __vsk_ssr_payload_store, NOT __vsk_ssr_data_*: the compiler keys",
|
|
40518
|
+
" // per-request slots `__vsk_ssr_data_<token>` and pruneSsrDataSlots()",
|
|
40519
|
+
" // reaps that prefix. Sharing it let the reaper wipe every pending",
|
|
40520
|
+
" // /ssr-data.js payload, so a served page's hydration script 404'd.",
|
|
40521
|
+
" const store = (globalThis.__vsk_ssr_payload_store ||= {});",
|
|
40209
40522
|
" store[token] = payload;",
|
|
40210
40523
|
" // Bound the store: if the browser never fetches /ssr-data.js the entry",
|
|
40211
40524
|
" // would otherwise linger forever. Evict the oldest entry past 100.",
|
|
@@ -40429,6 +40742,7 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
|
40429
40742
|
|
|
40430
40743
|
// ../compiler/src/server-codegen.ts
|
|
40431
40744
|
init_server_render();
|
|
40745
|
+
init_ssr_store();
|
|
40432
40746
|
|
|
40433
40747
|
// ../adapter/src/css.ts
|
|
40434
40748
|
import { readFileSync as readFileSync6, existsSync as existsSync7 } from "node:fs";
|
|
@@ -40688,54 +41002,67 @@ ${layoutDecls.map((d) => " " + d.compiled + ",").join("\n")}
|
|
|
40688
41002
|
let dataCode;
|
|
40689
41003
|
const exposeErr = "process.env.NODE_ENV !== 'production'";
|
|
40690
41004
|
const dataNavCleanup = [
|
|
40691
|
-
"
|
|
40692
|
-
"
|
|
40693
|
-
"
|
|
40694
|
-
"
|
|
40695
|
-
|
|
40696
|
-
|
|
40697
|
-
|
|
41005
|
+
" } finally {",
|
|
41006
|
+
" const __dnToken = globalThis.__vsk_ssr_token;",
|
|
41007
|
+
" delete globalThis.__vsk_ssr;",
|
|
41008
|
+
" if (__dnToken) delete globalThis[`__vsk_ssr_data_${__dnToken}`];",
|
|
41009
|
+
// NOT `delete globalThis.__vsk_ssr_token`: that global is a
|
|
41010
|
+
// configurable AsyncLocalStorage accessor (ssr-store.ts), so `delete`
|
|
41011
|
+
// removes the property definition and the process silently reverts to a
|
|
41012
|
+
// process-global token — the cross-request data-slot race, for good. The
|
|
41013
|
+
// token dies with the withSsrStore scope wrapped around this block instead.
|
|
41014
|
+
" delete globalThis.__vsk_ssr_data;",
|
|
41015
|
+
" }"
|
|
41016
|
+
];
|
|
41017
|
+
const dataNavWrap = (body) => [
|
|
41018
|
+
" return withSsrStore(async () => {",
|
|
41019
|
+
...body.map((l) => l ? " " + l : l),
|
|
41020
|
+
" });"
|
|
40698
41021
|
];
|
|
40699
41022
|
if (layoutDecls.length > 0) {
|
|
40700
41023
|
dataCode = [
|
|
40701
41024
|
" if (request.headers.get('x-vesk-data') === '1') {",
|
|
40702
|
-
|
|
40703
|
-
|
|
40704
|
-
|
|
40705
|
-
|
|
40706
|
-
|
|
40707
|
-
|
|
40708
|
-
|
|
40709
|
-
|
|
40710
|
-
|
|
40711
|
-
|
|
40712
|
-
|
|
40713
|
-
|
|
40714
|
-
|
|
40715
|
-
|
|
40716
|
-
|
|
40717
|
-
|
|
40718
|
-
|
|
40719
|
-
|
|
41025
|
+
...dataNavWrap([
|
|
41026
|
+
" try {",
|
|
41027
|
+
" let dataPage;",
|
|
41028
|
+
" try {",
|
|
41029
|
+
" dataPage = await renderPage('', _pageComp, { params }, __componentRegistry, { hydrate: true, cached: _pageCompiled });",
|
|
41030
|
+
" } catch (err) {",
|
|
41031
|
+
" if (err && (err.name === 'NotFoundError' || err.name === 'Redirect')) throw err;",
|
|
41032
|
+
" const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(err);",
|
|
41033
|
+
` return new Response(JSON.stringify({ error: ${exposeErr} ? message : 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', Vary: 'x-vesk-data' } });`,
|
|
41034
|
+
" }",
|
|
41035
|
+
" let _dataHead = dataPage.head || '';",
|
|
41036
|
+
" for (let _i = _layoutCompList.length - 1; _i >= 0; _i--) {",
|
|
41037
|
+
" const _dl = await renderPage('', _layoutCompList[_i], { params, children: '' }, __componentRegistry, { hydrate: true, cached: _layoutCompiledList[_i] });",
|
|
41038
|
+
" _dataHead = (_dl.head || '') + _dataHead;",
|
|
41039
|
+
" }",
|
|
41040
|
+
" return new Response(JSON.stringify({ path: url.pathname, params, props: dataPage.props || { params }, head: _dataHead }), {",
|
|
41041
|
+
" headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', Vary: 'x-vesk-data' },",
|
|
41042
|
+
" });",
|
|
41043
|
+
...dataNavCleanup
|
|
41044
|
+
]),
|
|
40720
41045
|
" }",
|
|
40721
41046
|
" return __renderHtml(params, url.href);"
|
|
40722
41047
|
].join("\n");
|
|
40723
41048
|
} else {
|
|
40724
41049
|
dataCode = [
|
|
40725
41050
|
" if (request.headers.get('x-vesk-data') === '1') {",
|
|
40726
|
-
|
|
40727
|
-
|
|
40728
|
-
|
|
40729
|
-
|
|
40730
|
-
|
|
40731
|
-
|
|
40732
|
-
|
|
40733
|
-
|
|
40734
|
-
|
|
40735
|
-
|
|
40736
|
-
|
|
40737
|
-
|
|
40738
|
-
|
|
41051
|
+
...dataNavWrap([
|
|
41052
|
+
" try {",
|
|
41053
|
+
" let dataPage;",
|
|
41054
|
+
" try {",
|
|
41055
|
+
" dataPage = await renderPage('', _comp, { params }, __componentRegistry, { hydrate: true, cached: _compiled });",
|
|
41056
|
+
" } catch (err) {",
|
|
41057
|
+
" if (err && (err.name === 'NotFoundError' || err.name === 'Redirect')) throw err;",
|
|
41058
|
+
" const message = err && typeof err === 'object' && 'message' in err ? String(err.message) : String(err);",
|
|
41059
|
+
` return new Response(JSON.stringify({ error: ${exposeErr} ? message : 'Internal Server Error' }), { status: 500, headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', Vary: 'x-vesk-data' } });`,
|
|
41060
|
+
" }",
|
|
41061
|
+
" return new Response(JSON.stringify({ path: url.pathname, params, props: dataPage.props || { params }, head: dataPage.head || '' }), {",
|
|
41062
|
+
" headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', Vary: 'x-vesk-data' },",
|
|
41063
|
+
" });",
|
|
41064
|
+
...dataNavCleanup
|
|
41065
|
+
]),
|
|
40739
41066
|
" }",
|
|
40740
41067
|
" return __renderHtml(params, url.href);"
|
|
40741
41068
|
].join("\n");
|
|
@@ -41425,6 +41752,7 @@ init_esbuild_fallback();
|
|
|
41425
41752
|
init_strip_ts();
|
|
41426
41753
|
init_parser();
|
|
41427
41754
|
init_client_codegen();
|
|
41755
|
+
init_vsk_collision();
|
|
41428
41756
|
import { readFileSync as readFileSync11, existsSync as existsSync11, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, statSync as statSync3, rmSync, mkdtempSync, mkdirSync as mkdirSync3 } from "node:fs";
|
|
41429
41757
|
import { resolve as resolve10, join as join7, dirname as dirname8, relative as relative2, sep } from "node:path";
|
|
41430
41758
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -41697,11 +42025,11 @@ var ChunkImports = class {
|
|
|
41697
42025
|
const lines = [];
|
|
41698
42026
|
const sources = [...this.bySource.keys()].sort();
|
|
41699
42027
|
for (const src2 of sources) {
|
|
41700
|
-
const
|
|
42028
|
+
const g4 = this.bySource.get(src2);
|
|
41701
42029
|
const parts = [];
|
|
41702
|
-
if (
|
|
41703
|
-
if (
|
|
41704
|
-
const named = [...
|
|
42030
|
+
if (g4.default) parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
|
|
42031
|
+
if (g4.namespace) parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
|
|
42032
|
+
const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
|
|
41705
42033
|
if (named.length > 0) {
|
|
41706
42034
|
const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
|
|
41707
42035
|
parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
|
|
@@ -41900,7 +42228,8 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
41900
42228
|
}
|
|
41901
42229
|
const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
|
|
41902
42230
|
const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
|
|
41903
|
-
const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths } = compileClientBoth(src2, null, filePath);
|
|
42231
|
+
const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
|
|
42232
|
+
for (const cn of componentNames || []) componentOwners.claim(cn, filePath);
|
|
41904
42233
|
const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
|
|
41905
42234
|
const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
|
|
41906
42235
|
const compSpecs = [];
|
|
@@ -41950,6 +42279,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
|
|
|
41950
42279
|
}
|
|
41951
42280
|
const codeSplit = !!options?.codeSplit;
|
|
41952
42281
|
const transformPlugins = options?.plugins || [];
|
|
42282
|
+
const componentOwners = new VskComponentOwners();
|
|
41953
42283
|
async function applyTransformPlugins(code, filePath) {
|
|
41954
42284
|
if (transformPlugins.length === 0) return code;
|
|
41955
42285
|
let out = code;
|
|
@@ -42088,6 +42418,7 @@ ${entry.code}
|
|
|
42088
42418
|
for (const chunk of chunks) {
|
|
42089
42419
|
transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
|
|
42090
42420
|
}
|
|
42421
|
+
componentOwners.report("client bundle");
|
|
42091
42422
|
return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
|
|
42092
42423
|
} else {
|
|
42093
42424
|
let compileFileMono2 = function(filePath, resolvedName) {
|
|
@@ -42095,6 +42426,7 @@ ${entry.code}
|
|
|
42095
42426
|
seen.add(filePath);
|
|
42096
42427
|
const src2 = readFileSync11(filePath, "utf-8");
|
|
42097
42428
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
42429
|
+
for (const cn of vskComponentNames(src2, filePath)) componentOwners.claim(cn, filePath);
|
|
42098
42430
|
const monoAlloc = nameAllocFor(filePath);
|
|
42099
42431
|
const compCode = compileClient(src2, null, { forceClient: true, sourcePath: filePath, nameAllocator: monoAlloc });
|
|
42100
42432
|
const hydCode = compileClient(src2, null, { hydrate: true, forceClient: true, includeTopLevel: false, sourcePath: filePath, nameAllocator: monoAlloc });
|
|
@@ -42144,6 +42476,7 @@ ${entry.code}
|
|
|
42144
42476
|
aliasLines,
|
|
42145
42477
|
hydratorAliasLines
|
|
42146
42478
|
}, !!options?.hmr, !!options?.importRuntime, runtimeImportNames, options?.routeDataCache);
|
|
42479
|
+
componentOwners.report("client bundle");
|
|
42147
42480
|
return { main: await applyTransformPlugins(main, "client.js"), chunks: [] };
|
|
42148
42481
|
}
|
|
42149
42482
|
}
|
|
@@ -42743,7 +43076,7 @@ async function startProdServer(outDir, options) {
|
|
|
42743
43076
|
}
|
|
42744
43077
|
if (url.pathname === "/ssr-data.js") {
|
|
42745
43078
|
const token = url.searchParams.get("t") || "";
|
|
42746
|
-
const store = globalThis.
|
|
43079
|
+
const store = globalThis.__vsk_ssr_payload_store;
|
|
42747
43080
|
const payload = store?.[token];
|
|
42748
43081
|
if (payload) delete store[token];
|
|
42749
43082
|
const lines = [];
|
|
@@ -43558,37 +43891,120 @@ init_server_utils();
|
|
|
43558
43891
|
init_server_head();
|
|
43559
43892
|
init_server_jsgen();
|
|
43560
43893
|
init_server_render();
|
|
43894
|
+
init_ssr_store();
|
|
43561
43895
|
|
|
43562
43896
|
// ../compiler/dist/ssr-store.js
|
|
43563
43897
|
init_index_server();
|
|
43564
43898
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
43565
|
-
var
|
|
43899
|
+
var TOKEN_KEY2 = "__vsk_ssr_token";
|
|
43900
|
+
var IMPL_KEY2 = "__vsk_ssr_store_impl";
|
|
43901
|
+
var g3 = globalThis;
|
|
43902
|
+
var impl2 = g3[IMPL_KEY2] ?? (g3[IMPL_KEY2] = {
|
|
43903
|
+
storage: new AsyncLocalStorage2(),
|
|
43904
|
+
liveSlots: /* @__PURE__ */ new Map(),
|
|
43905
|
+
// Only the copy that created the implementation installs the token
|
|
43906
|
+
// accessor; a later copy must not redefine it over the shared storage.
|
|
43907
|
+
ownsAccessor: true
|
|
43908
|
+
});
|
|
43909
|
+
var storage2 = impl2.storage;
|
|
43910
|
+
var liveSlots2 = impl2.liveSlots;
|
|
43911
|
+
function newSsrToken2() {
|
|
43912
|
+
return Math.random().toString(36).slice(2);
|
|
43913
|
+
}
|
|
43914
|
+
function createSsrStore3() {
|
|
43915
|
+
return { token: newSsrToken2(), data: {} };
|
|
43916
|
+
}
|
|
43917
|
+
function isThenable2(value) {
|
|
43918
|
+
return typeof value?.then === "function";
|
|
43919
|
+
}
|
|
43566
43920
|
function withSsrStore2(fn) {
|
|
43567
43921
|
const existing = storage2.getStore();
|
|
43568
43922
|
if (existing)
|
|
43569
43923
|
return fn();
|
|
43570
|
-
|
|
43924
|
+
const store = createSsrStore3();
|
|
43925
|
+
keepSsrSlot2(store.token);
|
|
43926
|
+
let result;
|
|
43927
|
+
try {
|
|
43928
|
+
result = storage2.run(store, fn);
|
|
43929
|
+
} catch (err) {
|
|
43930
|
+
dropSsrSlot2(store.token);
|
|
43931
|
+
throw err;
|
|
43932
|
+
}
|
|
43933
|
+
if (isThenable2(result)) {
|
|
43934
|
+
return result.then((value) => {
|
|
43935
|
+
dropSsrSlot2(store.token);
|
|
43936
|
+
return value;
|
|
43937
|
+
}, (err) => {
|
|
43938
|
+
dropSsrSlot2(store.token);
|
|
43939
|
+
throw err;
|
|
43940
|
+
});
|
|
43941
|
+
}
|
|
43942
|
+
dropSsrSlot2(store.token);
|
|
43943
|
+
return result;
|
|
43944
|
+
}
|
|
43945
|
+
function withSsrStoreOf2(store, fn) {
|
|
43946
|
+
return storage2.run(store, fn);
|
|
43947
|
+
}
|
|
43948
|
+
function resetSsrToken2() {
|
|
43949
|
+
const store = storage2.getStore();
|
|
43950
|
+
const token = newSsrToken2();
|
|
43951
|
+
if (store) {
|
|
43952
|
+
if (store.token)
|
|
43953
|
+
liveSlots2.delete(store.token);
|
|
43954
|
+
store.token = token;
|
|
43955
|
+
}
|
|
43956
|
+
liveSlots2.set(token, 1);
|
|
43957
|
+
return token;
|
|
43958
|
+
}
|
|
43959
|
+
function keepSsrSlot2(token) {
|
|
43960
|
+
if (!token)
|
|
43961
|
+
return;
|
|
43962
|
+
liveSlots2.set(token, (liveSlots2.get(token) ?? 0) + 1);
|
|
43963
|
+
}
|
|
43964
|
+
function dropSsrSlot2(token) {
|
|
43965
|
+
if (!token)
|
|
43966
|
+
return;
|
|
43967
|
+
const count = liveSlots2.get(token);
|
|
43968
|
+
if (count === void 0)
|
|
43969
|
+
return;
|
|
43970
|
+
if (count <= 1)
|
|
43971
|
+
liveSlots2.delete(token);
|
|
43972
|
+
else
|
|
43973
|
+
liveSlots2.set(token, count - 1);
|
|
43571
43974
|
}
|
|
43572
43975
|
var ssrSink3 = {
|
|
43573
43976
|
set: (key, value) => {
|
|
43574
43977
|
const store = storage2.getStore();
|
|
43575
43978
|
if (store)
|
|
43576
|
-
store[key] = value;
|
|
43979
|
+
store.data[key] = value;
|
|
43577
43980
|
},
|
|
43578
43981
|
get: (key) => {
|
|
43579
43982
|
const store = storage2.getStore();
|
|
43580
|
-
return store ? store[key] : void 0;
|
|
43983
|
+
return store ? store.data[key] : void 0;
|
|
43581
43984
|
},
|
|
43582
|
-
snapshot: () => ({ ...storage2.getStore() ?? {} }),
|
|
43985
|
+
snapshot: () => ({ ...storage2.getStore()?.data ?? {} }),
|
|
43583
43986
|
clear: () => {
|
|
43584
43987
|
const store = storage2.getStore();
|
|
43585
43988
|
if (store) {
|
|
43586
|
-
for (const key of Object.keys(store))
|
|
43587
|
-
delete store[key];
|
|
43989
|
+
for (const key of Object.keys(store.data))
|
|
43990
|
+
delete store.data[key];
|
|
43588
43991
|
}
|
|
43589
43992
|
}
|
|
43590
43993
|
};
|
|
43591
43994
|
setSsrSink(ssrSink3);
|
|
43995
|
+
if (impl2.ownsAccessor) {
|
|
43996
|
+
Object.defineProperty(globalThis, TOKEN_KEY2, {
|
|
43997
|
+
configurable: true,
|
|
43998
|
+
get() {
|
|
43999
|
+
return storage2.getStore()?.token;
|
|
44000
|
+
},
|
|
44001
|
+
set(value) {
|
|
44002
|
+
const store = storage2.getStore();
|
|
44003
|
+
if (store)
|
|
44004
|
+
store.token = value;
|
|
44005
|
+
}
|
|
44006
|
+
});
|
|
44007
|
+
}
|
|
43592
44008
|
|
|
43593
44009
|
// ../compiler/dist/client-codegen.js
|
|
43594
44010
|
init_ir();
|
|
@@ -45890,13 +46306,17 @@ function compileClientBoth2(source, _componentName, sourcePath2, opts) {
|
|
|
45890
46306
|
const aliases = vskRegistryAliases(ir.imports, ir.exportAliases);
|
|
45891
46307
|
const reexportPaths = sourcePath2 ? collectVskReexportPaths(ir.reexportSources, sourcePath2) : [];
|
|
45892
46308
|
if (opts?.skipHyd)
|
|
45893
|
-
return { comp, hyd: "", name, aliases, reexportPaths };
|
|
46309
|
+
return { comp, hyd: "", name, aliases, reexportPaths, componentNames: ir.components.map((c) => c.name) };
|
|
45894
46310
|
return {
|
|
45895
46311
|
comp,
|
|
45896
46312
|
hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
|
|
45897
46313
|
name,
|
|
45898
46314
|
aliases,
|
|
45899
|
-
reexportPaths
|
|
46315
|
+
reexportPaths,
|
|
46316
|
+
// Every component NAME this file registers, not just the resolved one —
|
|
46317
|
+
// the bundle needs the full list to spot same-name declarations across
|
|
46318
|
+
// files (see findVskComponentCollisions).
|
|
46319
|
+
componentNames: ir.components.map((c) => c.name)
|
|
45900
46320
|
};
|
|
45901
46321
|
}
|
|
45902
46322
|
|
|
@@ -47095,6 +47515,7 @@ async function build3(options) {
|
|
|
47095
47515
|
init_strip_ts();
|
|
47096
47516
|
init_parser();
|
|
47097
47517
|
init_client_codegen();
|
|
47518
|
+
init_vsk_collision();
|
|
47098
47519
|
init_vsk_imports();
|
|
47099
47520
|
init_md_inline();
|
|
47100
47521
|
init_module_imports();
|
|
@@ -47390,13 +47811,13 @@ var ChunkImports2 = class {
|
|
|
47390
47811
|
const lines = [];
|
|
47391
47812
|
const sources = [...this.bySource.keys()].sort();
|
|
47392
47813
|
for (const src2 of sources) {
|
|
47393
|
-
const
|
|
47814
|
+
const g4 = this.bySource.get(src2);
|
|
47394
47815
|
const parts = [];
|
|
47395
|
-
if (
|
|
47396
|
-
parts.push(`import ${
|
|
47397
|
-
if (
|
|
47398
|
-
parts.push(`import * as ${
|
|
47399
|
-
const named = [...
|
|
47816
|
+
if (g4.default)
|
|
47817
|
+
parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
|
|
47818
|
+
if (g4.namespace)
|
|
47819
|
+
parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
|
|
47820
|
+
const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
|
|
47400
47821
|
if (named.length > 0) {
|
|
47401
47822
|
const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
|
|
47402
47823
|
parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
|
|
@@ -47612,7 +48033,9 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
47612
48033
|
}
|
|
47613
48034
|
const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
|
|
47614
48035
|
const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
|
|
47615
|
-
const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths } = compileClientBoth(src2, null, filePath);
|
|
48036
|
+
const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths, componentNames } = compileClientBoth(src2, null, filePath);
|
|
48037
|
+
for (const cn of componentNames || [])
|
|
48038
|
+
componentOwners.claim(cn, filePath);
|
|
47616
48039
|
const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
|
|
47617
48040
|
const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
|
|
47618
48041
|
const compSpecs = [];
|
|
@@ -47666,6 +48089,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
|
|
|
47666
48089
|
}
|
|
47667
48090
|
const codeSplit = !!options?.codeSplit;
|
|
47668
48091
|
const transformPlugins = options?.plugins || [];
|
|
48092
|
+
const componentOwners = new VskComponentOwners();
|
|
47669
48093
|
async function applyTransformPlugins(code, filePath) {
|
|
47670
48094
|
if (transformPlugins.length === 0)
|
|
47671
48095
|
return code;
|
|
@@ -47811,6 +48235,7 @@ ${entry.code}
|
|
|
47811
48235
|
for (const chunk of chunks) {
|
|
47812
48236
|
transformedChunks.push({ ...chunk, code: await applyTransformPlugins(chunk.code, chunk.name) });
|
|
47813
48237
|
}
|
|
48238
|
+
componentOwners.report("client bundle");
|
|
47814
48239
|
return { main: await applyTransformPlugins(main, "client.js"), chunks: transformedChunks, cachedFileHits, compiledFiles, mainFromCache, editedSources, editedNames };
|
|
47815
48240
|
} else {
|
|
47816
48241
|
let compileFileMono2 = function(filePath, resolvedName) {
|
|
@@ -47819,6 +48244,8 @@ ${entry.code}
|
|
|
47819
48244
|
seen.add(filePath);
|
|
47820
48245
|
const src2 = readFileSync24(filePath, "utf-8");
|
|
47821
48246
|
resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
|
|
48247
|
+
for (const cn of vskComponentNames(src2, filePath))
|
|
48248
|
+
componentOwners.claim(cn, filePath);
|
|
47822
48249
|
const monoAlloc = nameAllocFor(filePath);
|
|
47823
48250
|
const compCode = compileClient(src2, null, { forceClient: true, sourcePath: filePath, nameAllocator: monoAlloc });
|
|
47824
48251
|
const hydCode = compileClient(src2, null, { hydrate: true, forceClient: true, includeTopLevel: false, sourcePath: filePath, nameAllocator: monoAlloc });
|
|
@@ -47878,6 +48305,7 @@ ${entry.code}
|
|
|
47878
48305
|
aliasLines,
|
|
47879
48306
|
hydratorAliasLines
|
|
47880
48307
|
}, !!options?.hmr, !!options?.importRuntime, runtimeImportNames, options?.routeDataCache);
|
|
48308
|
+
componentOwners.report("client bundle");
|
|
47881
48309
|
return { main: await applyTransformPlugins(main, "client.js"), chunks: [] };
|
|
47882
48310
|
}
|
|
47883
48311
|
}
|
|
@@ -53833,10 +54261,10 @@ function parseCookies3(str3) {
|
|
|
53833
54261
|
// ../runtime/dist/action.js
|
|
53834
54262
|
var registryKey2 = "__vesk_actions";
|
|
53835
54263
|
function getActionRegistry2() {
|
|
53836
|
-
const
|
|
53837
|
-
if (!
|
|
53838
|
-
|
|
53839
|
-
return
|
|
54264
|
+
const g4 = globalThis;
|
|
54265
|
+
if (!g4[registryKey2])
|
|
54266
|
+
g4[registryKey2] = {};
|
|
54267
|
+
return g4[registryKey2];
|
|
53840
54268
|
}
|
|
53841
54269
|
function getAction2(id) {
|
|
53842
54270
|
return getActionRegistry2()[id] || null;
|
|
@@ -54412,8 +54840,41 @@ var ROUTE_STRUCTURAL_VSK = /* @__PURE__ */ new Set([
|
|
|
54412
54840
|
"offline.vsk",
|
|
54413
54841
|
"network.vsk"
|
|
54414
54842
|
]);
|
|
54415
|
-
var HMR_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
54416
|
-
|
|
54843
|
+
var HMR_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
54844
|
+
"node_modules",
|
|
54845
|
+
".vesk",
|
|
54846
|
+
"tarballs",
|
|
54847
|
+
".git",
|
|
54848
|
+
"dist",
|
|
54849
|
+
"build",
|
|
54850
|
+
"coverage",
|
|
54851
|
+
"out",
|
|
54852
|
+
".next",
|
|
54853
|
+
".nuxt",
|
|
54854
|
+
".output",
|
|
54855
|
+
".svelte-kit",
|
|
54856
|
+
".turbo",
|
|
54857
|
+
".cache",
|
|
54858
|
+
".vercel",
|
|
54859
|
+
".netlify"
|
|
54860
|
+
]);
|
|
54861
|
+
var HMR_SKIP_MARKERS = [
|
|
54862
|
+
"node_modules/",
|
|
54863
|
+
".vesk/",
|
|
54864
|
+
"tmp-vesk-chunk-",
|
|
54865
|
+
"/dist/",
|
|
54866
|
+
"/build/",
|
|
54867
|
+
"/coverage/",
|
|
54868
|
+
"/out/",
|
|
54869
|
+
"/.next/",
|
|
54870
|
+
"/.nuxt/",
|
|
54871
|
+
"/.output/",
|
|
54872
|
+
"/.svelte-kit/",
|
|
54873
|
+
"/.turbo/",
|
|
54874
|
+
"/.cache/",
|
|
54875
|
+
"/.vercel/",
|
|
54876
|
+
"/.netlify/"
|
|
54877
|
+
];
|
|
54417
54878
|
var HMR_SCRIPT_EXTS = [".mts", ".ts", ".tsx", ".mjs", ".js", ".cjs"];
|
|
54418
54879
|
var HMR_CONFIG_NAMES = /* @__PURE__ */ new Set([
|
|
54419
54880
|
"vesk.config.ts",
|
|
@@ -54459,9 +54920,9 @@ function storeDataScript(payload) {
|
|
|
54459
54920
|
return "/_vesk/ssr-data.js?t=" + token;
|
|
54460
54921
|
}
|
|
54461
54922
|
function currentSsrData() {
|
|
54462
|
-
const
|
|
54463
|
-
const token =
|
|
54464
|
-
const slot = (token ?
|
|
54923
|
+
const g4 = globalThis;
|
|
54924
|
+
const token = g4.__vsk_ssr_token;
|
|
54925
|
+
const slot = (token ? g4[`__vsk_ssr_data_${token}`] : void 0) || {};
|
|
54465
54926
|
return { ...ssrSink3.snapshot() || {}, ...slot };
|
|
54466
54927
|
}
|
|
54467
54928
|
function countPages(nodes) {
|
|
@@ -54554,9 +55015,9 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
54554
55015
|
}
|
|
54555
55016
|
}
|
|
54556
55017
|
function eventsStore() {
|
|
54557
|
-
const
|
|
54558
|
-
if (!
|
|
54559
|
-
return
|
|
55018
|
+
const g4 = globalThis;
|
|
55019
|
+
if (!g4.__vesk_server_ctx) g4.__vesk_server_ctx = {};
|
|
55020
|
+
return g4.__vesk_server_ctx;
|
|
54560
55021
|
}
|
|
54561
55022
|
function makeEventCtx(overrides) {
|
|
54562
55023
|
const store = eventsStore();
|
|
@@ -54960,6 +55421,7 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
54960
55421
|
const treeChanged = needsRescan && prevTree !== stripAnnots(routeTree);
|
|
54961
55422
|
const isOutsideApp = !fullPath.startsWith(appDirPath + "/") && fullPath !== appDirPath;
|
|
54962
55423
|
const fileDeleted = eventType === "rename" && !fileExists;
|
|
55424
|
+
if (isOutsideApp) ssrCompileCache.clear();
|
|
54963
55425
|
const cssPromise = rebuildTailwindCss();
|
|
54964
55426
|
let bundleError = null;
|
|
54965
55427
|
let hotEditedSource = null;
|
|
@@ -55104,6 +55566,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
55104
55566
|
const t0 = Date.now();
|
|
55105
55567
|
try {
|
|
55106
55568
|
bcast({ type: "compiling" });
|
|
55569
|
+
ssrCompileCache.clear();
|
|
55107
55570
|
await fullRebuild();
|
|
55108
55571
|
LOG.info(`${kind === "config" ? "config" : "script"} changed, full rebuild + reload (${filename}) \u2014 ${Date.now() - t0}ms`);
|
|
55109
55572
|
} catch (e) {
|
|
@@ -55411,11 +55874,11 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
55411
55874
|
const forData = req.headers["x-vesk-data"] === "1";
|
|
55412
55875
|
async function renderSSR() {
|
|
55413
55876
|
const ssg2 = globalThis;
|
|
55414
|
-
const freshToken = Math.random().toString(36).slice(2);
|
|
55415
|
-
ssg2.__vsk_ssr_token = freshToken;
|
|
55416
55877
|
ssg2.__vsk_ssr_data = {};
|
|
55878
|
+
let freshToken;
|
|
55417
55879
|
try {
|
|
55418
55880
|
return await withSsrStore2(async () => {
|
|
55881
|
+
freshToken = resetSsrToken2();
|
|
55419
55882
|
const chain = cleanChain;
|
|
55420
55883
|
let body = "";
|
|
55421
55884
|
let head = "";
|
|
@@ -55490,17 +55953,16 @@ ${prettifyHtml(body)}
|
|
|
55490
55953
|
return { html, props: props || { params: matched.params }, head };
|
|
55491
55954
|
});
|
|
55492
55955
|
} finally {
|
|
55493
|
-
|
|
55494
|
-
|
|
55495
|
-
delete ssg2[`
|
|
55496
|
-
|
|
55956
|
+
const token = freshToken;
|
|
55957
|
+
dropSsrSlot2(token);
|
|
55958
|
+
delete ssg2[`__vsk_ssr_data_${token}`];
|
|
55959
|
+
delete ssg2[`__vsk_ssr_promises_${token}`];
|
|
55960
|
+
delete ssg2[`__vsk_ssr_failures_${token}`];
|
|
55497
55961
|
delete ssg2.__vsk_ssr_data;
|
|
55498
55962
|
}
|
|
55499
55963
|
}
|
|
55500
55964
|
function renderSSRStream() {
|
|
55501
55965
|
const sst = globalThis;
|
|
55502
|
-
const streamToken = Math.random().toString(36).slice(2);
|
|
55503
|
-
sst.__vsk_ssr_token = streamToken;
|
|
55504
55966
|
sst.__vsk_ssr_data = {};
|
|
55505
55967
|
async function* raw2() {
|
|
55506
55968
|
const chain = cleanChain;
|
|
@@ -55564,18 +56026,22 @@ ${prettifyHtml(body)}
|
|
|
55564
56026
|
yield ' <script type="module" src="/_vesk/client.js"></script>\n</body>\n</html>';
|
|
55565
56027
|
}
|
|
55566
56028
|
const gen = raw2();
|
|
56029
|
+
const streamStore = createSsrStore3();
|
|
55567
56030
|
async function* scoped() {
|
|
55568
56031
|
try {
|
|
55569
56032
|
let result;
|
|
55570
56033
|
do {
|
|
55571
|
-
result = await
|
|
56034
|
+
result = await withSsrStoreOf2(streamStore, () => gen.next());
|
|
55572
56035
|
if (!result.done) yield result.value;
|
|
55573
56036
|
} while (!result.done);
|
|
55574
56037
|
} finally {
|
|
55575
|
-
|
|
55576
|
-
|
|
55577
|
-
|
|
55578
|
-
|
|
56038
|
+
const token = streamStore.token;
|
|
56039
|
+
dropSsrSlot2(token);
|
|
56040
|
+
if (token) {
|
|
56041
|
+
delete sst[`__vsk_ssr_data_${token}`];
|
|
56042
|
+
delete sst[`__vsk_ssr_promises_${token}`];
|
|
56043
|
+
delete sst[`__vsk_ssr_failures_${token}`];
|
|
56044
|
+
}
|
|
55579
56045
|
delete sst.__vsk_ssr_data;
|
|
55580
56046
|
}
|
|
55581
56047
|
}
|
|
@@ -55794,7 +56260,6 @@ ${prettifyHtml(body)}
|
|
|
55794
56260
|
LOG.info(`${projectDir}`);
|
|
55795
56261
|
LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
|
|
55796
56262
|
if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
|
|
55797
|
-
LOG.info("hmr enabled \u2014 edit app/ to hot reload");
|
|
55798
56263
|
});
|
|
55799
56264
|
updateSourceMapping();
|
|
55800
56265
|
const hmrClients = /* @__PURE__ */ new Set();
|