@halospv3/hce.shared-config 3.4.6-develop.1 → 3.4.6-develop.2
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/mjs/CaseInsensitiveMap.d.mts +15 -0
- package/mjs/CaseInsensitiveMap.d.mts.map +1 -0
- package/mjs/CaseInsensitiveMap.mjs +2 -33
- package/mjs/CaseInsensitiveMap.mjs.map +1 -1
- package/mjs/commitlintConfig.d.mts +15 -0
- package/mjs/commitlintConfig.d.mts.map +1 -0
- package/mjs/commitlintConfig.mjs +2 -13
- package/mjs/commitlintConfig.mjs.map +1 -1
- package/mjs/debug.d.mts +9 -0
- package/mjs/debug.d.mts.map +1 -0
- package/mjs/debug.mjs +2 -9
- package/mjs/debug.mjs.map +1 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts +42 -0
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts.map +1 -0
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs +2 -43
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts +65 -0
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts.map +1 -0
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +2 -99
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.d.mts +1 -0
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +2 -44
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProject.d.mts +267 -0
- package/mjs/dotnet/MSBuildProject.d.mts.map +1 -0
- package/mjs/dotnet/MSBuildProject.mjs +3 -490
- package/mjs/dotnet/MSBuildProject.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.d.mts +172 -0
- package/mjs/dotnet/MSBuildProjectProperties.d.mts.map +1 -0
- package/mjs/dotnet/MSBuildProjectProperties.mjs +2 -260
- package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetProjectProperties.d.mts +381 -0
- package/mjs/dotnet/NugetProjectProperties.d.mts.map +1 -0
- package/mjs/dotnet/NugetProjectProperties.mjs +2 -577
- package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetRegistryInfo.d.mts +387 -0
- package/mjs/dotnet/NugetRegistryInfo.d.mts.map +1 -0
- package/mjs/dotnet/NugetRegistryInfo.mjs +4 -752
- package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/helpers.d.mts +66 -0
- package/mjs/dotnet/helpers.d.mts.map +1 -0
- package/mjs/dotnet/helpers.mjs +2 -354
- package/mjs/dotnet/helpers.mjs.map +1 -1
- package/mjs/dotnet/index.d.mts +8 -0
- package/mjs/dotnet/index.mjs +1 -9
- package/mjs/dotnet.d.mts +8 -0
- package/mjs/dotnet.mjs +1 -9
- package/mjs/eslintConfig.d.mts +7 -0
- package/mjs/eslintConfig.d.mts.map +1 -0
- package/mjs/eslintConfig.mjs +2 -64
- package/mjs/eslintConfig.mjs.map +1 -1
- package/mjs/index.d.mts +2 -0
- package/mjs/index.mjs +1 -4
- package/mjs/insertPlugins.d.mts +22 -0
- package/mjs/insertPlugins.d.mts.map +1 -0
- package/mjs/insertPlugins.mjs +2 -73
- package/mjs/insertPlugins.mjs.map +1 -1
- package/mjs/semantic-release__commit-analyzer.d.mts +44 -0
- package/mjs/semantic-release__commit-analyzer.d.mts.map +1 -0
- package/mjs/semantic-release__exec.d.mts +17 -0
- package/mjs/semantic-release__exec.d.mts.map +1 -0
- package/mjs/semantic-release__git.d.mts +83 -0
- package/mjs/semantic-release__git.d.mts.map +1 -0
- package/mjs/semantic-release__github.d.mts +141 -0
- package/mjs/semantic-release__github.d.mts.map +1 -0
- package/mjs/semanticReleaseConfig.d.mts +94 -0
- package/mjs/semanticReleaseConfig.d.mts.map +1 -0
- package/mjs/semanticReleaseConfig.mjs +2 -63
- package/mjs/semanticReleaseConfig.mjs.map +1 -1
- package/mjs/semanticReleaseConfigDotnet.d.mts +96 -0
- package/mjs/semanticReleaseConfigDotnet.d.mts.map +1 -0
- package/mjs/semanticReleaseConfigDotnet.mjs +7 -274
- package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -1
- package/mjs/setupGitPluginSpec.d.mts +18 -0
- package/mjs/setupGitPluginSpec.d.mts.map +1 -0
- package/mjs/setupGitPluginSpec.default.d.mts +13 -0
- package/mjs/setupGitPluginSpec.default.d.mts.map +1 -0
- package/mjs/setupGitPluginSpec.default.mjs +4 -0
- package/mjs/setupGitPluginSpec.default.mjs.map +1 -0
- package/mjs/setupGitPluginSpec.mjs +2 -144
- package/mjs/setupGitPluginSpec.mjs.map +1 -1
- package/mjs/utils/Exact.d.mts +18 -0
- package/mjs/utils/Exact.d.mts.map +1 -0
- package/mjs/utils/Exact.mjs +2 -75
- package/mjs/utils/Exact.mjs.map +1 -1
- package/mjs/utils/GracefulRecursion.d.mts +14 -0
- package/mjs/utils/GracefulRecursion.d.mts.map +1 -0
- package/mjs/utils/env.d.mts +28 -0
- package/mjs/utils/env.d.mts.map +1 -0
- package/mjs/utils/env.mjs +2 -47
- package/mjs/utils/env.mjs.map +1 -1
- package/mjs/utils/execAsync.d.mts +40 -0
- package/mjs/utils/execAsync.d.mts.map +1 -0
- package/mjs/utils/execAsync.mjs +10 -59
- package/mjs/utils/execAsync.mjs.map +1 -1
- package/mjs/utils/isError.d.mts +14 -0
- package/mjs/utils/isError.d.mts.map +1 -0
- package/mjs/utils/isError.mjs +2 -19
- package/mjs/utils/isError.mjs.map +1 -1
- package/mjs/utils/miscTypes.d.mts +16 -0
- package/mjs/utils/miscTypes.d.mts.map +1 -0
- package/mjs/utils/miscTypes.mjs +2 -10
- package/mjs/utils/miscTypes.mjs.map +1 -1
- package/mjs/utils/reflection/FunctionLike.d.mts +17 -0
- package/mjs/utils/reflection/FunctionLike.d.mts.map +1 -0
- package/mjs/utils/reflection/GetterDescriptor.d.mts +11 -0
- package/mjs/utils/reflection/GetterDescriptor.d.mts.map +1 -0
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mts +26 -0
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mts.map +1 -0
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts +17 -0
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts.map +1 -0
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts +18 -0
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts.map +1 -0
- package/mjs/utils/reflection/OwnKeyOf.d.mts +15 -0
- package/mjs/utils/reflection/OwnKeyOf.d.mts.map +1 -0
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mts +15 -0
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mts.map +1 -0
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts +13 -0
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts.map +1 -0
- package/mjs/utils/reflection/filterForGetters.d.mts +11 -0
- package/mjs/utils/reflection/filterForGetters.d.mts.map +1 -0
- package/mjs/utils/reflection/filterForGetters.mjs +2 -27
- package/mjs/utils/reflection/filterForGetters.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.mts +26 -0
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.mts.map +1 -0
- package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs +2 -34
- package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.mts +51 -0
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.mts.map +1 -0
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +2 -72
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts +19 -0
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts.map +1 -0
- package/mjs/utils/reflection/getPrototypeChainOf.mjs +2 -55
- package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeOf.d.mts +12 -0
- package/mjs/utils/reflection/getPrototypeOf.d.mts.map +1 -0
- package/mjs/utils/reflection/getPrototypeOf.mjs +2 -10
- package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -1
- package/mjs/utils/reflection/inheritance.d.mts +173 -0
- package/mjs/utils/reflection/inheritance.d.mts.map +1 -0
- package/mjs/utils/reflection/inheritance.mjs +2 -148
- package/mjs/utils/reflection/inheritance.mjs.map +1 -1
- package/mjs/utils/reflection/isConstructor.d.mts +20 -0
- package/mjs/utils/reflection/isConstructor.d.mts.map +1 -0
- package/mjs/utils/reflection/isConstructor.mjs +2 -63
- package/mjs/utils/reflection/isConstructor.mjs.map +1 -1
- package/mjs/utils/reflection/isGetterDescriptor.d.mts +13 -0
- package/mjs/utils/reflection/isGetterDescriptor.d.mts.map +1 -0
- package/mjs/utils/reflection/isGetterDescriptor.mjs +2 -12
- package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -1
- package/mjs/utils/reflection/listOwnGetters.d.mts +29 -0
- package/mjs/utils/reflection/listOwnGetters.d.mts.map +1 -0
- package/mjs/utils/reflection/listOwnGetters.mjs +2 -39
- package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -1
- package/mjs/utils/reflection.d.mts +18 -0
- package/mjs/utils/reflection.mjs +1 -10
- package/package.json +99 -62
- package/src/debug.ts +1 -0
- package/src/dotnet/GithubNugetRegistryInfo.ts +4 -4
- package/src/dotnet/GitlabNugetRegistryInfo.ts +5 -5
- package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +2 -1
- package/src/dotnet/MSBuildProject.ts +7 -6
- package/src/dotnet/MSBuildProjectProperties.ts +4 -3
- package/src/dotnet/NugetProjectProperties.ts +4 -4
- package/src/dotnet/NugetRegistryInfo.ts +9 -8
- package/src/dotnet/helpers.ts +5 -4
- package/src/dotnet/index.ts +8 -8
- package/src/dotnet.ts +1 -1
- package/src/index.ts +1 -1
- package/src/semanticReleaseConfig.ts +5 -1
- package/src/semanticReleaseConfigDotnet.ts +10 -8
- package/src/setupGitPluginSpec.default.ts +22 -0
- package/src/setupGitPluginSpec.ts +4 -21
- package/src/tsconfig.json +1 -2
- package/src/utils/execAsync.ts +1 -1
- package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +1 -1
- package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +2 -2
- package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +2 -2
- package/src/utils/reflection/filterForGetters.ts +5 -5
- package/src/utils/reflection/getOwnPropertyDescriptors.ts +4 -4
- package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +12 -12
- package/src/utils/reflection/getPrototypeChainOf.ts +5 -5
- package/src/utils/reflection/getPrototypeOf.ts +1 -1
- package/src/utils/reflection/inheritance.ts +5 -5
- package/src/utils/reflection/isGetterDescriptor.ts +1 -1
- package/src/utils/reflection/listOwnGetters.ts +6 -6
- package/src/utils/reflection.ts +17 -17
- package/tsconfig.base.json +2 -2
- package/mjs/CaseInsensitiveMap.d.ts +0 -12
- package/mjs/CaseInsensitiveMap.d.ts.map +0 -1
- package/mjs/commitlintConfig.d.ts +0 -12
- package/mjs/commitlintConfig.d.ts.map +0 -1
- package/mjs/debug.d.ts +0 -6
- package/mjs/debug.d.ts.map +0 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.d.ts +0 -38
- package/mjs/dotnet/GithubNugetRegistryInfo.d.ts.map +0 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.ts +0 -61
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.ts.map +0 -1
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.d.ts +0 -2
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.d.ts.map +0 -1
- package/mjs/dotnet/MSBuildProject.d.ts +0 -264
- package/mjs/dotnet/MSBuildProject.d.ts.map +0 -1
- package/mjs/dotnet/MSBuildProjectProperties.d.ts +0 -170
- package/mjs/dotnet/MSBuildProjectProperties.d.ts.map +0 -1
- package/mjs/dotnet/NugetProjectProperties.d.ts +0 -379
- package/mjs/dotnet/NugetProjectProperties.d.ts.map +0 -1
- package/mjs/dotnet/NugetRegistryInfo.d.ts +0 -384
- package/mjs/dotnet/NugetRegistryInfo.d.ts.map +0 -1
- package/mjs/dotnet/helpers.d.ts +0 -63
- package/mjs/dotnet/helpers.d.ts.map +0 -1
- package/mjs/dotnet/index.d.ts +0 -9
- package/mjs/dotnet/index.d.ts.map +0 -1
- package/mjs/dotnet/index.mjs.map +0 -1
- package/mjs/dotnet.d.ts +0 -2
- package/mjs/dotnet.d.ts.map +0 -1
- package/mjs/dotnet.mjs.map +0 -1
- package/mjs/eslintConfig.d.ts +0 -4
- package/mjs/eslintConfig.d.ts.map +0 -1
- package/mjs/index.d.ts +0 -3
- package/mjs/index.d.ts.map +0 -1
- package/mjs/index.mjs.map +0 -1
- package/mjs/insertPlugins.d.ts +0 -18
- package/mjs/insertPlugins.d.ts.map +0 -1
- package/mjs/semantic-release__commit-analyzer.d.mjs +0 -2
- package/mjs/semantic-release__commit-analyzer.d.mjs.map +0 -1
- package/mjs/semantic-release__exec.d.mjs +0 -2
- package/mjs/semantic-release__exec.d.mjs.map +0 -1
- package/mjs/semantic-release__git.d.mjs +0 -2
- package/mjs/semantic-release__git.d.mjs.map +0 -1
- package/mjs/semantic-release__github.d.mjs +0 -2
- package/mjs/semantic-release__github.d.mjs.map +0 -1
- package/mjs/semanticReleaseConfig.d.ts +0 -97
- package/mjs/semanticReleaseConfig.d.ts.map +0 -1
- package/mjs/semanticReleaseConfigDotnet.d.ts +0 -112
- package/mjs/semanticReleaseConfigDotnet.d.ts.map +0 -1
- package/mjs/setupGitPluginSpec.d.ts +0 -22
- package/mjs/setupGitPluginSpec.d.ts.map +0 -1
- package/mjs/utils/Exact.d.ts +0 -20
- package/mjs/utils/Exact.d.ts.map +0 -1
- package/mjs/utils/GracefulRecursion.d.mjs +0 -2
- package/mjs/utils/GracefulRecursion.d.mjs.map +0 -1
- package/mjs/utils/env.d.ts +0 -24
- package/mjs/utils/env.d.ts.map +0 -1
- package/mjs/utils/execAsync.d.ts +0 -37
- package/mjs/utils/execAsync.d.ts.map +0 -1
- package/mjs/utils/isError.d.ts +0 -11
- package/mjs/utils/isError.d.ts.map +0 -1
- package/mjs/utils/miscTypes.d.ts +0 -12
- package/mjs/utils/miscTypes.d.ts.map +0 -1
- package/mjs/utils/reflection/FunctionLike.d.mjs +0 -2
- package/mjs/utils/reflection/FunctionLike.d.mjs.map +0 -1
- package/mjs/utils/reflection/GetterDescriptor.d.mjs +0 -2
- package/mjs/utils/reflection/GetterDescriptor.d.mjs.map +0 -1
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mjs +0 -2
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mjs.map +0 -1
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mjs +0 -2
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mjs.map +0 -1
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mjs +0 -2
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mjs.map +0 -1
- package/mjs/utils/reflection/OwnKeyOf.d.mjs +0 -2
- package/mjs/utils/reflection/OwnKeyOf.d.mjs.map +0 -1
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mjs +0 -2
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mjs.map +0 -1
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mjs +0 -2
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mjs.map +0 -1
- package/mjs/utils/reflection/filterForGetters.d.ts +0 -7
- package/mjs/utils/reflection/filterForGetters.d.ts.map +0 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.ts +0 -22
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.ts.map +0 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.ts +0 -56
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.ts.map +0 -1
- package/mjs/utils/reflection/getPrototypeChainOf.d.ts +0 -16
- package/mjs/utils/reflection/getPrototypeChainOf.d.ts.map +0 -1
- package/mjs/utils/reflection/getPrototypeOf.d.ts +0 -8
- package/mjs/utils/reflection/getPrototypeOf.d.ts.map +0 -1
- package/mjs/utils/reflection/inheritance.d.ts +0 -180
- package/mjs/utils/reflection/inheritance.d.ts.map +0 -1
- package/mjs/utils/reflection/isConstructor.d.ts +0 -17
- package/mjs/utils/reflection/isConstructor.d.ts.map +0 -1
- package/mjs/utils/reflection/isGetterDescriptor.d.ts +0 -9
- package/mjs/utils/reflection/isGetterDescriptor.d.ts.map +0 -1
- package/mjs/utils/reflection/listOwnGetters.d.ts +0 -26
- package/mjs/utils/reflection/listOwnGetters.d.ts.map +0 -1
- package/mjs/utils/reflection.d.ts +0 -18
- package/mjs/utils/reflection.d.ts.map +0 -1
- package/mjs/utils/reflection.mjs.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Increment } from "../GracefulRecursion.mjs";
|
|
2
|
+
import { FunctionLike } from "./FunctionLike.mjs";
|
|
3
|
+
import { PropertyDescriptorMap } from "./PropertyDescriptorMap.mjs";
|
|
4
|
+
import { Integer } from "../miscTypes.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/reflection/inheritance.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The `[[Prototype]]` (i.e. `__proto__`) of any base class.
|
|
9
|
+
* @since 3.0.0
|
|
10
|
+
*/
|
|
11
|
+
type BaseClassProto = (() => object) & {
|
|
12
|
+
/** @example BaseClass.__proto__.__proto__.toString() === '[object Object]' */["__proto__"]: ObjectConstructor["prototype"] & {
|
|
13
|
+
["__proto__"]: null;
|
|
14
|
+
constructor: ObjectConstructor;
|
|
15
|
+
};
|
|
16
|
+
constructor: IBaseClass;
|
|
17
|
+
length: 0;
|
|
18
|
+
name: "";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The `[[Prototype]]` of all base classes.
|
|
22
|
+
* @since 3.0.0
|
|
23
|
+
*/
|
|
24
|
+
declare const baseClassProto: BaseClassProto;
|
|
25
|
+
/**
|
|
26
|
+
* [INTERNAL]
|
|
27
|
+
* An interface representing for attaching base class properties to a class type.
|
|
28
|
+
* This kept separate from {@link BaseClass} so it can be used by {@link BaseClassProto}.
|
|
29
|
+
* @since 3.0.0
|
|
30
|
+
*/
|
|
31
|
+
interface IBaseClass {
|
|
32
|
+
/**
|
|
33
|
+
* Readable for compatibility reasons, but invisible and non-enumerable in Node.js runtime.
|
|
34
|
+
* @example BaseClass.__proto__.toString() === 'function () { [native code] }'
|
|
35
|
+
*/
|
|
36
|
+
["__proto__"]: BaseClassProto;
|
|
37
|
+
constructor: FunctionConstructor & {
|
|
38
|
+
name: "Function";
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Type a class type as a base class.
|
|
43
|
+
* Note: is `Class & ...`
|
|
44
|
+
* @since 3.0.0
|
|
45
|
+
*/
|
|
46
|
+
type BaseClass<Class extends ConstructorConstraint<Class>> = IClass<Class> & IBaseClass;
|
|
47
|
+
/**
|
|
48
|
+
* A type representing any unknown constructor.
|
|
49
|
+
* @since 3.0.0
|
|
50
|
+
*/
|
|
51
|
+
type Constructor_Unknown = abstract new (...args: any[]) => any;
|
|
52
|
+
/**
|
|
53
|
+
* The constraint for constructor types.
|
|
54
|
+
* This is intended for generic type constraints.
|
|
55
|
+
* For conditional return types, use `T extends Constructor<T>` instead.
|
|
56
|
+
* @template T Any newable constructor type
|
|
57
|
+
* @since 3.0.0
|
|
58
|
+
*/
|
|
59
|
+
type ConstructorConstraint<T extends abstract new (...args: ConstructorParameters<T>) => InstanceType<T>> = abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>;
|
|
60
|
+
/**
|
|
61
|
+
* {@link T} is a class constructor or unknown constructor. Else, `never`.
|
|
62
|
+
*
|
|
63
|
+
* Consider using {@link ClassLike} where walking the inheritance chain is necessary.
|
|
64
|
+
* @template [T=Constructor_Unknown]
|
|
65
|
+
* @since 3.0.0
|
|
66
|
+
*/
|
|
67
|
+
type ConstructorLike<T = Constructor_Unknown> = T extends Constructor_Unknown ? T extends ConstructorConstraint<T> ? T & ConstructorConstraint<T> : T & Constructor_Unknown : never;
|
|
68
|
+
/**
|
|
69
|
+
* A type representing unknown {@link ClassLike} types.
|
|
70
|
+
* @since 3.0.0
|
|
71
|
+
*/
|
|
72
|
+
type ClassLike_Unknown = IClass<Constructor_Unknown & WithProto<SuperClassLike | BaseClassProto>>;
|
|
73
|
+
/**
|
|
74
|
+
* A subset of {@link ProtoOrSuperClass} suitable for a class's `[[Prototype]]`
|
|
75
|
+
* @since 3.0.0
|
|
76
|
+
*/
|
|
77
|
+
type SuperClassLike = BaseClass<Constructor_Unknown> | ClassLike_Unknown;
|
|
78
|
+
/**
|
|
79
|
+
* A terrible type. Use it if you must, but prefer other types when possible.
|
|
80
|
+
*
|
|
81
|
+
* Covers most SuperClass/Prototype types.
|
|
82
|
+
* A class that does not extend another class will satisfy {@link BaseClass}.
|
|
83
|
+
*
|
|
84
|
+
* If a type extends {@link ProtoOrSuperClass} and is `null`, you cannot get the
|
|
85
|
+
* type's keys. See {@link ./OwnKeyOf.ts}.
|
|
86
|
+
* @template [T=ReturnType<typeof Reflect.getPrototypeOf>] `null` or an `object`-like type.
|
|
87
|
+
* @since 3.0.0
|
|
88
|
+
*/
|
|
89
|
+
type ProtoOrSuperClass<T extends object | null = ReturnType<typeof Reflect.getPrototypeOf>> = T extends null ? null : T extends object ? T extends ConstructorLike<T> ? T extends ClassLike<T & WithProto<SuperClassLike | BaseClassProto>> ? T extends BaseClass<T> ? ClassLike<BaseClass<T>> : ClassLike<T> : T extends BaseClass<T> ? BaseClass<T> : ConstructorLike<T> : T extends FunctionLike<infer FunctionConstraint> ? T extends FunctionConstraint ? FunctionLike<T> : T & FunctionLike<FunctionConstraint> : T extends object ? T & object : never : never;
|
|
90
|
+
/**
|
|
91
|
+
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of any `object`-like type.
|
|
92
|
+
* Not to be confused with the _instance_ `.prototype` chain!
|
|
93
|
+
* ```
|
|
94
|
+
* > util.isDeepStrictEqual(Object.getOwnPropertyDescriptors({}.__proto__), Object.getOwnPropertyDescriptors(Object.prototype))
|
|
95
|
+
* true
|
|
96
|
+
* ```
|
|
97
|
+
* @template Object0 Any type with its `[[Prototype]]` attached as a `__proto__` property. The type of `__proto__` must extend {@link ProtoOrSuperClass}.
|
|
98
|
+
* @template [Limit=16]
|
|
99
|
+
* The maximum depth of recursion.
|
|
100
|
+
* Affects the maximum length of the returned type.\
|
|
101
|
+
* CAUTION: Larger values will severely degrade performance.
|
|
102
|
+
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
103
|
+
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
104
|
+
* @since 3.0.0
|
|
105
|
+
*/
|
|
106
|
+
type ProtoChainOfObject<Object0 extends WithProto<ProtoOrSuperClass>, Limit extends Integer<number> = 16, CurrentLevel extends Integer<number> = 0> = PropertyDescriptorMap<Object0["__proto__"]> extends PropertyDescriptorMap<ObjectConstructor["prototype"]> ? [Object0] : Object0["__proto__"] extends WithProto<ProtoOrSuperClass> ? CurrentLevel extends Limit ? [Object0] : [Object0, ...ProtoChainOfObject<Object0["__proto__"], Limit, Increment<CurrentLevel>>] : never;
|
|
107
|
+
/**
|
|
108
|
+
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of an object (particularly, a class).
|
|
109
|
+
* @template Class Any type with its `[[Prototype]]` attached as a `__proto__` property.
|
|
110
|
+
* The type of `__proto__` must extend {@link SuperClassLike} or {@link BaseClassProto}.
|
|
111
|
+
* @template [Limit=16]
|
|
112
|
+
* The maximum depth of recursion.
|
|
113
|
+
* Affects the maximum length of the returned type.\
|
|
114
|
+
* CAUTION: Larger values will severely degrade performance.
|
|
115
|
+
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
116
|
+
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
117
|
+
* @since 3.0.0
|
|
118
|
+
*/
|
|
119
|
+
type ProtoChainOfClass<Class extends WithProto<SuperClassLike | BaseClassProto>, Limit extends Integer<number> = 16, CurrentLevel extends Integer<number> = 0> = Class["__proto__"] extends BaseClassProto ? [Class] : Class["__proto__"] extends SuperClassLike ? CurrentLevel extends Limit ? [Class] : [Class, ...ProtoChainOfClass<Class["__proto__"], Limit, Increment<CurrentLevel>>] : never;
|
|
120
|
+
/**
|
|
121
|
+
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of a class instance.
|
|
122
|
+
* @template Class A constructor type with its `[[Prototype]]` attached as a `__proto__` property.
|
|
123
|
+
* @template [Limit=16]
|
|
124
|
+
* The maximum depth of recursion.
|
|
125
|
+
* Affects the maximum length of the returned type.\
|
|
126
|
+
* CAUTION: Larger values will severely degrade performance.
|
|
127
|
+
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
128
|
+
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
129
|
+
* @since 3.0.0
|
|
130
|
+
*/
|
|
131
|
+
type ProtoChainOfClassInstance<Class extends ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>, Limit extends Integer<number> = 16, CurrentLevel extends Integer<number> = 0> = Class["__proto__"] extends BaseClassProto ? [InstanceType<Class>] : Class["__proto__"] extends SuperClassLike ? CurrentLevel extends Limit ? [InstanceType<Class>] : [InstanceType<Class>, ...ProtoChainOfClassInstance<Class["__proto__"], Limit, Increment<CurrentLevel>>] : never;
|
|
132
|
+
/**
|
|
133
|
+
* Augment a class type to expose properties not exposed by TypeScript by default.
|
|
134
|
+
* Note: is `Class & ...`
|
|
135
|
+
* @template Class The typeof any class. If the type is unknown, wrap it with {@link ConstructorConstraint}.
|
|
136
|
+
* @since 3.0.0
|
|
137
|
+
*/
|
|
138
|
+
type IClass<Class extends ConstructorConstraint<Class>> = Class & {
|
|
139
|
+
prototype: InstanceType<Class>;
|
|
140
|
+
name: ConstructorConstraint<Class>["name"];
|
|
141
|
+
length: ConstructorConstraint<Class>["length"];
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* A more fleshed-out Class type.
|
|
145
|
+
*
|
|
146
|
+
* Note: is `Class & ...`
|
|
147
|
+
*
|
|
148
|
+
* In addition to the Constructor constraint, this type...
|
|
149
|
+
* - Sets the type of the immediate superclass.
|
|
150
|
+
* - Sets `prototype` to {@link InstanceType}
|
|
151
|
+
* @template Class The `typeof MyClass`. If this class extends a class, pass `typeof MySuperClass` to the generic argument {@link Class}.
|
|
152
|
+
* @example
|
|
153
|
+
* type Class_MyClass = ClassLike<typeof MyClass & WithProto<BaseClass<typeof MyBaseClass>>;
|
|
154
|
+
* @since 3.0.0
|
|
155
|
+
*/
|
|
156
|
+
type ClassLike<Class extends ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>> = Class extends BaseClass<Class> ? Class : Class["__proto__"] extends BaseClassProto ? BaseClass<Class> : Class["__proto__"] extends ConstructorLike<Class["__proto__"]> ? IClass<Class> & WithProto<ConstructorLike<Class["__proto__"]>> : IClass<Class>;
|
|
157
|
+
/**
|
|
158
|
+
* If {@link T} is a class or constructor, {@link InstanceType}<{@link T}>. Else, {@link T}.
|
|
159
|
+
* @template T `null` or any `object`-like type.
|
|
160
|
+
* @since 3.0.0
|
|
161
|
+
*/
|
|
162
|
+
type InstanceTypeOrSelf<T extends object | null> = T extends ConstructorLike ? T extends ConstructorLike<T> ? InstanceType<T> : T : T;
|
|
163
|
+
/**
|
|
164
|
+
* Interface for attaching a `__proto__` to an object e.g. `T0 & WithProto<T1>`
|
|
165
|
+
* @template __proto__ the type of the an object's `[[Prototype]]`.
|
|
166
|
+
* @since 3.0.0
|
|
167
|
+
*/
|
|
168
|
+
interface WithProto<__proto__ extends ProtoOrSuperClass> {
|
|
169
|
+
["__proto__"]: __proto__;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { BaseClass, BaseClassProto, ClassLike, ClassLike_Unknown, ConstructorConstraint, ConstructorLike, Constructor_Unknown, IClass, InstanceTypeOrSelf, ProtoChainOfClass, ProtoChainOfClassInstance, ProtoChainOfObject, ProtoOrSuperClass, SuperClassLike, WithProto, baseClassProto };
|
|
173
|
+
//# sourceMappingURL=inheritance.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inheritance.d.mts","names":[],"sources":["../../../src/utils/reflection/inheritance.ts"],"mappings":";;;;;;;;AAUA;;KAAY,cAAA;iFAET,WAAA,GAAc,iBAAA;IAAA,CACZ,WAAA;IACD,WAAA,EAAa,iBAAA;EAAA;EAEf,WAAA,EAAa,UAAA;EACb,MAAA;EACA,IAAA;AAAA;;;;;cAOW,cAAA,EAAgB,cAAA;;;AAA7B;;;;UAQU,UAAA;EARmB;;;;EAAA,CAa1B,WAAA,GAAc,cAAA;EAEf,WAAA,EAAa,mBAAA;IAAwB,IAAA;EAAA;AAAA;;;AAQvC;;;KAAY,SAAA,eAAwB,qBAAA,CAAsB,KAAA,KACtD,MAAA,CAAO,KAAA,IAAS,UAAA;;;;;KAOR,mBAAA,oBAAuC,IAAA;;;;;;;;KASvC,qBAAA,4BAAiD,IAAA,EAAM,qBAAA,CAAsB,CAAA,MAAO,YAAA,CAAa,CAAA,sBAAuB,UAAA,EAAY,qBAAA,CAAsB,CAAA,MAAO,YAAA,CAAa,CAAA;;AAT1L;;;;;AASA;KASY,eAAA,KAAoB,mBAAA,IAC5B,CAAA,SAAU,mBAAA,GACR,CAAA,SAAU,qBAAA,CAAsB,CAAA,IAC9B,CAAA,GAAI,qBAAA,CAAsB,CAAA,IAC1B,CAAA,GAAI,mBAAA;;;;;KAOA,iBAAA,GACR,MAAA,CACA,mBAAA,GACE,SAAA,CAAU,cAAA,GAAiB,cAAA;;;;;KAOrB,cAAA,GAAiB,SAAA,CAAU,mBAAA,IAAuB,iBAAA;;;;;;;;;;;;KAalD,iBAAA,2BAA4C,UAAA,QAAkB,OAAA,CAAQ,cAAA,KAC9E,CAAA,uBACE,CAAA,kBACE,CAAA,SAAU,eAAA,CAAgB,CAAA,IACxB,CAAA,SAAU,SAAA,CAAU,CAAA,GAAI,SAAA,CAAU,cAAA,GAAiB,cAAA,KACjD,CAAA,SAAU,SAAA,CAAU,CAAA,IAAK,SAAA,CAAU,SAAA,CAAU,CAAA,KAC3C,SAAA,CAAU,CAAA,IACZ,CAAA,SAAU,SAAA,CAAU,CAAA,IAClB,SAAA,CAAU,CAAA,IACV,eAAA,CAAgB,CAAA,IACpB,CAAA,SAAU,YAAA,6BACR,CAAA,SAAU,kBAAA,GACR,YAAA,CAAa,CAAA,IACb,CAAA,GAAI,YAAA,CAAa,kBAAA,IACnB,CAAA,kBACE,CAAA;;;AAjDd;;;;;;;;;;;;;;KAqEY,kBAAA,iBACM,SAAA,CAAU,iBAAA,iBACZ,OAAA,oCACO,OAAA,gBACnB,qBAAA,CAAsB,OAAA,uBAA8B,qBAAA,CAAsB,iBAAA,kBACzE,OAAA,IACD,OAAA,sBAA6B,SAAA,CAAU,iBAAA,IACrC,YAAA,SAAqB,KAAA,IAAS,OAAA,KAE1B,OAAA,KACG,kBAAA,CAAmB,OAAA,eAAsB,KAAA,EAAO,SAAA,CAAU,YAAA;;;;;;;;;;;;AApEvE;KAoFY,iBAAA,eACI,SAAA,CAAU,cAAA,GAAiB,cAAA,iBAC3B,OAAA,oCACO,OAAA,gBACnB,KAAA,sBAA2B,cAAA,IAAkB,KAAA,IAC7C,KAAA,sBAA2B,cAAA,GACzB,YAAA,SAAqB,KAAA,IAAS,KAAA,KAE1B,KAAA,KACG,iBAAA,CAAkB,KAAA,eAAoB,KAAA,EAAO,SAAA,CAAU,YAAA;;;;;;;;;;;;KAexD,yBAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAU,cAAA,GAAiB,cAAA,iBAC1D,OAAA,oCACO,OAAA,gBACnB,KAAA,sBAA2B,cAAA,IAAkB,YAAA,CAAa,KAAA,KAC1D,KAAA,sBAA2B,cAAA,GACzB,YAAA,SAAqB,KAAA,IAAS,YAAA,CAAa,KAAA,MAEvC,YAAA,CAAa,KAAA,MACV,yBAAA,CAA0B,KAAA,eAAoB,KAAA,EAAO,SAAA,CAAU,YAAA;;;;;;;KAWhE,MAAA,eAAqB,qBAAA,CAAsB,KAAA,KACnD,KAAA;EAEE,SAAA,EAAW,YAAA,CAAa,KAAA;EACxB,IAAA,EAAM,qBAAA,CAAsB,KAAA;EAC5B,MAAA,EAAQ,qBAAA,CAAsB,KAAA;AAAA;;;;;;;;;;;;;;KAgBxB,SAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAU,cAAA,GAAiB,cAAA,KACtE,KAAA,SAAc,SAAA,CAAU,KAAA,IAAS,KAAA,GACjC,KAAA,sBAA2B,cAAA,GAAiB,SAAA,CAAU,KAAA,IACpD,KAAA,sBAA2B,eAAA,CAAgB,KAAA,iBACzC,MAAA,CAAO,KAAA,IAAS,SAAA,CAAU,eAAA,CAAgB,KAAA,kBAE1C,MAAA,CAAO,KAAA;;;;;;KAOH,kBAAA,4BAA8C,CAAA,SAAU,eAAA,GAChE,CAAA,SAAU,eAAA,CAAgB,CAAA,IACxB,YAAA,CAAa,CAAA,IACb,CAAA,GACF,CAAA;;;;;;UAOa,SAAA,mBAA4B,iBAAA;EAAA,CAC1C,WAAA,GAAc,SAAA;AAAA"}
|
|
@@ -1,148 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The `[[Prototype]]` (i.e. `__proto__`) of any base class.
|
|
5
|
-
* @since 3.0.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The `[[Prototype]]` of all base classes.
|
|
10
|
-
* @since 3.0.0
|
|
11
|
-
*/
|
|
12
|
-
const baseClassProto = getPrototypeOf(Object);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* [INTERNAL]
|
|
16
|
-
* An interface representing for attaching base class properties to a class type.
|
|
17
|
-
* This kept separate from {@link BaseClass} so it can be used by {@link BaseClassProto}.
|
|
18
|
-
* @since 3.0.0
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Type a class type as a base class.
|
|
23
|
-
* Note: is `Class & ...`
|
|
24
|
-
* @since 3.0.0
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A type representing any unknown constructor.
|
|
29
|
-
* @since 3.0.0
|
|
30
|
-
*/
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The constraint for constructor types.
|
|
35
|
-
* This is intended for generic type constraints.
|
|
36
|
-
* For conditional return types, use `T extends Constructor<T>` instead.
|
|
37
|
-
* @template T Any newable constructor type
|
|
38
|
-
* @since 3.0.0
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* {@link T} is a class constructor or unknown constructor. Else, `never`.
|
|
43
|
-
*
|
|
44
|
-
* Consider using {@link ClassLike} where walking the inheritance chain is necessary.
|
|
45
|
-
* @template [T=Constructor_Unknown]
|
|
46
|
-
* @since 3.0.0
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A type representing unknown {@link ClassLike} types.
|
|
51
|
-
* @since 3.0.0
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* A subset of {@link ProtoOrSuperClass} suitable for a class's `[[Prototype]]`
|
|
56
|
-
* @since 3.0.0
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* A terrible type. Use it if you must, but prefer other types when possible.
|
|
61
|
-
*
|
|
62
|
-
* Covers most SuperClass/Prototype types.
|
|
63
|
-
* A class that does not extend another class will satisfy {@link BaseClass}.
|
|
64
|
-
*
|
|
65
|
-
* If a type extends {@link ProtoOrSuperClass} and is `null`, you cannot get the
|
|
66
|
-
* type's keys. See {@link ./OwnKeyOf.ts}.
|
|
67
|
-
* @template [T=ReturnType<typeof Reflect.getPrototypeOf>] `null` or an `object`-like type.
|
|
68
|
-
* @since 3.0.0
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of any `object`-like type.
|
|
73
|
-
* Not to be confused with the _instance_ `.prototype` chain!
|
|
74
|
-
* ```
|
|
75
|
-
* > util.isDeepStrictEqual(Object.getOwnPropertyDescriptors({}.__proto__), Object.getOwnPropertyDescriptors(Object.prototype))
|
|
76
|
-
* true
|
|
77
|
-
* ```
|
|
78
|
-
* @template Object0 Any type with its `[[Prototype]]` attached as a `__proto__` property. The type of `__proto__` must extend {@link ProtoOrSuperClass}.
|
|
79
|
-
* @template [Limit=16]
|
|
80
|
-
* The maximum depth of recursion.
|
|
81
|
-
* Affects the maximum length of the returned type.\
|
|
82
|
-
* CAUTION: Larger values will severely degrade performance.
|
|
83
|
-
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
84
|
-
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
85
|
-
* @since 3.0.0
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of an object (particularly, a class).
|
|
90
|
-
* @template Class Any type with its `[[Prototype]]` attached as a `__proto__` property.
|
|
91
|
-
* The type of `__proto__` must extend {@link SuperClassLike} or {@link BaseClassProto}.
|
|
92
|
-
* @template [Limit=16]
|
|
93
|
-
* The maximum depth of recursion.
|
|
94
|
-
* Affects the maximum length of the returned type.\
|
|
95
|
-
* CAUTION: Larger values will severely degrade performance.
|
|
96
|
-
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
97
|
-
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
98
|
-
* @since 3.0.0
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of a class instance.
|
|
103
|
-
* @template Class A constructor type with its `[[Prototype]]` attached as a `__proto__` property.
|
|
104
|
-
* @template [Limit=16]
|
|
105
|
-
* The maximum depth of recursion.
|
|
106
|
-
* Affects the maximum length of the returned type.\
|
|
107
|
-
* CAUTION: Larger values will severely degrade performance.
|
|
108
|
-
* 50 or more will trigger infinite-or-near-infinite-recursion errors.
|
|
109
|
-
* @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.
|
|
110
|
-
* @since 3.0.0
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Augment a class type to expose properties not exposed by TypeScript by default.
|
|
115
|
-
* Note: is `Class & ...`
|
|
116
|
-
* @template Class The typeof any class. If the type is unknown, wrap it with {@link ConstructorConstraint}.
|
|
117
|
-
* @since 3.0.0
|
|
118
|
-
*/
|
|
119
|
-
// defined as `type` because interfaces cannot extend their generic parameters
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* A more fleshed-out Class type.
|
|
123
|
-
*
|
|
124
|
-
* Note: is `Class & ...`
|
|
125
|
-
*
|
|
126
|
-
* In addition to the Constructor constraint, this type...
|
|
127
|
-
* - Sets the type of the immediate superclass.
|
|
128
|
-
* - Sets `prototype` to {@link InstanceType}
|
|
129
|
-
* @template Class The `typeof MyClass`. If this class extends a class, pass `typeof MySuperClass` to the generic argument {@link Class}.
|
|
130
|
-
* @example
|
|
131
|
-
* type Class_MyClass = ClassLike<typeof MyClass & WithProto<BaseClass<typeof MyBaseClass>>;
|
|
132
|
-
* @since 3.0.0
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* If {@link T} is a class or constructor, {@link InstanceType}<{@link T}>. Else, {@link T}.
|
|
137
|
-
* @template T `null` or any `object`-like type.
|
|
138
|
-
* @since 3.0.0
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Interface for attaching a `__proto__` to an object e.g. `T0 & WithProto<T1>`
|
|
143
|
-
* @template __proto__ the type of the an object's `[[Prototype]]`.
|
|
144
|
-
* @since 3.0.0
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
export { baseClassProto };
|
|
148
|
-
//# sourceMappingURL=inheritance.mjs.map
|
|
1
|
+
import{getPrototypeOf as e}from"./getPrototypeOf.mjs";const t=e(Object);export{t as baseClassProto};
|
|
2
|
+
//# sourceMappingURL=inheritance.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inheritance.mjs","sources":["../../../src/utils/reflection/inheritance.ts"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACY,MAAC,cAAc,GAAG,cAAc,CAAC,MAAM;;AAEnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"inheritance.mjs","names":[],"sources":["../../../src/utils/reflection/inheritance.ts"],"sourcesContent":["import type { Increment } from '../GracefulRecursion.d.ts';\nimport type { Integer } from '../miscTypes.ts';\nimport type { FunctionLike } from './FunctionLike.d.ts';\nimport { getPrototypeOf } from './getPrototypeOf.ts';\nimport type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';\n\n/**\n * The `[[Prototype]]` (i.e. `__proto__`) of any base class.\n * @since 3.0.0\n */\nexport type BaseClassProto = (() => object) & {\n /** @example BaseClass.__proto__.__proto__.toString() === '[object Object]' */\n ['__proto__']: ObjectConstructor['prototype'] & {\n ['__proto__']: null;\n constructor: ObjectConstructor;\n };\n constructor: IBaseClass;\n length: 0;\n name: '';\n};\n\n/**\n * The `[[Prototype]]` of all base classes.\n * @since 3.0.0\n */\nexport const baseClassProto: BaseClassProto = getPrototypeOf(Object as BaseClass<ObjectConstructor>);\n\n/**\n * [INTERNAL]\n * An interface representing for attaching base class properties to a class type.\n * This kept separate from {@link BaseClass} so it can be used by {@link BaseClassProto}.\n * @since 3.0.0\n */\ninterface IBaseClass {\n /**\n * Readable for compatibility reasons, but invisible and non-enumerable in Node.js runtime.\n * @example BaseClass.__proto__.toString() === 'function () { [native code] }'\n */\n ['__proto__']: BaseClassProto;\n\n constructor: FunctionConstructor & { name: 'Function' };\n}\n\n/**\n * Type a class type as a base class.\n * Note: is `Class & ...`\n * @since 3.0.0\n */\nexport type BaseClass<Class extends ConstructorConstraint<Class>>\n = IClass<Class> & IBaseClass;\n\n/**\n * A type representing any unknown constructor.\n * @since 3.0.0\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Constructor_Unknown = abstract new (...args: any[]) => any;\n\n/**\n * The constraint for constructor types.\n * This is intended for generic type constraints.\n * For conditional return types, use `T extends Constructor<T>` instead.\n * @template T Any newable constructor type\n * @since 3.0.0\n */\nexport type ConstructorConstraint<T extends abstract new (...args: ConstructorParameters<T>) => InstanceType<T>> = abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>;\n\n/**\n * {@link T} is a class constructor or unknown constructor. Else, `never`.\n *\n * Consider using {@link ClassLike} where walking the inheritance chain is necessary.\n * @template [T=Constructor_Unknown]\n * @since 3.0.0\n */\nexport type ConstructorLike<T = Constructor_Unknown>\n = T extends Constructor_Unknown\n ? T extends ConstructorConstraint<T>\n ? T & ConstructorConstraint<T>\n : T & Constructor_Unknown\n : never;\n\n/**\n * A type representing unknown {@link ClassLike} types.\n * @since 3.0.0\n */\nexport type ClassLike_Unknown\n = IClass<\n Constructor_Unknown\n & WithProto<SuperClassLike | BaseClassProto>\n >;\n\n/**\n * A subset of {@link ProtoOrSuperClass} suitable for a class's `[[Prototype]]`\n * @since 3.0.0\n */\nexport type SuperClassLike = BaseClass<Constructor_Unknown> | ClassLike_Unknown;\n\n/**\n * A terrible type. Use it if you must, but prefer other types when possible.\n *\n * Covers most SuperClass/Prototype types.\n * A class that does not extend another class will satisfy {@link BaseClass}.\n *\n * If a type extends {@link ProtoOrSuperClass} and is `null`, you cannot get the\n * type's keys. See {@link ./OwnKeyOf.ts}.\n * @template [T=ReturnType<typeof Reflect.getPrototypeOf>] `null` or an `object`-like type.\n * @since 3.0.0\n */\nexport type ProtoOrSuperClass<T extends object | null = ReturnType<typeof Reflect.getPrototypeOf>>\n = T extends null ? null\n : T extends object\n ? T extends ConstructorLike<T>\n ? T extends ClassLike<T & WithProto<SuperClassLike | BaseClassProto>>\n ? T extends BaseClass<T> ? ClassLike<BaseClass<T>>\n : ClassLike<T>\n : T extends BaseClass<T>\n ? BaseClass<T>\n : ConstructorLike<T>\n : T extends FunctionLike<infer FunctionConstraint>\n ? T extends FunctionConstraint\n ? FunctionLike<T>\n : T & FunctionLike<FunctionConstraint>\n : T extends object\n ? T & object\n : never\n : never;\n\n/**\n * The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of any `object`-like type.\n * Not to be confused with the _instance_ `.prototype` chain!\n * ```\n * > util.isDeepStrictEqual(Object.getOwnPropertyDescriptors({}.__proto__), Object.getOwnPropertyDescriptors(Object.prototype))\n * true\n * ```\n * @template Object0 Any type with its `[[Prototype]]` attached as a `__proto__` property. The type of `__proto__` must extend {@link ProtoOrSuperClass}.\n * @template [Limit=16]\n * The maximum depth of recursion.\n * Affects the maximum length of the returned type.\\\n * CAUTION: Larger values will severely degrade performance.\n * 50 or more will trigger infinite-or-near-infinite-recursion errors.\n * @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.\n * @since 3.0.0\n */\nexport type ProtoChainOfObject<\n Object0 extends WithProto<ProtoOrSuperClass>,\n Limit extends Integer<number> = 16,\n CurrentLevel extends Integer<number> = 0,\n> = PropertyDescriptorMap<Object0['__proto__']> extends PropertyDescriptorMap<ObjectConstructor['prototype']>\n ? [Object0]\n : Object0['__proto__'] extends WithProto<ProtoOrSuperClass>\n ? CurrentLevel extends Limit ? [Object0]\n : [\n Object0,\n ...ProtoChainOfObject<Object0['__proto__'], Limit, Increment<CurrentLevel>>,\n ]\n : never;\n\n/**\n * The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of an object (particularly, a class).\n * @template Class Any type with its `[[Prototype]]` attached as a `__proto__` property.\n * The type of `__proto__` must extend {@link SuperClassLike} or {@link BaseClassProto}.\n * @template [Limit=16]\n * The maximum depth of recursion.\n * Affects the maximum length of the returned type.\\\n * CAUTION: Larger values will severely degrade performance.\n * 50 or more will trigger infinite-or-near-infinite-recursion errors.\n * @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.\n * @since 3.0.0\n */\nexport type ProtoChainOfClass<\n Class extends WithProto<SuperClassLike | BaseClassProto>,\n Limit extends Integer<number> = 16,\n CurrentLevel extends Integer<number> = 0,\n> = Class['__proto__'] extends BaseClassProto ? [Class]\n : Class['__proto__'] extends SuperClassLike\n ? CurrentLevel extends Limit ? [Class]\n : [\n Class,\n ...ProtoChainOfClass<Class['__proto__'], Limit, Increment<CurrentLevel>>,\n ]\n : never;\n\n/**\n * The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain prototype chain} of a class instance.\n * @template Class A constructor type with its `[[Prototype]]` attached as a `__proto__` property.\n * @template [Limit=16]\n * The maximum depth of recursion.\n * Affects the maximum length of the returned type.\\\n * CAUTION: Larger values will severely degrade performance.\n * 50 or more will trigger infinite-or-near-infinite-recursion errors.\n * @template [CurrentLevel=0] (INTERNAL) The current depth of the prototype chain.\n * @since 3.0.0\n */\nexport type ProtoChainOfClassInstance<\n Class extends ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>,\n Limit extends Integer<number> = 16,\n CurrentLevel extends Integer<number> = 0,\n> = Class['__proto__'] extends BaseClassProto ? [InstanceType<Class>]\n : Class['__proto__'] extends SuperClassLike\n ? CurrentLevel extends Limit ? [InstanceType<Class>]\n : [\n InstanceType<Class>,\n ...ProtoChainOfClassInstance<Class['__proto__'], Limit, Increment<CurrentLevel>>,\n ]\n : never;\n\n/**\n * Augment a class type to expose properties not exposed by TypeScript by default.\n * Note: is `Class & ...`\n * @template Class The typeof any class. If the type is unknown, wrap it with {@link ConstructorConstraint}.\n * @since 3.0.0\n */\n// defined as `type` because interfaces cannot extend their generic parameters\nexport type IClass<Class extends ConstructorConstraint<Class>>\n = Class\n & {\n prototype: InstanceType<Class>;\n name: ConstructorConstraint<Class>['name'];\n length: ConstructorConstraint<Class>['length'];\n };\n\n/**\n * A more fleshed-out Class type.\n *\n * Note: is `Class & ...`\n *\n * In addition to the Constructor constraint, this type...\n * - Sets the type of the immediate superclass.\n * - Sets `prototype` to {@link InstanceType}\n * @template Class The `typeof MyClass`. If this class extends a class, pass `typeof MySuperClass` to the generic argument {@link Class}.\n * @example\n * type Class_MyClass = ClassLike<typeof MyClass & WithProto<BaseClass<typeof MyBaseClass>>;\n * @since 3.0.0\n */\nexport type ClassLike<\n Class extends ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>,\n> = Class extends BaseClass<Class> ? Class\n : Class['__proto__'] extends BaseClassProto ? BaseClass<Class>\n : Class['__proto__'] extends ConstructorLike<Class['__proto__']>\n ? IClass<Class> & WithProto<ConstructorLike<Class['__proto__']>>\n // Here, __proto__ is retained via Class\n : IClass<Class>;\n\n/**\n * If {@link T} is a class or constructor, {@link InstanceType}<{@link T}>. Else, {@link T}.\n * @template T `null` or any `object`-like type.\n * @since 3.0.0\n */\nexport type InstanceTypeOrSelf<T extends object | null> = T extends ConstructorLike\n ? T extends ConstructorLike<T>\n ? InstanceType<T>\n : T\n : T;\n\n/**\n * Interface for attaching a `__proto__` to an object e.g. `T0 & WithProto<T1>`\n * @template __proto__ the type of the an object's `[[Prototype]]`.\n * @since 3.0.0\n */\nexport interface WithProto<__proto__ extends ProtoOrSuperClass> {\n ['__proto__']: __proto__;\n}\n"],"mappings":"sDAyBA,MAAa,EAAiC,EAAe,OAAuC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/utils/reflection/isConstructor.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A very jank function to determine if an object can be the target of Reflect.construct.
|
|
4
|
+
* Unfortunately, many functions have a constructor in their prototype. These
|
|
5
|
+
* functions are treated like classes due to JavaScript's poor distinction between
|
|
6
|
+
* classes and functions.\
|
|
7
|
+
* Typescript can enforce "new" keyword usage, but overriding the type
|
|
8
|
+
* allows you to `new isConstructor()` despite this function not intended to be
|
|
9
|
+
* used with the `new` keyword.
|
|
10
|
+
* #### NOTE: Only works when targeting ES6/ES2015 or later.
|
|
11
|
+
* > If your project or a dependent project is compiled to < ES6, this function will always return `false`; classes and constructors were introduced in ES6/ES2015.
|
|
12
|
+
* @param obj Anything.
|
|
13
|
+
* @returns `true` if the obj is a constructor. Else, `false`.
|
|
14
|
+
* @since 3.0.0
|
|
15
|
+
* @see https://stackoverflow.com/a/49510834
|
|
16
|
+
*/
|
|
17
|
+
declare function isConstructor(obj: unknown): obj is abstract new (...args: any[]) => any;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isConstructor };
|
|
20
|
+
//# sourceMappingURL=isConstructor.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isConstructor.d.mts","names":[],"sources":["../../../src/utils/reflection/isConstructor.ts"],"mappings":";;AAgBA;;;;;;;;;;;;;;iBAAgB,aAAA,CAAc,GAAA,YAAe,GAAA,qBAAwB,IAAA"}
|
|
@@ -1,63 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Unfortunately, many functions have a constructor in their prototype. These
|
|
4
|
-
* functions are treated like classes due to JavaScript's poor distinction between
|
|
5
|
-
* classes and functions.\
|
|
6
|
-
* Typescript can enforce "new" keyword usage, but overriding the type
|
|
7
|
-
* allows you to `new isConstructor()` despite this function not intended to be
|
|
8
|
-
* used with the `new` keyword.
|
|
9
|
-
* #### NOTE: Only works when targeting ES6/ES2015 or later.
|
|
10
|
-
* > If your project or a dependent project is compiled to < ES6, this function will always return `false`; classes and constructors were introduced in ES6/ES2015.
|
|
11
|
-
* @param obj Anything.
|
|
12
|
-
* @returns `true` if the obj is a constructor. Else, `false`.
|
|
13
|
-
* @since 3.0.0
|
|
14
|
-
* @see https://stackoverflow.com/a/49510834
|
|
15
|
-
*/
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
function isConstructor(obj) {
|
|
18
|
-
// Method 0 - filter
|
|
19
|
-
if (typeof obj !== 'function') return false;
|
|
20
|
-
|
|
21
|
-
// Method 1
|
|
22
|
-
// statically-defined class
|
|
23
|
-
if (/^class\s/.test(obj.toString())) return true;
|
|
24
|
-
|
|
25
|
-
/* Method 2
|
|
26
|
-
* > class class_ {}; function func(){}
|
|
27
|
-
* undefined
|
|
28
|
-
* > class_.prototype.constructor.name === class_.name
|
|
29
|
-
* true
|
|
30
|
-
* > func.prototype?.constructor?.name === func.name
|
|
31
|
-
* false
|
|
32
|
-
* typeof String.prototype ==='object'
|
|
33
|
-
* > true
|
|
34
|
-
* typeof Function.prototype === 'object';
|
|
35
|
-
* > false
|
|
36
|
-
* typeof Function.prototype
|
|
37
|
-
* > 'function'
|
|
38
|
-
*/
|
|
39
|
-
const prototype = obj.prototype;
|
|
40
|
-
if ((typeof prototype === 'object' || typeof prototype === 'function') && prototype !== null && 'constructor' in prototype && typeof prototype.constructor === 'function') {
|
|
41
|
-
const _ctor = prototype.constructor;
|
|
42
|
-
const _name = Reflect.getOwnPropertyDescriptor(_ctor, 'name');
|
|
43
|
-
// short-circuit if `obj.prototype.constructor` is a function, but not a constructor. Return false.
|
|
44
|
-
return _ctor === obj && _name?.writable === false && _name.enumerable === false && _name.configurable === true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Short-circuit
|
|
48
|
-
// Method 3 catches exceptions when !isConstructor. When debugging, that's annoying.
|
|
49
|
-
return false;
|
|
50
|
-
|
|
51
|
-
// Method 3
|
|
52
|
-
// isConstructable (See https://stackoverflow.com/a/49510834)
|
|
53
|
-
// try {
|
|
54
|
-
// // @ts-expect-error ts(2351): Type 'Function' has no construct signatures.
|
|
55
|
-
// new new Proxy(obj, { construct: () => ({}) })()
|
|
56
|
-
// return true
|
|
57
|
-
// }
|
|
58
|
-
// catch {
|
|
59
|
-
// return false
|
|
60
|
-
// }
|
|
61
|
-
}
|
|
62
|
-
export { isConstructor };
|
|
63
|
-
//# sourceMappingURL=isConstructor.mjs.map
|
|
1
|
+
function e(e){if(typeof e!=`function`)return!1;if(/^class\s/.test(e.toString()))return!0;let t=e.prototype;if((typeof t==`object`||typeof t==`function`)&&t!==null&&`constructor`in t&&typeof t.constructor==`function`){let n=t.constructor,r=Reflect.getOwnPropertyDescriptor(n,`name`);return n===e&&r?.writable===!1&&r.enumerable===!1&&r.configurable===!0}return!1}export{e as isConstructor};
|
|
2
|
+
//# sourceMappingURL=isConstructor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConstructor.mjs","sources":["../../../src/utils/reflection/isConstructor.ts"],"
|
|
1
|
+
{"version":3,"file":"isConstructor.mjs","names":[],"sources":["../../../src/utils/reflection/isConstructor.ts"],"sourcesContent":["/**\n * A very jank function to determine if an object can be the target of Reflect.construct.\n * Unfortunately, many functions have a constructor in their prototype. These\n * functions are treated like classes due to JavaScript's poor distinction between\n * classes and functions.\\\n * Typescript can enforce \"new\" keyword usage, but overriding the type\n * allows you to `new isConstructor()` despite this function not intended to be\n * used with the `new` keyword.\n * #### NOTE: Only works when targeting ES6/ES2015 or later.\n * > If your project or a dependent project is compiled to < ES6, this function will always return `false`; classes and constructors were introduced in ES6/ES2015.\n * @param obj Anything.\n * @returns `true` if the obj is a constructor. Else, `false`.\n * @since 3.0.0\n * @see https://stackoverflow.com/a/49510834\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isConstructor(obj: unknown): obj is abstract new (...args: any[]) => any {\n // Method 0 - filter\n if (typeof obj !== 'function')\n return false;\n\n // Method 1\n // statically-defined class\n if (/^class\\s/.test(obj.toString()))\n return true;\n\n /* Method 2\n * > class class_ {}; function func(){}\n * undefined\n * > class_.prototype.constructor.name === class_.name\n * true\n * > func.prototype?.constructor?.name === func.name\n * false\n * typeof String.prototype ==='object'\n * > true\n * typeof Function.prototype === 'object';\n * > false\n * typeof Function.prototype\n * > 'function'\n */\n const prototype: unknown = obj.prototype;\n if ((typeof prototype === 'object' || typeof prototype === 'function')\n && prototype !== null\n && 'constructor' in prototype\n && typeof prototype.constructor === 'function') {\n const _ctor = prototype.constructor as (new (...arguments_: unknown[]) => unknown);\n const _name = Reflect.getOwnPropertyDescriptor(\n _ctor,\n 'name',\n );\n // short-circuit if `obj.prototype.constructor` is a function, but not a constructor. Return false.\n return (\n _ctor === obj\n && _name?.writable === false\n && _name.enumerable === false\n && _name.configurable === true\n );\n }\n\n // Short-circuit\n // Method 3 catches exceptions when !isConstructor. When debugging, that's annoying.\n return false;\n\n // Method 3\n // isConstructable (See https://stackoverflow.com/a/49510834)\n // try {\n // // @ts-expect-error ts(2351): Type 'Function' has no construct signatures.\n // new new Proxy(obj, { construct: () => ({}) })()\n // return true\n // }\n // catch {\n // return false\n // }\n}\n"],"mappings":"AAgBA,SAAgB,EAAc,EAA2D,CAEvF,GAAI,OAAO,GAAQ,WACjB,MAAO,GAIT,GAAI,WAAW,KAAK,EAAI,UAAU,CAAC,CACjC,MAAO,GAgBT,IAAM,EAAqB,EAAI,UAC/B,IAAK,OAAO,GAAc,UAAY,OAAO,GAAc,aACtD,IAAc,MACd,gBAAiB,GACjB,OAAO,EAAU,aAAgB,WAAY,CAChD,IAAM,EAAQ,EAAU,YAClB,EAAQ,QAAQ,yBACpB,EACA,OACD,CAED,OACE,IAAU,GACP,GAAO,WAAa,IACpB,EAAM,aAAe,IACrB,EAAM,eAAiB,GAM9B,MAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GetterDescriptor } from "./GetterDescriptor.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/reflection/isGetterDescriptor.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A function for inferring a {@link TypedPropertyDescriptor} is a {@link GetterDescriptor}
|
|
6
|
+
* @param propertyDescriptor The {@link TypedPropertyDescriptor} to inspect.
|
|
7
|
+
* @returns `true` if {@link propertyDescriptor} describes a getter. Else, `false.
|
|
8
|
+
* @since 3.0.0
|
|
9
|
+
*/
|
|
10
|
+
declare function isGetterDescriptor<T>(propertyDescriptor: TypedPropertyDescriptor<T>): propertyDescriptor is GetterDescriptor<T>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isGetterDescriptor };
|
|
13
|
+
//# sourceMappingURL=isGetterDescriptor.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isGetterDescriptor.d.mts","names":[],"sources":["../../../src/utils/reflection/isGetterDescriptor.ts"],"mappings":";;;;;AAQA;;;;iBAAgB,kBAAA,GAAA,CAAsB,kBAAA,EAAoB,uBAAA,CAAwB,CAAA,IAAK,kBAAA,IAAsB,gBAAA,CAAiB,CAAA"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @param propertyDescriptor The {@link TypedPropertyDescriptor} to inspect.
|
|
4
|
-
* @returns `true` if {@link propertyDescriptor} describes a getter. Else, `false.
|
|
5
|
-
* @since 3.0.0
|
|
6
|
-
*/
|
|
7
|
-
function isGetterDescriptor(propertyDescriptor) {
|
|
8
|
-
return typeof propertyDescriptor.get === 'function';
|
|
9
|
-
}
|
|
10
|
-
;
|
|
11
|
-
export { isGetterDescriptor };
|
|
12
|
-
//# sourceMappingURL=isGetterDescriptor.mjs.map
|
|
1
|
+
function e(e){return typeof e.get==`function`}export{e as isGetterDescriptor};
|
|
2
|
+
//# sourceMappingURL=isGetterDescriptor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isGetterDescriptor.mjs","sources":["../../../src/utils/reflection/isGetterDescriptor.ts"],"
|
|
1
|
+
{"version":3,"file":"isGetterDescriptor.mjs","names":[],"sources":["../../../src/utils/reflection/isGetterDescriptor.ts"],"sourcesContent":["import type { GetterDescriptor } from './GetterDescriptor.d.ts';\n\n/**\n * A function for inferring a {@link TypedPropertyDescriptor} is a {@link GetterDescriptor}\n * @param propertyDescriptor The {@link TypedPropertyDescriptor} to inspect.\n * @returns `true` if {@link propertyDescriptor} describes a getter. Else, `false.\n * @since 3.0.0\n */\nexport function isGetterDescriptor<T>(propertyDescriptor: TypedPropertyDescriptor<T>): propertyDescriptor is GetterDescriptor<T> {\n return typeof propertyDescriptor.get === 'function';\n};\n"],"mappings":"AAQA,SAAgB,EAAsB,EAA2F,CAC/H,OAAO,OAAO,EAAmB,KAAQ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { InstanceOrStatic } from "../miscTypes.mjs";
|
|
2
|
+
import { BaseClassProto, ClassLike, ConstructorConstraint, InstanceTypeOrSelf, SuperClassLike, WithProto } from "./inheritance.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/reflection/listOwnGetters.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Description placeholder
|
|
7
|
+
* @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class
|
|
8
|
+
* @template {InstanceOrStatic} _InstanceOrStatic
|
|
9
|
+
* @since 3.0.0
|
|
10
|
+
*/
|
|
11
|
+
type OwnGetters<Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>, _InstanceOrStatic extends InstanceOrStatic> = [_InstanceOrStatic] extends ["Instance"] ? Exclude<(Class["__proto__"] extends BaseClassProto ? null : InstanceTypeOrSelf<Class["__proto__"]>) extends null ? keyof InstanceType<Class> : Exclude<keyof InstanceType<Class>, keyof (Class["__proto__"] extends BaseClassProto ? null : InstanceTypeOrSelf<Class["__proto__"]>)>, "__proto__">[] : [_InstanceOrStatic] extends ["Static"] ? Exclude<Class["__proto__"] extends null ? keyof Class : Exclude<keyof Class, keyof Class["__proto__"]>, "__proto__">[] : never;
|
|
12
|
+
/**
|
|
13
|
+
* # !WARNING!
|
|
14
|
+
* > If you don't specify the Class's SuperClass (or `BaseClassProto`) via WithProto, the return type will wrongly include inherited property names! This is a design limitation of TypeScript.
|
|
15
|
+
*
|
|
16
|
+
* Returns the names of the instantiated (or static), noninherited getters derived from the
|
|
17
|
+
* given prototype or prototype of the given object.
|
|
18
|
+
* @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class
|
|
19
|
+
* @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.
|
|
20
|
+
* @param classDefinition Any class cast to ClassLike
|
|
21
|
+
* @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.
|
|
22
|
+
* @since 3.0.0
|
|
23
|
+
* @returns
|
|
24
|
+
* An array of names of getters that were not inherited from a parent class. If {@link classDefinition} is a class instance, the names of instanced getters are returned. Otherwise, the names of static getters are returned;
|
|
25
|
+
*/
|
|
26
|
+
declare function listOwnGetters<Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>, _InstanceOrStatic extends InstanceOrStatic>(classDefinition: Class, instanceOrStatic: Extract<_InstanceOrStatic, InstanceOrStatic>): OwnGetters<Class, _InstanceOrStatic>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { listOwnGetters };
|
|
29
|
+
//# sourceMappingURL=listOwnGetters.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOwnGetters.d.mts","names":[],"sources":["../../../src/utils/reflection/listOwnGetters.ts"],"mappings":";;;;;;AAUO;;;;KAUF,UAAA,eACW,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAU,cAAA,GAAiB,cAAA,8BACxD,gBAAA,KAEvB,iBAAA,yBACC,OAAA,EACC,KAAA,sBAA2B,cAAA,UAAwB,kBAAA,CAAmB,KAAA,qCAC7D,YAAA,CAAa,KAAA,IACnB,OAAA,OACM,YAAA,CAAa,KAAA,UACZ,KAAA,sBAA2B,cAAA,UAAwB,kBAAA,CAAmB,KAAA,oCAIhF,iBAAA,uBACG,OAAA,CACA,KAAA,mCAAwC,KAAA,GAAQ,OAAA,OAAc,KAAA,QAAa,KAAA;;;;;;;;;;;;;;;iBAmBrE,cAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAU,cAAA,GAAiB,cAAA,8BACxD,gBAAA,CAAA,CAE1B,eAAA,EAAiB,KAAA,EACjB,gBAAA,EAAkB,OAAA,CAAQ,iBAAA,EAAmB,gBAAA,IAC5C,UAAA,CAAW,KAAA,EAAO,iBAAA"}
|
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Description placeholder
|
|
6
|
-
* @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class
|
|
7
|
-
* @template {InstanceOrStatic} _InstanceOrStatic
|
|
8
|
-
* @since 3.0.0
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* # !WARNING!
|
|
13
|
-
* > If you don't specify the Class's SuperClass (or `BaseClassProto`) via WithProto, the return type will wrongly include inherited property names! This is a design limitation of TypeScript.
|
|
14
|
-
*
|
|
15
|
-
* Returns the names of the instantiated (or static), noninherited getters derived from the
|
|
16
|
-
* given prototype or prototype of the given object.
|
|
17
|
-
* @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class
|
|
18
|
-
* @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.
|
|
19
|
-
* @param classDefinition Any class cast to ClassLike
|
|
20
|
-
* @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.
|
|
21
|
-
* @since 3.0.0
|
|
22
|
-
* @returns
|
|
23
|
-
* An array of names of getters that were not inherited from a parent class. If {@link classDefinition} is a class instance, the names of instanced getters are returned. Otherwise, the names of static getters are returned;
|
|
24
|
-
*/
|
|
25
|
-
function listOwnGetters(classDefinition, instanceOrStatic) {
|
|
26
|
-
if (instanceOrStatic === 'Instance') {
|
|
27
|
-
const descriptorMap = getOwnPropertyDescriptors(classDefinition, instanceOrStatic);
|
|
28
|
-
const getterDescriptorMap = filterForGetters(descriptorMap);
|
|
29
|
-
const keyArray = Reflect.ownKeys(getterDescriptorMap);
|
|
30
|
-
return keyArray;
|
|
31
|
-
} else if (instanceOrStatic === 'Static') {
|
|
32
|
-
const descriptorMap = getOwnPropertyDescriptors(classDefinition, instanceOrStatic);
|
|
33
|
-
const getterDescriptorMap = filterForGetters(descriptorMap);
|
|
34
|
-
const keyArray = Reflect.ownKeys(getterDescriptorMap);
|
|
35
|
-
return keyArray;
|
|
36
|
-
} else throw new TypeError('Argument `instanceOrStatic` must be "Instance" or "Static".');
|
|
37
|
-
}
|
|
38
|
-
export { listOwnGetters };
|
|
39
|
-
//# sourceMappingURL=listOwnGetters.mjs.map
|
|
1
|
+
import{filterForGetters as e}from"./filterForGetters.mjs";import{getOwnPropertyDescriptors as t}from"./getOwnPropertyDescriptors.mjs";function n(n,r){if(r===`Instance`){let i=e(t(n,r));return Reflect.ownKeys(i)}else if(r===`Static`){let i=e(t(n,r));return Reflect.ownKeys(i)}else throw TypeError('Argument `instanceOrStatic` must be "Instance" or "Static".')}export{n as listOwnGetters};
|
|
2
|
+
//# sourceMappingURL=listOwnGetters.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOwnGetters.mjs","sources":["../../../src/utils/reflection/listOwnGetters.ts"],"
|
|
1
|
+
{"version":3,"file":"listOwnGetters.mjs","names":[],"sources":["../../../src/utils/reflection/listOwnGetters.ts"],"sourcesContent":["import type { InstanceOrStatic } from '../miscTypes.ts';\nimport { filterForGetters } from './filterForGetters.ts';\nimport { getOwnPropertyDescriptors } from './getOwnPropertyDescriptors.ts';\nimport type {\n BaseClassProto,\n ClassLike,\n ConstructorConstraint,\n InstanceTypeOrSelf,\n SuperClassLike,\n WithProto,\n} from './inheritance.ts';\nimport type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n\n/**\n * Description placeholder\n * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class\n * @template {InstanceOrStatic} _InstanceOrStatic\n * @since 3.0.0\n */\ntype OwnGetters<\n Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>,\n _InstanceOrStatic extends InstanceOrStatic,\n>\n = [_InstanceOrStatic] extends ['Instance']\n ? Exclude<\n (Class['__proto__'] extends BaseClassProto ? null : InstanceTypeOrSelf<Class['__proto__']>) extends null\n ? keyof InstanceType<Class>\n : Exclude<\n keyof InstanceType<Class>,\n keyof (Class['__proto__'] extends BaseClassProto ? null : InstanceTypeOrSelf<Class['__proto__']>)\n >,\n '__proto__'\n >[]\n : [_InstanceOrStatic] extends ['Static']\n ? Exclude<\n Class['__proto__'] extends null ? keyof Class : Exclude<keyof Class, keyof Class['__proto__']>,\n '__proto__'\n >[]\n : never;\n\n/**\n * # !WARNING!\n * > If you don't specify the Class's SuperClass (or `BaseClassProto`) via WithProto, the return type will wrongly include inherited property names! This is a design limitation of TypeScript.\n *\n * Returns the names of the instantiated (or static), noninherited getters derived from the\n * given prototype or prototype of the given object.\n * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class\n * @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @param classDefinition Any class cast to ClassLike\n * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @since 3.0.0\n * @returns\n * An array of names of getters that were not inherited from a parent class. If {@link classDefinition} is a class instance, the names of instanced getters are returned. Otherwise, the names of static getters are returned;\n */\nexport function listOwnGetters<\n Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>,\n _InstanceOrStatic extends InstanceOrStatic,\n>(\n classDefinition: Class,\n instanceOrStatic: Extract<_InstanceOrStatic, InstanceOrStatic>,\n): OwnGetters<Class, _InstanceOrStatic> {\n if (instanceOrStatic === 'Instance') {\n const descriptorMap: InstancePropertyDescriptorMap<Class> = getOwnPropertyDescriptors(classDefinition, instanceOrStatic as 'Instance');\n const getterDescriptorMap = filterForGetters(descriptorMap);\n const keyArray = Reflect.ownKeys(getterDescriptorMap) as (keyof typeof getterDescriptorMap)[];\n return keyArray as [typeof instanceOrStatic & 'Instance'] extends ['Instance'] ? typeof keyArray : never;\n }\n else if (instanceOrStatic === 'Static') {\n const descriptorMap: OwnPropertyDescriptorMap<Class> = getOwnPropertyDescriptors(classDefinition, instanceOrStatic as 'Static');\n const getterDescriptorMap = filterForGetters(descriptorMap);\n const keyArray = Reflect.ownKeys(getterDescriptorMap) as (keyof typeof getterDescriptorMap)[];\n return keyArray as [_InstanceOrStatic] extends ['Instance']\n ? never\n : [_InstanceOrStatic] extends ['Static']\n ? typeof keyArray\n : never;\n }\n else throw new TypeError('Argument `instanceOrStatic` must be \"Instance\" or \"Static\".');\n}\n"],"mappings":"sIAuDA,SAAgB,EAId,EACA,EACsC,CACtC,GAAI,IAAqB,WAAY,CAEnC,IAAM,EAAsB,EADgC,EAA0B,EAAiB,EAA+B,CAC3E,CAE3D,OADiB,QAAQ,QAAQ,EAAoB,SAG9C,IAAqB,SAAU,CAEtC,IAAM,EAAsB,EAD2B,EAA0B,EAAiB,EAA6B,CACpE,CAE3D,OADiB,QAAQ,QAAQ,EAAoB,MAOlD,MAAU,UAAU,8DAA8D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FunctionLike } from "./reflection/FunctionLike.mjs";
|
|
2
|
+
import { GetterDescriptor } from "./reflection/GetterDescriptor.mjs";
|
|
3
|
+
import { PropertyDescriptorMap } from "./reflection/PropertyDescriptorMap.mjs";
|
|
4
|
+
import { BaseClass, BaseClassProto, ClassLike, ClassLike_Unknown, ConstructorConstraint, ConstructorLike, Constructor_Unknown, IClass, InstanceTypeOrSelf, ProtoChainOfClass, ProtoChainOfClassInstance, ProtoChainOfObject, ProtoOrSuperClass, SuperClassLike, WithProto, baseClassProto } from "./reflection/inheritance.mjs";
|
|
5
|
+
import { InstancePropertyDescriptorMap } from "./reflection/InstancePropertyDescriptorMap.mjs";
|
|
6
|
+
import { InstanceTypeOrSelfPropertyDescriptorMap } from "./reflection/InstanceTypeOrSelfPropertyDescriptorMap.mjs";
|
|
7
|
+
import { OwnKeyOf } from "./reflection/OwnKeyOf.mjs";
|
|
8
|
+
import { OwnGetterDescriptorMap } from "./reflection/OwnGetterDescriptorMap.mjs";
|
|
9
|
+
import { OwnPropertyDescriptorMap } from "./reflection/OwnPropertyDescriptorMap.mjs";
|
|
10
|
+
import { filterForGetters } from "./reflection/filterForGetters.mjs";
|
|
11
|
+
import { getOwnPropertyDescriptors } from "./reflection/getOwnPropertyDescriptors.mjs";
|
|
12
|
+
import { RecursedPropertyDescriptorMap, RecursedPropertyDescriptorMapArray, getOwnPropertyDescriptorsRecursively } from "./reflection/getOwnPropertyDescriptorsRecursively.mjs";
|
|
13
|
+
import { getPrototypesChainOf } from "./reflection/getPrototypeChainOf.mjs";
|
|
14
|
+
import { getPrototypeOf } from "./reflection/getPrototypeOf.mjs";
|
|
15
|
+
import { isConstructor } from "./reflection/isConstructor.mjs";
|
|
16
|
+
import { isGetterDescriptor } from "./reflection/isGetterDescriptor.mjs";
|
|
17
|
+
import { listOwnGetters } from "./reflection/listOwnGetters.mjs";
|
|
18
|
+
export { BaseClass, BaseClassProto, ClassLike, ClassLike_Unknown, ConstructorConstraint, ConstructorLike, Constructor_Unknown, FunctionLike, GetterDescriptor, IClass, InstancePropertyDescriptorMap, InstanceTypeOrSelf, InstanceTypeOrSelfPropertyDescriptorMap, OwnGetterDescriptorMap, OwnKeyOf, OwnPropertyDescriptorMap, PropertyDescriptorMap, ProtoChainOfClass, ProtoChainOfClassInstance, ProtoChainOfObject, ProtoOrSuperClass, RecursedPropertyDescriptorMap, RecursedPropertyDescriptorMapArray, SuperClassLike, WithProto, baseClassProto, filterForGetters, getOwnPropertyDescriptors, getOwnPropertyDescriptorsRecursively, getPrototypeOf, getPrototypesChainOf, isConstructor, isGetterDescriptor, listOwnGetters };
|