@h3ravel/view 0.1.14-alpha.9 → 0.1.15
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 +11 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -8
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
2
2
|
let __h3ravel_musket = require("@h3ravel/musket");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
let edge_js = require("edge.js");
|
|
5
|
-
let
|
|
6
|
-
let __h3ravel_support = require("@h3ravel/support");
|
|
5
|
+
let __h3ravel_core = require("@h3ravel/core");
|
|
7
6
|
|
|
8
7
|
//#region src/Commands/MakeViewCommand.ts
|
|
9
8
|
/**
|
|
@@ -88,13 +87,15 @@ var EdgeViewEngine = class {
|
|
|
88
87
|
*
|
|
89
88
|
* Registers the view engine with the application container
|
|
90
89
|
*/
|
|
91
|
-
var ViewServiceProvider = class extends
|
|
90
|
+
var ViewServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
92
91
|
static priority = 995;
|
|
93
92
|
async register() {
|
|
94
|
-
const
|
|
93
|
+
const viewEngine = new EdgeViewEngine({
|
|
95
94
|
viewsPath: this.app.getPath("views"),
|
|
96
95
|
cache: process.env.NODE_ENV === "production"
|
|
97
|
-
})
|
|
96
|
+
});
|
|
97
|
+
viewEngine.global("app", this.app);
|
|
98
|
+
const edge = viewEngine.getEdge();
|
|
98
99
|
/**
|
|
99
100
|
* Bind the view engine to the container
|
|
100
101
|
*/
|
|
@@ -109,12 +110,13 @@ var ViewServiceProvider = class extends __h3ravel_support.ServiceProvider {
|
|
|
109
110
|
* @returns
|
|
110
111
|
*/
|
|
111
112
|
const view = async (template, data) => {
|
|
112
|
-
|
|
113
|
-
const request = this.app.make("http.request");
|
|
114
|
-
if (response instanceof __h3ravel_http.Responsable) response = response.toResponse(request);
|
|
115
|
-
return response.html(await this.app.make("edge").render(template, data), true);
|
|
113
|
+
return this.app.make("http.response").html(await this.app.make("edge").render(template, data));
|
|
116
114
|
};
|
|
117
115
|
/**
|
|
116
|
+
* Bind the view method to the global variable space
|
|
117
|
+
*/
|
|
118
|
+
globalThis.view = view;
|
|
119
|
+
/**
|
|
118
120
|
* Dynamically bind the view renderer to the service container.
|
|
119
121
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
120
122
|
*/
|
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/core";
|
|
5
5
|
|
|
6
6
|
//#region src/Commands/MakeViewCommand.d.ts
|
|
7
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@ 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
|
-
import { ServiceProvider } from "@h3ravel/support";
|
|
5
|
+
import { ServiceProvider } from "@h3ravel/core";
|
|
7
6
|
|
|
8
7
|
//#region src/Commands/MakeViewCommand.ts
|
|
9
8
|
/**
|
|
@@ -91,10 +90,12 @@ var EdgeViewEngine = class {
|
|
|
91
90
|
var ViewServiceProvider = class extends ServiceProvider {
|
|
92
91
|
static priority = 995;
|
|
93
92
|
async register() {
|
|
94
|
-
const
|
|
93
|
+
const viewEngine = new EdgeViewEngine({
|
|
95
94
|
viewsPath: this.app.getPath("views"),
|
|
96
95
|
cache: process.env.NODE_ENV === "production"
|
|
97
|
-
})
|
|
96
|
+
});
|
|
97
|
+
viewEngine.global("app", this.app);
|
|
98
|
+
const edge = viewEngine.getEdge();
|
|
98
99
|
/**
|
|
99
100
|
* Bind the view engine to the container
|
|
100
101
|
*/
|
|
@@ -109,12 +110,13 @@ var ViewServiceProvider = class extends ServiceProvider {
|
|
|
109
110
|
* @returns
|
|
110
111
|
*/
|
|
111
112
|
const view = async (template, data) => {
|
|
112
|
-
|
|
113
|
-
const request = this.app.make("http.request");
|
|
114
|
-
if (response instanceof Responsable) response = response.toResponse(request);
|
|
115
|
-
return response.html(await this.app.make("edge").render(template, data), true);
|
|
113
|
+
return this.app.make("http.response").html(await this.app.make("edge").render(template, data));
|
|
116
114
|
};
|
|
117
115
|
/**
|
|
116
|
+
* Bind the view method to the global variable space
|
|
117
|
+
*/
|
|
118
|
+
globalThis.view = view;
|
|
119
|
+
/**
|
|
118
120
|
* Dynamically bind the view renderer to the service container.
|
|
119
121
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
120
122
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "View rendering system for H3ravel framework",
|
|
5
5
|
"h3ravel": {
|
|
6
6
|
"providers": [
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://h3ravel.toneflix.net",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@h3ravel/musket": "
|
|
47
|
-
"
|
|
48
|
-
"@h3ravel/
|
|
49
|
-
"
|
|
46
|
+
"@h3ravel/musket": "~0.3.13",
|
|
47
|
+
"edge.js": "^6.3.0",
|
|
48
|
+
"@h3ravel/core": "~1.21.9",
|
|
49
|
+
"@h3ravel/http": "~11.7.9"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vitest": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@h3ravel/shared": "
|
|
57
|
-
"@h3ravel/support": "^0.17.0-alpha.9"
|
|
56
|
+
"@h3ravel/shared": "~0.27.9"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
59
|
"dev": "tsx watch src/index.ts",
|
|
61
60
|
"typecheck": "tsc --noEmit",
|
|
61
|
+
"barrel": "barrelsby --directory src --delete --singleQuotes",
|
|
62
62
|
"build": "tsdown --config-loader unconfig",
|
|
63
63
|
"start": "node dist/index.js",
|
|
64
64
|
"lint": "eslint . --ext .ts",
|