@vesk/vesk-cli 0.2.44 → 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 +442 -424
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1659,11 +1659,11 @@ var init_context = __esm({
|
|
|
1659
1659
|
|
|
1660
1660
|
// ../runtime/src/server-events.ts
|
|
1661
1661
|
function getStore() {
|
|
1662
|
-
const
|
|
1663
|
-
if (!
|
|
1664
|
-
|
|
1662
|
+
const g4 = globalThis;
|
|
1663
|
+
if (!g4.__vesk_server_ctx || typeof g4.__vesk_server_ctx !== "object") {
|
|
1664
|
+
g4.__vesk_server_ctx = {};
|
|
1665
1665
|
}
|
|
1666
|
-
return
|
|
1666
|
+
return g4.__vesk_server_ctx;
|
|
1667
1667
|
}
|
|
1668
1668
|
function server_locals() {
|
|
1669
1669
|
return getStore();
|
|
@@ -2032,16 +2032,6 @@ function startRequest(handle2, skipCache) {
|
|
|
2032
2032
|
if (getInflight().get(key) === prom2) getInflight().delete(key);
|
|
2033
2033
|
});
|
|
2034
2034
|
} else {
|
|
2035
|
-
const ownerToken = g().__vsk_ssr_token || void 0;
|
|
2036
|
-
if (ownerToken) {
|
|
2037
|
-
prom2.then(
|
|
2038
|
-
(data2) => {
|
|
2039
|
-
setSsrData(key, data2, ownerToken);
|
|
2040
|
-
},
|
|
2041
|
-
() => {
|
|
2042
|
-
}
|
|
2043
|
-
);
|
|
2044
|
-
}
|
|
2045
2035
|
attachSettle(handle2, prom2);
|
|
2046
2036
|
}
|
|
2047
2037
|
trackSsrPromise(prom2);
|
|
@@ -2663,9 +2653,9 @@ function createHydrateWalker(container, markerList) {
|
|
|
2663
2653
|
}
|
|
2664
2654
|
function bumpNavEpoch() {
|
|
2665
2655
|
try {
|
|
2666
|
-
const
|
|
2667
|
-
const next = (
|
|
2668
|
-
|
|
2656
|
+
const g4 = globalThis;
|
|
2657
|
+
const next = (g4.__vesk_nav_epoch || 0) + 1;
|
|
2658
|
+
g4.__vesk_nav_epoch = next;
|
|
2669
2659
|
return next;
|
|
2670
2660
|
} catch {
|
|
2671
2661
|
return 0;
|
|
@@ -5345,8 +5335,8 @@ function createRouter(routes, options = {}) {
|
|
|
5345
5335
|
},
|
|
5346
5336
|
_runGuards(to) {
|
|
5347
5337
|
const from = get(_state.path) || window.location.pathname;
|
|
5348
|
-
for (const
|
|
5349
|
-
const d =
|
|
5338
|
+
for (const g4 of this._beforeGuards ?? []) {
|
|
5339
|
+
const d = g4(to, from);
|
|
5350
5340
|
if (d instanceof Promise) {
|
|
5351
5341
|
return d.then((r) => {
|
|
5352
5342
|
if (r === false || typeof r === "string") return r;
|
|
@@ -5672,8 +5662,8 @@ function createFileRouter(routeTree, options = {}) {
|
|
|
5672
5662
|
},
|
|
5673
5663
|
_runGuards(to) {
|
|
5674
5664
|
const from = get(_state.path) || window.location.pathname;
|
|
5675
|
-
for (const
|
|
5676
|
-
const d =
|
|
5665
|
+
for (const g4 of this._beforeGuards ?? []) {
|
|
5666
|
+
const d = g4(to, from);
|
|
5677
5667
|
if (d instanceof Promise) {
|
|
5678
5668
|
return d.then((r) => {
|
|
5679
5669
|
if (r === false || typeof r === "string") return r;
|
|
@@ -21759,16 +21749,16 @@ function sha256Bytes(msg) {
|
|
|
21759
21749
|
const s1 = rr(w[j - 2], 17) ^ rr(w[j - 2], 19) ^ w[j - 2] >>> 10;
|
|
21760
21750
|
w[j] = w[j - 16] + s0 + w[j - 7] + s1 >>> 0;
|
|
21761
21751
|
}
|
|
21762
|
-
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;
|
|
21763
21753
|
for (let j = 0; j < 64; j++) {
|
|
21764
21754
|
const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
|
|
21765
|
-
const ch = e & f ^ ~e &
|
|
21755
|
+
const ch = e & f ^ ~e & g4;
|
|
21766
21756
|
const t1 = h + S1 + ch + SHA_K[j] + w[j] >>> 0;
|
|
21767
21757
|
const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
|
|
21768
21758
|
const maj = a & b ^ a & c ^ b & c;
|
|
21769
21759
|
const t2 = S0 + maj >>> 0;
|
|
21770
|
-
h =
|
|
21771
|
-
|
|
21760
|
+
h = g4;
|
|
21761
|
+
g4 = f;
|
|
21772
21762
|
f = e;
|
|
21773
21763
|
e = d + t1 >>> 0;
|
|
21774
21764
|
d = c;
|
|
@@ -21782,7 +21772,7 @@ function sha256Bytes(msg) {
|
|
|
21782
21772
|
h3 = h3 + d >>> 0;
|
|
21783
21773
|
h4 = h4 + e >>> 0;
|
|
21784
21774
|
h5 = h5 + f >>> 0;
|
|
21785
|
-
h6 = h6 +
|
|
21775
|
+
h6 = h6 + g4 >>> 0;
|
|
21786
21776
|
h7 = h7 + h >>> 0;
|
|
21787
21777
|
}
|
|
21788
21778
|
const out = new Uint8Array(32);
|
|
@@ -22833,23 +22823,23 @@ async function _getImpl() {
|
|
|
22833
22823
|
return _signImpl;
|
|
22834
22824
|
}
|
|
22835
22825
|
async function signCookie2(name, value, host) {
|
|
22836
|
-
const
|
|
22837
|
-
if (
|
|
22826
|
+
const impl3 = await _getImpl();
|
|
22827
|
+
if (impl3.signCookie) return impl3.signCookie(name, value, host);
|
|
22838
22828
|
throw new Error("signCookie: @vesk/compiler not available");
|
|
22839
22829
|
}
|
|
22840
22830
|
async function unsignCookie2(name, signedValue, host) {
|
|
22841
|
-
const
|
|
22842
|
-
if (
|
|
22831
|
+
const impl3 = await _getImpl();
|
|
22832
|
+
if (impl3.unsignCookie) return impl3.unsignCookie(name, signedValue, host);
|
|
22843
22833
|
throw new Error("unsignCookie: @vesk/compiler not available");
|
|
22844
22834
|
}
|
|
22845
22835
|
async function setSignedCookie2(name, value, options = {}, host) {
|
|
22846
|
-
const
|
|
22847
|
-
if (
|
|
22836
|
+
const impl3 = await _getImpl();
|
|
22837
|
+
if (impl3.setSignedCookie) return impl3.setSignedCookie(name, value, options, host);
|
|
22848
22838
|
throw new Error("setSignedCookie: @vesk/compiler not available");
|
|
22849
22839
|
}
|
|
22850
22840
|
async function readSignedCookie2(name, cookieString, host) {
|
|
22851
|
-
const
|
|
22852
|
-
if (
|
|
22841
|
+
const impl3 = await _getImpl();
|
|
22842
|
+
if (impl3.readSignedCookie) return impl3.readSignedCookie(name, cookieString, host);
|
|
22853
22843
|
throw new Error("readSignedCookie: @vesk/compiler not available");
|
|
22854
22844
|
}
|
|
22855
22845
|
var ServerRequest, ServerResponse, DEFAULT_MAX_BODY_BYTES2, PayloadTooLargeError, VeskRequest, _VeskResponse, VeskResponse, _signImpl;
|
|
@@ -26365,9 +26355,9 @@ var init_primitive = __esm({
|
|
|
26365
26355
|
|
|
26366
26356
|
// ../runtime/src/action.ts
|
|
26367
26357
|
function getActionRegistry() {
|
|
26368
|
-
const
|
|
26369
|
-
if (!
|
|
26370
|
-
return
|
|
26358
|
+
const g4 = globalThis;
|
|
26359
|
+
if (!g4[registryKey]) g4[registryKey] = {};
|
|
26360
|
+
return g4[registryKey];
|
|
26371
26361
|
}
|
|
26372
26362
|
function hashString(str3) {
|
|
26373
26363
|
let h1 = 2166136261;
|
|
@@ -26405,8 +26395,8 @@ function getAction(id) {
|
|
|
26405
26395
|
return getActionRegistry()[id] || null;
|
|
26406
26396
|
}
|
|
26407
26397
|
function clearActions() {
|
|
26408
|
-
const
|
|
26409
|
-
|
|
26398
|
+
const g4 = globalThis;
|
|
26399
|
+
g4[registryKey] = {};
|
|
26410
26400
|
}
|
|
26411
26401
|
function isFormAction(action) {
|
|
26412
26402
|
return typeof action === "object" && action !== null && (action.__veskAction === true || typeof action.id === "string" && typeof action.url === "string");
|
|
@@ -31810,14 +31800,23 @@ function dropSsrSlot(token) {
|
|
|
31810
31800
|
function isSsrSlotLive(token) {
|
|
31811
31801
|
return liveSlots.has(token);
|
|
31812
31802
|
}
|
|
31813
|
-
var TOKEN_KEY, storage, liveSlots, ssrSink2;
|
|
31803
|
+
var TOKEN_KEY, IMPL_KEY, g2, impl, storage, liveSlots, ssrSink2;
|
|
31814
31804
|
var init_ssr_store = __esm({
|
|
31815
31805
|
"../compiler/src/ssr-store.ts"() {
|
|
31816
31806
|
"use strict";
|
|
31817
31807
|
init_index_server();
|
|
31818
31808
|
TOKEN_KEY = "__vsk_ssr_token";
|
|
31819
|
-
|
|
31820
|
-
|
|
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;
|
|
31821
31820
|
ssrSink2 = {
|
|
31822
31821
|
set: (key, value) => {
|
|
31823
31822
|
const store = storage.getStore();
|
|
@@ -31836,16 +31835,18 @@ var init_ssr_store = __esm({
|
|
|
31836
31835
|
}
|
|
31837
31836
|
};
|
|
31838
31837
|
setSsrSink(ssrSink2);
|
|
31839
|
-
|
|
31840
|
-
|
|
31841
|
-
|
|
31842
|
-
|
|
31843
|
-
|
|
31844
|
-
|
|
31845
|
-
|
|
31846
|
-
|
|
31847
|
-
|
|
31848
|
-
|
|
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
|
+
}
|
|
31849
31850
|
}
|
|
31850
31851
|
});
|
|
31851
31852
|
|
|
@@ -32104,17 +32105,17 @@ async function settleSsrPromises(token) {
|
|
|
32104
32105
|
}
|
|
32105
32106
|
}
|
|
32106
32107
|
function pruneSsrDataSlots() {
|
|
32107
|
-
const
|
|
32108
|
+
const g4 = globalThis;
|
|
32108
32109
|
const prefix = "__vsk_ssr_data_";
|
|
32109
32110
|
const stale = [];
|
|
32110
|
-
for (const k of Object.keys(
|
|
32111
|
+
for (const k of Object.keys(g4)) {
|
|
32111
32112
|
if (typeof k !== "string" || !k.startsWith(prefix)) continue;
|
|
32112
32113
|
if (isSsrSlotLive(k.slice(prefix.length))) continue;
|
|
32113
32114
|
stale.push(k);
|
|
32114
32115
|
}
|
|
32115
32116
|
if (stale.length <= 40) return;
|
|
32116
32117
|
stale.sort().slice(0, stale.length - 40).forEach((k) => {
|
|
32117
|
-
delete
|
|
32118
|
+
delete g4[k];
|
|
32118
32119
|
});
|
|
32119
32120
|
}
|
|
32120
32121
|
async function applyHeadPlugins(headHtml, plugins, ctx2) {
|
|
@@ -34062,7 +34063,7 @@ ${serverStoreLine}
|
|
|
34062
34063
|
// SSR already resolved. Entry is consumed on read (bound store).
|
|
34063
34064
|
if (pathname === '/ssr-data.js') {
|
|
34064
34065
|
const dataToken = url.searchParams.get('t') || '';
|
|
34065
|
-
const dataStore = (globalThis.
|
|
34066
|
+
const dataStore = (globalThis.__vsk_ssr_payload_store || {});
|
|
34066
34067
|
const payload = dataStore[dataToken];
|
|
34067
34068
|
if (payload) delete dataStore[dataToken];
|
|
34068
34069
|
const dataLines = [];
|
|
@@ -37846,9 +37847,9 @@ function getJSXTagName2(el) {
|
|
|
37846
37847
|
if (name.type === "JSXNamespacedName") return name.namespace.name + ":" + name.name.name;
|
|
37847
37848
|
return null;
|
|
37848
37849
|
}
|
|
37849
|
-
function emitJSXText(
|
|
37850
|
+
function emitJSXText(g4, text, start, end) {
|
|
37850
37851
|
if (text.indexOf("<") === -1 && text.indexOf(">") === -1 && text.indexOf("&") === -1 && text.indexOf("{") === -1 && text.indexOf("}") === -1) {
|
|
37851
|
-
|
|
37852
|
+
g4.add(text, start, end);
|
|
37852
37853
|
return;
|
|
37853
37854
|
}
|
|
37854
37855
|
let out = "";
|
|
@@ -37861,7 +37862,7 @@ function emitJSXText(g2, text, start, end) {
|
|
|
37861
37862
|
else if (c === "}") out += "}";
|
|
37862
37863
|
else out += c;
|
|
37863
37864
|
}
|
|
37864
|
-
|
|
37865
|
+
g4.add(out, start, end);
|
|
37865
37866
|
}
|
|
37866
37867
|
function collapseWithMap(value) {
|
|
37867
37868
|
let out = "";
|
|
@@ -38018,31 +38019,31 @@ function stripCallTypeArgs(text) {
|
|
|
38018
38019
|
}
|
|
38019
38020
|
return text;
|
|
38020
38021
|
}
|
|
38021
|
-
function emitTrackDeclStatement(
|
|
38022
|
+
function emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts) {
|
|
38022
38023
|
const fullText = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
|
|
38023
38024
|
const text = fullText + (!fullText.endsWith("}") && !isLast ? ";" : "");
|
|
38024
38025
|
const decls = stmt.declarations || [];
|
|
38025
|
-
|
|
38026
|
+
g4.add(indent4);
|
|
38026
38027
|
let prevEnd = stmt.start;
|
|
38027
38028
|
for (let di = 0; di < decls.length; di++) {
|
|
38028
38029
|
const decl = decls[di];
|
|
38029
38030
|
const id = decl.id;
|
|
38030
38031
|
const isLazy = id && id.type === "ArrayPattern" && id.lazy === true && decl.init;
|
|
38031
38032
|
if (!isLazy) {
|
|
38032
|
-
|
|
38033
|
-
|
|
38033
|
+
g4.addRaw(source.slice(prevEnd, decl.start));
|
|
38034
|
+
g4.add(source.slice(decl.start, decl.end), decl.start, decl.end);
|
|
38034
38035
|
prevEnd = decl.end;
|
|
38035
38036
|
continue;
|
|
38036
38037
|
}
|
|
38037
|
-
if (di > 0)
|
|
38038
|
+
if (di > 0) g4.addRaw(source.slice(prevEnd, decl.start));
|
|
38038
38039
|
const ch = text[decl.end - stmt.start] ?? " ";
|
|
38039
38040
|
const elements = id.elements || [];
|
|
38040
38041
|
const names = elements.map((el) => el ? el.name : null).filter((n) => typeof n === "string");
|
|
38041
38042
|
const initText = source.slice(decl.init.start, decl.init.end);
|
|
38042
38043
|
if (names.length === 0) {
|
|
38043
|
-
|
|
38044
|
-
|
|
38045
|
-
if (ch !== ";")
|
|
38044
|
+
g4.add("let _ = ");
|
|
38045
|
+
g4.add(initText, decl.init.start, decl.init.end);
|
|
38046
|
+
if (ch !== ";") g4.addRaw(";");
|
|
38046
38047
|
prevEnd = decl.end;
|
|
38047
38048
|
continue;
|
|
38048
38049
|
}
|
|
@@ -38053,133 +38054,133 @@ function emitTrackDeclStatement(g2, source, stmt, indent4, isLast, opts) {
|
|
|
38053
38054
|
const firstRange = [elements[0].start, elements[0].end];
|
|
38054
38055
|
const dropLastSemi = ch === ";";
|
|
38055
38056
|
if (opts.typedCells) {
|
|
38056
|
-
const cellName =
|
|
38057
|
-
|
|
38057
|
+
const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
|
|
38058
|
+
g4.cellCount++;
|
|
38058
38059
|
if (annotation) {
|
|
38059
|
-
|
|
38060
|
-
|
|
38061
|
-
|
|
38060
|
+
g4.add(`const ${cellName}: Tracked<`);
|
|
38061
|
+
g4.add(annotation, annStart, annEnd);
|
|
38062
|
+
g4.add("> = ");
|
|
38062
38063
|
} else {
|
|
38063
|
-
|
|
38064
|
+
g4.add(`const ${cellName} = `);
|
|
38064
38065
|
}
|
|
38065
38066
|
const cellInit = annotation ? stripCallTypeArgs(initText) : initText;
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
|
|
38069
|
-
|
|
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);
|
|
38070
38071
|
if (annotation) {
|
|
38071
|
-
|
|
38072
|
-
|
|
38072
|
+
g4.add(": ");
|
|
38073
|
+
g4.add(annotation, annStart, annEnd);
|
|
38073
38074
|
}
|
|
38074
|
-
|
|
38075
|
+
g4.add(` = ${cellName}.get();`);
|
|
38075
38076
|
for (let n = 1; n < names.length; n++) {
|
|
38076
|
-
|
|
38077
|
-
|
|
38078
|
-
|
|
38077
|
+
g4.add(" let ");
|
|
38078
|
+
g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
|
|
38079
|
+
g4.add(` = ${cellName};`);
|
|
38079
38080
|
}
|
|
38080
|
-
if (dropLastSemi)
|
|
38081
|
+
if (dropLastSemi) g4.code = g4.code.slice(0, -1);
|
|
38081
38082
|
} else {
|
|
38082
38083
|
if (annotation) {
|
|
38083
|
-
|
|
38084
|
-
|
|
38085
|
-
|
|
38086
|
-
|
|
38087
|
-
|
|
38088
|
-
|
|
38089
|
-
|
|
38090
|
-
|
|
38091
|
-
|
|
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(");");
|
|
38092
38093
|
} else {
|
|
38093
|
-
const cellName =
|
|
38094
|
-
|
|
38095
|
-
|
|
38096
|
-
|
|
38097
|
-
|
|
38098
|
-
|
|
38099
|
-
|
|
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();`);
|
|
38100
38101
|
}
|
|
38101
38102
|
for (let n = 1; n < names.length; n++) {
|
|
38102
|
-
|
|
38103
|
-
|
|
38104
|
-
|
|
38105
|
-
|
|
38106
|
-
|
|
38107
|
-
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);
|
|
38108
38109
|
}
|
|
38109
|
-
if (names.length === 1 && dropLastSemi)
|
|
38110
|
+
if (names.length === 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
|
|
38110
38111
|
}
|
|
38111
38112
|
prevEnd = decl.end;
|
|
38112
38113
|
}
|
|
38113
|
-
if (!isLast)
|
|
38114
|
+
if (!isLast) g4.addRaw(";");
|
|
38114
38115
|
}
|
|
38115
|
-
function emitBlock(
|
|
38116
|
+
function emitBlock(g4, source, body, indent4, opts) {
|
|
38116
38117
|
const stmts = body && body.type === "BlockStatement" ? body.body : body ? Array.isArray(body) ? body : [body] : [];
|
|
38117
|
-
|
|
38118
|
-
emitBody(
|
|
38119
|
-
|
|
38120
|
-
|
|
38121
|
-
|
|
38118
|
+
g4.addRaw("{\n");
|
|
38119
|
+
emitBody(g4, source, stmts, indent4 + " ", opts);
|
|
38120
|
+
g4.addRaw("\n");
|
|
38121
|
+
g4.add(indent4);
|
|
38122
|
+
g4.addRaw("}");
|
|
38122
38123
|
}
|
|
38123
|
-
function emitJSXAttr(
|
|
38124
|
+
function emitJSXAttr(g4, source, attr) {
|
|
38124
38125
|
if (attr.type === "JSXSpreadAttribute") {
|
|
38125
|
-
|
|
38126
|
+
g4.add(source.slice(attr.start, attr.end), attr.start, attr.end);
|
|
38126
38127
|
return;
|
|
38127
38128
|
}
|
|
38128
38129
|
const name = attr.name;
|
|
38129
|
-
|
|
38130
|
+
g4.add(source.slice(name.start, name.end), name.start, name.end);
|
|
38130
38131
|
const v = attr.value;
|
|
38131
38132
|
if (!v) return;
|
|
38132
|
-
|
|
38133
|
+
g4.add(source.slice(name.end, v.start), name.end, v.start);
|
|
38133
38134
|
if (v.type === "JSXExpressionContainer") {
|
|
38134
|
-
|
|
38135
|
-
|
|
38136
|
-
|
|
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);
|
|
38137
38138
|
} else {
|
|
38138
|
-
|
|
38139
|
+
g4.add(source.slice(v.start, v.end), v.start, v.end);
|
|
38139
38140
|
}
|
|
38140
38141
|
}
|
|
38141
|
-
function emitJSXElement(
|
|
38142
|
+
function emitJSXElement(g4, source, el, opts, hoist) {
|
|
38142
38143
|
const op = el.openingElement;
|
|
38143
38144
|
const name = op.name;
|
|
38144
38145
|
let prev;
|
|
38145
38146
|
if (name) {
|
|
38146
|
-
|
|
38147
|
-
|
|
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);
|
|
38148
38149
|
prev = name.end;
|
|
38149
38150
|
} else {
|
|
38150
38151
|
prev = op.start + 1;
|
|
38151
38152
|
}
|
|
38152
38153
|
for (const attr of op.attributes ?? []) {
|
|
38153
|
-
|
|
38154
|
-
emitJSXAttr(
|
|
38154
|
+
g4.add(source.slice(prev, attr.start), prev, attr.start);
|
|
38155
|
+
emitJSXAttr(g4, source, attr);
|
|
38155
38156
|
prev = attr.end;
|
|
38156
38157
|
}
|
|
38157
38158
|
const tail = source.slice(prev, op.end);
|
|
38158
38159
|
if (op.selfClosing && !tail.includes("/")) {
|
|
38159
38160
|
const gt = tail.lastIndexOf(">");
|
|
38160
38161
|
const head = gt === -1 ? tail : tail.slice(0, gt);
|
|
38161
|
-
if (head)
|
|
38162
|
-
|
|
38162
|
+
if (head) g4.add(head, prev, prev + head.length);
|
|
38163
|
+
g4.addRaw("/>");
|
|
38163
38164
|
} else {
|
|
38164
|
-
|
|
38165
|
+
g4.add(tail, prev, op.end);
|
|
38165
38166
|
}
|
|
38166
38167
|
if (op.selfClosing) return;
|
|
38167
|
-
emitJSXChildren(
|
|
38168
|
+
emitJSXChildren(g4, source, el.children ?? [], opts, hoist);
|
|
38168
38169
|
if (el.closingElement) {
|
|
38169
|
-
|
|
38170
|
+
g4.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
|
|
38170
38171
|
}
|
|
38171
38172
|
}
|
|
38172
|
-
function emitJSXExprBody(
|
|
38173
|
-
if (expr.type === "JSXElement") return emitJSXElement(
|
|
38174
|
-
if (expr.type === "JSXFragment") return emitJSXFragment(
|
|
38175
|
-
|
|
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);
|
|
38176
38177
|
}
|
|
38177
|
-
function emitJSXFragment(
|
|
38178
|
-
|
|
38179
|
-
emitJSXChildren(
|
|
38180
|
-
|
|
38178
|
+
function emitJSXFragment(g4, source, frag, opts, hoist) {
|
|
38179
|
+
g4.addRaw("<>");
|
|
38180
|
+
emitJSXChildren(g4, source, frag.children ?? [], opts, hoist);
|
|
38181
|
+
g4.addRaw("</>");
|
|
38181
38182
|
}
|
|
38182
|
-
function emitForClauseMap(
|
|
38183
|
+
function emitForClauseMap(g4, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
|
|
38183
38184
|
const clauseEnd = findBalancedEnd(text, clauseStart - 1);
|
|
38184
38185
|
const clause = text.slice(clauseStart, clauseEnd);
|
|
38185
38186
|
const ofIdx = findTopLevelSep(clause, "of");
|
|
@@ -38196,38 +38197,38 @@ function emitForClauseMap(g2, source, child, text, map, clauseStart, bodyEmit, e
|
|
|
38196
38197
|
const itemVar = stripDeclKeyword(lhs).trim();
|
|
38197
38198
|
if (ofIdx !== -1) {
|
|
38198
38199
|
if (emptyEmit) {
|
|
38199
|
-
|
|
38200
|
-
|
|
38201
|
-
|
|
38200
|
+
g4.addRaw("{ (() => { const _v = ");
|
|
38201
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38202
|
+
g4.addRaw("; return _v.length === 0 ? (");
|
|
38202
38203
|
emptyEmit();
|
|
38203
|
-
|
|
38204
|
-
|
|
38205
|
-
|
|
38204
|
+
g4.addRaw(") : _v.map((");
|
|
38205
|
+
g4.addRaw(itemVar);
|
|
38206
|
+
g4.addRaw(": (typeof _v)[number]) => (");
|
|
38206
38207
|
bodyEmit();
|
|
38207
|
-
|
|
38208
|
+
g4.addRaw(")); })() }");
|
|
38208
38209
|
} else {
|
|
38209
|
-
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
|
|
38213
|
-
|
|
38214
|
-
|
|
38215
|
-
|
|
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]) => (");
|
|
38216
38217
|
bodyEmit();
|
|
38217
|
-
|
|
38218
|
+
g4.addRaw(")) }");
|
|
38218
38219
|
}
|
|
38219
38220
|
} else {
|
|
38220
|
-
|
|
38221
|
-
|
|
38222
|
-
|
|
38223
|
-
|
|
38224
|
-
|
|
38221
|
+
g4.addRaw("{ Object.keys(");
|
|
38222
|
+
g4.add(arrExpr, arrStart, arrEnd);
|
|
38223
|
+
g4.addRaw(").map((");
|
|
38224
|
+
g4.addRaw(itemVar);
|
|
38225
|
+
g4.addRaw(") => (");
|
|
38225
38226
|
bodyEmit();
|
|
38226
|
-
|
|
38227
|
+
g4.addRaw(")) }");
|
|
38227
38228
|
}
|
|
38228
38229
|
return true;
|
|
38229
38230
|
}
|
|
38230
|
-
function emitJSXChildren(
|
|
38231
|
+
function emitJSXChildren(g4, source, children, opts, hoist) {
|
|
38231
38232
|
let i = 0;
|
|
38232
38233
|
let forPending = false;
|
|
38233
38234
|
while (i < children.length) {
|
|
@@ -38253,46 +38254,46 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
|
|
|
38253
38254
|
const emptyContainer = children[i + 3];
|
|
38254
38255
|
if (emptyTextNode && emptyTextNode.type === "JSXText" && ["#empty", "empty"].includes(emptyTextNode.value.trim()) && emptyContainer && emptyContainer.type === "JSXExpressionContainer" && emptyContainer.expression.type !== "JSXEmptyExpression") {
|
|
38255
38256
|
consumed = 4;
|
|
38256
|
-
emptyEmit = () => emitJSXExprBody(
|
|
38257
|
+
emptyEmit = () => emitJSXExprBody(g4, source, emptyContainer.expression, opts);
|
|
38257
38258
|
}
|
|
38258
38259
|
let matched = false;
|
|
38259
38260
|
if (nextChild.type === "JSXExpressionContainer") {
|
|
38260
38261
|
const exprNode = nextChild.expression;
|
|
38261
38262
|
if (exprNode.type === "JSXEmptyExpression") {
|
|
38262
|
-
|
|
38263
|
+
g4.add(text, child.start, child.end);
|
|
38263
38264
|
i++;
|
|
38264
38265
|
continue;
|
|
38265
38266
|
}
|
|
38266
38267
|
matched = emitForClauseMap(
|
|
38267
|
-
|
|
38268
|
+
g4,
|
|
38268
38269
|
source,
|
|
38269
38270
|
child,
|
|
38270
38271
|
text,
|
|
38271
38272
|
map,
|
|
38272
38273
|
clauseStartCollapsed,
|
|
38273
|
-
() => emitJSXExprBody(
|
|
38274
|
+
() => emitJSXExprBody(g4, source, exprNode, opts),
|
|
38274
38275
|
emptyEmit
|
|
38275
38276
|
);
|
|
38276
38277
|
} else if (nextChild.type === "JSXFragment") {
|
|
38277
38278
|
matched = emitForClauseMap(
|
|
38278
|
-
|
|
38279
|
+
g4,
|
|
38279
38280
|
source,
|
|
38280
38281
|
child,
|
|
38281
38282
|
text,
|
|
38282
38283
|
map,
|
|
38283
38284
|
clauseStartCollapsed,
|
|
38284
|
-
() => emitJSXFragment(
|
|
38285
|
+
() => emitJSXFragment(g4, source, nextChild, opts),
|
|
38285
38286
|
emptyEmit
|
|
38286
38287
|
);
|
|
38287
38288
|
} else {
|
|
38288
38289
|
matched = emitForClauseMap(
|
|
38289
|
-
|
|
38290
|
+
g4,
|
|
38290
38291
|
source,
|
|
38291
38292
|
child,
|
|
38292
38293
|
text,
|
|
38293
38294
|
map,
|
|
38294
38295
|
clauseStartCollapsed,
|
|
38295
|
-
() => emitJSXElement(
|
|
38296
|
+
() => emitJSXElement(g4, source, nextChild, opts),
|
|
38296
38297
|
emptyEmit
|
|
38297
38298
|
);
|
|
38298
38299
|
}
|
|
@@ -38309,184 +38310,184 @@ function emitJSXChildren(g2, source, children, opts, hoist) {
|
|
|
38309
38310
|
continue;
|
|
38310
38311
|
}
|
|
38311
38312
|
forPending = false;
|
|
38312
|
-
emitJSXText(
|
|
38313
|
+
emitJSXText(g4, text, child.start, child.end);
|
|
38313
38314
|
i++;
|
|
38314
38315
|
} else if (child.type === "JSXExpressionContainer") {
|
|
38315
38316
|
if (child.expression.type === "JSXEmptyExpression") {
|
|
38316
38317
|
i++;
|
|
38317
38318
|
continue;
|
|
38318
38319
|
}
|
|
38319
|
-
|
|
38320
|
-
|
|
38321
|
-
|
|
38320
|
+
g4.addRaw("{");
|
|
38321
|
+
g4.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
|
|
38322
|
+
g4.addRaw("}");
|
|
38322
38323
|
i++;
|
|
38323
38324
|
} else if (child.type === "JSXElement") {
|
|
38324
38325
|
if (getJSXTagName2(child) === "style") {
|
|
38325
38326
|
const openEnd = child.openingElement?.end ?? child.start;
|
|
38326
38327
|
const closeStart = child.closingElement?.start ?? child.end;
|
|
38327
|
-
|
|
38328
|
+
g4.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
|
|
38328
38329
|
i++;
|
|
38329
38330
|
continue;
|
|
38330
38331
|
}
|
|
38331
|
-
emitJSXElement(
|
|
38332
|
+
emitJSXElement(g4, source, child, opts, hoist);
|
|
38332
38333
|
i++;
|
|
38333
38334
|
} else if (child.type === "JSXFragment") {
|
|
38334
|
-
emitJSXFragment(
|
|
38335
|
+
emitJSXFragment(g4, source, child, opts, hoist);
|
|
38335
38336
|
i++;
|
|
38336
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") {
|
|
38337
38338
|
if (hoist && hoist.set.has(child)) {
|
|
38338
38339
|
i++;
|
|
38339
38340
|
continue;
|
|
38340
38341
|
}
|
|
38341
|
-
|
|
38342
|
-
emitBody(
|
|
38343
|
-
|
|
38342
|
+
g4.addRaw("{(() => { ");
|
|
38343
|
+
emitBody(g4, source, [child], "", opts);
|
|
38344
|
+
g4.addRaw(" })()}");
|
|
38344
38345
|
i++;
|
|
38345
38346
|
} else {
|
|
38346
38347
|
i++;
|
|
38347
38348
|
}
|
|
38348
38349
|
}
|
|
38349
38350
|
}
|
|
38350
|
-
function emitIf(
|
|
38351
|
-
|
|
38352
|
-
|
|
38353
|
-
|
|
38354
|
-
|
|
38355
|
-
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);
|
|
38356
38357
|
if (stmt.alternate) {
|
|
38357
|
-
|
|
38358
|
-
emitBlock(
|
|
38358
|
+
g4.addRaw(" else ");
|
|
38359
|
+
emitBlock(g4, source, stmt.alternate, indent4, opts);
|
|
38359
38360
|
}
|
|
38360
38361
|
}
|
|
38361
|
-
function emitLoopVariable(
|
|
38362
|
+
function emitLoopVariable(g4, source, left) {
|
|
38362
38363
|
if (left && left.type === "Identifier") {
|
|
38363
|
-
|
|
38364
|
-
|
|
38364
|
+
g4.addRaw("const ");
|
|
38365
|
+
g4.add(source.slice(left.start, left.end), left.start, left.end);
|
|
38365
38366
|
return;
|
|
38366
38367
|
}
|
|
38367
|
-
|
|
38368
|
-
}
|
|
38369
|
-
function emitForOf(
|
|
38370
|
-
|
|
38371
|
-
|
|
38372
|
-
emitLoopVariable(
|
|
38373
|
-
|
|
38374
|
-
|
|
38375
|
-
|
|
38376
|
-
emitBlock(
|
|
38377
|
-
}
|
|
38378
|
-
function emitForIn(
|
|
38379
|
-
|
|
38380
|
-
|
|
38381
|
-
emitLoopVariable(
|
|
38382
|
-
|
|
38383
|
-
|
|
38384
|
-
|
|
38385
|
-
emitBlock(
|
|
38386
|
-
}
|
|
38387
|
-
function emitFor(
|
|
38388
|
-
|
|
38389
|
-
|
|
38390
|
-
if (stmt.init)
|
|
38391
|
-
|
|
38392
|
-
if (stmt.test)
|
|
38393
|
-
|
|
38394
|
-
if (stmt.update)
|
|
38395
|
-
|
|
38396
|
-
emitBlock(
|
|
38397
|
-
}
|
|
38398
|
-
function emitWhile(
|
|
38399
|
-
|
|
38400
|
-
|
|
38401
|
-
|
|
38402
|
-
|
|
38403
|
-
emitBlock(
|
|
38404
|
-
}
|
|
38405
|
-
function emitDoWhile(
|
|
38406
|
-
|
|
38407
|
-
|
|
38408
|
-
emitBlock(
|
|
38409
|
-
|
|
38410
|
-
|
|
38411
|
-
|
|
38412
|
-
}
|
|
38413
|
-
function emitSwitch(
|
|
38414
|
-
|
|
38415
|
-
|
|
38416
|
-
|
|
38417
|
-
|
|
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(") {");
|
|
38418
38419
|
let firstCase = true;
|
|
38419
38420
|
for (const c of stmt.cases ?? []) {
|
|
38420
|
-
|
|
38421
|
+
g4.addRaw(firstCase ? "\n" : "\n");
|
|
38421
38422
|
firstCase = false;
|
|
38422
|
-
|
|
38423
|
-
|
|
38423
|
+
g4.add(indent4);
|
|
38424
|
+
g4.addRaw(" ");
|
|
38424
38425
|
if (c.test) {
|
|
38425
|
-
|
|
38426
|
-
|
|
38427
|
-
|
|
38426
|
+
g4.addRaw("case ");
|
|
38427
|
+
g4.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
|
|
38428
|
+
g4.addRaw(":");
|
|
38428
38429
|
} else {
|
|
38429
|
-
|
|
38430
|
+
g4.addRaw("default:");
|
|
38430
38431
|
}
|
|
38431
|
-
const before =
|
|
38432
|
-
emitBody(
|
|
38433
|
-
if (
|
|
38432
|
+
const before = g4.code.length;
|
|
38433
|
+
emitBody(g4, source, c.consequent, indent4 + " ", opts);
|
|
38434
|
+
if (g4.code.length > before) g4.addRaw("\n");
|
|
38434
38435
|
}
|
|
38435
|
-
|
|
38436
|
-
|
|
38437
|
-
|
|
38436
|
+
g4.addRaw("\n");
|
|
38437
|
+
g4.add(indent4);
|
|
38438
|
+
g4.addRaw("}");
|
|
38438
38439
|
}
|
|
38439
|
-
function emitTry(
|
|
38440
|
-
|
|
38441
|
-
|
|
38442
|
-
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);
|
|
38443
38444
|
if (stmt.handler) {
|
|
38444
|
-
|
|
38445
|
+
g4.addRaw(" catch");
|
|
38445
38446
|
if (stmt.handler.param) {
|
|
38446
|
-
|
|
38447
|
-
|
|
38448
|
-
|
|
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(")");
|
|
38449
38450
|
}
|
|
38450
|
-
|
|
38451
|
-
emitBlock(
|
|
38451
|
+
g4.addRaw(" ");
|
|
38452
|
+
emitBlock(g4, source, stmt.handler.body, indent4, opts);
|
|
38452
38453
|
}
|
|
38453
38454
|
if (stmt.finalizer) {
|
|
38454
|
-
|
|
38455
|
-
emitBlock(
|
|
38455
|
+
g4.addRaw(" finally ");
|
|
38456
|
+
emitBlock(g4, source, stmt.finalizer, indent4, opts);
|
|
38456
38457
|
}
|
|
38457
38458
|
}
|
|
38458
|
-
function emitPlainStatement(
|
|
38459
|
+
function emitPlainStatement(g4, source, stmt, indent4, isLast) {
|
|
38459
38460
|
let text = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
|
|
38460
38461
|
if (text === "") return;
|
|
38461
|
-
|
|
38462
|
-
|
|
38463
|
-
if (!text.endsWith("}") && !isLast)
|
|
38462
|
+
g4.add(indent4);
|
|
38463
|
+
g4.add(text, stmt.start, stmt.end);
|
|
38464
|
+
if (!text.endsWith("}") && !isLast) g4.addRaw(";");
|
|
38464
38465
|
}
|
|
38465
|
-
function emitStatement(
|
|
38466
|
+
function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
|
|
38466
38467
|
switch (stmt.type) {
|
|
38467
38468
|
case "JSXElement":
|
|
38468
38469
|
if (getJSXTagName2(stmt) === "style") {
|
|
38469
38470
|
const openEnd = stmt.openingElement?.end ?? stmt.start;
|
|
38470
38471
|
const closeStart = stmt.closingElement?.start ?? stmt.end;
|
|
38471
|
-
|
|
38472
|
+
g4.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
|
|
38472
38473
|
return;
|
|
38473
38474
|
}
|
|
38474
|
-
|
|
38475
|
-
emitJSXElement(
|
|
38476
|
-
if (!isLast)
|
|
38475
|
+
g4.add(indent4);
|
|
38476
|
+
emitJSXElement(g4, source, stmt, opts, hoist);
|
|
38477
|
+
if (!isLast) g4.addRaw(";");
|
|
38477
38478
|
return;
|
|
38478
38479
|
case "JSXFragment":
|
|
38479
|
-
|
|
38480
|
-
emitJSXFragment(
|
|
38481
|
-
if (!isLast)
|
|
38480
|
+
g4.add(indent4);
|
|
38481
|
+
emitJSXFragment(g4, source, stmt, opts, hoist);
|
|
38482
|
+
if (!isLast) g4.addRaw(";");
|
|
38482
38483
|
return;
|
|
38483
38484
|
case "JSXExpressionContainer": {
|
|
38484
38485
|
if (stmt.expression.type === "JSXEmptyExpression") return;
|
|
38485
|
-
|
|
38486
|
-
|
|
38487
|
-
|
|
38488
|
-
|
|
38489
|
-
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(";");
|
|
38490
38491
|
return;
|
|
38491
38492
|
}
|
|
38492
38493
|
case "VeskBlock": {
|
|
@@ -38494,10 +38495,10 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
|
|
|
38494
38495
|
const innerStmts = stmt.body ?? [];
|
|
38495
38496
|
let firstLine = true;
|
|
38496
38497
|
for (let i = 0; i < innerStmts.length; i++) {
|
|
38497
|
-
const before =
|
|
38498
|
-
emitStatement(
|
|
38499
|
-
if (
|
|
38500
|
-
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");
|
|
38501
38502
|
firstLine = false;
|
|
38502
38503
|
}
|
|
38503
38504
|
}
|
|
@@ -38505,38 +38506,38 @@ function emitStatement(g2, source, stmt, indent4, isLast, opts, hoist) {
|
|
|
38505
38506
|
}
|
|
38506
38507
|
case "VariableDeclaration":
|
|
38507
38508
|
if (isTrackDeclStatement(stmt)) {
|
|
38508
|
-
emitTrackDeclStatement(
|
|
38509
|
+
emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts);
|
|
38509
38510
|
return;
|
|
38510
38511
|
}
|
|
38511
|
-
return emitPlainStatement(
|
|
38512
|
+
return emitPlainStatement(g4, source, stmt, indent4, isLast);
|
|
38512
38513
|
case "IfStatement":
|
|
38513
|
-
return emitIf(
|
|
38514
|
+
return emitIf(g4, source, stmt, indent4, opts);
|
|
38514
38515
|
case "ForOfStatement":
|
|
38515
|
-
return emitForOf(
|
|
38516
|
+
return emitForOf(g4, source, stmt, indent4, opts);
|
|
38516
38517
|
case "ForInStatement":
|
|
38517
|
-
return emitForIn(
|
|
38518
|
+
return emitForIn(g4, source, stmt, indent4, opts);
|
|
38518
38519
|
case "ForStatement":
|
|
38519
|
-
return emitFor(
|
|
38520
|
+
return emitFor(g4, source, stmt, indent4, opts);
|
|
38520
38521
|
case "WhileStatement":
|
|
38521
|
-
return emitWhile(
|
|
38522
|
+
return emitWhile(g4, source, stmt, indent4, opts);
|
|
38522
38523
|
case "DoWhileStatement":
|
|
38523
|
-
return emitDoWhile(
|
|
38524
|
+
return emitDoWhile(g4, source, stmt, indent4, opts);
|
|
38524
38525
|
case "SwitchStatement":
|
|
38525
|
-
return emitSwitch(
|
|
38526
|
+
return emitSwitch(g4, source, stmt, indent4, opts);
|
|
38526
38527
|
case "TryStatement":
|
|
38527
|
-
return emitTry(
|
|
38528
|
+
return emitTry(g4, source, stmt, indent4, opts);
|
|
38528
38529
|
case "LabeledStatement": {
|
|
38529
|
-
|
|
38530
|
-
|
|
38531
|
-
|
|
38532
|
-
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);
|
|
38533
38534
|
return;
|
|
38534
38535
|
}
|
|
38535
38536
|
default:
|
|
38536
|
-
return emitPlainStatement(
|
|
38537
|
+
return emitPlainStatement(g4, source, stmt, indent4, isLast);
|
|
38537
38538
|
}
|
|
38538
38539
|
}
|
|
38539
|
-
function emitBody(
|
|
38540
|
+
function emitBody(g4, source, stmts, indent4, opts, hoist) {
|
|
38540
38541
|
let firstLine = true;
|
|
38541
38542
|
let i = 0;
|
|
38542
38543
|
while (i < stmts.length) {
|
|
@@ -38544,34 +38545,34 @@ function emitBody(g2, source, stmts, indent4, opts, hoist) {
|
|
|
38544
38545
|
const isLast = i === stmts.length - 1;
|
|
38545
38546
|
if (stmt.type === "ForOfStatement" && stmts[i + 1] && stmts[i + 1].type === "VeskBlock" && stmts[i + 1].tag === "empty") {
|
|
38546
38547
|
const empty2 = stmts[i + 1];
|
|
38547
|
-
if (!firstLine)
|
|
38548
|
+
if (!firstLine) g4.addRaw("\n");
|
|
38548
38549
|
firstLine = false;
|
|
38549
|
-
emitForOf(
|
|
38550
|
+
emitForOf(g4, source, stmt, indent4, opts);
|
|
38550
38551
|
const inner = empty2.body ?? [];
|
|
38551
38552
|
if (inner.length > 0) {
|
|
38552
|
-
|
|
38553
|
-
|
|
38554
|
-
|
|
38555
|
-
|
|
38556
|
-
|
|
38557
|
-
emitBody(
|
|
38558
|
-
|
|
38559
|
-
|
|
38560
|
-
|
|
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("})();");
|
|
38561
38562
|
}
|
|
38562
38563
|
i += 2;
|
|
38563
38564
|
continue;
|
|
38564
38565
|
}
|
|
38565
|
-
const before =
|
|
38566
|
-
emitStatement(
|
|
38567
|
-
if (
|
|
38568
|
-
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");
|
|
38569
38570
|
firstLine = false;
|
|
38570
38571
|
}
|
|
38571
38572
|
i++;
|
|
38572
38573
|
}
|
|
38573
38574
|
}
|
|
38574
|
-
function emitChunkMapped(
|
|
38575
|
+
function emitChunkMapped(g4, source, start, end) {
|
|
38575
38576
|
if (end <= start) return;
|
|
38576
38577
|
let pos = start;
|
|
38577
38578
|
let i = start;
|
|
@@ -38583,8 +38584,8 @@ function emitChunkMapped(g2, source, start, end) {
|
|
|
38583
38584
|
if (openEnd !== -1 && openEnd <= end) {
|
|
38584
38585
|
const closeIdx = source.indexOf("</style>", openEnd);
|
|
38585
38586
|
if (closeIdx !== -1 && closeIdx + 8 <= end) {
|
|
38586
|
-
|
|
38587
|
-
|
|
38587
|
+
g4.add(source.slice(pos, i), pos, i);
|
|
38588
|
+
g4.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
|
|
38588
38589
|
pos = closeIdx + 8;
|
|
38589
38590
|
i = closeIdx + 8;
|
|
38590
38591
|
continue;
|
|
@@ -38594,20 +38595,20 @@ function emitChunkMapped(g2, source, start, end) {
|
|
|
38594
38595
|
}
|
|
38595
38596
|
i++;
|
|
38596
38597
|
}
|
|
38597
|
-
|
|
38598
|
+
g4.add(source.slice(pos, end), pos, end);
|
|
38598
38599
|
}
|
|
38599
|
-
function emitReturn(
|
|
38600
|
-
|
|
38600
|
+
function emitReturn(g4, source, stmt, opts) {
|
|
38601
|
+
g4.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
|
|
38601
38602
|
const arg = stmt.argument;
|
|
38602
38603
|
if (!arg) {
|
|
38603
|
-
emitChunkMapped(
|
|
38604
|
+
emitChunkMapped(g4, source, stmt.start + 6, stmt.end);
|
|
38604
38605
|
return;
|
|
38605
38606
|
}
|
|
38606
|
-
emitChunkMapped(
|
|
38607
|
-
if (arg.type === "JSXElement") emitJSXElement(
|
|
38608
|
-
else if (arg.type === "JSXFragment") emitJSXFragment(
|
|
38609
|
-
else emitChunkMapped(
|
|
38610
|
-
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);
|
|
38611
38612
|
}
|
|
38612
38613
|
function collectHoistEligible(children, set2, list) {
|
|
38613
38614
|
for (const child of children ?? []) {
|
|
@@ -38627,7 +38628,7 @@ function collectHoistEligible(children, set2, list) {
|
|
|
38627
38628
|
}
|
|
38628
38629
|
}
|
|
38629
38630
|
}
|
|
38630
|
-
function emitBodyCore(
|
|
38631
|
+
function emitBodyCore(g4, source, stmts, opts) {
|
|
38631
38632
|
const hoistSet = /* @__PURE__ */ new Set();
|
|
38632
38633
|
const byRoot = /* @__PURE__ */ new Map();
|
|
38633
38634
|
const collectRoot = (root3) => {
|
|
@@ -38678,107 +38679,107 @@ function emitBodyCore(g2, source, stmts, opts) {
|
|
|
38678
38679
|
byRoot.delete(u.node);
|
|
38679
38680
|
const n = list.length;
|
|
38680
38681
|
for (let k = 0; k < n; k++) {
|
|
38681
|
-
const before2 =
|
|
38682
|
-
emitStatement(
|
|
38683
|
-
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");
|
|
38684
38685
|
}
|
|
38685
38686
|
}
|
|
38686
38687
|
}
|
|
38687
38688
|
if (u.empty !== void 0) {
|
|
38688
|
-
emitForOf(
|
|
38689
|
+
emitForOf(g4, source, u.node, "", opts);
|
|
38689
38690
|
const inner = u.empty.body ?? [];
|
|
38690
38691
|
if (inner.length > 0) {
|
|
38691
|
-
|
|
38692
|
-
|
|
38693
|
-
|
|
38692
|
+
g4.addRaw("\n");
|
|
38693
|
+
g4.add("");
|
|
38694
|
+
g4.add(
|
|
38694
38695
|
source.slice(u.node.right.start, u.node.right.end),
|
|
38695
38696
|
u.node.right.start,
|
|
38696
38697
|
u.node.right.end
|
|
38697
38698
|
);
|
|
38698
|
-
|
|
38699
|
-
|
|
38700
|
-
emitBody(
|
|
38701
|
-
|
|
38702
|
-
|
|
38703
|
-
|
|
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("})();");
|
|
38704
38705
|
}
|
|
38705
38706
|
return;
|
|
38706
38707
|
}
|
|
38707
|
-
const before =
|
|
38708
|
-
emitStatement(
|
|
38709
|
-
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");
|
|
38710
38711
|
};
|
|
38711
38712
|
for (let i = 0; i < units.length; i++) {
|
|
38712
38713
|
emitUnit(units[i], i === units.length - 1);
|
|
38713
38714
|
}
|
|
38714
38715
|
}
|
|
38715
|
-
function emitExpressionBody(
|
|
38716
|
+
function emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts) {
|
|
38716
38717
|
let pos = coreStart;
|
|
38717
38718
|
for (const stmt of stmts) {
|
|
38718
38719
|
if (!stmt) continue;
|
|
38719
|
-
emitChunkMapped(
|
|
38720
|
+
emitChunkMapped(g4, source, pos, stmt.start);
|
|
38720
38721
|
pos = stmt.start;
|
|
38721
38722
|
if (isTrackDeclStatement(stmt)) {
|
|
38722
|
-
emitTrackDeclStatement(
|
|
38723
|
+
emitTrackDeclStatement(g4, source, stmt, "", true, opts);
|
|
38723
38724
|
} else if (stmt.type === "ReturnStatement") {
|
|
38724
|
-
emitReturn(
|
|
38725
|
+
emitReturn(g4, source, stmt, opts);
|
|
38725
38726
|
} else {
|
|
38726
|
-
emitChunkMapped(
|
|
38727
|
+
emitChunkMapped(g4, source, stmt.start, stmt.end);
|
|
38727
38728
|
}
|
|
38728
38729
|
pos = stmt.end;
|
|
38729
38730
|
}
|
|
38730
|
-
emitChunkMapped(
|
|
38731
|
+
emitChunkMapped(g4, source, pos, coreEnd);
|
|
38731
38732
|
}
|
|
38732
|
-
function emitRestMapped(
|
|
38733
|
+
function emitRestMapped(g4, text, base, end) {
|
|
38733
38734
|
let i = 0;
|
|
38734
38735
|
while (i < text.length && !isIdentStart(text[i])) i++;
|
|
38735
38736
|
if (i >= text.length) {
|
|
38736
|
-
|
|
38737
|
+
g4.add(text, base, end);
|
|
38737
38738
|
return;
|
|
38738
38739
|
}
|
|
38739
38740
|
let j = i + 1;
|
|
38740
38741
|
while (j < text.length && isIdentChar(text[j])) j++;
|
|
38741
|
-
|
|
38742
|
-
|
|
38743
|
-
|
|
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);
|
|
38744
38745
|
}
|
|
38745
|
-
function emitComponentHeader(
|
|
38746
|
+
function emitComponentHeader(g4, source, start, bodyStart) {
|
|
38746
38747
|
const h = source.slice(start, bodyStart);
|
|
38747
38748
|
const k = findFirstKeyword(h, "component");
|
|
38748
38749
|
if (k === -1) {
|
|
38749
38750
|
const { text, end: end2 } = stripTrailingClientRange(h);
|
|
38750
38751
|
if (!text.includes("(")) {
|
|
38751
38752
|
const trimmed = text.trimEnd();
|
|
38752
|
-
|
|
38753
|
-
|
|
38753
|
+
g4.add(trimmed, start, start + end2 - (text.length - trimmed.length));
|
|
38754
|
+
g4.addRaw("() ");
|
|
38754
38755
|
} else {
|
|
38755
|
-
|
|
38756
|
+
g4.add(text, start, start + end2);
|
|
38756
38757
|
}
|
|
38757
38758
|
return;
|
|
38758
38759
|
}
|
|
38759
|
-
|
|
38760
|
-
|
|
38760
|
+
g4.add(h.slice(0, k), start, start + k);
|
|
38761
|
+
g4.add("function", start + k, start + k + "component".length);
|
|
38761
38762
|
const restBase = start + k + "component".length;
|
|
38762
38763
|
const { text: rest, end } = stripTrailingClientRange(h.slice(k + "component".length));
|
|
38763
38764
|
const transformed = h.slice(0, k) + "function" + rest;
|
|
38764
38765
|
if (!transformed.includes("(")) {
|
|
38765
38766
|
const trimmed = rest.trimEnd();
|
|
38766
|
-
emitRestMapped(
|
|
38767
|
-
|
|
38767
|
+
emitRestMapped(g4, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
|
|
38768
|
+
g4.addRaw("() ");
|
|
38768
38769
|
} else {
|
|
38769
|
-
emitRestMapped(
|
|
38770
|
+
emitRestMapped(g4, rest, restBase, restBase + end);
|
|
38770
38771
|
}
|
|
38771
38772
|
}
|
|
38772
|
-
function emitComponent(
|
|
38773
|
+
function emitComponent(g4, source, node, start, opts) {
|
|
38773
38774
|
const body = node.body;
|
|
38774
38775
|
if (!body || body.start == null || body.end == null) return;
|
|
38775
|
-
emitComponentHeader(
|
|
38776
|
+
emitComponentHeader(g4, source, start, body.start);
|
|
38776
38777
|
const statementMode = isStatementMode2(node);
|
|
38777
38778
|
const stmts = body.body ?? [];
|
|
38778
38779
|
if (statementMode) {
|
|
38779
|
-
|
|
38780
|
-
emitBodyCore(
|
|
38781
|
-
|
|
38780
|
+
g4.addRaw("{ ");
|
|
38781
|
+
emitBodyCore(g4, source, stmts, opts);
|
|
38782
|
+
g4.addRaw(" }");
|
|
38782
38783
|
} else {
|
|
38783
38784
|
const raw2 = source.slice(body.start, body.end);
|
|
38784
38785
|
const rawLen = raw2.length;
|
|
@@ -38798,9 +38799,9 @@ function emitComponent(g2, source, node, start, opts) {
|
|
|
38798
38799
|
}
|
|
38799
38800
|
while (coreStart < coreEnd && isWhitespaceChar(source[coreStart])) coreStart++;
|
|
38800
38801
|
while (coreEnd > coreStart && isWhitespaceChar(source[coreEnd - 1])) coreEnd--;
|
|
38801
|
-
if (hasBraces)
|
|
38802
|
-
emitExpressionBody(
|
|
38803
|
-
if (hasBraces)
|
|
38802
|
+
if (hasBraces) g4.addRaw("{ ");
|
|
38803
|
+
emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts);
|
|
38804
|
+
if (hasBraces) g4.addRaw(" }");
|
|
38804
38805
|
}
|
|
38805
38806
|
}
|
|
38806
38807
|
function isModuleAst(ast) {
|
|
@@ -38830,26 +38831,26 @@ function compileVskCodegen(source, opts = {}) {
|
|
|
38830
38831
|
};
|
|
38831
38832
|
}
|
|
38832
38833
|
const clean = blankForClauses(source, ast);
|
|
38833
|
-
const
|
|
38834
|
+
const g4 = new VskGen();
|
|
38834
38835
|
const components = getComponents(ast).sort((a, b) => a.start - b.start);
|
|
38835
38836
|
let pos = 0;
|
|
38836
38837
|
for (const { node, start } of components) {
|
|
38837
38838
|
const body = node.body;
|
|
38838
38839
|
if (!body || body.start == null || body.end == null) continue;
|
|
38839
|
-
|
|
38840
|
-
emitComponent(
|
|
38840
|
+
g4.add(clean.slice(pos, start), pos, start);
|
|
38841
|
+
emitComponent(g4, clean, node, start, opts);
|
|
38841
38842
|
pos = body.end;
|
|
38842
38843
|
}
|
|
38843
|
-
|
|
38844
|
-
let code =
|
|
38844
|
+
g4.add(clean.slice(pos), pos, source.length);
|
|
38845
|
+
let code = g4.code;
|
|
38845
38846
|
if (isModuleAst(ast) && containsIdentifier(code, "Head") && !isIdentifierImported(code, "Head")) {
|
|
38846
|
-
|
|
38847
|
-
code =
|
|
38847
|
+
g4.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
|
|
38848
|
+
code = g4.code;
|
|
38848
38849
|
}
|
|
38849
38850
|
if (!isModuleAst(ast)) {
|
|
38850
38851
|
code += "\nexport {};\n";
|
|
38851
38852
|
}
|
|
38852
|
-
return { code, mappings:
|
|
38853
|
+
return { code, mappings: g4.mappings, styleRegions: g4.styleRegions, errors: [] };
|
|
38853
38854
|
}
|
|
38854
38855
|
function isTypeDecl(stmt) {
|
|
38855
38856
|
return stmt.type === "TSInterfaceDeclaration" || stmt.type === "TSTypeAliasDeclaration" || stmt.type === "ExportNamedDeclaration" && (stmt.declaration?.type === "TSInterfaceDeclaration" || stmt.declaration?.type === "TSTypeAliasDeclaration");
|
|
@@ -40462,7 +40463,7 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40462
40463
|
const runtimeRoot = findRuntimeSrc(appDir);
|
|
40463
40464
|
const entryFile = resolve3(outDir, "server", `.runtime-entry-${buildId++}.mjs`);
|
|
40464
40465
|
const entryContent = [
|
|
40465
|
-
`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"))};`,
|
|
40466
40467
|
`import { parseCookies } from ${JSON.stringify(resolve3(compilerRoot, "server-cookies.js"))};`,
|
|
40467
40468
|
`import * as __veskRuntime from ${JSON.stringify(resolve3(runtimeRoot, "index-server.js"))};`,
|
|
40468
40469
|
"",
|
|
@@ -40501,7 +40502,7 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40501
40502
|
"}",
|
|
40502
40503
|
"",
|
|
40503
40504
|
"export { renderPage, renderFullPage, renderPageStream, compileFile, setVskHydrate, hydratePrecompile, parseCookies, assertSameOrigin };",
|
|
40504
|
-
|
|
40505
|
+
"export { withSsrStore };",
|
|
40505
40506
|
"",
|
|
40506
40507
|
"// Deliver hydration data as an origin-served script so strict CSP (no unsafe-inline)",
|
|
40507
40508
|
"// does not block it. The prod server serves /ssr-data.js from the global store.",
|
|
@@ -40513,7 +40514,11 @@ async function bundleRuntime(appDir, outDir) {
|
|
|
40513
40514
|
" let tk = '';",
|
|
40514
40515
|
" for (const b of bytes) tk += b.toString(16).padStart(2, '0');",
|
|
40515
40516
|
" const token = tk;",
|
|
40516
|
-
"
|
|
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 ||= {});",
|
|
40517
40522
|
" store[token] = payload;",
|
|
40518
40523
|
" // Bound the store: if the browser never fetches /ssr-data.js the entry",
|
|
40519
40524
|
" // would otherwise linger forever. Evict the oldest entry past 100.",
|
|
@@ -40737,6 +40742,7 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
|
|
|
40737
40742
|
|
|
40738
40743
|
// ../compiler/src/server-codegen.ts
|
|
40739
40744
|
init_server_render();
|
|
40745
|
+
init_ssr_store();
|
|
40740
40746
|
|
|
40741
40747
|
// ../adapter/src/css.ts
|
|
40742
40748
|
import { readFileSync as readFileSync6, existsSync as existsSync7 } from "node:fs";
|
|
@@ -42019,11 +42025,11 @@ var ChunkImports = class {
|
|
|
42019
42025
|
const lines = [];
|
|
42020
42026
|
const sources = [...this.bySource.keys()].sort();
|
|
42021
42027
|
for (const src2 of sources) {
|
|
42022
|
-
const
|
|
42028
|
+
const g4 = this.bySource.get(src2);
|
|
42023
42029
|
const parts = [];
|
|
42024
|
-
if (
|
|
42025
|
-
if (
|
|
42026
|
-
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);
|
|
42027
42033
|
if (named.length > 0) {
|
|
42028
42034
|
const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
|
|
42029
42035
|
parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
|
|
@@ -43070,7 +43076,7 @@ async function startProdServer(outDir, options) {
|
|
|
43070
43076
|
}
|
|
43071
43077
|
if (url.pathname === "/ssr-data.js") {
|
|
43072
43078
|
const token = url.searchParams.get("t") || "";
|
|
43073
|
-
const store = globalThis.
|
|
43079
|
+
const store = globalThis.__vsk_ssr_payload_store;
|
|
43074
43080
|
const payload = store?.[token];
|
|
43075
43081
|
if (payload) delete store[token];
|
|
43076
43082
|
const lines = [];
|
|
@@ -43885,13 +43891,23 @@ init_server_utils();
|
|
|
43885
43891
|
init_server_head();
|
|
43886
43892
|
init_server_jsgen();
|
|
43887
43893
|
init_server_render();
|
|
43894
|
+
init_ssr_store();
|
|
43888
43895
|
|
|
43889
43896
|
// ../compiler/dist/ssr-store.js
|
|
43890
43897
|
init_index_server();
|
|
43891
43898
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
43892
43899
|
var TOKEN_KEY2 = "__vsk_ssr_token";
|
|
43893
|
-
var
|
|
43894
|
-
var
|
|
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;
|
|
43895
43911
|
function newSsrToken2() {
|
|
43896
43912
|
return Math.random().toString(36).slice(2);
|
|
43897
43913
|
}
|
|
@@ -43929,7 +43945,7 @@ function withSsrStore2(fn) {
|
|
|
43929
43945
|
function withSsrStoreOf2(store, fn) {
|
|
43930
43946
|
return storage2.run(store, fn);
|
|
43931
43947
|
}
|
|
43932
|
-
function
|
|
43948
|
+
function resetSsrToken2() {
|
|
43933
43949
|
const store = storage2.getStore();
|
|
43934
43950
|
const token = newSsrToken2();
|
|
43935
43951
|
if (store) {
|
|
@@ -43976,17 +43992,19 @@ var ssrSink3 = {
|
|
|
43976
43992
|
}
|
|
43977
43993
|
};
|
|
43978
43994
|
setSsrSink(ssrSink3);
|
|
43979
|
-
|
|
43980
|
-
|
|
43981
|
-
|
|
43982
|
-
|
|
43983
|
-
|
|
43984
|
-
|
|
43985
|
-
|
|
43986
|
-
|
|
43987
|
-
store
|
|
43988
|
-
|
|
43989
|
-
}
|
|
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
|
+
}
|
|
43990
44008
|
|
|
43991
44009
|
// ../compiler/dist/client-codegen.js
|
|
43992
44010
|
init_ir();
|
|
@@ -47793,13 +47811,13 @@ var ChunkImports2 = class {
|
|
|
47793
47811
|
const lines = [];
|
|
47794
47812
|
const sources = [...this.bySource.keys()].sort();
|
|
47795
47813
|
for (const src2 of sources) {
|
|
47796
|
-
const
|
|
47814
|
+
const g4 = this.bySource.get(src2);
|
|
47797
47815
|
const parts = [];
|
|
47798
|
-
if (
|
|
47799
|
-
parts.push(`import ${
|
|
47800
|
-
if (
|
|
47801
|
-
parts.push(`import * as ${
|
|
47802
|
-
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);
|
|
47803
47821
|
if (named.length > 0) {
|
|
47804
47822
|
const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
|
|
47805
47823
|
parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
|
|
@@ -54243,10 +54261,10 @@ function parseCookies3(str3) {
|
|
|
54243
54261
|
// ../runtime/dist/action.js
|
|
54244
54262
|
var registryKey2 = "__vesk_actions";
|
|
54245
54263
|
function getActionRegistry2() {
|
|
54246
|
-
const
|
|
54247
|
-
if (!
|
|
54248
|
-
|
|
54249
|
-
return
|
|
54264
|
+
const g4 = globalThis;
|
|
54265
|
+
if (!g4[registryKey2])
|
|
54266
|
+
g4[registryKey2] = {};
|
|
54267
|
+
return g4[registryKey2];
|
|
54250
54268
|
}
|
|
54251
54269
|
function getAction2(id) {
|
|
54252
54270
|
return getActionRegistry2()[id] || null;
|
|
@@ -54902,9 +54920,9 @@ function storeDataScript(payload) {
|
|
|
54902
54920
|
return "/_vesk/ssr-data.js?t=" + token;
|
|
54903
54921
|
}
|
|
54904
54922
|
function currentSsrData() {
|
|
54905
|
-
const
|
|
54906
|
-
const token =
|
|
54907
|
-
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) || {};
|
|
54908
54926
|
return { ...ssrSink3.snapshot() || {}, ...slot };
|
|
54909
54927
|
}
|
|
54910
54928
|
function countPages(nodes) {
|
|
@@ -54997,9 +55015,9 @@ async function startDevServer(port, projectDir, config, host) {
|
|
|
54997
55015
|
}
|
|
54998
55016
|
}
|
|
54999
55017
|
function eventsStore() {
|
|
55000
|
-
const
|
|
55001
|
-
if (!
|
|
55002
|
-
return
|
|
55018
|
+
const g4 = globalThis;
|
|
55019
|
+
if (!g4.__vesk_server_ctx) g4.__vesk_server_ctx = {};
|
|
55020
|
+
return g4.__vesk_server_ctx;
|
|
55003
55021
|
}
|
|
55004
55022
|
function makeEventCtx(overrides) {
|
|
55005
55023
|
const store = eventsStore();
|
|
@@ -55860,7 +55878,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
55860
55878
|
let freshToken;
|
|
55861
55879
|
try {
|
|
55862
55880
|
return await withSsrStore2(async () => {
|
|
55863
|
-
freshToken =
|
|
55881
|
+
freshToken = resetSsrToken2();
|
|
55864
55882
|
const chain = cleanChain;
|
|
55865
55883
|
let body = "";
|
|
55866
55884
|
let head = "";
|