@tsed/platform-views 8.0.0-rc.5 → 8.0.0
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/lib/esm/decorators/view.js +5 -1
- package/lib/esm/decorators/view.js.map +1 -1
- package/lib/esm/services/PlatformViews.js +26 -47
- package/lib/esm/services/PlatformViews.js.map +1 -1
- package/lib/types/decorators/view.d.ts +5 -1
- package/lib/types/services/PlatformViews.d.ts +4 -5
- package/package.json +15 -18
- package/vitest.config.mts +9 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/decorators/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/decorators/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,CAAC,EAAC,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAa,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../domain/PlatformViewsSettings.js";
|
|
2
2
|
import { Env, getValue } from "@tsed/core";
|
|
3
|
-
import {
|
|
3
|
+
import { constant, injectable, ProviderType } from "@tsed/di";
|
|
4
4
|
import { engines, getEngine, requires } from "@tsed/engines";
|
|
5
|
+
import { $asyncAlter } from "@tsed/hooks";
|
|
5
6
|
import Fs from "fs";
|
|
6
7
|
import { extname, join, resolve } from "path";
|
|
7
8
|
import { PLATFORM_VIEWS_EXTENSIONS } from "../domain/PlatformViewsSettings.js";
|
|
@@ -19,10 +20,21 @@ async function patchEJS(ejs) {
|
|
|
19
20
|
/**
|
|
20
21
|
* @platform
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
export class PlatformViews {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.root = constant("views.root", `${process.cwd()}/views`);
|
|
26
|
+
this.cache = constant("views.cache");
|
|
27
|
+
this.disabled = constant("views.disabled", false);
|
|
28
|
+
this.viewEngine = constant("views.viewEngine", "ejs");
|
|
29
|
+
this.env = constant("env");
|
|
30
|
+
this.extensionsOptions = constant("views.extensions", {});
|
|
31
|
+
this.engineOptions = constant("views.options", {});
|
|
32
|
+
this.#engines = new Map();
|
|
33
|
+
this.#cachePaths = new Map();
|
|
34
|
+
}
|
|
23
35
|
#extensions;
|
|
24
|
-
#engines
|
|
25
|
-
#cachePaths
|
|
36
|
+
#engines;
|
|
37
|
+
#cachePaths;
|
|
26
38
|
async $onInit() {
|
|
27
39
|
if (!this.disabled) {
|
|
28
40
|
this.#extensions = new Map(Object.entries({
|
|
@@ -68,7 +80,7 @@ let PlatformViews = class PlatformViews {
|
|
|
68
80
|
}
|
|
69
81
|
async render(viewPath, options = {}) {
|
|
70
82
|
const { $ctx } = options;
|
|
71
|
-
options = await
|
|
83
|
+
options = await $asyncAlter("$alterRenderOptions", options, $ctx);
|
|
72
84
|
const { path, extension } = this.#cachePaths.get(viewPath) || this.#cachePaths.set(viewPath, this.resolve(viewPath)).get(viewPath);
|
|
73
85
|
const engine = this.getEngine(extension);
|
|
74
86
|
if (!engine) {
|
|
@@ -94,45 +106,12 @@ let PlatformViews = class PlatformViews {
|
|
|
94
106
|
extension
|
|
95
107
|
};
|
|
96
108
|
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
], PlatformViews.prototype, "root", void 0);
|
|
106
|
-
__decorate([
|
|
107
|
-
Constant("views.cache"),
|
|
108
|
-
__metadata("design:type", Boolean)
|
|
109
|
-
], PlatformViews.prototype, "cache", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
Constant("views.disabled", false),
|
|
112
|
-
__metadata("design:type", String)
|
|
113
|
-
], PlatformViews.prototype, "disabled", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
Constant("views.viewEngine", "ejs"),
|
|
116
|
-
__metadata("design:type", String)
|
|
117
|
-
], PlatformViews.prototype, "viewEngine", void 0);
|
|
118
|
-
__decorate([
|
|
119
|
-
Constant("views.extensions", {}),
|
|
120
|
-
__metadata("design:type", Object)
|
|
121
|
-
], PlatformViews.prototype, "extensionsOptions", void 0);
|
|
122
|
-
__decorate([
|
|
123
|
-
Constant("views.options", {}),
|
|
124
|
-
__metadata("design:type", Object)
|
|
125
|
-
], PlatformViews.prototype, "engineOptions", void 0);
|
|
126
|
-
__decorate([
|
|
127
|
-
Inject(),
|
|
128
|
-
__metadata("design:type", InjectorService)
|
|
129
|
-
], PlatformViews.prototype, "injector", void 0);
|
|
130
|
-
PlatformViews = __decorate([
|
|
131
|
-
Module({
|
|
132
|
-
views: {
|
|
133
|
-
exists: true
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
], PlatformViews);
|
|
137
|
-
export { PlatformViews };
|
|
109
|
+
}
|
|
110
|
+
injectable(PlatformViews)
|
|
111
|
+
.type(ProviderType.MODULE)
|
|
112
|
+
.configuration({
|
|
113
|
+
views: {
|
|
114
|
+
exists: true
|
|
115
|
+
}
|
|
116
|
+
});
|
|
138
117
|
//# sourceMappingURL=PlatformViews.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformViews.js","sourceRoot":"","sources":["../../../src/services/PlatformViews.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformViews.js","sourceRoot":"","sources":["../../../src/services/PlatformViews.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC3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PlatformViewEngine, PlatformViewsEngineOptions, PlatformViewsExtensionsTypes, PlatformViewWritableStream } from "../domain/PlatformViewsSettings.js";
|
|
4
4
|
/**
|
|
5
5
|
* @platform
|
|
6
6
|
*/
|
|
7
7
|
export declare class PlatformViews {
|
|
8
8
|
#private;
|
|
9
|
-
env: Env;
|
|
10
9
|
readonly root: string;
|
|
11
|
-
readonly cache: boolean;
|
|
12
|
-
readonly disabled: string;
|
|
10
|
+
readonly cache: boolean | undefined;
|
|
11
|
+
readonly disabled: string | boolean;
|
|
13
12
|
readonly viewEngine: string;
|
|
13
|
+
protected env: Env | undefined;
|
|
14
14
|
protected extensionsOptions: PlatformViewsExtensionsTypes;
|
|
15
15
|
protected engineOptions: Record<string, PlatformViewsEngineOptions>;
|
|
16
|
-
protected injector: InjectorService;
|
|
17
16
|
$onInit(): Promise<void>;
|
|
18
17
|
loadEngines(): Promise<void>;
|
|
19
18
|
getEngines(): {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/platform-views",
|
|
3
3
|
"description": "Views module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0
|
|
5
|
+
"version": "8.0.0",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -21,29 +21,29 @@
|
|
|
21
21
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tsed/engines": "8.0.0
|
|
24
|
+
"@tsed/engines": "8.0.0",
|
|
25
25
|
"ejs": "^3.1.10",
|
|
26
26
|
"tslib": "2.7.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@tsed/barrels": "8.0.0
|
|
30
|
-
"@tsed/core": "8.0.0
|
|
31
|
-
"@tsed/di": "8.0.0
|
|
32
|
-
"@tsed/engines": "8.0.0
|
|
33
|
-
"@tsed/exceptions": "8.0.0
|
|
34
|
-
"@tsed/schema": "8.0.0
|
|
35
|
-
"@tsed/typescript": "8.0.0
|
|
29
|
+
"@tsed/barrels": "8.0.0",
|
|
30
|
+
"@tsed/core": "8.0.0",
|
|
31
|
+
"@tsed/di": "8.0.0",
|
|
32
|
+
"@tsed/engines": "8.0.0",
|
|
33
|
+
"@tsed/exceptions": "8.0.0",
|
|
34
|
+
"@tsed/schema": "8.0.0",
|
|
35
|
+
"@tsed/typescript": "8.0.0",
|
|
36
36
|
"@types/ejs": "3.1.5",
|
|
37
37
|
"eslint": "9.12.0",
|
|
38
38
|
"typescript": "5.4.5",
|
|
39
39
|
"vitest": "2.1.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@tsed/core": "8.0.0
|
|
43
|
-
"@tsed/di": "8.0.0
|
|
44
|
-
"@tsed/engines": "8.0.0
|
|
45
|
-
"@tsed/exceptions": "8.0.0
|
|
46
|
-
"@tsed/schema": "8.0.0
|
|
42
|
+
"@tsed/core": "8.0.0",
|
|
43
|
+
"@tsed/di": "8.0.0",
|
|
44
|
+
"@tsed/engines": "8.0.0",
|
|
45
|
+
"@tsed/exceptions": "8.0.0",
|
|
46
|
+
"@tsed/schema": "8.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@tsed/core": {
|
|
@@ -65,8 +65,5 @@
|
|
|
65
65
|
},
|
|
66
66
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-views",
|
|
67
67
|
"author": "Romain Lenzotti",
|
|
68
|
-
"license": "MIT"
|
|
69
|
-
"publishConfig": {
|
|
70
|
-
"tag": "rc"
|
|
71
|
-
}
|
|
68
|
+
"license": "MIT"
|
|
72
69
|
}
|
package/vitest.config.mts
CHANGED
|
@@ -9,13 +9,17 @@ export default defineConfig(
|
|
|
9
9
|
...presets.test,
|
|
10
10
|
coverage: {
|
|
11
11
|
...presets.test.coverage,
|
|
12
|
+
exclude:[
|
|
13
|
+
...presets.test.coverage.exclude,
|
|
14
|
+
"src/decorators/view.ts",
|
|
15
|
+
],
|
|
12
16
|
thresholds: {
|
|
13
|
-
statements:
|
|
14
|
-
branches:
|
|
15
|
-
functions:
|
|
16
|
-
lines:
|
|
17
|
+
statements: 91.3,
|
|
18
|
+
branches: 94.73,
|
|
19
|
+
functions: 76.92,
|
|
20
|
+
lines: 91.3
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
);
|
|
25
|
+
);
|