@jay-framework/stack-server-runtime 0.16.2 → 0.16.4

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
@@ -517,6 +517,8 @@ interface PluginWithInit {
517
517
  * Can be overridden via `init` property in plugin.yaml (for compiled packages).
518
518
  */
519
519
  initExport: string;
520
+ /** Whether init was explicitly declared or confirmed to exist */
521
+ initConfirmed: boolean;
520
522
  /** Dependencies from package.json (for ordering) */
521
523
  dependencies: string[];
522
524
  /** When true, plugin is loaded on every page regardless of usage in jay-html */
package/dist/index.js CHANGED
@@ -1131,9 +1131,10 @@ async function loadPageParts(vite, route, pagesBase, projectBase, jayRollupConfi
1131
1131
  if (exists) {
1132
1132
  const exportName = route.componentExport || "page";
1133
1133
  const pageComponent = (await vite.ssrLoadModule(route.compPath))[exportName];
1134
+ const clientImportPath = route.componentExport ? route.compPath.replace(/index\.js$/, "index.client.js") : route.compPath;
1134
1135
  parts.push({
1135
1136
  compDefinition: pageComponent,
1136
- clientImport: `import {${exportName}} from '${route.compPath}'`,
1137
+ clientImport: `import {${exportName}} from '${clientImportPath}'`,
1137
1138
  clientPart: `{comp: ${exportName}.comp, contextMarkers: ${exportName}.contexts || []}`
1138
1139
  });
1139
1140
  }
@@ -2012,6 +2013,7 @@ async function discoverPluginsWithInit(options) {
2012
2013
  isLocal: scanned.isLocal,
2013
2014
  initModule: initConfig.module,
2014
2015
  initExport: initConfig.export,
2016
+ initConfirmed: initConfig.explicit,
2015
2017
  dependencies: scanned.dependencies,
2016
2018
  global: scanned.manifest.global === true
2017
2019
  });
@@ -2034,27 +2036,14 @@ function resolvePluginInit(pluginPath, initConfig, isLocal) {
2034
2036
  if (fs.existsSync(initPath)) {
2035
2037
  const relativePath = path.relative(pluginPath, initPath);
2036
2038
  const modulePath = relativePath.replace(/\.(ts|js)$/, "");
2037
- const exportName = typeof initConfig === "string" ? initConfig : defaultExport;
2038
- return { module: modulePath, export: exportName };
2039
+ const exportName2 = typeof initConfig === "string" ? initConfig : defaultExport;
2040
+ return { module: modulePath, export: exportName2, explicit: true };
2039
2041
  }
2040
2042
  }
2041
2043
  return null;
2042
2044
  }
2043
- const packageJsonPath = path.join(pluginPath, "package.json");
2044
- if (!fs.existsSync(packageJsonPath)) {
2045
- return null;
2046
- }
2047
- try {
2048
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
2049
- const hasMain = packageJson.main || packageJson.exports;
2050
- if (!hasMain && !initConfig) {
2051
- return null;
2052
- }
2053
- const exportName = typeof initConfig === "string" ? initConfig : defaultExport;
2054
- return { module: "", export: exportName };
2055
- } catch {
2056
- return null;
2057
- }
2045
+ const exportName = typeof initConfig === "string" ? initConfig : defaultExport;
2046
+ return { module: "", export: exportName, explicit: !!initConfig };
2058
2047
  }
