@flun/mailer 2.1.5 → 2.1.7

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/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
1
  # 变更日志
2
- ## [2.1.5] - 2026-04-30 15:58
3
- ### 修复:
4
- - 修复了拷贝示例文件路径错误的问题;
2
+ ## [2.1.7] - 2026-05-01 17:30
3
+ ### 优化:
4
+ - 优化了内部处理逻辑;
package/copy-files.js CHANGED
@@ -31,6 +31,5 @@ const copyFile = () => {
31
31
  }
32
32
  }
33
33
 
34
- // 执行脚本并导出函数
35
34
  if (process.argv[1] === __filename) copyFile();
36
35
  export { copyFile };
package/lib/shared.js CHANGED
@@ -1,4 +1,4 @@
1
- import { lookup as dnsLookup, resolve as dnsResolve } from 'dns';
1
+ import dns from 'dns';
2
2
  import { format } from 'util';
3
3
  import { isIP, connect as netConnect } from 'net';
4
4
  import { createReadStream as fsReadStream } from 'fs';
@@ -10,10 +10,26 @@ import pkg from '../package.json' with { type: 'json' };
10
10
 
11
11
  /**
12
12
  * package.json 包对象(含 name,version,homepage);
13
- * >查看定义:@see {@link PK}、{@link dnsLookup}、{@link dnsResolve}
13
+ * >查看定义:@see {@link PK}
14
14
  */
15
15
  const PK = (({ name, version, homepage }) => ({ name, version, homepage }))(pkg),
16
- DNS_TTL = 5 * 60 * 1000, DNS_MAP = new Map(),
16
+ DNS_TTL = 5 * 60 * 1000, DNS_MAP = new Map();
17
+ /**
18
+ * @type {Function} DNS 查找函数
19
+ * @param {string} hostname - 要解析的主机名
20
+ * @param {object} options - 解析选项
21
+ * @param {function} callback - 回调函数
22
+ * >查看定义:@see {@link dnsLookup}
23
+ */
24
+ const dnsLookup = dns.lookup;
25
+ /**
26
+ * @type {Function} DNS 解析函数
27
+ * @param {string} hostname - 要解析的主机名
28
+ * @param {object} options - 解析选项
29
+ * @param {function} callback - 回调函数
30
+ * >查看定义:@see {@link dnsResolve}
31
+ */
32
+ const dnsResolve = dns.resolve,
17
33
  /**
18
34
  * @param {number} family - IP地址族(4=IPv4, 6=IPv6)
19
35
  * @param {boolean} allowInternal - 是否允许内部网络接口
@@ -206,7 +222,7 @@ const resolveHostname = (options = {}, callback) => {
206
222
  if (err) return handleError(err);
207
223
  if (addrV6?.length) return handleSuccess(addrV6); // 如果IPv6解析成功,同理...
208
224
 
209
- // 如果DNS解析都失败,尝试使用dns.lookup
225
+ // 如果DNS解析都失败,尝试使用dnsLookup
210
226
  try {
211
227
  dnsLookup(newHost, { all: true }, (err, lookupAddr) => {
212
228
  if (err) return handleError(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/mailer",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "A powerful and flexible email sending library for Node.js with multiple transport support (SMTP, SMTP Pool, Sendmail, Stream, JSON, SES)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -75,4 +75,4 @@
75
75
  "example": "examples",
76
76
  "test": "tests"
77
77
  }
78
- }
78
+ }