@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.
Files changed (63) hide show
  1. package/lib/components/config.js +109 -35
  2. package/lib/components/core.d.ts +2 -0
  3. package/lib/components/core.js +842 -30
  4. package/lib/components/index.js +858 -17
  5. package/lib/components/message.d.ts +9 -2
  6. package/lib/components/message.js +832 -125
  7. package/lib/global/constants.js +66 -17
  8. package/lib/global/index.js +81 -16
  9. package/lib/global/symbols.d.ts +2 -0
  10. package/lib/global/symbols.js +50 -11
  11. package/lib/index.js +871 -35
  12. package/lib/service/adapter.d.ts +2 -5
  13. package/lib/service/adapter.js +826 -125
  14. package/lib/service/api.js +81 -44
  15. package/lib/service/cache.js +68 -33
  16. package/lib/service/elements.js +74 -38
  17. package/lib/service/index.js +850 -19
  18. package/lib/types/adapter.js +28 -1
  19. package/lib/types/config.js +28 -1
  20. package/lib/types/index.js +73 -17
  21. package/lib/types/message.d.ts +19 -6
  22. package/lib/types/message.js +70 -14
  23. package/lib/utils/command.d.ts +18 -10
  24. package/lib/utils/command.js +253 -204
  25. package/lib/utils/commandError.js +75 -12
  26. package/lib/utils/container.js +60 -20
  27. package/lib/utils/error.js +68 -28
  28. package/lib/utils/factory.d.ts +11 -3
  29. package/lib/utils/factory.js +846 -36
  30. package/lib/utils/jsxFactory.js +28 -1
  31. package/package.json +5 -7
  32. package/lib/components/modules.d.ts +0 -12
  33. package/lib/components/modules.js +0 -127
  34. package/lib/constants.d.ts +0 -15
  35. package/lib/constants.js +0 -19
  36. package/lib/consts.d.ts +0 -15
  37. package/lib/consts.js +0 -19
  38. package/lib/context/context.d.ts +0 -36
  39. package/lib/context/context.js +0 -115
  40. package/lib/context/events.d.ts +0 -18
  41. package/lib/context/events.js +0 -2
  42. package/lib/context/index.d.ts +0 -5
  43. package/lib/context/index.js +0 -21
  44. package/lib/context/modules.d.ts +0 -39
  45. package/lib/context/modules.js +0 -65
  46. package/lib/context/service.d.ts +0 -16
  47. package/lib/context/service.js +0 -22
  48. package/lib/context/symbols.d.ts +0 -12
  49. package/lib/context/symbols.js +0 -18
  50. package/lib/context/test.d.ts +0 -6
  51. package/lib/context/test.js +0 -12
  52. package/lib/global/tokens.d.ts +0 -8
  53. package/lib/global/tokens.js +0 -12
  54. package/lib/service/service.d.ts +0 -16
  55. package/lib/service/service.js +0 -22
  56. package/lib/types/core.d.ts +0 -7
  57. package/lib/types/core.js +0 -2
  58. package/lib/types/modules.d.ts +0 -39
  59. package/lib/types/modules.js +0 -2
  60. package/lib/types/service.d.ts +0 -23
  61. package/lib/types/service.js +0 -2
  62. package/lib/utils/errror.d.ts +0 -24
  63. package/lib/utils/errror.js +0 -29
