@vesk/vesk-cli 0.2.65 → 0.2.67

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.
Files changed (2) hide show
  1. package/dist/cli.js +680 -582
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1177,10 +1177,10 @@ function run_block(block2) {
1177
1177
  const res = block2.fn(block2.s);
1178
1178
  if (typeof res === "function") {
1179
1179
  block2.t = res;
1180
- let current2 = block2;
1181
- while (current2 !== null && (current2.f & CONTAINS_TEARDOWN) === 0) {
1182
- current2.f ^= CONTAINS_TEARDOWN;
1183
- current2 = current2.p;
1180
+ let current3 = block2;
1181
+ while (current3 !== null && (current3.f & CONTAINS_TEARDOWN) === 0) {
1182
+ current3.f ^= CONTAINS_TEARDOWN;
1183
+ current3 = current3.p;
1184
1184
  }
1185
1185
  }
1186
1186
  block2.d = active_dependency;
@@ -1227,13 +1227,13 @@ function create_dependency(tracked2) {
1227
1227
  if (is_orphan(tracked2.b)) {
1228
1228
  (tracked2.r ??= /* @__PURE__ */ new Set()).add(reaction);
1229
1229
  }
1230
- const existing = reaction.d;
1231
- if (existing !== null) {
1232
- reaction.d = existing.n;
1233
- existing.c = tracked2.c;
1234
- existing.t = tracked2;
1235
- existing.n = null;
1236
- return existing;
1230
+ const existing2 = reaction.d;
1231
+ if (existing2 !== null) {
1232
+ reaction.d = existing2.n;
1233
+ existing2.c = tracked2.c;
1234
+ existing2.t = tracked2;
1235
+ existing2.n = null;
1236
+ return existing2;
1237
1237
  }
1238
1238
  return {
1239
1239
  c: tracked2.c,
@@ -1276,44 +1276,44 @@ function is_block_dirty(block2) {
1276
1276
  return is_tracking_dirty(block2.d);
1277
1277
  }
1278
1278
  function flush_updates(root_block) {
1279
- let current2 = root_block;
1279
+ let current3 = root_block;
1280
1280
  const pre_effects = [];
1281
1281
  const other_blocks = [];
1282
1282
  const effects = [];
1283
1283
  let scope_root = disable_scoped_flush ? root_block : null;
1284
- while (current2 !== null) {
1285
- const flags = current2.f;
1284
+ while (current3 !== null) {
1285
+ const flags = current3.f;
1286
1286
  const on_path = (flags & CONTAINS_UPDATE) !== 0;
1287
1287
  if (on_path) {
1288
- current2.f ^= CONTAINS_UPDATE;
1288
+ current3.f ^= CONTAINS_UPDATE;
1289
1289
  }
1290
1290
  if ((flags & UPDATE_SOURCE) !== 0) {
1291
- current2.f ^= UPDATE_SOURCE;
1291
+ current3.f ^= UPDATE_SOURCE;
1292
1292
  if (scope_root === null) {
1293
- scope_root = current2;
1293
+ scope_root = current3;
1294
1294
  }
1295
1295
  }
1296
1296
  if ((flags & PAUSED) === 0 && (on_path || scope_root !== null)) {
1297
1297
  if ((flags & PRE_EFFECT_BLOCK) !== 0) {
1298
- pre_effects.push(current2);
1298
+ pre_effects.push(current3);
1299
1299
  } else if ((flags & EFFECT_BLOCK) !== 0) {
1300
- effects.push(current2);
1300
+ effects.push(current3);
1301
1301
  } else {
1302
- other_blocks.push(current2);
1302
+ other_blocks.push(current3);
1303
1303
  }
1304
- const child = current2.first;
1304
+ const child = current3.first;
1305
1305
  if (child !== null) {
1306
- current2 = child;
1306
+ current3 = child;
1307
1307
  continue;
1308
1308
  }
1309
1309
  }
1310
- let parent = current2.p;
1311
- current2 = current2.next;
1312
- while (current2 === null && parent !== null) {
1310
+ let parent = current3.p;
1311
+ current3 = current3.next;
1312
+ while (current3 === null && parent !== null) {
1313
1313
  if (parent === scope_root) {
1314
1314
  scope_root = null;
1315
1315
  }
1316
- current2 = parent.next;
1316
+ current3 = parent.next;
1317
1317
  parent = parent.p;
1318
1318
  }
1319
1319
  }
@@ -1406,17 +1406,17 @@ function schedule_update(block2) {
1406
1406
  queue_microtask();
1407
1407
  }
1408
1408
  block2.f |= UPDATE_SOURCE;
1409
- let current2 = block2;
1410
- while (current2 !== null) {
1411
- const flags = current2.f;
1409
+ let current3 = block2;
1410
+ while (current3 !== null) {
1411
+ const flags = current3.f;
1412
1412
  if ((flags & CONTAINS_UPDATE) !== 0) return;
1413
- current2.f ^= CONTAINS_UPDATE;
1413
+ current3.f ^= CONTAINS_UPDATE;
1414
1414
  if ((flags & ROOT_BLOCK) !== 0) {
1415
1415
  break;
1416
1416
  }
1417
- current2 = current2.p;
1417
+ current3 = current3.p;
1418
1418
  }
1419
- queued_root_blocks.push(current2);
1419
+ queued_root_blocks.push(current3);
1420
1420
  }
1421
1421
  function register_dependency(tracked2) {
1422
1422
  if (!disable_scoped_flush && active_block !== null && active_block !== tracked2.b) {
@@ -1445,20 +1445,20 @@ function register_dependency(tracked2) {
1445
1445
  dependency = create_dependency(tracked2);
1446
1446
  active_dependency = dependency;
1447
1447
  } else {
1448
- let current2 = dependency;
1449
- while (current2 !== null) {
1450
- if (current2.t === tracked2) {
1451
- current2.c = tracked2.c;
1448
+ let current3 = dependency;
1449
+ while (current3 !== null) {
1450
+ if (current3.t === tracked2) {
1451
+ current3.c = tracked2.c;
1452
1452
  return;
1453
1453
  }
1454
- const next = current2.n;
1454
+ const next = current3.n;
1455
1455
  if (next === null) {
1456
1456
  break;
1457
1457
  }
1458
- current2 = next;
1458
+ current3 = next;
1459
1459
  }
1460
1460
  dependency = create_dependency(tracked2);
1461
- current2.n = dependency;
1461
+ current3.n = dependency;
1462
1462
  }
1463
1463
  }
1464
1464
  function unsubscribe_reaction(reaction) {
@@ -1837,10 +1837,10 @@ var init_context = __esm({
1837
1837
  * way to every reader.
1838
1838
  */
1839
1839
  get() {
1840
- let current2 = getActiveComponent();
1841
- while (current2) {
1842
- if (current2.c?.has(this)) return current2.c.get(this);
1843
- current2 = current2.p;
1840
+ let current3 = getActiveComponent();
1841
+ while (current3) {
1842
+ if (current3.c?.has(this)) return current3.c.get(this);
1843
+ current3 = current3.p;
1844
1844
  }
1845
1845
  return this._v;
1846
1846
  }
@@ -1858,11 +1858,11 @@ var init_context = __esm({
1858
1858
 
1859
1859
  // ../runtime/src/server-events.ts
1860
1860
  function getStore() {
1861
- const g4 = globalThis;
1862
- if (!g4.__vesk_server_ctx || typeof g4.__vesk_server_ctx !== "object") {
1863
- g4.__vesk_server_ctx = {};
1861
+ const g5 = globalThis;
1862
+ if (!g5.__vesk_server_ctx || typeof g5.__vesk_server_ctx !== "object") {
1863
+ g5.__vesk_server_ctx = {};
1864
1864
  }
1865
- return g4.__vesk_server_ctx;
1865
+ return g5.__vesk_server_ctx;
1866
1866
  }
1867
1867
  function server_locals() {
1868
1868
  return getStore();
@@ -2126,8 +2126,8 @@ function streamText(res, into, onChunk) {
2126
2126
  function settle(handle2, data2) {
2127
2127
  if (handle2.block !== null && is_destroyed(handle2.block)) return;
2128
2128
  if (handle2.into) setInto(handle2.into, data2);
2129
- const current2 = get(handle2.state);
2130
- if (!(current2.data === data2 && !current2.loading && current2.error === null)) {
2129
+ const current3 = get(handle2.state);
2130
+ if (!(current3.data === data2 && !current3.loading && current3.error === null)) {
2131
2131
  set(handle2.state, { loading: false, error: null, data: data2 });
2132
2132
  }
2133
2133
  handle2.settleNotify();
@@ -2136,22 +2136,22 @@ function settleError(handle2, error) {
2136
2136
  if (handle2.block !== null && is_destroyed(handle2.block)) return;
2137
2137
  if (isAbortError(error)) {
2138
2138
  if (handle2.controller !== null) return;
2139
- const current3 = get(handle2.state);
2140
- if (current3.loading) set(handle2.state, { loading: false, error: null, data: current3.data });
2139
+ const current4 = get(handle2.state);
2140
+ if (current4.loading) set(handle2.state, { loading: false, error: null, data: current4.data });
2141
2141
  handle2.settleNotify();
2142
2142
  return;
2143
2143
  }
2144
- const current2 = get(handle2.state);
2145
- set(handle2.state, { loading: false, error, data: current2.data });
2144
+ const current3 = get(handle2.state);
2145
+ set(handle2.state, { loading: false, error, data: current3.data });
2146
2146
  handle2.settleNotify();
2147
2147
  }
2148
2148
  function markRefetching(handle2) {
2149
- const current2 = get(handle2.state);
2150
- if (current2.loading) return;
2149
+ const current3 = get(handle2.state);
2150
+ if (current3.loading) return;
2151
2151
  set(handle2.state, {
2152
2152
  loading: true,
2153
2153
  error: null,
2154
- data: handle2.options.keepPreviousData ? current2.data : void 0
2154
+ data: handle2.options.keepPreviousData ? current3.data : void 0
2155
2155
  });
2156
2156
  }
2157
2157
  function attachSettle(handle2, promise) {
@@ -2217,10 +2217,10 @@ function startRequest(handle2, skipCache) {
2217
2217
  });
2218
2218
  return settled;
2219
2219
  }
2220
- const existing = getInflight().get(key);
2220
+ const existing2 = getInflight().get(key);
2221
2221
  const startToken = g().__vsk_ssr_token || void 0;
2222
- const prom2 = existing ?? runFetcher(handle2, options.timeout || 0);
2223
- if (!existing) {
2222
+ const prom2 = existing2 ?? runFetcher(handle2, options.timeout || 0);
2223
+ if (!existing2) {
2224
2224
  getInflight().set(key, prom2);
2225
2225
  prom2.then(
2226
2226
  (data2) => {
@@ -2252,10 +2252,10 @@ function startRequest(handle2, skipCache) {
2252
2252
  }
2253
2253
  }
2254
2254
  if (options.dedupe !== false) {
2255
- const existing = getInflight().get(key);
2256
- if (existing) {
2257
- attachSettle(handle2, existing);
2258
- return existing;
2255
+ const existing2 = getInflight().get(key);
2256
+ if (existing2) {
2257
+ attachSettle(handle2, existing2);
2258
+ return existing2;
2259
2259
  }
2260
2260
  }
2261
2261
  markRefetching(handle2);
@@ -2398,8 +2398,8 @@ function createResource(fn, key, into, options = {}) {
2398
2398
  on_destroy(() => {
2399
2399
  if (is_destroyed(handle2.block)) {
2400
2400
  handle2.controller?.abort();
2401
- const current2 = getRegistry().get(resourceKey);
2402
- if (current2) current2.delete(handle2);
2401
+ const current3 = getRegistry().get(resourceKey);
2402
+ if (current3) current3.delete(handle2);
2403
2403
  }
2404
2404
  });
2405
2405
  }
@@ -2860,9 +2860,9 @@ function createHydrateWalker(container, markerList) {
2860
2860
  }
2861
2861
  function bumpNavEpoch() {
2862
2862
  try {
2863
- const g4 = globalThis;
2864
- const next = (g4.__vesk_nav_epoch || 0) + 1;
2865
- g4.__vesk_nav_epoch = next;
2863
+ const g5 = globalThis;
2864
+ const next = (g5.__vesk_nav_epoch || 0) + 1;
2865
+ g5.__vesk_nav_epoch = next;
2866
2866
  return next;
2867
2867
  } catch {
2868
2868
  return 0;
@@ -4009,8 +4009,8 @@ function LoadingIndicator(props = {}, _registry, hydrate) {
4009
4009
  if (hydrate && typeof hydrate.nextElement === "function") {
4010
4010
  el = hydrate.nextElement("div");
4011
4011
  if (el && !el.parentNode && hydrate.root) {
4012
- const existing = hydrate.root.querySelector(`[${INDICATOR_ATTR}]`);
4013
- if (existing) el = existing;
4012
+ const existing2 = hydrate.root.querySelector(`[${INDICATOR_ATTR}]`);
4013
+ if (existing2) el = existing2;
4014
4014
  }
4015
4015
  } else {
4016
4016
  el = document.createElement("div");
@@ -4330,8 +4330,8 @@ function NavLink(props, registry, hydrate) {
4330
4330
  if (hydrate && hydrate.nextElement) {
4331
4331
  let a2 = hydrate.nextElement("a");
4332
4332
  if (a2 && !a2.parentNode && hydrate.root) {
4333
- const existing = hydrate.root.querySelector("a");
4334
- if (existing) a2 = existing;
4333
+ const existing2 = hydrate.root.querySelector("a");
4334
+ if (existing2) a2 = existing2;
4335
4335
  }
4336
4336
  const claimed = a2 ? a2.parentNode !== null : false;
4337
4337
  if (!a2) a2 = document.createElement("a");
@@ -4779,8 +4779,8 @@ async function fetchRouteData(path) {
4779
4779
  }
4780
4780
  function getRouteData(path, scope2) {
4781
4781
  const key = scope2 === void 0 ? path : path + "\0" + scope2;
4782
- const existing = _dataPromises.get(key);
4783
- if (existing) return existing;
4782
+ const existing2 = _dataPromises.get(key);
4783
+ if (existing2) return existing2;
4784
4784
  const p = fetchRouteData(path).finally(() => {
4785
4785
  _dataPromises.delete(key);
4786
4786
  });
@@ -5604,8 +5604,8 @@ function createRouter(routes, options = {}) {
5604
5604
  },
5605
5605
  _runGuards(to) {
5606
5606
  const from = get(_state.path) || window.location.pathname;
5607
- for (const g4 of this._beforeGuards ?? []) {
5608
- const d = g4(to, from);
5607
+ for (const g5 of this._beforeGuards ?? []) {
5608
+ const d = g5(to, from);
5609
5609
  if (d instanceof Promise) {
5610
5610
  return d.then((r) => {
5611
5611
  if (r === false || typeof r === "string") return r;
@@ -5931,8 +5931,8 @@ function createFileRouter(routeTree, options = {}) {
5931
5931
  },
5932
5932
  _runGuards(to) {
5933
5933
  const from = get(_state.path) || window.location.pathname;
5934
- for (const g4 of this._beforeGuards ?? []) {
5935
- const d = g4(to, from);
5934
+ for (const g5 of this._beforeGuards ?? []) {
5935
+ const d = g5(to, from);
5936
5936
  if (d instanceof Promise) {
5937
5937
  return d.then((r) => {
5938
5938
  if (r === false || typeof r === "string") return r;
@@ -6377,6 +6377,58 @@ var init_router = __esm({
6377
6377
  }
6378
6378
  });
6379
6379
 
6380
+ // ../runtime/src/security-overrides.ts
6381
+ function resolveAls() {
6382
+ try {
6383
+ const proc = g2.process;
6384
+ const mod = proc?.getBuiltinModule?.("async_hooks");
6385
+ const ctor = mod?.AsyncLocalStorage;
6386
+ return ctor ? new ctor() : null;
6387
+ } catch {
6388
+ return null;
6389
+ }
6390
+ }
6391
+ function current() {
6392
+ if (als) return als.getStore() ?? null;
6393
+ return fallbackStore;
6394
+ }
6395
+ function runWithSecurityOverrides(fn) {
6396
+ const bag = {};
6397
+ if (als) return als.run(bag, fn);
6398
+ const prev = fallbackStore;
6399
+ fallbackStore = bag;
6400
+ try {
6401
+ return fn();
6402
+ } finally {
6403
+ fallbackStore = prev;
6404
+ }
6405
+ }
6406
+ function setSecurityOverride(key, value) {
6407
+ const bag = current();
6408
+ if (bag) bag[key] = value;
6409
+ }
6410
+ function getSecurityOverrides() {
6411
+ const bag = current();
6412
+ if (!bag) return null;
6413
+ return Object.keys(bag).length > 0 ? bag : null;
6414
+ }
6415
+ var g2, als, fallbackStore, bridge, existing;
6416
+ var init_security_overrides = __esm({
6417
+ "../runtime/src/security-overrides.ts"() {
6418
+ "use strict";
6419
+ g2 = globalThis;
6420
+ als = resolveAls();
6421
+ fallbackStore = null;
6422
+ bridge = {
6423
+ run: runWithSecurityOverrides,
6424
+ get: getSecurityOverrides,
6425
+ set: setSecurityOverride
6426
+ };
6427
+ existing = g2.__vesk_security || {};
6428
+ g2.__vesk_security = { ...existing, ...bridge };
6429
+ }
6430
+ });
6431
+
6380
6432
  // ../../node_modules/acorn/dist/acorn.mjs
6381
6433
  var acorn_exports = {};
6382
6434
  __export(acorn_exports, {
@@ -10098,7 +10150,7 @@ var init_acorn = __esm({
10098
10150
  }
10099
10151
  return i + 2;
10100
10152
  };
10101
- RegExpValidationState.prototype.current = function current(forceU) {
10153
+ RegExpValidationState.prototype.current = function current2(forceU) {
10102
10154
  if (forceU === void 0) forceU = false;
10103
10155
  return this.at(this.pos, forceU);
10104
10156
  };
@@ -10123,8 +10175,8 @@ var init_acorn = __esm({
10123
10175
  var pos = this.pos;
10124
10176
  for (var i = 0, list = chs; i < list.length; i += 1) {
10125
10177
  var ch = list[i];
10126
- var current2 = this.at(pos, forceU);
10127
- if (current2 === -1 || current2 !== ch) {
10178
+ var current3 = this.at(pos, forceU);
10179
+ if (current3 === -1 || current3 !== ch) {
10128
10180
  return false;
10129
10181
  }
10130
10182
  pos = this.nextIndex(pos, forceU);
@@ -20367,8 +20419,8 @@ function collectModuleSpecifiers(ast) {
20367
20419
  return specs;
20368
20420
  }
20369
20421
  function collectModuleBundled(absPath, collector) {
20370
- const existing = collector.keysByAbs.get(absPath);
20371
- if (existing) return existing;
20422
+ const existing2 = collector.keysByAbs.get(absPath);
20423
+ if (existing2) return existing2;
20372
20424
  const key = `__veskMod${collector.keysByAbs.size}`;
20373
20425
  collector.keysByAbs.set(absPath, key);
20374
20426
  const dir = dirname2(absPath);
@@ -22417,16 +22469,16 @@ function generateIR(ast, source, filename) {
22417
22469
  if (called.has(fn)) usedFunctions.add(fn);
22418
22470
  }
22419
22471
  if (usedFunctions.size > 0) {
22420
- const existing = /* @__PURE__ */ new Set();
22472
+ const existing2 = /* @__PURE__ */ new Set();
22421
22473
  for (const imp of imports) {
22422
22474
  if (importModuleTarget(imp) !== "@vesk/runtime") continue;
22423
- for (const n of extractImportNames(imp)) existing.add(n);
22475
+ for (const n of extractImportNames(imp)) existing2.add(n);
22424
22476
  }
22425
22477
  const boundLocally = /* @__PURE__ */ new Set();
22426
22478
  for (const imp of imports) {
22427
22479
  for (const pair of importBindingPairs(imp)) boundLocally.add(pair.local);
22428
22480
  }
22429
- const missing = [...usedFunctions].filter((f) => !existing.has(f) && !boundLocally.has(f));
22481
+ const missing = [...usedFunctions].filter((f) => !existing2.has(f) && !boundLocally.has(f));
22430
22482
  if (missing.length > 0) {
22431
22483
  imports.push(`import { ${missing.join(", ")} } from '@vesk/runtime';`);
22432
22484
  }
@@ -22836,16 +22888,16 @@ function sha256Bytes(msg) {
22836
22888
  const s1 = rr(w[j - 2], 17) ^ rr(w[j - 2], 19) ^ w[j - 2] >>> 10;
22837
22889
  w[j] = w[j - 16] + s0 + w[j - 7] + s1 >>> 0;
22838
22890
  }
22839
- let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g4 = h6, h = h7;
22891
+ let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g5 = h6, h = h7;
22840
22892
  for (let j = 0; j < 64; j++) {
22841
22893
  const S1 = rr(e, 6) ^ rr(e, 11) ^ rr(e, 25);
22842
- const ch = e & f ^ ~e & g4;
22894
+ const ch = e & f ^ ~e & g5;
22843
22895
  const t1 = h + S1 + ch + SHA_K[j] + w[j] >>> 0;
22844
22896
  const S0 = rr(a, 2) ^ rr(a, 13) ^ rr(a, 22);
22845
22897
  const maj = a & b ^ a & c ^ b & c;
22846
22898
  const t2 = S0 + maj >>> 0;
22847
- h = g4;
22848
- g4 = f;
22899
+ h = g5;
22900
+ g5 = f;
22849
22901
  f = e;
22850
22902
  e = d + t1 >>> 0;
22851
22903
  d = c;
@@ -22859,7 +22911,7 @@ function sha256Bytes(msg) {
22859
22911
  h3 = h3 + d >>> 0;
22860
22912
  h4 = h4 + e >>> 0;
22861
22913
  h5 = h5 + f >>> 0;
22862
- h6 = h6 + g4 >>> 0;
22914
+ h6 = h6 + g5 >>> 0;
22863
22915
  h7 = h7 + h >>> 0;
22864
22916
  }
22865
22917
  const out = new Uint8Array(32);
@@ -23882,7 +23934,7 @@ function headers() {
23882
23934
  }
23883
23935
  function applyRequestSecurity(request, response) {
23884
23936
  if (!request || !response) return;
23885
- const overrides = request.getSecurityOverrides?.() || {};
23937
+ const overrides = getSecurityOverrides() || request.getSecurityOverrides?.() || {};
23886
23938
  if (overrides.contentSecurityPolicy !== void 0) {
23887
23939
  response.setCsp(overrides.contentSecurityPolicy);
23888
23940
  }
@@ -23962,6 +24014,7 @@ var ServerRequest, ServerResponse, DEFAULT_MAX_BODY_BYTES2, PayloadTooLargeError
23962
24014
  var init_request = __esm({
23963
24015
  "../runtime/src/request.ts"() {
23964
24016
  "use strict";
24017
+ init_security_overrides();
23965
24018
  ServerRequest = class extends Request {
23966
24019
  _cookies;
23967
24020
  _params;
@@ -24203,19 +24256,25 @@ var init_request = __esm({
24203
24256
  }
24204
24257
  setCsp(policy) {
24205
24258
  this._security.contentSecurityPolicy = policy;
24259
+ setSecurityOverride("contentSecurityPolicy", policy);
24206
24260
  }
24207
24261
  setRateLimit(options) {
24208
24262
  this._security.rateLimit = options;
24263
+ setSecurityOverride("rateLimit", options);
24209
24264
  }
24210
24265
  setCsrf(enable) {
24211
24266
  this._security.csrf = enable;
24267
+ setSecurityOverride("csrf", enable);
24212
24268
  }
24213
24269
  setSecurityHeader(name, value) {
24214
24270
  if (!this._security.customHeaders) this._security.customHeaders = {};
24215
24271
  this._security.customHeaders[name] = value;
24272
+ const existing2 = this._security.customHeaders;
24273
+ setSecurityOverride("customHeaders", { ...existing2 });
24216
24274
  }
24217
24275
  setTrustProxy(enable) {
24218
24276
  this._security.trustProxy = enable;
24277
+ setSecurityOverride("trustProxy", enable);
24219
24278
  }
24220
24279
  getSecurityOverrides() {
24221
24280
  return this._security;
@@ -24313,14 +24372,14 @@ var init_request = __esm({
24313
24372
  _flushSecurityHeaders() {
24314
24373
  for (const [name, value] of Object.entries(this._secHeaders)) {
24315
24374
  if (value === null) continue;
24316
- const existing = this.headers?.get(name);
24317
- if (!existing) this.headers?.set(name, value);
24375
+ const existing2 = this.headers?.get(name);
24376
+ if (!existing2) this.headers?.set(name, value);
24318
24377
  }
24319
24378
  this._secHeaders = {};
24320
24379
  if (this._cookieHeaders.length > 0) {
24321
- const existing = this.headers?.get("Set-Cookie");
24322
- if (existing) {
24323
- this.headers?.set("Set-Cookie", existing + ", " + this._cookieHeaders.join(", "));
24380
+ const existing2 = this.headers?.get("Set-Cookie");
24381
+ if (existing2) {
24382
+ this.headers?.set("Set-Cookie", existing2 + ", " + this._cookieHeaders.join(", "));
24324
24383
  } else {
24325
24384
  this.headers?.set("Set-Cookie", this._cookieHeaders.join(", "));
24326
24385
  }
@@ -24780,8 +24839,8 @@ function Experiment(props) {
24780
24839
  }
24781
24840
  if (track3 && assignedVariant && typeof window !== "undefined") {
24782
24841
  const w = window;
24783
- const existing = w.__vsk_experiments || (w.__vsk_experiments = []);
24784
- existing.push({ experiment: name, variant: assignedVariant.name || "default" });
24842
+ const existing2 = w.__vsk_experiments || (w.__vsk_experiments = []);
24843
+ existing2.push({ experiment: name, variant: assignedVariant.name || "default" });
24785
24844
  }
24786
24845
  return assignedVariant ? assignedVariant.children || assignedVariant.content || null : defaultContent;
24787
24846
  }
@@ -24855,8 +24914,8 @@ function Field(props, registry, hydrate) {
24855
24914
  if (hydrate && hydrate.nextElement) {
24856
24915
  let wrapper2 = hydrate.nextElement("div");
24857
24916
  if (wrapper2 && !wrapper2.parentNode && hydrate.root) {
24858
- const existing = hydrate.root.querySelector(`[data-vsk-field="${name}"]`);
24859
- if (existing) wrapper2 = existing;
24917
+ const existing2 = hydrate.root.querySelector(`[data-vsk-field="${name}"]`);
24918
+ if (existing2) wrapper2 = existing2;
24860
24919
  }
24861
24920
  const inner = wrapper2 ? wrapper2.querySelector(`[data-vsk-field="${name}"]`) : null;
24862
24921
  const fieldEl = inner || wrapper2;
@@ -24998,8 +25057,8 @@ function Form(props, registry, hydrate) {
24998
25057
  const skipK = typeof hydrate.takeSkipK === "function" ? hydrate.takeSkipK() : 0;
24999
25058
  let form2 = hydrate.nextElement("form", skipK);
25000
25059
  if (form2 && !form2.parentNode && hydrate.root) {
25001
- const existing = hydrate.root.querySelector("form");
25002
- if (existing) form2 = existing;
25060
+ const existing2 = hydrate.root.querySelector("form");
25061
+ if (existing2) form2 = existing2;
25003
25062
  }
25004
25063
  if (form2) {
25005
25064
  form2.noValidate = true;
@@ -26857,8 +26916,8 @@ function Md(props, _registry, hydrate) {
26857
26916
  if (hydrate && typeof hydrate.nextElement === "function") {
26858
26917
  let el = hydrate.nextElement("div");
26859
26918
  if (el && !el.parentNode && hydrate.root) {
26860
- const existing = hydrate.root.querySelector("div");
26861
- if (existing) el = existing;
26919
+ const existing2 = hydrate.root.querySelector("div");
26920
+ if (existing2) el = existing2;
26862
26921
  }
26863
26922
  const claimed = !!el.parentNode;
26864
26923
  if (pathMode && claimed) {
@@ -27428,18 +27487,18 @@ function rerenderNode(node, deps, call) {
27428
27487
  if (typeof document === "undefined") return node;
27429
27488
  if (deps.length === 0) return node;
27430
27489
  let owned = null;
27431
- let current2 = null;
27490
+ let current3 = null;
27432
27491
  if (Array.isArray(node)) {
27433
27492
  const roots = node.filter((n) => n && typeof n.nodeType === "number");
27434
27493
  owned = roots.length ? roots : null;
27435
- current2 = owned ? owned[0] : null;
27494
+ current3 = owned ? owned[0] : null;
27436
27495
  } else if (node && typeof node.nodeType === "number") {
27437
- current2 = node;
27496
+ current3 = node;
27438
27497
  }
27439
- if (!current2) return node;
27498
+ if (!current3) return node;
27440
27499
  const liveRange = () => {
27441
27500
  if (owned) return owned;
27442
- return current2 && current2.parentNode ? [current2] : null;
27501
+ return current3 && current3.parentNode ? [current3] : null;
27443
27502
  };
27444
27503
  let seen = deps.map(readDep);
27445
27504
  effect(() => {
@@ -27455,7 +27514,7 @@ function rerenderNode(node, deps, call) {
27455
27514
  for (const freshNode of fresh) parent.insertBefore(freshNode, old[0]);
27456
27515
  for (const oldNode of old) if (oldNode.parentNode) oldNode.parentNode.removeChild(oldNode);
27457
27516
  owned = next.nodeType === 11 ? fresh : null;
27458
- current2 = fresh[0] ?? current2;
27517
+ current3 = fresh[0] ?? current3;
27459
27518
  });
27460
27519
  return node;
27461
27520
  }
@@ -27471,9 +27530,9 @@ var init_primitive = __esm({
27471
27530
 
27472
27531
  // ../runtime/src/action.ts
27473
27532
  function getActionRegistry() {
27474
- const g4 = globalThis;
27475
- if (!g4[registryKey]) g4[registryKey] = {};
27476
- return g4[registryKey];
27533
+ const g5 = globalThis;
27534
+ if (!g5[registryKey]) g5[registryKey] = {};
27535
+ return g5[registryKey];
27477
27536
  }
27478
27537
  function hashString(str3) {
27479
27538
  let h1 = 2166136261;
@@ -27511,8 +27570,8 @@ function getAction(id) {
27511
27570
  return getActionRegistry()[id] || null;
27512
27571
  }
27513
27572
  function clearActions() {
27514
- const g4 = globalThis;
27515
- g4[registryKey] = {};
27573
+ const g5 = globalThis;
27574
+ g5[registryKey] = {};
27516
27575
  }
27517
27576
  function isFormAction(action) {
27518
27577
  return typeof action === "object" && action !== null && (action.__veskAction === true || typeof action.id === "string" && typeof action.url === "string");
@@ -27725,8 +27784,8 @@ function setIn(value, path, next) {
27725
27784
  const [key, ...rest] = path;
27726
27785
  const container = Array.isArray(value) ? value : isObject(value) ? value : null;
27727
27786
  if (container === null) return value;
27728
- const current2 = Array.isArray(container) ? container[typeof key === "number" ? key : Number(key)] : container[String(key)];
27729
- if (rest.length > 0 && current2 === void 0) return value;
27787
+ const current3 = Array.isArray(container) ? container[typeof key === "number" ? key : Number(key)] : container[String(key)];
27788
+ if (rest.length > 0 && current3 === void 0) return value;
27730
27789
  if (Array.isArray(value)) {
27731
27790
  const index = typeof key === "number" ? key : Number(key);
27732
27791
  if (!Number.isInteger(index) || index < 0) return value;
@@ -27747,18 +27806,18 @@ function updateIn(value, path, fn) {
27747
27806
  return setIn(value, [key], next);
27748
27807
  }
27749
27808
  function getIn(value, path) {
27750
- let current2 = value;
27809
+ let current3 = value;
27751
27810
  for (const key of path) {
27752
- if (Array.isArray(current2)) {
27811
+ if (Array.isArray(current3)) {
27753
27812
  const index = typeof key === "number" ? key : Number(key);
27754
27813
  if (!Number.isInteger(index)) return void 0;
27755
- current2 = current2[index];
27814
+ current3 = current3[index];
27756
27815
  continue;
27757
27816
  }
27758
- if (!isObject(current2)) return void 0;
27759
- current2 = current2[String(key)];
27817
+ if (!isObject(current3)) return void 0;
27818
+ current3 = current3[String(key)];
27760
27819
  }
27761
- return current2;
27820
+ return current3;
27762
27821
  }
27763
27822
  var init_nested_update = __esm({
27764
27823
  "../runtime/src/nested-update.ts"() {
@@ -27768,8 +27827,8 @@ var init_nested_update = __esm({
27768
27827
 
27769
27828
  // ../runtime/src/store-persistence.ts
27770
27829
  function currentSsrToken() {
27771
- const g4 = globalThis;
27772
- return typeof g4.__vsk_ssr_token === "string" ? g4.__vsk_ssr_token : "";
27830
+ const g5 = globalThis;
27831
+ return typeof g5.__vsk_ssr_token === "string" ? g5.__vsk_ssr_token : "";
27773
27832
  }
27774
27833
  function persistedStoreCookieName(storageKey) {
27775
27834
  return "vsk_store_" + encodeURIComponent(storageKey);
@@ -27866,23 +27925,23 @@ function createStore(initial, options = {}) {
27866
27925
  let batchDepth = 0;
27867
27926
  let dirty = false;
27868
27927
  function notifyNow(action, payload) {
27869
- const current2 = stateCell.get();
27870
- if (current2 === prevValue) return;
27871
- subs.forEach((fn) => fn(current2));
27928
+ const current3 = stateCell.get();
27929
+ if (current3 === prevValue) return;
27930
+ subs.forEach((fn) => fn(current3));
27872
27931
  watchers.forEach(({ selector, cb, equals }) => {
27873
27932
  const eq = equals ?? Object.is;
27874
- const newVal = selector(current2);
27933
+ const newVal = selector(current3);
27875
27934
  const oldVal = selector(prevValue);
27876
27935
  if (!eq(newVal, oldVal)) cb(newVal, oldVal);
27877
27936
  });
27878
- middlewares.forEach((fn) => fn(current2, action, payload));
27937
+ middlewares.forEach((fn) => fn(current3, action, payload));
27879
27938
  if (devtools && typeof window !== "undefined") {
27880
27939
  const dt = window.__VESK_STORE_DEVTOOLS__;
27881
27940
  if (dt && typeof dt.send === "function") {
27882
- dt.send({ type: action, payload, state: structuredClone(current2) });
27941
+ dt.send({ type: action, payload, state: structuredClone(current3) });
27883
27942
  }
27884
27943
  }
27885
- prevValue = cloneState(current2);
27944
+ prevValue = cloneState(current3);
27886
27945
  }
27887
27946
  function notifyDirty(action, payload) {
27888
27947
  if (batchDepth > 0) {
@@ -27909,17 +27968,17 @@ function createStore(initial, options = {}) {
27909
27968
  notifyDirty(action, next);
27910
27969
  }
27911
27970
  function update(partialOrFn, action = "update") {
27912
- const current2 = stateCell.get();
27913
- const patch = typeof partialOrFn === "function" ? partialOrFn(current2) : partialOrFn;
27914
- const next = Object.assign(cloneState(current2), patch);
27971
+ const current3 = stateCell.get();
27972
+ const patch = typeof partialOrFn === "function" ? partialOrFn(current3) : partialOrFn;
27973
+ const next = Object.assign(cloneState(current3), patch);
27915
27974
  stateCell.set(next);
27916
27975
  persistToStorage();
27917
27976
  notifyDirty(action, patch);
27918
27977
  }
27919
27978
  function deleteKeys(keys, action = "delete") {
27920
- const current2 = stateCell.get();
27979
+ const current3 = stateCell.get();
27921
27980
  const kArray = Array.isArray(keys) ? keys : [keys];
27922
- const next = cloneState(current2);
27981
+ const next = cloneState(current3);
27923
27982
  kArray.forEach((k) => {
27924
27983
  delete next[k];
27925
27984
  });
@@ -28085,8 +28144,8 @@ function isStrictPrefix(prefix, full) {
28085
28144
  function cloneValue(value, seen) {
28086
28145
  if (value === null || typeof value !== "object") return value;
28087
28146
  seen = seen ?? /* @__PURE__ */ new Map();
28088
- const existing = seen.get(value);
28089
- if (existing !== void 0) return existing;
28147
+ const existing2 = seen.get(value);
28148
+ if (existing2 !== void 0) return existing2;
28090
28149
  if (value instanceof Date) {
28091
28150
  const d = new Date(value.getTime());
28092
28151
  seen.set(value, d);
@@ -28520,8 +28579,8 @@ function createPathStore(initial, options = {}) {
28520
28579
  const subscribers = /* @__PURE__ */ new Set();
28521
28580
  const watchers = /* @__PURE__ */ new Set();
28522
28581
  function dispatchAll() {
28523
- const current2 = buildMerged();
28524
- for (const wrapper of subscribers) wrapper(current2);
28582
+ const current3 = buildMerged();
28583
+ for (const wrapper of subscribers) wrapper(current3);
28525
28584
  for (const wrapper of watchers) wrapper();
28526
28585
  }
28527
28586
  function whyAt(tokens, depth = 0, versionNow = version2) {
@@ -28706,7 +28765,7 @@ function createPathStore(initial, options = {}) {
28706
28765
  prev = selected;
28707
28766
  fn(selected);
28708
28767
  }
28709
- } : (current2) => fn(current2);
28768
+ } : (current3) => fn(current3);
28710
28769
  subscribers.add(wrapper);
28711
28770
  wrapper(buildMerged());
28712
28771
  return () => {
@@ -34735,8 +34794,8 @@ function isThenable(value) {
34735
34794
  return typeof value?.then === "function";
34736
34795
  }
34737
34796
  function withSsrStore(fn) {
34738
- const existing = storage.getStore();
34739
- if (existing) return fn();
34797
+ const existing2 = storage.getStore();
34798
+ if (existing2) return fn();
34740
34799
  const store = createSsrStore();
34741
34800
  keepSsrSlot(store.token);
34742
34801
  let result;
@@ -34778,15 +34837,15 @@ function dropSsrSlot(token) {
34778
34837
  function isSsrSlotLive(token) {
34779
34838
  return liveSlots.has(token);
34780
34839
  }
34781
- var TOKEN_KEY, IMPL_KEY, g2, impl, storage, liveSlots, ssrSink2;
34840
+ var TOKEN_KEY, IMPL_KEY, g3, impl, storage, liveSlots, ssrSink2;
34782
34841
  var init_ssr_store = __esm({
34783
34842
  "../compiler/src/ssr-store.ts"() {
34784
34843
  "use strict";
34785
34844
  init_index_server();
34786
34845
  TOKEN_KEY = "__vsk_ssr_token";
34787
34846
  IMPL_KEY = "__vsk_ssr_store_impl";
34788
- g2 = globalThis;
34789
- impl = g2[IMPL_KEY] ?? (g2[IMPL_KEY] = {
34847
+ g3 = globalThis;
34848
+ impl = g3[IMPL_KEY] ?? (g3[IMPL_KEY] = {
34790
34849
  storage: new AsyncLocalStorage(),
34791
34850
  liveSlots: /* @__PURE__ */ new Map(),
34792
34851
  // Only the copy that created the implementation installs the token
@@ -35093,17 +35152,17 @@ async function settleSsrPromises(token) {
35093
35152
  }
35094
35153
  }
35095
35154
  function pruneSsrDataSlots() {
35096
- const g4 = globalThis;
35155
+ const g5 = globalThis;
35097
35156
  const prefix = "__vsk_ssr_data_";
35098
35157
  const stale = [];
35099
- for (const k of Object.keys(g4)) {
35158
+ for (const k of Object.keys(g5)) {
35100
35159
  if (typeof k !== "string" || !k.startsWith(prefix)) continue;
35101
35160
  if (isSsrSlotLive(k.slice(prefix.length))) continue;
35102
35161
  stale.push(k);
35103
35162
  }
35104
35163
  if (stale.length <= 40) return;
35105
35164
  stale.sort().slice(0, stale.length - 40).forEach((k) => {
35106
- delete g4[k];
35165
+ delete g5[k];
35107
35166
  });
35108
35167
  }
35109
35168
  async function applyHeadPlugins(headHtml, plugins, ctx2) {
@@ -35832,9 +35891,9 @@ function getPluginRecords(appDir, veskDir, configPluginNames) {
35832
35891
  }
35833
35892
  function setPluginActive(veskDir, name, active) {
35834
35893
  const state = readPluginState(veskDir);
35835
- const existing = state.plugins.find((p) => eqIgnoreCase(p.name, name));
35836
- if (existing) {
35837
- existing.active = active;
35894
+ const existing2 = state.plugins.find((p) => eqIgnoreCase(p.name, name));
35895
+ if (existing2) {
35896
+ existing2.active = active;
35838
35897
  } else {
35839
35898
  state.plugins.push({ name, package: name, active });
35840
35899
  }
@@ -35914,13 +35973,13 @@ async function installPlugin(appDir, veskDir, pkg) {
35914
35973
  }
35915
35974
  const state = readPluginState(veskDir);
35916
35975
  const name = probe.packageJson?.name || pkg;
35917
- const existing = state.plugins.find(
35976
+ const existing2 = state.plugins.find(
35918
35977
  (p) => eqIgnoreCase(p.package, pkg) || eqIgnoreCase(p.name, name)
35919
35978
  );
35920
- if (existing) {
35921
- existing.package = pkg;
35922
- existing.name = name;
35923
- existing.active = true;
35979
+ if (existing2) {
35980
+ existing2.package = pkg;
35981
+ existing2.name = name;
35982
+ existing2.active = true;
35924
35983
  } else {
35925
35984
  state.plugins.push({ name, package: pkg, active: true });
35926
35985
  }
@@ -35958,12 +36017,12 @@ async function updatePlugin(appDir, veskDir, pkg) {
35958
36017
  const probe = resolvePackage(appDir, pkg);
35959
36018
  const state = readPluginState(veskDir);
35960
36019
  const name = probe.packageJson?.name || pkg;
35961
- const existing = state.plugins.find(
36020
+ const existing2 = state.plugins.find(
35962
36021
  (p) => eqIgnoreCase(p.package, pkg) || eqIgnoreCase(p.name, name)
35963
36022
  );
35964
- if (existing) {
35965
- existing.package = pkg;
35966
- existing.name = name;
36023
+ if (existing2) {
36024
+ existing2.package = pkg;
36025
+ existing2.name = name;
35967
36026
  } else {
35968
36027
  state.plugins.push({ name, package: pkg, active: true });
35969
36028
  }
@@ -35972,7 +36031,7 @@ async function updatePlugin(appDir, veskDir, pkg) {
35972
36031
  name,
35973
36032
  pkg,
35974
36033
  source: "state",
35975
- activeRaw: existing ? existing.active : true,
36034
+ activeRaw: existing2 ? existing2.active : true,
35976
36035
  error: null
35977
36036
  }, appDir);
35978
36037
  }
@@ -36666,6 +36725,7 @@ var init_static = __esm({
36666
36725
  // ../adapter/dist/image-pipeline.js
36667
36726
  var image_pipeline_exports = {};
36668
36727
  __export(image_pipeline_exports, {
36728
+ collectImageRefs: () => collectImageRefs,
36669
36729
  optimizeImages: () => optimizeImages
36670
36730
  });
36671
36731
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
@@ -36732,21 +36792,29 @@ async function processImage(srcPath, outDir, baseName) {
36732
36792
  const image = sharpFn ? sharpFn(srcPath) : null;
36733
36793
  if (!image) {
36734
36794
  const original = readFileSync18(srcPath);
36795
+ const ext = extname5(srcPath);
36796
+ const written = [];
36735
36797
  for (const w of OUTPUT_WIDTHS) {
36736
- const outputPath = resolve16(outDir, `${baseName}-${w}w`);
36798
+ const outputPath = resolve16(outDir, `${baseName}-${w}w${ext}`);
36737
36799
  mkdirSync8(dirname12(outputPath), { recursive: true });
36738
36800
  writeFileSync9(outputPath, original);
36801
+ written.push(outputPath);
36739
36802
  }
36740
- return [];
36803
+ return written;
36741
36804
  }
36742
36805
  const meta = await image.metadata();
36743
36806
  const originalWidth = meta.width || 1920;
36744
36807
  const generated = [];
36745
36808
  for (const w of OUTPUT_WIDTHS) {
36746
- if (w > originalWidth)
36809
+ const base = `${baseName}-${w}w`;
36810
+ if (w >= originalWidth) {
36811
+ const copyPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
36812
+ mkdirSync8(dirname12(copyPath), { recursive: true });
36813
+ writeFileSync9(copyPath, readFileSync18(srcPath));
36814
+ generated.push(copyPath);
36747
36815
  continue;
36816
+ }
36748
36817
  const resized = image.clone().resize({ width: w, withoutEnlargement: true });
36749
- const base = `${baseName}-${w}w`;
36750
36818
  const jpgPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
36751
36819
  mkdirSync8(dirname12(jpgPath), { recursive: true });
36752
36820
  await resized.toFile(jpgPath);
@@ -36775,9 +36843,9 @@ function collectImageRefs(appDir) {
36775
36843
  if (entry.startsWith("."))
36776
36844
  continue;
36777
36845
  walk9(full);
36778
- } else if (entry === "page.vsk") {
36846
+ } else if (entry.endsWith(".vsk")) {
36779
36847
  const src2 = readFileSync18(full, "utf-8");
36780
- const imgRegex = /<Image\s+src=["']([^"']+)["']/g;
36848
+ const imgRegex = /<Image\s[^>]*src=["']([^"']+)["']/g;
36781
36849
  let m;
36782
36850
  while ((m = imgRegex.exec(src2)) !== null) {
36783
36851
  refs.push({ source: full, src: m[1] });
@@ -36789,8 +36857,7 @@ function collectImageRefs(appDir) {
36789
36857
  return refs;
36790
36858
  }
36791
36859
  async function optimizeImages(appDir, outDir) {
36792
- const imageOutDir = resolve16(outDir, "static", "images");
36793
- mkdirSync8(imageOutDir, { recursive: true });
36860
+ mkdirSync8(resolve16(outDir, "static", "public"), { recursive: true });
36794
36861
  const refs = collectImageRefs(appDir);
36795
36862
  if (refs.length === 0) {
36796
36863
  console.error("vesk images: no <Image> refs found");
@@ -36823,6 +36890,8 @@ async function optimizeImages(appDir, outDir) {
36823
36890
  continue;
36824
36891
  }
36825
36892
  const baseName = ref2.src.replace(/^\//, "").replace(extname5(ref2.src), "");
36893
+ const imageOutDir = resolve16(outDir, "static", "public");
36894
+ mkdirSync8(imageOutDir, { recursive: true });
36826
36895
  const files = await processImage(srcPath, imageOutDir, baseName);
36827
36896
  results.push({ src: ref2.src, baseName, files, widths: OUTPUT_WIDTHS });
36828
36897
  console.error(`vesk images: ${ref2.src} \u2192 ${files.length} variants`);
@@ -40145,9 +40214,9 @@ function Md2(props, _registry, hydrate) {
40145
40214
  if (hydrate && typeof hydrate.nextElement === "function") {
40146
40215
  let el = hydrate.nextElement("div");
40147
40216
  if (el && !el.parentNode && hydrate.root) {
40148
- const existing = hydrate.root.querySelector("div");
40149
- if (existing)
40150
- el = existing;
40217
+ const existing2 = hydrate.root.querySelector("div");
40218
+ if (existing2)
40219
+ el = existing2;
40151
40220
  }
40152
40221
  const claimed = !!el.parentNode;
40153
40222
  if (pathMode && claimed) {
@@ -41122,9 +41191,9 @@ function getJSXTagName2(el) {
41122
41191
  if (name.type === "JSXNamespacedName") return name.namespace.name + ":" + name.name.name;
41123
41192
  return null;
41124
41193
  }
41125
- function emitJSXText(g4, text, start, end) {
41194
+ function emitJSXText(g5, text, start, end) {
41126
41195
  if (text.indexOf("<") === -1 && text.indexOf(">") === -1 && text.indexOf("&") === -1 && text.indexOf("{") === -1 && text.indexOf("}") === -1) {
41127
- g4.add(text, start, end);
41196
+ g5.add(text, start, end);
41128
41197
  return;
41129
41198
  }
41130
41199
  let out = "";
@@ -41137,7 +41206,7 @@ function emitJSXText(g4, text, start, end) {
41137
41206
  else if (c === "}") out += "&#125;";
41138
41207
  else out += c;
41139
41208
  }
41140
- g4.add(out, start, end);
41209
+ g5.add(out, start, end);
41141
41210
  }
41142
41211
  function collapseWithMap(value) {
41143
41212
  let out = "";
@@ -41294,31 +41363,31 @@ function stripCallTypeArgs(text) {
41294
41363
  }
41295
41364
  return text;
41296
41365
  }
41297
- function emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts) {
41366
+ function emitTrackDeclStatement(g5, source, stmt, indent4, isLast, opts) {
41298
41367
  const fullText = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
41299
41368
  const text = fullText + (!fullText.endsWith("}") && !isLast ? ";" : "");
41300
41369
  const decls = stmt.declarations || [];
41301
- g4.add(indent4);
41370
+ g5.add(indent4);
41302
41371
  let prevEnd = stmt.start;
41303
41372
  for (let di = 0; di < decls.length; di++) {
41304
41373
  const decl = decls[di];
41305
41374
  const id = decl.id;
41306
41375
  const isLazy = id && id.type === "ArrayPattern" && id.lazy === true && decl.init;
41307
41376
  if (!isLazy) {
41308
- g4.addRaw(source.slice(prevEnd, decl.start));
41309
- g4.add(source.slice(decl.start, decl.end), decl.start, decl.end);
41377
+ g5.addRaw(source.slice(prevEnd, decl.start));
41378
+ g5.add(source.slice(decl.start, decl.end), decl.start, decl.end);
41310
41379
  prevEnd = decl.end;
41311
41380
  continue;
41312
41381
  }
41313
- if (di > 0) g4.addRaw(source.slice(prevEnd, decl.start));
41382
+ if (di > 0) g5.addRaw(source.slice(prevEnd, decl.start));
41314
41383
  const ch = text[decl.end - stmt.start] ?? " ";
41315
41384
  const elements = id.elements || [];
41316
41385
  const names = elements.map((el) => el ? el.name : null).filter((n) => typeof n === "string");
41317
41386
  const initText = source.slice(decl.init.start, decl.init.end);
41318
41387
  if (names.length === 0) {
41319
- g4.add("let _ = ");
41320
- g4.add(initText, decl.init.start, decl.init.end);
41321
- if (ch !== ";") g4.addRaw(";");
41388
+ g5.add("let _ = ");
41389
+ g5.add(initText, decl.init.start, decl.init.end);
41390
+ if (ch !== ";") g5.addRaw(";");
41322
41391
  prevEnd = decl.end;
41323
41392
  continue;
41324
41393
  }
@@ -41329,133 +41398,133 @@ function emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts) {
41329
41398
  const firstRange = [elements[0].start, elements[0].end];
41330
41399
  const dropLastSemi = ch === ";";
41331
41400
  if (opts.typedCells) {
41332
- const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
41333
- g4.cellCount++;
41401
+ const cellName = g5.cellCount === 0 ? "__cell" : `__cell${g5.cellCount}`;
41402
+ g5.cellCount++;
41334
41403
  if (annotation) {
41335
- g4.add(`const ${cellName}: Tracked<`);
41336
- g4.add(annotation, annStart, annEnd);
41337
- g4.add("> = ");
41404
+ g5.add(`const ${cellName}: Tracked<`);
41405
+ g5.add(annotation, annStart, annEnd);
41406
+ g5.add("> = ");
41338
41407
  } else {
41339
- g4.add(`const ${cellName} = `);
41408
+ g5.add(`const ${cellName} = `);
41340
41409
  }
41341
41410
  const cellInit = annotation ? stripCallTypeArgs(initText) : initText;
41342
- g4.add(cellInit, decl.init.start, decl.init.end);
41343
- g4.add(";");
41344
- g4.add(" let ");
41345
- g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41411
+ g5.add(cellInit, decl.init.start, decl.init.end);
41412
+ g5.add(";");
41413
+ g5.add(" let ");
41414
+ g5.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41346
41415
  if (annotation) {
41347
- g4.add(": ");
41348
- g4.add(annotation, annStart, annEnd);
41416
+ g5.add(": ");
41417
+ g5.add(annotation, annStart, annEnd);
41349
41418
  }
41350
- g4.add(` = ${cellName}.get();`);
41419
+ g5.add(` = ${cellName}.get();`);
41351
41420
  for (let n = 1; n < names.length; n++) {
41352
- g4.add(" let ");
41353
- g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
41354
- g4.add(` = ${cellName};`);
41421
+ g5.add(" let ");
41422
+ g5.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
41423
+ g5.add(` = ${cellName};`);
41355
41424
  }
41356
- if (dropLastSemi) g4.code = g4.code.slice(0, -1);
41425
+ if (dropLastSemi) g5.code = g5.code.slice(0, -1);
41357
41426
  } else {
41358
41427
  if (annotation) {
41359
- g4.add("let ");
41360
- g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41361
- g4.add(": ");
41362
- g4.add(annotation, annStart, annEnd);
41363
- g4.add(" = (");
41364
- g4.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
41365
- g4.add(" as unknown as ");
41366
- g4.add(annotation, annStart, annEnd);
41367
- g4.add(");");
41428
+ g5.add("let ");
41429
+ g5.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41430
+ g5.add(": ");
41431
+ g5.add(annotation, annStart, annEnd);
41432
+ g5.add(" = (");
41433
+ g5.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
41434
+ g5.add(" as unknown as ");
41435
+ g5.add(annotation, annStart, annEnd);
41436
+ g5.add(");");
41368
41437
  } else {
41369
- const cellName = g4.cellCount === 0 ? "__cell" : `__cell${g4.cellCount}`;
41370
- g4.cellCount++;
41371
- g4.add(`const ${cellName} = `);
41372
- g4.add(initText, decl.init.start, decl.init.end);
41373
- g4.add("; let ");
41374
- g4.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41375
- g4.add(` = ${cellName}.get();`);
41438
+ const cellName = g5.cellCount === 0 ? "__cell" : `__cell${g5.cellCount}`;
41439
+ g5.cellCount++;
41440
+ g5.add(`const ${cellName} = `);
41441
+ g5.add(initText, decl.init.start, decl.init.end);
41442
+ g5.add("; let ");
41443
+ g5.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
41444
+ g5.add(` = ${cellName}.get();`);
41376
41445
  }
41377
41446
  for (let n = 1; n < names.length; n++) {
41378
- g4.add(" let ");
41379
- g4.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
41380
- g4.add(": any = ");
41381
- g4.add(first, firstRange[0], firstRange[1]);
41382
- g4.add(";");
41383
- if (n === names.length - 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
41447
+ g5.add(" let ");
41448
+ g5.add(names[n], elements[n].start, elements[n].end, REACTIVE_DATA);
41449
+ g5.add(": any = ");
41450
+ g5.add(first, firstRange[0], firstRange[1]);
41451
+ g5.add(";");
41452
+ if (n === names.length - 1 && dropLastSemi) g5.code = g5.code.slice(0, -1);
41384
41453
  }
41385
- if (names.length === 1 && dropLastSemi) g4.code = g4.code.slice(0, -1);
41454
+ if (names.length === 1 && dropLastSemi) g5.code = g5.code.slice(0, -1);
41386
41455
  }
41387
41456
  prevEnd = decl.end;
41388
41457
  }
41389
- if (!isLast) g4.addRaw(";");
41458
+ if (!isLast) g5.addRaw(";");
41390
41459
  }
41391
- function emitBlock(g4, source, body, indent4, opts) {
41460
+ function emitBlock(g5, source, body, indent4, opts) {
41392
41461
  const stmts = body && body.type === "BlockStatement" ? body.body : body ? Array.isArray(body) ? body : [body] : [];
41393
- g4.addRaw("{\n");
41394
- emitBody(g4, source, stmts, indent4 + " ", opts);
41395
- g4.addRaw("\n");
41396
- g4.add(indent4);
41397
- g4.addRaw("}");
41462
+ g5.addRaw("{\n");
41463
+ emitBody(g5, source, stmts, indent4 + " ", opts);
41464
+ g5.addRaw("\n");
41465
+ g5.add(indent4);
41466
+ g5.addRaw("}");
41398
41467
  }
41399
- function emitJSXAttr(g4, source, attr) {
41468
+ function emitJSXAttr(g5, source, attr) {
41400
41469
  if (attr.type === "JSXSpreadAttribute") {
41401
- g4.add(source.slice(attr.start, attr.end), attr.start, attr.end);
41470
+ g5.add(source.slice(attr.start, attr.end), attr.start, attr.end);
41402
41471
  return;
41403
41472
  }
41404
41473
  const name = attr.name;
41405
- g4.add(source.slice(name.start, name.end), name.start, name.end);
41474
+ g5.add(source.slice(name.start, name.end), name.start, name.end);
41406
41475
  const v = attr.value;
41407
41476
  if (!v) return;
41408
- g4.add(source.slice(name.end, v.start), name.end, v.start);
41477
+ g5.add(source.slice(name.end, v.start), name.end, v.start);
41409
41478
  if (v.type === "JSXExpressionContainer") {
41410
- g4.add(source.slice(v.start, v.expression.start), v.start, v.expression.start);
41411
- g4.add(source.slice(v.expression.start, v.expression.end), v.expression.start, v.expression.end);
41412
- g4.add(source.slice(v.expression.end, v.end), v.expression.end, v.end);
41479
+ g5.add(source.slice(v.start, v.expression.start), v.start, v.expression.start);
41480
+ g5.add(source.slice(v.expression.start, v.expression.end), v.expression.start, v.expression.end);
41481
+ g5.add(source.slice(v.expression.end, v.end), v.expression.end, v.end);
41413
41482
  } else {
41414
- g4.add(source.slice(v.start, v.end), v.start, v.end);
41483
+ g5.add(source.slice(v.start, v.end), v.start, v.end);
41415
41484
  }
41416
41485
  }
41417
- function emitJSXElement(g4, source, el, opts, hoist) {
41486
+ function emitJSXElement(g5, source, el, opts, hoist) {
41418
41487
  const op = el.openingElement;
41419
41488
  const name = op.name;
41420
41489
  let prev;
41421
41490
  if (name) {
41422
- g4.add(source.slice(op.start, name.start), op.start, name.start);
41423
- g4.add(source.slice(name.start, name.end), name.start, name.end);
41491
+ g5.add(source.slice(op.start, name.start), op.start, name.start);
41492
+ g5.add(source.slice(name.start, name.end), name.start, name.end);
41424
41493
  prev = name.end;
41425
41494
  } else {
41426
41495
  prev = op.start + 1;
41427
41496
  }
41428
41497
  for (const attr of op.attributes ?? []) {
41429
- g4.add(source.slice(prev, attr.start), prev, attr.start);
41430
- emitJSXAttr(g4, source, attr);
41498
+ g5.add(source.slice(prev, attr.start), prev, attr.start);
41499
+ emitJSXAttr(g5, source, attr);
41431
41500
  prev = attr.end;
41432
41501
  }
41433
41502
  const tail = source.slice(prev, op.end);
41434
41503
  if (op.selfClosing && !tail.includes("/")) {
41435
41504
  const gt = tail.lastIndexOf(">");
41436
41505
  const head = gt === -1 ? tail : tail.slice(0, gt);
41437
- if (head) g4.add(head, prev, prev + head.length);
41438
- g4.addRaw("/>");
41506
+ if (head) g5.add(head, prev, prev + head.length);
41507
+ g5.addRaw("/>");
41439
41508
  } else {
41440
- g4.add(tail, prev, op.end);
41509
+ g5.add(tail, prev, op.end);
41441
41510
  }
41442
41511
  if (op.selfClosing) return;
41443
- emitJSXChildren(g4, source, el.children ?? [], opts, hoist);
41512
+ emitJSXChildren(g5, source, el.children ?? [], opts, hoist);
41444
41513
  if (el.closingElement) {
41445
- g4.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
41514
+ g5.add(source.slice(el.closingElement.start, el.closingElement.end), el.closingElement.start, el.closingElement.end);
41446
41515
  }
41447
41516
  }
41448
- function emitJSXExprBody(g4, source, expr, opts) {
41449
- if (expr.type === "JSXElement") return emitJSXElement(g4, source, expr, opts);
41450
- if (expr.type === "JSXFragment") return emitJSXFragment(g4, source, expr, opts);
41451
- g4.add(source.slice(expr.start, expr.end), expr.start, expr.end);
41517
+ function emitJSXExprBody(g5, source, expr, opts) {
41518
+ if (expr.type === "JSXElement") return emitJSXElement(g5, source, expr, opts);
41519
+ if (expr.type === "JSXFragment") return emitJSXFragment(g5, source, expr, opts);
41520
+ g5.add(source.slice(expr.start, expr.end), expr.start, expr.end);
41452
41521
  }
41453
- function emitJSXFragment(g4, source, frag, opts, hoist) {
41454
- g4.addRaw("<>");
41455
- emitJSXChildren(g4, source, frag.children ?? [], opts, hoist);
41456
- g4.addRaw("</>");
41522
+ function emitJSXFragment(g5, source, frag, opts, hoist) {
41523
+ g5.addRaw("<>");
41524
+ emitJSXChildren(g5, source, frag.children ?? [], opts, hoist);
41525
+ g5.addRaw("</>");
41457
41526
  }
41458
- function emitForClauseMap(g4, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
41527
+ function emitForClauseMap(g5, source, child, text, map, clauseStart, bodyEmit, emptyEmit) {
41459
41528
  const clauseEnd = findBalancedEnd(text, clauseStart - 1);
41460
41529
  const clause = text.slice(clauseStart, clauseEnd);
41461
41530
  const ofIdx = findTopLevelSep(clause, "of");
@@ -41472,38 +41541,38 @@ function emitForClauseMap(g4, source, child, text, map, clauseStart, bodyEmit, e
41472
41541
  const itemVar = stripDeclKeyword(lhs).trim();
41473
41542
  if (ofIdx !== -1) {
41474
41543
  if (emptyEmit) {
41475
- g4.addRaw("{ (() => { const _v = ");
41476
- g4.add(arrExpr, arrStart, arrEnd);
41477
- g4.addRaw("; return _v.length === 0 ? (");
41544
+ g5.addRaw("{ (() => { const _v = ");
41545
+ g5.add(arrExpr, arrStart, arrEnd);
41546
+ g5.addRaw("; return _v.length === 0 ? (");
41478
41547
  emptyEmit();
41479
- g4.addRaw(") : _v.map((");
41480
- g4.addRaw(itemVar);
41481
- g4.addRaw(": (typeof _v)[number]) => (");
41548
+ g5.addRaw(") : _v.map((");
41549
+ g5.addRaw(itemVar);
41550
+ g5.addRaw(": (typeof _v)[number]) => (");
41482
41551
  bodyEmit();
41483
- g4.addRaw(")); })() }");
41552
+ g5.addRaw(")); })() }");
41484
41553
  } else {
41485
- g4.addRaw("{ ");
41486
- g4.add(arrExpr, arrStart, arrEnd);
41487
- g4.addRaw(".map((");
41488
- g4.addRaw(itemVar);
41489
- g4.addRaw(": (typeof ");
41490
- g4.add(arrExpr, arrStart, arrEnd);
41491
- g4.addRaw(")[number]) => (");
41554
+ g5.addRaw("{ ");
41555
+ g5.add(arrExpr, arrStart, arrEnd);
41556
+ g5.addRaw(".map((");
41557
+ g5.addRaw(itemVar);
41558
+ g5.addRaw(": (typeof ");
41559
+ g5.add(arrExpr, arrStart, arrEnd);
41560
+ g5.addRaw(")[number]) => (");
41492
41561
  bodyEmit();
41493
- g4.addRaw(")) }");
41562
+ g5.addRaw(")) }");
41494
41563
  }
41495
41564
  } else {
41496
- g4.addRaw("{ Object.keys(");
41497
- g4.add(arrExpr, arrStart, arrEnd);
41498
- g4.addRaw(").map((");
41499
- g4.addRaw(itemVar);
41500
- g4.addRaw(") => (");
41565
+ g5.addRaw("{ Object.keys(");
41566
+ g5.add(arrExpr, arrStart, arrEnd);
41567
+ g5.addRaw(").map((");
41568
+ g5.addRaw(itemVar);
41569
+ g5.addRaw(") => (");
41501
41570
  bodyEmit();
41502
- g4.addRaw(")) }");
41571
+ g5.addRaw(")) }");
41503
41572
  }
41504
41573
  return true;
41505
41574
  }
41506
- function emitJSXChildren(g4, source, children, opts, hoist) {
41575
+ function emitJSXChildren(g5, source, children, opts, hoist) {
41507
41576
  let i = 0;
41508
41577
  let forPending = false;
41509
41578
  while (i < children.length) {
@@ -41529,46 +41598,46 @@ function emitJSXChildren(g4, source, children, opts, hoist) {
41529
41598
  const emptyContainer = children[i + 3];
41530
41599
  if (emptyTextNode && emptyTextNode.type === "JSXText" && ["#empty", "empty"].includes(emptyTextNode.value.trim()) && emptyContainer && emptyContainer.type === "JSXExpressionContainer" && emptyContainer.expression.type !== "JSXEmptyExpression") {
41531
41600
  consumed = 4;
41532
- emptyEmit = () => emitJSXExprBody(g4, source, emptyContainer.expression, opts);
41601
+ emptyEmit = () => emitJSXExprBody(g5, source, emptyContainer.expression, opts);
41533
41602
  }
41534
41603
  let matched = false;
41535
41604
  if (nextChild.type === "JSXExpressionContainer") {
41536
41605
  const exprNode = nextChild.expression;
41537
41606
  if (exprNode.type === "JSXEmptyExpression") {
41538
- g4.add(text, child.start, child.end);
41607
+ g5.add(text, child.start, child.end);
41539
41608
  i++;
41540
41609
  continue;
41541
41610
  }
41542
41611
  matched = emitForClauseMap(
41543
- g4,
41612
+ g5,
41544
41613
  source,
41545
41614
  child,
41546
41615
  text,
41547
41616
  map,
41548
41617
  clauseStartCollapsed,
41549
- () => emitJSXExprBody(g4, source, exprNode, opts),
41618
+ () => emitJSXExprBody(g5, source, exprNode, opts),
41550
41619
  emptyEmit
41551
41620
  );
41552
41621
  } else if (nextChild.type === "JSXFragment") {
41553
41622
  matched = emitForClauseMap(
41554
- g4,
41623
+ g5,
41555
41624
  source,
41556
41625
  child,
41557
41626
  text,
41558
41627
  map,
41559
41628
  clauseStartCollapsed,
41560
- () => emitJSXFragment(g4, source, nextChild, opts),
41629
+ () => emitJSXFragment(g5, source, nextChild, opts),
41561
41630
  emptyEmit
41562
41631
  );
41563
41632
  } else {
41564
41633
  matched = emitForClauseMap(
41565
- g4,
41634
+ g5,
41566
41635
  source,
41567
41636
  child,
41568
41637
  text,
41569
41638
  map,
41570
41639
  clauseStartCollapsed,
41571
- () => emitJSXElement(g4, source, nextChild, opts),
41640
+ () => emitJSXElement(g5, source, nextChild, opts),
41572
41641
  emptyEmit
41573
41642
  );
41574
41643
  }
@@ -41585,184 +41654,184 @@ function emitJSXChildren(g4, source, children, opts, hoist) {
41585
41654
  continue;
41586
41655
  }
41587
41656
  forPending = false;
41588
- emitJSXText(g4, text, child.start, child.end);
41657
+ emitJSXText(g5, text, child.start, child.end);
41589
41658
  i++;
41590
41659
  } else if (child.type === "JSXExpressionContainer") {
41591
41660
  if (child.expression.type === "JSXEmptyExpression") {
41592
41661
  i++;
41593
41662
  continue;
41594
41663
  }
41595
- g4.addRaw("{");
41596
- g4.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
41597
- g4.addRaw("}");
41664
+ g5.addRaw("{");
41665
+ g5.add(source.slice(child.expression.start, child.expression.end), child.expression.start, child.expression.end);
41666
+ g5.addRaw("}");
41598
41667
  i++;
41599
41668
  } else if (child.type === "JSXElement") {
41600
41669
  if (getJSXTagName2(child) === "style") {
41601
41670
  const openEnd = child.openingElement?.end ?? child.start;
41602
41671
  const closeStart = child.closingElement?.start ?? child.end;
41603
- g4.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
41672
+ g5.recordStyle(child.start, child.end, source.slice(openEnd, closeStart));
41604
41673
  i++;
41605
41674
  continue;
41606
41675
  }
41607
- emitJSXElement(g4, source, child, opts, hoist);
41676
+ emitJSXElement(g5, source, child, opts, hoist);
41608
41677
  i++;
41609
41678
  } else if (child.type === "JSXFragment") {
41610
- emitJSXFragment(g4, source, child, opts, hoist);
41679
+ emitJSXFragment(g5, source, child, opts, hoist);
41611
41680
  i++;
41612
41681
  } 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") {
41613
41682
  if (hoist && hoist.set.has(child)) {
41614
41683
  i++;
41615
41684
  continue;
41616
41685
  }
41617
- g4.addRaw("{(() => { ");
41618
- emitBody(g4, source, [child], "", opts);
41619
- g4.addRaw(" })()}");
41686
+ g5.addRaw("{(() => { ");
41687
+ emitBody(g5, source, [child], "", opts);
41688
+ g5.addRaw(" })()}");
41620
41689
  i++;
41621
41690
  } else {
41622
41691
  i++;
41623
41692
  }
41624
41693
  }
41625
41694
  }
41626
- function emitIf(g4, source, stmt, indent4, opts) {
41627
- g4.add(indent4);
41628
- g4.addRaw("if (");
41629
- g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41630
- g4.addRaw(") ");
41631
- emitBlock(g4, source, stmt.consequent, indent4, opts);
41695
+ function emitIf(g5, source, stmt, indent4, opts) {
41696
+ g5.add(indent4);
41697
+ g5.addRaw("if (");
41698
+ g5.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41699
+ g5.addRaw(") ");
41700
+ emitBlock(g5, source, stmt.consequent, indent4, opts);
41632
41701
  if (stmt.alternate) {
41633
- g4.addRaw(" else ");
41634
- emitBlock(g4, source, stmt.alternate, indent4, opts);
41702
+ g5.addRaw(" else ");
41703
+ emitBlock(g5, source, stmt.alternate, indent4, opts);
41635
41704
  }
41636
41705
  }
41637
- function emitLoopVariable(g4, source, left) {
41706
+ function emitLoopVariable(g5, source, left) {
41638
41707
  if (left && left.type === "Identifier") {
41639
- g4.addRaw("const ");
41640
- g4.add(source.slice(left.start, left.end), left.start, left.end);
41708
+ g5.addRaw("const ");
41709
+ g5.add(source.slice(left.start, left.end), left.start, left.end);
41641
41710
  return;
41642
41711
  }
41643
- g4.add(source.slice(left.start, left.end), left.start, left.end);
41644
- }
41645
- function emitForOf(g4, source, stmt, indent4, opts) {
41646
- g4.add(indent4);
41647
- g4.addRaw("for (");
41648
- emitLoopVariable(g4, source, stmt.left);
41649
- g4.addRaw(" of ");
41650
- g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41651
- g4.addRaw(") ");
41652
- emitBlock(g4, source, stmt.body, indent4, opts);
41653
- }
41654
- function emitForIn(g4, source, stmt, indent4, opts) {
41655
- g4.add(indent4);
41656
- g4.addRaw("for (");
41657
- emitLoopVariable(g4, source, stmt.left);
41658
- g4.addRaw(" in ");
41659
- g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41660
- g4.addRaw(") ");
41661
- emitBlock(g4, source, stmt.body, indent4, opts);
41662
- }
41663
- function emitFor(g4, source, stmt, indent4, opts) {
41664
- g4.add(indent4);
41665
- g4.addRaw("for (");
41666
- if (stmt.init) g4.add(source.slice(stmt.init.start, stmt.init.end), stmt.init.start, stmt.init.end);
41667
- g4.addRaw("; ");
41668
- if (stmt.test) g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41669
- g4.addRaw("; ");
41670
- if (stmt.update) g4.add(source.slice(stmt.update.start, stmt.update.end), stmt.update.start, stmt.update.end);
41671
- g4.addRaw(") ");
41672
- emitBlock(g4, source, stmt.body, indent4, opts);
41673
- }
41674
- function emitWhile(g4, source, stmt, indent4, opts) {
41675
- g4.add(indent4);
41676
- g4.addRaw("while (");
41677
- g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41678
- g4.addRaw(") ");
41679
- emitBlock(g4, source, stmt.body, indent4, opts);
41680
- }
41681
- function emitDoWhile(g4, source, stmt, indent4, opts) {
41682
- g4.add(indent4);
41683
- g4.addRaw("do ");
41684
- emitBlock(g4, source, stmt.body, indent4, opts);
41685
- g4.addRaw(" while (");
41686
- g4.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41687
- g4.addRaw(");");
41688
- }
41689
- function emitSwitch(g4, source, stmt, indent4, opts) {
41690
- g4.add(indent4);
41691
- g4.addRaw("switch (");
41692
- g4.add(source.slice(stmt.discriminant.start, stmt.discriminant.end), stmt.discriminant.start, stmt.discriminant.end);
41693
- g4.addRaw(") {");
41712
+ g5.add(source.slice(left.start, left.end), left.start, left.end);
41713
+ }
41714
+ function emitForOf(g5, source, stmt, indent4, opts) {
41715
+ g5.add(indent4);
41716
+ g5.addRaw("for (");
41717
+ emitLoopVariable(g5, source, stmt.left);
41718
+ g5.addRaw(" of ");
41719
+ g5.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41720
+ g5.addRaw(") ");
41721
+ emitBlock(g5, source, stmt.body, indent4, opts);
41722
+ }
41723
+ function emitForIn(g5, source, stmt, indent4, opts) {
41724
+ g5.add(indent4);
41725
+ g5.addRaw("for (");
41726
+ emitLoopVariable(g5, source, stmt.left);
41727
+ g5.addRaw(" in ");
41728
+ g5.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41729
+ g5.addRaw(") ");
41730
+ emitBlock(g5, source, stmt.body, indent4, opts);
41731
+ }
41732
+ function emitFor(g5, source, stmt, indent4, opts) {
41733
+ g5.add(indent4);
41734
+ g5.addRaw("for (");
41735
+ if (stmt.init) g5.add(source.slice(stmt.init.start, stmt.init.end), stmt.init.start, stmt.init.end);
41736
+ g5.addRaw("; ");
41737
+ if (stmt.test) g5.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41738
+ g5.addRaw("; ");
41739
+ if (stmt.update) g5.add(source.slice(stmt.update.start, stmt.update.end), stmt.update.start, stmt.update.end);
41740
+ g5.addRaw(") ");
41741
+ emitBlock(g5, source, stmt.body, indent4, opts);
41742
+ }
41743
+ function emitWhile(g5, source, stmt, indent4, opts) {
41744
+ g5.add(indent4);
41745
+ g5.addRaw("while (");
41746
+ g5.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41747
+ g5.addRaw(") ");
41748
+ emitBlock(g5, source, stmt.body, indent4, opts);
41749
+ }
41750
+ function emitDoWhile(g5, source, stmt, indent4, opts) {
41751
+ g5.add(indent4);
41752
+ g5.addRaw("do ");
41753
+ emitBlock(g5, source, stmt.body, indent4, opts);
41754
+ g5.addRaw(" while (");
41755
+ g5.add(source.slice(stmt.test.start, stmt.test.end), stmt.test.start, stmt.test.end);
41756
+ g5.addRaw(");");
41757
+ }
41758
+ function emitSwitch(g5, source, stmt, indent4, opts) {
41759
+ g5.add(indent4);
41760
+ g5.addRaw("switch (");
41761
+ g5.add(source.slice(stmt.discriminant.start, stmt.discriminant.end), stmt.discriminant.start, stmt.discriminant.end);
41762
+ g5.addRaw(") {");
41694
41763
  let firstCase = true;
41695
41764
  for (const c of stmt.cases ?? []) {
41696
- g4.addRaw(firstCase ? "\n" : "\n");
41765
+ g5.addRaw(firstCase ? "\n" : "\n");
41697
41766
  firstCase = false;
41698
- g4.add(indent4);
41699
- g4.addRaw(" ");
41767
+ g5.add(indent4);
41768
+ g5.addRaw(" ");
41700
41769
  if (c.test) {
41701
- g4.addRaw("case ");
41702
- g4.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
41703
- g4.addRaw(":");
41770
+ g5.addRaw("case ");
41771
+ g5.add(source.slice(c.test.start, c.test.end), c.test.start, c.test.end);
41772
+ g5.addRaw(":");
41704
41773
  } else {
41705
- g4.addRaw("default:");
41774
+ g5.addRaw("default:");
41706
41775
  }
41707
- const before = g4.code.length;
41708
- emitBody(g4, source, c.consequent, indent4 + " ", opts);
41709
- if (g4.code.length > before) g4.addRaw("\n");
41776
+ const before = g5.code.length;
41777
+ emitBody(g5, source, c.consequent, indent4 + " ", opts);
41778
+ if (g5.code.length > before) g5.addRaw("\n");
41710
41779
  }
41711
- g4.addRaw("\n");
41712
- g4.add(indent4);
41713
- g4.addRaw("}");
41780
+ g5.addRaw("\n");
41781
+ g5.add(indent4);
41782
+ g5.addRaw("}");
41714
41783
  }
41715
- function emitTry(g4, source, stmt, indent4, opts) {
41716
- g4.add(indent4);
41717
- g4.addRaw("try ");
41718
- emitBlock(g4, source, stmt.block, indent4, opts);
41784
+ function emitTry(g5, source, stmt, indent4, opts) {
41785
+ g5.add(indent4);
41786
+ g5.addRaw("try ");
41787
+ emitBlock(g5, source, stmt.block, indent4, opts);
41719
41788
  if (stmt.handler) {
41720
- g4.addRaw(" catch");
41789
+ g5.addRaw(" catch");
41721
41790
  if (stmt.handler.param) {
41722
- g4.addRaw(" (");
41723
- g4.add(source.slice(stmt.handler.param.start, stmt.handler.param.end), stmt.handler.param.start, stmt.handler.param.end);
41724
- g4.addRaw(")");
41791
+ g5.addRaw(" (");
41792
+ g5.add(source.slice(stmt.handler.param.start, stmt.handler.param.end), stmt.handler.param.start, stmt.handler.param.end);
41793
+ g5.addRaw(")");
41725
41794
  }
41726
- g4.addRaw(" ");
41727
- emitBlock(g4, source, stmt.handler.body, indent4, opts);
41795
+ g5.addRaw(" ");
41796
+ emitBlock(g5, source, stmt.handler.body, indent4, opts);
41728
41797
  }
41729
41798
  if (stmt.finalizer) {
41730
- g4.addRaw(" finally ");
41731
- emitBlock(g4, source, stmt.finalizer, indent4, opts);
41799
+ g5.addRaw(" finally ");
41800
+ emitBlock(g5, source, stmt.finalizer, indent4, opts);
41732
41801
  }
41733
41802
  }
41734
- function emitPlainStatement(g4, source, stmt, indent4, isLast) {
41803
+ function emitPlainStatement(g5, source, stmt, indent4, isLast) {
41735
41804
  let text = stripTrailingSemicolons(source.slice(stmt.start, stmt.end).trimEnd());
41736
41805
  if (text === "") return;
41737
- g4.add(indent4);
41738
- g4.add(text, stmt.start, stmt.end);
41739
- if (!text.endsWith("}") && !isLast) g4.addRaw(";");
41806
+ g5.add(indent4);
41807
+ g5.add(text, stmt.start, stmt.end);
41808
+ if (!text.endsWith("}") && !isLast) g5.addRaw(";");
41740
41809
  }
41741
- function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
41810
+ function emitStatement(g5, source, stmt, indent4, isLast, opts, hoist) {
41742
41811
  switch (stmt.type) {
41743
41812
  case "JSXElement":
41744
41813
  if (getJSXTagName2(stmt) === "style") {
41745
41814
  const openEnd = stmt.openingElement?.end ?? stmt.start;
41746
41815
  const closeStart = stmt.closingElement?.start ?? stmt.end;
41747
- g4.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
41816
+ g5.recordStyle(stmt.start, stmt.end, source.slice(openEnd, closeStart));
41748
41817
  return;
41749
41818
  }
41750
- g4.add(indent4);
41751
- emitJSXElement(g4, source, stmt, opts, hoist);
41752
- if (!isLast) g4.addRaw(";");
41819
+ g5.add(indent4);
41820
+ emitJSXElement(g5, source, stmt, opts, hoist);
41821
+ if (!isLast) g5.addRaw(";");
41753
41822
  return;
41754
41823
  case "JSXFragment":
41755
- g4.add(indent4);
41756
- emitJSXFragment(g4, source, stmt, opts, hoist);
41757
- if (!isLast) g4.addRaw(";");
41824
+ g5.add(indent4);
41825
+ emitJSXFragment(g5, source, stmt, opts, hoist);
41826
+ if (!isLast) g5.addRaw(";");
41758
41827
  return;
41759
41828
  case "JSXExpressionContainer": {
41760
41829
  if (stmt.expression.type === "JSXEmptyExpression") return;
41761
- g4.add(indent4);
41762
- g4.addRaw("{");
41763
- g4.add(source.slice(stmt.expression.start, stmt.expression.end), stmt.expression.start, stmt.expression.end);
41764
- g4.addRaw("}");
41765
- if (!isLast) g4.addRaw(";");
41830
+ g5.add(indent4);
41831
+ g5.addRaw("{");
41832
+ g5.add(source.slice(stmt.expression.start, stmt.expression.end), stmt.expression.start, stmt.expression.end);
41833
+ g5.addRaw("}");
41834
+ if (!isLast) g5.addRaw(";");
41766
41835
  return;
41767
41836
  }
41768
41837
  case "VeskBlock": {
@@ -41770,10 +41839,10 @@ function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
41770
41839
  const innerStmts = stmt.body ?? [];
41771
41840
  let firstLine = true;
41772
41841
  for (let i = 0; i < innerStmts.length; i++) {
41773
- const before = g4.code.length;
41774
- emitStatement(g4, source, innerStmts[i], indent4, isLast && i === innerStmts.length - 1, opts, hoist);
41775
- if (g4.code.length > before) {
41776
- if (!firstLine) g4.addRaw("\n");
41842
+ const before = g5.code.length;
41843
+ emitStatement(g5, source, innerStmts[i], indent4, isLast && i === innerStmts.length - 1, opts, hoist);
41844
+ if (g5.code.length > before) {
41845
+ if (!firstLine) g5.addRaw("\n");
41777
41846
  firstLine = false;
41778
41847
  }
41779
41848
  }
@@ -41781,38 +41850,38 @@ function emitStatement(g4, source, stmt, indent4, isLast, opts, hoist) {
41781
41850
  }
41782
41851
  case "VariableDeclaration":
41783
41852
  if (isTrackDeclStatement(stmt)) {
41784
- emitTrackDeclStatement(g4, source, stmt, indent4, isLast, opts);
41853
+ emitTrackDeclStatement(g5, source, stmt, indent4, isLast, opts);
41785
41854
  return;
41786
41855
  }
41787
- return emitPlainStatement(g4, source, stmt, indent4, isLast);
41856
+ return emitPlainStatement(g5, source, stmt, indent4, isLast);
41788
41857
  case "IfStatement":
41789
- return emitIf(g4, source, stmt, indent4, opts);
41858
+ return emitIf(g5, source, stmt, indent4, opts);
41790
41859
  case "ForOfStatement":
41791
- return emitForOf(g4, source, stmt, indent4, opts);
41860
+ return emitForOf(g5, source, stmt, indent4, opts);
41792
41861
  case "ForInStatement":
41793
- return emitForIn(g4, source, stmt, indent4, opts);
41862
+ return emitForIn(g5, source, stmt, indent4, opts);
41794
41863
  case "ForStatement":
41795
- return emitFor(g4, source, stmt, indent4, opts);
41864
+ return emitFor(g5, source, stmt, indent4, opts);
41796
41865
  case "WhileStatement":
41797
- return emitWhile(g4, source, stmt, indent4, opts);
41866
+ return emitWhile(g5, source, stmt, indent4, opts);
41798
41867
  case "DoWhileStatement":
41799
- return emitDoWhile(g4, source, stmt, indent4, opts);
41868
+ return emitDoWhile(g5, source, stmt, indent4, opts);
41800
41869
  case "SwitchStatement":
41801
- return emitSwitch(g4, source, stmt, indent4, opts);
41870
+ return emitSwitch(g5, source, stmt, indent4, opts);
41802
41871
  case "TryStatement":
41803
- return emitTry(g4, source, stmt, indent4, opts);
41872
+ return emitTry(g5, source, stmt, indent4, opts);
41804
41873
  case "LabeledStatement": {
41805
- g4.add(indent4);
41806
- g4.add(stmt.label.name, stmt.label.start, stmt.label.end);
41807
- g4.addRaw(":\n");
41808
- emitStatement(g4, source, stmt.body, indent4, isLast, opts);
41874
+ g5.add(indent4);
41875
+ g5.add(stmt.label.name, stmt.label.start, stmt.label.end);
41876
+ g5.addRaw(":\n");
41877
+ emitStatement(g5, source, stmt.body, indent4, isLast, opts);
41809
41878
  return;
41810
41879
  }
41811
41880
  default:
41812
- return emitPlainStatement(g4, source, stmt, indent4, isLast);
41881
+ return emitPlainStatement(g5, source, stmt, indent4, isLast);
41813
41882
  }
41814
41883
  }
41815
- function emitBody(g4, source, stmts, indent4, opts, hoist) {
41884
+ function emitBody(g5, source, stmts, indent4, opts, hoist) {
41816
41885
  let firstLine = true;
41817
41886
  let i = 0;
41818
41887
  while (i < stmts.length) {
@@ -41820,34 +41889,34 @@ function emitBody(g4, source, stmts, indent4, opts, hoist) {
41820
41889
  const isLast = i === stmts.length - 1;
41821
41890
  if (stmt.type === "ForOfStatement" && stmts[i + 1] && stmts[i + 1].type === "VeskBlock" && stmts[i + 1].tag === "empty") {
41822
41891
  const empty2 = stmts[i + 1];
41823
- if (!firstLine) g4.addRaw("\n");
41892
+ if (!firstLine) g5.addRaw("\n");
41824
41893
  firstLine = false;
41825
- emitForOf(g4, source, stmt, indent4, opts);
41894
+ emitForOf(g5, source, stmt, indent4, opts);
41826
41895
  const inner = empty2.body ?? [];
41827
41896
  if (inner.length > 0) {
41828
- g4.addRaw("\n");
41829
- g4.add(indent4);
41830
- g4.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41831
- g4.addRaw(".length === 0 && (() => {");
41832
- g4.addRaw("\n");
41833
- emitBody(g4, source, inner, indent4 + " ", opts);
41834
- g4.addRaw("\n");
41835
- g4.add(indent4);
41836
- g4.addRaw("})();");
41897
+ g5.addRaw("\n");
41898
+ g5.add(indent4);
41899
+ g5.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
41900
+ g5.addRaw(".length === 0 && (() => {");
41901
+ g5.addRaw("\n");
41902
+ emitBody(g5, source, inner, indent4 + " ", opts);
41903
+ g5.addRaw("\n");
41904
+ g5.add(indent4);
41905
+ g5.addRaw("})();");
41837
41906
  }
41838
41907
  i += 2;
41839
41908
  continue;
41840
41909
  }
41841
- const before = g4.code.length;
41842
- emitStatement(g4, source, stmt, indent4, isLast, opts, hoist);
41843
- if (g4.code.length > before) {
41844
- if (!firstLine) g4.addRaw("\n");
41910
+ const before = g5.code.length;
41911
+ emitStatement(g5, source, stmt, indent4, isLast, opts, hoist);
41912
+ if (g5.code.length > before) {
41913
+ if (!firstLine) g5.addRaw("\n");
41845
41914
  firstLine = false;
41846
41915
  }
41847
41916
  i++;
41848
41917
  }
41849
41918
  }
41850
- function emitChunkMapped(g4, source, start, end) {
41919
+ function emitChunkMapped(g5, source, start, end) {
41851
41920
  if (end <= start) return;
41852
41921
  let pos = start;
41853
41922
  let i = start;
@@ -41859,8 +41928,8 @@ function emitChunkMapped(g4, source, start, end) {
41859
41928
  if (openEnd !== -1 && openEnd <= end) {
41860
41929
  const closeIdx = source.indexOf("</style>", openEnd);
41861
41930
  if (closeIdx !== -1 && closeIdx + 8 <= end) {
41862
- g4.add(source.slice(pos, i), pos, i);
41863
- g4.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
41931
+ g5.add(source.slice(pos, i), pos, i);
41932
+ g5.recordStyle(i, closeIdx + 8, source.slice(openEnd, closeIdx));
41864
41933
  pos = closeIdx + 8;
41865
41934
  i = closeIdx + 8;
41866
41935
  continue;
@@ -41870,20 +41939,20 @@ function emitChunkMapped(g4, source, start, end) {
41870
41939
  }
41871
41940
  i++;
41872
41941
  }
41873
- g4.add(source.slice(pos, end), pos, end);
41942
+ g5.add(source.slice(pos, end), pos, end);
41874
41943
  }
41875
- function emitReturn(g4, source, stmt, opts) {
41876
- g4.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
41944
+ function emitReturn(g5, source, stmt, opts) {
41945
+ g5.add(source.slice(stmt.start, stmt.start + 6), stmt.start, stmt.start + 6);
41877
41946
  const arg = stmt.argument;
41878
41947
  if (!arg) {
41879
- emitChunkMapped(g4, source, stmt.start + 6, stmt.end);
41948
+ emitChunkMapped(g5, source, stmt.start + 6, stmt.end);
41880
41949
  return;
41881
41950
  }
41882
- emitChunkMapped(g4, source, stmt.start + 6, arg.start);
41883
- if (arg.type === "JSXElement") emitJSXElement(g4, source, arg, opts);
41884
- else if (arg.type === "JSXFragment") emitJSXFragment(g4, source, arg, opts);
41885
- else emitChunkMapped(g4, source, arg.start, arg.end);
41886
- emitChunkMapped(g4, source, arg.end, stmt.end);
41951
+ emitChunkMapped(g5, source, stmt.start + 6, arg.start);
41952
+ if (arg.type === "JSXElement") emitJSXElement(g5, source, arg, opts);
41953
+ else if (arg.type === "JSXFragment") emitJSXFragment(g5, source, arg, opts);
41954
+ else emitChunkMapped(g5, source, arg.start, arg.end);
41955
+ emitChunkMapped(g5, source, arg.end, stmt.end);
41887
41956
  }
41888
41957
  function collectHoistEligible(children, set2, list) {
41889
41958
  for (const child of children ?? []) {
@@ -41903,7 +41972,7 @@ function collectHoistEligible(children, set2, list) {
41903
41972
  }
41904
41973
  }
41905
41974
  }
41906
- function emitBodyCore(g4, source, stmts, opts) {
41975
+ function emitBodyCore(g5, source, stmts, opts) {
41907
41976
  const hoistSet = /* @__PURE__ */ new Set();
41908
41977
  const byRoot = /* @__PURE__ */ new Map();
41909
41978
  const collectRoot = (root3) => {
@@ -41954,107 +42023,107 @@ function emitBodyCore(g4, source, stmts, opts) {
41954
42023
  byRoot.delete(u.node);
41955
42024
  const n = list.length;
41956
42025
  for (let k = 0; k < n; k++) {
41957
- const before2 = g4.code.length;
41958
- emitStatement(g4, source, list[k], "", false, opts, ctx2);
41959
- if (g4.code.length > before2) g4.addRaw("\n");
42026
+ const before2 = g5.code.length;
42027
+ emitStatement(g5, source, list[k], "", false, opts, ctx2);
42028
+ if (g5.code.length > before2) g5.addRaw("\n");
41960
42029
  }
41961
42030
  }
41962
42031
  }
41963
42032
  if (u.empty !== void 0) {
41964
- emitForOf(g4, source, u.node, "", opts);
42033
+ emitForOf(g5, source, u.node, "", opts);
41965
42034
  const inner = u.empty.body ?? [];
41966
42035
  if (inner.length > 0) {
41967
- g4.addRaw("\n");
41968
- g4.add("");
41969
- g4.add(
42036
+ g5.addRaw("\n");
42037
+ g5.add("");
42038
+ g5.add(
41970
42039
  source.slice(u.node.right.start, u.node.right.end),
41971
42040
  u.node.right.start,
41972
42041
  u.node.right.end
41973
42042
  );
41974
- g4.addRaw(".length === 0 && (() => {");
41975
- g4.addRaw("\n");
41976
- emitBody(g4, source, inner, " ", opts);
41977
- g4.addRaw("\n");
41978
- g4.add("");
41979
- g4.addRaw("})();");
42043
+ g5.addRaw(".length === 0 && (() => {");
42044
+ g5.addRaw("\n");
42045
+ emitBody(g5, source, inner, " ", opts);
42046
+ g5.addRaw("\n");
42047
+ g5.add("");
42048
+ g5.addRaw("})();");
41980
42049
  }
41981
42050
  return;
41982
42051
  }
41983
- const before = g4.code.length;
41984
- emitStatement(g4, source, u.node, "", isLast, opts, ctx2);
41985
- if (g4.code.length > before && !isLast) g4.addRaw("\n");
42052
+ const before = g5.code.length;
42053
+ emitStatement(g5, source, u.node, "", isLast, opts, ctx2);
42054
+ if (g5.code.length > before && !isLast) g5.addRaw("\n");
41986
42055
  };
41987
42056
  for (let i = 0; i < units.length; i++) {
41988
42057
  emitUnit(units[i], i === units.length - 1);
41989
42058
  }
41990
42059
  }
41991
- function emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts) {
42060
+ function emitExpressionBody(g5, source, coreStart, coreEnd, stmts, opts) {
41992
42061
  let pos = coreStart;
41993
42062
  for (const stmt of stmts) {
41994
42063
  if (!stmt) continue;
41995
- emitChunkMapped(g4, source, pos, stmt.start);
42064
+ emitChunkMapped(g5, source, pos, stmt.start);
41996
42065
  pos = stmt.start;
41997
42066
  if (isTrackDeclStatement(stmt)) {
41998
- emitTrackDeclStatement(g4, source, stmt, "", true, opts);
42067
+ emitTrackDeclStatement(g5, source, stmt, "", true, opts);
41999
42068
  } else if (stmt.type === "ReturnStatement") {
42000
- emitReturn(g4, source, stmt, opts);
42069
+ emitReturn(g5, source, stmt, opts);
42001
42070
  } else {
42002
- emitChunkMapped(g4, source, stmt.start, stmt.end);
42071
+ emitChunkMapped(g5, source, stmt.start, stmt.end);
42003
42072
  }
42004
42073
  pos = stmt.end;
42005
42074
  }
42006
- emitChunkMapped(g4, source, pos, coreEnd);
42075
+ emitChunkMapped(g5, source, pos, coreEnd);
42007
42076
  }
42008
- function emitRestMapped(g4, text, base, end) {
42077
+ function emitRestMapped(g5, text, base, end) {
42009
42078
  let i = 0;
42010
42079
  while (i < text.length && !isIdentStart(text[i])) i++;
42011
42080
  if (i >= text.length) {
42012
- g4.add(text, base, end);
42081
+ g5.add(text, base, end);
42013
42082
  return;
42014
42083
  }
42015
42084
  let j = i + 1;
42016
42085
  while (j < text.length && isIdentChar(text[j])) j++;
42017
- g4.add(text.slice(0, i), base, base + i);
42018
- g4.add(text.slice(i, j), base + i, base + j);
42019
- g4.add(text.slice(j), base + j, end);
42086
+ g5.add(text.slice(0, i), base, base + i);
42087
+ g5.add(text.slice(i, j), base + i, base + j);
42088
+ g5.add(text.slice(j), base + j, end);
42020
42089
  }
42021
- function emitComponentHeader(g4, source, start, bodyStart) {
42090
+ function emitComponentHeader(g5, source, start, bodyStart) {
42022
42091
  const h = source.slice(start, bodyStart);
42023
42092
  const k = findFirstKeyword(h, "component");
42024
42093
  if (k === -1) {
42025
42094
  const { text, end: end2 } = stripTrailingClientRange(h);
42026
42095
  if (!text.includes("(")) {
42027
42096
  const trimmed = text.trimEnd();
42028
- g4.add(trimmed, start, start + end2 - (text.length - trimmed.length));
42029
- g4.addRaw("() ");
42097
+ g5.add(trimmed, start, start + end2 - (text.length - trimmed.length));
42098
+ g5.addRaw("() ");
42030
42099
  } else {
42031
- g4.add(text, start, start + end2);
42100
+ g5.add(text, start, start + end2);
42032
42101
  }
42033
42102
  return;
42034
42103
  }
42035
- g4.add(h.slice(0, k), start, start + k);
42036
- g4.add("function", start + k, start + k + "component".length);
42104
+ g5.add(h.slice(0, k), start, start + k);
42105
+ g5.add("function", start + k, start + k + "component".length);
42037
42106
  const restBase = start + k + "component".length;
42038
42107
  const { text: rest, end } = stripTrailingClientRange(h.slice(k + "component".length));
42039
42108
  const transformed = h.slice(0, k) + "function" + rest;
42040
42109
  if (!transformed.includes("(")) {
42041
42110
  const trimmed = rest.trimEnd();
42042
- emitRestMapped(g4, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
42043
- g4.addRaw("() ");
42111
+ emitRestMapped(g5, trimmed, restBase, restBase + end - (rest.length - trimmed.length));
42112
+ g5.addRaw("() ");
42044
42113
  } else {
42045
- emitRestMapped(g4, rest, restBase, restBase + end);
42114
+ emitRestMapped(g5, rest, restBase, restBase + end);
42046
42115
  }
42047
42116
  }
42048
- function emitComponent(g4, source, node, start, opts) {
42117
+ function emitComponent(g5, source, node, start, opts) {
42049
42118
  const body = node.body;
42050
42119
  if (!body || body.start == null || body.end == null) return;
42051
- emitComponentHeader(g4, source, start, body.start);
42120
+ emitComponentHeader(g5, source, start, body.start);
42052
42121
  const statementMode = isStatementMode2(node);
42053
42122
  const stmts = body.body ?? [];
42054
42123
  if (statementMode) {
42055
- g4.addRaw("{ ");
42056
- emitBodyCore(g4, source, stmts, opts);
42057
- g4.addRaw(" }");
42124
+ g5.addRaw("{ ");
42125
+ emitBodyCore(g5, source, stmts, opts);
42126
+ g5.addRaw(" }");
42058
42127
  } else {
42059
42128
  const raw2 = source.slice(body.start, body.end);
42060
42129
  const rawLen = raw2.length;
@@ -42074,9 +42143,9 @@ function emitComponent(g4, source, node, start, opts) {
42074
42143
  }
42075
42144
  while (coreStart < coreEnd && isWhitespaceChar(source[coreStart])) coreStart++;
42076
42145
  while (coreEnd > coreStart && isWhitespaceChar(source[coreEnd - 1])) coreEnd--;
42077
- if (hasBraces) g4.addRaw("{ ");
42078
- emitExpressionBody(g4, source, coreStart, coreEnd, stmts, opts);
42079
- if (hasBraces) g4.addRaw(" }");
42146
+ if (hasBraces) g5.addRaw("{ ");
42147
+ emitExpressionBody(g5, source, coreStart, coreEnd, stmts, opts);
42148
+ if (hasBraces) g5.addRaw(" }");
42080
42149
  }
42081
42150
  }
42082
42151
  function isModuleAst(ast) {
@@ -42106,26 +42175,26 @@ function compileVskCodegen(source, opts = {}) {
42106
42175
  };
42107
42176
  }
42108
42177
  const clean = blankForClauses(source, ast);
42109
- const g4 = new VskGen();
42178
+ const g5 = new VskGen();
42110
42179
  const components = getComponents(ast).sort((a, b) => a.start - b.start);
42111
42180
  let pos = 0;
42112
42181
  for (const { node, start } of components) {
42113
42182
  const body = node.body;
42114
42183
  if (!body || body.start == null || body.end == null) continue;
42115
- g4.add(clean.slice(pos, start), pos, start);
42116
- emitComponent(g4, clean, node, start, opts);
42184
+ g5.add(clean.slice(pos, start), pos, start);
42185
+ emitComponent(g5, clean, node, start, opts);
42117
42186
  pos = body.end;
42118
42187
  }
42119
- g4.add(clean.slice(pos), pos, source.length);
42120
- let code = g4.code;
42188
+ g5.add(clean.slice(pos), pos, source.length);
42189
+ let code = g5.code;
42121
42190
  if (isModuleAst(ast) && containsIdentifier(code, "Head") && !isIdentifierImported(code, "Head")) {
42122
- g4.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
42123
- code = g4.code;
42191
+ g5.prepend("declare const Head: (props: { children?: Component }) => Component;\n");
42192
+ code = g5.code;
42124
42193
  }
42125
42194
  if (!isModuleAst(ast)) {
42126
42195
  code += "\nexport {};\n";
42127
42196
  }
42128
- return { code, mappings: g4.mappings, styleRegions: g4.styleRegions, errors: [] };
42197
+ return { code, mappings: g5.mappings, styleRegions: g5.styleRegions, errors: [] };
42129
42198
  }
42130
42199
  function isTypeDecl(stmt) {
42131
42200
  return stmt.type === "TSInterfaceDeclaration" || stmt.type === "TSTypeAliasDeclaration" || stmt.type === "ExportNamedDeclaration" && (stmt.declaration?.type === "TSInterfaceDeclaration" || stmt.declaration?.type === "TSTypeAliasDeclaration");
@@ -48830,25 +48899,25 @@ function runMigrate(options) {
48830
48899
  }
48831
48900
  const applicable = codemods.filter((c) => c.appliesTo(abs));
48832
48901
  if (applicable.length === 0) continue;
48833
- let current2 = source;
48902
+ let current3 = source;
48834
48903
  let changed = false;
48835
48904
  for (const codemod of applicable) {
48836
48905
  let result;
48837
48906
  try {
48838
- result = codemod.run(current2, ctx2);
48907
+ result = codemod.run(current3, ctx2);
48839
48908
  } catch (e) {
48840
48909
  report.skipped.push(`${relPath}: ${codemod.id} failed (${e.message})`);
48841
48910
  continue;
48842
48911
  }
48843
48912
  report.notes.push(...result.notes);
48844
- if (result.code !== null && result.code !== current2) {
48845
- current2 = result.code;
48913
+ if (result.code !== null && result.code !== current3) {
48914
+ current3 = result.code;
48846
48915
  changed = true;
48847
48916
  }
48848
48917
  }
48849
48918
  if (!changed) continue;
48850
48919
  report.filesChanged.push(relPath);
48851
- if (!options.dryRun) writeFileSync22(abs, current2, "utf-8");
48920
+ if (!options.dryRun) writeFileSync22(abs, current3, "utf-8");
48852
48921
  }
48853
48922
  return report;
48854
48923
  }
@@ -51245,9 +51314,9 @@ var ChunkImports = class {
51245
51314
  this.fail(`nameless named-import from '${source}' in ${filePath}`, code);
51246
51315
  return false;
51247
51316
  }
51248
- const existing = group.named.get(imported);
51249
- if (existing && existing.local !== local) {
51250
- this.fail(`'${imported}' from '${source}' bound to both '${existing.local}' and '${local}' in ${filePath}`, code);
51317
+ const existing2 = group.named.get(imported);
51318
+ if (existing2 && existing2.local !== local) {
51319
+ this.fail(`'${imported}' from '${source}' bound to both '${existing2.local}' and '${local}' in ${filePath}`, code);
51251
51320
  return false;
51252
51321
  }
51253
51322
  group.named.set(imported, { kind: "named", local, imported });
@@ -51282,11 +51351,11 @@ var ChunkImports = class {
51282
51351
  const lines = [];
51283
51352
  const sources = [...this.bySource.keys()].sort();
51284
51353
  for (const src2 of sources) {
51285
- const g4 = this.bySource.get(src2);
51354
+ const g5 = this.bySource.get(src2);
51286
51355
  const parts = [];
51287
- if (g4.default) parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
51288
- if (g4.namespace) parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
51289
- const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
51356
+ if (g5.default) parts.push(`import ${g5.default.local} from ${JSON.stringify(src2)}`);
51357
+ if (g5.namespace) parts.push(`import * as ${g5.namespace.local} from ${JSON.stringify(src2)}`);
51358
+ const named = [...g5.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
51290
51359
  if (named.length > 0) {
51291
51360
  const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
51292
51361
  parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
@@ -52537,6 +52606,34 @@ async function startProdServer(outDir, options) {
52537
52606
  }
52538
52607
  return origWriteHead(statusCode, headers2);
52539
52608
  });
52609
+ const securityBridge = globalThis.__vesk_security;
52610
+ const securityRun = securityBridge?.run;
52611
+ const withSecurityScope = securityRun ? (fn) => securityRun(fn) : (fn) => fn();
52612
+ const applyOverrideHeaders = (headers2) => {
52613
+ const overrides = securityBridge?.get?.();
52614
+ if (!overrides) return headers2;
52615
+ const next = { ...headers2 };
52616
+ if (typeof overrides.contentSecurityPolicy === "string") {
52617
+ next["Content-Security-Policy"] = overrides.contentSecurityPolicy;
52618
+ }
52619
+ const custom2 = overrides.customHeaders;
52620
+ if (custom2) {
52621
+ for (const [name, value] of Object.entries(custom2)) {
52622
+ if (value === false) delete next[name];
52623
+ else next[name] = value;
52624
+ }
52625
+ }
52626
+ return next;
52627
+ };
52628
+ const origWriteHead2 = res.writeHead.bind(res);
52629
+ let overridesApplied = false;
52630
+ res.writeHead = ((statusCode, headers2) => {
52631
+ if (!overridesApplied) {
52632
+ overridesApplied = true;
52633
+ headers2 = applyOverrideHeaders(headers2 || {});
52634
+ }
52635
+ return origWriteHead2(statusCode, headers2);
52636
+ });
52540
52637
  const publicDir = resolve13(staticDir, "public");
52541
52638
  const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
52542
52639
  if (rootFile && existsSync15(rootFile) && statSync6(rootFile).isFile()) {
@@ -52676,7 +52773,8 @@ async function startProdServer(outDir, options) {
52676
52773
  }
52677
52774
  try {
52678
52775
  const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
52679
- const response = await mod.handleAction(webRequest, actionId);
52776
+ const handleAction = mod.handleAction.bind(mod);
52777
+ const response = await withSecurityScope(() => handleAction(webRequest, actionId));
52680
52778
  await deliverResponse(res, response);
52681
52779
  } catch (e) {
52682
52780
  const status = errorStatus(e, 500);
@@ -52695,7 +52793,7 @@ async function startProdServer(outDir, options) {
52695
52793
  if (mod) {
52696
52794
  try {
52697
52795
  const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
52698
- const response = await mod.handle(webRequest);
52796
+ const response = await withSecurityScope(() => mod.handle(webRequest));
52699
52797
  await deliverResponse(res, response);
52700
52798
  return;
52701
52799
  } catch (e) {
@@ -52737,7 +52835,7 @@ async function startProdServer(outDir, options) {
52737
52835
  if (route.revalidate && route.revalidate > 0) {
52738
52836
  const { pageIsr: pageIsr2 } = await Promise.resolve().then(() => (init_index_server(), index_server_exports));
52739
52837
  cachedResult = await pageIsr2(url.pathname, async () => {
52740
- const response2 = await mod.handle(webRequest);
52838
+ const response2 = await withSecurityScope(() => mod.handle(webRequest));
52741
52839
  return { html: await response2.text(), headers: Object.fromEntries(response2.headers) };
52742
52840
  }, { revalidate: route.revalidate, tags: route.tags || [] });
52743
52841
  }
@@ -52746,7 +52844,7 @@ async function startProdServer(outDir, options) {
52746
52844
  res.end(cachedResult.html);
52747
52845
  return;
52748
52846
  }
52749
- const response = await mod.handle(webRequest);
52847
+ const response = await withSecurityScope(() => mod.handle(webRequest));
52750
52848
  const headers2 = Object.fromEntries(response.headers);
52751
52849
  if (!headers2["content-type"] && !headers2["Content-Type"]) headers2["Content-Type"] = "text/html";
52752
52850
  if (response.body && typeof response.body.getReader === "function") {
@@ -53501,8 +53599,8 @@ init_index_server();
53501
53599
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
53502
53600
  var TOKEN_KEY2 = "__vsk_ssr_token";
53503
53601
  var IMPL_KEY2 = "__vsk_ssr_store_impl";
53504
- var g3 = globalThis;
53505
- var impl2 = g3[IMPL_KEY2] ?? (g3[IMPL_KEY2] = {
53602
+ var g4 = globalThis;
53603
+ var impl2 = g4[IMPL_KEY2] ?? (g4[IMPL_KEY2] = {
53506
53604
  storage: new AsyncLocalStorage2(),
53507
53605
  liveSlots: /* @__PURE__ */ new Map(),
53508
53606
  // Only the copy that created the implementation installs the token
@@ -53521,8 +53619,8 @@ function isThenable2(value) {
53521
53619
  return typeof value?.then === "function";
53522
53620
  }
53523
53621
  function withSsrStore2(fn) {
53524
- const existing = storage2.getStore();
53525
- if (existing)
53622
+ const existing2 = storage2.getStore();
53623
+ if (existing2)
53526
53624
  return fn();
53527
53625
  const store = createSsrStore3();
53528
53626
  keepSsrSlot2(store.token);
@@ -57709,9 +57807,9 @@ var ChunkImports2 = class {
57709
57807
  this.fail(`nameless named-import from '${source}' in ${filePath}`, code);
57710
57808
  return false;
57711
57809
  }
57712
- const existing = group.named.get(imported);
57713
- if (existing && existing.local !== local) {
57714
- this.fail(`'${imported}' from '${source}' bound to both '${existing.local}' and '${local}' in ${filePath}`, code);
57810
+ const existing2 = group.named.get(imported);
57811
+ if (existing2 && existing2.local !== local) {
57812
+ this.fail(`'${imported}' from '${source}' bound to both '${existing2.local}' and '${local}' in ${filePath}`, code);
57715
57813
  return false;
57716
57814
  }
57717
57815
  group.named.set(imported, { kind: "named", local, imported });
@@ -57748,13 +57846,13 @@ var ChunkImports2 = class {
57748
57846
  const lines = [];
57749
57847
  const sources = [...this.bySource.keys()].sort();
57750
57848
  for (const src2 of sources) {
57751
- const g4 = this.bySource.get(src2);
57849
+ const g5 = this.bySource.get(src2);
57752
57850
  const parts = [];
57753
- if (g4.default)
57754
- parts.push(`import ${g4.default.local} from ${JSON.stringify(src2)}`);
57755
- if (g4.namespace)
57756
- parts.push(`import * as ${g4.namespace.local} from ${JSON.stringify(src2)}`);
57757
- const named = [...g4.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
57851
+ if (g5.default)
57852
+ parts.push(`import ${g5.default.local} from ${JSON.stringify(src2)}`);
57853
+ if (g5.namespace)
57854
+ parts.push(`import * as ${g5.namespace.local} from ${JSON.stringify(src2)}`);
57855
+ const named = [...g5.named.values()].sort((a, b) => a.imported < b.imported ? -1 : 1);
57758
57856
  if (named.length > 0) {
57759
57857
  const specs = named.map((sp) => sp.imported === sp.local ? sp.local : `${sp.imported} as ${sp.local}`).join(", ");
57760
57858
  parts.push(`import { ${specs} } from ${JSON.stringify(src2)}`);
@@ -58973,9 +59071,9 @@ function getPluginRecords2(appDir, veskDir, configPluginNames) {
58973
59071
  }
58974
59072
  function setPluginActive2(veskDir, name, active) {
58975
59073
  const state = readPluginState2(veskDir);
58976
- const existing = state.plugins.find((p) => eqIgnoreCase2(p.name, name));
58977
- if (existing) {
58978
- existing.active = active;
59074
+ const existing2 = state.plugins.find((p) => eqIgnoreCase2(p.name, name));
59075
+ if (existing2) {
59076
+ existing2.active = active;
58979
59077
  } else {
58980
59078
  state.plugins.push({ name, package: name, active });
58981
59079
  }
@@ -59062,11 +59160,11 @@ async function installPlugin2(appDir, veskDir, pkg) {
59062
59160
  }
59063
59161
  const state = readPluginState2(veskDir);
59064
59162
  const name = probe.packageJson?.name || pkg;
59065
- const existing = state.plugins.find((p) => eqIgnoreCase2(p.package, pkg) || eqIgnoreCase2(p.name, name));
59066
- if (existing) {
59067
- existing.package = pkg;
59068
- existing.name = name;
59069
- existing.active = true;
59163
+ const existing2 = state.plugins.find((p) => eqIgnoreCase2(p.package, pkg) || eqIgnoreCase2(p.name, name));
59164
+ if (existing2) {
59165
+ existing2.package = pkg;
59166
+ existing2.name = name;
59167
+ existing2.active = true;
59070
59168
  } else {
59071
59169
  state.plugins.push({ name, package: pkg, active: true });
59072
59170
  }
@@ -59098,10 +59196,10 @@ async function updatePlugin2(appDir, veskDir, pkg) {
59098
59196
  const probe = resolvePackage2(appDir, pkg);
59099
59197
  const state = readPluginState2(veskDir);
59100
59198
  const name = probe.packageJson?.name || pkg;
59101
- const existing = state.plugins.find((p) => eqIgnoreCase2(p.package, pkg) || eqIgnoreCase2(p.name, name));
59102
- if (existing) {
59103
- existing.package = pkg;
59104
- existing.name = name;
59199
+ const existing2 = state.plugins.find((p) => eqIgnoreCase2(p.package, pkg) || eqIgnoreCase2(p.name, name));
59200
+ if (existing2) {
59201
+ existing2.package = pkg;
59202
+ existing2.name = name;
59105
59203
  } else {
59106
59204
  state.plugins.push({ name, package: pkg, active: true });
59107
59205
  }
@@ -59110,7 +59208,7 @@ async function updatePlugin2(appDir, veskDir, pkg) {
59110
59208
  name,
59111
59209
  pkg,
59112
59210
  source: "state",
59113
- activeRaw: existing ? existing.active : true,
59211
+ activeRaw: existing2 ? existing2.active : true,
59114
59212
  error: null
59115
59213
  }, appDir);
59116
59214
  }
@@ -61445,8 +61543,8 @@ function loadAgenticConfig(projectDir) {
61445
61543
  }
61446
61544
  function saveAgenticConfig(projectDir, patch) {
61447
61545
  const p = configPath(projectDir);
61448
- const current2 = loadAgenticConfig(projectDir);
61449
- const next = { ...DEFAULT_CONFIG, ...current2, ...patch };
61546
+ const current3 = loadAgenticConfig(projectDir);
61547
+ const next = { ...DEFAULT_CONFIG, ...current3, ...patch };
61450
61548
  const toWrite = { provider: next.provider, model: next.model, mode: next.mode, maxSteps: next.maxSteps };
61451
61549
  if (next.baseUrl)
61452
61550
  toWrite.baseUrl = next.baseUrl;
@@ -63186,11 +63284,11 @@ function createVeskTools(deps) {
63186
63284
  const contained = resolveWithin3(projectDir, info.path.slice(projectDir.length + 1));
63187
63285
  if (!contained)
63188
63286
  return jsonError("path escapes project root");
63189
- const current2 = readFileSync32(info.path, "utf-8");
63190
- const patched = applySimpleConfigToggle(current2, key, a.value);
63287
+ const current3 = readFileSync32(info.path, "utf-8");
63288
+ const patched = applySimpleConfigToggle(current3, key, a.value);
63191
63289
  if (patched === null)
63192
63290
  return jsonError("could not safely edit the config object; use the source editor");
63193
- if (patched === current2)
63291
+ if (patched === current3)
63194
63292
  return jsonOk({ ok: true, path: info.path, source: patched, unchanged: true });
63195
63293
  writeFileSync18(info.path, patched, "utf-8");
63196
63294
  return jsonOk({ ok: true, path: info.path, source: patched });
@@ -63320,11 +63418,11 @@ function createVeskTools(deps) {
63320
63418
  const at2 = pkg.lastIndexOf("@");
63321
63419
  if (at2 > 0)
63322
63420
  name = pkg.slice(0, at2);
63323
- const existing = state.plugins.find((p) => eqIgnoreCase3(p.package, pkg) || eqIgnoreCase3(p.package, name) || eqIgnoreCase3(p.name, name));
63324
- if (existing) {
63325
- existing.package = pkg;
63326
- existing.name = name;
63327
- existing.active = true;
63421
+ const existing2 = state.plugins.find((p) => eqIgnoreCase3(p.package, pkg) || eqIgnoreCase3(p.package, name) || eqIgnoreCase3(p.name, name));
63422
+ if (existing2) {
63423
+ existing2.package = pkg;
63424
+ existing2.name = name;
63425
+ existing2.active = true;
63328
63426
  } else {
63329
63427
  state.plugins.push({ name, package: pkg, active: true });
63330
63428
  }
@@ -63385,9 +63483,9 @@ function createVeskTools(deps) {
63385
63483
  if (!name)
63386
63484
  return jsonError('missing "name" in body');
63387
63485
  const state = readPluginState3(veskDir);
63388
- const existing = state.plugins.find((p) => eqIgnoreCase3(p.name, name) || eqIgnoreCase3(p.package, name));
63389
- if (existing) {
63390
- existing.active = true;
63486
+ const existing2 = state.plugins.find((p) => eqIgnoreCase3(p.name, name) || eqIgnoreCase3(p.package, name));
63487
+ if (existing2) {
63488
+ existing2.active = true;
63391
63489
  } else {
63392
63490
  state.plugins.push({ name, package: name, active: true });
63393
63491
  }
@@ -63417,9 +63515,9 @@ function createVeskTools(deps) {
63417
63515
  if (!name)
63418
63516
  return jsonError('missing "name" in body');
63419
63517
  const state = readPluginState3(veskDir);
63420
- const existing = state.plugins.find((p) => eqIgnoreCase3(p.name, name) || eqIgnoreCase3(p.package, name));
63421
- if (existing) {
63422
- existing.active = false;
63518
+ const existing2 = state.plugins.find((p) => eqIgnoreCase3(p.name, name) || eqIgnoreCase3(p.package, name));
63519
+ if (existing2) {
63520
+ existing2.active = false;
63423
63521
  } else {
63424
63522
  state.plugins.push({ name, package: name, active: false });
63425
63523
  }
@@ -63494,8 +63592,8 @@ function createVeskTools(deps) {
63494
63592
  return jsonError("invalid checkpointId");
63495
63593
  }
63496
63594
  try {
63497
- const existing = getCheckpoint(projectDir, checkpointId);
63498
- if (existing) {
63595
+ const existing2 = getCheckpoint(projectDir, checkpointId);
63596
+ if (existing2) {
63499
63597
  const rolled = rollback(projectDir, checkpointId);
63500
63598
  if (rolled)
63501
63599
  return jsonOk({ ok: true, checkpointId, checkpoint: rolled, rolledBack: true });
@@ -64430,10 +64528,10 @@ function parseCookies3(str3) {
64430
64528
  // ../runtime/dist/action.js
64431
64529
  var registryKey2 = "__vesk_actions";
64432
64530
  function getActionRegistry2() {
64433
- const g4 = globalThis;
64434
- if (!g4[registryKey2])
64435
- g4[registryKey2] = {};
64436
- return g4[registryKey2];
64531
+ const g5 = globalThis;
64532
+ if (!g5[registryKey2])
64533
+ g5[registryKey2] = {};
64534
+ return g5[registryKey2];
64437
64535
  }
64438
64536
  function getAction2(id) {
64439
64537
  return getActionRegistry2()[id] || null;
@@ -65089,9 +65187,9 @@ function storeDataScript(payload) {
65089
65187
  return "/_vesk/ssr-data.js?t=" + token;
65090
65188
  }
65091
65189
  function currentSsrData() {
65092
- const g4 = globalThis;
65093
- const token = g4.__vsk_ssr_token;
65094
- const slot = (token ? g4[`__vsk_ssr_data_${token}`] : void 0) || {};
65190
+ const g5 = globalThis;
65191
+ const token = g5.__vsk_ssr_token;
65192
+ const slot = (token ? g5[`__vsk_ssr_data_${token}`] : void 0) || {};
65095
65193
  return { ...ssrSink3.snapshot() || {}, ...slot };
65096
65194
  }
65097
65195
  function countPages(nodes) {
@@ -65184,9 +65282,9 @@ async function startDevServer(port, projectDir, config, host) {
65184
65282
  }
65185
65283
  }
65186
65284
  function eventsStore() {
65187
- const g4 = globalThis;
65188
- if (!g4.__vesk_server_ctx) g4.__vesk_server_ctx = {};
65189
- return g4.__vesk_server_ctx;
65285
+ const g5 = globalThis;
65286
+ if (!g5.__vesk_server_ctx) g5.__vesk_server_ctx = {};
65287
+ return g5.__vesk_server_ctx;
65190
65288
  }
65191
65289
  function makeEventCtx(overrides) {
65192
65290
  const store = eventsStore();
@@ -65482,9 +65580,9 @@ async function startDevServer(port, projectDir, config, host) {
65482
65580
  function updateSourceMapping() {
65483
65581
  sourceToComponents.clear();
65484
65582
  for (const [compName, sourcePath2] of collectSources(routeTree)) {
65485
- const existing = sourceToComponents.get(sourcePath2) || [];
65486
- existing.push(compName);
65487
- sourceToComponents.set(sourcePath2, existing);
65583
+ const existing2 = sourceToComponents.get(sourcePath2) || [];
65584
+ existing2.push(compName);
65585
+ sourceToComponents.set(sourcePath2, existing2);
65488
65586
  }
65489
65587
  }
65490
65588
  updateSourceMapping();
@@ -65684,12 +65782,12 @@ async function startDevServer(port, projectDir, config, host) {
65684
65782
  debounceTimer = setTimeout(async () => {
65685
65783
  const t0 = Date.now();
65686
65784
  try {
65687
- const current2 = fileExists ? readFileSync38(fullPath, "utf-8") : null;
65688
- if (eventType !== "rename" && current2 !== null && lastSeenContent.get(fullPath) === current2) {
65785
+ const current3 = fileExists ? readFileSync38(fullPath, "utf-8") : null;
65786
+ if (eventType !== "rename" && current3 !== null && lastSeenContent.get(fullPath) === current3) {
65689
65787
  LOG.info(`skipped unchanged (${filename})`);
65690
65788
  return;
65691
65789
  }
65692
- lastSeenContent.set(fullPath, current2);
65790
+ lastSeenContent.set(fullPath, current3);
65693
65791
  if (typeof globalThis.__vesk_broadcastHmr === "function") {
65694
65792
  globalThis.__vesk_broadcastHmr({ type: "compiling" });
65695
65793
  }
@@ -65713,8 +65811,8 @@ async function startDevServer(port, projectDir, config, host) {
65713
65811
  if (treeChanged || isOutsideApp || fileDeleted) {
65714
65812
  await buildClientBundle();
65715
65813
  await bundleRuntime2();
65716
- } else if (fileExists && current2 !== null) {
65717
- let source = current2;
65814
+ } else if (fileExists && current3 !== null) {
65815
+ let source = current3;
65718
65816
  if (/content=["'][^"']*\.md["']/i.test(source)) {
65719
65817
  source = inlineMdContentAttrs2(source, dirname26(fullPath), guessProjectRoots2(appDirPath));
65720
65818
  }