@h3ravel/view 0.1.18 → 1.29.0-alpha.11
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/index.cjs +13 -18
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -15
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1
2
|
let node_fs_promises = require("node:fs/promises");
|
|
2
|
-
let
|
|
3
|
+
let _h3ravel_musket = require("@h3ravel/musket");
|
|
3
4
|
let node_path = require("node:path");
|
|
4
5
|
let edge_js = require("edge.js");
|
|
5
|
-
let
|
|
6
|
-
|
|
6
|
+
let _h3ravel_http = require("@h3ravel/http");
|
|
7
|
+
let _h3ravel_support = require("@h3ravel/support");
|
|
7
8
|
//#region src/Commands/MakeViewCommand.ts
|
|
8
9
|
/**
|
|
9
10
|
* Command to create new view files
|
|
10
11
|
*/
|
|
11
|
-
var MakeViewCommand = class extends
|
|
12
|
+
var MakeViewCommand = class extends _h3ravel_musket.Command {
|
|
12
13
|
/**
|
|
13
14
|
* Create a new view file
|
|
14
15
|
*
|
|
@@ -32,7 +33,6 @@ var MakeViewCommand = class extends __h3ravel_musket.Command {
|
|
|
32
33
|
</div>`);
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
|
-
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/EdgeViewEngine.ts
|
|
38
38
|
/**
|
|
@@ -79,7 +79,6 @@ var EdgeViewEngine = class {
|
|
|
79
79
|
return this.edge;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
82
|
//#endregion
|
|
84
83
|
//#region src/Providers/ViewServiceProvider.ts
|
|
85
84
|
/**
|
|
@@ -87,15 +86,13 @@ var EdgeViewEngine = class {
|
|
|
87
86
|
*
|
|
88
87
|
* Registers the view engine with the application container
|
|
89
88
|
*/
|
|
90
|
-
var ViewServiceProvider = class extends
|
|
89
|
+
var ViewServiceProvider = class extends _h3ravel_support.ServiceProvider {
|
|
91
90
|
static priority = 995;
|
|
92
91
|
async register() {
|
|
93
|
-
const
|
|
92
|
+
const edge = new EdgeViewEngine({
|
|
94
93
|
viewsPath: this.app.getPath("views"),
|
|
95
94
|
cache: process.env.NODE_ENV === "production"
|
|
96
|
-
});
|
|
97
|
-
viewEngine.global("app", this.app);
|
|
98
|
-
const edge = viewEngine.getEdge();
|
|
95
|
+
}).getEdge();
|
|
99
96
|
/**
|
|
100
97
|
* Bind the view engine to the container
|
|
101
98
|
*/
|
|
@@ -110,22 +107,20 @@ var ViewServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
110
107
|
* @returns
|
|
111
108
|
*/
|
|
112
109
|
const view = async (template, data) => {
|
|
113
|
-
|
|
110
|
+
let response = this.app.make("http.response");
|
|
111
|
+
const request = this.app.make("http.request");
|
|
112
|
+
if (response instanceof _h3ravel_http.Responsable) response = response.toResponse(request);
|
|
113
|
+
return response.html(await this.app.make("edge").render(template, data), true);
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
116
|
-
* Bind the view method to the global variable space
|
|
117
|
-
*/
|
|
118
|
-
globalThis.view = view;
|
|
119
|
-
/**
|
|
120
116
|
* Dynamically bind the view renderer to the service container.
|
|
121
117
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
122
118
|
*/
|
|
123
119
|
this.app.bind("view", () => view);
|
|
124
120
|
}
|
|
125
121
|
};
|
|
126
|
-
|
|
127
122
|
//#endregion
|
|
128
123
|
exports.EdgeViewEngine = EdgeViewEngine;
|
|
129
124
|
exports.MakeViewCommand = MakeViewCommand;
|
|
130
125
|
exports.ViewManager = EdgeViewEngine;
|
|
131
|
-
exports.ViewServiceProvider = ViewServiceProvider;
|
|
126
|
+
exports.ViewServiceProvider = ViewServiceProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { Command } from "@h3ravel/musket";
|
|
3
3
|
import { Edge } from "edge.js";
|
|
4
|
-
import { ServiceProvider } from "@h3ravel/
|
|
4
|
+
import { ServiceProvider } from "@h3ravel/support";
|
|
5
5
|
|
|
6
6
|
//#region src/Commands/MakeViewCommand.d.ts
|
|
7
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { Command } from "@h3ravel/musket";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
4
|
import { Edge } from "edge.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { Responsable } from "@h3ravel/http";
|
|
6
|
+
import { ServiceProvider } from "@h3ravel/support";
|
|
7
7
|
//#region src/Commands/MakeViewCommand.ts
|
|
8
8
|
/**
|
|
9
9
|
* Command to create new view files
|
|
@@ -32,7 +32,6 @@ var MakeViewCommand = class extends Command {
|
|
|
32
32
|
</div>`);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
|
|
36
35
|
//#endregion
|
|
37
36
|
//#region src/EdgeViewEngine.ts
|
|
38
37
|
/**
|
|
@@ -79,7 +78,6 @@ var EdgeViewEngine = class {
|
|
|
79
78
|
return this.edge;
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
|
-
|
|
83
81
|
//#endregion
|
|
84
82
|
//#region src/Providers/ViewServiceProvider.ts
|
|
85
83
|
/**
|
|
@@ -90,12 +88,10 @@ var EdgeViewEngine = class {
|
|
|
90
88
|
var ViewServiceProvider = class extends ServiceProvider {
|
|
91
89
|
static priority = 995;
|
|
92
90
|
async register() {
|
|
93
|
-
const
|
|
91
|
+
const edge = new EdgeViewEngine({
|
|
94
92
|
viewsPath: this.app.getPath("views"),
|
|
95
93
|
cache: process.env.NODE_ENV === "production"
|
|
96
|
-
});
|
|
97
|
-
viewEngine.global("app", this.app);
|
|
98
|
-
const edge = viewEngine.getEdge();
|
|
94
|
+
}).getEdge();
|
|
99
95
|
/**
|
|
100
96
|
* Bind the view engine to the container
|
|
101
97
|
*/
|
|
@@ -110,19 +106,17 @@ var ViewServiceProvider = class extends ServiceProvider {
|
|
|
110
106
|
* @returns
|
|
111
107
|
*/
|
|
112
108
|
const view = async (template, data) => {
|
|
113
|
-
|
|
109
|
+
let response = this.app.make("http.response");
|
|
110
|
+
const request = this.app.make("http.request");
|
|
111
|
+
if (response instanceof Responsable) response = response.toResponse(request);
|
|
112
|
+
return response.html(await this.app.make("edge").render(template, data), true);
|
|
114
113
|
};
|
|
115
114
|
/**
|
|
116
|
-
* Bind the view method to the global variable space
|
|
117
|
-
*/
|
|
118
|
-
globalThis.view = view;
|
|
119
|
-
/**
|
|
120
115
|
* Dynamically bind the view renderer to the service container.
|
|
121
116
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
122
117
|
*/
|
|
123
118
|
this.app.bind("view", () => view);
|
|
124
119
|
}
|
|
125
120
|
};
|
|
126
|
-
|
|
127
121
|
//#endregion
|
|
128
|
-
export { EdgeViewEngine, EdgeViewEngine as ViewManager, MakeViewCommand, ViewServiceProvider };
|
|
122
|
+
export { EdgeViewEngine, EdgeViewEngine as ViewManager, MakeViewCommand, ViewServiceProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/view",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.29.0-alpha.11",
|
|
4
4
|
"description": "View rendering system for H3ravel framework",
|
|
5
5
|
"h3ravel": {
|
|
6
6
|
"providers": [
|
|
@@ -43,23 +43,23 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://h3ravel.toneflix.net",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@h3ravel/musket": "
|
|
47
|
-
"
|
|
48
|
-
"@h3ravel/
|
|
49
|
-
"
|
|
46
|
+
"@h3ravel/musket": "^0.8.0-alpha.7",
|
|
47
|
+
"@h3ravel/core": "^1.29.0-alpha.11",
|
|
48
|
+
"@h3ravel/http": "^11.15.0-alpha.11",
|
|
49
|
+
"edge.js": "^6.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
|
-
"vitest": "^
|
|
53
|
+
"vitest": "^4.1.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@h3ravel/shared": "
|
|
56
|
+
"@h3ravel/shared": "^1.29.0-alpha.11",
|
|
57
|
+
"@h3ravel/support": "^1.29.0-alpha.11"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"dev": "tsx watch src/index.ts",
|
|
60
61
|
"typecheck": "tsc --noEmit",
|
|
61
|
-
"
|
|
62
|
-
"build": "tsdown --config-loader unconfig",
|
|
62
|
+
"build": "tsdown --config-loader unrun",
|
|
63
63
|
"start": "node dist/index.js",
|
|
64
64
|
"lint": "eslint . --ext .ts",
|
|
65
65
|
"test": "jest --passWithNoTests",
|