@gravito/ion 4.0.1 β†’ 4.0.3

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/README.md CHANGED
@@ -7,14 +7,28 @@
7
7
  ## ✨ Key Features
8
8
 
9
9
  - **πŸš€ Modern Monolith Architecture**: Combine the productivity of server-side routing with the interactivity of SPA frameworks.
10
- - **πŸ› οΈ Zero API Development**: Pass data directly from controllers to components as typed propsβ€”no more managing endpoints or manual serialization.
11
- - **⚑ High-Performance Rendering**: Built-in multi-layer caching, version caching (60s TTL), and component metadata optimization.
12
- - **πŸ›‘οΈ Native Type Safety**: Full TypeScript support with generics for props, ensuring end-to-end type safety from server to client.
13
- - **πŸ”— Ecosystem Integration**: Seamlessly works with `OrbitPrism` for root templates and Gravito's session/auth modules.
14
- - **πŸ” SEO & SSR Friendly**: Designed for modern web requirements, supporting Server-Side Rendering patterns for optimal visibility.
15
- - **🎨 Multi-Framework Support**: Official support for **React**, **Vue**, and **Svelte**.
10
+ - **🌌 Galaxy-Ready Interface**: Native integration with PlanetCore for universal frontend state management across Satellites.
11
+ - **πŸ› οΈ Zero API Development**: Pass data directly from controllers to components as typed propsβ€”no more managing endpoints.
12
+ - **⚑ High-Performance Rendering**: Built-in multi-layer caching and versioning optimized for the Bun runtime.
13
+ - **πŸ›‘οΈ Native Type Safety**: End-to-end TypeScript support with automatic generics for server-to-client propagation.
16
14
  - **✨ Inertia v2 Protocol**: Full support for deferred props, merge strategies, error bags, and CSRF protection.
17
15
 
16
+ ## 🌌 Role in Galaxy Architecture
17
+
18
+ In the **Gravito Galaxy Architecture**, Ion acts as the **Neural Bridge (Monolith Interface)**.
19
+
20
+ - **Unified Frontend Overlay**: Connects the `Photon` Sensing Layer directly to the UI components (React/Vue/Svelte), allowing Satellites to control the user experience without needing a complex REST/GraphQL middle layer.
21
+ - **Context Teleporter**: Effortlessly propagates the "State of the Galaxy" (User, Auth, Permissions) from the backend IoC container directly into the frontend component tree as "Shared Props".
22
+ - **Productivity Catalyst**: Enables rapid development of feature-rich administrative interfaces and dashboards that interact with multiple Satellites through a single "Stateful" pipeline.
23
+
24
+ ```mermaid
25
+ graph LR
26
+ S[Satellite: Membership] -- "render('Profile', data)" --> Ion{Ion Bridge}
27
+ Ion -->|Teleport State| UI[Frontend: React/Vue]
28
+ UI -->|XHR Request| Photon[Photon Sensing Layer]
29
+ Photon --> S
30
+ ```
31
+
18
32
  ## πŸ“¦ Installation
19
33
 
20
34
  ```bash
@@ -75,6 +89,14 @@ export class DashboardController {
75
89
  }
76
90
  ```
77
91
 
