@nitronjs/framework 0.2.27 → 0.3.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.
Files changed (58) hide show
  1. package/README.md +260 -170
  2. package/lib/Auth/Auth.js +2 -2
  3. package/lib/Build/CssBuilder.js +5 -7
  4. package/lib/Build/EffectivePropUsage.js +174 -0
  5. package/lib/Build/FactoryTransform.js +1 -21
  6. package/lib/Build/FileAnalyzer.js +2 -33
  7. package/lib/Build/Manager.js +354 -58
  8. package/lib/Build/PropUsageAnalyzer.js +1189 -0
  9. package/lib/Build/jsxRuntime.js +25 -155
  10. package/lib/Build/plugins.js +212 -146
  11. package/lib/Build/propUtils.js +70 -0
  12. package/lib/Console/Commands/DevCommand.js +30 -10
  13. package/lib/Console/Commands/MakeCommand.js +8 -1
  14. package/lib/Console/Output.js +0 -2
  15. package/lib/Console/Stubs/rsc-consumer.tsx +74 -0
  16. package/lib/Console/Stubs/vendor-dev.tsx +30 -41
  17. package/lib/Console/Stubs/vendor.tsx +25 -1
  18. package/lib/Core/Config.js +0 -6
  19. package/lib/Core/Paths.js +0 -19
  20. package/lib/Database/Migration/Checksum.js +0 -3
  21. package/lib/Database/Migration/MigrationRepository.js +0 -8
  22. package/lib/Database/Migration/MigrationRunner.js +1 -2
  23. package/lib/Database/Model.js +19 -11
  24. package/lib/Database/QueryBuilder.js +25 -4
  25. package/lib/Database/Schema/Blueprint.js +10 -0
  26. package/lib/Database/Schema/Manager.js +2 -0
  27. package/lib/Date/DateTime.js +1 -1
  28. package/lib/Dev/DevContext.js +44 -0
  29. package/lib/Dev/DevErrorPage.js +990 -0
  30. package/lib/Dev/DevIndicator.js +836 -0
  31. package/lib/HMR/Server.js +16 -37
  32. package/lib/Http/Server.js +171 -23
  33. package/lib/Logging/Log.js +34 -2
  34. package/lib/Mail/Mail.js +41 -10
  35. package/lib/Route/Router.js +43 -19
  36. package/lib/Runtime/Entry.js +10 -6
  37. package/lib/Session/Manager.js +103 -1
  38. package/lib/Session/Session.js +0 -4
  39. package/lib/Support/Str.js +6 -4
  40. package/lib/Translation/Lang.js +376 -32
  41. package/lib/Translation/pluralize.js +81 -0
  42. package/lib/Validation/MagicBytes.js +120 -0
  43. package/lib/Validation/Validator.js +46 -29
  44. package/lib/View/Client/hmr-client.js +100 -90
  45. package/lib/View/Client/spa.js +121 -50
  46. package/lib/View/ClientManifest.js +60 -0
  47. package/lib/View/FlightRenderer.js +100 -0
  48. package/lib/View/Layout.js +0 -3
  49. package/lib/View/PropFilter.js +81 -0
  50. package/lib/View/View.js +230 -495
  51. package/lib/index.d.ts +22 -1
  52. package/package.json +2 -2
  53. package/skeleton/config/app.js +1 -0
  54. package/skeleton/config/server.js +13 -0
  55. package/skeleton/config/session.js +3 -0
  56. package/lib/Build/HydrationBuilder.js +0 -190
  57. package/lib/Console/Stubs/page-hydration-dev.tsx +0 -72
  58. package/lib/Console/Stubs/page-hydration.tsx +0 -53
@@ -1,3 +1,5 @@
1
+ import { validateIdentifier } from "../QueryValidation.js";
2
+
1
3
  class Blueprint {
2
4
  #tableName;
3
5
  #columns = [];
@@ -5,6 +7,7 @@ class Blueprint {
5
7
  #dropIndexes = [];
6
8
 
7
9
  constructor(tableName) {
10
+ validateIdentifier(tableName);
8
11
  this.#tableName = tableName;
9
12
  }
10
13
 
@@ -30,11 +33,17 @@ class Blueprint {
30
33
 
31
34
  index(columns) {
32
35
  const cols = Array.isArray(columns) ? columns : [columns];
36
+
37
+ for (const col of cols) {
38
+ validateIdentifier(col);
39
+ }
40
+
33
41
  const name = `idx_${this.#tableName}_${cols.join('_')}`;
34
42
  this.#indexes.push({ name, columns: cols });
35
43
  }
36
44
 
37
45
  dropIndex(name) {
46
+ validateIdentifier(name);
38
47
  this.#dropIndexes.push(name);
39
48
  }
40
49
 
@@ -76,6 +85,7 @@ class Blueprint {
76
85
  // ─────────────────────────────────────────────────────────────────────────
77
86
 
78
87
  #addColumn(type, name, options = {}) {
88
+ validateIdentifier(name);
79
89
  const column = {
80
90
  name,
81
91
  type,
@@ -1,5 +1,6 @@
1
1
  import DB from "../DB.js";
2
2
  import Config from "../../Core/Config.js";
3
+ import { validateIdentifier } from "../QueryValidation.js";
3
4
 
4
5
  export default class Schema {
5
6
 
@@ -28,6 +29,7 @@ export default class Schema {
28
29
  }
29
30
 
30
31
  static async dropIfExists(tableName) {
32
+ validateIdentifier(tableName);
31
33
  await DB.rawQuery(`DROP TABLE IF EXISTS \`${tableName}\``);
32
34
  }
33
35
 
@@ -8,7 +8,7 @@ import Config from '../Core/Config.js';
8
8
  * @example
9
9
  * DateTime.toSQL(); // "2025-01-15 10:30:00"
10
10
  * DateTime.addDays(7); // 7 days from now
11
- * DateTime.diffForHumans(ts); // "2 hours ago"
11
+ * DateTime.getDate(ts); // Formatted date string
12
12
  */
13
13
  class DateTime {
14
14
  static #getDate(date = null) {
@@ -0,0 +1,44 @@
1
+ /**
2
+ * DevContext — Per-request development context collector.
3
+ *
4
+ * Attaches timing, route, middleware, and props information to each
5
+ * Fastify request via `req.__devCtx`. Only used in development mode;
6
+ * production code never imports this module.
7
+ */
8
+
9
+ class DevContext {
10
+
11
+ static attach(req) {
12
+ req.__devCtx = {
13
+ startTime: performance.now(),
14
+ middlewareTiming: [],
15
+ controllerDuration: 0,
16
+ renderDuration: 0,
17
+ route: null,
18
+ viewName: null,
19
+ rawProps: null,
20
+ propUsage: null,
21
+ request: null
22
+ };
23
+ }
24
+
25
+ static get(req) {
26
+ return req.__devCtx || null;
27
+ }
28
+
29
+ static snapshot(req) {
30
+ const ctx = req.__devCtx;
31
+ if (!ctx) return null;
32
+
33
+ const totalTime = performance.now() - ctx.startTime;
34
+ const middlewareTotal = ctx.middlewareTiming.reduce((sum, m) => sum + m.duration, 0);
35
+
36
+ return {
37
+ ...ctx,
38
+ totalTime,
39
+ middlewareTotal
40
+ };
41
+ }
42
+ }
43
+
44
+ export default DevContext;