@maiyunnet/kebab 3.1.3 → 3.1.5

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/text.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import * as types from '#types/index.js';
1
+ /**
2
+ * Project: Kebab, User: JianSuoQiYue
3
+ * Date: 2019-5-15 16:49:39
4
+ * Last: 2020-04-06 20:51:06, 2022-9-29 15:18:16, 2022-12-29 00:01:30, 2024-3-6 17:53:14, 2024-5-31 17:29:52, 2025-6-13 15:47:02, 2025-9-23 12:51:49
5
+ */
6
+ import * as kebab from '#index.js';
2
7
  /**
3
8
  * --- 将文件大小格式化为带单位的字符串 ---
4
9
  * @param size 文件大小
@@ -9,7 +14,7 @@ export declare function sizeFormat(size: number, spliter?: string): string;
9
14
  * --- 格式化一段 URL ---
10
15
  * @param url
11
16
  */
12
- export declare function parseUrl(url: string): types.IUrlParse;
17
+ export declare function parseUrl(url: string): kebab.IUrlParse;
13
18
  /**
14
19
  * --- 将相对路径根据基准路径进行转换 ---
15
20
  * @param from 基准路径
@@ -116,7 +121,7 @@ export declare function getFilename(path: string): string;
116
121
  * --- 将普通的返回 JSON 对象序列化为字符串,Mutton 不能使用 ---
117
122
  * @param o 返回 JSON 对象
118
123
  */
119
- export declare function stringifyResult(rtn: types.Json): string;
124
+ export declare function stringifyResult(rtn: kebab.Json): string;
120
125
  /**
121
126
  * --- 将字符串解析为对象,返回 false 代表解析失败,支持 BigInt,Kebab true, Mutton false ---
122
127
  * @param str 要解析的 json 字符串
@@ -127,7 +132,7 @@ export declare function parseJson(str: string): any;
127
132
  * @param obj 要转换的 json 对象
128
133
  * @param space 美化方式
129
134
  */
130
- export declare function stringifyJson(obj: types.Json, space?: string | number): string;
135
+ export declare function stringifyJson(obj: kebab.Json, space?: string | number): string;
131
136
  /**
132
137
  * --- 输出文本格式的 buffer ---
133
138
  * @param buf 原始 buffer
package/lib/text.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-5-15 16:49:39
4
- * Last: 2020-04-06 20:51:06, 2022-9-29 15:18:16, 2022-12-29 00:01:30, 2024-3-6 17:53:14, 2024-5-31 17:29:52, 2025-6-13 15:47:02
4
+ * Last: 2020-04-06 20:51:06, 2022-9-29 15:18:16, 2022-12-29 00:01:30, 2024-3-6 17:53:14, 2024-5-31 17:29:52, 2025-6-13 15:47:02, 2025-9-23 12:51:49
5
5
  */
6
6
  import * as kebab from '#index.js';
7
- import * as fs from './fs.js';
7
+ import * as lFs from './fs.js';
8
8
  /**
9
9
  * --- 将文件大小格式化为带单位的字符串 ---
10
10
  * @param size 文件大小
@@ -253,7 +253,7 @@ export async function parseDomain(domain) {
253
253
  }
254
254
  else {
255
255
  if (!tldList) {
256
- tldList = JSON.parse(await fs.getContent(kebab.LIB_PATH + 'text/tld.json', 'utf8') ?? '[]');
256
+ tldList = JSON.parse(await lFs.getContent(kebab.LIB_PATH + 'text/tld.json', 'utf8') ?? '[]');
257
257
  }
258
258
  const last2 = (arr[arr.length - 2] + '.' + arr[arr.length - 1]).toLowerCase();
259
259
  if (tldList.includes(last2)) {
package/lib/ws.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Project: Kebab, User: JianSuoQiYue
3
3
  * Date: 2019-6-2 20:42
4
- * Last: 2020-4-9 22:33:11, 2022-09-13 13:32:01, 2022-12-30 19:13:07, 2024-2-6 23:53:45, 2024-12-23 01:33:16, 2025-1-28 21:05:51
4
+ * Last: 2020-4-9 22:33:11, 2022-09-13 13:32:01, 2022-12-30 19:13:07, 2024-2-6 23:53:45, 2024-12-23 01:33:16, 2025-1-28 21:05:51, 2025-9-23 12:27:48
5
5
  */
