@noego/forge 0.0.23 → 0.0.25
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/client.cjs +3 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +1316 -280
- package/dist/client.mjs.map +1 -1
- package/dist-ssr/server.cjs +53 -6
- package/dist-ssr/server.cjs.map +1 -1
- package/dist-ssr/server.js +53 -6
- package/dist-ssr/server.js.map +1 -1
- package/package.json +3 -2
package/dist-ssr/server.cjs
CHANGED
|
@@ -449,7 +449,16 @@ class ManifestBuilder {
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
async function requires_server(route, loader) {
|
|
452
|
-
|
|
452
|
+
const has_middleware = route.middleware && route.middleware.length > 0;
|
|
453
|
+
const has_loaders = await layout_requires_server(route, loader) || await view_requires_server(route, loader);
|
|
454
|
+
const requires_server2 = has_middleware || has_loaders;
|
|
455
|
+
console.log("[MANIFEST]", route.path, {
|
|
456
|
+
has_middleware,
|
|
457
|
+
middleware: route.middleware,
|
|
458
|
+
has_loaders,
|
|
459
|
+
requires_server: requires_server2
|
|
460
|
+
});
|
|
461
|
+
return requires_server2;
|
|
453
462
|
}
|
|
454
463
|
async function layout_requires_server(route, loader) {
|
|
455
464
|
const layout = route.layout;
|
|
@@ -680,16 +689,21 @@ class ComponentManager {
|
|
|
680
689
|
continue;
|
|
681
690
|
}
|
|
682
691
|
try {
|
|
692
|
+
console.log(`[ComponentManager] Trying loader path: ${loaderFilePath}`);
|
|
683
693
|
const module2 = await import(url.pathToFileURL(loaderFilePath).href);
|
|
684
694
|
const loader = module2 == null ? void 0 : module2.default;
|
|
695
|
+
console.log(`[ComponentManager] Imported loader module: default=${typeof loader}`);
|
|
685
696
|
if (typeof loader === "function") {
|
|
697
|
+
console.log(`[ComponentManager] Loaded loader function from: ${loaderFilePath}`);
|
|
686
698
|
return loader;
|
|
687
699
|
}
|
|
688
700
|
} catch (error) {
|
|
689
|
-
|
|
701
|
+
const code = (error == null ? void 0 : error.code) || (error == null ? void 0 : error.name) || "UNKNOWN_ERROR";
|
|
702
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND") {
|
|
703
|
+
console.warn(`[ComponentManager] Loader not found at ${loaderFilePath} (${ext}): ${(error == null ? void 0 : error.message) || code}`);
|
|
690
704
|
continue;
|
|
691
705
|
}
|
|
692
|
-
console.error(`[ComponentManager] Failed to load loader for ${componentPath} (${ext}):`, error);
|
|
706
|
+
console.error(`[ComponentManager] Failed to load loader for ${componentPath} (${ext}) at ${loaderFilePath}:`, error);
|
|
693
707
|
}
|
|
694
708
|
}
|
|
695
709
|
return null;
|
|
@@ -1023,8 +1037,18 @@ class ExpressServerAdapter extends ServerAdapter {
|
|
|
1023
1037
|
body: req.body,
|
|
1024
1038
|
context
|
|
1025
1039
|
};
|
|
1040
|
+
console.log("[SERVER] Handling request", req.url, {
|
|
1041
|
+
middleware: route.middleware,
|
|
1042
|
+
accept: req.headers.accept,
|
|
1043
|
+
route_path: route.path,
|
|
1044
|
+
server_api_call
|
|
1045
|
+
});
|
|
1026
1046
|
try {
|
|
1027
1047
|
await this.middleware_adapter.handleMiddleware(req, res, route.middleware || []);
|
|
1048
|
+
console.log("[SERVER] Middleware complete", {
|
|
1049
|
+
headersSent: res.headersSent,
|
|
1050
|
+
statusCode: res.statusCode
|
|
1051
|
+
});
|
|
1028
1052
|
} catch (e) {
|
|
1029
1053
|
console.log("Error in middleware", e);
|
|
1030
1054
|
res.status(500).send(`
|
|
@@ -1035,6 +1059,10 @@ ${e.stack}</pre>
|
|
|
1035
1059
|
`);
|
|
1036
1060
|
return;
|
|
1037
1061
|
}
|
|
1062
|
+
if (res.headersSent) {
|
|
1063
|
+
console.log("[SERVER] Headers already sent by middleware, returning early");
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1038
1066
|
let server_data = await this.api_adapter.getApiData(route, request_data);
|
|
1039
1067
|
if (server_api_call) {
|
|
1040
1068
|
res.header("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate").header("Pragma", "no-cache").header("Expires", "0").type("application/json").send(server_data);
|
|
@@ -1083,7 +1111,27 @@ ${e.stack}</pre>
|
|
|
1083
1111
|
});
|
|
1084
1112
|
const body_render = renderedHtml;
|
|
1085
1113
|
console.log("[SSR DEBUG] render result - body length:", (body_render == null ? void 0 : body_render.length) || 0);
|
|
1086
|
-
const
|
|
1114
|
+
const deriveClientBase = (dir) => {
|
|
1115
|
+
try {
|
|
1116
|
+
const norm = String(dir || "").replace(/\\/g, "/");
|
|
1117
|
+
const marker = "/ssr/";
|
|
1118
|
+
const idx = norm.indexOf(marker);
|
|
1119
|
+
if (idx >= 0) {
|
|
1120
|
+
const suffix = norm.slice(idx + marker.length).replace(/^\/+/, "");
|
|
1121
|
+
return suffix ? `/assets/${suffix}` : "/assets";
|
|
1122
|
+
}
|
|
1123
|
+
for (const hint of ["/components", "/pages"]) {
|
|
1124
|
+
const hIdx = norm.indexOf(hint);
|
|
1125
|
+
if (hIdx >= 0) {
|
|
1126
|
+
const suffix = norm.slice(hIdx + 1).replace(/^\/+/, "");
|
|
1127
|
+
return suffix ? `/assets/${suffix}` : "/assets";
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
} catch {
|
|
1131
|
+
}
|
|
1132
|
+
return "/assets";
|
|
1133
|
+
};
|
|
1134
|
+
const clientComponentDir = this.isProd ? deriveClientBase(this.componentDir || "") : this.componentDir || "/assets";
|
|
1087
1135
|
const head_routing = `
|
|
1088
1136
|
<script type='text/javascript'>
|
|
1089
1137
|
window.__ROUTING__ = ${JSON.stringify(this.clientRoutes)}
|
|
@@ -1091,6 +1139,7 @@ ${e.stack}</pre>
|
|
|
1091
1139
|
|
|
1092
1140
|
<script type='text/javascript'>
|
|
1093
1141
|
window.__MANIFEST__ = ${JSON.stringify(manifest)}
|
|
1142
|
+
console.log('[MANIFEST INJECTED]', window.__MANIFEST__);
|
|
1094
1143
|
<\/script>
|
|
1095
1144
|
|
|
1096
1145
|
<script type='text/javascript'>
|
|
@@ -1223,8 +1272,6 @@ async function createServer(app, options) {
|
|
|
1223
1272
|
let componentLoader;
|
|
1224
1273
|
let vite;
|
|
1225
1274
|
console.log(`Serving components from ${COMPONENT_DIR}`);
|
|
1226
|
-
const rendererFullPath = typeof full_options.renderer === "string" && full_options.renderer !== "default" ? ensureFullPath(root, full_options.renderer) : ensureFullPath(root, "index.html");
|
|
1227
|
-
path.dirname(rendererFullPath);
|
|
1228
1275
|
const resolveAssetRoot = (entry) => {
|
|
1229
1276
|
if (typeof entry === "function") {
|
|
1230
1277
|
return entry;
|