@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/context/test.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const symbols_1 = require("./symbols");
|
|
4
|
-
const cache_1 = require("../service/cache");
|
|
5
|
-
const context_1 = require("./context");
|
|
6
|
-
class K extends context_1.Context {
|
|
7
|
-
}
|
|
8
|
-
const ctx = new K();
|
|
9
|
-
ctx.provide('cache', new cache_1.Cache(ctx));
|
|
10
|
-
const ctx2 = ctx.extends({}, 'tt');
|
|
11
|
-
ctx2.inject('cache');
|
|
12
|
-
console.log(ctx2[symbols_1.Symbols.container].get('cache').ctx.identity, ctx2.cache.ctx.identity, ctx[symbols_1.Symbols.container].get('cache').ctx.identity, ctx2.get('cache').ctx.identity);
|
package/lib/global/tokens.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare class Tokens {
|
|
2
|
-
static readonly adapter: unique symbol;
|
|
3
|
-
static readonly bot: unique symbol;
|
|
4
|
-
static readonly midware: unique symbol;
|
|
5
|
-
static readonly command: unique symbol;
|
|
6
|
-
static readonly regexp: unique symbol;
|
|
7
|
-
static readonly modules: unique symbol;
|
|
8
|
-
}
|
package/lib/global/tokens.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tokens = void 0;
|
|
4
|
-
class Tokens {
|
|
5
|
-
static adapter = Symbol.for('kotori.core.adapter');
|
|
6
|
-
static bot = Symbol.for('kotori.core.bot');
|
|
7
|
-
static midware = Symbol.for('kotori.core.midware');
|
|
8
|
-
static command = Symbol.for('kotori.core.command');
|
|
9
|
-
static regexp = Symbol.for('kotori.core.regexp');
|
|
10
|
-
static modules = Symbol.for('kotori.loader.module');
|
|
11
|
-
}
|
|
12
|
-
exports.Tokens = Tokens;
|
package/lib/service/service.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Context } from '../context';
|
|
2
|
-
interface ServiceImpl<T extends object = object> {
|
|
3
|
-
readonly identity: string;
|
|
4
|
-
readonly config: T;
|
|
5
|
-
start(): void;
|
|
6
|
-
stop(): void;
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class Service<T extends object = object> implements ServiceImpl<T> {
|
|
9
|
-
readonly ctx: Context;
|
|
10
|
-
readonly config: T;
|
|
11
|
-
readonly identity: string;
|
|
12
|
-
constructor(ctx: Context, config: T, identity: string);
|
|
13
|
-
start(): void;
|
|
14
|
-
stop(): void;
|
|
15
|
-
}
|
|
16
|
-
export default Service;
|
package/lib/service/service.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Service = void 0;
|
|
4
|
-
const tools_1 = require("@kotori-bot/tools");
|
|
5
|
-
class Service {
|
|
6
|
-
ctx;
|
|
7
|
-
config;
|
|
8
|
-
identity;
|
|
9
|
-
constructor(ctx, config, identity) {
|
|
10
|
-
this.ctx = ctx;
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.identity = identity;
|
|
13
|
-
}
|
|
14
|
-
start() {
|
|
15
|
-
return (0, tools_1.none)(this);
|
|
16
|
-
}
|
|
17
|
-
stop() {
|
|
18
|
-
return (0, tools_1.none)(this);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.Service = Service;
|
|
22
|
-
exports.default = Service;
|
package/lib/types/core.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type EventsList = {
|
|
2
|
-
[K in keyof EventsMapping]: Parameters<EventsMapping[K]>[1] extends never | undefined | null ? Parameters<EventsMapping[K]>[0] : [...Parameters<EventsMapping[K]>];
|
|
3
|
-
};
|
|
4
|
-
export interface EventsMapping {
|
|
5
|
-
ready(): void;
|
|
6
|
-
dispose(): void;
|
|
7
|
-
}
|
package/lib/types/core.js
DELETED
package/lib/types/modules.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { LocaleType } from '@kotori-bot/i18n';
|
|
2
|
-
declare module './core' {
|
|
3
|
-
interface EventsMapping {
|
|
4
|
-
ready_module(data: EventDataReadyModule): void;
|
|
5
|
-
dispose_module(data: EventDataDisposeModule): void;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface EventDataReadyModule {
|
|
9
|
-
module: ModuleInstance | string;
|
|
10
|
-
error?: unknown;
|
|
11
|
-
}
|
|
12
|
-
interface EventDataDisposeModule {
|
|
13
|
-
module: ModuleInstance | string;
|
|
14
|
-
}
|
|
15
|
-
export interface ModulePackage {
|
|
16
|
-
name: string;
|
|
17
|
-
version: string;
|
|
18
|
-
description: string;
|
|
19
|
-
main: string;
|
|
20
|
-
keywords: string[];
|
|
21
|
-
license: 'GPL-3.0';
|
|
22
|
-
author: string | string[];
|
|
23
|
-
peerDependencies: {
|
|
24
|
-
'kotori-bot': string;
|
|
25
|
-
[propName: string]: string;
|
|
26
|
-
};
|
|
27
|
-
kotori: {
|
|
28
|
-
enforce?: 'pre' | 'post';
|
|
29
|
-
meta: {
|
|
30
|
-
language: LocaleType[];
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export interface ModuleInstance {
|
|
35
|
-
pkg: ModulePackage;
|
|
36
|
-
files: string[];
|
|
37
|
-
main: string;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
package/lib/types/modules.js
DELETED
package/lib/types/service.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Context } from '../context';
|
|
2
|
-
import type { Adapter, Service } from '../service';
|
|
3
|
-
import type { AdapterConfig } from './config';
|
|
4
|
-
declare module './core' {
|
|
5
|
-
interface EventsMapping {
|
|
6
|
-
connect(data: EventDataConnect): void;
|
|
7
|
-
status(data: EventDataStatus): void;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface EventDataConnect {
|
|
11
|
-
adapter: Adapter;
|
|
12
|
-
type: 'connect' | 'disconnect';
|
|
13
|
-
normal: boolean;
|
|
14
|
-
mode: 'ws' | 'ws-reverse' | 'other';
|
|
15
|
-
address: string;
|
|
16
|
-
}
|
|
17
|
-
interface EventDataStatus {
|
|
18
|
-
adapter: Adapter;
|
|
19
|
-
status: Adapter['status']['value'];
|
|
20
|
-
}
|
|
21
|
-
export type ServiceClass = new (config: object) => Service;
|
|
22
|
-
export type AdapterClass = new (ctx: Context, config: AdapterConfig, identity: string) => Adapter;
|
|
23
|
-
export {};
|
package/lib/types/service.js
DELETED
package/lib/utils/errror.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type KotoriErrorType = 'ServiceError' | 'ModuleError' | 'UnknownError' | 'DevError';
|
|
2
|
-
interface KotoriErrorImpl {
|
|
3
|
-
readonly name: KotoriErrorType;
|
|
4
|
-
readonly extend: () => typeof KotoriError;
|
|
5
|
-
}
|
|
6
|
-
export declare class KotoriError<T extends object = object> extends Error implements KotoriErrorImpl {
|
|
7
|
-
constructor(message?: string, extra?: T, type?: KotoriErrorType);
|
|
8
|
-
readonly extra?: T;
|
|
9
|
-
readonly name: KotoriErrorType;
|
|
10
|
-
extend(): typeof KotoriError<T>;
|
|
11
|
-
}
|
|
12
|
-
export declare const ModuleError: {
|
|
13
|
-
new (message?: string, extra?: object | undefined, type?: KotoriErrorType): KotoriError<object>;
|
|
14
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
15
|
-
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
16
|
-
stackTraceLimit: number;
|
|
17
|
-
};
|
|
18
|
-
export declare const DevError: {
|
|
19
|
-
new (message?: string, extra?: object | undefined, type?: KotoriErrorType): KotoriError<object>;
|
|
20
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
21
|
-
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
22
|
-
stackTraceLimit: number;
|
|
23
|
-
};
|
|
24
|
-
export default KotoriError;
|
package/lib/utils/errror.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DevError = exports.ModuleError = exports.KotoriError = void 0;
|
|
4
|
-
class KotoriError extends Error {
|
|
5
|
-
constructor(message, extra, type = 'UnknownError') {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = type;
|
|
8
|
-
this.extra = extra;
|
|
9
|
-
}
|
|
10
|
-
extra;
|
|
11
|
-
name;
|
|
12
|
-
extend() {
|
|
13
|
-
const { message: fatherMessage, name: fatherType, extra: fatherExtra } = this;
|
|
14
|
-
// const newClass: typeof KotoriError = Object.create(KotoriError);
|
|
15
|
-
return new Proxy((KotoriError), {
|
|
16
|
-
construct(Class, params) {
|
|
17
|
-
const args = params;
|
|
18
|
-
args[0] = `${fatherMessage} ${args[0]}`;
|
|
19
|
-
args[1] = args[1] ?? fatherExtra;
|
|
20
|
-
args[2] = args[2] ?? fatherType;
|
|
21
|
-
return new Class(...args);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.KotoriError = KotoriError;
|
|
27
|
-
exports.ModuleError = new KotoriError(undefined, undefined, 'ModuleError').extend();
|
|
28
|
-
exports.DevError = new KotoriError(undefined, undefined, 'DevError').extend();
|
|
29
|
-
exports.default = KotoriError;
|