@kotori-bot/core 1.4.1 → 1.5.0
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/components/config.js +109 -35
- package/lib/components/core.d.ts +2 -0
- package/lib/components/core.js +842 -30
- package/lib/components/index.js +858 -17
- package/lib/components/message.d.ts +9 -2
- package/lib/components/message.js +832 -125
- package/lib/global/constants.js +66 -17
- package/lib/global/index.js +81 -16
- package/lib/global/symbols.d.ts +2 -0
- package/lib/global/symbols.js +50 -11
- package/lib/index.js +871 -35
- package/lib/service/adapter.d.ts +2 -5
- package/lib/service/adapter.js +826 -125
- package/lib/service/api.js +81 -44
- package/lib/service/cache.js +68 -33
- package/lib/service/elements.js +74 -38
- package/lib/service/index.js +850 -19
- package/lib/types/adapter.js +28 -1
- package/lib/types/config.js +28 -1
- package/lib/types/index.js +73 -17
- package/lib/types/message.d.ts +19 -6
- package/lib/types/message.js +70 -14
- package/lib/utils/command.d.ts +18 -10
- package/lib/utils/command.js +253 -204
- package/lib/utils/commandError.js +75 -12
- package/lib/utils/container.js +60 -20
- package/lib/utils/error.js +68 -28
- package/lib/utils/factory.d.ts +11 -3
- package/lib/utils/factory.js +846 -36
- package/lib/utils/jsxFactory.js +28 -1
- package/package.json +5 -7
- package/lib/components/modules.d.ts +0 -12
- package/lib/components/modules.js +0 -127
- package/lib/constants.d.ts +0 -15
- package/lib/constants.js +0 -19
- package/lib/consts.d.ts +0 -15
- package/lib/consts.js +0 -19
- package/lib/context/context.d.ts +0 -36
- package/lib/context/context.js +0 -115
- package/lib/context/events.d.ts +0 -18
- package/lib/context/events.js +0 -2
- package/lib/context/index.d.ts +0 -5
- package/lib/context/index.js +0 -21
- package/lib/context/modules.d.ts +0 -39
- package/lib/context/modules.js +0 -65
- package/lib/context/service.d.ts +0 -16
- package/lib/context/service.js +0 -22
- package/lib/context/symbols.d.ts +0 -12
- package/lib/context/symbols.js +0 -18
- package/lib/context/test.d.ts +0 -6
- package/lib/context/test.js +0 -12
- package/lib/global/tokens.d.ts +0 -8
- package/lib/global/tokens.js +0 -12
- package/lib/service/service.d.ts +0 -16
- package/lib/service/service.js +0 -22
- package/lib/types/core.d.ts +0 -7
- package/lib/types/core.js +0 -2
- package/lib/types/modules.d.ts +0 -39
- package/lib/types/modules.js +0 -2
- package/lib/types/service.d.ts +0 -23
- package/lib/types/service.js +0 -2
- package/lib/utils/errror.d.ts +0 -24
- package/lib/utils/errror.js +0 -29
package/lib/utils/error.js
CHANGED
|
@@ -1,29 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @Package @kotori-bot/core
|
|
4
|
+
* @Version 1.4.2-beta.1
|
|
5
|
+
* @Author Hotaru <biyuehuya@gmail.com>
|
|
6
|
+
* @Copyright 2024 Hotaru. All rights reserved.
|
|
7
|
+
* @License GPL-3.0
|
|
8
|
+
* @Link https://github.com/kotorijs/kotori
|
|
9
|
+
* @Date 2024/6/6 21:03:53
|
|
10
|
+
*/
|
|
11
|
+
|
|
1
12
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
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
|
-
exports
|
|
29
|
-
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/utils/error.ts
|
|
32
|
+
var error_exports = {};
|
|
33
|
+
__export(error_exports, {
|
|
34
|
+
DevError: () => DevError,
|
|
35
|
+
KotoriError: () => KotoriError,
|
|
36
|
+
ModuleError: () => ModuleError,
|
|
37
|
+
default: () => error_default
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(error_exports);
|
|
40
|
+
var KotoriError = class _KotoriError extends Error {
|
|
41
|
+
constructor(message, extra, type = "UnknownError") {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = type;
|
|
44
|
+
this.extra = extra;
|
|
45
|
+
}
|
|
46
|
+
extra;
|
|
47
|
+
name;
|
|
48
|
+
extend() {
|
|
49
|
+
const { message: fatherMessage, name: fatherType, extra: fatherExtra } = this;
|
|
50
|
+
return new Proxy(_KotoriError, {
|
|
51
|
+
construct(Class, params) {
|
|
52
|
+
const args = params;
|
|
53
|
+
args[0] = `${fatherMessage} ${args[0]}`;
|
|
54
|
+
args[1] = args[1] ?? fatherExtra;
|
|
55
|
+
args[2] = args[2] ?? fatherType;
|
|
56
|
+
return new Class(...args);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var ModuleError = new KotoriError(void 0, void 0, "ModuleError").extend();
|
|
62
|
+
var DevError = new KotoriError(void 0, void 0, "DevError").extend();
|
|
63
|
+
var error_default = KotoriError;
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
DevError,
|
|
67
|
+
KotoriError,
|
|
68
|
+
ModuleError
|
|
69
|
+
});
|
package/lib/utils/factory.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import I18n from '@kotori-bot/i18n/src/common';
|
|
2
1
|
import type { Context } from 'fluoro';
|
|
3
|
-
import {
|
|
2
|
+
import type { I18n } from '@kotori-bot/i18n';
|
|
3
|
+
import { type CommandArgType, MessageRaw, MessageQuick, EventApiType } from '../types';
|
|
4
|
+
import type { Adapter } from '../service/adapter';
|
|
4
5
|
export declare function disposeFactory(ctx: Context, dispose: () => void): void;
|
|
5
6
|
export declare function cancelFactory(): {
|
|
6
7
|
get(): () => void;
|
|
7
8
|
fn(): void;
|
|
8
9
|
value: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare function formatFactory(i18n: I18n): (template: string, data: Record<string,
|
|
11
|
+
export declare function formatFactory(i18n: I18n): (template: string, data: Record<string, CommandArgType | undefined> | (CommandArgType | undefined)[]) => string;
|
|
12
|
+
export declare function sendMessageFactory(adapter: Adapter, type: keyof EventApiType, data: Parameters<Adapter['session']>[1]): (message: MessageRaw) => void;
|
|
13
|
+
export declare function quickFactory(send: ReturnType<typeof sendMessageFactory>, i18n: I18n): (message: MessageQuick) => Promise<void>;
|
|
14
|
+
export declare function promptFactory(quick: ReturnType<typeof quickFactory>, adapter: Adapter, data: Parameters<Adapter['session']>[1]): (message?: MessageRaw) => Promise<unknown>;
|
|
15
|
+
export declare function confirmFactory(quick: ReturnType<typeof quickFactory>, adapter: Adapter, data: Parameters<Adapter['session']>[1]): (options?: {
|
|
16
|
+
message: MessageRaw;
|
|
17
|
+
sure: MessageRaw;
|
|
18
|
+
}) => Promise<unknown>;
|