@halospv3/hce.shared-config 3.5.3-develop.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +33 -10
- package/dotnet/.github/workflows/_unit_test.yml +1 -1
- package/dotnet/.github/workflows/dotnet-release.yml +1 -1
- package/dotnet/.github/workflows/sample-dotnet-build.yml +1 -1
- package/dotnet/CleanupWpfTmp.targets +15 -0
- package/dotnet/HCE.Shared.targets +3 -0
- package/mjs/CaseInsensitiveMap.mjs.map +1 -1
- package/mjs/commitlintConfig.mjs.map +1 -1
- package/mjs/debug.mjs.map +1 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts +5 -5
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs +7 -7
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts +6 -6
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +14 -14
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +5 -5
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProject.d.mts +28 -28
- package/mjs/dotnet/MSBuildProject.d.mts.map +1 -1
- package/mjs/dotnet/MSBuildProject.mjs +88 -66
- package/mjs/dotnet/MSBuildProject.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.d.mts.map +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.mjs +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetProjectProperties.d.mts +3 -3
- package/mjs/dotnet/NugetProjectProperties.d.mts.map +1 -1
- package/mjs/dotnet/NugetProjectProperties.mjs +7 -9
- package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetRegistryInfo.d.mts +40 -40
- package/mjs/dotnet/NugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/NugetRegistryInfo.mjs +170 -148
- package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/helpers.d.mts.map +1 -1
- package/mjs/dotnet/helpers.mjs +33 -34
- package/mjs/dotnet/helpers.mjs.map +1 -1
- package/mjs/eslintConfig.mjs.map +1 -1
- package/mjs/insertPlugins.mjs +2 -2
- package/mjs/insertPlugins.mjs.map +1 -1
- package/mjs/semantic-release__commit-analyzer.d.mts.map +1 -1
- package/mjs/semantic-release__exec.d.mts.map +1 -1
- package/mjs/semantic-release__git.d.mts.map +1 -1
- package/mjs/semantic-release__github.d.mts +1 -0
- package/mjs/semantic-release__github.d.mts.map +1 -1
- package/mjs/semanticReleaseConfig.d.mts.map +1 -1
- package/mjs/semanticReleaseConfig.mjs.map +1 -1
- package/mjs/semanticReleaseConfigDotnet.d.mts.map +1 -1
- package/mjs/semanticReleaseConfigDotnet.mjs +23 -16
- package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -1
- package/mjs/setupGitPluginSpec.d.mts.map +1 -1
- package/mjs/setupGitPluginSpec.default.mjs.map +1 -1
- package/mjs/setupGitPluginSpec.mjs +19 -19
- package/mjs/setupGitPluginSpec.mjs.map +1 -1
- package/mjs/utils/Exact.d.mts.map +1 -1
- package/mjs/utils/GracefulRecursion.d.mts.map +1 -1
- package/mjs/utils/env.d.mts.map +1 -1
- package/mjs/utils/env.mjs.map +1 -1
- package/mjs/utils/execAsync.d.mts +3 -3
- package/mjs/utils/execAsync.d.mts.map +1 -1
- package/mjs/utils/execAsync.mjs +14 -12
- package/mjs/utils/execAsync.mjs.map +1 -1
- package/mjs/utils/isError.mjs.map +1 -1
- package/mjs/utils/miscTypes.d.mts.map +1 -1
- package/mjs/utils/miscTypes.mjs.map +1 -1
- package/mjs/utils/reflection/FunctionLike.d.mts +1 -0
- package/mjs/utils/reflection/FunctionLike.d.mts.map +1 -1
- package/mjs/utils/reflection/GetterDescriptor.d.mts.map +1 -1
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnKeyOf.d.mts +1 -1
- package/mjs/utils/reflection/OwnKeyOf.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/filterForGetters.d.mts.map +1 -1
- package/mjs/utils/reflection/filterForGetters.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.mts.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.mts.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +3 -3
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts +2 -2
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts.map +1 -1
- package/mjs/utils/reflection/getPrototypeChainOf.mjs +1 -2
- package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeOf.d.mts.map +1 -1
- package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -1
- package/mjs/utils/reflection/inheritance.d.mts +4 -4
- package/mjs/utils/reflection/inheritance.d.mts.map +1 -1
- package/mjs/utils/reflection/inheritance.mjs.map +1 -1
- package/mjs/utils/reflection/isConstructor.d.mts +3 -3
- package/mjs/utils/reflection/isConstructor.d.mts.map +1 -1
- package/mjs/utils/reflection/isConstructor.mjs +7 -7
- package/mjs/utils/reflection/isConstructor.mjs.map +1 -1
- package/mjs/utils/reflection/isGetterDescriptor.d.mts.map +1 -1
- package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -1
- package/mjs/utils/reflection/listOwnGetters.d.mts.map +1 -1
- package/mjs/utils/reflection/listOwnGetters.mjs +4 -2
- package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -1
- package/mjs/utils/reflection.d.mts +1 -1
- package/package.json +25 -24
- package/src/dotnet/GithubNugetRegistryInfo.ts +18 -15
- package/src/dotnet/GitlabNugetRegistryInfo.ts +28 -26
- package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +6 -6
- package/src/dotnet/MSBuildProject.ts +103 -106
- package/src/dotnet/MSBuildProjectProperties.ts +1 -1
- package/src/dotnet/NugetProjectProperties.ts +13 -18
- package/src/dotnet/NugetRegistryInfo.ts +287 -243
- package/src/dotnet/helpers.ts +58 -58
- package/src/insertPlugins.ts +3 -3
- package/src/semantic-release__github.d.ts +1 -0
- package/src/semanticReleaseConfigDotnet.ts +52 -54
- package/src/setupGitPluginSpec.ts +25 -26
- package/src/utils/env.ts +1 -0
- package/src/utils/execAsync.ts +16 -13
- package/src/utils/reflection/FunctionLike.d.ts +1 -0
- package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +4 -4
- package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +6 -6
- package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +2 -2
- package/src/utils/reflection/OwnKeyOf.d.ts +3 -3
- package/src/utils/reflection/OwnPropertyDescriptorMap.d.ts +3 -3
- package/src/utils/reflection/PropertyDescriptorMap.d.ts +3 -3
- package/src/utils/reflection/filterForGetters.ts +10 -10
- package/src/utils/reflection/getOwnPropertyDescriptors.ts +2 -2
- package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +13 -13
- package/src/utils/reflection/getPrototypeChainOf.ts +17 -17
- package/src/utils/reflection/getPrototypeOf.ts +2 -2
- package/src/utils/reflection/inheritance.ts +5 -4
- package/src/utils/reflection/isConstructor.ts +7 -7
- package/src/utils/reflection/listOwnGetters.ts +8 -8
- package/tsconfig.base.json +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseClassProto, ConstructorLike, InstanceTypeOrSelf, ProtoOrSuperClass, SuperClassLike, WithProto } from './inheritance.ts';
|
|
1
|
+
import type { BaseClassProto as BaseClassPrototype, ConstructorLike, InstanceTypeOrSelf, ProtoOrSuperClass as PrototypeOrSuperClass, SuperClassLike, WithProto as WithPrototype } from './inheritance.ts';
|
|
2
2
|
import type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';
|
|
3
3
|
import type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';
|
|
4
4
|
|
|
@@ -12,9 +12,9 @@ import type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';
|
|
|
12
12
|
*/
|
|
13
13
|
export type InstanceTypeOrSelfPropertyDescriptorMap<
|
|
14
14
|
T extends object | null,
|
|
15
|
-
|
|
15
|
+
__prototype__ extends PrototypeOrSuperClass,
|
|
16
16
|
> = T extends ConstructorLike<T>
|
|
17
|
-
?
|
|
18
|
-
? InstancePropertyDescriptorMap<T &
|
|
19
|
-
: PropertyDescriptorMap<InstanceType<T>, InstanceTypeOrSelf<
|
|
20
|
-
: PropertyDescriptorMap<InstanceTypeOrSelf<T>, InstanceTypeOrSelf<
|
|
17
|
+
? __prototype__ extends SuperClassLike | BaseClassPrototype
|
|
18
|
+
? InstancePropertyDescriptorMap<T & WithPrototype<__prototype__>>
|
|
19
|
+
: PropertyDescriptorMap<InstanceType<T>, InstanceTypeOrSelf<__prototype__>>
|
|
20
|
+
: PropertyDescriptorMap<InstanceTypeOrSelf<T>, InstanceTypeOrSelf<__prototype__>>;
|
|
@@ -13,5 +13,5 @@ import type { OwnKeyOf } from './OwnKeyOf.d.ts';
|
|
|
13
13
|
*/
|
|
14
14
|
export type OwnGetterDescriptorMap<
|
|
15
15
|
T,
|
|
16
|
-
|
|
17
|
-
> = { [P in OwnKeyOf<T,
|
|
16
|
+
__prototype__ extends object | null,
|
|
17
|
+
> = { [P in OwnKeyOf<T, __prototype__>]: GetterDescriptor<T[P]> };
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* OwnKeyOf<typeof NPP, null> === "prototype" | "GetFullPath"
|
|
9
9
|
* @since 3.0.0
|
|
10
10
|
*/
|
|
11
|
-
export type OwnKeyOf<T,
|
|
11
|
+
export type OwnKeyOf<T, __prototype__ extends object | null>
|
|
12
12
|
= Exclude<
|
|
13
|
-
|
|
13
|
+
__prototype__ extends null
|
|
14
14
|
? keyof T
|
|
15
15
|
: Exclude<
|
|
16
16
|
keyof T,
|
|
17
|
-
keyof
|
|
17
|
+
keyof __prototype__
|
|
18
18
|
>,
|
|
19
19
|
'__proto__'
|
|
20
20
|
>;
|
|
@@ -2,8 +2,8 @@ import type {
|
|
|
2
2
|
BaseClass,
|
|
3
3
|
ClassLike,
|
|
4
4
|
ClassLike_Unknown,
|
|
5
|
-
ProtoOrSuperClass,
|
|
6
|
-
WithProto,
|
|
5
|
+
ProtoOrSuperClass as PrototypeOrSuperClass,
|
|
6
|
+
WithProto as WithPrototype,
|
|
7
7
|
} from './inheritance.ts';
|
|
8
8
|
|
|
9
9
|
// todo: Omit [P in keyof T] where T['__proto__'][P] === T[P].
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
* @template T Any type with its `[[Prototype]]` attached via a type-only `__proto__` property. The type of `__proto__` must extends {@link ProtoOrSuperClass}.
|
|
16
16
|
* @since 3.0.0
|
|
17
17
|
*/
|
|
18
|
-
export type OwnPropertyDescriptorMap<T extends
|
|
18
|
+
export type OwnPropertyDescriptorMap<T extends WithPrototype<PrototypeOrSuperClass>>
|
|
19
19
|
= T['__proto__'] extends null
|
|
20
20
|
? { [P0 in keyof T]: TypedPropertyDescriptor<T[P0]>; }
|
|
21
21
|
: Omit<
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* The `null` or the `object`-like `[[Prototype]]` of {@link T}.
|
|
7
7
|
* @since 3.0.0
|
|
8
8
|
*/
|
|
9
|
-
export type PropertyDescriptorMap<T,
|
|
10
|
-
=
|
|
9
|
+
export type PropertyDescriptorMap<T, __prototype__ extends object | null = null>
|
|
10
|
+
= __prototype__ extends null
|
|
11
11
|
? { [P0 in keyof T]: TypedPropertyDescriptor<T[P0]>; }
|
|
12
12
|
: Omit<
|
|
13
13
|
{ [P0 in keyof T]: TypedPropertyDescriptor<T[P0]>; },
|
|
14
|
-
keyof { [P1 in keyof
|
|
14
|
+
keyof { [P1 in keyof __prototype__]: TypedPropertyDescriptor<__prototype__[P1]> }
|
|
15
15
|
>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
BaseClassProto,
|
|
3
|
-
baseClassProto,
|
|
2
|
+
BaseClassProto as BaseClassPrototype,
|
|
3
|
+
baseClassProto as baseClassPrototype,
|
|
4
4
|
ClassLike,
|
|
5
5
|
ConstructorConstraint,
|
|
6
6
|
InstanceTypeOrSelf,
|
|
7
7
|
SuperClassLike,
|
|
8
|
-
WithProto,
|
|
8
|
+
WithProto as WithPrototype,
|
|
9
9
|
} from './inheritance.ts';
|
|
10
10
|
import type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';
|
|
11
11
|
import type { OwnGetterDescriptorMap } from './OwnGetterDescriptorMap.d.ts';
|
|
@@ -13,15 +13,15 @@ import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
|
13
13
|
import type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';
|
|
14
14
|
|
|
15
15
|
export function filterForGetters<
|
|
16
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
16
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | typeof baseClassPrototype>>,
|
|
17
17
|
>(
|
|
18
18
|
descriptorMap: InstancePropertyDescriptorMap<Class>,
|
|
19
19
|
): Partial<OwnGetterDescriptorMap<
|
|
20
20
|
InstanceType<Class>,
|
|
21
|
-
Class['__proto__'] extends
|
|
21
|
+
Class['__proto__'] extends BaseClassPrototype ? null : InstanceTypeOrSelf<Class['__proto__']>
|
|
22
22
|
>>;
|
|
23
23
|
export function filterForGetters<
|
|
24
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
24
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
25
25
|
>(
|
|
26
26
|
descriptorMap: OwnPropertyDescriptorMap<Class>,
|
|
27
27
|
): Partial<OwnGetterDescriptorMap<Class, Class['__proto__']>>;
|
|
@@ -40,11 +40,11 @@ export function filterForGetters<
|
|
|
40
40
|
*/
|
|
41
41
|
export function filterForGetters<
|
|
42
42
|
T extends object,
|
|
43
|
-
|
|
43
|
+
__prototype__ extends object | null = null,
|
|
44
44
|
>(
|
|
45
|
-
descriptorMap: PropertyDescriptorMap<T,
|
|
46
|
-
): Partial<OwnGetterDescriptorMap<T,
|
|
47
|
-
let getterDescriptorMap: Partial<OwnGetterDescriptorMap<T,
|
|
45
|
+
descriptorMap: PropertyDescriptorMap<T, __prototype__> | PropertyDescriptorMap<T>,
|
|
46
|
+
): Partial<OwnGetterDescriptorMap<T, __prototype__>> {
|
|
47
|
+
let getterDescriptorMap: Partial<OwnGetterDescriptorMap<T, __prototype__>> = {};
|
|
48
48
|
for (const key in descriptorMap) {
|
|
49
49
|
const element = descriptorMap[key as keyof typeof descriptorMap];
|
|
50
50
|
if (typeof element.get === 'function') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InstanceOrStatic } from '../miscTypes.ts';
|
|
2
|
-
import type { BaseClassProto, ClassLike, ConstructorConstraint, SuperClassLike, WithProto } from './inheritance.ts';
|
|
2
|
+
import type { BaseClassProto as BaseClassPrototype, ClassLike, ConstructorConstraint, SuperClassLike, WithProto as WithPrototype } from './inheritance.ts';
|
|
3
3
|
import type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';
|
|
4
4
|
import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
|
20
20
|
* @since 3.0.0
|
|
21
21
|
*/
|
|
22
22
|
export function getOwnPropertyDescriptors<
|
|
23
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
23
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
24
24
|
_InstanceOrStatic extends InstanceOrStatic,
|
|
25
25
|
>(
|
|
26
26
|
classDefinition: Class,
|
|
@@ -4,13 +4,13 @@ import { getOwnPropertyDescriptors } from './getOwnPropertyDescriptors.ts';
|
|
|
4
4
|
import { getPrototypesChainOf } from './getPrototypeChainOf.ts';
|
|
5
5
|
import type {
|
|
6
6
|
BaseClass,
|
|
7
|
-
BaseClassProto,
|
|
7
|
+
BaseClassProto as BaseClassPrototype,
|
|
8
8
|
ClassLike,
|
|
9
9
|
ConstructorConstraint,
|
|
10
10
|
ConstructorLike,
|
|
11
|
-
ProtoChainOfClass,
|
|
11
|
+
ProtoChainOfClass as PrototypeChainOfClass,
|
|
12
12
|
SuperClassLike,
|
|
13
|
-
WithProto,
|
|
13
|
+
WithProto as WithPrototype,
|
|
14
14
|
} from './inheritance.ts';
|
|
15
15
|
import type { InstanceTypeOrSelfPropertyDescriptorMap } from './InstanceTypeOrSelfPropertyDescriptorMap.d.ts';
|
|
16
16
|
import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
@@ -38,7 +38,7 @@ import type { InstancePropertyDescriptorMap as _InstancePropertyDescriptorMap }
|
|
|
38
38
|
* @since 3.0.0
|
|
39
39
|
*/
|
|
40
40
|
export type RecursedPropertyDescriptorMap<
|
|
41
|
-
Class extends ConstructorConstraint<Class> &
|
|
41
|
+
Class extends ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>,
|
|
42
42
|
_InstanceOrStatic extends InstanceOrStatic,
|
|
43
43
|
> = [_InstanceOrStatic] extends ['Instance'] ? InstanceTypeOrSelfPropertyDescriptorMap<Class, Class['__proto__']>
|
|
44
44
|
: [_InstanceOrStatic] extends ['Static'] ? OwnPropertyDescriptorMap<Class>
|
|
@@ -55,17 +55,17 @@ export type RecursedPropertyDescriptorMap<
|
|
|
55
55
|
* @template {Integer<number>} [CurrentLevel=0]
|
|
56
56
|
*/
|
|
57
57
|
export type RecursedPropertyDescriptorMapArray<
|
|
58
|
-
Class extends ConstructorConstraint<Class> &
|
|
58
|
+
Class extends ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>,
|
|
59
59
|
InstanceOrStatic extends 'Instance' | 'Static',
|
|
60
60
|
Limit extends Integer<number> = 16,
|
|
61
61
|
CurrentLevel extends Integer<number> = 0,
|
|
62
|
-
> = Class['__proto__'] extends
|
|
63
|
-
: Class['__proto__'] extends
|
|
62
|
+
> = Class['__proto__'] extends BaseClassPrototype['__proto__'] | BaseClassPrototype['__proto__']['__proto__'] ? never
|
|
63
|
+
: Class['__proto__'] extends BaseClassPrototype ? [RecursedPropertyDescriptorMap<BaseClass<Class>, InstanceOrStatic>]
|
|
64
64
|
: Class['__proto__'] extends ConstructorLike<Class['__proto__']>
|
|
65
65
|
? [
|
|
66
66
|
RecursedPropertyDescriptorMap<Class, InstanceOrStatic>,
|
|
67
67
|
...RecursedPropertyDescriptorMapArray<
|
|
68
|
-
ClassLike<Exclude<Class['__proto__'],
|
|
68
|
+
ClassLike<Exclude<Class['__proto__'], BaseClassPrototype> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
69
69
|
InstanceOrStatic,
|
|
70
70
|
Limit,
|
|
71
71
|
Increment<CurrentLevel>
|
|
@@ -88,7 +88,7 @@ export type RecursedPropertyDescriptorMapArray<
|
|
|
88
88
|
*/
|
|
89
89
|
export function getOwnPropertyDescriptorsRecursively<
|
|
90
90
|
// Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>,
|
|
91
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
91
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
92
92
|
_InstanceOrStatic extends InstanceOrStatic,
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
94
94
|
Limit extends Integer<number> = 16,
|
|
@@ -96,17 +96,17 @@ export function getOwnPropertyDescriptorsRecursively<
|
|
|
96
96
|
classDefinition: Class,
|
|
97
97
|
instanceOrStatic: _InstanceOrStatic,
|
|
98
98
|
): RecursedPropertyDescriptorMapArray<Class, _InstanceOrStatic> {
|
|
99
|
-
const
|
|
100
|
-
if (isSingleTuple(
|
|
99
|
+
const staticPrototypeChain: PrototypeChainOfClass<Class> = getPrototypesChainOf(classDefinition, 'classes');
|
|
100
|
+
if (isSingleTuple(staticPrototypeChain)) {
|
|
101
101
|
return [
|
|
102
102
|
getOwnPropertyDescriptors(
|
|
103
|
-
|
|
103
|
+
staticPrototypeChain[0],
|
|
104
104
|
instanceOrStatic,
|
|
105
105
|
) as RecursedPropertyDescriptorMap<Class, _InstanceOrStatic>,
|
|
106
106
|
] as unknown as RecursedPropertyDescriptorMapArray<Class, _InstanceOrStatic, Limit>;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
const recursedPropertyDescriptorMapArray =
|
|
109
|
+
const recursedPropertyDescriptorMapArray = staticPrototypeChain.map(classDefinition =>
|
|
110
110
|
getOwnPropertyDescriptors(
|
|
111
111
|
classDefinition,
|
|
112
112
|
instanceOrStatic,
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
import type { TupleIndices } from '../miscTypes.ts';
|
|
3
3
|
import { getPrototypeOf } from './getPrototypeOf.ts';
|
|
4
4
|
import {
|
|
5
|
-
baseClassProto,
|
|
6
|
-
type BaseClassProto,
|
|
5
|
+
baseClassProto as baseClassPrototype,
|
|
6
|
+
type BaseClassProto as BaseClassPrototype,
|
|
7
7
|
type ClassLike,
|
|
8
8
|
type ConstructorConstraint,
|
|
9
|
-
type ProtoChainOfClass,
|
|
10
|
-
type ProtoChainOfClassInstance,
|
|
9
|
+
type ProtoChainOfClass as PrototypeChainOfClass,
|
|
10
|
+
type ProtoChainOfClassInstance as PrototypeChainOfClassInstance,
|
|
11
11
|
type SuperClassLike,
|
|
12
|
-
type WithProto,
|
|
12
|
+
type WithProto as WithPrototype,
|
|
13
13
|
} from './inheritance.ts';
|
|
14
14
|
import { isConstructor } from './isConstructor.ts';
|
|
15
15
|
|
|
16
|
-
type
|
|
17
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
16
|
+
type PrototypeChain<
|
|
17
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
18
18
|
ClassesOrInstances extends 'classes' | 'classInstances',
|
|
19
|
-
> = [ClassesOrInstances] extends ['classInstances'] ?
|
|
20
|
-
: [ClassesOrInstances] extends ['classes'] ?
|
|
19
|
+
> = [ClassesOrInstances] extends ['classInstances'] ? PrototypeChainOfClassInstance<Class>
|
|
20
|
+
: [ClassesOrInstances] extends ['classes'] ? PrototypeChainOfClass<Class>
|
|
21
21
|
: never;
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -32,21 +32,21 @@ type ProtoChain<
|
|
|
32
32
|
* Excludes default superclasses e.g. anonymous functions, native code.
|
|
33
33
|
*/
|
|
34
34
|
export function getPrototypesChainOf<
|
|
35
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
35
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
36
36
|
ClassesOrInstances extends 'classes' | 'classInstances',
|
|
37
37
|
>(
|
|
38
38
|
classDefinition: Class,
|
|
39
39
|
returnType: ClassesOrInstances,
|
|
40
|
-
):
|
|
40
|
+
): PrototypeChain<Class, ClassesOrInstances> {
|
|
41
41
|
// class definitions or their respective .prototype; exclude default superclasses.
|
|
42
|
-
let current:
|
|
43
|
-
let parent: typeof current & WithProto<SuperClassLike | BaseClassProto> | object;
|
|
42
|
+
let current: PrototypeChainOfClass<Class>[TupleIndices<PrototypeChainOfClass<Class>>] = classDefinition as PrototypeChainOfClass<Class>[0 extends TupleIndices<PrototypeChainOfClass<Class>> ? 0 : never];
|
|
44
43
|
const returnValue = [] as unknown as
|
|
45
|
-
|
|
44
|
+
PrototypeChain<Class, ClassesOrInstances>;
|
|
46
45
|
let index: TupleIndices<typeof returnValue> = 0 as TupleIndices<typeof returnValue>;
|
|
47
46
|
|
|
48
|
-
while (
|
|
49
|
-
parent
|
|
47
|
+
while (baseClassPrototype !== current) {
|
|
48
|
+
const parent: typeof current & WithPrototype<SuperClassLike | BaseClassPrototype> | object
|
|
49
|
+
= getPrototypeOf(current);
|
|
50
50
|
// current is a Class symbol/constructor. Object.getOwnPropertyDescriptors on current will include static properties.
|
|
51
51
|
if (!isConstructor(current))
|
|
52
52
|
break;
|
|
@@ -70,7 +70,7 @@ export function getPrototypesChainOf<
|
|
|
70
70
|
&& typeof parent.name === 'string'
|
|
71
71
|
&& '' !== parent.name // it's possible for a Function/Constructor to be anonymous...
|
|
72
72
|
) {
|
|
73
|
-
current = parent as
|
|
73
|
+
current = parent as PrototypeChainOfClass<Class>[TupleIndices<PrototypeChainOfClass<Class>>];
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
break;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProtoOrSuperClass, WithProto } from './inheritance.ts';
|
|
1
|
+
import type { ProtoOrSuperClass as PrototypeOrSuperClass, WithProto as WithPrototype } from './inheritance.ts';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A nearly useless wrapper for {@link Reflect.getPrototypeOf}
|
|
@@ -6,7 +6,7 @@ import type { ProtoOrSuperClass, WithProto } from './inheritance.ts';
|
|
|
6
6
|
* @returns The `__proto__` of the `object` param.
|
|
7
7
|
*/
|
|
8
8
|
export function getPrototypeOf<
|
|
9
|
-
T extends
|
|
9
|
+
T extends WithPrototype<PrototypeOrSuperClass>,
|
|
10
10
|
>(object: T): T['__proto__'] {
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
12
12
|
return Reflect.getPrototypeOf(object) as T['__proto__'];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable unicorn/name-replacements */
|
|
1
2
|
import type { Increment } from '../GracefulRecursion.d.ts';
|
|
2
3
|
import type { Integer } from '../miscTypes.ts';
|
|
3
4
|
import type { FunctionLike } from './FunctionLike.d.ts';
|
|
@@ -54,7 +55,7 @@ export type BaseClass<Class extends ConstructorConstraint<Class>>
|
|
|
54
55
|
* @since 3.0.0
|
|
55
56
|
*/
|
|
56
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
export type Constructor_Unknown = abstract new (...
|
|
58
|
+
export type Constructor_Unknown = abstract new (...arguments_: any[]) => any;
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* The constraint for constructor types.
|
|
@@ -63,7 +64,7 @@ export type Constructor_Unknown = abstract new (...args: any[]) => any;
|
|
|
63
64
|
* @template T Any newable constructor type
|
|
64
65
|
* @since 3.0.0
|
|
65
66
|
*/
|
|
66
|
-
export type ConstructorConstraint<T extends abstract new (...
|
|
67
|
+
export type ConstructorConstraint<T extends abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>> = abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>;
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* {@link T} is a class constructor or unknown constructor. Else, `never`.
|
|
@@ -257,6 +258,6 @@ export type InstanceTypeOrSelf<T extends object | null> = T extends ConstructorL
|
|
|
257
258
|
* @template __proto__ the type of the an object's `[[Prototype]]`.
|
|
258
259
|
* @since 3.0.0
|
|
259
260
|
*/
|
|
260
|
-
export interface WithProto<
|
|
261
|
-
['__proto__']:
|
|
261
|
+
export interface WithProto<__prototype__ extends ProtoOrSuperClass> {
|
|
262
|
+
['__proto__']: __prototype__;
|
|
262
263
|
}
|
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
* used with the `new` keyword.
|
|
9
9
|
* #### NOTE: Only works when targeting ES6/ES2015 or later.
|
|
10
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
|
|
12
|
-
* @returns `true` if the
|
|
11
|
+
* @param object Anything.
|
|
12
|
+
* @returns `true` if the {@link object} is a constructor. Else, `false`.
|
|
13
13
|
* @since 3.0.0
|
|
14
14
|
* @see https://stackoverflow.com/a/49510834
|
|
15
15
|
*/
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
export function isConstructor(
|
|
17
|
+
export function isConstructor(object: unknown): object is abstract new (...arguments_: any[]) => any {
|
|
18
18
|
// Method 0 - filter
|
|
19
|
-
if (typeof
|
|
19
|
+
if (typeof object !== 'function')
|
|
20
20
|
return false;
|
|
21
21
|
|
|
22
22
|
// Method 1
|
|
23
23
|
// statically-defined class
|
|
24
|
-
if (/^class\s/.test(
|
|
24
|
+
if (/^class\s/.test(object.toString()))
|
|
25
25
|
return true;
|
|
26
26
|
|
|
27
27
|
/* Method 2
|
|
@@ -38,7 +38,7 @@ export function isConstructor(obj: unknown): obj is abstract new (...args: any[]
|
|
|
38
38
|
* typeof Function.prototype
|
|
39
39
|
* > 'function'
|
|
40
40
|
*/
|
|
41
|
-
const prototype: unknown =
|
|
41
|
+
const prototype: unknown = object.prototype;
|
|
42
42
|
if ((typeof prototype === 'object' || typeof prototype === 'function')
|
|
43
43
|
&& prototype !== null
|
|
44
44
|
&& 'constructor' in prototype
|
|
@@ -50,7 +50,7 @@ export function isConstructor(obj: unknown): obj is abstract new (...args: any[]
|
|
|
50
50
|
);
|
|
51
51
|
// short-circuit if `obj.prototype.constructor` is a function, but not a constructor. Return false.
|
|
52
52
|
return (
|
|
53
|
-
_ctor ===
|
|
53
|
+
_ctor === object
|
|
54
54
|
&& _name?.writable === false
|
|
55
55
|
&& _name.enumerable === false
|
|
56
56
|
&& _name.configurable === true
|
|
@@ -2,12 +2,12 @@ import type { InstanceOrStatic } from '../miscTypes.ts';
|
|
|
2
2
|
import { filterForGetters } from './filterForGetters.ts';
|
|
3
3
|
import { getOwnPropertyDescriptors } from './getOwnPropertyDescriptors.ts';
|
|
4
4
|
import type {
|
|
5
|
-
BaseClassProto,
|
|
5
|
+
BaseClassProto as BaseClassPrototype,
|
|
6
6
|
ClassLike,
|
|
7
7
|
ConstructorConstraint,
|
|
8
8
|
InstanceTypeOrSelf,
|
|
9
9
|
SuperClassLike,
|
|
10
|
-
WithProto,
|
|
10
|
+
WithProto as WithPrototype,
|
|
11
11
|
} from './inheritance.ts';
|
|
12
12
|
import type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';
|
|
13
13
|
import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
@@ -19,16 +19,16 @@ import type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';
|
|
|
19
19
|
* @since 3.0.0
|
|
20
20
|
*/
|
|
21
21
|
type OwnGetters<
|
|
22
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
22
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
23
23
|
_InstanceOrStatic extends InstanceOrStatic,
|
|
24
24
|
>
|
|
25
25
|
= [_InstanceOrStatic] extends ['Instance']
|
|
26
26
|
? Exclude<
|
|
27
|
-
(Class['__proto__'] extends
|
|
27
|
+
(Class['__proto__'] extends BaseClassPrototype ? null : InstanceTypeOrSelf<Class['__proto__']>) extends null
|
|
28
28
|
? keyof InstanceType<Class>
|
|
29
29
|
: Exclude<
|
|
30
30
|
keyof InstanceType<Class>,
|
|
31
|
-
keyof (Class['__proto__'] extends
|
|
31
|
+
keyof (Class['__proto__'] extends BaseClassPrototype ? null : InstanceTypeOrSelf<Class['__proto__']>)
|
|
32
32
|
>,
|
|
33
33
|
'__proto__'
|
|
34
34
|
>[]
|
|
@@ -54,7 +54,7 @@ type OwnGetters<
|
|
|
54
54
|
* 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;
|
|
55
55
|
*/
|
|
56
56
|
export function listOwnGetters<
|
|
57
|
-
Class extends ClassLike<ConstructorConstraint<Class> &
|
|
57
|
+
Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,
|
|
58
58
|
_InstanceOrStatic extends InstanceOrStatic,
|
|
59
59
|
>(
|
|
60
60
|
classDefinition: Class,
|
|
@@ -66,7 +66,7 @@ export function listOwnGetters<
|
|
|
66
66
|
const keyArray = Reflect.ownKeys(getterDescriptorMap) as (keyof typeof getterDescriptorMap)[];
|
|
67
67
|
return keyArray as [typeof instanceOrStatic & 'Instance'] extends ['Instance'] ? typeof keyArray : never;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
if (instanceOrStatic === 'Static') {
|
|
70
70
|
const descriptorMap: OwnPropertyDescriptorMap<Class> = getOwnPropertyDescriptors(classDefinition, instanceOrStatic as 'Static');
|
|
71
71
|
const getterDescriptorMap = filterForGetters(descriptorMap);
|
|
72
72
|
const keyArray = Reflect.ownKeys(getterDescriptorMap) as (keyof typeof getterDescriptorMap)[];
|
|
@@ -76,5 +76,5 @@ export function listOwnGetters<
|
|
|
76
76
|
? typeof keyArray
|
|
77
77
|
: never;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
throw new TypeError('Argument `instanceOrStatic` must be "Instance" or "Static".');
|
|
80
80
|
}
|
package/tsconfig.base.json
CHANGED
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
"extends": "./tsconfig.node.json",
|
|
27
27
|
"compilerOptions": {
|
|
28
28
|
"allowImportingTsExtensions": true,
|
|
29
|
+
"allowJs": false,
|
|
29
30
|
"composite": true,
|
|
30
31
|
"declarationMap": true,
|
|
31
32
|
"emitDeclarationOnly": true,
|
|
33
|
+
"erasableSyntaxOnly": true,
|
|
32
34
|
"forceConsistentCasingInFileNames": true,
|
|
33
35
|
"isolatedDeclarations": true,
|
|
34
36
|
"isolatedModules": true,
|