@kotori-bot/loader 1.5.1 → 1.6.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.
@@ -1,11 +1,13 @@
1
1
  import { Context, LocaleType, ModuleConfig, Symbols } from '@kotori-bot/core';
2
2
  import { BUILD_MODE, DEV_MODE, DEV_SOURCE_MODE } from '../constants';
3
+ import '../types/internal';
3
4
  import './loader';
4
5
  interface BaseDir {
5
6
  root: string;
6
7
  modules: string;
7
8
  data: string;
8
9
  logs: string;
10
+ config: string;
9
11
  }
10
12
  interface Options {
11
13
  mode: typeof BUILD_MODE | typeof DEV_MODE | typeof DEV_SOURCE_MODE;
@@ -1,234 +1,325 @@
1
+
2
+ /**
3
+ * @Package @kotori-bot/loader
4
+ * @Version 1.6.0-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:54
10
+ */
11
+
1
12
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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 });
22
+ };
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;
24
30
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
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/class/runner.ts
42
+ var runner_exports = {};
43
+ __export(runner_exports, {
44
+ Runner: () => Runner,
45
+ default: () => runner_default,
46
+ localeTypeSchema: () => localeTypeSchema
47
+ });
48
+ module.exports = __toCommonJS(runner_exports);
49
+ var import_node_fs2 = __toESM(require("fs"));
50
+ var import_node_path3 = __toESM(require("path"));
51
+ var import_core4 = require("@kotori-bot/core");
52
+ var import_logger3 = require("@kotori-bot/logger");
53
+
54
+ // src/constants.ts
55
+ var DEV_FILE = ".ts";
56
+ var BUILD_FILE = ".js";
57
+ var DEV_CODE_DIRS = "./src/";
58
+ var DEV_IMPORT = `${DEV_CODE_DIRS}index.ts`;
59
+ var DEV_MODE = "dev";
60
+ var DEV_SOURCE_MODE = "dev-source";
61
+ var CORE_MODULES = [
62
+ "@kotori-bot/kotori-plugin-core",
63
+ "@kotori-bot/kotori-plugin-i18n-command",
64
+ "@kotori-bot/kotori-plugin-filter"
65
+ // '@kotori-bot/kotori-plugin-webui'
66
+ ];
67
+
68
+ // src/utils/logger.ts
69
+ var import_logger = require("@kotori-bot/logger");
70
+ var KotoriLogger = class extends import_logger.Logger {
71
+ constructor(optionsSelf, ctx) {
72
+ super(optionsSelf);
73
+ this.optionsSelf = optionsSelf;
74
+ this.ctx = ctx;
75
+ }
76
+ setLabel() {
77
+ const origin = Object.create(this.optionsSelf.label);
78
+ const label = this.ctx.identity ? [this.ctx.identity, ...this.optionsSelf.label] : this.optionsSelf.label;
79
+ this[/* @__PURE__ */ (() => "options")()].label = label;
80
+ return () => {
81
+ this[/* @__PURE__ */ (() => "options")()].label = origin;
82
+ };
83
+ }
84
+ fatal(...args) {
85
+ const dispose = this.setLabel();
86
+ super.fatal(...args);
87
+ dispose();
88
+ }
89
+ error(...args) {
90
+ const dispose = this.setLabel();
91
+ super.error(...args);
92
+ dispose();
93
+ }
94
+ warn(...args) {
95
+ const dispose = this.setLabel();
96
+ super.warn(...args);
97
+ dispose();
98
+ }
99
+ info(...args) {
100
+ const dispose = this.setLabel();
101
+ super.info(...args);
102
+ dispose();
103
+ }
104
+ record(...args) {
105
+ const dispose = this.setLabel();
106
+ super.record(...args);
107
+ dispose();
108
+ }
109
+ debug(...args) {
110
+ const dispose = this.setLabel();
111
+ super.debug(...args);
112
+ dispose();
113
+ }
114
+ trace(...args) {
115
+ const dispose = this.setLabel();
116
+ super.trace(...args);
117
+ dispose();
118
+ }
27
119
  };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Runner = exports.localeTypeSchema = void 0;
