@jay-framework/production-server 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-XSavezh8.js';
2
- export { A as ActionEntry, e as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, d as PageModule, P as PluginEntry, n as PreImportedPlugin, b as RouteSegment, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-XSavezh8.js';
1
+ import { B as BuildOptions, R as RouteManifest, a as RouteEntry } from './serve-index-Ccw8CNDg.js';
2
+ export { A as ActionEntry, b as ArtifactStore, c as BuildMetadata, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, P as PageModule, d as PluginEntry, e as PreImportedPlugin, f as RouteSegment, S as ServerElementModule, g as fetchActionRequest, h as fetchPageRequest, i as fetchStaticFile, j as initializeServices, k as initializeServicesFromModules, l as isActionRequest, m as matchRequest, r as registerActionsFromManifest, n as registerActionsFromModules } from './serve-index-Ccw8CNDg.js';
3
3
  import '@jay-framework/ssr-runtime';
4
4
  import '@jay-framework/compiler-shared';
5
5
  import '@jay-framework/stack-server-runtime';
package/dist/index.js CHANGED
@@ -6,8 +6,8 @@ import path from "node:path";
6
6
  import fs from "node:fs/promises";
7
7
  import { createRequire } from "node:module";
8
8
  import { DevSlowlyChangingPhase, slowRenderInstances, scanPlugins, runLoadParams, parseCookies } from "@jay-framework/stack-server-runtime";
9
- import { l as loadProductionPageParts, g as buildPagePartsConfig, d as initializeServices, r as registerActionsFromManifest, i as isActionRequest, a as fetchActionRequest, c as fetchStaticFile, m as matchRequest, f as fetchPageRequest, F as FilesystemArtifactStore } from "./init-services-AtDV4X1i.js";
10
- import { e, b } from "./init-services-AtDV4X1i.js";
9
+ import { l as loadProductionPageParts, g as buildPagePartsConfig, F as FilesystemArtifactStore, i as initializeServices, r as registerActionsFromManifest, d as isActionRequest, f as fetchActionRequest, b as fetchStaticFile, m as matchRequest, a as fetchPageRequest } from "./init-services-BVEuyIVG.js";
10
+ import { c, e } from "./init-services-BVEuyIVG.js";
11
11
  import crypto, { createHash } from "node:crypto";
12
12
  import fs$1 from "node:fs";
13
13
  import { jayRuntime } from "@jay-framework/vite-plugin";
@@ -18,8 +18,6 @@ import { transform } from "esbuild";
18
18
  import http from "node:http";
19
19
  import { Readable } from "node:stream";
20
20
  import { isJayWebhook } from "@jay-framework/fullstack-component";
21
- import "@jay-framework/view-state-merge";
22
- import "@jay-framework/ssr-runtime";
23
21
  async function discoverServerEntries(projectRoot, pagesRoot) {
24
22
  const logger = getLogger();
25
23
  const routes = await scanRoutes(pagesRoot, {
@@ -51,8 +49,7 @@ async function discoverServerEntries(projectRoot, pagesRoot) {
51
49
  try {
52
50
  const dirs = await fs.readdir(scanDir, { withFileTypes: true });
53
51
  for (const dir of dirs) {
54
- if (!dir.isDirectory())
55
- continue;
52
+ if (!dir.isDirectory()) continue;
56
53
  const dirPath = path.join(scanDir, dir.name);
57
54
  const files = await fs.readdir(dirPath);
58
55
  for (const file of files) {
@@ -194,8 +191,7 @@ async function parseViteManifest(outputDir, packages) {
194
191
  }
195
192
  const manifest = {};
196
193
  for (const [, entry] of Object.entries(raw)) {
197
- if (!entry.isEntry)
198
- continue;
194
+ if (!entry.isEntry) continue;
199
195
  const outputBase = path.basename(entry.file, ".js");
200
196
  for (const [varName, pkg] of varNameToPackage) {
201
197
  if (outputBase.startsWith(varName)) {
@@ -218,8 +214,7 @@ function hashParams(params, suffix) {
218
214
  {}
219
215
  );
220
216
  const json = JSON.stringify(sorted);
221
- if (json === "{}" && !suffix)
222
- return "";
217
+ if (json === "{}" && !suffix) return "";
223
218
  const input = suffix ? json + ":" + suffix : json;
224
219
  return "_" + crypto.createHash("md5").update(input).digest("hex").substring(0, 8);
225
220
  }
@@ -245,7 +240,7 @@ async function buildInstance(route, params, pageModule, ctx, routeServerElementP
245
240
  );
246
241
  const contracts = [
247
242
  .../* @__PURE__ */ new Set([
248
- ...pageParts.headlessInstanceComponents.map((c) => c.contractName),
243
+ ...pageParts.headlessInstanceComponents.map((c2) => c2.contractName),
249
244
  ...pageParts.parts.filter((p) => p.contractInfo?.contractName).map((p) => p.contractInfo.contractName)
250
245
  ])
251
246
  ];
@@ -401,8 +396,7 @@ async function discoverActions(actionPaths, serverOutputDir, buildDir, projectRo
401
396
  try {
402
397
  const scannedPlugins = await scanPlugins({ projectRoot });
403
398
  for (const [packageName, plugin] of scannedPlugins) {
404
- if (plugin.isLocal)
405
- continue;
399
+ if (plugin.isLocal) continue;
406
400
  plugins.push({ name: plugin.manifest.name, packageName });
407
401
  const pluginActions = plugin.manifest.actions;
408
402
  if (pluginActions && pluginActions.length > 0) {
@@ -438,10 +432,8 @@ async function scanPluginRoutes(projectRoot, projectRoutes) {
438
432
  const projectPaths = new Set(projectRoutes.map((r) => r.rawRoute));
439
433
  const pluginRoutes = [];
440
434
  for (const [, plugin] of plugins) {
441
- if (plugin.isLocal)
442
- continue;
443
- if (!plugin.manifest.routes)
444
- continue;
435
+ if (plugin.isLocal) continue;
436
+ if (!plugin.manifest.routes) continue;
445
437
  for (const route of plugin.manifest.routes) {
446
438
  if (projectPaths.has(route.path)) {
447
439
  logger.info(
@@ -484,8 +476,7 @@ function resolvePluginExport(pluginPath, exportSubpath) {
484
476
  const exportValue = packageJson.exports[exportKey];
485
477
  if (exportValue) {
486
478
  const resolved = typeof exportValue === "string" ? exportValue : exportValue.default || exportValue.import || exportValue.require;
487
- if (resolved)
488
- return path.join(pluginPath, resolved);
479
+ if (resolved) return path.join(pluginPath, resolved);
489
480
  }
490
481
  }
491
482
  } catch {
@@ -508,8 +499,7 @@ function resolvePluginModule(pluginPath) {
508
499
  const mainPath = typeof mainExport === "string" ? mainExport : mainExport?.default || mainExport?.import || pkg.main;
509
500
  if (mainPath) {
510
501
  const resolved = path.join(pluginPath, mainPath);
511
- if (fs$1.existsSync(resolved))
512
- return resolved;
502
+ if (fs$1.existsSync(resolved)) return resolved;
513
503
  }
514
504
  } catch {
515
505
  }
@@ -633,8 +623,7 @@ async function compileRouteHydrateScript(jayHtmlPath, outputDir, projectRoot, ts
633
623
  const manifest = JSON.parse(await fs.readFile(manifestPath, "utf-8"));
634
624
  await fs.rm(manifestPath, { force: true });
635
625
  const entryKey = Object.keys(manifest).find((k) => manifest[k].isEntry);
636
- if (!entryKey)
637
- throw new Error("No entry in route hydrate manifest");
626
+ if (!entryKey) throw new Error("No entry in route hydrate manifest");
638
627
  const jsFile = manifest[entryKey].file;
639
628
  getLogger().info(`[Build] Compiled route hydrate script: ${jsFile}`);
640
629
  return { jsFile };
@@ -649,8 +638,7 @@ function resolveJayHtmlPaths(html, sourceDir, targetDir) {
649
638
  if (val && (val.startsWith("./") || val.startsWith("../"))) {
650
639
  const abs = path.resolve(sourceDir, val);
651
640
  let rel = path.relative(targetDir, abs);
652
- if (!rel.startsWith("."))
653
- rel = "./" + rel;
641
+ if (!rel.startsWith(".")) rel = "./" + rel;
654
642
  el.setAttribute(attr, rel);
655
643
  }
656
644
  };
@@ -781,10 +769,8 @@ async function buildInstanceClient(hydrateEntryPath, instanceId, outputDir, proj
781
769
  return result;
782
770
  }
783
771
  function crossProductParams(parts) {
784
- if (parts.length === 0)
785
- return [];
786
- if (parts.length === 1)
787
- return parts[0].values;
772
+ if (parts.length === 0) return [];
773
+ if (parts.length === 1) return parts[0].values;
788
774
  const logger = getLogger();
789
775
  for (let i = 0; i < parts.length; i++) {
790
776
  for (let j = i + 1; j < parts.length; j++) {
@@ -802,8 +788,8 @@ function crossProductParams(parts) {
802
788
  const next = parts[i].values;
803
789
  const combined = [];
804
790
  for (const a of result) {
805
- for (const b2 of next) {
806
- combined.push({ ...a, ...b2 });
791
+ for (const b of next) {
792
+ combined.push({ ...a, ...b });
807
793
  }
808
794
  }
809
795
  result = combined;
@@ -812,8 +798,7 @@ function crossProductParams(parts) {
812
798
  }
813
799
  function paramsMatchInferred(params, inferredParams, optionalSegments) {
814
800
  return Object.entries(inferredParams).every(([k, v]) => {
815
- if (optionalSegments?.has(k))
816
- return true;
801
+ if (optionalSegments?.has(k)) return true;
817
802
  return params[k] === v;
818
803
  });
819
804
  }
@@ -826,10 +811,8 @@ function computeSpecificity(route) {
826
811
  function buildUrl(route, params) {
827
812
  return route.rawRoute.replace(/\[\[(\w+)\]\]/g, (_, name) => {
828
813
  const value = params[name];
829
- if (!value)
830
- return "";
831
- if (route.inferredParams?.[name] === value)
832
- return "";
814
+ if (!value) return "";
815
+ if (route.inferredParams?.[name] === value) return "";
833
816
  return value;
834
817
  }).replace(/\[(\w+)\]/g, (_, name) => params[name] || "").replace(/\/\/+/g, "/").replace(/\/$/, "") || "/";
835
818
  }
@@ -886,8 +869,7 @@ async function discoverPluginClientPackages(projectRoot) {
886
869
  const seen = /* @__PURE__ */ new Set();
887
870
  const result = [];
888
871
  async function walk(pkgName) {
889
- if (seen.has(pkgName))
890
- return;
872
+ if (seen.has(pkgName)) return;
891
873
  seen.add(pkgName);
892
874
  try {
893
875
  const mainPath = projectRequire.resolve(pkgName);
@@ -1023,8 +1005,7 @@ async function buildVersion(options) {
1023
1005
  await discoverPluginsWithInit({ projectRoot: options.projectRoot })
1024
1006
  );
1025
1007
  for (const pluginInit of allPluginsWithInit) {
1026
- if (pluginInit.isLocal)
1027
- continue;
1008
+ if (pluginInit.isLocal) continue;
1028
1009
  const clientImportPath = `${pluginInit.packageName}/client`;
1029
1010
  try {
1030
1011
  const clientModule = await import(clientImportPath);
@@ -1089,10 +1070,8 @@ async function buildVersion(options) {
1089
1070
  logger.important(`[Build] ${instanceCount}/${totalExpected} ${routeName}${paramStr}`);
1090
1071
  }
1091
1072
  async function loadPageModule(entry) {
1092
- if (!entry.serverModule)
1093
- return {};
1094
- if (entry.isPlugin)
1095
- return import(entry.serverModule);
1073
+ if (!entry.serverModule) return {};
1074
+ if (entry.isPlugin) return import(entry.serverModule);
1096
1075
  return import(path.join(backendDir, entry.serverModule));
1097
1076
  }
1098
1077
  const routeInfos = routeEntries.map((re) => {
@@ -1108,8 +1087,7 @@ async function buildVersion(options) {
1108
1087
  const loadParamsCache = /* @__PURE__ */ new Map();
1109
1088
  const loadParamsResults = /* @__PURE__ */ new Map();
1110
1089
  for (const info of routeInfos) {
1111
- if (!info.hasDynamicParams)
1112
- continue;
1090
+ if (!info.hasDynamicParams) continue;
1113
1091
  const { route, entry } = info.routeEntry;
1114
1092
  let pageModule;
1115
1093
  try {
@@ -1127,8 +1105,7 @@ async function buildVersion(options) {
1127
1105
  serverOutputDir
1128
1106
  );
1129
1107
  const partsWithLoadParams = pageParts.parts.filter((p) => p.compDefinition?.loadParams);
1130
- if (partsWithLoadParams.length === 0)
1131
- continue;
1108
+ if (partsWithLoadParams.length === 0) continue;
1132
1109
  const paramParts = [];
1133
1110
  for (const part of partsWithLoadParams) {
1134
1111
  const propsKey = JSON.stringify(part.headlessProps ?? {});
@@ -1158,14 +1135,12 @@ async function buildVersion(options) {
1158
1135
  const byRoute = /* @__PURE__ */ new Map();
1159
1136
  for (const materialized2 of deduped) {
1160
1137
  const info = materialized2.route;
1161
- if (!byRoute.has(info))
1162
- byRoute.set(info, []);
1138
+ if (!byRoute.has(info)) byRoute.set(info, []);
1163
1139
  byRoute.get(info).push(materialized2.params);
1164
1140
  }
1165
1141
  for (const [info] of byRoute) {
1166
1142
  const { route, entry } = info.routeEntry;
1167
- if (!route.jayHtmlPath)
1168
- continue;
1143
+ if (!route.jayHtmlPath) continue;
1169
1144
  const routeDir = route.rawRoute.replace(/^\//, "") || "index";
1170
1145
  const frontendSafeRouteDir = routeDir.replace(/\[/g, "%5B").replace(/\]/g, "%5D");
1171
1146
  const backendRouteDir = path.join(backendDir, "pre-rendered", routeDir);
@@ -1354,8 +1329,7 @@ function toFetchRequest(req) {
1354
1329
  const url = new URL(req.url || "/", `http://${req.headers.host}`);
1355
1330
  const headers = new Headers();
1356
1331
  for (const [key, value] of Object.entries(req.headers)) {
1357
- if (value)
1358
- headers.set(key, Array.isArray(value) ? value.join(", ") : value);
1332
+ if (value) headers.set(key, Array.isArray(value) ? value.join(", ") : value);
1359
1333
  }
1360
1334
  const init = { method: req.method, headers };
1361
1335
  if (req.method !== "GET" && req.method !== "HEAD") {
@@ -1375,8 +1349,7 @@ async function pipeFetchResponse(response, res) {
1375
1349
  try {
1376
1350
  while (true) {
1377
1351
  const { done, value } = await reader.read();
1378
- if (done)
1379
- break;
1352
+ if (done) break;
1380
1353
  res.write(value);
1381
1354
  }
1382
1355
  } finally {
@@ -1456,8 +1429,7 @@ async function startMainServer(options) {
1456
1429
  await pipeFetchResponse(response, res);
1457
1430
  } catch (err) {
1458
1431
  logger.error(`[Server] Error handling ${url.pathname}: ${err.message}`);
1459
- if (err.stack)
1460
- logger.error(err.stack);
1432
+ if (err.stack) logger.error(err.stack);
1461
1433
  if (!res.headersSent) {
1462
1434
  res.writeHead(500);
1463
1435
  res.end("Internal Server Error");
@@ -1483,11 +1455,9 @@ async function discoverWebhooks(projectRoot, serverBuildDir) {
1483
1455
  try {
1484
1456
  const plugins = await scanPlugins({ projectRoot });
1485
1457
  for (const [packageName, plugin] of plugins) {
1486
- if (plugin.isLocal)
1487
- continue;
1458
+ if (plugin.isLocal) continue;
1488
1459
  const declaredWebhooks = plugin.manifest.webhooks;
1489
- if (!declaredWebhooks || declaredWebhooks.length === 0)
1490
- continue;
1460
+ if (!declaredWebhooks || declaredWebhooks.length === 0) continue;
1491
1461
  try {
1492
1462
  const pluginModule = await import(packageName);
1493
1463
  for (const entry of declaredWebhooks) {
@@ -1519,11 +1489,9 @@ async function discoverWebhooks(projectRoot, serverBuildDir) {
1519
1489
  try {
1520
1490
  const plugins = await scanPlugins({ projectRoot });
1521
1491
  for (const [, plugin] of plugins) {
1522
- if (!plugin.isLocal)
1523
- continue;
1492
+ if (!plugin.isLocal) continue;
1524
1493
  const declaredWebhooks = plugin.manifest.webhooks;
1525
- if (!declaredWebhooks || declaredWebhooks.length === 0)
1526
- continue;
1494
+ if (!declaredWebhooks || declaredWebhooks.length === 0) continue;
1527
1495
  const pluginDirName = path.basename(plugin.pluginPath);
1528
1496
  for (const entry of declaredWebhooks) {
1529
1497
  const exportName = typeof entry === "string" ? entry : entry.name;
@@ -1554,8 +1522,7 @@ async function discoverWebhooks(projectRoot, serverBuildDir) {
1554
1522
  try {
1555
1523
  const files = await fs.readdir(webhooksDir);
1556
1524
  for (const file of files) {
1557
- if (!file.endsWith(".js"))
1558
- continue;
1525
+ if (!file.endsWith(".js")) continue;
1559
1526
  try {
1560
1527
  const mod = await import(path.join(webhooksDir, file));
1561
1528
  for (const [, value] of Object.entries(mod)) {
@@ -1738,10 +1705,8 @@ async function rebuildContract(options) {
1738
1705
  });
1739
1706
  }
1740
1707
  async function loadRouteModule(route, buildDir) {
1741
- if (!route.serverModule)
1742
- return {};
1743
- if (route.isPlugin)
1744
- return import(route.serverModule);
1708
+ if (!route.serverModule) return {};
1709
+ if (route.isPlugin) return import(route.serverModule);
1745
1710
  return import(path.join(buildDir, route.serverModule));
1746
1711
  }
1747
1712
  async function resolveJayRouteFromManifest(route, options) {
@@ -1761,8 +1726,7 @@ async function resolveJayRouteFromManifest(route, options) {
1761
1726
  return {
1762
1727
  rawRoute: route.pattern,
1763
1728
  segments: route.segments.map((s) => {
1764
- if (s.type === "static")
1765
- return s.value;
1729
+ if (s.type === "static") return s.value;
1766
1730
  return { name: s.value, type: segmentTypeMap[s.type] };
1767
1731
  }),
1768
1732
  jayHtmlPath: resolvedJayHtmlPath,
@@ -1779,11 +1743,9 @@ function paramsMatch(instanceParams, targetParams) {
1779
1743
  return Object.entries(targetParams).every(([key, value]) => instanceParams[key] === value);
1780
1744
  }
1781
1745
  function collectInstanceFiles(instance) {
1782
- if (!instance.cachePath)
1783
- return [];
1746
+ if (!instance.cachePath) return [];
1784
1747
  const files = [instance.cachePath, instance.serverElementPath, instance.clientBundlePath];
1785
- if (instance.clientCssPath)
1786
- files.push(instance.clientCssPath);
1748
+ if (instance.clientCssPath) files.push(instance.clientCssPath);
1787
1749
  return files.filter(Boolean);
1788
1750
  }
1789
1751
  async function appendCleanupManifest(buildDir, files) {
@@ -1959,13 +1921,13 @@ export {
1959
1921
  fetchPageRequest,
1960
1922
  fetchStaticFile,
1961
1923
  initializeServices,
1962
- e as initializeServicesFromModules,
1924
+ c as initializeServicesFromModules,
1963
1925
  isActionRequest,
1964
1926
  matchRequest,
1965
1927
  rebuild,
1966
1928
  rebuildContract,
1967
1929
  registerActionsFromManifest,
1968
- b as registerActionsFromModules,
1930
+ e as registerActionsFromModules,
1969
1931
  resolveContractToRoutes,
1970
1932
  startMainServer,
1971
1933
  startRendererServer
@@ -1,9 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  import fs from "node:fs/promises";
8
5
  import path from "node:path";
9
6
  import { renderFastChangingData, headMetaToHeadTags, mergeHeadTags, serializeHeadTags, getClientInitData, actionRegistry, setClientInitData } from "@jay-framework/stack-server-runtime";
@@ -14,7 +11,7 @@ import { getLogger } from "@jay-framework/logger";
14
11
  import { parseJayFile, JAY_IMPORT_RESOLVER, injectHeadfullFSTemplates, assignCoordinatesToJayHtml, discoverHeadlessInstances } from "@jay-framework/compiler-jay-html";
15
12
  import { checkValidationErrors } from "@jay-framework/compiler-shared";
16
13
  import { isJayAction, isJayStreamAction } from "@jay-framework/fullstack-component";
17
- const require2 = createRequire(import.meta.url);
14
+ const require$1 = createRequire(import.meta.url);
18
15
  async function loadProductionPageParts(route, pageModule, jayHtmlContent, projectRoot, tsConfigFilePath, serverBuildDir) {
19
16
  const exportName = route.componentExport || "page";
20
17
  const compDefinition = pageModule[exportName] ?? pageModule.default;
@@ -68,7 +65,7 @@ async function loadProductionPageParts(route, pageModule, jayHtmlContent, projec
68
65
  if (headlessImport.structural) {
69
66
  continue;
70
67
  } else {
71
- const resolvedModulePath = isLocalModule ? modulePath : require2.resolve(module, { paths: [dirName] });
68
+ const resolvedModulePath = isLocalModule ? modulePath : require$1.resolve(module, { paths: [dirName] });
72
69
  const headlessModule = await import(resolvedModulePath);
73
70
  headlessCompDef = headlessModule[name];
74
71
  }
@@ -221,8 +218,7 @@ async function loadPagePartsFromConfig(configPath, artifacts) {
221
218
  const serveTimeContract = {
222
219
  props: entry.propNames.map((name) => ({ name }))
223
220
  };
224
- if (entry.structural)
225
- continue;
221
+ if (entry.structural) continue;
226
222
  const mod = await importModule(entry);
227
223
  headlessInstanceComponents.push({
228
224
  contractName: entry.contractName,
@@ -296,8 +292,7 @@ class FilesystemArtifactStore {
296
292
  this.moduleCache.set(modulePath, { module: mod, mtime: stat.mtimeMs });
297
293
  return mod;
298
294
  } catch {
299
- if (local)
300
- throw new Error(`Local module not found: ${fullPath}`);
295
+ if (local) throw new Error(`Local module not found: ${fullPath}`);
301
296
  }
302
297
  }
303
298
  return import(modulePath);
@@ -327,8 +322,7 @@ function matchSegments(routeSegments, urlSegments) {
327
322
  }
328
323
  urlIdx++;
329
324
  } else if (seg.type === "param") {
330
- if (urlIdx >= urlSegments.length)
331
- return void 0;
325
+ if (urlIdx >= urlSegments.length) return void 0;
332
326
  params[seg.value] = urlSegments[urlIdx];
333
327
  urlIdx++;
334
328
  } else if (seg.type === "optional") {
@@ -337,8 +331,7 @@ function matchSegments(routeSegments, urlSegments) {
337
331
  urlIdx++;
338
332
  }
339
333
  } else if (seg.type === "catchAll") {
340
- if (urlIdx >= urlSegments.length)
341
- return void 0;
334
+ if (urlIdx >= urlSegments.length) return void 0;
342
335
  params[seg.value] = urlSegments.slice(urlIdx).join("/");
343
336
  urlIdx = urlSegments.length;
344
337
  } else if (seg.type === "optionalCatchAll") {
@@ -348,8 +341,7 @@ function matchSegments(routeSegments, urlSegments) {
348
341
  }
349
342
  }
350
343
  }
351
- if (urlIdx !== urlSegments.length)
352
- return void 0;
344
+ if (urlIdx !== urlSegments.length) return void 0;
353
345
  return params;
354
346
  }
355
347
  function findInstance(route, params) {
@@ -360,10 +352,8 @@ function findInstance(route, params) {
360
352
  for (const name of paramNames) {
361
353
  const urlVal = params[name];
362
354
  const instVal = instance.params[name];
363
- if (urlVal === void 0 && instVal === void 0)
364
- continue;
365
- if (urlVal !== instVal)
366
- return false;
355
+ if (urlVal === void 0 && instVal === void 0) continue;
356
+ if (urlVal !== instVal) return false;
367
357
  }
368
358
  return true;
369
359
  });
@@ -379,8 +369,7 @@ const pagePartsCache = /* @__PURE__ */ new Map();
379
369
  async function getPageParts(route, artifacts, cachePath) {
380
370
  const cacheKey = route.pattern;
381
371
  const cached = pagePartsCache.get(cacheKey);
382
- if (cached)
383
- return cached;
372
+ if (cached) return cached;
384
373
  const routeDir = path.dirname(cachePath);
385
374
  const configRelPath = path.join(routeDir, "page-parts.json");
386
375
  const parts = await loadPagePartsFromConfig(configRelPath, artifacts);
@@ -443,13 +432,10 @@ async function fetchPageRequest(match, manifest, requestUrl, artifacts, staticBa
443
432
  };
444
433
  const headTagSources = [];
445
434
  const slowHeadTags = cf.__slowHeadTags;
446
- if (slowHeadTags)
447
- headTagSources.push(...slowHeadTags);
448
- if (fastResult.headTags)
449
- headTagSources.push(fastResult.headTags);
435
+ if (slowHeadTags) headTagSources.push(...slowHeadTags);
436
+ if (fastResult.headTags) headTagSources.push(fastResult.headTags);
450
437
  const templateHeadTags = headMetaToHeadTags(route.headMeta, fullViewState);
451
- if (templateHeadTags.length > 0)
452
- headTagSources.push(templateHeadTags);
438
+ if (templateHeadTags.length > 0) headTagSources.push(templateHeadTags);
453
439
  const headTags = headTagSources.length > 0 ? mergeHeadTags(headTagSources) : [];
454
440
  const hasCustomTitle = headTags.some((t) => t.tag?.toLowerCase() === "title");
455
441
  const titleTag = hasCustomTitle ? "" : " <title>Vite + TS</title>\n";
@@ -509,8 +495,7 @@ ${headParts}
509
495
  const tSsr = Date.now();
510
496
  write("</div>");
511
497
  const asyncScripts = (await Promise.all(asyncPromises)).filter((s) => s).join("");
512
- if (asyncScripts)
513
- write(asyncScripts);
498
+ if (asyncScripts) write(asyncScripts);
514
499
  const clientInitData = getClientInitData();
515
500
  const initArgs = route.routeClientBundlePath ? `${JSON.stringify(fullSlowViewState)}, ${JSON.stringify(fastViewState)}, ${JSON.stringify(fastCarryForward)}, ${JSON.stringify(clientInitData)}` : `${JSON.stringify(fastViewState)}, ${JSON.stringify(fastCarryForward)}, ${JSON.stringify(clientInitData)}`;
516
501
  const tTotal = Date.now() - t0;
@@ -518,7 +503,6 @@ ${headParts}
518
503
  const serverTiming = {
519
504
  cache: tCache,
520
505
  parts: tParts,
521
- data: tData - t0,
522
506
  fast: tFast - tData,
523
507
  load: tLoadMs,
524
508
  ssr: tSsr - tSsrStart,
@@ -697,8 +681,7 @@ async function registerActionsFromModules(modules, registry = actionRegistry) {
697
681
  logger.info(`[Server] Registered ${count} actions from pre-imported modules`);
698
682
  }
699
683
  function getStatusCode(code, isActionError) {
700
- if (isActionError)
701
- return 422;
684
+ if (isActionError) return 422;
702
685
  switch (code) {
703
686
  case "ACTION_NOT_FOUND":
704
687
  return 404;
@@ -733,8 +716,7 @@ async function fetchStaticFile(pathname, frontendDir) {
733
716
  const normalizedBase = path.resolve(frontendDir);
734
717
  for (const candidate of [path.join(frontendDir, pathname)]) {
735
718
  const normalizedFile = path.resolve(candidate);
736
- if (!normalizedFile.startsWith(normalizedBase))
737
- continue;
719
+ if (!normalizedFile.startsWith(normalizedBase)) continue;
738
720
  try {
739
721
  const content = await fs.readFile(candidate);
740
722
  const ext = path.extname(candidate);
@@ -760,8 +742,7 @@ async function initializeServicesFromModules(plugins, label) {
760
742
  if (plugin.init?._serverInit) {
761
743
  logger.info(`[${label}] Running plugin init: ${plugin.name}`);
762
744
  const data = await plugin.init._serverInit();
763
- if (data)
764
- setClientInitData(plugin.name, data);
745
+ if (data) setClientInitData(plugin.name, data);
765
746
  }
766
747
  } catch (err) {
767
748
  logger.warn(`[${label}] Plugin init failed: ${plugin.name}: ${err.message}`);
@@ -796,8 +777,7 @@ async function initializeServices(buildDir, projectRoot, label) {
796
777
  if (init?._serverInit) {
797
778
  logger.info(`[${label}] Running plugin init: ${pluginInit.name}`);
798
779
  const data = await init._serverInit();
799
- if (data)
800
- setClientInitData(pluginInit.name, data);
780
+ if (data) setClientInitData(pluginInit.name, data);
801
781
  }
802
782
  } catch (err) {
803
783
  logger.warn(`[${label}] Plugin init failed: ${pluginInit.name}: ${err.message}`);
@@ -812,22 +792,21 @@ async function initializeServices(buildDir, projectRoot, label) {
812
792
  if (init?._serverInit) {
813
793
  logger.info(`[${label}] Running server init...`);
814
794
  const data = await init._serverInit();
815
- if (data)
816
- setClientInitData("project", data);
795
+ if (data) setClientInitData("project", data);
817
796
  }
818
797
  } catch {
819
798
  }
820
799
  }
821
800
  export {
822
801
  FilesystemArtifactStore as F,
823
- fetchActionRequest as a,
824
- registerActionsFromModules as b,
825
- fetchStaticFile as c,
826
- initializeServices as d,
827
- initializeServicesFromModules as e,
828
- fetchPageRequest as f,
802
+ fetchPageRequest as a,
803
+ fetchStaticFile as b,
804
+ initializeServicesFromModules as c,
805
+ isActionRequest as d,
806
+ registerActionsFromModules as e,
807
+ fetchActionRequest as f,
829
808
  buildPagePartsConfig as g,
830
- isActionRequest as i,
809
+ initializeServices as i,
831
810
  loadProductionPageParts as l,
832
811
  matchRequest as m,
833
812
  registerActionsFromManifest as r
@@ -183,4 +183,4 @@ interface PreImportedPlugin {
183
183
  declare function initializeServicesFromModules(plugins: PreImportedPlugin[], label: string): Promise<void>;
184
184
  declare function initializeServices(buildDir: string, projectRoot: string, label: string): Promise<void>;
185
185
 
186
- export { type ActionEntry as A, type BuildOptions as B, type CacheEntry as C, FilesystemArtifactStore as F, type InstanceEntry as I, type MatchResult as M, type PluginEntry as P, type RouteManifest as R, type ServerElementModule as S, type RouteEntry as a, type RouteSegment as b, type BuildMetadata as c, type PageModule as d, type ArtifactStore as e, fetchPageRequest as f, fetchActionRequest as g, registerActionsFromModules as h, isActionRequest as i, fetchStaticFile as j, initializeServices as k, initializeServicesFromModules as l, matchRequest as m, type PreImportedPlugin as n, registerActionsFromManifest as r };
186
+ export { type ActionEntry as A, type BuildOptions as B, type CacheEntry as C, FilesystemArtifactStore as F, type InstanceEntry as I, type MatchResult as M, type PageModule as P, type RouteManifest as R, type ServerElementModule as S, type RouteEntry as a, type ArtifactStore as b, type BuildMetadata as c, type PluginEntry as d, type PreImportedPlugin as e, type RouteSegment as f, fetchActionRequest as g, fetchPageRequest as h, fetchStaticFile as i, initializeServices as j, initializeServicesFromModules as k, isActionRequest as l, matchRequest as m, registerActionsFromModules as n, registerActionsFromManifest as r };
@@ -1,4 +1,4 @@
1
- export { e as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, n as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, f as fetchPageRequest, j as fetchStaticFile, k as initializeServices, l as initializeServicesFromModules, i as isActionRequest, m as matchRequest, r as registerActionsFromManifest, h as registerActionsFromModules } from './serve-index-XSavezh8.js';
1
+ export { b as ArtifactStore, C as CacheEntry, F as FilesystemArtifactStore, I as InstanceEntry, M as MatchResult, e as PreImportedPlugin, a as RouteEntry, R as RouteManifest, S as ServerElementModule, g as fetchActionRequest, h as fetchPageRequest, i as fetchStaticFile, j as initializeServices, k as initializeServicesFromModules, l as isActionRequest, m as matchRequest, r as registerActionsFromManifest, n as registerActionsFromModules } from './serve-index-Ccw8CNDg.js';
2
2
  import '@jay-framework/ssr-runtime';
3
3
  import '@jay-framework/compiler-shared';
4
4
  import '@jay-framework/stack-server-runtime';
@@ -1,23 +1,13 @@
1
- import { F, a, f, c, d, e, i, m, r, b } from "./init-services-AtDV4X1i.js";
2
- import "node:fs/promises";
3
- import "node:path";
4
- import "@jay-framework/stack-server-runtime";
5
- import "@jay-framework/view-state-merge";
6
- import "@jay-framework/ssr-runtime";
7
- import "node:module";
8
- import "@jay-framework/logger";
9
- import "@jay-framework/compiler-jay-html";
10
- import "@jay-framework/compiler-shared";
11
- import "@jay-framework/fullstack-component";
1
+ import { F, f, a, b, i, c, d, m, r, e } from "./init-services-BVEuyIVG.js";
12
2
  export {
13
3
  F as FilesystemArtifactStore,
14
- a as fetchActionRequest,
15
- f as fetchPageRequest,
16
- c as fetchStaticFile,
17
- d as initializeServices,
18
- e as initializeServicesFromModules,
19
- i as isActionRequest,
4
+ f as fetchActionRequest,
5
+ a as fetchPageRequest,
6
+ b as fetchStaticFile,
7
+ i as initializeServices,
8
+ c as initializeServicesFromModules,
9
+ d as isActionRequest,
20
10
  m as matchRequest,
21
11
  r as registerActionsFromManifest,
22
- b as registerActionsFromModules
12
+ e as registerActionsFromModules
23
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/production-server",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,20 +30,20 @@
30
30
  "test:watch": "vitest"
31
31
  },
32
32
  "dependencies": {
33
- "@jay-framework/compiler-jay-html": "^0.23.0",
34
- "@jay-framework/compiler-jay-stack": "^0.23.0",
35
- "@jay-framework/compiler-shared": "^0.23.0",
36
- "@jay-framework/fullstack-component": "^0.23.0",
37
- "@jay-framework/logger": "^0.23.0",
38
- "@jay-framework/ssr-runtime": "^0.23.0",
39
- "@jay-framework/stack-route-scanner": "^0.23.0",
40
- "@jay-framework/stack-server-runtime": "^0.23.0",
41
- "@jay-framework/view-state-merge": "^0.23.0",
42
- "@jay-framework/vite-plugin": "^0.23.0",
33
+ "@jay-framework/compiler-jay-html": "^0.23.1",
34
+ "@jay-framework/compiler-jay-stack": "^0.23.1",
35
+ "@jay-framework/compiler-shared": "^0.23.1",
36
+ "@jay-framework/fullstack-component": "^0.23.1",
37
+ "@jay-framework/logger": "^0.23.1",
38
+ "@jay-framework/ssr-runtime": "^0.23.1",
39
+ "@jay-framework/stack-route-scanner": "^0.23.1",
40
+ "@jay-framework/stack-server-runtime": "^0.23.1",
41
+ "@jay-framework/view-state-merge": "^0.23.1",
42
+ "@jay-framework/vite-plugin": "^0.23.1",
43
43
  "vite": "^5.0.11"
44
44
  },
45
45
  "devDependencies": {
46
- "@jay-framework/dev-environment": "^0.23.0",
46
+ "@jay-framework/dev-environment": "^0.23.1",
47
47
  "@types/node": "^22.15.21",
48
48
  "rimraf": "^5.0.5",
49
49
  "tsup": "^8.0.1",