tina4-nodejs 3.10.72 → 3.10.73

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tina4-nodejs",
3
- "version": "3.10.72",
3
+ "version": "3.10.73",
4
4
  "type": "module",
5
5
  "description": "Tina4 for Node.js/TypeScript — 54 built-in features, zero dependencies",
6
6
  "keywords": ["tina4", "framework", "web", "api", "orm", "graphql", "websocket", "typescript"],
@@ -1208,20 +1208,35 @@ const handleVersionCheck: RouteHandler = async (_req, res) => {
1208
1208
  // ---------------------------------------------------------------------------
1209
1209
 
1210
1210
  const handleDevAdminJs: RouteHandler = async (_req, res) => {
1211
- // Serve the pre-built SPA bundle from public/js/
1212
- const { readFileSync } = await import("node:fs");
1213
- const { dirname, join } = await import("node:path");
1211
+ const { readFileSync, existsSync } = await import("node:fs");
1212
+ const { dirname, join, resolve } = await import("node:path");
1214
1213
  const { fileURLToPath } = await import("node:url");
1215
1214
  const dir = dirname(fileURLToPath(import.meta.url));
1216
- const jsPath = join(dir, "..", "public", "js", "tina4-dev-admin.min.js");
1217
- try {
1218
- const content = readFileSync(jsPath, "utf-8");
1219
- res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
1220
- res.raw.end(content);
1221
- } catch {
1222
- res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
1223
- res.raw.end(renderDevAdminJs());
1215
+
1216
+ // Try multiple paths — handles both monorepo dev and npm-installed package
1217
+ const candidates = [
1218
+ join(dir, "..", "public", "js", "tina4-dev-admin.min.js"), // src/../public/js/
1219
+ join(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"), // deeper nesting
1220
+ resolve(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin.min.js"),
1221
+ resolve(process.cwd(), "public", "js", "tina4-dev-admin.min.js"), // project public/
1222
+ ];
1223
+
1224
+ for (const jsPath of candidates) {
1225
+ if (existsSync(jsPath)) {
1226
+ try {
1227
+ const content = readFileSync(jsPath, "utf-8");
1228
+ if (content.length > 40000) { // SPA bundle is ~72KB, old inline is ~32KB
1229
+ res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
1230
+ res.raw.end(content);
1231
+ return;
1232
+ }
1233
+ } catch { /* try next */ }
1234
+ }
1224
1235
  }
1236
+
1237
+ // Fallback to inline JS (old dev admin)
1238
+ res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
1239
+ res.raw.end(renderDevAdminJs());
1225
1240
  };
1226
1241
 
1227
1242
  // ---------------------------------------------------------------------------