seyfert 2.2.1-dev-13340711253.0 → 2.2.1-dev-13377648432.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.
@@ -261,17 +261,7 @@ exports.ReplaceRegex = {
261
261
  },
262
262
  };
263
263
  async function magicImport(path) {
264
- try {
265
- if ('Deno' in globalThis)
266
- throw new Error('https://github.com/denoland/deno/issues/26136');
267
- return require(path);
268
- }
269
- catch (e) {
270
- // (bun)dows moment
271
- if (!('Bun' in globalThis) || e.message.includes('is unsupported. use "await import()" instead.'))
272
- return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path.split('\\').join('\\\\'));
273
- throw new Error(`Cannot import ${path}`, { cause: e });
274
- }
264
+ return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path);
275
265
  }
276
266
  function fakePromise(value) {
277
267
  if (value instanceof Promise)
@@ -15,10 +15,7 @@ export declare class LangsHandler extends BaseHandler {
15
15
  load(dir: string): Promise<void>;
16
16
  parse(file: LangInstance): void;
17
17
  set(instances: LangInstance[]): void;
18
- reload(lang: string): Promise<false | {
19
- file: Record<string, any>;
20
- locale: string;
21
- } | null>;
18
+ reload(lang: string): Promise<Record<string, any> | null>;
22
19
  reloadAll(stopIfFail?: boolean): Promise<void>;
23
20
  onFile(locale: string, { file }: LangInstance): {
24
21
  file: Record<string, any>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LangsHandler = void 0;
4
+ const node_path_1 = require("node:path");
4
5
  const common_1 = require("../common");
5
6
  const router_1 = require("./router");
6
7
  class LangsHandler extends common_1.BaseHandler {
@@ -55,11 +56,18 @@ class LangsHandler extends common_1.BaseHandler {
55
56
  if ((0, common_1.isCloudfareWorker)()) {
56
57
  throw new Error('Reload in cloudfare worker is not supported');
57
58
  }
58
- const value = this.__paths[lang];
59
+ const path = this.__paths[lang];
60
+ if (!path)
61
+ return null;
62
+ delete require.cache[path];
63
+ const value = await (0, common_1.magicImport)(path).then(x => this.onFile(lang, {
64
+ file: x,
65
+ name: (0, node_path_1.basename)(path),
66
+ path,
67
+ }));
59
68
  if (!value)
60
69
  return null;
61
- delete require.cache[value];
62
- return (this.values[lang] = await (0, common_1.magicImport)(value).then(x => this.onFile(lang, x)));
70
+ return (this.values[lang] = value.file);
63
71
  }
64
72
  async reloadAll(stopIfFail = true) {
65
73
  for (const i in this.__paths) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.2.1-dev-13340711253.0",
3
+ "version": "2.2.1-dev-13377648432.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",