seyfert 2.2.1-dev-12970267967.0 → 2.2.1-dev-13217777411.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/deps/mixer.js CHANGED
@@ -26,11 +26,8 @@ function getNodeDescriptors(c) {
26
26
  const result = [];
27
27
  while (proto) {
28
28
  const descriptors = Object.getOwnPropertyDescriptors(proto);
29
- // @ts-expect-error this is not a function in all cases
30
- if (descriptors.valueOf.configurable)
31
- break;
32
29
  result.push(descriptors);
33
- proto = proto.__proto__;
30
+ proto = Object.getPrototypeOf(proto);
34
31
  }
35
32
  return result;
36
33
  }
@@ -45,32 +42,29 @@ function getDescriptors(c) {
45
42
  * @returns The mixed class.
46
43
  */
47
44
  function Mixin(...args) {
48
- const ignoreOverwriteToString = Object.keys(Object.getOwnPropertyDescriptors(args[0].prototype)).includes('toString');
49
- function MixedClass(...constructorArgs) {
50
- for (const i of args) {
51
- const descriptors = getDescriptors(i).reverse();
52
- for (const j of descriptors) {
53
- // @ts-expect-error
54
- Object.assign(this, new j.constructor.value(...constructorArgs));
55
- for (const descriptorK in j) {
56
- if (descriptorK === 'constructor')
57
- continue;
58
- if (descriptorK in MixedClass.prototype && descriptorK !== 'toString')
59
- continue;
60
- const descriptor = j[descriptorK];
61
- if (descriptor.value) {
62
- if (descriptorK === 'toString' && ignoreOverwriteToString) {
63
- MixedClass.prototype[descriptorK] = args[0].prototype.toString;
45
+ const Base = args[0];
46
+ class MixedClass extends Base {
47
+ constructor(...constructorArgs) {
48
+ super(...constructorArgs);
49
+ for (const mixin of args.slice(1)) {
50
+ const descriptors = getDescriptors(mixin).reverse();
51
+ for (const desc of descriptors) {
52
+ for (const key in desc) {
53
+ if (key === 'constructor')
64
54
  continue;
55
+ if (key in mixin.prototype)
56
+ continue;
57
+ const descriptor = desc[key];
58
+ if (descriptor.value) {
59
+ // @ts-expect-error
60
+ MixedClass.prototype[key] = descriptor.value;
61
+ }
62
+ else if (descriptor.get || descriptor.set) {
63
+ Object.defineProperty(MixedClass.prototype, key, {
64
+ get: descriptor.get,
65
+ set: descriptor.set,
66
+ });
65
67
  }
66
- MixedClass.prototype[descriptorK] = descriptor.value;
67
- continue;
68
- }
69
- if (descriptor.get || descriptor.set) {
70
- Object.defineProperty(MixedClass.prototype, descriptorK, {
71
- get: descriptor.get,
72
- set: descriptor.set,
73
- });
74
68
  }
75
69
  }
76
70
  }
@@ -13,13 +13,20 @@ export declare class LangsHandler extends BaseHandler {
13
13
  get(locale?: string): import("..").DefaultLocale;
14
14
  };
15
15
  load(dir: string): Promise<void>;
16
- parse(file: EventInstance): void;
17
- set(instances: EventInstance[]): void;
18
- reload(lang: string): Promise<false | Record<string, any> | null>;
16
+ parse(file: LangInstance): void;
17
+ set(instances: LangInstance[]): void;
18
+ reload(lang: string): Promise<false | {
19
+ file: Record<string, any>;
20
+ locale: string;
21
+ } | null>;
19
22
  reloadAll(stopIfFail?: boolean): Promise<void>;
20
- onFile(_locale: string, file: FileLoaded<Record<string, any>>): Record<string, any> | false;
23
+ onFile(locale: string, file: FileLoaded<Record<string, any>>): {
24
+ file: Record<string, any>;
25
+ locale: string;
26
+ } | false;
21
27
  }
22
- export type EventInstance = {
28
+ export type LangInstance = {
23
29
  name: string;
24
30
  file: Record<string, any>;
31
+ path: string;
25
32
  };
@@ -38,12 +38,13 @@ class LangsHandler extends common_1.BaseHandler {
38
38
  }
39
39
  }
40
40
  parse(file) {
41
- const locale = file.name.split('.').slice(0, -1).join('.') || file.name;
42
- const result = this.onFile(locale, file.file);
41
+ const oldLocale = file.name.split('.').slice(0, -1).join('.') || file.name;
42
+ const result = this.onFile(oldLocale, file.file);
43
+ if (!result)
44
+ return;
43
45
  if ('path' in file)
44
- this.__paths[locale] = file.path;
45
- if (result)
46
- this.values[locale] = result;
46
+ this.__paths[result.locale] = file.path;
47
+ this.values[result.locale] = result.file;
47
48
  }
48
49
  set(instances) {
49
50
  for (const i of instances) {
@@ -71,8 +72,13 @@ class LangsHandler extends common_1.BaseHandler {
71
72
  }
72
73
  }
73
74
  }
74
- onFile(_locale, file) {
75
- return file.default ?? false;
75
+ onFile(locale, file) {
76
+ return file.default
77
+ ? {
78
+ file: file.default,
79
+ locale,
80
+ }
81
+ : false;
76
82
  }
77
83
  }
78
84
  exports.LangsHandler = LangsHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.2.1-dev-12970267967.0",
3
+ "version": "2.2.1-dev-13217777411.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",