feat: init

This commit is contained in:
Nick 2024-08-10 02:59:22 -05:00
parent 8379d09058
commit 2cfa016090
2929 changed files with 299087 additions and 3 deletions

120
node_modules/ts-mixer/CHANGELOG.md generated vendored Normal file
View file

@ -0,0 +1,120 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [6.0.4](https://github.com/tannerntannern/ts-mixer/compare/v6.0.3...v6.0.4) (2024-02-20)
### Bug Fixes
* weakmap in mixing tracking ([acd28db](https://github.com/tannerntannern/ts-mixer/commit/acd28dbe96f18557b05f7f86312ed109d3098b98))
### [6.0.3](https://github.com/tannerntannern/ts-mixer/compare/v6.0.2...v6.0.3) (2023-02-09)
### Bug Fixes
* allow abstract constructor signature for hasMixin ([f82e27b](https://github.com/tannerntannern/ts-mixer/commit/f82e27b96d142cfdec6446930a1db354167e88d2)), closes [tannerntannern/ts-mixer#56](https://github.com/tannerntannern/ts-mixer/issues/56)
* allow abstract constructor signatures for hasMixin ([8964b59](https://github.com/tannerntannern/ts-mixer/commit/8964b59e062854fde52424497930ca3e8bb98e87)), closes [#57](https://github.com/tannerntannern/ts-mixer/issues/57)
* simplify signature ([8a79197](https://github.com/tannerntannern/ts-mixer/commit/8a79197cc6bca5757d7c06560d7b26e73491b11f))
### [6.0.2](https://github.com/tannerntannern/ts-mixer/compare/v6.0.1...v6.0.2) (2022-11-10)
### Bug Fixes
* **decorators:** support class decorators that don't return anything ([7433cf3](https://github.com/tannerntannern/ts-mixer/commit/7433cf36a43bb18a1dd280aa629ac81ef532c74a))
### [6.0.1](https://github.com/tannerntannern/ts-mixer/compare/v6.0.0...v6.0.1) (2022-03-13)
### Bug Fixes
* fix bug in `directDecoratorSearch` ([51c50b8](https://github.com/tannerntannern/ts-mixer/commit/51c50b8c50a63e85b133bdd61eaad4427a22e515)) (thanks, [@AMcBain](https://github.com/AMcBain)!)
## [6.0.0](https://github.com/tannerntannern/ts-mixer/compare/v6.0.0-beta.0...v6.0.0) (2021-07-07)
## [6.0.0-beta.0](https://github.com/tannerntannern/ts-mixer/compare/v5.4.1...v6.0.0-beta.0) (2021-06-24)
### ⚠ BREAKING CHANGES
* drop TS < 4.2 support
### Features
* add abstract mixin support ([1c4b306](https://github.com/tannerntannern/ts-mixer/commit/1c4b306bae62fa6319c74d1f3040c8aba0da2c28))
### [5.4.1](https://github.com/tannerntannern/ts-mixer/compare/v5.4.0...v5.4.1) (2021-04-30)
### Bug Fixes
* "publish" workflow ([bd2e4ec](https://github.com/tannerntannern/ts-mixer/commit/bd2e4ec088b19a403bc013926c7f3a2545cc4171))
* circular dependency ([66f7e2d](https://github.com/tannerntannern/ts-mixer/commit/66f7e2dc929c90e8c15d718415114ceaa31402c2))
## [5.4.0](https://github.com/tannerntannern/ts-mixer/compare/v5.3.0...v5.4.0) (2020-11-18)
### Features
* deep decorator inheritance ([6daabc5](https://github.com/tannerntannern/ts-mixer/commit/6daabc5d340d20c8eda4fe96b635a54f6a7e18fb))
## [5.3.0](https://github.com/tannerntannern/ts-mixer/compare/v5.3.0-beta.0...v5.3.0) (2020-06-01)
## [5.3.0-beta.0](https://github.com/tannerntannern/ts-mixer/compare/v5.2.1...v5.3.0-beta.0) (2020-05-31)
### Features
* add hasMixin function ([#27](https://github.com/tannerntannern/ts-mixer/issues/27)) ([c8bfc2d](https://github.com/tannerntannern/ts-mixer/commit/c8bfc2d48854808755088332636e8d166007ed9f))
### [5.2.1](https://github.com/tannerntannern/ts-mixer/compare/v5.2.0...v5.2.1) (2020-05-08)
### Bug Fixes
* mix decorator not preserving constructor name ([7274fa2](https://github.com/tannerntannern/ts-mixer/commit/7274fa26a68e05cc59cde1108610e6a1ab51b430))
## [5.2.0](https://github.com/tannerntannern/ts-mixer/compare/v5.2.0-beta.1...v5.2.0) (2020-04-29)
## [5.2.0-beta.1](https://github.com/tannerntannern/ts-mixer/compare/v5.2.0-beta.0...v5.2.0-beta.1) (2020-04-23)
### Bug Fixes
* wrong this in init functions for Mixin(A, Mixin(B, C)) scenario ([0ba1128](https://github.com/tannerntannern/ts-mixer/commit/0ba11283c63a878271b85c282f75190758101e63))
## [5.2.0-beta.0](https://github.com/tannerntannern/ts-mixer/compare/v5.1.0...v5.2.0-beta.0) (2020-04-13)
### Features
* adds init func feature for impure constructors ([99a946b](https://github.com/tannerntannern/ts-mixer/commit/99a946b8e272773f6bafd7a7e8bf8313517dec16))
## [5.1.0](https://github.com/tannerntannern/ts-mixer/compare/v5.1.0-beta.0...v5.1.0) (2020-03-27)
## [5.1.0-beta.0](https://github.com/tannerntannern/ts-mixer/compare/v5.0.0...v5.1.0-beta.0) (2020-03-26)
### Features
* decorator support for class-validators, typeORM, etc ([2c14812](https://github.com/tannerntannern/ts-mixer/commit/2c1481237b325916ca95dbb9e33141b3220f8068))
## [5.0.0](https://github.com/tannerntannern/ts-mixer/compare/v5.0.0-beta.0...v5.0.0) (2020-03-01)
## [5.0.0-beta.0](https://github.com/tannerntannern/ts-mixer/compare/v4.0.0...v5.0.0-beta.0) (2020-02-02)
### Features
* adds and tests a nearestCommonAncestor function ([b084579](https://github.com/tannerntannern/ts-mixer/commit/b084579d5ac52e0b456be95ff6b776309b436473))
* initial static inheritance implementation ([8467c40](https://github.com/tannerntannern/ts-mixer/commit/8467c40c9748e769eebf77b45cccad5ce785bac9))
* initial version of proxyMix ([95a91c7](https://github.com/tannerntannern/ts-mixer/commit/95a91c78e5f05af75cfc95d82a65ce5b3413b9f1))
* makes mixin constructor argument inference slightly smarter ([b844b5c](https://github.com/tannerntannern/ts-mixer/commit/b844b5c93f5eab0d6f522559ed567f67291fae76))
### Bug Fixes
* mixins with shared ancestor when using proxy prototype ([5af189d](https://github.com/tannerntannern/ts-mixer/commit/5af189d9903083f675f65b5039875c4aa97be1a6))
* resolves indefinite tuple issue with `Longest` type ([68342b0](https://github.com/tannerntannern/ts-mixer/commit/68342b0a3fe224a485f220039af872050aa941fc))
* static chain inheritance ([0aca8f0](https://github.com/tannerntannern/ts-mixer/commit/0aca8f056a005ccf27cc564d5a84abe1ef999d7b))

21
node_modules/ts-mixer/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Tanner Nielsen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

270
node_modules/ts-mixer/README.md generated vendored Normal file
View file

@ -0,0 +1,270 @@
# ts-mixer
[version-badge]: https://badgen.net/npm/v/ts-mixer
[version-link]: https://npmjs.com/package/ts-mixer
[build-link]: https://github.com/tannerntannern/ts-mixer/actions
[ts-versions]: https://badgen.net/badge/icon/4.2,4.6,5.0,5.2?icon=typescript&label&list=|
[node-versions]: https://badgen.net/badge/node/16%2C18%2C20/blue/?list=|
[![npm version][version-badge]][version-link]
[![TS Versions][ts-versions]][build-link]
[![Node.js Versions][node-versions]][build-link]
[![Minified Size](https://badgen.net/bundlephobia/min/ts-mixer)](https://bundlephobia.com/result?p=ts-mixer)
[![Conventional Commits](https://badgen.net/badge/conventional%20commits/1.0.0/yellow)](https://conventionalcommits.org)
## Overview
`ts-mixer` brings mixins to TypeScript. "Mixins" to `ts-mixer` are just classes, so you already know how to write them, and you can probably mix classes from your favorite library without trouble.
The mixin problem is more nuanced than it appears. I've seen countless code snippets that work for certain situations, but fail in others. `ts-mixer` tries to take the best from all these solutions while accounting for the situations you might not have considered.
[Quick start guide](#quick-start)
### Features
* mixes plain classes
* mixes classes that extend other classes
* mixes classes that were mixed with `ts-mixer`
* supports static properties
* supports protected/private properties (the popular function-that-returns-a-class solution does not)
* mixes abstract classes (requires TypeScript >= 4.2)
* mixes generic classes (with caveats [[1](#caveats)])
* supports class, method, and property decorators (with caveats [[2, 5](#caveats)])
* mostly supports the complexity presented by constructor functions (with caveats [[3](#caveats)])
* comes with an `instanceof`-like replacement (with caveats [[4, 5](#caveats)])
* [multiple mixing strategies](#settings) (ES6 proxies vs hard copy)
### Caveats
1. Mixing generic classes requires a more cumbersome notation, but it's still possible. See [mixing generic classes](#mixing-generic-classes) below.
2. Using decorators in mixed classes also requires a more cumbersome notation. See [mixing with decorators](#mixing-with-decorators) below.
3. ES6 made it impossible to use `.apply(...)` on class constructors (or any means of calling them without `new`), which makes it impossible for `ts-mixer` to pass the proper `this` to your constructors. This may or may not be an issue for your code, but there are options to work around it. See [dealing with constructors](#dealing-with-constructors) below.
4. `ts-mixer` does not support `instanceof` for mixins, but it does offer a replacement. See the [hasMixin function](#hasmixin) for more details.
5. Certain features (specifically, `@decorator` and `hasMixin`) make use of ES6 `Map`s, which means you must either use ES6+ or polyfill `Map` to use them. If you don't need these features, you should be fine without.
## Quick Start
### Installation
```
$ npm install ts-mixer
```
or if you prefer [Yarn](https://yarnpkg.com):
```
$ yarn add ts-mixer
```
### Basic Example
```typescript
import { Mixin } from 'ts-mixer';
class Foo {
protected makeFoo() {
return 'foo';
}
}
class Bar {
protected makeBar() {
return 'bar';
}
}
class FooBar extends Mixin(Foo, Bar) {
public makeFooBar() {
return this.makeFoo() + this.makeBar();
}
}
const fooBar = new FooBar();
console.log(fooBar.makeFooBar()); // "foobar"
```
## Special Cases
### Mixing Generic Classes
Frustratingly, it is _impossible_ for generic parameters to be referenced in base class expressions. No matter what, you will eventually run into `Base class expressions cannot reference class type parameters.`
The way to get around this is to leverage [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html), and a slightly different mixing function from ts-mixer: `mix`. It works exactly like `Mixin`, except it's a decorator, which means it doesn't affect the type information of the class being decorated. See it in action below:
```typescript
import { mix } from 'ts-mixer';
class Foo<T> {
public fooMethod(input: T): T {
return input;
}
}
class Bar<T> {
public barMethod(input: T): T {
return input;
}
}
interface FooBar<T1, T2> extends Foo<T1>, Bar<T2> { }
@mix(Foo, Bar)
class FooBar<T1, T2> {
public fooBarMethod(input1: T1, input2: T2) {
return [this.fooMethod(input1), this.barMethod(input2)];
}
}
```
Key takeaways from this example:
* `interface FooBar<T1, T2> extends Foo<T1>, Bar<T2> { }` makes sure `FooBar` has the typing we want, thanks to declaration merging
* `@mix(Foo, Bar)` wires things up "on the JavaScript side", since the interface declaration has nothing to do with runtime behavior.
* The reason we have to use the `mix` decorator is that the typing produced by `Mixin(Foo, Bar)` would conflict with the typing of the interface. `mix` has no effect "on the TypeScript side," thus avoiding type conflicts.
### Mixing with Decorators
Popular libraries such as [class-validator](https://github.com/typestack/class-validator) and [TypeORM](https://github.com/typeorm/typeorm) use decorators to add functionality. Unfortunately, `ts-mixer` has no way of knowing what these libraries do with the decorators behind the scenes. So if you want these decorators to be "inherited" with classes you plan to mix, you first have to wrap them with a special `decorate` function exported by `ts-mixer`. Here's an example using `class-validator`:
```typescript
import { IsBoolean, IsIn, validate } from 'class-validator';
import { Mixin, decorate } from 'ts-mixer';
class Disposable {
@decorate(IsBoolean()) // instead of @IsBoolean()
isDisposed: boolean = false;
}
class Statusable {
@decorate(IsIn(['red', 'green'])) // instead of @IsIn(['red', 'green'])
status: string = 'green';
}
class ExtendedObject extends Mixin(Disposable, Statusable) {}
const extendedObject = new ExtendedObject();
extendedObject.status = 'blue';
validate(extendedObject).then(errors => {
console.log(errors);
});
```
### Dealing with Constructors
As mentioned in the [caveats section](#caveats), ES6 disallowed calling constructor functions without `new`. This means that the only way for `ts-mixer` to mix instance properties is to instantiate each base class separately, then copy the instance properties into a common object. The consequence of this is that constructors mixed by `ts-mixer` will _not_ receive the proper `this`.
**This very well may not be an issue for you!** It only means that your constructors need to be "mostly pure" in terms of how they handle `this`. Specifically, your constructors cannot produce [side effects](https://en.wikipedia.org/wiki/Side_effect_%28computer_science%29) involving `this`, _other than adding properties to `this`_ (the most common side effect in JavaScript constructors).
If you simply cannot eliminate `this` side effects from your constructor, there is a workaround available: `ts-mixer` will automatically forward constructor parameters to a predesignated init function (`settings.initFunction`) if it's present on the class. Unlike constructors, functions can be called with an arbitrary `this`, so this predesignated init function _will_ have the proper `this`. Here's a basic example:
```typescript
import { Mixin, settings } from 'ts-mixer';
settings.initFunction = 'init';
class Person {
public static allPeople: Set<Person> = new Set();
protected init() {
Person.allPeople.add(this);
}
}
type PartyAffiliation = 'democrat' | 'republican';
class PoliticalParticipant {
public static democrats: Set<PoliticalParticipant> = new Set();
public static republicans: Set<PoliticalParticipant> = new Set();
public party: PartyAffiliation;
// note that these same args will also be passed to init function
public constructor(party: PartyAffiliation) {
this.party = party;
}
protected init(party: PartyAffiliation) {
if (party === 'democrat')
PoliticalParticipant.democrats.add(this);
else
PoliticalParticipant.republicans.add(this);
}
}
class Voter extends Mixin(Person, PoliticalParticipant) {}
const v1 = new Voter('democrat');
const v2 = new Voter('democrat');
const v3 = new Voter('republican');
const v4 = new Voter('republican');
```
Note the above `.add(this)` statements. These would not work as expected if they were placed in the constructor instead, since `this` is not the same between the constructor and `init`, as explained above.
## Other Features
### hasMixin
As mentioned above, `ts-mixer` does not support `instanceof` for mixins. While it is possible to implement [custom `instanceof` behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance), this library does not do so because it would require modifying the source classes, which is deliberately avoided.
You can fill this missing functionality with `hasMixin(instance, mixinClass)` instead. See the below example:
```typescript
import { Mixin, hasMixin } from 'ts-mixer';
class Foo {}
class Bar {}
class FooBar extends Mixin(Foo, Bar) {}
const instance = new FooBar();
// doesn't work with instanceof...
console.log(instance instanceof FooBar) // true
console.log(instance instanceof Foo) // false
console.log(instance instanceof Bar) // false
// but everything works nicely with hasMixin!
console.log(hasMixin(instance, FooBar)) // true
console.log(hasMixin(instance, Foo)) // true
console.log(hasMixin(instance, Bar)) // true
```
`hasMixin(instance, mixinClass)` will work anywhere that `instance instanceof mixinClass` works. Additionally, like `instanceof`, you get the same [type narrowing benefits](https://www.typescriptlang.org/docs/handbook/advanced-types.html#instanceof-type-guards):
```typescript
if (hasMixin(instance, Foo)) {
// inferred type of instance is "Foo"
}
if (hasMixin(instance, Bar)) {
// inferred type of instance of "Bar"
}
```
## Settings
ts-mixer has multiple strategies for mixing classes which can be configured by modifying `settings` from ts-mixer. For example:
```typescript
import { settings, Mixin } from 'ts-mixer';
settings.prototypeStrategy = 'proxy';
// then use `Mixin` as normal...
```
### `settings.prototypeStrategy`
* Determines how ts-mixer will mix class prototypes together
* Possible values:
- `'copy'` (default) - Copies all methods from the classes being mixed into a new prototype object. (This will include all methods up the prototype chains as well.) This is the default for ES5 compatibility, but it has the downside of stale references. For example, if you mix `Foo` and `Bar` to make `FooBar`, then redefine a method on `Foo`, `FooBar` will not have the latest methods from `Foo`. If this is not a concern for you, `'copy'` is the best value for this setting.
- `'proxy'` - Uses an ES6 Proxy to "soft mix" prototypes. Unlike `'copy'`, updates to the base classes _will_ be reflected in the mixed class, which may be desirable. The downside is that method access is not as performant, nor is it ES5 compatible.
### `settings.staticsStrategy`
* Determines how static properties are inherited
* Possible values:
- `'copy'` (default) - Simply copies all properties (minus `prototype`) from the base classes/constructor functions onto the mixed class. Like `settings.prototypeStrategy = 'copy'`, this strategy also suffers from stale references, but shouldn't be a concern if you don't redefine static methods after mixing.
- `'proxy'` - Similar to `settings.prototypeStrategy`, proxy's static method access to base classes. Has the same benefits/downsides.
### `settings.initFunction`
* If set, `ts-mixer` will automatically call the function with this name upon construction
* Possible values:
- `null` (default) - disables the behavior
- a string - function name to call upon construction
* Read more about why you would want this in [dealing with constructors](#dealing-with-constructors)
### `settings.decoratorInheritance`
* Determines how decorators are inherited from classes passed to `Mixin(...)`
* Possible values:
- `'deep'` (default) - Deeply inherits decorators from all given classes and their ancestors
- `'direct'` - Only inherits decorators defined directly on the given classes
- `'none'` - Skips decorator inheritance
# Author
Tanner Nielsen <tannerntannern@gmail.com>
* Website - [tannernielsen.com](http://tannernielsen.com)
* Github - [tannerntannern](https://github.com/tannerntannern)

109
node_modules/ts-mixer/dist/cjs/decorator.js generated vendored Normal file
View file

@ -0,0 +1,109 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decorate = exports.getDecoratorsForClass = exports.directDecoratorSearch = exports.deepDecoratorSearch = void 0;
const util_1 = require("./util");
const mixin_tracking_1 = require("./mixin-tracking");
const mergeObjectsOfDecorators = (o1, o2) => {
var _a, _b;
const allKeys = (0, util_1.unique)([...Object.getOwnPropertyNames(o1), ...Object.getOwnPropertyNames(o2)]);
const mergedObject = {};
for (let key of allKeys)
mergedObject[key] = (0, util_1.unique)([...((_a = o1 === null || o1 === void 0 ? void 0 : o1[key]) !== null && _a !== void 0 ? _a : []), ...((_b = o2 === null || o2 === void 0 ? void 0 : o2[key]) !== null && _b !== void 0 ? _b : [])]);
return mergedObject;
};
const mergePropertyAndMethodDecorators = (d1, d2) => {
var _a, _b, _c, _d;
return ({
property: mergeObjectsOfDecorators((_a = d1 === null || d1 === void 0 ? void 0 : d1.property) !== null && _a !== void 0 ? _a : {}, (_b = d2 === null || d2 === void 0 ? void 0 : d2.property) !== null && _b !== void 0 ? _b : {}),
method: mergeObjectsOfDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.method) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.method) !== null && _d !== void 0 ? _d : {}),
});
};
const mergeDecorators = (d1, d2) => {
var _a, _b, _c, _d, _e, _f;
return ({
class: (0, util_1.unique)([...(_a = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a !== void 0 ? _a : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
static: mergePropertyAndMethodDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.static) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.static) !== null && _d !== void 0 ? _d : {}),
instance: mergePropertyAndMethodDecorators((_e = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e !== void 0 ? _e : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {}),
});
};
const decorators = new Map();
const findAllConstituentClasses = (...classes) => {
var _a;
const allClasses = new Set();
const frontier = new Set([...classes]);
while (frontier.size > 0) {
for (let clazz of frontier) {
const protoChainClasses = (0, util_1.protoChain)(clazz.prototype).map(proto => proto.constructor);
const mixinClasses = (_a = (0, mixin_tracking_1.getMixinsForClass)(clazz)) !== null && _a !== void 0 ? _a : [];
const potentiallyNewClasses = [...protoChainClasses, ...mixinClasses];
const newClasses = potentiallyNewClasses.filter(c => !allClasses.has(c));
for (let newClass of newClasses)
frontier.add(newClass);
allClasses.add(clazz);
frontier.delete(clazz);
}
}
return [...allClasses];
};
const deepDecoratorSearch = (...classes) => {
const decoratorsForClassChain = findAllConstituentClasses(...classes)
.map(clazz => decorators.get(clazz))
.filter(decorators => !!decorators);
if (decoratorsForClassChain.length == 0)
return {};
if (decoratorsForClassChain.length == 1)
return decoratorsForClassChain[0];
return decoratorsForClassChain.reduce((d1, d2) => mergeDecorators(d1, d2));
};
exports.deepDecoratorSearch = deepDecoratorSearch;
const directDecoratorSearch = (...classes) => {
const classDecorators = classes.map(clazz => (0, exports.getDecoratorsForClass)(clazz));
if (classDecorators.length === 0)
return {};
if (classDecorators.length === 1)
return classDecorators[0];
return classDecorators.reduce((d1, d2) => mergeDecorators(d1, d2));
};
exports.directDecoratorSearch = directDecoratorSearch;
const getDecoratorsForClass = (clazz) => {
let decoratorsForClass = decorators.get(clazz);
if (!decoratorsForClass) {
decoratorsForClass = {};
decorators.set(clazz, decoratorsForClass);
}
return decoratorsForClass;
};
exports.getDecoratorsForClass = getDecoratorsForClass;
const decorateClass = (decorator) => ((clazz) => {
const decoratorsForClass = (0, exports.getDecoratorsForClass)(clazz);
let classDecorators = decoratorsForClass.class;
if (!classDecorators) {
classDecorators = [];
decoratorsForClass.class = classDecorators;
}
classDecorators.push(decorator);
return decorator(clazz);
});
const decorateMember = (decorator) => ((object, key, ...otherArgs) => {
var _a, _b, _c;
const decoratorTargetType = typeof object === 'function' ? 'static' : 'instance';
const decoratorType = typeof object[key] === 'function' ? 'method' : 'property';
const clazz = decoratorTargetType === 'static' ? object : object.constructor;
const decoratorsForClass = (0, exports.getDecoratorsForClass)(clazz);
const decoratorsForTargetType = (_a = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType]) !== null && _a !== void 0 ? _a : {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
let decoratorsForType = (_b = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType]) !== null && _b !== void 0 ? _b : {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
let decoratorsForKey = (_c = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key]) !== null && _c !== void 0 ? _c : [];
decoratorsForType[key] = decoratorsForKey;
// @ts-ignore: array is type `A[] | B[]` and item is type `A | B`, so technically a type error, but it's fine
decoratorsForKey.push(decorator);
// @ts-ignore
return decorator(object, key, ...otherArgs);
});
const decorate = (decorator) => ((...args) => {
if (args.length === 1)
return decorateClass(decorator)(args[0]);
return decorateMember(decorator)(...args);
});
exports.decorate = decorate;

12
node_modules/ts-mixer/dist/cjs/index.js generated vendored Normal file
View file

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasMixin = exports.decorate = exports.settings = exports.mix = exports.Mixin = void 0;
var mixins_1 = require("./mixins");
Object.defineProperty(exports, "Mixin", { enumerable: true, get: function () { return mixins_1.Mixin; } });
Object.defineProperty(exports, "mix", { enumerable: true, get: function () { return mixins_1.mix; } });
var settings_1 = require("./settings");
Object.defineProperty(exports, "settings", { enumerable: true, get: function () { return settings_1.settings; } });
var decorator_1 = require("./decorator");
Object.defineProperty(exports, "decorate", { enumerable: true, get: function () { return decorator_1.decorate; } });
var mixin_tracking_1 = require("./mixin-tracking");
Object.defineProperty(exports, "hasMixin", { enumerable: true, get: function () { return mixin_tracking_1.hasMixin; } });

42
node_modules/ts-mixer/dist/cjs/mixin-tracking.js generated vendored Normal file
View file

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasMixin = exports.registerMixins = exports.getMixinsForClass = void 0;
const util_1 = require("./util");
// Keeps track of constituent classes for every mixin class created by ts-mixer.
const mixins = new WeakMap();
const getMixinsForClass = (clazz) => mixins.get(clazz);
exports.getMixinsForClass = getMixinsForClass;
const registerMixins = (mixedClass, constituents) => mixins.set(mixedClass, constituents);
exports.registerMixins = registerMixins;
const hasMixin = (instance, mixin) => {
if (instance instanceof mixin)
return true;
const constructor = instance.constructor;
const visited = new Set();
let frontier = new Set();
frontier.add(constructor);
while (frontier.size > 0) {
// check if the frontier has the mixin we're looking for. if not, we can say we visited every item in the frontier
if (frontier.has(mixin))
return true;
frontier.forEach((item) => visited.add(item));
// build a new frontier based on the associated mixin classes and prototype chains of each frontier item
const newFrontier = new Set();
frontier.forEach((item) => {
var _a;
const itemConstituents = (_a = mixins.get(item)) !== null && _a !== void 0 ? _a : (0, util_1.protoChain)(item.prototype)
.map((proto) => proto.constructor)
.filter((item) => item !== null);
if (itemConstituents)
itemConstituents.forEach((constituent) => {
if (!visited.has(constituent) && !frontier.has(constituent))
newFrontier.add(constituent);
});
});
// we have a new frontier, now search again
frontier = newFrontier;
}
// if we get here, we couldn't find the mixin anywhere in the prototype chain or associated mixin classes
return false;
};
exports.hasMixin = hasMixin;

82
node_modules/ts-mixer/dist/cjs/mixins.js generated vendored Normal file
View file

@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mix = exports.Mixin = void 0;
const proxy_1 = require("./proxy");
const settings_1 = require("./settings");
const util_1 = require("./util");
const decorator_1 = require("./decorator");
const mixin_tracking_1 = require("./mixin-tracking");
function Mixin(...constructors) {
var _a, _b, _c;
const prototypes = constructors.map(constructor => constructor.prototype);
// Here we gather up the init functions of the ingredient prototypes, combine them into one init function, and
// attach it to the mixed class prototype. The reason we do this is because we want the init functions to mix
// similarly to constructors -- not methods, which simply override each other.
const initFunctionName = settings_1.settings.initFunction;
if (initFunctionName !== null) {
const initFunctions = prototypes
.map(proto => proto[initFunctionName])
.filter(func => typeof func === 'function');
const combinedInitFunction = function (...args) {
for (let initFunction of initFunctions)
initFunction.apply(this, args);
};
const extraProto = { [initFunctionName]: combinedInitFunction };
prototypes.push(extraProto);
}
function MixedClass(...args) {
for (const constructor of constructors)
// @ts-ignore: potentially abstract class
(0, util_1.copyProps)(this, new constructor(...args));
if (initFunctionName !== null && typeof this[initFunctionName] === 'function')
this[initFunctionName].apply(this, args);
}
MixedClass.prototype = settings_1.settings.prototypeStrategy === 'copy'
? (0, util_1.hardMixProtos)(prototypes, MixedClass)
: (0, proxy_1.softMixProtos)(prototypes, MixedClass);
Object.setPrototypeOf(MixedClass, settings_1.settings.staticsStrategy === 'copy'
? (0, util_1.hardMixProtos)(constructors, null, ['prototype'])
: (0, proxy_1.proxyMix)(constructors, Function.prototype));
let DecoratedMixedClass = MixedClass;
if (settings_1.settings.decoratorInheritance !== 'none') {
const classDecorators = settings_1.settings.decoratorInheritance === 'deep'
? (0, decorator_1.deepDecoratorSearch)(...constructors)
: (0, decorator_1.directDecoratorSearch)(...constructors);
for (let decorator of (_a = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.class) !== null && _a !== void 0 ? _a : []) {
const result = decorator(DecoratedMixedClass);
if (result) {
DecoratedMixedClass = result;
}
}
applyPropAndMethodDecorators((_b = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.static) !== null && _b !== void 0 ? _b : {}, DecoratedMixedClass);
applyPropAndMethodDecorators((_c = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.instance) !== null && _c !== void 0 ? _c : {}, DecoratedMixedClass.prototype);
}
(0, mixin_tracking_1.registerMixins)(DecoratedMixedClass, constructors);
return DecoratedMixedClass;
}
exports.Mixin = Mixin;
const applyPropAndMethodDecorators = (propAndMethodDecorators, target) => {
const propDecorators = propAndMethodDecorators.property;
const methodDecorators = propAndMethodDecorators.method;
if (propDecorators)
for (let key in propDecorators)
for (let decorator of propDecorators[key])
decorator(target, key);
if (methodDecorators)
for (let key in methodDecorators)
for (let decorator of methodDecorators[key])
decorator(target, key, Object.getOwnPropertyDescriptor(target, key));
};
/**
* A decorator version of the `Mixin` function. You'll want to use this instead of `Mixin` for mixing generic classes.
*/
const mix = (...ingredients) => decoratedClass => {
// @ts-ignore
const mixedClass = Mixin(...ingredients.concat([decoratedClass]));
Object.defineProperty(mixedClass, 'name', {
value: decoratedClass.name,
writable: false,
});
return mixedClass;
};
exports.mix = mix;

82
node_modules/ts-mixer/dist/cjs/proxy.js generated vendored Normal file
View file

@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.softMixProtos = exports.proxyMix = exports.getIngredientWithProp = void 0;
const util_1 = require("./util");
/**
* Finds the ingredient with the given prop, searching in reverse order and breadth-first if searching ingredient
* prototypes is required.
*/
const getIngredientWithProp = (prop, ingredients) => {
const protoChains = ingredients.map(ingredient => (0, util_1.protoChain)(ingredient));
// since we search breadth-first, we need to keep track of our depth in the prototype chains
let protoDepth = 0;
// not all prototype chains are the same depth, so this remains true as long as at least one of the ingredients'
// prototype chains has an object at this depth
let protosAreLeftToSearch = true;
while (protosAreLeftToSearch) {
// with the start of each horizontal slice, we assume this is the one that's deeper than any of the proto chains
protosAreLeftToSearch = false;
// scan through the ingredients right to left
for (let i = ingredients.length - 1; i >= 0; i--) {
const searchTarget = protoChains[i][protoDepth];
if (searchTarget !== undefined && searchTarget !== null) {
// if we find something, this is proof that this horizontal slice potentially more objects to search
protosAreLeftToSearch = true;
// eureka, we found it
if (Object.getOwnPropertyDescriptor(searchTarget, prop) != undefined) {
return protoChains[i][0];
}
}
}
protoDepth++;
}
return undefined;
};
exports.getIngredientWithProp = getIngredientWithProp;
/**
* "Mixes" ingredients by wrapping them in a Proxy. The optional prototype argument allows the mixed object to sit
* downstream of an existing prototype chain. Note that "properties" cannot be added, deleted, or modified.
*/
const proxyMix = (ingredients, prototype = Object.prototype) => new Proxy({}, {
getPrototypeOf() {
return prototype;
},
setPrototypeOf() {
throw Error('Cannot set prototype of Proxies created by ts-mixer');
},
getOwnPropertyDescriptor(_, prop) {
return Object.getOwnPropertyDescriptor((0, exports.getIngredientWithProp)(prop, ingredients) || {}, prop);
},
defineProperty() {
throw new Error('Cannot define new properties on Proxies created by ts-mixer');
},
has(_, prop) {
return (0, exports.getIngredientWithProp)(prop, ingredients) !== undefined || prototype[prop] !== undefined;
},
get(_, prop) {
return ((0, exports.getIngredientWithProp)(prop, ingredients) || prototype)[prop];
},
set(_, prop, val) {
const ingredientWithProp = (0, exports.getIngredientWithProp)(prop, ingredients);
if (ingredientWithProp === undefined)
throw new Error('Cannot set new properties on Proxies created by ts-mixer');
ingredientWithProp[prop] = val;
return true;
},
deleteProperty() {
throw new Error('Cannot delete properties on Proxies created by ts-mixer');
},
ownKeys() {
return ingredients
.map(Object.getOwnPropertyNames)
.reduce((prev, curr) => curr.concat(prev.filter(key => curr.indexOf(key) < 0)));
},
});
exports.proxyMix = proxyMix;
/**
* Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by
* proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any
* changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable.
*/
const softMixProtos = (ingredients, constructor) => (0, exports.proxyMix)([...ingredients, { constructor }]);
exports.softMixProtos = softMixProtos;

9
node_modules/ts-mixer/dist/cjs/settings.js generated vendored Normal file
View file

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.settings = void 0;
exports.settings = {
initFunction: null,
staticsStrategy: 'copy',
prototypeStrategy: 'copy',
decoratorInheritance: 'deep',
};

2
node_modules/ts-mixer/dist/cjs/types.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

85
node_modules/ts-mixer/dist/cjs/util.js generated vendored Normal file
View file

@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatten = exports.unique = exports.hardMixProtos = exports.nearestCommonProto = exports.protoChain = exports.copyProps = void 0;
/**
* Utility function that works like `Object.apply`, but copies getters and setters properly as well. Additionally gives
* the option to exclude properties by name.
*/
const copyProps = (dest, src, exclude = []) => {
const props = Object.getOwnPropertyDescriptors(src);
for (let prop of exclude)
delete props[prop];
Object.defineProperties(dest, props);
};
exports.copyProps = copyProps;
/**
* Returns the full chain of prototypes up until Object.prototype given a starting object. The order of prototypes will
* be closest to farthest in the chain.
*/
const protoChain = (obj, currentChain = [obj]) => {
const proto = Object.getPrototypeOf(obj);
if (proto === null)
return currentChain;
return (0, exports.protoChain)(proto, [...currentChain, proto]);
};
exports.protoChain = protoChain;
/**
* Identifies the nearest ancestor common to all the given objects in their prototype chains. For most unrelated
* objects, this function should return Object.prototype.
*/
const nearestCommonProto = (...objs) => {
if (objs.length === 0)
return undefined;
let commonProto = undefined;
const protoChains = objs.map(obj => (0, exports.protoChain)(obj));
while (protoChains.every(protoChain => protoChain.length > 0)) {
const protos = protoChains.map(protoChain => protoChain.pop());
const potentialCommonProto = protos[0];
if (protos.every(proto => proto === potentialCommonProto))
commonProto = potentialCommonProto;
else
break;
}
return commonProto;
};
exports.nearestCommonProto = nearestCommonProto;
/**
* Creates a new prototype object that is a mixture of the given prototypes. The mixing is achieved by first
* identifying the nearest common ancestor and using it as the prototype for a new object. Then all properties/methods
* downstream of this prototype (ONLY downstream) are copied into the new object.
*
* The resulting prototype is more performant than softMixProtos(...), as well as ES5 compatible. However, it's not as
* flexible as updates to the source prototypes aren't captured by the mixed result. See softMixProtos for why you may
* want to use that instead.
*/
const hardMixProtos = (ingredients, constructor, exclude = []) => {
var _a;
const base = (_a = (0, exports.nearestCommonProto)(...ingredients)) !== null && _a !== void 0 ? _a : Object.prototype;
const mixedProto = Object.create(base);
// Keeps track of prototypes we've already visited to avoid copying the same properties multiple times. We init the
// list with the proto chain below the nearest common ancestor because we don't want any of those methods mixed in
// when they will already be accessible via prototype access.
const visitedProtos = (0, exports.protoChain)(base);
for (let prototype of ingredients) {
let protos = (0, exports.protoChain)(prototype);
// Apply the prototype chain in reverse order so that old methods don't override newer ones.
for (let i = protos.length - 1; i >= 0; i--) {
let newProto = protos[i];
if (visitedProtos.indexOf(newProto) === -1) {
(0, exports.copyProps)(mixedProto, newProto, ['constructor', ...exclude]);
visitedProtos.push(newProto);
}
}
}
mixedProto.constructor = constructor;
return mixedProto;
};
exports.hardMixProtos = hardMixProtos;
const unique = (arr) => arr.filter((e, i) => arr.indexOf(e) == i);
exports.unique = unique;
const flatten = (arr) => arr.length === 0
? []
: arr.length === 1
? arr[0]
: arr.reduce((a1, a2) => [...a1, ...a2]);
exports.flatten = flatten;

18
node_modules/ts-mixer/dist/esm/decorator.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
import { Class } from './types';
type ObjectOfDecorators<T extends PropertyDecorator | MethodDecorator> = {
[key: string]: T[];
};
export type PropertyAndMethodDecorators = {
property?: ObjectOfDecorators<PropertyDecorator>;
method?: ObjectOfDecorators<MethodDecorator>;
};
type Decorators = {
class?: ClassDecorator[];
static?: PropertyAndMethodDecorators;
instance?: PropertyAndMethodDecorators;
};
export declare const deepDecoratorSearch: (...classes: Class[]) => Decorators;
export declare const directDecoratorSearch: (...classes: Class[]) => Decorators;
export declare const getDecoratorsForClass: (clazz: Class) => Decorators;
export declare const decorate: <T extends PropertyDecorator | MethodDecorator | ClassDecorator>(decorator: T) => T;
export {};

4
node_modules/ts-mixer/dist/esm/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
export { Mixin, mix } from './mixins';
export { settings } from './settings';
export { decorate } from './decorator';
export { hasMixin } from './mixin-tracking';

366
node_modules/ts-mixer/dist/esm/index.js generated vendored Normal file
View file

@ -0,0 +1,366 @@
/**
* Utility function that works like `Object.apply`, but copies getters and setters properly as well. Additionally gives
* the option to exclude properties by name.
*/
const copyProps = (dest, src, exclude = []) => {
const props = Object.getOwnPropertyDescriptors(src);
for (let prop of exclude)
delete props[prop];
Object.defineProperties(dest, props);
};
/**
* Returns the full chain of prototypes up until Object.prototype given a starting object. The order of prototypes will
* be closest to farthest in the chain.
*/
const protoChain = (obj, currentChain = [obj]) => {
const proto = Object.getPrototypeOf(obj);
if (proto === null)
return currentChain;
return protoChain(proto, [...currentChain, proto]);
};
/**
* Identifies the nearest ancestor common to all the given objects in their prototype chains. For most unrelated
* objects, this function should return Object.prototype.
*/
const nearestCommonProto = (...objs) => {
if (objs.length === 0)
return undefined;
let commonProto = undefined;
const protoChains = objs.map(obj => protoChain(obj));
while (protoChains.every(protoChain => protoChain.length > 0)) {
const protos = protoChains.map(protoChain => protoChain.pop());
const potentialCommonProto = protos[0];
if (protos.every(proto => proto === potentialCommonProto))
commonProto = potentialCommonProto;
else
break;
}
return commonProto;
};
/**
* Creates a new prototype object that is a mixture of the given prototypes. The mixing is achieved by first
* identifying the nearest common ancestor and using it as the prototype for a new object. Then all properties/methods
* downstream of this prototype (ONLY downstream) are copied into the new object.
*
* The resulting prototype is more performant than softMixProtos(...), as well as ES5 compatible. However, it's not as
* flexible as updates to the source prototypes aren't captured by the mixed result. See softMixProtos for why you may
* want to use that instead.
*/
const hardMixProtos = (ingredients, constructor, exclude = []) => {
var _a;
const base = (_a = nearestCommonProto(...ingredients)) !== null && _a !== void 0 ? _a : Object.prototype;
const mixedProto = Object.create(base);
// Keeps track of prototypes we've already visited to avoid copying the same properties multiple times. We init the
// list with the proto chain below the nearest common ancestor because we don't want any of those methods mixed in
// when they will already be accessible via prototype access.
const visitedProtos = protoChain(base);
for (let prototype of ingredients) {
let protos = protoChain(prototype);
// Apply the prototype chain in reverse order so that old methods don't override newer ones.
for (let i = protos.length - 1; i >= 0; i--) {
let newProto = protos[i];
if (visitedProtos.indexOf(newProto) === -1) {
copyProps(mixedProto, newProto, ['constructor', ...exclude]);
visitedProtos.push(newProto);
}
}
}
mixedProto.constructor = constructor;
return mixedProto;
};
const unique = (arr) => arr.filter((e, i) => arr.indexOf(e) == i);
/**
* Finds the ingredient with the given prop, searching in reverse order and breadth-first if searching ingredient
* prototypes is required.
*/
const getIngredientWithProp = (prop, ingredients) => {
const protoChains = ingredients.map(ingredient => protoChain(ingredient));
// since we search breadth-first, we need to keep track of our depth in the prototype chains
let protoDepth = 0;
// not all prototype chains are the same depth, so this remains true as long as at least one of the ingredients'
// prototype chains has an object at this depth
let protosAreLeftToSearch = true;
while (protosAreLeftToSearch) {
// with the start of each horizontal slice, we assume this is the one that's deeper than any of the proto chains
protosAreLeftToSearch = false;
// scan through the ingredients right to left
for (let i = ingredients.length - 1; i >= 0; i--) {
const searchTarget = protoChains[i][protoDepth];
if (searchTarget !== undefined && searchTarget !== null) {
// if we find something, this is proof that this horizontal slice potentially more objects to search
protosAreLeftToSearch = true;
// eureka, we found it
if (Object.getOwnPropertyDescriptor(searchTarget, prop) != undefined) {
return protoChains[i][0];
}
}
}
protoDepth++;
}
return undefined;
};
/**
* "Mixes" ingredients by wrapping them in a Proxy. The optional prototype argument allows the mixed object to sit
* downstream of an existing prototype chain. Note that "properties" cannot be added, deleted, or modified.
*/
const proxyMix = (ingredients, prototype = Object.prototype) => new Proxy({}, {
getPrototypeOf() {
return prototype;
},
setPrototypeOf() {
throw Error('Cannot set prototype of Proxies created by ts-mixer');
},
getOwnPropertyDescriptor(_, prop) {
return Object.getOwnPropertyDescriptor(getIngredientWithProp(prop, ingredients) || {}, prop);
},
defineProperty() {
throw new Error('Cannot define new properties on Proxies created by ts-mixer');
},
has(_, prop) {
return getIngredientWithProp(prop, ingredients) !== undefined || prototype[prop] !== undefined;
},
get(_, prop) {
return (getIngredientWithProp(prop, ingredients) || prototype)[prop];
},
set(_, prop, val) {
const ingredientWithProp = getIngredientWithProp(prop, ingredients);
if (ingredientWithProp === undefined)
throw new Error('Cannot set new properties on Proxies created by ts-mixer');
ingredientWithProp[prop] = val;
return true;
},
deleteProperty() {
throw new Error('Cannot delete properties on Proxies created by ts-mixer');
},
ownKeys() {
return ingredients
.map(Object.getOwnPropertyNames)
.reduce((prev, curr) => curr.concat(prev.filter(key => curr.indexOf(key) < 0)));
},
});
/**
* Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by
* proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any
* changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable.
*/
const softMixProtos = (ingredients, constructor) => proxyMix([...ingredients, { constructor }]);
const settings = {
initFunction: null,
staticsStrategy: 'copy',
prototypeStrategy: 'copy',
decoratorInheritance: 'deep',
};
// Keeps track of constituent classes for every mixin class created by ts-mixer.
const mixins = new WeakMap();
const getMixinsForClass = (clazz) => mixins.get(clazz);
const registerMixins = (mixedClass, constituents) => mixins.set(mixedClass, constituents);
const hasMixin = (instance, mixin) => {
if (instance instanceof mixin)
return true;
const constructor = instance.constructor;
const visited = new Set();
let frontier = new Set();
frontier.add(constructor);
while (frontier.size > 0) {
// check if the frontier has the mixin we're looking for. if not, we can say we visited every item in the frontier
if (frontier.has(mixin))
return true;
frontier.forEach((item) => visited.add(item));
// build a new frontier based on the associated mixin classes and prototype chains of each frontier item
const newFrontier = new Set();
frontier.forEach((item) => {
var _a;
const itemConstituents = (_a = mixins.get(item)) !== null && _a !== void 0 ? _a : protoChain(item.prototype)
.map((proto) => proto.constructor)
.filter((item) => item !== null);
if (itemConstituents)
itemConstituents.forEach((constituent) => {
if (!visited.has(constituent) && !frontier.has(constituent))
newFrontier.add(constituent);
});
});
// we have a new frontier, now search again
frontier = newFrontier;
}
// if we get here, we couldn't find the mixin anywhere in the prototype chain or associated mixin classes
return false;
};
const mergeObjectsOfDecorators = (o1, o2) => {
var _a, _b;
const allKeys = unique([...Object.getOwnPropertyNames(o1), ...Object.getOwnPropertyNames(o2)]);
const mergedObject = {};
for (let key of allKeys)
mergedObject[key] = unique([...((_a = o1 === null || o1 === void 0 ? void 0 : o1[key]) !== null && _a !== void 0 ? _a : []), ...((_b = o2 === null || o2 === void 0 ? void 0 : o2[key]) !== null && _b !== void 0 ? _b : [])]);
return mergedObject;
};
const mergePropertyAndMethodDecorators = (d1, d2) => {
var _a, _b, _c, _d;
return ({
property: mergeObjectsOfDecorators((_a = d1 === null || d1 === void 0 ? void 0 : d1.property) !== null && _a !== void 0 ? _a : {}, (_b = d2 === null || d2 === void 0 ? void 0 : d2.property) !== null && _b !== void 0 ? _b : {}),
method: mergeObjectsOfDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.method) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.method) !== null && _d !== void 0 ? _d : {}),
});
};
const mergeDecorators = (d1, d2) => {
var _a, _b, _c, _d, _e, _f;
return ({
class: unique([...(_a = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a !== void 0 ? _a : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
static: mergePropertyAndMethodDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.static) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.static) !== null && _d !== void 0 ? _d : {}),
instance: mergePropertyAndMethodDecorators((_e = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e !== void 0 ? _e : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {}),
});
};
const decorators = new Map();
const findAllConstituentClasses = (...classes) => {
var _a;
const allClasses = new Set();
const frontier = new Set([...classes]);
while (frontier.size > 0) {
for (let clazz of frontier) {
const protoChainClasses = protoChain(clazz.prototype).map(proto => proto.constructor);
const mixinClasses = (_a = getMixinsForClass(clazz)) !== null && _a !== void 0 ? _a : [];
const potentiallyNewClasses = [...protoChainClasses, ...mixinClasses];
const newClasses = potentiallyNewClasses.filter(c => !allClasses.has(c));
for (let newClass of newClasses)
frontier.add(newClass);
allClasses.add(clazz);
frontier.delete(clazz);
}
}
return [...allClasses];
};
const deepDecoratorSearch = (...classes) => {
const decoratorsForClassChain = findAllConstituentClasses(...classes)
.map(clazz => decorators.get(clazz))
.filter(decorators => !!decorators);
if (decoratorsForClassChain.length == 0)
return {};
if (decoratorsForClassChain.length == 1)
return decoratorsForClassChain[0];
return decoratorsForClassChain.reduce((d1, d2) => mergeDecorators(d1, d2));
};
const directDecoratorSearch = (...classes) => {
const classDecorators = classes.map(clazz => getDecoratorsForClass(clazz));
if (classDecorators.length === 0)
return {};
if (classDecorators.length === 1)
return classDecorators[0];
return classDecorators.reduce((d1, d2) => mergeDecorators(d1, d2));
};
const getDecoratorsForClass = (clazz) => {
let decoratorsForClass = decorators.get(clazz);
if (!decoratorsForClass) {
decoratorsForClass = {};
decorators.set(clazz, decoratorsForClass);
}
return decoratorsForClass;
};
const decorateClass = (decorator) => ((clazz) => {
const decoratorsForClass = getDecoratorsForClass(clazz);
let classDecorators = decoratorsForClass.class;
if (!classDecorators) {
classDecorators = [];
decoratorsForClass.class = classDecorators;
}
classDecorators.push(decorator);
return decorator(clazz);
});
const decorateMember = (decorator) => ((object, key, ...otherArgs) => {
var _a, _b, _c;
const decoratorTargetType = typeof object === 'function' ? 'static' : 'instance';
const decoratorType = typeof object[key] === 'function' ? 'method' : 'property';
const clazz = decoratorTargetType === 'static' ? object : object.constructor;
const decoratorsForClass = getDecoratorsForClass(clazz);
const decoratorsForTargetType = (_a = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType]) !== null && _a !== void 0 ? _a : {};
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
let decoratorsForType = (_b = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType]) !== null && _b !== void 0 ? _b : {};
decoratorsForTargetType[decoratorType] = decoratorsForType;
let decoratorsForKey = (_c = decoratorsForType === null || decoratorsForType === void 0 ? void 0 : decoratorsForType[key]) !== null && _c !== void 0 ? _c : [];
decoratorsForType[key] = decoratorsForKey;
// @ts-ignore: array is type `A[] | B[]` and item is type `A | B`, so technically a type error, but it's fine
decoratorsForKey.push(decorator);
// @ts-ignore
return decorator(object, key, ...otherArgs);
});
const decorate = (decorator) => ((...args) => {
if (args.length === 1)
return decorateClass(decorator)(args[0]);
return decorateMember(decorator)(...args);
});
function Mixin(...constructors) {
var _a, _b, _c;
const prototypes = constructors.map(constructor => constructor.prototype);
// Here we gather up the init functions of the ingredient prototypes, combine them into one init function, and
// attach it to the mixed class prototype. The reason we do this is because we want the init functions to mix
// similarly to constructors -- not methods, which simply override each other.
const initFunctionName = settings.initFunction;
if (initFunctionName !== null) {
const initFunctions = prototypes
.map(proto => proto[initFunctionName])
.filter(func => typeof func === 'function');
const combinedInitFunction = function (...args) {
for (let initFunction of initFunctions)
initFunction.apply(this, args);
};
const extraProto = { [initFunctionName]: combinedInitFunction };
prototypes.push(extraProto);
}
function MixedClass(...args) {
for (const constructor of constructors)
// @ts-ignore: potentially abstract class
copyProps(this, new constructor(...args));
if (initFunctionName !== null && typeof this[initFunctionName] === 'function')
this[initFunctionName].apply(this, args);
}
MixedClass.prototype = settings.prototypeStrategy === 'copy'
? hardMixProtos(prototypes, MixedClass)
: softMixProtos(prototypes, MixedClass);
Object.setPrototypeOf(MixedClass, settings.staticsStrategy === 'copy'
? hardMixProtos(constructors, null, ['prototype'])
: proxyMix(constructors, Function.prototype));
let DecoratedMixedClass = MixedClass;
if (settings.decoratorInheritance !== 'none') {
const classDecorators = settings.decoratorInheritance === 'deep'
? deepDecoratorSearch(...constructors)
: directDecoratorSearch(...constructors);
for (let decorator of (_a = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.class) !== null && _a !== void 0 ? _a : []) {
const result = decorator(DecoratedMixedClass);
if (result) {
DecoratedMixedClass = result;
}
}
applyPropAndMethodDecorators((_b = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.static) !== null && _b !== void 0 ? _b : {}, DecoratedMixedClass);
applyPropAndMethodDecorators((_c = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.instance) !== null && _c !== void 0 ? _c : {}, DecoratedMixedClass.prototype);
}
registerMixins(DecoratedMixedClass, constructors);
return DecoratedMixedClass;
}
const applyPropAndMethodDecorators = (propAndMethodDecorators, target) => {
const propDecorators = propAndMethodDecorators.property;
const methodDecorators = propAndMethodDecorators.method;
if (propDecorators)
for (let key in propDecorators)
for (let decorator of propDecorators[key])
decorator(target, key);
if (methodDecorators)
for (let key in methodDecorators)
for (let decorator of methodDecorators[key])
decorator(target, key, Object.getOwnPropertyDescriptor(target, key));
};
/**
* A decorator version of the `Mixin` function. You'll want to use this instead of `Mixin` for mixing generic classes.
*/
const mix = (...ingredients) => decoratedClass => {
// @ts-ignore
const mixedClass = Mixin(...ingredients.concat([decoratedClass]));
Object.defineProperty(mixedClass, 'name', {
value: decoratedClass.name,
writable: false,
});
return mixedClass;
};
export { Mixin, decorate, hasMixin, mix, settings };

1
node_modules/ts-mixer/dist/esm/index.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

4
node_modules/ts-mixer/dist/esm/mixin-tracking.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import { Class } from './types';
export declare const getMixinsForClass: (clazz: Class) => Function[] | undefined;
export declare const registerMixins: (mixedClass: any, constituents: Function[]) => WeakMap<any, Function[]>;
export declare const hasMixin: <M>(instance: any, mixin: abstract new (...args: any[]) => M) => instance is M;

16
node_modules/ts-mixer/dist/esm/mixins.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
import { Class, Longest } from './types';
declare function Mixin<A extends any[], I1, S1>(c1: Class<A, I1, S1>): Class<A, I1, S1>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>): Class<Longest<A1, A2>, I1 & I2, S1 & S2>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>): Class<Longest<A1, A2, A3>, I1 & I2 & I3, S1 & S2 & S3>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>): Class<Longest<A1, A2, A3, A4>, I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>): Class<Longest<A1, A2, A3, A4, A5>, I1 & I2 & I3 & I4 & I5, S1 & S2 & S3 & S4 & S5>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>): Class<Longest<A1, A2, A3, A4, A5, A6>, I1 & I2 & I3 & I4 & I5 & I6, S1 & S2 & S3 & S4 & S5 & S6>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>): Class<Longest<A1, A2, A3, A4, A5, A6, A7>, I1 & I2 & I3 & I4 & I5 & I6 & I7, S1 & S2 & S3 & S4 & S5 & S6 & S7>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8, A9 extends any[], I9, S9>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>, c9: Class<A9, I9, S9>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8, A9>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8, A9 extends any[], I9, S9, A10 extends any[], I10, S10>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>, c9: Class<A9, I9, S9>, c10: Class<A10, I10, S10>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9 & I10, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9 & S10>;
/**
* A decorator version of the `Mixin` function. You'll want to use this instead of `Mixin` for mixing generic classes.
*/
declare const mix: (...ingredients: Class[]) => (decoratedClass: any) => any;
export { Mixin, mix };

16
node_modules/ts-mixer/dist/esm/proxy.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* Finds the ingredient with the given prop, searching in reverse order and breadth-first if searching ingredient
* prototypes is required.
*/
export declare const getIngredientWithProp: (prop: string | number | symbol, ingredients: any[]) => object | undefined;
/**
* "Mixes" ingredients by wrapping them in a Proxy. The optional prototype argument allows the mixed object to sit
* downstream of an existing prototype chain. Note that "properties" cannot be added, deleted, or modified.
*/
export declare const proxyMix: (ingredients: any[], prototype?: Object) => {};
/**
* Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by
* proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any
* changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable.
*/
export declare const softMixProtos: (ingredients: any[], constructor: Function) => object;

7
node_modules/ts-mixer/dist/esm/settings.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
export type Settings = {
initFunction: string | null;
staticsStrategy: 'copy' | 'proxy';
prototypeStrategy: 'copy' | 'proxy';
decoratorInheritance: 'deep' | 'direct' | 'none';
};
export declare const settings: Settings;

13
node_modules/ts-mixer/dist/esm/types.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* Returns the longer of the two tuples. Indefinite tuples will always be considered longest.
*/
type _Longest<T1 extends any[], T2 extends any[]> = any[] extends T1 ? T1 : any[] extends T2 ? T2 : Exclude<keyof T1, keyof T2> extends never ? T2 : T1;
/**
* Returns the longest of up to 10 different tuples.
*/
export type Longest<T1 extends any[], T2 extends any[] = [], T3 extends any[] = [], T4 extends any[] = [], T5 extends any[] = [], T6 extends any[] = [], T7 extends any[] = [], T8 extends any[] = [], T9 extends any[] = [], T10 extends any[] = []> = _Longest<_Longest<_Longest<_Longest<T1, T2>, _Longest<T3, T4>>, _Longest<_Longest<T5, T6>, _Longest<T7, T8>>>, _Longest<T9, T10>>;
/**
* A rigorous type alias for a class.
*/
export type Class<CtorArgs extends any[] = any[], InstanceType = {}, StaticType = {}, IsAbstract = false> = (abstract new (...args: any[]) => InstanceType) & StaticType;
export {};

27
node_modules/ts-mixer/dist/esm/util.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
/**
* Utility function that works like `Object.apply`, but copies getters and setters properly as well. Additionally gives
* the option to exclude properties by name.
*/
export declare const copyProps: (dest: object, src: object, exclude?: string[]) => void;
/**
* Returns the full chain of prototypes up until Object.prototype given a starting object. The order of prototypes will
* be closest to farthest in the chain.
*/
export declare const protoChain: (obj: object, currentChain?: object[]) => object[];
/**
* Identifies the nearest ancestor common to all the given objects in their prototype chains. For most unrelated
* objects, this function should return Object.prototype.
*/
export declare const nearestCommonProto: (...objs: object[]) => object | undefined;
/**
* Creates a new prototype object that is a mixture of the given prototypes. The mixing is achieved by first
* identifying the nearest common ancestor and using it as the prototype for a new object. Then all properties/methods
* downstream of this prototype (ONLY downstream) are copied into the new object.
*
* The resulting prototype is more performant than softMixProtos(...), as well as ES5 compatible. However, it's not as
* flexible as updates to the source prototypes aren't captured by the mixed result. See softMixProtos for why you may
* want to use that instead.
*/
export declare const hardMixProtos: (ingredients: any[], constructor: Function | null, exclude?: string[]) => object;
export declare const unique: <T>(arr: T[]) => T[];
export declare const flatten: <T>(arr: T[][]) => T[];

18
node_modules/ts-mixer/dist/types/decorator.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
import { Class } from './types';
type ObjectOfDecorators<T extends PropertyDecorator | MethodDecorator> = {
[key: string]: T[];
};
export type PropertyAndMethodDecorators = {
property?: ObjectOfDecorators<PropertyDecorator>;
method?: ObjectOfDecorators<MethodDecorator>;
};
type Decorators = {
class?: ClassDecorator[];
static?: PropertyAndMethodDecorators;
instance?: PropertyAndMethodDecorators;
};
export declare const deepDecoratorSearch: (...classes: Class[]) => Decorators;
export declare const directDecoratorSearch: (...classes: Class[]) => Decorators;
export declare const getDecoratorsForClass: (clazz: Class) => Decorators;
export declare const decorate: <T extends PropertyDecorator | MethodDecorator | ClassDecorator>(decorator: T) => T;
export {};

4
node_modules/ts-mixer/dist/types/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
export { Mixin, mix } from './mixins';
export { settings } from './settings';
export { decorate } from './decorator';
export { hasMixin } from './mixin-tracking';

4
node_modules/ts-mixer/dist/types/mixin-tracking.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import { Class } from './types';
export declare const getMixinsForClass: (clazz: Class) => Function[] | undefined;
export declare const registerMixins: (mixedClass: any, constituents: Function[]) => WeakMap<any, Function[]>;
export declare const hasMixin: <M>(instance: any, mixin: abstract new (...args: any[]) => M) => instance is M;

16
node_modules/ts-mixer/dist/types/mixins.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
import { Class, Longest } from './types';
declare function Mixin<A extends any[], I1, S1>(c1: Class<A, I1, S1>): Class<A, I1, S1>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>): Class<Longest<A1, A2>, I1 & I2, S1 & S2>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>): Class<Longest<A1, A2, A3>, I1 & I2 & I3, S1 & S2 & S3>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>): Class<Longest<A1, A2, A3, A4>, I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>): Class<Longest<A1, A2, A3, A4, A5>, I1 & I2 & I3 & I4 & I5, S1 & S2 & S3 & S4 & S5>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>): Class<Longest<A1, A2, A3, A4, A5, A6>, I1 & I2 & I3 & I4 & I5 & I6, S1 & S2 & S3 & S4 & S5 & S6>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>): Class<Longest<A1, A2, A3, A4, A5, A6, A7>, I1 & I2 & I3 & I4 & I5 & I6 & I7, S1 & S2 & S3 & S4 & S5 & S6 & S7>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8, A9 extends any[], I9, S9>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>, c9: Class<A9, I9, S9>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8, A9>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9>;
declare function Mixin<A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4, A5 extends any[], I5, S5, A6 extends any[], I6, S6, A7 extends any[], I7, S7, A8 extends any[], I8, S8, A9 extends any[], I9, S9, A10 extends any[], I10, S10>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3: Class<A3, I3, S3>, c4: Class<A4, I4, S4>, c5: Class<A5, I5, S5>, c6: Class<A6, I6, S6>, c7: Class<A7, I7, S7>, c8: Class<A8, I8, S8>, c9: Class<A9, I9, S9>, c10: Class<A10, I10, S10>): Class<Longest<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>, I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9 & I10, S1 & S2 & S3 & S4 & S5 & S6 & S7 & S8 & S9 & S10>;
/**
* A decorator version of the `Mixin` function. You'll want to use this instead of `Mixin` for mixing generic classes.
*/
declare const mix: (...ingredients: Class[]) => (decoratedClass: any) => any;
export { Mixin, mix };

16
node_modules/ts-mixer/dist/types/proxy.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* Finds the ingredient with the given prop, searching in reverse order and breadth-first if searching ingredient
* prototypes is required.
*/
export declare const getIngredientWithProp: (prop: string | number | symbol, ingredients: any[]) => object | undefined;
/**
* "Mixes" ingredients by wrapping them in a Proxy. The optional prototype argument allows the mixed object to sit
* downstream of an existing prototype chain. Note that "properties" cannot be added, deleted, or modified.
*/
export declare const proxyMix: (ingredients: any[], prototype?: Object) => {};
/**
* Creates a new proxy-prototype object that is a "soft" mixture of the given prototypes. The mixing is achieved by
* proxying all property access to the ingredients. This is not ES5 compatible and less performant. However, any
* changes made to the source prototypes will be reflected in the proxy-prototype, which may be desirable.
*/
export declare const softMixProtos: (ingredients: any[], constructor: Function) => object;

7
node_modules/ts-mixer/dist/types/settings.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
export type Settings = {
initFunction: string | null;
staticsStrategy: 'copy' | 'proxy';
prototypeStrategy: 'copy' | 'proxy';
decoratorInheritance: 'deep' | 'direct' | 'none';
};
export declare const settings: Settings;

13
node_modules/ts-mixer/dist/types/types.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* Returns the longer of the two tuples. Indefinite tuples will always be considered longest.
*/
type _Longest<T1 extends any[], T2 extends any[]> = any[] extends T1 ? T1 : any[] extends T2 ? T2 : Exclude<keyof T1, keyof T2> extends never ? T2 : T1;
/**
* Returns the longest of up to 10 different tuples.
*/
export type Longest<T1 extends any[], T2 extends any[] = [], T3 extends any[] = [], T4 extends any[] = [], T5 extends any[] = [], T6 extends any[] = [], T7 extends any[] = [], T8 extends any[] = [], T9 extends any[] = [], T10 extends any[] = []> = _Longest<_Longest<_Longest<_Longest<T1, T2>, _Longest<T3, T4>>, _Longest<_Longest<T5, T6>, _Longest<T7, T8>>>, _Longest<T9, T10>>;
/**
* A rigorous type alias for a class.
*/
export type Class<CtorArgs extends any[] = any[], InstanceType = {}, StaticType = {}, IsAbstract = false> = (abstract new (...args: any[]) => InstanceType) & StaticType;
export {};

27
node_modules/ts-mixer/dist/types/util.d.ts generated vendored Normal file
View file

@ -0,0 +1,27 @@
/**
* Utility function that works like `Object.apply`, but copies getters and setters properly as well. Additionally gives
* the option to exclude properties by name.
*/
export declare const copyProps: (dest: object, src: object, exclude?: string[]) => void;
/**
* Returns the full chain of prototypes up until Object.prototype given a starting object. The order of prototypes will
* be closest to farthest in the chain.
*/
export declare const protoChain: (obj: object, currentChain?: object[]) => object[];
/**
* Identifies the nearest ancestor common to all the given objects in their prototype chains. For most unrelated
* objects, this function should return Object.prototype.
*/
export declare const nearestCommonProto: (...objs: object[]) => object | undefined;
/**
* Creates a new prototype object that is a mixture of the given prototypes. The mixing is achieved by first
* identifying the nearest common ancestor and using it as the prototype for a new object. Then all properties/methods
* downstream of this prototype (ONLY downstream) are copied into the new object.
*
* The resulting prototype is more performant than softMixProtos(...), as well as ES5 compatible. However, it's not as
* flexible as updates to the source prototypes aren't captured by the mixed result. See softMixProtos for why you may
* want to use that instead.
*/
export declare const hardMixProtos: (ingredients: any[], constructor: Function | null, exclude?: string[]) => object;
export declare const unique: <T>(arr: T[]) => T[];
export declare const flatten: <T>(arr: T[][]) => T[];

63
node_modules/ts-mixer/package.json generated vendored Normal file
View file

@ -0,0 +1,63 @@
{
"name": "ts-mixer",
"version": "6.0.4",
"description": "A very small TypeScript library that provides tolerable Mixin functionality.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"browser": "dist/esm/index.js",
"unpkg": "dist/esm/index.min.js",
"types": "dist/types/index.d.ts",
"files": [
"dist"
],
"scripts": {
"prebuild": "yarn clean",
"build": "rollup -c && tsc",
"clean": "rimraf dist",
"lint": "eslint src/**/*.ts",
"test": "nyc mocha",
"codegen": "node ./codegen.js",
"release": "standard-version"
},
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@rollup/plugin-typescript": "^8.2.1",
"@types/chai": "^4.2.19",
"@types/mocha": "^8.2.2",
"@types/node": "^15.12.4",
"@types/sinon": "^10.0.2",
"@typescript-eslint/parser": "^4.27.0",
"chai": "^4.3.4",
"class-validator": "^0.13.1",
"coveralls": "^3.1.0",
"eslint": "^7.29.0",
"husky": "^4.2.5",
"js-yaml": "^4.1.0",
"mocha": "^9.0.1",
"nyc": "14.1.1",
"rimraf": "^3.0.2",
"rollup": "^2.52.1",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^11.1.1",
"standard-version": "^9.3.0",
"ts-node": "^10.0.0",
"tslib": "^2.3.0",
"typescript": "^4.3.4",
"yarn-add-no-save": "^1.0.3"
},
"homepage": "https://github.com/tannerntannern/ts-mixer#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/tannerntannern/ts-mixer.git"
},
"keywords": [
"typescript",
"mixin",
"mixins",
"multiple inheritance",
"mixin classes"
],
"author": "Tanner Nielsen",
"license": "MIT"
}