@h3ravel/view 0.1.13 → 0.1.14-alpha.2
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 +9 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -10
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,8 @@ 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
|
|
5
|
+
let __h3ravel_http = require("@h3ravel/http");
|
|
6
|
+
let __h3ravel_support = require("@h3ravel/support");
|
|
6
7
|
|
|
7
8
|
//#region src/Commands/MakeViewCommand.ts
|
|
8
9
|
/**
|
|
@@ -87,15 +88,13 @@ var EdgeViewEngine = class {
|
|
|
87
88
|
*
|
|
88
89
|
* Registers the view engine with the application container
|
|
89
90
|
*/
|
|
90
|
-
var ViewServiceProvider = class extends
|
|
91
|
+
var ViewServiceProvider = class extends __h3ravel_support.ServiceProvider {
|
|
91
92
|
static priority = 995;
|
|
92
93
|
async register() {
|
|
93
|
-
const
|
|
94
|
+
const edge = new EdgeViewEngine({
|
|
94
95
|
viewsPath: this.app.getPath("views"),
|
|
95
96
|
cache: process.env.NODE_ENV === "production"
|
|
96
|
-
});
|
|
97
|
-
viewEngine.global("app", this.app);
|
|
98
|
-
const edge = viewEngine.getEdge();
|
|
97
|
+
}).getEdge();
|
|
99
98
|
/**
|
|
100
99
|
* Bind the view engine to the container
|
|
101
100
|
*/
|
|
@@ -110,13 +109,12 @@ var ViewServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
110
109
|
* @returns
|
|
111
110
|
*/
|
|
112
111
|
const view = async (template, data) => {
|
|
113
|
-
|
|
112
|
+
let response = this.app.make("http.response");
|
|
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);
|
|
114
116
|
};
|
|
115
117
|
/**
|
|
116
|
-
* Bind the view method to the global variable space
|
|
117
|
-
*/
|
|
118
|
-
globalThis.view = view;
|
|
119
|
-
/**
|
|
120
118
|
* Dynamically bind the view renderer to the service container.
|
|
121
119
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
122
120
|
*/
|
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,7 +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 {
|
|
5
|
+
import { Responsable } from "@h3ravel/http";
|
|
6
|
+
import { ServiceProvider } from "@h3ravel/support";
|
|
6
7
|
|
|
7
8
|
//#region src/Commands/MakeViewCommand.ts
|
|
8
9
|
/**
|
|
@@ -90,12 +91,10 @@ var EdgeViewEngine = class {
|
|
|
90
91
|
var ViewServiceProvider = class extends ServiceProvider {
|
|
91
92
|
static priority = 995;
|
|
92
93
|
async register() {
|
|
93
|
-
const
|
|
94
|
+
const edge = new EdgeViewEngine({
|
|
94
95
|
viewsPath: this.app.getPath("views"),
|
|
95
96
|
cache: process.env.NODE_ENV === "production"
|
|
96
|
-
});
|
|
97
|
-
viewEngine.global("app", this.app);
|
|
98
|
-
const edge = viewEngine.getEdge();
|
|
97
|
+
}).getEdge();
|
|
99
98
|
/**
|
|
100
99
|
* Bind the view engine to the container
|
|
101
100
|
*/
|
|
@@ -110,13 +109,12 @@ var ViewServiceProvider = class extends ServiceProvider {
|
|
|
110
109
|
* @returns
|
|
111
110
|
*/
|
|
112
111
|
const view = async (template, data) => {
|
|
113
|
-
|
|
112
|
+
let response = this.app.make("http.response");
|
|
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);
|
|
114
116
|
};
|
|
115
117
|
/**
|
|
116
|
-
* Bind the view method to the global variable space
|
|
117
|
-
*/
|
|
118
|
-
globalThis.view = view;
|
|
119
|
-
/**
|
|
120
118
|
* Dynamically bind the view renderer to the service container.
|
|
121
119
|
* This allows any part of the request lifecycle to render templates using Edge.
|
|
122
120
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14-alpha.2",
|
|
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": "^0.
|
|
46
|
+
"@h3ravel/musket": "^0.6.11",
|
|
47
47
|
"edge.js": "^6.3.0",
|
|
48
|
-
"@h3ravel/
|
|
49
|
-
"@h3ravel/
|
|
48
|
+
"@h3ravel/http": "11.8.0-alpha.2",
|
|
49
|
+
"@h3ravel/core": "1.22.0-alpha.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vitest": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@h3ravel/
|
|
56
|
+
"@h3ravel/support": "0.17.0-alpha.2",
|
|
57
|
+
"@h3ravel/shared": "0.29.0-alpha.2"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"dev": "tsx watch src/index.ts",
|
|
60
61
|
"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",
|