@kotori-bot/loader 1.8.1 → 1.8.2
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/index.d.ts +4 -0
- package/lib/index.js +2 -2
- package/lib/loader/constants.d.ts +15 -0
- package/lib/loader/constants.js +2 -2
- package/lib/loader/index.d.ts +2 -0
- package/lib/loader/index.js +5 -5
- package/lib/loader/loader.d.ts +126 -0
- package/lib/loader/loader.js +5 -3
- package/lib/service/adapters.d.ts +17 -0
- package/lib/service/adapters.js +2 -2
- package/lib/service/browser.d.ts +5 -0
- package/lib/service/browser.js +2 -2
- package/lib/service/database.d.ts +28 -0
- package/lib/service/database.js +3 -3
- package/lib/service/file.d.ts +10 -0
- package/lib/service/file.js +3 -3
- package/lib/service/server.d.ts +61 -0
- package/lib/service/server.js +4 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -2
- package/lib/types/server.d.ts +26 -0
- package/lib/types/server.js +2 -2
- package/lib/utils/log.d.ts +3 -0
- package/lib/utils/log.js +2 -2
- package/lib/utils/logger.d.ts +16 -0
- package/lib/utils/logger.js +2 -2
- package/package.json +2 -2
package/lib/index.d.ts
ADDED
package/lib/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const PLUGIN_PREFIX = "kotori-plugin-";
|
|
2
|
+
export declare const ADAPTER_PREFIX = "adapter-";
|
|
3
|
+
export declare const CONFIG_NAME = "kotori.toml";
|
|
4
|
+
export declare const BUILD_MODE: "build";
|
|
5
|
+
export declare const DEV_MODE: "dev";
|
|
6
|
+
export declare const CORE_MODULES: string[];
|
|
7
|
+
export declare const INTERNAL_PACKAGES: string[];
|
|
8
|
+
export declare const DEFAULT_LOADER_CONFIG: {
|
|
9
|
+
dirs: string[];
|
|
10
|
+
port: number;
|
|
11
|
+
dbPrefix: string;
|
|
12
|
+
dbDuration: number;
|
|
13
|
+
level: any;
|
|
14
|
+
noColor: boolean;
|
|
15
|
+
};
|
package/lib/loader/constants.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
package/lib/loader/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -24,10 +24,10 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var loader_exports = {};
|
|
26
26
|
module.exports = __toCommonJS(loader_exports);
|
|
27
|
-
__reExport(loader_exports, require("./loader"), module.exports);
|
|
28
27
|
__reExport(loader_exports, require("./constants"), module.exports);
|
|
28
|
+
__reExport(loader_exports, require("./loader"), module.exports);
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
30
|
0 && (module.exports = {
|
|
31
|
-
...require("./
|
|
32
|
-
...require("./
|
|
31
|
+
...require("./constants"),
|
|
32
|
+
...require("./loader")
|
|
33
33
|
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Core, type LocaleType, type ModuleConfig, Parser, Symbols, Tsu } from '@kotori-bot/core';
|
|
2
|
+
import Logger from '@kotori-bot/logger';
|
|
3
|
+
import type Browser from '../service/browser';
|
|
4
|
+
import Database from '../service/database';
|
|
5
|
+
import File from '../service/file';
|
|
6
|
+
import Server from '../service/server';
|
|
7
|
+
import { BUILD_MODE, DEV_MODE } from './constants';
|
|
8
|
+
interface BaseDir {
|
|
9
|
+
root: string;
|
|
10
|
+
data: string;
|
|
11
|
+
logs: string;
|
|
12
|
+
config: string;
|
|
13
|
+
}
|
|
14
|
+
interface Options {
|
|
15
|
+
mode: typeof BUILD_MODE | typeof DEV_MODE;
|
|
16
|
+
isDaemon: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ModulePackage {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
description: string;
|
|
22
|
+
main: string;
|
|
23
|
+
keywords: string[];
|
|
24
|
+
license: 'GPL-3.0' | 'GPL-3.0-or-later' | 'GPL-3.0-only';
|
|
25
|
+
author: string | string[];
|
|
26
|
+
peerDependencies?: {
|
|
27
|
+
'kotori-bot': string;
|
|
28
|
+
[propName: string]: string;
|
|
29
|
+
};
|
|
30
|
+
devDependencies?: {
|
|
31
|
+
'rescript-kotori': string;
|
|
32
|
+
[propName: string]: string;
|
|
33
|
+
};
|
|
34
|
+
kotori: {
|
|
35
|
+
enforce?: 'pre' | 'post';
|
|
36
|
+
meta: {
|
|
37
|
+
language: LocaleType[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ModuleMeta {
|
|
42
|
+
pkg: ModulePackage;
|
|
43
|
+
files: string[];
|
|
44
|
+
main: string;
|
|
45
|
+
}
|
|
46
|
+
interface LoaderOptions {
|
|
47
|
+
mode: typeof DEV_MODE | typeof BUILD_MODE;
|
|
48
|
+
isDaemon?: boolean;
|
|
49
|
+
dir?: string;
|
|
50
|
+
config?: string;
|
|
51
|
+
port?: number;
|
|
52
|
+
dbPrefix?: string;
|
|
53
|
+
level?: number;
|
|
54
|
+
noColor?: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare module '@kotori-bot/core' {
|
|
57
|
+
interface Context {
|
|
58
|
+
readonly baseDir: BaseDir;
|
|
59
|
+
readonly options: Options;
|
|
60
|
+
readonly [Symbols.modules]: Loader[typeof Symbols.modules];
|
|
61
|
+
logger: Logger;
|
|
62
|
+
server: Server;
|
|
63
|
+
db: Database;
|
|
64
|
+
file: File;
|
|
65
|
+
browser: Browser;
|
|
66
|
+
}
|
|
67
|
+
interface GlobalConfig {
|
|
68
|
+
dirs: string[];
|
|
69
|
+
port: number;
|
|
70
|
+
dbPrefix: string;
|
|
71
|
+
dbDuration: number;
|
|
72
|
+
level: number;
|
|
73
|
+
noColor: boolean;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export declare const localeTypeSchema: import("@kotori-bot/core").UnionParser<[import("@kotori-bot/core").LiteralParser<"en_US">, import("@kotori-bot/core").LiteralParser<"ja_JP">, import("@kotori-bot/core").LiteralParser<"zh_TW">, import("@kotori-bot/core").AnyParser<any>]>;
|
|
77
|
+
export declare const globalLoaderConfigSchema: Parser<import("@kotori-bot/core").ObjectParserInfer<{
|
|
78
|
+
lang: Parser<any>;
|
|
79
|
+
commandPrefix: Parser<string>;
|
|
80
|
+
dirs: Parser<string[]>;
|
|
81
|
+
level: Parser<number>;
|
|
82
|
+
port: Parser<number>;
|
|
83
|
+
dbPrefix: Parser<string>;
|
|
84
|
+
dbDuration: Parser<number>;
|
|
85
|
+
noColor: Parser<boolean>;
|
|
86
|
+
}>>;
|
|
87
|
+
export declare const adapterConfigSchemaFactory: (lang: Tsu.infer<typeof localeTypeSchema>, commandPrefix: string) => import("@kotori-bot/core").ObjectParser<{
|
|
88
|
+
extends: import("@kotori-bot/core").StringParser;
|
|
89
|
+
master: import("@kotori-bot/core").UnionParser<[import("@kotori-bot/core").NumberParser, import("@kotori-bot/core").StringParser]>;
|
|
90
|
+
lang: Parser<any>;
|
|
91
|
+
commandPrefix: Parser<string>;
|
|
92
|
+
}>;
|
|
93
|
+
export declare const modulePackageSchema: import("@kotori-bot/core").ObjectParser<{
|
|
94
|
+
name: import("@kotori-bot/core").CustomParser<string>;
|
|
95
|
+
version: import("@kotori-bot/core").StringParser;
|
|
96
|
+
description: import("@kotori-bot/core").StringParser;
|
|
97
|
+
main: import("@kotori-bot/core").StringParser;
|
|
98
|
+
license: import("@kotori-bot/core").CustomParser<"GPL-3.0" | "GPL-3.0-or-later" | "GPL-3.0-only">;
|
|
99
|
+
keywords: import("@kotori-bot/core").CustomParser<string[]>;
|
|
100
|
+
author: import("@kotori-bot/core").UnionParser<[import("@kotori-bot/core").StringParser, import("@kotori-bot/core").ArrayParser<import("@kotori-bot/core").StringParser>]>;
|
|
101
|
+
kotori: Parser<import("@kotori-bot/core").ObjectParserInfer<{
|
|
102
|
+
enforce: Parser<"post" | "pre" | undefined>;
|
|
103
|
+
meta: Parser<import("@kotori-bot/core").ObjectParserInfer<{
|
|
104
|
+
language: Parser<any[]>;
|
|
105
|
+
}>>;
|
|
106
|
+
}>>;
|
|
107
|
+
}>;
|
|
108
|
+
export declare class Loader extends Core {
|
|
109
|
+
private loadRecord;
|
|
110
|
+
private isDev;
|
|
111
|
+
private format;
|
|
112
|
+
readonly baseDir: BaseDir;
|
|
113
|
+
readonly options: Options;
|
|
114
|
+
readonly [Symbols.modules]: Map<string, [ModuleMeta, ModuleConfig, Parser<unknown>?]>;
|
|
115
|
+
constructor(loaderOptions?: LoaderOptions);
|
|
116
|
+
run(onlyStart?: boolean): void;
|
|
117
|
+
private catchError;
|
|
118
|
+
private listenMessage;
|
|
119
|
+
private checkModuleFiles;
|
|
120
|
+
private loadEx;
|
|
121
|
+
private unloadEx;
|
|
122
|
+
private loadAllModules;
|
|
123
|
+
private loadAllAdapter;
|
|
124
|
+
private checkUpdate;
|
|
125
|
+
}
|
|
126
|
+
export default Loader;
|
package/lib/loader/loader.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __create = Object.create;
|
|
@@ -148,7 +148,9 @@ const modulePackageSchema = import_core.Tsu.Object({
|
|
|
148
148
|
version: import_core.Tsu.String(),
|
|
149
149
|
description: import_core.Tsu.String(),
|
|
150
150
|
main: import_core.Tsu.String(),
|
|
151
|
-
license: import_core.Tsu.
|
|
151
|
+
license: import_core.Tsu.Custom(
|
|
152
|
+
(val) => typeof val === "string" && (["GPL-3.0", "GPL-3.0-or-later", "GPL-3.0-only", "BCU"].includes(val) || val.includes("USING"))
|
|
153
|
+
),
|
|
152
154
|
keywords: import_core.Tsu.Custom(
|
|
153
155
|
(val) => Array.isArray(val) && val.includes("kotori") && val.includes("chatbot") && val.includes("kotori-plugin")
|
|
154
156
|
),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type AdapterConfig, type Api, type Elements, Adapter as OriginAdapter } from '@kotori-bot/core';
|
|
2
|
+
import type { WsRouteHandler } from '../types/server';
|
|
3
|
+
export declare namespace Adapters {
|
|
4
|
+
abstract class WebSocket<T extends Api = Api, D extends AdapterConfig = AdapterConfig, E extends Elements = Elements> extends OriginAdapter<T, D, E> {
|
|
5
|
+
private isSetup;
|
|
6
|
+
private destroyFn?;
|
|
7
|
+
private wssPath;
|
|
8
|
+
private wssAddress;
|
|
9
|
+
protected destroy(): void;
|
|
10
|
+
protected setup(): void;
|
|
11
|
+
abstract handle(...data: unknown[]): void;
|
|
12
|
+
connection?: (ws: Parameters<WsRouteHandler>[0], req: Parameters<WsRouteHandler>[1]) => void;
|
|
13
|
+
start(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export default Adapters;
|
package/lib/service/adapters.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
package/lib/service/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Context, Service } from '@kotori-bot/core';
|
|
2
|
+
import { Level } from 'level';
|
|
3
|
+
type DatabaseValue = string | number | object;
|
|
4
|
+
interface DatabaseConfig {
|
|
5
|
+
prefix: string;
|
|
6
|
+
duration: number;
|
|
7
|
+
}
|
|
8
|
+
declare class Database extends Service<DatabaseConfig> {
|
|
9
|
+
private readonly usingDir;
|
|
10
|
+
readonly level: Level;
|
|
11
|
+
private prefixKey;
|
|
12
|
+
constructor(ctx: Context, config: DatabaseConfig);
|
|
13
|
+
start(): Promise<void>;
|
|
14
|
+
stop(): void;
|
|
15
|
+
get<T extends DatabaseValue | null = DatabaseValue | null>(key: string, init?: Exclude<T, null>): Promise<T>;
|
|
16
|
+
getMany<T extends DatabaseValue = DatabaseValue>(keys: string[]): Promise<T[]>;
|
|
17
|
+
put<T extends DatabaseValue>(key: string, value: T): Promise<void>;
|
|
18
|
+
del(key: string): Promise<void>;
|
|
19
|
+
batch<T extends DatabaseValue>(operations: Array<{
|
|
20
|
+
type: 'put';
|
|
21
|
+
key: string;
|
|
22
|
+
value: T;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'del';
|
|
25
|
+
key: string;
|
|
26
|
+
}>): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export default Database;
|
package/lib/service/database.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -30,9 +30,9 @@ __export(database_exports, {
|
|
|
30
30
|
default: () => database_default
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(database_exports);
|
|
33
|
+
var import_node_path = require("node:path");
|
|
33
34
|
var import_core = require("@kotori-bot/core");
|
|
34
35
|
var import_level = require("level");
|
|
35
|
-
var import_node_path = require("node:path");
|
|
36
36
|
class Database extends import_core.Service {
|
|
37
37
|
// private readonly filename = resolve(this.ctx.baseDir.root, 'datab.db')
|
|
38
38
|
usingDir = (0, import_node_path.resolve)(this.ctx.baseDir.data, "db");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Context, createConfig, type JsonMap, loadConfig, Service, saveConfig } from '@kotori-bot/core';
|
|
2
|
+
export declare class File extends Service {
|
|
3
|
+
constructor(ctx: Context);
|
|
4
|
+
getDir(): string;
|
|
5
|
+
getFile(filename: string): string;
|
|
6
|
+
load<O = undefined, T extends Parameters<typeof loadConfig>[1] = 'json'>(filename: string, type?: T, init?: T extends 'text' ? string : object): O extends undefined ? T extends "text" ? string : JsonMap : O;
|
|
7
|
+
save(filename: string, data: Parameters<typeof saveConfig>[1], type?: Parameters<typeof saveConfig>[2]): void;
|
|
8
|
+
create(filename: string, data?: Parameters<typeof createConfig>[1], type?: Parameters<typeof createConfig>[2]): void;
|
|
9
|
+
}
|
|
10
|
+
export default File;
|
package/lib/service/file.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -31,8 +31,8 @@ __export(file_exports, {
|
|
|
31
31
|
default: () => file_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(file_exports);
|
|
34
|
-
var import_core = require("@kotori-bot/core");
|
|
35
34
|
var import_node_path = require("node:path");
|
|
35
|
+
var import_core = require("@kotori-bot/core");
|
|
36
36
|
class File extends import_core.Service {
|
|
37
37
|
constructor(ctx) {
|
|
38
38
|
super(ctx, {}, "file");
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
+
import { type Context, Service } from '@kotori-bot/core';
|
|
3
|
+
import type { HttpRouteHandler, HttpRoutes, WsRouteHandler } from '../types/server';
|
|
4
|
+
interface ServerConfig {
|
|
5
|
+
port: number;
|
|
6
|
+
}
|
|
7
|
+
interface BodyParserOptions {
|
|
8
|
+
inflate?: boolean | undefined;
|
|
9
|
+
limit?: number | string | undefined;
|
|
10
|
+
type?: string | string[] | ((req: IncomingMessage) => any) | undefined;
|
|
11
|
+
verify?(req: IncomingMessage, res: ServerResponse, buf: Buffer, encoding: string): void;
|
|
12
|
+
}
|
|
13
|
+
interface UrlencodedOptions extends BodyParserOptions {
|
|
14
|
+
extended?: boolean | undefined;
|
|
15
|
+
parameterLimit?: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface ServeStaticOptions<R extends ServerResponse = ServerResponse> {
|
|
18
|
+
acceptRanges?: boolean | undefined;
|
|
19
|
+
cacheControl?: boolean | undefined;
|
|
20
|
+
dotfiles?: string | undefined;
|
|
21
|
+
etag?: boolean | undefined;
|
|
22
|
+
extensions?: string[] | false | undefined;
|
|
23
|
+
fallthrough?: boolean | undefined;
|
|
24
|
+
immutable?: boolean | undefined;
|
|
25
|
+
index?: boolean | string | string[] | undefined;
|
|
26
|
+
lastModified?: boolean | undefined;
|
|
27
|
+
maxAge?: number | string | undefined;
|
|
28
|
+
redirect?: boolean | undefined;
|
|
29
|
+
setHeaders?: ((res: R, path: string, stat: any) => any) | undefined;
|
|
30
|
+
}
|
|
31
|
+
interface RouterOptions {
|
|
32
|
+
caseSensitive?: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @default false
|
|
35
|
+
* @since 4.5.0
|
|
36
|
+
*/
|
|
37
|
+
mergeParams?: boolean | undefined;
|
|
38
|
+
strict?: boolean | undefined;
|
|
39
|
+
}
|
|
40
|
+
export declare class Server extends Service<ServerConfig> implements HttpRoutes {
|
|
41
|
+
private app;
|
|
42
|
+
private server;
|
|
43
|
+
private wsServer;
|
|
44
|
+
private wsRoutes;
|
|
45
|
+
constructor(ctx: Context, config: ServerConfig);
|
|
46
|
+
start(callback?: () => void): void;
|
|
47
|
+
stop(): void;
|
|
48
|
+
get<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
49
|
+
post<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
50
|
+
patch<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
51
|
+
put<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
52
|
+
delete<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
53
|
+
all<P extends string>(path: P, ...callback: HttpRouteHandler<P>[]): void;
|
|
54
|
+
use<P extends string>(path: P | HttpRouteHandler | HttpRoutes, ...callback: (HttpRouteHandler<P> | HttpRoutes)[]): void;
|
|
55
|
+
router: (options?: RouterOptions) => HttpRoutes;
|
|
56
|
+
json: (options?: BodyParserOptions) => HttpRouteHandler;
|
|
57
|
+
static: (root: string, options?: ServeStaticOptions) => HttpRouteHandler;
|
|
58
|
+
urlencoded: (options?: UrlencodedOptions) => HttpRouteHandler;
|
|
59
|
+
wss<P extends string>(path: P, callback: WsRouteHandler<P>): () => boolean;
|
|
60
|
+
}
|
|
61
|
+
export default Server;
|
package/lib/service/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __create = Object.create;
|
|
@@ -41,10 +41,10 @@ __export(server_exports, {
|
|
|
41
41
|
default: () => server_default
|
|
42
42
|
});
|
|
43
43
|
module.exports = __toCommonJS(server_exports);
|
|
44
|
-
var import_core = require("@kotori-bot/core");
|
|
45
44
|
var import_node_http = require("node:http");
|
|
46
|
-
var
|
|
45
|
+
var import_core = require("@kotori-bot/core");
|
|
47
46
|
var import_express = __toESM(require("express"));
|
|
47
|
+
var import_path_to_regexp = require("path-to-regexp");
|
|
48
48
|
var import_ws = __toESM(require("ws"));
|
|
49
49
|
class Server extends import_core.Service {
|
|
50
50
|
app;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './server';
|
package/lib/types/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
2
|
+
import type { IncomingMessage } from 'node:http';
|
|
3
|
+
import type Ws from 'ws';
|
|
4
|
+
type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
|
|
5
|
+
type GetRouteParameter<S extends string> = RemoveTail<RemoveTail<RemoveTail<S, `/${string}`>, `-${string}`>, `.${string}`>;
|
|
6
|
+
interface ParamsDictionary {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
type RouteParameters<Route extends string> = string extends Route ? ParamsDictionary : Route extends `${string}(${string}` ? ParamsDictionary : Route extends `${string}:${infer Rest}` ? (GetRouteParameter<Rest> extends never ? ParamsDictionary : GetRouteParameter<Rest> extends `${infer ParamName}?` ? {
|
|
10
|
+
[P in ParamName]?: string;
|
|
11
|
+
} : {
|
|
12
|
+
[P in GetRouteParameter<Rest>]: string;
|
|
13
|
+
}) & (Rest extends `${GetRouteParameter<Rest>}${infer Next}` ? RouteParameters<Next> : unknown) : object;
|
|
14
|
+
export type HttpRouteHandler<P extends string = string> = (req: Request<RouteParameters<P>>, res: Response, next: NextFunction) => unknown;
|
|
15
|
+
type KeyList = 'get' | 'post' | 'patch' | 'put' | 'delete' | 'all';
|
|
16
|
+
export type WsRouteHandler<P extends string = ''> = (ws: Ws, req: IncomingMessage & {
|
|
17
|
+
params: RouteParameters<P>;
|
|
18
|
+
}) => void;
|
|
19
|
+
type HttpRoutesReflect = {
|
|
20
|
+
[K in KeyList]: <P extends string>(path: P, ...callback: HttpRouteHandler<P>[]) => unknown;
|
|
21
|
+
};
|
|
22
|
+
export interface HttpRoutes extends HttpRoutesReflect {
|
|
23
|
+
use<P extends string>(path: P, ...callback: (HttpRouteHandler<P> | HttpRoutes)[]): unknown;
|
|
24
|
+
use(...callback: (HttpRouteHandler | HttpRoutes)[]): unknown;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
package/lib/types/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
package/lib/utils/log.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from '@kotori-bot/core';
|
|
2
|
+
import { Logger } from '@kotori-bot/logger';
|
|
3
|
+
export declare class KotoriLogger extends Logger {
|
|
4
|
+
private optionsSelf;
|
|
5
|
+
private ctx;
|
|
6
|
+
constructor(optionsSelf: Logger['options'], ctx: Context);
|
|
7
|
+
private setLabel;
|
|
8
|
+
fatal(...args: unknown[]): void;
|
|
9
|
+
error(...args: unknown[]): void;
|
|
10
|
+
warn(...args: unknown[]): void;
|
|
11
|
+
info(...args: unknown[]): void;
|
|
12
|
+
record(...args: unknown[]): void;
|
|
13
|
+
debug(...args: unknown[]): void;
|
|
14
|
+
trace(...args: unknown[]): void;
|
|
15
|
+
}
|
|
16
|
+
export default KotoriLogger;
|
package/lib/utils/logger.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @Package @kotori-bot/loader
|
|
3
|
-
* @Version 1.8.
|
|
3
|
+
* @Version 1.8.2
|
|
4
4
|
* @Author Arimura Sena <me@hotaru.icu>
|
|
5
5
|
* @Copyright 2024-2025 Hotaru. All rights reserved.
|
|
6
6
|
* @License GPL-3.0
|
|
7
7
|
* @Link https://github.com/kotorijs/kotori
|
|
8
|
-
* @Date 2026/2/14
|
|
8
|
+
* @Date 2026/2/14 15:49:08
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
var __defProp = Object.defineProperty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kotori-bot/loader",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Loader For KotoriBot",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"path-to-regexp": "^6.2.2",
|
|
31
31
|
"ws": "^8.14.2",
|
|
32
32
|
"@kotori-bot/logger": "^1.3.4",
|
|
33
|
-
"@kotori-bot/core": "^1.7.
|
|
33
|
+
"@kotori-bot/core": "^1.7.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/express": "^4.17.21",
|