6
6
  import * as http from 'http';
7
7
  import * as net from 'net';
8
- import * as types from '#types/index.js';
8
+ import * as kebab from '#index.js';
9
+ import * as lNet from '#lib/net.js';
9
10
  import * as sCtr from '#sys/ctr.js';
10
11
  /** --- 一般用 SIMPLE --- */
11
12
  export declare enum EFrameReceiveMode {
@@ -28,9 +29,9 @@ export interface IConnectOptions {
28
29
  'timeout'?: number;
29
30
  'hosts'?: Record<string, string>;
30
31
  'local'?: string;
31
- 'headers'?: types.THttpHeaders;
32
+ 'headers'?: lNet.THttpHeaders;
32
33
  /** --- cookie 托管对象 --- */
33
- 'cookie'?: Record<string, types.ICookie>;
34
+ 'cookie'?: Record<string, lNet.ICookie>;
34
35
  /** --- 小帧模式,默认 false --- */
35
36
  'mode'?: EFrameReceiveMode;
36
37
  /** --- 加密模式,默认 true --- */
@@ -47,7 +48,7 @@ export interface IMproxyOptions {
47
48
  'timeout'?: number;
48
49
  'hosts'?: Record<string, string>;
49
50
  'local'?: string;
50
- 'headers'?: types.THttpHeaders;
51
+ 'headers'?: lNet.THttpHeaders;
51
52
  /** --- 小帧模式,默认 false --- */
52
53
  'mode'?: EFrameReceiveMode;
53
54
  /** --- 加密模式,默认 true --- */
@@ -59,7 +60,7 @@ export interface IRproxyOptions {
59
60
  'timeout'?: number;
60
61
  'hosts'?: Record<string, string>;
61
62
  'local'?: string;
62
- 'headers'?: types.THttpHeaders;
63
+ 'headers'?: lNet.THttpHeaders;
63
64
  /** --- 小帧模式,默认 false --- */
64
65
  'mode'?: EFrameReceiveMode;
65
66
  /** --- 加密模式,默认 true --- */
@@ -105,7 +106,7 @@ export declare class Socket {
105
106
  /** --- 发送文本 --- */
106
107
  writeText(data: string): boolean;
107
108
  /** --- 发送结果对象字符串 --- */
108
- writeResult(data: types.Json): boolean;
109
+ writeResult(data: kebab.Json): boolean;
109
110
  /** --- 发送二进制 --- */
110
111
  writeBinary(data: string | Buffer | Array<string | Buffer>): boolean;
111
112
  /** --- 当前是否是可写状态 --- */
package/lib/ws.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as net from 'net';
2
2
  // --- 第三方 ---
3
3
  import * as liws from '@litert/websocket';
4
- // --- 库 ---
5
4
  import * as lText from '#lib/text.js';
6
5
  import * as lNet from '#lib/net.js';
7
6
  /** --- 一般用 SIMPLE --- */
package/lib/zip.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import jszip from 'jszip';
2
- import * as types from '#types/index.js';
3
2
  /**
4
3
  * --- 本库主要用于读取 zip,请尽量不要用来写入 zip,尤其是大文件 zip ---
5
4
  */
@@ -10,14 +9,14 @@ export declare class Zip {
10
9
  private _path;
11
10
  constructor(zip: jszip);
12
11
  getContent(path: string): Promise<string | null>;
13
- getContent<T extends types.TZipOutputType>(path: string, type: T): Promise<types.IZipOutputByType[T] | null>;
12
+ getContent<T extends TZipOutputType>(path: string, type: T): Promise<IZipOutputByType[T] | null>;
14
13
  /**
15
14
  * --- 写入文件内容 ---
16
15
  * @param path 文件路径
17
16
  * @param data 要写入的内容
18
17
  * @param options 选项
19
18
  */
20
- putContent<T extends types.TZipInputType>(path: string, data: types.IZipInputByType[T], options?: {
19
+ putContent<T extends TZipInputType>(path: string, data: IZipInputByType[T], options?: {
21
20
  'base64'?: boolean;
22
21
  'binary'?: boolean;
23
22
  'date'?: Date;
@@ -32,28 +31,28 @@ export declare class Zip {
32
31
  * @param path 对象路径
33
32
  * @param options 选项
34
33
  */
35
- stats(path: string): types.IZipStats | null;
34
+ stats(path: string): IZipStats | null;
36
35
  /**
37
36
  * --- 判断是否是目录或目录是否存在,是的话返回 stats ---
38
37
  * @param path 判断路径
39
38
  */
40
- isDir(path: string): types.IZipStats | false;
39
+ isDir(path: string): IZipStats | false;
41
40
  /**
42
41
  * --- 判断是否是文件或文件是否存在,是的话返回 stats ---
43
42
  * @param path 判断路径
44
43
  */
45
- isFile(path: string): types.IZipStats | false;
44
+ isFile(path: string): IZipStats | false;
46
45
  /** --- 读取目录,hasChildren: false, hasDir: true, pathAsKey: false --- */
47
46
  readDir(path?: string, opt?: {
48
47
  'hasChildren'?: boolean;
49
48
  'hasDir'?: boolean;
50
49
  'pathAsKey'?: false;
51
- }): types.IZipItem[];
50
+ }): IZipItem[];
52
51
  readDir(path?: string, opt?: {
53
52
  'hasChildren'?: boolean;
54
53
  'hasDir'?: boolean;
55
54
  'pathAsKey': true;
56
- }): Record<string, types.IZipItem>;
55
+ }): Record<string, IZipItem>;
57
56
  private _readDir;
58
57
  /** --- 目录列表缓存 --- */
59
58
  private _list;
@@ -76,11 +75,11 @@ export declare class Zip {
76
75
  * --- 打包 zip ---
77
76
  * @param options 选项
78
77
  */
79
- generate<T extends types.TZipOutputType>(options?: {
78
+ generate<T extends TZipOutputType>(options?: {
80
79
  'type'?: T;
81
80
  'level'?: number;
82
81
  'onUpdate'?: (percent: number, currentFile: string | null) => void;
83
- }): Promise<types.IZipOutputByType[T]>;
82
+ }): Promise<IZipOutputByType[T]>;
84
83
  /**
85
84
  * --- 获取 path 和 string/Buffer 对应的文件列表 ---
86
85
  */
@@ -90,4 +89,49 @@ export declare class Zip {
90
89
  * --- 获取 zip 对象 ---
91
90
  * @param data 对象数据
92
91
  */
93
- export declare function get(data?: types.TZipInputFileFormat): Promise<Zip | null>;
92
+ export declare function get(data?: TZipInputFileFormat): Promise<Zip | null>;
93
+ export interface IZipItem {
94
+ 'name': string;
95
+ 'compressedSize': number;
96
+ 'uncompressedSize': number;
97
+ 'date': Date;
98
+ 'isFile': boolean;
99
+ 'isDirectory': boolean;
100
+ 'path': string;
101
+ }
102
+ export interface IZipStats {
103
+ 'compressedSize': number;
104
+ 'uncompressedSize': number;
105
+ 'date': Date;
106
+ 'isFile': boolean;
107
+ 'isDirectory': boolean;
108
+ }
109
+ export interface IZipOutputByType {
110
+ 'base64': string;
111
+ 'string': string;
112
+ 'text': string;
113
+ 'binarystring': string;
114
+ 'array': number[];
115
+ 'uint8array': Uint8Array;
116
+ 'arraybuffer': ArrayBuffer;
117
+ 'blob': Blob;
118
+ 'nodebuffer': Buffer;
119
+ }
120
+ export type TZipOutputType = keyof IZipOutputByType;
121
+ export interface IZipInputByType {
122
+ 'base64': string;
123
+ 'string': string;
124
+ 'text': string;
125
+ 'binarystring': string;
126
+ 'array': number[];
127
+ 'uint8array': Uint8Array;
128
+ 'arraybuffer': ArrayBuffer;
129
+ 'blob': Blob;
130
+ 'nodebuffer': Buffer;
131
+ }
132
+ export type TZipInputType = keyof IZipInputByType;
133
+ export type TZipInputFileFormat = IZipInputByType[keyof IZipInputByType];
134
+ export interface IZipMetadata {
135
+ 'percent': number;
136
+ 'currentFile': string | null;
137
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -11,6 +11,7 @@
11
11
  "main": "index.js",
12
12
  "author": "hanguoshuai",
13
13
  "license": "Apache-2.0",
14
+ "types": "./index.d.ts",
14
15
  "bin": {
15
16
  "kebab": "./bin/kebab.js"
16
17
  },
@@ -18,8 +19,8 @@
18
19
  "#*": "./*"
19
20
  },
20
21
  "dependencies": {
21
- "@aws-sdk/client-s3": "^3.893.0",
22
- "@aws-sdk/lib-storage": "^3.893.0",
22
+ "@aws-sdk/client-s3": "^3.894.0",
23
+ "@aws-sdk/lib-storage": "^3.894.0",
23
24
  "@litert/http-client": "^1.1.2",
24
25
  "@litert/mime": "^0.1.3",
25
26
  "@litert/redis": "^3.0.5",
@@ -30,7 +31,7 @@
30
31
  "mysql2": "^3.15.0",
31
32
  "ssh2": "^1.17.0",
32
33
  "svg-captcha": "^1.4.0",
33
- "tencentcloud-sdk-nodejs": "^4.1.119"
34
+ "tencentcloud-sdk-nodejs": "^4.1.120"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@litert/eslint-plugin-rules": "^0.3.1",
package/sys/child.js CHANGED
@@ -7,7 +7,7 @@ import * as http2 from 'http2';
7
7
  import * as tls from 'tls';
8
8
  import * as http from 'http';
9
9
  import * as crypto from 'crypto';
10
- // --- 库和定义 ---
10
+ // --- ---
11
11
  import * as fs from '#lib/fs.js';
12
12
  import * as lCore from '#lib/core.js';
13
13
  import * as lText from '#lib/text.js';
package/sys/ctr.d.ts CHANGED
@@ -5,11 +5,11 @@
5
5
  */
6
6
  import * as http from 'http';
7
7
  import * as http2 from 'http2';
8
- import * as session from '../lib/session.js';
9
- import * as db from '../lib/db.js';
10
- import * as kv from '../lib/kv.js';
11
- import * as lWs from '../lib/ws.js';
12
- import * as types from '../types/index.js';
8
+ import * as kebab from '#index.js';
9
+ import * as lSession from '#lib/session.js';
10
+ import * as lDb from '#lib/db.js';
11
+ import * as lKv from '#lib/kv.js';
12
+ import * as lWs from '#lib/ws.js';
13
13
  /**
14
14
  * --- 清除已经加载的 data 与语言包文件缓存 ---
15
15
  */
@@ -24,13 +24,13 @@ export declare class Ctr {
24
24
  /** --- GET 数据 --- */
25
25
  protected _get: Record<string, string>;
26
26
  /** --- 原始 POST 数据 --- */
27
- protected _rawPost: Record<string, types.Json>;
27
+ protected _rawPost: Record<string, kebab.Json>;
28
28
  /** --- POST 数据 --- */
29
- protected _post: Record<string, types.Json>;
29
+ protected _post: Record<string, kebab.Json>;
30
30
  /** --- 原始 input 字符串 */
31
31
  protected _input: string;
32
32
  /** --- 上传的文件列表 --- */
33
- protected _files: Record<string, types.IPostFile | types.IPostFile[]>;
33
+ protected _files: Record<string, kebab.IPostFile | kebab.IPostFile[]>;
34
34
  /** --- Cookie 数组 --- */
35
35
  protected _cookie: Record<string, string>;
36
36
  /** --- Jwt 数组 --- */
@@ -38,7 +38,7 @@ export declare class Ctr {
38
38
  /** --- Session 数组 --- */
39
39
  protected _session: Record<string, any>;
40
40
  /** --- Session --- 对象 */
41
- protected _sess: session.Session | null;
41
+ protected _sess: lSession.Session | null;
42
42
  /** --- 页面浏览器客户端缓存 --- */
43
43
  protected _cacheTTL: number;
44
44
  /** --- XSRF TOKEN 值 --- */
@@ -48,7 +48,7 @@ export declare class Ctr {
48
48
  /** --- 当前语言名 --- */
49
49
  protected _locale: string;
50
50
  /** --- vhost 的 kebab.json 以及全局常量 --- */
51
- protected readonly _config: types.IConfig;
51
+ protected readonly _config: kebab.IConfig;
52
52
  protected readonly _req: http2.Http2ServerRequest | http.IncomingMessage;
53
53
  protected readonly _res: http2.Http2ServerResponse | http.ServerResponse;
54
54
  protected readonly _socket: lWs.Socket;
@@ -56,7 +56,7 @@ export declare class Ctr {
56
56
  protected _localeFiles: string[];
57
57
  /** --- 本 ctr 的 locale data --- */
58
58
  protected _localeData: Record<string, Record<string, string>>;
59
- constructor(config: types.IConfig, req: http2.Http2ServerRequest | http.IncomingMessage, res?: http2.Http2ServerResponse | http.ServerResponse);
59
+ constructor(config: kebab.IConfig, req: http2.Http2ServerRequest | http.IncomingMessage, res?: http2.Http2ServerResponse | http.ServerResponse);
60
60
  /** --- 当前用户连接是否还在连接中 --- */
61
61
  get isAvail(): boolean;
62
62
  /** --- timeout 的 timer --- */
@@ -79,26 +79,26 @@ export declare class Ctr {
79
79
  */
80
80
  protected _asyncTask(func: () => void | Promise<void>): void;
81
81
  /** --- 获取类内部的 prototype --- */
82
- getPrototype(name: '_config'): types.IConfig;
83
- getPrototype(name: '_sess'): session.Session | null;
82
+ getPrototype(name: '_config'): kebab.IConfig;
83
+ getPrototype(name: '_sess'): lSession.Session | null;
84
84
  getPrototype(name: '_headers'): http.IncomingHttpHeaders;
85
85
  getPrototype(name: '_req'): http2.Http2ServerRequest | http.IncomingMessage;
86
86
  getPrototype(name: '_res'): http2.Http2ServerResponse | http.ServerResponse;
87
87
  getPrototype(name: '_socket'): lWs.Socket;
88
- getPrototype(name: '_rawPost' | '_post' | '_get' | '_session'): Record<string, types.Json>;
88
+ getPrototype(name: '_rawPost' | '_post' | '_get' | '_session'): Record<string, kebab.Json>;
89
89
  getPrototype(name: '_input'): string;
90
- getPrototype(name: string): types.Json;
90
+ getPrototype(name: string): kebab.Json;
91
91
  /** --- 设置类内部的 prototype --- */
92
- setPrototype(name: string, val: string | string[] | http.IncomingHttpHeaders | Record<string, types.Json> | session.Session | lWs.Socket | null): void;
92
+ setPrototype(name: string, val: string | string[] | http.IncomingHttpHeaders | Record<string, kebab.Json> | lSession.Session | lWs.Socket | null): void;
93
93
  /**
94
94
  * --- 实例化后会执行的方法,可重写此方法 ---
95
95
  */
96
- onLoad(): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
96
+ onLoad(): boolean | string | kebab.DbValue[] | Promise<boolean | string | kebab.DbValue[]>;
97
97
  /**
98
98
  * --- 整个结束前会执行本方法,可重写此方法对输出结果再处理一次(Websocket 模式无效) ---
99
99
  * @param rtn 之前用户的输出结果
100
100
  */
101
- onUnload(rtn: boolean | string | types.DbValue[]): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
101
+ onUnload(rtn: boolean | string | kebab.DbValue[]): boolean | string | kebab.DbValue[] | Promise<boolean | string | kebab.DbValue[]>;
102
102
  /**
103
103
  * --- WebSocket 下在建立 Server 连接之前可对 WebSocket 的信息进行配置 ---
104
104
  */
@@ -109,7 +109,7 @@ export declare class Ctr {
109
109
  /**
110
110
  * --- WebSocket 下当收到数据时会自动被调用的事件,即只文本和二进制数据,返回内容会被发送给 socket,但返回 false 连接会被中断 ---
111
111
  */
112
- onData(data: Buffer | string, opcode: lWs.EOpcode): types.Json;
112
+ onData(data: Buffer | string, opcode: lWs.EOpcode): kebab.Json;
113
113
  /**
114
114
  * --- 包含所有 opcode 的消息,若要发送数据需自行调用 write 方法,返回 false 则不会执行默认方法 ---
115
115
  * @param data 数据
@@ -138,21 +138,21 @@ export declare class Ctr {
138
138
  * @param path
139
139
  * @param data
140
140
  */
141
- protected _loadView(path: string, data?: types.Json): Promise<string>;
141
+ protected _loadView(path: string, data?: kebab.Json): Promise<string>;
142
142
  /**
143
143
  * --- 检测提交的数据类型 ---
144
144
  * @param input 要校验的输入项
145
145
  * @param rule 规则
146
146
  * @param rtn 返回值
147
147
  */
148
- protected _checkInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
148
+ protected _checkInput(input: Record<string, kebab.Json>, rule: Record<string, kebab.Json[]>, rtn: kebab.Json[]): boolean;
149
149
  /**
150
150
  * --- 检测提交的数据类型(会检测 XSRF) ---
151
151
  * @param input 要校验的输入项
152
152
  * @param rule 规则
153
153
  * @param rtn 返回值
154
154
  */
155
- protected _checkXInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
155
+ protected _checkXInput(input: Record<string, kebab.Json>, rule: Record<string, kebab.Json[]>, rtn: kebab.Json[]): boolean;
156
156
  /**
157
157
  * --- 当前页面开启 XSRF 支持(主要检测 cookie 是否存在) ---
158
158
  * --- 如果当前页面有 CDN,请不要使用 ---
@@ -193,7 +193,7 @@ export declare class Ctr {
193
193
  * @param auth 设为 true 则从头 Authorization 或 post _auth 值读取 token
194
194
  * @param opt name, ttl, ssl, sqlPre
195
195
  */
196
- protected _startSession(link: db.Pool | kv.Pool, auth?: boolean, opt?: session.IOptions): Promise<void>;
196
+ protected _startSession(link: lDb.Pool | lKv.Pool, auth?: boolean, opt?: lSession.IOptions): Promise<void>;
197
197
  /**
198
198
  * --- 设定语言并加载语言包 ---
199
199
  * @param loc 要加载的目标语言
@@ -230,7 +230,7 @@ export declare class Ctr {
230
230
  * --- 发送结果对象文本 ---
231
231
  * @param data 要发送的结果对象,如 [0, 'Failed.']
232
232
  */
233
- protected _writeResult(data: types.Json): boolean;
233
+ protected _writeResult(data: kebab.Json): boolean;
234
234
  /**
235
235
  * --- 发送 socket 二进制 ---
236
236
  * @param data 要发送的信息
package/sys/ctr.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as ejs from 'ejs';
2
- import * as lCore from '../lib/core.js';
3
- import * as fs from '../lib/fs.js';
4
- import * as crypto from '../lib/crypto.js';
5
- import * as session from '../lib/session.js';
6
- import * as text from '../lib/text.js';
7
- import * as sRoute from '../sys/route.js';
2
+ import * as lCore from '#lib/core.js';
3
+ import * as lFs from '#lib/fs.js';
4
+ import * as lCrypto from '#lib/crypto.js';
5
+ import * as lSession from '#lib/session.js';
6
+ import * as lText from '#lib/text.js';
7
+ import * as sRoute from '#sys/route.js';
8
8
  /** --- 已加载的 DATA 数据缓存(不是语言包)-- */
9
9
  let loadedData = {};
10
10
  /** --- 已加载的语言文件列表 --- */
@@ -112,7 +112,7 @@ export class Ctr {
112
112
  }
113
113
  })().catch(e => {
114
114
  lCore.display('[ERROR][CTR][ASYNCTASK]', e);
115
- lCore.log(this, '[CTR][_asyncTask] ' + text.stringifyJson(e.stack).slice(1, -1), '-error');
115
+ lCore.log(this, '[CTR][_asyncTask] ' + lText.stringifyJson(e.stack).slice(1, -1), '-error');
116
116
  --this._waitInfo.asyncTask.count;
117
117
  if (!this._waitInfo.asyncTask.count) {
118
118
  this._waitInfo.asyncTask.resolve();
@@ -184,7 +184,7 @@ export class Ctr {
184
184
  * @param data
185
185
  */
186
186
  async _loadView(path, data = {}) {
187
- const content = await fs.getContent(this._config.const.viewPath + path + '.ejs', 'utf8');
187
+ const content = await lFs.getContent(this._config.const.viewPath + path + '.ejs', 'utf8');
188
188
  if (!content) {
189
189
  return '';
190
190
  }
@@ -485,7 +485,7 @@ export class Ctr {
485
485
  * @param pwd 密码
486
486
  */
487
487
  _getBasicAuth(user, pwd) {
488
- return 'Basic ' + crypto.base64Encode(user + ':' + pwd);
488
+ return 'Basic ' + lCrypto.base64Encode(user + ':' + pwd);
489
489
  }
490
490
  /**
491
491
  * --- 根据用户 ua 获取当前用户的设备类型 ---
@@ -532,7 +532,7 @@ export class Ctr {
532
532
  // --- 不解析,解析使用 JWT 类解析 ---
533
533
  return authArr[1];
534
534
  }
535
- if (!(auth = crypto.base64Decode(authArr[1]))) {
535
+ if (!(auth = lCrypto.base64Decode(authArr[1]))) {
536
536
  return false;
537
537
  }
538
538
  authArr = auth.split(':');
@@ -548,11 +548,11 @@ export class Ctr {
548
548
  if (loadedData[realPath]) {
549
549
  return loadedData[realPath];
550
550
  }
551
- const content = await fs.getContent(realPath, 'utf8');
551
+ const content = await lFs.getContent(realPath, 'utf8');
552
552
  if (!content) {
553
553
  return null;
554
554
  }
555
- const json = text.parseJson(content);
555
+ const json = lText.parseJson(content);
556
556
  loadedData[realPath] = json;
557
557
  return json;
558
558
  }
@@ -562,7 +562,7 @@ export class Ctr {
562
562
  */
563
563
  _location(location) {
564
564
  if (this._res) {
565
- this._res.setHeader('location', text.urlResolve(this._config.const.urlBase, location));
565
+ this._res.setHeader('location', lText.urlResolve(this._config.const.urlBase, location));
566
566
  // this._res.writeHead(302); Kebab 中要在最后设置,否则会报错:ERR_HTTP_HEADERS_SENT
567
567
  }
568
568
  return false;
@@ -574,7 +574,7 @@ export class Ctr {
574
574
  * @param opt name, ttl, ssl, sqlPre
575
575
  */
576
576
  async _startSession(link, auth = false, opt = {}) {
577
- this._sess = new session.Session();
577
+ this._sess = new lSession.Session();
578
578
  await this._sess.init(this, link, auth, opt);
579
579
  }
580
580
  // --- 本地化 ---
@@ -632,7 +632,7 @@ export class Ctr {
632
632
  */
633
633
  _getLocaleJsonString() {
634
634
  if (this._localeData[this._locale] !== undefined) {
635
- return text.stringifyJson(this._localeData[this._locale]);
635
+ return lText.stringifyJson(this._localeData[this._locale]);
636
636
  }
637
637
  else {
638
638
  return '{}';