@flun/html-template 4.0.14 → 4.0.23
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/f-CHANGELOG.md +2 -4
- package/package.json +76 -76
- package/services/templateService.js +24 -6
package/f-CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
2
|
+
"name": "@flun/html-template",
|
|
3
|
+
"version": "4.0.23",
|
|
4
|
+
"description": "一个HTML模板工具包,提供开发服务器和模板编译功能,支持自定义标签和快捷输入,变量定义,包含文件引用,帮助开发者模块化处理HTML;",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "node dev-server.js",
|
|
9
|
+
"build": "node compile.js",
|
|
10
|
+
"postinstall": "node copy-files.js 2>&1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"html",
|
|
14
|
+
"template",
|
|
15
|
+
"server",
|
|
16
|
+
"flun"
|
|
17
|
+
],
|
|
18
|
+
"files": [
|
|
19
|
+
"templates",
|
|
20
|
+
"services",
|
|
21
|
+
"static",
|
|
22
|
+
"customize",
|
|
23
|
+
".env",
|
|
24
|
+
"dev-server.js",
|
|
25
|
+
"dev.js",
|
|
26
|
+
"compile.js",
|
|
27
|
+
"build.js",
|
|
28
|
+
"restoreDefaults.js",
|
|
29
|
+
"index.js",
|
|
30
|
+
"index.d.ts",
|
|
31
|
+
"copy-files.js",
|
|
32
|
+
"f-README.md",
|
|
33
|
+
"f-CHANGELOG.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"type": "module",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./index.js"
|
|
39
|
+
},
|
|
40
|
+
"author": "flun <cn@flun.top>",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/flunGit/html-template.git"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://www.npmjs.com/package/@flun/html-template#readme",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/flunGit/html-template/issues"
|
|
51
|
+
},
|
|
52
|
+
"license": "ISC",
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22.12.0",
|
|
55
|
+
"npm": ">=10.0.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"bcrypt": "^6.0.0",
|
|
59
|
+
"chokidar": "^5.0.0",
|
|
60
|
+
"express": "^5.2.1",
|
|
61
|
+
"express-rate-limit": "^8.3.2",
|
|
62
|
+
"express-session": "^1.19.0",
|
|
63
|
+
"@flun/env": "*",
|
|
64
|
+
"@flun/mailer": "*",
|
|
65
|
+
"@flun/webauthn-server": "*",
|
|
66
|
+
"mysql2": "^3.20.0",
|
|
67
|
+
"otplib": "^13.4.0",
|
|
68
|
+
"qrcode": "^1.5.4",
|
|
69
|
+
"socket.io": "^4.8.3"
|
|
70
|
+
},
|
|
71
|
+
"overrides": {
|
|
72
|
+
"fast-xml-parser": "^5.3.4"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"nodemon": "^3.1.11"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -19,13 +19,31 @@ import { pathToFileURL } from 'url';
|
|
|
19
19
|
// ==================== 1. 常量声明及工具函数====================
|
|
20
20
|
let isCompilationMode = false;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* >查看定义:@see {@link fsPromises}
|
|
24
|
-
* {@link customizeDir}、{@link accountDir}、{@link defaultPort}、{@link writtenFilesToIgnore}
|
|
22
|
+
* fs模块的Promise版本,用于异步文件操作
|
|
23
|
+
* >查看定义:@see {@link fsPromises}
|
|
25
24
|
*/
|
|
26
|
-
const fsPromises = fs.promises
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const fsPromises = fs.promises;
|
|
26
|
+
/**
|
|
27
|
+
* 当前工作目录
|
|
28
|
+
* >查看定义:@see {@link CWD}、{@link templatesDir}、{@link staticDir}、{@link customizeDir}、{@link accountDir}、{@link defaultPort}
|
|
29
|
+
*/
|
|
30
|
+
const CWD = process.cwd(), templatesDir = 'templates', staticDir = 'static', customizeDir = 'customize',
|
|
31
|
+
accountDir = 'account', defaultPort = 7296;
|
|
32
|
+
/**
|
|
33
|
+
* 模板文件绝对路径
|
|
34
|
+
* >查看定义:@see {@link templatesAbsDir}
|
|
35
|
+
*/
|
|
36
|
+
const templatesAbsDir = path.join(CWD, templatesDir);
|
|
37
|
+
/**
|
|
38
|
+
* 路径解析函数
|
|
39
|
+
* >查看定义:@see {@link pRes}
|
|
40
|
+
*/
|
|
41
|
+
const pRes = path.resolve;
|
|
42
|
+
/**
|
|
43
|
+
* 已写入文件忽略列表(监控文件写入时使用,防止编译器误触发重新编译)
|
|
44
|
+
* >查看定义:@see {@link writtenFilesToIgnore}
|
|
45
|
+
*/
|
|
46
|
+
const writtenFilesToIgnore = [], userFeatures = {}, includedFiles = new Set(),
|
|
29
47
|
// 预编译所有高频正则表达式
|
|
30
48
|
includeRegex = /(\"|')\[include\s+([^\]]+)\](\"|')|\[include\s+([\S\s]+?)\]/gi, quotedVarRegex = /`\s*{{(.*?)}}\s*`/g,
|
|
31
49
|
userFuncRegex = /\{\{\s*user:\s*([^\s()]+?)\s*\(([^)]*)\)\s*\}\}/g, templateTagRegex = /\[!([^\]]*?)\]|\[\~([^\]]*?)\]/g,
|