92
+ ## πŸ“š Documentation
93
+
94
+ Detailed guides and references for the Galaxy Architecture:
95
+
96
+ - [πŸ—οΈ **Architecture Overview**](./README.md) β€” Inertia.js integration and monolith bridge.
97
+ - [πŸŒ‰ **Modern Monolith**](./doc/MODERN_MONOLITH.md) β€” **NEW**: Zero-API philosophy, shared props, and deferred loading.
98
+ - [✨ **Inertia v2 Protocol**](#-inertia-v2-protocol-features) β€” New protocol features and migration.
99
+
78
100
  ## πŸ”§ Inertia v2 Protocol Features
79
101
 
80
102
  ### Deferred Props (Lazy Loading)
package/dist/index.cjs CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -30,6 +29,9 @@ __export(index_exports, {
30
29
  });
31
30
  module.exports = __toCommonJS(index_exports);
32
31
 
32
+ // src/InertiaService.ts
33
+ var import_core = require("@gravito/core");
34
+
33
35
  // src/errors.ts
34
36
  var InertiaError = class extends Error {
35
37
  constructor(code, httpStatus = 500, details) {
@@ -102,6 +104,15 @@ var InertiaService = class {
102
104
  clearHistoryFlag = false;
103
105
  logLevel;
104
106
  onRenderCallback;
107
+ escapeHtml = (0, import_core.getEscapeHtml)();
108
+ appendVaryHeader(...values) {
109
+ const existing = this.context.res?.headers?.get?.("Vary") ?? "";
110
+ const current = existing.split(",").map((value) => value.trim()).filter(Boolean);
111
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...values]));
112
+ if (merged.length > 0) {
113
+ this.context.header("Vary", merged.join(", "));
114
+ }
115
+ }
105
116
  /**
106
117
  * Creates a deferred prop that will be loaded after the initial render.
107
118
  *
@@ -194,7 +205,7 @@ var InertiaService = class {
194
205
  * @returns Safely escaped HTML attribute value.
195
206
  */
196
207
  escapeForSingleQuotedHtmlAttribute(value) {
197
- return value.replace(/&/g, "&amp;").replace(/\\"/g, "\\&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#039;");
208
+ return this.escapeHtml(value).replace(/\\"/g, "\\&quot;");
198
209
  }
199
210
  /**
200
211
  * Renders an Inertia component and returns the appropriate HTTP response.
@@ -367,7 +378,7 @@ var InertiaService = class {
367
378
  return new Response("", { status: 409 });
368
379
  }
369
380
  this.context.header("X-Inertia", "true");
370
- this.context.header("Vary", "Accept");
381
+ this.appendVaryHeader("Accept", "X-Inertia");
371
382
  response = this.context.json(page, status);
372
383
  } else {
373
384
  const view = this.context.get("view");
@@ -553,6 +564,7 @@ var InertiaService = class {
553
564
  location(url) {
554
565
  const isInertiaRequest = Boolean(this.context.req.header("X-Inertia"));
555
566
  if (isInertiaRequest) {
567
+ this.appendVaryHeader("X-Inertia");
556
568
  this.context.header("X-Inertia-Location", url);
557
569
  return new Response("", { status: 409 });
558
570
  }
package/dist/index.d.cts CHANGED
@@ -255,6 +255,8 @@ declare class InertiaService {
255
255
  private clearHistoryFlag;
256
256
  private readonly logLevel;
257
257
  private readonly onRenderCallback?;
258
+ private escapeHtml;
259
+ private appendVaryHeader;
258
260
  /**
259
261
  * Creates a deferred prop that will be loaded after the initial render.
260
262
  *
@@ -485,14 +487,14 @@ declare class InertiaService {
485
487
  declare class InertiaError extends Error {
486
488
  readonly code: string;
487
489
  readonly httpStatus: number;
488
- readonly details?: Record<string, any> | undefined;
489
- constructor(code: string, httpStatus?: number, details?: Record<string, any> | undefined);
490
+ readonly details?: Record<string, any>;
491
+ constructor(code: string, httpStatus?: number, details?: Record<string, any>);
490
492
  toJSON(): {
491
493
  name: string;
492
494
  code: string;
493
495
  httpStatus: number;
494
496
  message: string;
495
- details: Record<string, any> | undefined;
497
+ details: Record<string, any>;
496
498
  };
497
499
  }
498
500
  /**
package/dist/index.d.ts CHANGED
@@ -255,6 +255,8 @@ declare class InertiaService {
255
255
  private clearHistoryFlag;
256
256
  private readonly logLevel;
257
257
  private readonly onRenderCallback?;
258
+ private escapeHtml;
259
+ private appendVaryHeader;
258
260
  /**
259
261
  * Creates a deferred prop that will be loaded after the initial render.
260
262
  *
@@ -485,14 +487,14 @@ declare class InertiaService {
485
487
  declare class InertiaError extends Error {
486
488
  readonly code: string;
487
489
  readonly httpStatus: number;
488
- readonly details?: Record<string, any> | undefined;
489
- constructor(code: string, httpStatus?: number, details?: Record<string, any> | undefined);
490
+ readonly details?: Record<string, any>;
491
+ constructor(code: string, httpStatus?: number, details?: Record<string, any>);
490
492
  toJSON(): {
491
493
  name: string;
492
494
  code: string;
493
495
  httpStatus: number;
494
496
  message: string;
495
- details: Record<string, any> | undefined;
497
+ details: Record<string, any>;
496
498
  };
497
499
  }
498
500
  /**
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // src/InertiaService.ts
2
+ import { getEscapeHtml } from "@gravito/core";
3
+
1
4
  // src/errors.ts
2
5
  var InertiaError = class extends Error {
3
6
  constructor(code, httpStatus = 500, details) {
@@ -70,6 +73,15 @@ var InertiaService = class {
70
73
  clearHistoryFlag = false;
71
74
  logLevel;
72
75
  onRenderCallback;
76
+ escapeHtml = getEscapeHtml();
77
+ appendVaryHeader(...values) {
78
+ const existing = this.context.res?.headers?.get?.("Vary") ?? "";
79
+ const current = existing.split(",").map((value) => value.trim()).filter(Boolean);
80
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...values]));
81
+ if (merged.length > 0) {
82
+ this.context.header("Vary", merged.join(", "));
83
+ }
84
+ }
73
85
  /**
74
86
  * Creates a deferred prop that will be loaded after the initial render.
75
87
  *
@@ -162,7 +174,7 @@ var InertiaService = class {
162
174
  * @returns Safely escaped HTML attribute value.
163
175
  */
164
176
  escapeForSingleQuotedHtmlAttribute(value) {
165
- return value.replace(/&/g, "&amp;").replace(/\\"/g, "\\&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#039;");
177
+ return this.escapeHtml(value).replace(/\\"/g, "\\&quot;");
166
178
  }
167
179
  /**
168
180
  * Renders an Inertia component and returns the appropriate HTTP response.
@@ -335,7 +347,7 @@ var InertiaService = class {
335
347
  return new Response("", { status: 409 });
336
348
  }
337
349
  this.context.header("X-Inertia", "true");
338
- this.context.header("Vary", "Accept");
350
+ this.appendVaryHeader("Accept", "X-Inertia");
339
351
  response = this.context.json(page, status);
340
352
  } else {
341
353
  const view = this.context.get("view");
@@ -521,6 +533,7 @@ var InertiaService = class {
521
533
  location(url) {
522
534
  const isInertiaRequest = Boolean(this.context.req.header("X-Inertia"));
523
535
  if (isInertiaRequest) {
536
+ this.appendVaryHeader("X-Inertia");
524
537
  this.context.header("X-Inertia-Location", url);
525
538
  return new Response("", { status: 409 });
526
539
  }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@gravito/ion",
3
- "version": "4.0.1",
3
+ "sideEffects": false,
4
+ "version": "4.0.3",
4
5
  "description": "Inertia.js v2 adapter for Gravito",
5
6
  "main": "./dist/index.cjs",
6
7
  "module": "./dist/index.js",
@@ -8,6 +9,7 @@
8
9
  "types": "./dist/index.d.ts",
9
10
  "exports": {
10
11
  ".": {
12
+ "bun": "./dist/index.js",
11
13
  "types": "./dist/index.d.ts",
12
14
  "import": "./dist/index.js",
13
15
  "require": "./dist/index.cjs"
@@ -20,6 +22,7 @@
20
22
  ],
21
23
  "scripts": {
22
24
  "build": "bun run build.ts",
25
+ "build:dts": "bun run build.ts --dts-only",
23
26
  "test": "bun test --timeout=10000",
24
27
  "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
25
28
  "test:coverage": "bun test --timeout=10000 --coverage --coverage-reporter=lcov --coverage-dir coverage && bun run --bun scripts/check-coverage.ts",
@@ -28,13 +31,13 @@
28
31
  "test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'"
29
32
  },
30
33
  "peerDependencies": {
31
- "@gravito/core": "^1.6.1",
32
- "@gravito/photon": "^1.0.1"
34
+ "@gravito/core": "^2.0.0",
35
+ "@gravito/photon": "^1.1.0"
33
36
  },
34
37
  "devDependencies": {
35
38
  "bun-types": "latest",
36
- "@gravito/core": "^1.6.1",
37
- "@gravito/photon": "^1.0.1",
39
+ "@gravito/core": "workspace:*",
40
+ "@gravito/photon": "workspace:*",
38
41
  "tsup": "^8.5.1",
39
42
  "typescript": "^5.9.3"
40
43
  },