2059
2048
  function sortPluginsByDependencies(plugins) {
2060
2049
  const pluginNames = new Set(plugins.map((p) => p.packageName));
@@ -2106,11 +2095,14 @@ async function executePluginServerInits(plugins, viteServer, verbose = false) {
2106
2095
  }
2107
2096
  const jayInit = pluginModule[plugin.initExport];
2108
2097
  if (!jayInit || jayInit.__brand !== "JayInit") {
2109
- getLogger().warn(
2110
- `[PluginInit] Plugin "${plugin.name}" init module doesn't export a valid JayInit at "${plugin.initExport}"`
2111
- );
2098
+ if (plugin.initConfirmed) {
2099
+ getLogger().warn(
2100
+ `[PluginInit] Plugin "${plugin.name}" init module doesn't export a valid JayInit at "${plugin.initExport}"`
2101
+ );
2102
+ }
2112
2103
  continue;
2113
2104
  }
2105
+ plugin.initConfirmed = true;
2114
2106
  if (typeof jayInit._serverInit === "function") {
2115
2107
  if (verbose) {
2116
2108
  getLogger().info(`[DevServer] Running server init: ${plugin.name}`);
@@ -2131,7 +2123,7 @@ async function executePluginServerInits(plugins, viteServer, verbose = false) {
2131
2123
  return initErrors;
2132
2124
  }
2133
2125
  function preparePluginClientInits(plugins) {
2134
- return plugins.map((plugin) => {
2126
+ return plugins.filter((p) => p.initConfirmed).map((plugin) => {
2135
2127
  let importPath;
2136
2128
  if (plugin.isLocal) {
2137
2129
  importPath = path.join(plugin.pluginPath, plugin.initModule);
@@ -2630,9 +2622,19 @@ async function materializeContracts(options, services = /* @__PURE__ */ new Map(
2630
2622
  viteServer
2631
2623
  );
2632
2624
  const prefix = config.prefix;
2625
+ if (generatedContracts.length > 1) {
2626
+ const missing = generatedContracts.filter((c) => !c.name);
2627
+ if (missing.length > 0) {
2628
+ getLogger().error(
2629
+ ` ❌ Dynamic contract generator for "${prefix}" returned ${generatedContracts.length} contracts but ${missing.length} are missing a name. Names are required when a generator returns multiple contracts.`
2630
+ );
2631
+ continue;
2632
+ }
2633
+ }
2633
2634
  for (const generated of generatedContracts) {
2634
- const fullName = `${prefix}/${toKebabCase(generated.name)}`;
2635
- const fileName = `${prefix}-${toKebabCase(generated.name)}.jay-contract`;
2635
+ const kebabName = generated.name ? toKebabCase(generated.name) : null;
2636
+ const fullName = kebabName ? `${prefix}/${kebabName}` : prefix;
2637
+ const fileName = kebabName ? `${prefix}-${kebabName}.jay-contract` : `${prefix}.jay-contract`;
2636
2638
  const filePath = path.join(pluginOutputDir, fileName);
2637
2639
  fs.writeFileSync(filePath, generated.yaml, "utf-8");
2638
2640
  const relativePath = path.relative(projectRoot, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/stack-server-runtime",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.mts",
@@ -26,21 +26,21 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "dependencies": {
29
- "@jay-framework/compiler-jay-html": "^0.16.2",
30
- "@jay-framework/compiler-shared": "^0.16.2",
31
- "@jay-framework/component": "^0.16.2",
32
- "@jay-framework/fullstack-component": "^0.16.2",
33
- "@jay-framework/logger": "^0.16.2",
34
- "@jay-framework/runtime": "^0.16.2",
35
- "@jay-framework/ssr-runtime": "^0.16.2",
36
- "@jay-framework/stack-route-scanner": "^0.16.2",
37
- "@jay-framework/view-state-merge": "^0.16.2",
29
+ "@jay-framework/compiler-jay-html": "^0.16.4",
30
+ "@jay-framework/compiler-shared": "^0.16.4",
31
+ "@jay-framework/component": "^0.16.4",
32
+ "@jay-framework/fullstack-component": "^0.16.4",
33
+ "@jay-framework/logger": "^0.16.4",
34
+ "@jay-framework/runtime": "^0.16.4",
35
+ "@jay-framework/ssr-runtime": "^0.16.4",
36
+ "@jay-framework/stack-route-scanner": "^0.16.4",
37
+ "@jay-framework/view-state-merge": "^0.16.4",
38
38
  "yaml": "^2.3.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@jay-framework/dev-environment": "^0.16.2",
42
- "@jay-framework/jay-cli": "^0.16.2",
43
- "@jay-framework/stack-client-runtime": "^0.16.2",
41
+ "@jay-framework/dev-environment": "^0.16.4",
42
+ "@jay-framework/jay-cli": "^0.16.4",
43
+ "@jay-framework/stack-client-runtime": "^0.16.4",
44
44
  "@types/express": "^5.0.2",
45
45
  "@types/node": "^22.15.21",
46
46
  "nodemon": "^3.0.3",