seyfert 2.2.1-dev-13493266703.0 → 2.2.1-dev-13556253089.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,8 +1,4 @@
1
- /**
2
- * Mixes a class with other classes.
3
- * @param args The classes to mix.
4
- * @returns The mixed class.
5
- */
6
- export declare function Mixin<T, C extends TypeClass[]>(...args: C): C[number] & T;
1
+ export declare function copyProperties(target: InstanceType<TypeClass>, source: TypeClass): void;
2
+ export declare function Mixin<T, C extends TypeClass[]>(...mixins: C): C[number] & T;
7
3
  export type TypeClass<InstanceType = object, StaticType = object> = (abstract new (...args: any[]) => InstanceType) & StaticType;
8
4
  export declare const mix: (...ingredients: TypeClass[]) => (decoratedClass: any) => any;
package/lib/deps/mixer.js CHANGED
@@ -1,76 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mix = void 0;
4
+ exports.copyProperties = copyProperties;
4
5
  exports.Mixin = Mixin;
5
- /**
6
- * Gets the descriptors of a class.
7
- * @param c The class to get the descriptors of.
8
- * @returns The descriptors of the class.
9
- */
10
- function getDenoDescriptors(c) {
11
- const protos = [c.prototype];
12
- let v = c;
13
- while ((v = Object.getPrototypeOf(v))) {
14
- if (v.prototype)
15
- protos.push(v.prototype);
16
- }
17
- return protos.map(x => Object.getOwnPropertyDescriptors(x));
18
- }
19
- /**
20
- * Gets the descriptors of a class.
21
- * @param c The class to get the descriptors of.
22
- * @returns The descriptors of the class.
23
- */
24
- function getNodeDescriptors(c) {
25
- let proto = c.prototype;
26
- const result = [];
27
- while (proto) {
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
- result.push(descriptors);
33
- proto = Object.getPrototypeOf(proto);
6
+ const IgnoredProps = ['constructor', 'prototype', 'name'];
7
+ function copyProperties(target, source) {
8
+ const keys = Reflect.ownKeys(source);
9
+ for (const key of keys) {
10
+ if (IgnoredProps.includes(key))
11
+ continue;
12
+ if (key in target)
13
+ continue;
14
+ const descriptor = Object.getOwnPropertyDescriptor(source, key);
15
+ if (descriptor) {
16
+ Object.defineProperty(target, key, descriptor);
17
+ }
34
18
  }
35
- return result;
36
- }
37
- function getDescriptors(c) {
38
- //@ts-expect-error
39
- // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
40
- return typeof Deno === 'undefined' ? getNodeDescriptors(c) : getDenoDescriptors(c);
41
19
  }
42
- /**
43
- * Mixes a class with other classes.
44
- * @param args The classes to mix.
45
- * @returns The mixed class.
46
- */
47
- function Mixin(...args) {
48
- const Base = args[0];
20
+ function Mixin(...mixins) {
21
+ const Base = mixins[0];
49
22
  class MixedClass extends Base {
50
- constructor(...constructorArgs) {
51
- super(...constructorArgs);
52
- for (const mixin of args.slice(1)) {
53
- const descriptors = getDescriptors(mixin).reverse();
54
- for (const desc of descriptors) {
55
- // @ts-expect-error
56
- Object.assign(this, new desc.constructor.value(...constructorArgs));
57
- for (const key in desc) {
58
- if (key === 'constructor')
59
- continue;
60
- if (key in MixedClass.prototype)
61
- continue;
62
- const descriptor = desc[key];
63
- if (descriptor.value) {
64
- // @ts-expect-error
65
- MixedClass.prototype[key] = descriptor.value;
66
- }
67
- else if (descriptor.get || descriptor.set) {
68
- Object.defineProperty(MixedClass.prototype, key, {
69
- get: descriptor.get,
70
- set: descriptor.set,
71
- });
72
- }
73
- }
23
+ constructor(...args) {
24
+ super(...args);
25
+ for (const mixin of mixins.slice(1)) {
26
+ // @ts-expect-error
27
+ const mixinInstance = new mixin(...args);
28
+ copyProperties(this, mixinInstance);
29
+ let proto = Object.getPrototypeOf(mixinInstance);
30
+ while (proto && proto !== Object.prototype) {
31
+ copyProperties(this, proto);
32
+ proto = Object.getPrototypeOf(proto);
74
33
  }
75
34
  }
76
35
  }
@@ -1,6 +1,6 @@
1
1
  import type { UsingClient } from '../../commands';
2
2
  /** */
3
- export declare abstract class Base {
3
+ export declare class Base {
4
4
  constructor(client: UsingClient);
5
5
  readonly client: UsingClient;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.2.1-dev-13493266703.0",
3
+ "version": "2.2.1-dev-13556253089.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",