@tstdl/base 0.83.24 → 0.83.26
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/.eslintrc.json +259 -0
- package/examples/template/basic.js +10 -2
- package/object-storage/s3/s3.object-storage.js +6 -1
- package/package.json +13 -13
- package/pool/pool.d.ts +6 -1
- package/pool/pool.js +2 -2
- package/templates/renderers/handlebars.template-renderer.d.ts +4 -4
- package/templates/renderers/handlebars.template-renderer.js +12 -2
- package/.eslintrc.cjs +0 -259
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"browser": true,
|
|
5
|
+
"es2022": true,
|
|
6
|
+
"worker": true
|
|
7
|
+
},
|
|
8
|
+
"extends": [
|
|
9
|
+
"eslint:all",
|
|
10
|
+
"plugin:@typescript-eslint/all",
|
|
11
|
+
"plugin:import/recommended",
|
|
12
|
+
"plugin:import/typescript"
|
|
13
|
+
],
|
|
14
|
+
"settings": {
|
|
15
|
+
"import/resolver": {
|
|
16
|
+
"typescript": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"parser": "@typescript-eslint/parser",
|
|
20
|
+
"parserOptions": {
|
|
21
|
+
"ecmaVersion": "latest",
|
|
22
|
+
"sourceType": "module",
|
|
23
|
+
"project": "tsconfig.json"
|
|
24
|
+
},
|
|
25
|
+
"plugins": ["@typescript-eslint"],
|
|
26
|
+
"rules": {
|
|
27
|
+
/** angular */
|
|
28
|
+
"@angular-eslint/template/eqeqeq": "off",
|
|
29
|
+
|
|
30
|
+
/** typescript */
|
|
31
|
+
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
|
32
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
33
|
+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
|
|
34
|
+
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
|
|
35
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
36
|
+
"@typescript-eslint/indent": "off",
|
|
37
|
+
"@typescript-eslint/init-declarations": "off",
|
|
38
|
+
"@typescript-eslint/lines-around-comment": "off",
|
|
39
|
+
"@typescript-eslint/lines-between-class-members": ["warn", "always", { "exceptAfterSingleLine": true }],
|
|
40
|
+
"@typescript-eslint/method-signature-style": "off",
|
|
41
|
+
"@typescript-eslint/no-confusing-void-expression": ["error", { "ignoreArrowShorthand": true, "ignoreVoidOperator": true }],
|
|
42
|
+
"@typescript-eslint/no-empty-interface": ["warn", { "allowSingleExtends": true }],
|
|
43
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
44
|
+
"@typescript-eslint/no-extra-parens": "off",
|
|
45
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
46
|
+
"@typescript-eslint/no-inferrable-types": ["warn", { "ignoreParameters": true, "ignoreProperties": true }],
|
|
47
|
+
"@typescript-eslint/no-invalid-void-type": "off",
|
|
48
|
+
"@typescript-eslint/no-magic-numbers": ["off", { "ignoreNumericLiteralTypes": true, "ignoreEnums": true, "ignore": [0, 1, 128, 256, 512, 1024, 2048, 4096], "ignoreArrayIndexes": true }],
|
|
49
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
50
|
+
"@typescript-eslint/no-restricted-imports": "off",
|
|
51
|
+
"@typescript-eslint/no-type-alias": "off",
|
|
52
|
+
"@typescript-eslint/no-unnecessary-condition": ["error", { "allowConstantLoopConditions": true }],
|
|
53
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
54
|
+
"@typescript-eslint/no-unused-vars-experimental": "off",
|
|
55
|
+
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
|
|
56
|
+
"@typescript-eslint/no-use-before-define": ["error", { "functions": false }],
|
|
57
|
+
"@typescript-eslint/no-useless-constructor": "off",
|
|
58
|
+
"@typescript-eslint/object-curly-spacing": "off",
|
|
59
|
+
"@typescript-eslint/prefer-readonly-parameter-types": ["off", { "checkParameterProperties": false }],
|
|
60
|
+
"@typescript-eslint/quotes": ["warn", "single"],
|
|
61
|
+
"@typescript-eslint/restrict-template-expressions": ["error", { "allowNumber": true, "allowBoolean": true, "allowNullish": true }],
|
|
62
|
+
"@typescript-eslint/sort-type-constituents": "off",
|
|
63
|
+
"@typescript-eslint/sort-type-union-intersection-members": "off",
|
|
64
|
+
"@typescript-eslint/space-before-function-paren": ["warn", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
|
|
65
|
+
"@typescript-eslint/typedef": "off",
|
|
66
|
+
|
|
67
|
+
/** import */
|
|
68
|
+
"import/no-duplicates": ["warn", { "prefer-inline": true }],
|
|
69
|
+
"import/no-cycle": ["off", { "ignoreExternal": true }],
|
|
70
|
+
"import/no-self-import": ["error"],
|
|
71
|
+
"import/no-extraneous-dependencies": ["off", { "devDependencies": false, "includeTypes": true }],
|
|
72
|
+
"import/no-empty-named-blocks": ["error"],
|
|
73
|
+
"import/no-mutable-exports": ["error"],
|
|
74
|
+
"import/no-nodejs-modules": ["error"],
|
|
75
|
+
"import/no-absolute-path": ["error"],
|
|
76
|
+
"import/no-useless-path-segments": ["warn"],
|
|
77
|
+
"import/consistent-type-specifier-style": ["off", "prefer-inline"],
|
|
78
|
+
"import/newline-after-import": ["warn", { "considerComments": true }],
|
|
79
|
+
"import/no-anonymous-default-export": ["error"],
|
|
80
|
+
"import/no-named-default": ["error"],
|
|
81
|
+
"import/no-unassigned-import": ["error"],
|
|
82
|
+
|
|
83
|
+
/** misc */
|
|
84
|
+
"array-bracket-newline": ["error", "consistent"],
|
|
85
|
+
"array-element-newline": ["error", "consistent"],
|
|
86
|
+
"camelcase": "off",
|
|
87
|
+
"capitalized-comments": "off",
|
|
88
|
+
"class-methods-use-this": "off",
|
|
89
|
+
"complexity": "off",
|
|
90
|
+
"dot-location": ["error", "property"],
|
|
91
|
+
"eqeqeq": "off",
|
|
92
|
+
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
|
|
93
|
+
"function-call-argument-newline": ["warn", "consistent"],
|
|
94
|
+
"function-paren-newline": ["warn", "consistent"],
|
|
95
|
+
"generator-star-spacing": ["off", { "before": false, "after": true }],
|
|
96
|
+
"id-length": "off",
|
|
97
|
+
"indent": "off",
|
|
98
|
+
"init-declarations": "off",
|
|
99
|
+
"line-comment-position": "off",
|
|
100
|
+
"linebreak-style": ["error", "unix"],
|
|
101
|
+
"lines-around-comment": "off",
|
|
102
|
+
"lines-between-class-members": "off",
|
|
103
|
+
"max-classes-per-file": "off",
|
|
104
|
+
"max-len": ["off", { "code": 150 }],
|
|
105
|
+
"max-lines-per-function": ["off", { "max": 100, "skipBlankLines": true, "skipComments": true }],
|
|
106
|
+
"max-lines": "off",
|
|
107
|
+
"max-params": "off",
|
|
108
|
+
"max-statements": "off",
|
|
109
|
+
"multiline-ternary": "off",
|
|
110
|
+
"new-cap": "off",
|
|
111
|
+
"newline-per-chained-call": "off",
|
|
112
|
+
"no-await-in-loop": "off",
|
|
113
|
+
"no-case-declarations": "off",
|
|
114
|
+
"no-constant-condition": "off",
|
|
115
|
+
"no-continue": "off",
|
|
116
|
+
"no-duplicate-imports": "off",
|
|
117
|
+
"no-inline-comments": "off",
|
|
118
|
+
"no-negated-condition": "off",
|
|
119
|
+
"no-nested-ternary": "off",
|
|
120
|
+
"no-plusplus": ["off", { "allowForLoopAfterthoughts": true }],
|
|
121
|
+
"no-promise-executor-return": "off",
|
|
122
|
+
"no-restricted-imports": "off",
|
|
123
|
+
"no-ternary": "off",
|
|
124
|
+
"no-undefined": "off",
|
|
125
|
+
"no-underscore-dangle": "off",
|
|
126
|
+
"no-void": "off",
|
|
127
|
+
"object-curly-spacing": "off",
|
|
128
|
+
"object-property-newline": ["warn", { "allowAllPropertiesOnSameLine": true }],
|
|
129
|
+
"one-var": ["error", "never"],
|
|
130
|
+
"operator-linebreak": ["warn", "before"],
|
|
131
|
+
"padded-blocks": ["error", "never"],
|
|
132
|
+
"prefer-arrow/prefer-arrow-functions": "off",
|
|
133
|
+
"prefer-destructuring": "off",
|
|
134
|
+
"prefer-named-capture-group": "off",
|
|
135
|
+
"quote-props": ["error", "as-needed"],
|
|
136
|
+
"quotes": ["error", "single"],
|
|
137
|
+
"semi": ["error", "always"],
|
|
138
|
+
"sort-imports": ["off", { "ignoreCase": true }],
|
|
139
|
+
"sort-keys": "off",
|
|
140
|
+
|
|
141
|
+
"@typescript-eslint/naming-convention": [
|
|
142
|
+
"warn",
|
|
143
|
+
{
|
|
144
|
+
"selector": "default",
|
|
145
|
+
"format": ["camelCase"],
|
|
146
|
+
"leadingUnderscore": "allowSingleOrDouble"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"selector": "enumMember",
|
|
150
|
+
"format": ["PascalCase"]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"selector": "typeLike",
|
|
154
|
+
"format": ["PascalCase"]
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"@typescript-eslint/member-delimiter-style": ["error", {
|
|
158
|
+
"multiline": {
|
|
159
|
+
"delimiter": "comma",
|
|
160
|
+
"requireLast": false
|
|
161
|
+
},
|
|
162
|
+
"singleline": {
|
|
163
|
+
"delimiter": "comma",
|
|
164
|
+
"requireLast": false
|
|
165
|
+
},
|
|
166
|
+
"overrides": {
|
|
167
|
+
"interface": {
|
|
168
|
+
"multiline": {
|
|
169
|
+
"delimiter": "semi",
|
|
170
|
+
"requireLast": true
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}],
|
|
175
|
+
"@typescript-eslint/member-ordering": ["warn", {
|
|
176
|
+
"default": [
|
|
177
|
+
// Index signature
|
|
178
|
+
"signature",
|
|
179
|
+
"call-signature",
|
|
180
|
+
|
|
181
|
+
// Fields
|
|
182
|
+
"#private-static-field",
|
|
183
|
+
"private-static-field",
|
|
184
|
+
"protected-static-field",
|
|
185
|
+
"public-static-field",
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
"private-decorated-field",
|
|
189
|
+
"protected-decorated-field",
|
|
190
|
+
"public-decorated-field",
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
"#private-instance-field",
|
|
194
|
+
"private-instance-field",
|
|
195
|
+
"protected-instance-field",
|
|
196
|
+
"public-instance-field",
|
|
197
|
+
|
|
198
|
+
"protected-abstract-field",
|
|
199
|
+
"public-abstract-field",
|
|
200
|
+
|
|
201
|
+
"#private-field",
|
|
202
|
+
"private-field",
|
|
203
|
+
"protected-field",
|
|
204
|
+
"public-field",
|
|
205
|
+
|
|
206
|
+
"static-field",
|
|
207
|
+
"instance-field",
|
|
208
|
+
"abstract-field",
|
|
209
|
+
|
|
210
|
+
// "decorated-field",
|
|
211
|
+
|
|
212
|
+
"field",
|
|
213
|
+
|
|
214
|
+
// Static initialization
|
|
215
|
+
"static-initialization",
|
|
216
|
+
|
|
217
|
+
// Constructors
|
|
218
|
+
"public-constructor",
|
|
219
|
+
"protected-constructor",
|
|
220
|
+
"private-constructor",
|
|
221
|
+
|
|
222
|
+
"constructor",
|
|
223
|
+
|
|
224
|
+
// Methods
|
|
225
|
+
"public-static-method",
|
|
226
|
+
"protected-static-method",
|
|
227
|
+
"private-static-method",
|
|
228
|
+
"#private-static-method",
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
"public-decorated-method",
|
|
232
|
+
"protected-decorated-method",
|
|
233
|
+
"private-decorated-method",
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
"public-instance-method",
|
|
237
|
+
"protected-instance-method",
|
|
238
|
+
"private-instance-method",
|
|
239
|
+
"#private-instance-method",
|
|
240
|
+
|
|
241
|
+
"public-abstract-method",
|
|
242
|
+
"protected-abstract-method",
|
|
243
|
+
|
|
244
|
+
"public-method",
|
|
245
|
+
"protected-method",
|
|
246
|
+
"private-method",
|
|
247
|
+
"#private-method",
|
|
248
|
+
|
|
249
|
+
"static-method",
|
|
250
|
+
"instance-method",
|
|
251
|
+
"abstract-method",
|
|
252
|
+
|
|
253
|
+
// "decorated-method",
|
|
254
|
+
|
|
255
|
+
"method"
|
|
256
|
+
]
|
|
257
|
+
}]
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -9,14 +9,22 @@ var import_jsx_template_renderer = require("../../templates/renderers/jsx.templa
|
|
|
9
9
|
var import_file_template_resolver = require("../../templates/resolvers/file.template-resolver.js");
|
|
10
10
|
var import_jsx_template_resolver = require("../../templates/resolvers/jsx.template-resolver.js");
|
|
11
11
|
var import_node_path = require("node:path");
|
|
12
|
+
var import_node_url = require("node:url");
|
|
13
|
+
const import_meta = {};
|
|
14
|
+
let dirname;
|
|
15
|
+
try {
|
|
16
|
+
dirname = (0, import_node_url.fileURLToPath)(new URL(".", import_meta.url));
|
|
17
|
+
} catch {
|
|
18
|
+
dirname = __dirname;
|
|
19
|
+
}
|
|
12
20
|
(0, import_core.configureTstdl)();
|
|
13
21
|
(0, import_templates.configureTemplates)({
|
|
14
22
|
templateProvider: import_file_template_provider.FileTemplateProvider,
|
|
15
23
|
templateResolvers: [import_file_template_resolver.FileTemplateResolver, import_jsx_template_resolver.JsxTemplateResolver],
|
|
16
24
|
templateRenderers: [import_handlebars_template_renderer.HandlebarsTemplateRenderer, import_jsx_template_renderer.JsxTemplateRenderer]
|
|
17
25
|
});
|
|
18
|
-
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(
|
|
19
|
-
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(
|
|
26
|
+
(0, import_file_template_provider.configureFileTemplateProvider)({ basePath: (0, import_node_path.resolve)(dirname, "templates") });
|
|
27
|
+
(0, import_file_template_resolver.configureFileTemplateResolver)({ basePath: (0, import_node_path.resolve)(dirname.replace("dist", "source"), "templates") });
|
|
20
28
|
async function test() {
|
|
21
29
|
const templateService = await import_container.container.resolveAsync(import_templates.TemplateService);
|
|
22
30
|
const handlebarsResult = await templateService.render("hello-name", { name: "Max Mustermann" });
|
|
@@ -86,7 +86,12 @@ let S3ObjectStorage = class S3ObjectStorage2 extends import_object_storage.Objec
|
|
|
86
86
|
}
|
|
87
87
|
async uploadObjectStream(key, stream, options) {
|
|
88
88
|
const bucketKey = this.getBucketKey(key);
|
|
89
|
-
|
|
89
|
+
const readable = import_node_stream.Readable.fromWeb(stream);
|
|
90
|
+
const errorPromise = new Promise((_, reject) => readable.on("error", reject));
|
|
91
|
+
await Promise.race([
|
|
92
|
+
this.client.putObject(this.bucket, bucketKey, readable, options?.metadata),
|
|
93
|
+
errorPromise
|
|
94
|
+
]);
|
|
90
95
|
}
|
|
91
96
|
async getContent(key) {
|
|
92
97
|
const bucketKey = this.getBucketKey(key);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.26",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"build:watch": "tsc && (concurrently --raw 'tsc --watch' 'tsc-alias --watch')",
|
|
12
12
|
"build:production": "rm -rf dist && npm run build && npm run build:production:cjs && npm run build:production:copy-files",
|
|
13
13
|
"build:production:cjs": "esbuild `find dist \\( -name '*.js' -o -name '*.jsx' \\)` --outdir=dist --allow-overwrite --format=cjs",
|
|
14
|
-
"build:production:copy-files": "cp package.json .eslintrc.
|
|
14
|
+
"build:production:copy-files": "cp package.json .eslintrc.json tsconfig.server.json dist/ && cp tsconfig.base.json dist/tsconfig.json && sed -i 's/\"type\": \"module\",/\"type\": \"commonjs\",/g' dist/package.json",
|
|
15
15
|
"build:docs": "typedoc",
|
|
16
16
|
"build:docs-watch": "typedoc --watch",
|
|
17
|
-
"lint": "eslint -c .eslintrc.
|
|
17
|
+
"lint": "eslint -c .eslintrc.json --ext .ts .",
|
|
18
18
|
"pub": "npm run build:production && rm -vf dist/test* && npm publish dist/"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@types/mjml": "4.7",
|
|
32
32
|
"@types/node": "18",
|
|
33
33
|
"@types/nodemailer": "6.4",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
35
|
-
"@typescript-eslint/parser": "5.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "5.59",
|
|
35
|
+
"@typescript-eslint/parser": "5.59",
|
|
36
36
|
"concurrently": "8.0",
|
|
37
37
|
"esbuild": "0.17",
|
|
38
38
|
"eslint": "8.38",
|
|
@@ -46,22 +46,22 @@
|
|
|
46
46
|
"@elastic/elasticsearch": "^8.7",
|
|
47
47
|
"@koa/router": "^12.0",
|
|
48
48
|
"@tstdl/angular": "^0.83",
|
|
49
|
-
"@zxcvbn-ts/core": "2.2",
|
|
50
|
-
"@zxcvbn-ts/language-common": "2.0",
|
|
51
|
-
"@zxcvbn-ts/language-de": "2.1",
|
|
52
|
-
"@zxcvbn-ts/language-en": "2.1",
|
|
49
|
+
"@zxcvbn-ts/core": "^2.2",
|
|
50
|
+
"@zxcvbn-ts/language-common": "^2.0",
|
|
51
|
+
"@zxcvbn-ts/language-de": "^2.1",
|
|
52
|
+
"@zxcvbn-ts/language-en": "^2.1",
|
|
53
53
|
"chroma-js": "^2.4",
|
|
54
54
|
"handlebars": "^4.7",
|
|
55
55
|
"knex": "^2.4",
|
|
56
56
|
"koa": "^2.14",
|
|
57
57
|
"minio": "^7.0",
|
|
58
58
|
"mjml": "^4.14",
|
|
59
|
-
"mongodb": "5.
|
|
59
|
+
"mongodb": "^5.3",
|
|
60
60
|
"nodemailer": "^6.9",
|
|
61
61
|
"preact": "^10.13",
|
|
62
|
-
"preact-render-to-string": "^
|
|
63
|
-
"puppeteer": "^19.
|
|
64
|
-
"undici": "^5.
|
|
62
|
+
"preact-render-to-string": "^6.0",
|
|
63
|
+
"puppeteer": "^19.10",
|
|
64
|
+
"undici": "^5.22",
|
|
65
65
|
"urlpattern-polyfill": "^7.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependenciesMeta": {
|
package/pool/pool.d.ts
CHANGED
|
@@ -7,10 +7,15 @@ export type PoolOptions = {
|
|
|
7
7
|
* @default number of cpu cores
|
|
8
8
|
*/
|
|
9
9
|
size?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Dipose used instance on error instead of reusing it.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
disposeOnError?: boolean;
|
|
10
15
|
};
|
|
11
16
|
export type PoolUseOptions = {
|
|
12
17
|
/**
|
|
13
|
-
* Dipose used instance on error instead of reusing it.
|
|
18
|
+
* Dipose used instance on error instead of reusing it. Overwrites pool instance option
|
|
14
19
|
* @default false
|
|
15
20
|
*/
|
|
16
21
|
disposeOnError?: boolean;
|
package/pool/pool.js
CHANGED
|
@@ -44,6 +44,7 @@ class Pool {
|
|
|
44
44
|
this.factory = factory;
|
|
45
45
|
this.disposer = disposer;
|
|
46
46
|
this.logger = logger;
|
|
47
|
+
this.disposeOnError = options?.disposeOnError ?? false;
|
|
47
48
|
this.freeInstances = new import_array_list.ArrayList();
|
|
48
49
|
this.usedInstances = new import_set.Set();
|
|
49
50
|
this.placeholderInstances = 0;
|
|
@@ -96,7 +97,7 @@ class Pool {
|
|
|
96
97
|
await this.release(instance);
|
|
97
98
|
return result;
|
|
98
99
|
} catch (error) {
|
|
99
|
-
if (options.disposeOnError
|
|
100
|
+
if (options.disposeOnError ?? this.disposeOnError) {
|
|
100
101
|
try {
|
|
101
102
|
await this.disposeInstance(instance);
|
|
102
103
|
} catch (disposeError) {
|
|
@@ -135,6 +136,5 @@ class Pool {
|
|
|
135
136
|
await this.disposer(instance);
|
|
136
137
|
this.usedInstances.delete(instance);
|
|
137
138
|
}
|
|
138
|
-
await this[import_disposable.disposeAsync]();
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ObjectLiteral, Record } from '../../types.js';
|
|
2
|
-
import * as
|
|
2
|
+
import type * as Handlebars from 'handlebars';
|
|
3
3
|
import { TemplateResolverProvider } from '../template-resolver.provider.js';
|
|
4
4
|
import type { TemplateField } from '../template.model.js';
|
|
5
5
|
import type { TemplateRenderObject } from '../template.renderer.js';
|
|
@@ -18,12 +18,12 @@ export type HandlebarsTemplateHelperOptions = {
|
|
|
18
18
|
data?: Record<string>;
|
|
19
19
|
hash: Record<string>;
|
|
20
20
|
lookupProperty: (object: ObjectLiteral, propertyName: string) => unknown;
|
|
21
|
-
fn?:
|
|
22
|
-
inverse?:
|
|
21
|
+
fn?: Handlebars.TemplateDelegate;
|
|
22
|
+
inverse?: Handlebars.TemplateDelegate;
|
|
23
23
|
};
|
|
24
24
|
export type HandlebarsTemplateHelper = (context: unknown, args: unknown[], options: HandlebarsTemplateHelperOptions) => any;
|
|
25
25
|
export type HandlebarsTemplateHelpersObject = Record<string, HandlebarsTemplateHelper>;
|
|
26
|
-
export type HandlebarsTemplatePartial = string | TemplateField<string, 'handlebars', HandlebarsRendererOptions> |
|
|
26
|
+
export type HandlebarsTemplatePartial = string | TemplateField<string, 'handlebars', HandlebarsRendererOptions> | Handlebars.TemplateDelegate;
|
|
27
27
|
export type HandlebarsTemplatePartialsObject = Record<string, HandlebarsTemplatePartial>;
|
|
28
28
|
export type HandlebarsRendererOptions = {
|
|
29
29
|
strict?: boolean;
|
|
@@ -35,7 +35,6 @@ var import_container = require("../../container/index.js");
|
|
|
35
35
|
var import_memoize = require("../../utils/function/memoize.js");
|
|
36
36
|
var import_object = require("../../utils/object/object.js");
|
|
37
37
|
var import_type_guards = require("../../utils/type-guards.js");
|
|
38
|
-
var handlebars = __toESM(require("handlebars"), 1);
|
|
39
38
|
var import_template_resolver_provider = require("../template-resolver.provider.js");
|
|
40
39
|
var import_template_renderer = require("../template.renderer.js");
|
|
41
40
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -71,7 +70,8 @@ let HandlebarsTemplateRenderer = class HandlebarsTemplateRenderer2 extends impor
|
|
|
71
70
|
async _compileHandlebarsTemplate(renderObject) {
|
|
72
71
|
const { template, options = {} } = renderObject;
|
|
73
72
|
const allHelpers = getAllPartialHelpersDeep(renderObject);
|
|
74
|
-
const
|
|
73
|
+
const compile = await importHandlebarsCompile();
|
|
74
|
+
const renderer = compile(template, {
|
|
75
75
|
strict: options.strict ?? true,
|
|
76
76
|
preventIndent: options.preventIndent,
|
|
77
77
|
knownHelpers: (0, import_type_guards.isDefined)(allHelpers) ? (0, import_object.mapObjectValues)(allHelpers, () => true) : void 0,
|
|
@@ -126,3 +126,13 @@ function getPartialHelpersDeep(partial) {
|
|
|
126
126
|
const childEntries = (0, import_object.objectValues)(partial.options?.partials ?? {}).flatMap(getPartialHelpersDeep);
|
|
127
127
|
return [...entries, ...childEntries];
|
|
128
128
|
}
|
|
129
|
+
let handlebarsCompile;
|
|
130
|
+
async function importHandlebarsCompile() {
|
|
131
|
+
if ((0, import_type_guards.isDefined)(handlebarsCompile)) {
|
|
132
|
+
return handlebarsCompile;
|
|
133
|
+
}
|
|
134
|
+
const handlebars = await import("handlebars");
|
|
135
|
+
const compile = handlebars.compile ?? handlebars.default?.compile;
|
|
136
|
+
(0, import_type_guards.assertDefined)(compile, "Could not import handlebars.");
|
|
137
|
+
return handlebarsCompile = compile;
|
|
138
|
+
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
browser: true,
|
|
5
|
-
es2022: true,
|
|
6
|
-
worker: true
|
|
7
|
-
},
|
|
8
|
-
extends: [
|
|
9
|
-
'eslint:all',
|
|
10
|
-
'plugin:@typescript-eslint/all',
|
|
11
|
-
'plugin:import/recommended',
|
|
12
|
-
'plugin:import/typescript'
|
|
13
|
-
],
|
|
14
|
-
settings: {
|
|
15
|
-
'import/resolver': {
|
|
16
|
-
typescript: true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
parser: '@typescript-eslint/parser',
|
|
20
|
-
parserOptions: {
|
|
21
|
-
ecmaVersion: 'latest',
|
|
22
|
-
sourceType: 'module',
|
|
23
|
-
project: 'tsconfig.json'
|
|
24
|
-
},
|
|
25
|
-
plugins: ['@typescript-eslint'],
|
|
26
|
-
rules: {
|
|
27
|
-
/** angular */
|
|
28
|
-
'@angular-eslint/template/eqeqeq': 'off',
|
|
29
|
-
|
|
30
|
-
/** typescript */
|
|
31
|
-
'@typescript-eslint/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
|
|
32
|
-
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
33
|
-
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
|
|
34
|
-
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
|
|
35
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
36
|
-
'@typescript-eslint/indent': 'off',
|
|
37
|
-
'@typescript-eslint/init-declarations': 'off',
|
|
38
|
-
'@typescript-eslint/lines-around-comment': 'off',
|
|
39
|
-
'@typescript-eslint/lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
|
|
40
|
-
'@typescript-eslint/method-signature-style': 'off',
|
|
41
|
-
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
|
|
42
|
-
'@typescript-eslint/no-empty-interface': ['warn', { 'allowSingleExtends': true }],
|
|
43
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
44
|
-
'@typescript-eslint/no-extra-parens': 'off',
|
|
45
|
-
'@typescript-eslint/no-extraneous-class': 'off',
|
|
46
|
-
'@typescript-eslint/no-inferrable-types': ['warn', { ignoreParameters: true, ignoreProperties: true }],
|
|
47
|
-
'@typescript-eslint/no-invalid-void-type': 'off',
|
|
48
|
-
'@typescript-eslint/no-magic-numbers': ['off', { ignoreNumericLiteralTypes: true, ignoreEnums: true, ignore: [0, 1, 128, 256, 512, 1024, 2048, 4096], ignoreArrayIndexes: true }],
|
|
49
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
50
|
-
'@typescript-eslint/no-restricted-imports': 'off',
|
|
51
|
-
'@typescript-eslint/no-type-alias': 'off',
|
|
52
|
-
'@typescript-eslint/no-unnecessary-condition': ['error', { allowConstantLoopConditions: true }],
|
|
53
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
54
|
-
'@typescript-eslint/no-unused-vars-experimental': 'off',
|
|
55
|
-
'@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
|
|
56
|
-
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
|
|
57
|
-
'@typescript-eslint/no-useless-constructor': 'off',
|
|
58
|
-
'@typescript-eslint/object-curly-spacing': 'off',
|
|
59
|
-
'@typescript-eslint/prefer-readonly-parameter-types': ['off', { checkParameterProperties: false }],
|
|
60
|
-
'@typescript-eslint/quotes': ['warn', 'single'],
|
|
61
|
-
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true, allowBoolean: true, allowNullish: true }],
|
|
62
|
-
'@typescript-eslint/sort-type-constituents': 'off',
|
|
63
|
-
'@typescript-eslint/sort-type-union-intersection-members': 'off',
|
|
64
|
-
'@typescript-eslint/space-before-function-paren': ['warn', { anonymous: 'never', named: 'never', asyncArrow: 'always' }],
|
|
65
|
-
'@typescript-eslint/typedef': 'off',
|
|
66
|
-
|
|
67
|
-
/** import */
|
|
68
|
-
'import/no-duplicates': ['warn', { 'prefer-inline': true }],
|
|
69
|
-
'import/no-cycle': ['off', { ignoreExternal: true }],
|
|
70
|
-
'import/no-self-import': ['error'],
|
|
71
|
-
'import/no-extraneous-dependencies': ['off', { devDependencies: false, includeTypes: true }],
|
|
72
|
-
'import/no-empty-named-blocks': ['error'],
|
|
73
|
-
'import/no-mutable-exports': ['error'],
|
|
74
|
-
'import/no-nodejs-modules': ['error'],
|
|
75
|
-
'import/no-absolute-path': ['error'],
|
|
76
|
-
'import/no-useless-path-segments': ['warn'],
|
|
77
|
-
'import/consistent-type-specifier-style': ['off', 'prefer-inline'],
|
|
78
|
-
'import/newline-after-import': ['warn', { considerComments: true }],
|
|
79
|
-
'import/no-anonymous-default-export': ['error'],
|
|
80
|
-
'import/no-named-default': ['error'],
|
|
81
|
-
'import/no-unassigned-import': ['error'],
|
|
82
|
-
|
|
83
|
-
/** misc */
|
|
84
|
-
'array-bracket-newline': ['error', 'consistent'],
|
|
85
|
-
'array-element-newline': ['error', 'consistent'],
|
|
86
|
-
'camelcase': 'off',
|
|
87
|
-
'capitalized-comments': 'off',
|
|
88
|
-
'class-methods-use-this': 'off',
|
|
89
|
-
'complexity': 'off',
|
|
90
|
-
'dot-location': ['error', 'property'],
|
|
91
|
-
'eqeqeq': 'off',
|
|
92
|
-
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
|
|
93
|
-
'function-call-argument-newline': ['warn', 'consistent'],
|
|
94
|
-
'function-paren-newline': ['warn', 'consistent'],
|
|
95
|
-
'generator-star-spacing': ['off', { before: false, after: true }],
|
|
96
|
-
'id-length': 'off',
|
|
97
|
-
'indent': 'off',
|
|
98
|
-
'init-declarations': 'off',
|
|
99
|
-
'line-comment-position': 'off',
|
|
100
|
-
'linebreak-style': ['error', 'unix'],
|
|
101
|
-
'lines-around-comment': 'off',
|
|
102
|
-
'lines-between-class-members': 'off',
|
|
103
|
-
'max-classes-per-file': 'off',
|
|
104
|
-
'max-len': ['off', { code: 150 }],
|
|
105
|
-
'max-lines-per-function': ['off', { 'max': 100, 'skipBlankLines': true, 'skipComments': true }],
|
|
106
|
-
'max-lines': 'off',
|
|
107
|
-
'max-params': 'off',
|
|
108
|
-
'max-statements': 'off',
|
|
109
|
-
'multiline-ternary': 'off',
|
|
110
|
-
'new-cap': 'off',
|
|
111
|
-
'newline-per-chained-call': 'off',
|
|
112
|
-
'no-await-in-loop': 'off',
|
|
113
|
-
'no-case-declarations': 'off',
|
|
114
|
-
'no-constant-condition': 'off',
|
|
115
|
-
'no-continue': 'off',
|
|
116
|
-
'no-duplicate-imports': 'off',
|
|
117
|
-
'no-inline-comments': 'off',
|
|
118
|
-
'no-negated-condition': 'off',
|
|
119
|
-
'no-nested-ternary': 'off',
|
|
120
|
-
'no-plusplus': ['off', { allowForLoopAfterthoughts: true }],
|
|
121
|
-
'no-promise-executor-return': 'off',
|
|
122
|
-
'no-restricted-imports': 'off',
|
|
123
|
-
'no-ternary': 'off',
|
|
124
|
-
'no-undefined': 'off',
|
|
125
|
-
'no-underscore-dangle': 'off',
|
|
126
|
-
'no-void': 'off',
|
|
127
|
-
'object-curly-spacing': 'off',
|
|
128
|
-
'object-property-newline': ['warn', { allowAllPropertiesOnSameLine: true }],
|
|
129
|
-
'one-var': ['error', 'never'],
|
|
130
|
-
'operator-linebreak': ['warn', 'before'],
|
|
131
|
-
'padded-blocks': ['error', 'never'],
|
|
132
|
-
'prefer-arrow/prefer-arrow-functions': 'off',
|
|
133
|
-
'prefer-destructuring': 'off',
|
|
134
|
-
'prefer-named-capture-group': 'off',
|
|
135
|
-
'quote-props': ['error', 'as-needed'],
|
|
136
|
-
'quotes': ['error', 'single'],
|
|
137
|
-
'semi': ['error', 'always'],
|
|
138
|
-
'sort-imports': ['off', { ignoreCase: true }],
|
|
139
|
-
'sort-keys': 'off',
|
|
140
|
-
|
|
141
|
-
'@typescript-eslint/naming-convention': [
|
|
142
|
-
'warn',
|
|
143
|
-
{
|
|
144
|
-
selector: 'default',
|
|
145
|
-
format: ['camelCase'],
|
|
146
|
-
leadingUnderscore: 'allowSingleOrDouble'
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
selector: 'enumMember',
|
|
150
|
-
format: ['PascalCase']
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
selector: 'typeLike',
|
|
154
|
-
format: ['PascalCase']
|
|
155
|
-
}
|
|
156
|
-
],
|
|
157
|
-
'@typescript-eslint/member-delimiter-style': ['error', {
|
|
158
|
-
multiline: {
|
|
159
|
-
delimiter: 'comma',
|
|
160
|
-
requireLast: false
|
|
161
|
-
},
|
|
162
|
-
singleline: {
|
|
163
|
-
delimiter: 'comma',
|
|
164
|
-
requireLast: false
|
|
165
|
-
},
|
|
166
|
-
overrides: {
|
|
167
|
-
interface: {
|
|
168
|
-
multiline: {
|
|
169
|
-
delimiter: 'semi',
|
|
170
|
-
requireLast: true
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}],
|
|
175
|
-
'@typescript-eslint/member-ordering': ['warn', {
|
|
176
|
-
default: [
|
|
177
|
-
// Index signature
|
|
178
|
-
'signature',
|
|
179
|
-
'call-signature',
|
|
180
|
-
|
|
181
|
-
// Fields
|
|
182
|
-
'#private-static-field',
|
|
183
|
-
'private-static-field',
|
|
184
|
-
'protected-static-field',
|
|
185
|
-
'public-static-field',
|
|
186
|
-
|
|
187
|
-
/*
|
|
188
|
-
'private-decorated-field',
|
|
189
|
-
'protected-decorated-field',
|
|
190
|
-
'public-decorated-field',
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
'#private-instance-field',
|
|
194
|
-
'private-instance-field',
|
|
195
|
-
'protected-instance-field',
|
|
196
|
-
'public-instance-field',
|
|
197
|
-
|
|
198
|
-
'protected-abstract-field',
|
|
199
|
-
'public-abstract-field',
|
|
200
|
-
|
|
201
|
-
'#private-field',
|
|
202
|
-
'private-field',
|
|
203
|
-
'protected-field',
|
|
204
|
-
'public-field',
|
|
205
|
-
|
|
206
|
-
'static-field',
|
|
207
|
-
'instance-field',
|
|
208
|
-
'abstract-field',
|
|
209
|
-
|
|
210
|
-
// 'decorated-field',
|
|
211
|
-
|
|
212
|
-
'field',
|
|
213
|
-
|
|
214
|
-
// Static initialization
|
|
215
|
-
'static-initialization',
|
|
216
|
-
|
|
217
|
-
// Constructors
|
|
218
|
-
'public-constructor',
|
|
219
|
-
'protected-constructor',
|
|
220
|
-
'private-constructor',
|
|
221
|
-
|
|
222
|
-
'constructor',
|
|
223
|
-
|
|
224
|
-
// Methods
|
|
225
|
-
'public-static-method',
|
|
226
|
-
'protected-static-method',
|
|
227
|
-
'private-static-method',
|
|
228
|
-
'#private-static-method',
|
|
229
|
-
|
|
230
|
-
/*
|
|
231
|
-
'public-decorated-method',
|
|
232
|
-
'protected-decorated-method',
|
|
233
|
-
'private-decorated-method',
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
'public-instance-method',
|
|
237
|
-
'protected-instance-method',
|
|
238
|
-
'private-instance-method',
|
|
239
|
-
'#private-instance-method',
|
|
240
|
-
|
|
241
|
-
'public-abstract-method',
|
|
242
|
-
'protected-abstract-method',
|
|
243
|
-
|
|
244
|
-
'public-method',
|
|
245
|
-
'protected-method',
|
|
246
|
-
'private-method',
|
|
247
|
-
'#private-method',
|
|
248
|
-
|
|
249
|
-
'static-method',
|
|
250
|
-
'instance-method',
|
|
251
|
-
'abstract-method',
|
|
252
|
-
|
|
253
|
-
// 'decorated-method',
|
|
254
|
-
|
|
255
|
-
'method'
|
|
256
|
-
]
|
|
257
|
-
}]
|
|
258
|
-
}
|
|
259
|
-
}
|