30
- const node_fs_1 = __importStar(require("node:fs"));
31
- const node_path_1 = __importStar(require("node:path"));
32
- const core_1 = require("@kotori-bot/core");
33
- const logger_1 = require("@kotori-bot/logger");
34
- const constants_1 = require("../constants");
35
- const logger_2 = __importDefault(require("../utils/logger"));
36
- require("./loader");
37
- exports.localeTypeSchema = core_1.Tsu.Union([
38
- core_1.Tsu.Union([core_1.Tsu.Literal('en_US'), core_1.Tsu.Literal('ja_JP')]),
39
- core_1.Tsu.Union([core_1.Tsu.Literal('zh_TW'), core_1.Tsu.Any()])
120
+ var logger_default = KotoriLogger;
121
+
122
+ // src/class/loader.ts
123
+ var import_core3 = require("@kotori-bot/core");
124
+ var import_node_path2 = __toESM(require("path"));
125
+ var import_node_fs = __toESM(require("fs"));
126
+ var import_logger2 = __toESM(require("@kotori-bot/logger"));
127
+
128
+ // src/service/server.ts
129
+ var import_core = require("@kotori-bot/core");
130
+ var import_node_http = require("http");
131
+ var import_path_to_regexp = require("path-to-regexp");
132
+ var import_express = __toESM(require("express"));
133
+ var import_ws = __toESM(require("ws"));
134
+
135
+ // src/service/file.ts
136
+ var import_core2 = require("@kotori-bot/core");
137
+ var import_node_path = require("path");
138
+
139
+ // src/class/runner.ts
140
+ var localeTypeSchema = import_core4.Tsu.Union([
141
+ import_core4.Tsu.Union([import_core4.Tsu.Literal("en_US"), import_core4.Tsu.Literal("ja_JP")]),
142
+ import_core4.Tsu.Union([import_core4.Tsu.Literal("zh_TW"), import_core4.Tsu.Any()])
40
143
  ]);
41
- const modulePackageSchema = core_1.Tsu.Object({
42
- name: core_1.Tsu.String().regexp(/kotori-plugin-[a-z]([a-z,0-9]{2,13})\b/),
43
- version: core_1.Tsu.String(),
44
- description: core_1.Tsu.String(),
45
- main: core_1.Tsu.String(),
46
- license: core_1.Tsu.Literal('GPL-3.0'),
47
- keywords: core_1.Tsu.Custom((val) => Array.isArray(val) && val.includes('kotori') && val.includes('chatbot') && val.includes('kotori-plugin')),
48
- author: core_1.Tsu.Union([core_1.Tsu.String(), core_1.Tsu.Array(core_1.Tsu.String())]),
49
- peerDependencies: core_1.Tsu.Object({
50
- 'kotori-bot': core_1.Tsu.String()
51
- }),
52
- kotori: core_1.Tsu.Object({
53
- enforce: core_1.Tsu.Union([core_1.Tsu.Literal('pre'), core_1.Tsu.Literal('post')]).optional(),
54
- meta: core_1.Tsu.Object({
55
- language: core_1.Tsu.Array(exports.localeTypeSchema).default([])
56
- }).default({ language: [] })
57
- }).default({
58
- enforce: undefined,
59
- meta: { language: [] }
60
- })
144
+ var modulePackageSchema = import_core4.Tsu.Object({
145
+ name: import_core4.Tsu.String().regexp(/kotori-plugin-[a-z]([a-z,0-9]{2,13})\b/),
146
+ version: import_core4.Tsu.String(),
147
+ description: import_core4.Tsu.String(),
148
+ main: import_core4.Tsu.String(),
149
+ license: import_core4.Tsu.Literal("GPL-3.0"),
150
+ keywords: import_core4.Tsu.Custom(
151
+ (val) => Array.isArray(val) && val.includes("kotori") && val.includes("chatbot") && val.includes("kotori-plugin")
152
+ ),
153
+ author: import_core4.Tsu.Union([import_core4.Tsu.String(), import_core4.Tsu.Array(import_core4.Tsu.String())]),
154
+ peerDependencies: import_core4.Tsu.Object({
155
+ "kotori-bot": import_core4.Tsu.String()
156
+ }),
157
+ kotori: import_core4.Tsu.Object({
158
+ enforce: import_core4.Tsu.Union([import_core4.Tsu.Literal("pre"), import_core4.Tsu.Literal("post")]).optional(),
159
+ meta: import_core4.Tsu.Object({
160
+ language: import_core4.Tsu.Array(localeTypeSchema).default([])
161
+ }).default({ language: [] })
162
+ }).default({
163
+ enforce: void 0,
164
+ meta: { language: [] }
165
+ })
61
166
  });
62
167
  function moduleLoadOrder(pkg) {
63
- if (pkg.name.includes(core_1.DATABASE_PREFIX))
64
- return 1;
65
- if (pkg.name.includes(core_1.ADAPTER_PREFIX))
66
- return 2;
67
- // if (CORE_MODULES.includes(pkg.name)) return 3;
68
- if (pkg.kotori.enforce === 'pre')
69
- return 4;
70
- if (!pkg.kotori.enforce)
71
- return 5;
72
- return 6;
168
+ if (CORE_MODULES.includes(pkg.name)) return 1;
169
+ if (pkg.name.includes(import_core4.DATABASE_PREFIX)) return 2;
170
+ if (pkg.name.includes(import_core4.ADAPTER_PREFIX)) return 3;
171
+ if (pkg.kotori.enforce === "pre") return 4;
172
+ if (!pkg.kotori.enforce) return 5;
173
+ return 6;
73
174
  }
74
- class Runner {
75
- baseDir;
76
- options;
77
- ctx;
78
- isDev;
79
- isSourceDev;
80
- [core_1.Symbols.modules] = new Map();
81
- constructor(ctx, config) {
82
- this.ctx = ctx;
83
- /* handle config */
84
- this.baseDir = config.baseDir;
85
- this.options = config.options;
86
- this.isDev = this.options.mode.startsWith(constants_1.DEV_MODE);
87
- this.isSourceDev = this.options.mode === constants_1.DEV_SOURCE_MODE;
88
- const loggerOptions = {
89
- level: this.ctx.config.global.level ?? config.level,
90
- label: [],
91
- transports: [
92
- new logger_1.ConsoleTransport(),
93
- new logger_1.FileTransport({ dir: this.baseDir.logs, filter: (data) => data.level >= logger_1.LoggerLevel.WARN })
94
- ]
95
- };
96
- ctx.provide('logger', new logger_2.default(loggerOptions, this.ctx));
97
- ctx.inject('logger');
98
- }
99
- getDirFiles(rootDir) {
100
- const files = node_fs_1.default.readdirSync(rootDir);
101
- const list = [];
102
- files.forEach((fileName) => {
103
- const file = node_path_1.default.join(rootDir, fileName);
104
- if (node_fs_1.default.statSync(file).isDirectory()) {
105
- list.push(...this.getDirFiles(file));
106
- }
107
- if (node_path_1.default.parse(file).ext !== (this.isSourceDev ? constants_1.DEV_FILE : constants_1.BUILD_FILE))
108
- return;
109
- list.push(node_path_1.default.resolve(file));
110
- });
111
- return list;
112
- }
113
- getModuleRootDir() {
114
- const moduleRootDir = [];
115
- [
116
- ...this.ctx.config.global.dirs.map((dir) => node_path_1.default.resolve(this.ctx.baseDir.root, dir)),
117
- this.ctx.baseDir.modules
118
- ].forEach((dir) => {
119
- if (node_fs_1.default.existsSync(dir) && node_fs_1.default.statSync(dir).isDirectory())
120
- moduleRootDir.push(dir);
121
- });
122
- return moduleRootDir;
175
+ var Runner = class {
176
+ baseDir;
177
+ options;
178
+ ctx;
179
+ isDev;
180
+ isSourceDev;
181
+ [import_core4.Symbols.modules] = /* @__PURE__ */ new Map();
182
+ constructor(ctx, config) {
183
+ this.ctx = ctx;
184
+ this.baseDir = config.baseDir;
185
+ this.options = config.options;
186
+ this.isDev = this.options.mode.startsWith(DEV_MODE);
187
+ this.isSourceDev = this.options.mode === DEV_SOURCE_MODE;
188
+ const loggerOptions = {
189
+ level: this.ctx.config.global.level ?? config.level,
190
+ label: [],
191
+ transports: [
192
+ new import_logger3.ConsoleTransport({
193
+ template: "<blue>%time%</blue> %level% (<bold>%pid%</bold>) %labels%: %msg%",
194
+ time: "M/D H:m:s"
195
+ }),
196
+ new import_logger3.FileTransport({ dir: this.baseDir.logs, filter: (data) => data.level >= import_logger3.LoggerLevel.WARN })
197
+ ]
198
+ };
199
+ ctx.provide("logger", new logger_default(loggerOptions, this.ctx));
200
+ ctx.inject("logger");
201
+ }
202
+ getDirFiles(rootDir) {
203
+ const files = import_node_fs2.default.readdirSync(rootDir);
204
+ const list = [];
205
+ files.forEach((fileName) => {
206
+ const file = import_node_path3.default.join(rootDir, fileName);
207
+ if (import_node_fs2.default.statSync(file).isDirectory()) {
208
+ list.push(...this.getDirFiles(file));
209
+ }
210
+ if (import_node_path3.default.parse(file).ext !== (this.isSourceDev ? DEV_FILE : BUILD_FILE)) return;
211
+ list.push(import_node_path3.default.resolve(file));
212
+ });
213
+ return list;
214
+ }
215
+ getModuleRootDir() {
216
+ const moduleRootDir = [];
217
+ [
218
+ ...this.ctx.config.global.dirs.map((dir) => import_node_path3.default.resolve(this.ctx.baseDir.root, dir)),
219
+ this.ctx.baseDir.modules
220
+ ].forEach((dir) => {
221
+ if (import_node_fs2.default.existsSync(dir) && import_node_fs2.default.statSync(dir).isDirectory()) moduleRootDir.push(dir);
222
+ });
223
+ return moduleRootDir;
224
+ }
225
+ async checkModuleFiles(rootDir, filename) {
226
+ const dir = import_node_path3.default.join(rootDir, filename);
227
+ if (!import_node_fs2.default.statSync(dir).isDirectory()) return;
228
+ if (rootDir !== this.ctx.baseDir.modules && !filename.startsWith(import_core4.PLUGIN_PREFIX)) return;
229
+ const packagePath = import_node_path3.default.join(dir, "package.json");
230
+ let pkg;
231
+ if (!import_node_fs2.default.existsSync(packagePath)) return;
232
+ try {
233
+ pkg = JSON.parse(import_node_fs2.default.readFileSync(packagePath).toString());
234
+ } catch {
235
+ throw new import_core4.DevError(this.ctx.format("error.dev.package.illegal", [packagePath]));
123
236
  }
124
- async checkModuleFiles(rootDir, filename) {
125
- const dir = node_path_1.default.join(rootDir, filename);
126
- if (!node_fs_1.default.statSync(dir).isDirectory())
127
- return;
128
- if (rootDir !== this.ctx.baseDir.modules && !filename.startsWith(core_1.PLUGIN_PREFIX))
129
- return;
130
- const packagePath = node_path_1.default.join(dir, 'package.json');
131
- let pkg;
132
- if (!node_fs_1.default.existsSync(packagePath))
133
- return;
134
- try {
135
- pkg = JSON.parse(node_fs_1.default.readFileSync(packagePath).toString());
136
- }
137
- catch {
138
- throw new core_1.DevError(this.ctx.format('error.dev.package.illegal', [packagePath]));
139
- }
140
- const result = modulePackageSchema.parseSafe(pkg);
141
- if (!result.value) {
142
- if (rootDir !== this.ctx.baseDir.modules)
143
- return;
144
- throw new core_1.DevError(this.ctx.format('error.dev.package.missing', [packagePath, result.error.message]));
145
- }
146
- pkg = result.data;
147
- const devMode = this.isSourceDev && (0, node_fs_1.existsSync)(node_path_1.default.resolve(dir, constants_1.DEV_IMPORT));
148
- const main = node_path_1.default.resolve(dir, devMode ? constants_1.DEV_IMPORT : pkg.main);
149
- if (!node_fs_1.default.existsSync(main))
150
- throw new core_1.DevError(this.ctx.format('error.dev.main_file', [main]));
151
- const dirs = node_path_1.default.join(dir, devMode ? constants_1.DEV_CODE_DIRS : node_path_1.default.dirname(pkg.main));
152
- const files = node_fs_1.default.statSync(dirs).isDirectory() ? this.getDirFiles(dirs) : [];
153
- this[core_1.Symbols.modules].set(pkg.name, [
154
- { pkg, files, main },
155
- this.ctx.config.plugin[(0, core_1.stringRightSplit)(pkg.name, core_1.PLUGIN_PREFIX)] || {}
156
- ]);
237
+ const result = modulePackageSchema.parseSafe(pkg);
238
+ if (!result.value) {
239
+ if (rootDir !== this.ctx.baseDir.modules) return;
240
+ throw new import_core4.DevError(this.ctx.format("error.dev.package.missing", [packagePath, result.error.message]));
157
241
  }
158
- getModuleList(rootDir) {
159
- this.ctx.logger.trace('load dirs:', rootDir);
160
- node_fs_1.default.readdirSync(rootDir).forEach(async (filename) => {
161
- await this.checkModuleFiles(rootDir, filename);
162
- });
242
+ pkg = result.data;
243
+ const devMode = this.isSourceDev && (0, import_node_fs2.existsSync)(import_node_path3.default.resolve(dir, DEV_IMPORT));
244
+ const main = import_node_path3.default.resolve(dir, devMode ? DEV_IMPORT : pkg.main);
245
+ if (!import_node_fs2.default.existsSync(main)) throw new import_core4.DevError(this.ctx.format("error.dev.main_file", [main]));
246
+ const dirs = import_node_path3.default.join(dir, devMode ? DEV_CODE_DIRS : import_node_path3.default.dirname(pkg.main));
247
+ const files = import_node_fs2.default.statSync(dirs).isDirectory() ? this.getDirFiles(dirs) : [];
248
+ this[import_core4.Symbols.modules].set(pkg.name, [
249
+ { pkg, files, main },
250
+ this.ctx.config.plugin[(0, import_core4.stringRightSplit)(pkg.name, import_core4.PLUGIN_PREFIX)] || {}
251
+ ]);
252
+ }
253
+ getModuleList(rootDir) {
254
+ this.ctx.logger.trace("load dirs:", rootDir);
255
+ import_node_fs2.default.readdirSync(rootDir).forEach(async (filename) => {
256
+ await this.checkModuleFiles(rootDir, filename);
257
+ });
258
+ }
259
+ loadLang(lang) {
260
+ if (lang) this.ctx.i18n.use((0, import_node_path3.resolve)(...Array.isArray(lang) ? lang : [lang]));
261
+ }
262
+ loadEx(instance, origin) {
263
+ this.ctx.logger.trace("module:", instance, origin);
264
+ if (!instance.main) return;
265
+ const parsed = (schema) => {
266
+ const result = schema.parseSafe(config);
267
+ if (!result.value)
268
+ throw new import_core4.ModuleError(this.ctx.format("error.module.config", [pkg.name, result.error.message]));
269
+ return result.data;
270
+ };
271
+ const { main, pkg } = instance;
272
+ let obj = require(main);
273
+ let config = origin;
274
+ const adapterName = pkg.name.split(import_core4.ADAPTER_PREFIX)[1];
275
+ if (this.ctx.get("decorators")?.registers.includes(pkg.name)) {
276
+ this.ctx.emit("ready_module_decorators", pkg.name);
277
+ return;
163
278
  }
164
- loadLang(lang) {
165
- if (lang)
166
- this.ctx.i18n.use((0, node_path_1.resolve)(...(Array.isArray(lang) ? lang : [lang])));
279
+ if (import_core4.Adapter.isPrototypeOf.call(import_core4.Adapter, obj.default) && adapterName && (!obj.config || obj.config instanceof import_core4.Parser)) {
280
+ this.ctx[import_core4.Symbols.adapter].set(adapterName, [obj.default, obj.config]);
281
+ obj = {};
282
+ } else if (import_core4.Service.isPrototypeOf.call(import_core4.Service, obj.default)) {
283
+ obj = {};
284
+ } else if (obj.config instanceof import_core4.Parser) {
285
+ config = parsed(obj.config);
167
286
  }
168
- loadEx(instance, origin) {
169
- this.ctx.logger.trace('module:', instance, origin);
170
- const parsed = (schema) => {
171
- const result = schema.parseSafe(config);
172
- if (!result.value)
173
- throw new core_1.ModuleError(this.ctx.format('error.module.config', [pkg.name, result.error.message]));
174
- return result.data;
175
- };
176
- const { main, pkg } = instance;
177
- /* eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires */
178
- let obj = require(main);
179
- let config = origin;
180
- const adapterName = pkg.name.split(core_1.ADAPTER_PREFIX)[1];
181
- if (core_1.Adapter.isPrototypeOf.call(core_1.Adapter, obj.default) &&
182
- adapterName &&
183
- (!obj.config || obj.config instanceof core_1.Parser)) {
184
- /* Adapter Class */
185
- this.ctx[core_1.Symbols.adapter].set(adapterName, [obj.default, obj.config]);
186
- obj = {};
187
- }
188
- else if (core_1.Service.isPrototypeOf.call(core_1.Service, obj.default)) {
189
- /* Service Class */
190
- obj = {};
191
- }
192
- else if (obj.config instanceof core_1.Parser) {
193
- config = parsed(obj.config);
194
- }
195
- if (obj.lang)
196
- this.loadLang(obj.lang);
197
- if (obj.default) {
198
- if (obj.default.lang)
199
- this.loadLang(obj.default.lang);
200
- if (obj.default.config instanceof core_1.Parser)
201
- config = parsed(obj.default.config);
202
- }
203
- else if (obj.Main) {
204
- if (obj.Main.lang)
205
- this.loadLang(obj.Main.lang);
206
- if (obj.Main.config instanceof core_1.Parser)
207
- config = parsed(obj.Main.config);
208
- }
209
- this.ctx.load({ name: pkg.name, ...obj, config });
287
+ if (obj.lang) this.loadLang(obj.lang);
288
+ if (obj.default) {
289
+ if (obj.default.lang) this.loadLang(obj.default.lang);
290
+ if (obj.default.config instanceof import_core4.Parser) config = parsed(obj.default.config);
291
+ } else if (obj.Main) {
292
+ if (obj.Main.lang) this.loadLang(obj.Main.lang);
293
+ if (obj.Main.config instanceof import_core4.Parser) config = parsed(obj.Main.config);
210
294
  }
211
- unloadEx(instance) {
212
- instance.files.forEach((file) => delete require.cache[require.resolve(file)]);
213
- this.ctx.load({ name: instance.pkg.name });
214
- }
215
- loadAll() {
216
- this.getModuleRootDir().forEach((dir) => this.getModuleList(dir));
217
- const modules = [];
218
- this[core_1.Symbols.modules].forEach((val) => modules.push(val));
219
- modules
220
- .sort((el1, el2) => moduleLoadOrder(el1[0].pkg) - moduleLoadOrder(el2[0].pkg))
221
- .forEach((el) => this.loadEx(...el));
222
- if (this.isDev)
223
- this.watcher();
224
- }
225
- watcher() {
226
- this[core_1.Symbols.modules].forEach((data) => data[0].files.forEach((file) => node_fs_1.default.watchFile(file, async () => {
227
- this.ctx.logger.debug(this.ctx.format('loader.debug.reload', [data[0].pkg.name]));
228
- this.unloadEx(data[0]);
229
- this.loadEx(...data);
230
- })));
231
- }
232
- }
233
- exports.Runner = Runner;
234
- exports.default = Runner;
295
+ this.ctx.load({ name: pkg.name, ...obj, config });
296
+ }
297
+ unloadEx(instance) {
298
+ instance.files.forEach((file) => delete require.cache[require.resolve(file)]);
299
+ this.ctx.load({ name: instance.pkg.name });
300
+ }
301
+ loadAll() {
302
+ this.getModuleRootDir().forEach((dir) => this.getModuleList(dir));
303
+ const modules = [];
304
+ this[import_core4.Symbols.modules].forEach((val) => modules.push(val));
305
+ modules.sort(([{ pkg: pkg1 }], [{ pkg: pkg2 }]) => moduleLoadOrder(pkg1) - moduleLoadOrder(pkg2)).forEach((el) => this.loadEx(...el));
306
+ if (this.isDev) this.watcher();
307
+ }
308
+ watcher() {
309
+ this[import_core4.Symbols.modules].forEach(
310
+ (data) => data[0].files.forEach(
311
+ (file) => import_node_fs2.default.watchFile(file, async () => {
312
+ this.ctx.logger.debug(this.ctx.format("loader.debug.reload", [data[0].pkg.name]));
313
+ this.unloadEx(data[0]);
314
+ this.loadEx(...data);
315
+ })
316
+ )
317
+ );
318
+ }
319
+ };
320
+ var runner_default = Runner;
321
+ // Annotate the CommonJS export names for ESM import in node:
322
+ 0 && (module.exports = {
323
+ Runner,
324
+ localeTypeSchema
325
+ });
@@ -2,10 +2,12 @@ export declare const DEV_FILE = ".ts";
2
2
  export declare const BUILD_FILE = ".js";
3
3
  export declare const DEV_CODE_DIRS = "./src/";
4
4
  export declare const DEV_IMPORT = "./src/index.ts";
5
- export declare const BUILD_CONFIG_NAME = "kotori.yml";
6
- export declare const DEV_CONFIG_NAME = "kotori.dev.yml";
5
+ export declare const CONFIG_EXT: string[];
6
+ export declare const BUILD_CONFIG_NAME = "kotori";
7
+ export declare const DEV_CONFIG_NAME = "kotori.dev";
7
8
  export declare const SUPPORTS_VERSION: RegExp;
8
9
  export declare const SUPPORTS_HALF_VERSION: RegExp;
9
10
  export declare const BUILD_MODE: "build";
10
11
  export declare const DEV_MODE: "dev";
11
12
  export declare const DEV_SOURCE_MODE: "dev-source";
13
+ export declare const CORE_MODULES: string[];