tina4-nodejs 3.10.71 → 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.71",
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"],
@@ -1207,7 +1207,34 @@ const handleVersionCheck: RouteHandler = async (_req, res) => {
1207
1207
  // Dev Admin JS handler — serves the shared JS file
1208
1208
  // ---------------------------------------------------------------------------
1209
1209
 
1210
- const handleDevAdminJs: RouteHandler = (_req, res) => {
1210
+ const handleDevAdminJs: RouteHandler = async (_req, res) => {
1211
+ const { readFileSync, existsSync } = await import("node:fs");
1212
+ const { dirname, join, resolve } = await import("node:path");
1213
+ const { fileURLToPath } = await import("node:url");
1214
+ const dir = dirname(fileURLToPath(import.meta.url));
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
+ }
1235
+ }
1236
+
1237
+ // Fallback to inline JS (old dev admin)
1211
1238
  res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
1212
1239
  res.raw.end(renderDevAdminJs());
1213
1240
  };