@@ -1,39 +1,113 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ var __create = Object.create;
14
+ var __defProp = Object.defineProperty;
15
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
+ var __getOwnPropNames = Object.getOwnPropertyNames;
17
+ var __getProtoOf = Object.getPrototypeOf;
18
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
4
22
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Config = void 0;
7
- const tsukiko_1 = __importDefault(require("tsukiko"));
8
- const node_path_1 = require("node:path");
9
- const tools_1 = require("@kotori-bot/tools");
10
- const global_1 = require("../global");
11
- const packageInfoSchema = tsukiko_1.default.Object({
12
- name: tsukiko_1.default.String(),
13
- version: tsukiko_1.default.String(),
14
- description: tsukiko_1.default.String(),
15
- main: tsukiko_1.default.String(),
16
- license: tsukiko_1.default.Literal('GPL-3.0'),
17
- author: tsukiko_1.default.String()
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
39
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
+
41
+ // src/components/config.ts
42
+ var config_exports = {};
43
+ __export(config_exports, {
44
+ Config: () => Config,
45
+ default: () => config_default
46
+ });
47
+ module.exports = __toCommonJS(config_exports);
48
+ var import_tsukiko = __toESM(require("tsukiko"));
49
+ var import_node_path = require("path");
50
+ var import_tools = require("@kotori-bot/tools");
51
+
52
+ // src/global/constants.ts
53
+ var import_i18n = require("@kotori-bot/i18n");
54
+ var PLUGIN_PREFIX = "kotori-plugin-";
55
+ var DATABASE_PREFIX = `${PLUGIN_PREFIX}database-`;
56
+ var ADAPTER_PREFIX = `${PLUGIN_PREFIX}adapter-`;
57
+ var CUSTOM_PREFIX = `${PLUGIN_PREFIX}custom-`;
58
+ var DEFAULT_PORT = 720;
59
+ var DEFAULT_CORE_CONFIG = {
60
+ global: {
61
+ lang: import_i18n.DEFAULT_LANG,
62
+ "command-prefix": "/",
63
+ port: DEFAULT_PORT
64
+ },
65
+ adapter: {},
66
+ plugin: {}
67
+ };
68
+
69
+ // src/global/symbols.ts
70
+ var Symbols = class {
71
+ static adapter = Symbol.for("kotori.core.adapter");
72
+ static bot = Symbol.for("kotori.core.bot");
73
+ static midware = Symbol.for("kotori.core.midware");
74
+ static command = Symbol.for("kotori.core.command");
75
+ static regexp = Symbol.for("kotori.core.regexp");
76
+ static modules = Symbol.for("kotori.loader.module");
77
+ static job = Symbol.for("kotori.loader.job");
78
+ };
79
+
80
+ // src/components/config.ts
81
+ var packageInfoSchema = import_tsukiko.default.Object({
82
+ name: import_tsukiko.default.String(),
83
+ version: import_tsukiko.default.String(),
84
+ description: import_tsukiko.default.String(),
85
+ main: import_tsukiko.default.String(),
86
+ license: import_tsukiko.default.Literal("GPL-3.0"),
87
+ author: import_tsukiko.default.String()
18
88
  });
19
- class Config {
20
- config;
21
- pkg;
22
- constructor(config = global_1.DEFAULT_CORE_CONFIG) {
23
- this.config = config;
24
- /* load package.json */
25
- const info = (0, tools_1.loadConfig)((0, node_path_1.join)(__dirname, '../../package.json'));
26
- if (!info || Object.values(info).length === 0) {
27
- process.stderr.write(`Cannot find kotori-bot package.json\n`);
28
- process.exit();
29
- }
30
- const result = packageInfoSchema.parseSafe(info);
31
- if (!result.value) {
32
- process.stderr.write(`File package.json format error: ${result.error.message}\n`);
33
- process.exit();
34
- }
35
- this.pkg = result.data;
89
+ var Config = class {
90
+ config;
91
+ pkg;
92
+ constructor(config = DEFAULT_CORE_CONFIG) {
93
+ this.config = config;
94
+ const info = (0, import_tools.loadConfig)((0, import_node_path.resolve)(__dirname, "../../package.json"));
95
+ if (!info || Object.values(info).length === 0) {
96
+ process.stderr.write(`Cannot find kotori-bot package.json
97
+ `);
98
+ process.exit();
36
99
  }
37
- }
38
- exports.Config = Config;
39
- exports.default = Config;
100
+ const result = packageInfoSchema.parseSafe(info);
101
+ if (!result.value) {
102
+ process.stderr.write(`File package.json format error: ${result.error.message}
103
+ `);
104
+ process.exit();
105
+ }
106
+ this.pkg = result.data;
107
+ }
108
+ };
109
+ var config_default = Config;
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ Config
113
+ });
@@ -19,6 +19,8 @@ declare module 'fluoro' {
19
19
  midware: Message['midware'];
20
20
  command: Message['command'];
21
21
  regexp: Message['regexp'];
22
+ notify: Message['notify'];
23
+ task: Message['task'];
22
24
  http: Http;
23
25
  i18n: I18n;
24
26
  cache: Cache;