@halospv3/hce.shared-config 3.5.3-develop.2 → 3.6.0-develop.1
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 +13 -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 +24 -23
- 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
package/mjs/utils/execAsync.mjs
CHANGED
|
@@ -8,14 +8,16 @@ import { constants } from "node:os";
|
|
|
8
8
|
* A `promisify(exec)` wrapper to optionally assign the child process's STDERR as the {@link Error.prototype.cause}.
|
|
9
9
|
* @see {@link promisify}, {@link exec}
|
|
10
10
|
* @param command The command to run, with space-separated arguments.
|
|
11
|
-
* @param [
|
|
11
|
+
* @param [shouldSetStderrAsCause=false] If true and the child process's stderr is available, the thrown Error's {@link Error.prototype.cause} is assigned the stderr string.
|
|
12
12
|
* @returns A promise of the child process's STDOUT and STDERR streams as strings
|
|
13
13
|
* @throws {Error | ChildProcessSpawnException}
|
|
14
14
|
*/
|
|
15
|
-
async function execAsync(command,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
async function execAsync(command, shouldSetStderrAsCause = false) {
|
|
16
|
+
try {
|
|
17
|
+
return await promisify(exec)(command);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (!isError(error)) throw new Error(JSON.stringify(error), { cause: error });
|
|
20
|
+
if (shouldSetStderrAsCause && "stderr" in error && typeof error.stderr === "string" && error.stderr !== "") error.cause ??= error.stderr;
|
|
19
21
|
if ("stdout" in error && typeof error.stdout === "string") error.message += `
|
|
20
22
|
STDOUT:
|
|
21
23
|
${error.stdout.replaceAll("\n", "\n ")}`;
|
|
@@ -23,7 +25,7 @@ STDOUT:
|
|
|
23
25
|
STDERR:
|
|
24
26
|
${error.stderr.replaceAll("\n", "\n ")}`;
|
|
25
27
|
throw new ChildProcessSpawnException(error.message, error);
|
|
26
|
-
}
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
const T_ExecException = type("Error").and({
|
|
29
31
|
"cmd?": "string | null",
|
|
@@ -34,6 +36,12 @@ const T_ExecException = type("Error").and({
|
|
|
34
36
|
"stderr?": "string"
|
|
35
37
|
});
|
|
36
38
|
var ChildProcessSpawnException = class extends Error {
|
|
39
|
+
cmd;
|
|
40
|
+
code;
|
|
41
|
+
killed;
|
|
42
|
+
signal;
|
|
43
|
+
stderr;
|
|
44
|
+
stdout;
|
|
37
45
|
constructor(message, options) {
|
|
38
46
|
options = T_ExecException.from(options);
|
|
39
47
|
super(message, options);
|
|
@@ -44,12 +52,6 @@ var ChildProcessSpawnException = class extends Error {
|
|
|
44
52
|
this.stderr = options.stderr;
|
|
45
53
|
this.stdout = options.stdout;
|
|
46
54
|
}
|
|
47
|
-
cmd;
|
|
48
|
-
code;
|
|
49
|
-
killed;
|
|
50
|
-
signal;
|
|
51
|
-
stderr;
|
|
52
|
-
stdout;
|
|
53
55
|
};
|
|
54
56
|
//#endregion
|
|
55
57
|
export { ChildProcessSpawnException, execAsync };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execAsync.mjs","names":[],"sources":["../../src/utils/execAsync.ts"],"sourcesContent":["/* eslint-disable jsdoc/no-defaults */\nimport { type, type Type } from 'arktype';\nimport { exec } from 'node:child_process';\nimport { constants } from 'node:os';\nimport { promisify } from 'node:util';\nimport { isError } from './isError.ts';\n\n/**\n * A `promisify(exec)` wrapper to optionally assign the child process's STDERR as the {@link Error.prototype.cause}.\n * @see {@link promisify}, {@link exec}\n * @param command The command to run, with space-separated arguments.\n * @param [
|
|
1
|
+
{"version":3,"file":"execAsync.mjs","names":[],"sources":["../../src/utils/execAsync.ts"],"sourcesContent":["/* eslint-disable jsdoc/no-defaults */\nimport { type, type Type } from 'arktype';\nimport { exec } from 'node:child_process';\nimport { constants } from 'node:os';\nimport { promisify } from 'node:util';\nimport { isError } from './isError.ts';\n\n/**\n * A `promisify(exec)` wrapper to optionally assign the child process's STDERR as the {@link Error.prototype.cause}.\n * @see {@link promisify}, {@link exec}\n * @param command The command to run, with space-separated arguments.\n * @param [shouldSetStderrAsCause=false] If true and the child process's stderr is available, the thrown Error's {@link Error.prototype.cause} is assigned the stderr string.\n * @returns A promise of the child process's STDOUT and STDERR streams as strings\n * @throws {Error | ChildProcessSpawnException}\n */\nexport async function execAsync(command: string, shouldSetStderrAsCause = false): Promise<{\n stdout: string;\n stderr: string;\n}> {\n try {\n return await promisify(exec)(command);\n }\n catch (error: unknown) {\n if (!isError(error))\n throw new Error(JSON.stringify(error), { cause: error });\n\n if (shouldSetStderrAsCause && 'stderr' in error && typeof error.stderr === 'string' && error.stderr !== '')\n error.cause ??= error.stderr;\n\n if ('stdout' in error && typeof error.stdout === 'string') {\n error.message\n += '\\nSTDOUT:\\n'\n + ` ${error.stdout.replaceAll('\\n', '\\n ')}`;\n }\n if ('stderr' in error && typeof error.stderr === 'string') {\n error.message\n += '\\nSTDERR:\\n'\n + ` ${error.stderr.replaceAll('\\n', '\\n ')}`;\n }\n\n throw new ChildProcessSpawnException(error.message, error);\n }\n}\n\nconst T_ExecException: Type<{\n name: string;\n message: string;\n stack?: string | undefined;\n cause?: unknown;\n cmd?: string | null | undefined;\n killed?: boolean | null | undefined;\n code?: number | null | undefined;\n signal?: 'SIGABRT' | 'SIGALRM' | 'SIGBUS' | 'SIGCHLD' | 'SIGCONT' | 'SIGFPE' | 'SIGHUP' | 'SIGILL' | 'SIGINT' | 'SIGIO' | 'SIGIOT' | 'SIGKILL' | 'SIGPIPE' | 'SIGPOLL' | 'SIGPROF' | 'SIGPWR' | 'SIGQUIT' | 'SIGSEGV' | 'SIGSTKFLT' | 'SIGSTOP' | 'SIGSYS' | 'SIGTERM' | 'SIGTRAP' | 'SIGTSTP' | 'SIGTTIN' | 'SIGTTOU' | 'SIGUNUSED' | 'SIGURG' | 'SIGUSR1' | 'SIGUSR2' | 'SIGVTALRM' | 'SIGWINCH' | 'SIGXCPU' | 'SIGXFSZ' | 'SIGBREAK' | 'SIGLOST' | 'SIGINFO' | null | undefined;\n stdout?: string | undefined;\n stderr?: string | undefined;\n}> = type('Error').and({\n 'cmd?': 'string | null',\n 'killed?': 'boolean | null',\n 'code?': 'number | null',\n 'signal?': type.null.or((Object.keys(constants.signals) as NodeJS.Signals[])\n .map(v => type(`'${v}'`))\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce((previous, current) => previous.or(current))),\n 'stdout?': 'string',\n 'stderr?': 'string',\n});\n\ntype _ExecException = typeof T_ExecException.inferOut;\n\nexport class ChildProcessSpawnException extends Error implements _ExecException {\n cmd: typeof T_ExecException.inferOut.cmd;\n code: typeof T_ExecException.inferOut.code;\n killed: typeof T_ExecException.inferOut.killed;\n signal: typeof T_ExecException.inferOut.signal;\n stderr: typeof T_ExecException.inferOut.stderr;\n stdout: typeof T_ExecException.inferOut.stdout;\n\n constructor(\n message: Parameters<typeof Error>[0],\n options: typeof T_ExecException.inferIn,\n ) {\n options = T_ExecException.from(options);\n super(message, options);\n this.cmd = options.cmd;\n this.code = options.code;\n this.killed = options.killed;\n this.signal = options.signal;\n this.stderr = options.stderr;\n this.stdout = options.stdout;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,eAAsB,UAAU,SAAiB,yBAAyB,OAGvE;CACD,IAAI;EACF,OAAO,MAAM,UAAU,IAAI,CAAC,CAAC,OAAO;CACtC,SACO,OAAgB;EACrB,IAAI,CAAC,QAAQ,KAAK,GAChB,MAAM,IAAI,MAAM,KAAK,UAAU,KAAK,GAAG,EAAE,OAAO,MAAM,CAAC;EAEzD,IAAI,0BAA0B,YAAY,SAAS,OAAO,MAAM,WAAW,YAAY,MAAM,WAAW,IACtG,MAAM,UAAU,MAAM;EAExB,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,UAC/C,MAAM,WACD;;IACM,MAAM,OAAO,WAAW,MAAM,MAAM;EAEjD,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,UAC/C,MAAM,WACD;;IACM,MAAM,OAAO,WAAW,MAAM,MAAM;EAGjD,MAAM,IAAI,2BAA2B,MAAM,SAAS,KAAK;CAC3D;AACF;AAEA,MAAM,kBAWD,KAAK,OAAO,CAAC,CAAC,IAAI;CACrB,QAAQ;CACR,WAAW;CACX,SAAS;CACT,WAAW,KAAK,KAAK,GAAI,OAAO,KAAK,UAAU,OAAO,CAAC,CACpD,KAAI,MAAK,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC,CAExB,QAAQ,UAAU,YAAY,SAAS,GAAG,OAAO,CAAC,CAAC;CACtD,WAAW;CACX,WAAW;AACb,CAAC;AAID,IAAa,6BAAb,cAAgD,MAAgC;CAC9E;CACA;CACA;CACA;CACA;CACA;CAEA,YACE,SACA,SACA;EACA,UAAU,gBAAgB,KAAK,OAAO;EACtC,MAAM,SAAS,OAAO;EACtB,KAAK,MAAM,QAAQ;EACnB,KAAK,OAAO,QAAQ;EACpB,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;CACxB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isError.mjs","names":[],"sources":["../../src/utils/isError.ts"],"sourcesContent":["import { isNativeError } from 'node:util/types';\n\n/** @import 'typescript/lib/lib.esnext.error.d.ts' */\n\n/**\n * Compatibility wrapper for ES2026 (Node.js 25)\n * {@link Error.isError Error.isError}\n * with failover to the deprecated {@link isNativeError utils.types.isNativeError}.\n * @param error A parameter which may be an Error.\n * @returns `true` if {@link error} is derived from or is sufficiently similar to {@link Error}. Else, `false`.\n * Note: DOMExceptions will result in `false`\n */\nexport function isError(error: unknown): error is Error {\n return 'isError' in Error && typeof Error.isError === 'function' && Error.isError.length > 0\n ? Error.isError(error)\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n : isNativeError(error);\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,QAAQ,OAAgC;CACtD,OAAO,aAAa,SAAS,OAAO,MAAM,YAAY,cAAc,MAAM,QAAQ,SAAS,IACvF,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"isError.mjs","names":[],"sources":["../../src/utils/isError.ts"],"sourcesContent":["import { isNativeError } from 'node:util/types';\n\n/** @import 'typescript/lib/lib.esnext.error.d.ts' */\n\n/**\n * Compatibility wrapper for ES2026 (Node.js 25)\n * {@link Error.isError Error.isError}\n * with failover to the deprecated {@link isNativeError utils.types.isNativeError}.\n * @param error A parameter which may be an Error.\n * @returns `true` if {@link error} is derived from or is sufficiently similar to {@link Error}. Else, `false`.\n * Note: DOMExceptions will result in `false`\n */\nexport function isError(error: unknown): error is Error {\n return 'isError' in Error && typeof Error.isError === 'function' && Error.isError.length > 0\n ? Error.isError(error)\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n : isNativeError(error);\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,QAAQ,OAAgC;CACtD,OAAO,aAAa,SAAS,OAAO,MAAM,YAAY,cAAc,MAAM,QAAQ,SAAS,IACvF,MAAM,QAAQ,KAAK,IAEnB,cAAc,KAAK;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miscTypes.d.mts","names":[],"sources":["../../src/utils/miscTypes.ts"],"mappings":";;;cAEa,cAAA,EAAgB,IAAA;AAAA,KACjB,aAAA,UAAuB,cAAA,CAAe,KAAA;AAAA,cAErC,qBAAA,EAAuB,IAAA;AAAA,KACxB,oBAAA,UAA8B,qBAAA,CAAsB,KAAA;AAAA,KAEpD,OAAA,wBAA+B,CAAA,2CAA4C,CAAA
|
|
1
|
+
{"version":3,"file":"miscTypes.d.mts","names":[],"sources":["../../src/utils/miscTypes.ts"],"mappings":";;;cAEa,cAAA,EAAgB,IAAA;AAAA,KACjB,aAAA,UAAuB,cAAA,CAAe,KAAA;AAAA,cAErC,qBAAA,EAAuB,IAAA;AAAA,KACxB,oBAAA,UAA8B,qBAAA,CAAsB,KAAA;AAAA,KAEpD,OAAA,wBAA+B,CAAA,2CAA4C,CAAA;;AAN1D;AAC7B;KAUY,YAAA,iCACR,OAAA,OAAc,CAAA,qDAAsD,CAAA;AAAA,KAE5D,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miscTypes.mjs","names":[],"sources":["../../src/utils/miscTypes.ts"],"sourcesContent":["import { type, type Type } from 'arktype';\n\nexport const tBooleanString: Type<'false' | 'true'> = type('\"true\" | \"false\"');\nexport type BooleanString = typeof tBooleanString.infer;\n\nexport const tEmptyOrBooleanString: Type<'' | 'false' | 'true'> = type(tBooleanString.or('\"\"'));\nexport type EmptyOrBooleanString = typeof tEmptyOrBooleanString.infer;\n\nexport type Integer<N extends number> = `${N}` extends `${number}.${number}` ? never : N;\n\n/**\n * @see https://stackoverflow.com/a/73920140/14894786\n */\nexport type TupleIndices<T extends readonly unknown[]>\n = Extract<keyof T, `${number}`> extends `${infer N extends number}` ? N : never;\n\nexport type InstanceOrStatic = 'Instance' | 'Static';\n"],"mappings":";;AAEA,MAAa,iBAAyC,KAAK,
|
|
1
|
+
{"version":3,"file":"miscTypes.mjs","names":[],"sources":["../../src/utils/miscTypes.ts"],"sourcesContent":["import { type, type Type } from 'arktype';\n\nexport const tBooleanString: Type<'false' | 'true'> = type('\"true\" | \"false\"');\nexport type BooleanString = typeof tBooleanString.infer;\n\nexport const tEmptyOrBooleanString: Type<'' | 'false' | 'true'> = type(tBooleanString.or('\"\"'));\nexport type EmptyOrBooleanString = typeof tEmptyOrBooleanString.infer;\n\nexport type Integer<N extends number> = `${N}` extends `${number}.${number}` ? never : N;\n\n/**\n * @see https://stackoverflow.com/a/73920140/14894786\n */\nexport type TupleIndices<T extends readonly unknown[]>\n = Extract<keyof T, `${number}`> extends `${infer N extends number}` ? N : never;\n\nexport type InstanceOrStatic = 'Instance' | 'Static';\n"],"mappings":";;AAEA,MAAa,iBAAyC,KAAK,sBAAkB;AAG7E,MAAa,wBAAqD,KAAK,eAAe,GAAG,MAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionLike.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"FunctionLike.d.mts","names":["T","args","P","Parameters","R","ReturnType"],"sources":["../../../src/utils/reflection/FunctionLike.d.ts"],"mappings":";;AAaA;;;;;;;;;;;;KAAY,YAAA,gBACKC,IAAAA,yCAA6CA,IAAAA,6CAClD,UAAA,CAAW,CAAA,IAAK,UAAA,CAAW,CAAA,aAC3B,UAAA,CAAW,CAAA,IAAK,UAAA,CAAW,CAAA,KACnC,CAAA,QAASA,IAAAA,EAAM,CAAA,KAAM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetterDescriptor.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"GetterDescriptor.d.mts","names":["T","Omit","TypedPropertyDescriptor","Required","Pick"],"sources":["../../../src/utils/reflection/GetterDescriptor.d.ts"],"mappings":";;AAMA;;;;;KAAY,gBAAA,gBAAgC,IAAA,CAAK,uBAAA,CAAwB,CAAA,YACrE,QAAA,CAAS,IAAA,CAAK,uBAAA,CAAwB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstancePropertyDescriptorMap.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"InstancePropertyDescriptorMap.d.mts","names":["Class","ConstructorConstraint","WithPrototype","SuperClassLike","BaseClassPrototype","PropertyDescriptorMap","InstanceType","InstanceTypeOrSelf"],"sources":["../../../src/utils/reflection/InstancePropertyDescriptorMap.d.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KA2BY,6BAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,KAC1E,KAAA,sBAA2B,cAAA,GAC3B,qBAAA,CAAsB,YAAA,CAAa,KAAA,KACnC,qBAAA,CAAsB,YAAA,CAAa,KAAA,GAAQ,kBAAA,CAAmB,KAAA"}
|
|
@@ -11,7 +11,7 @@ import { InstancePropertyDescriptorMap } from "./InstancePropertyDescriptorMap.m
|
|
|
11
11
|
* @template __proto__ The `[[Prototype]]` of {@link T}.
|
|
12
12
|
* @since 3.0.0
|
|
13
13
|
*/
|
|
14
|
-
type InstanceTypeOrSelfPropertyDescriptorMap<T extends object | null,
|
|
14
|
+
type InstanceTypeOrSelfPropertyDescriptorMap<T extends object | null, __prototype__ extends ProtoOrSuperClass> = T extends ConstructorLike<T> ? __prototype__ extends SuperClassLike | BaseClassProto ? InstancePropertyDescriptorMap<T & WithProto<__prototype__>> : PropertyDescriptorMap<InstanceType<T>, InstanceTypeOrSelf<__prototype__>> : PropertyDescriptorMap<InstanceTypeOrSelf<T>, InstanceTypeOrSelf<__prototype__>>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { InstanceTypeOrSelfPropertyDescriptorMap };
|
|
17
17
|
//# sourceMappingURL=InstanceTypeOrSelfPropertyDescriptorMap.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceTypeOrSelfPropertyDescriptorMap.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"InstanceTypeOrSelfPropertyDescriptorMap.d.mts","names":["T","__prototype__","PrototypeOrSuperClass","ConstructorLike","SuperClassLike","BaseClassPrototype","InstancePropertyDescriptorMap","WithPrototype","PropertyDescriptorMap","InstanceType","InstanceTypeOrSelf"],"sources":["../../../src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts"],"mappings":";;;;;;AAYA;;;;;;;KAAY,uCAAA,gDAEY,iBAAA,IACpB,CAAA,SAAU,eAAA,CAAgB,CAAA,IAC1B,aAAA,SAAsB,cAAA,GAAiB,cAAA,GACrC,6BAAA,CAA8B,CAAA,GAAI,SAAA,CAAc,aAAA,KAChD,qBAAA,CAAsB,YAAA,CAAa,CAAA,GAAI,kBAAA,CAAmB,aAAA,KAC5D,qBAAA,CAAsB,kBAAA,CAAmB,CAAA,GAAI,kBAAA,CAAmB,aAAA"}
|
|
@@ -12,7 +12,7 @@ import { OwnKeyOf } from "./OwnKeyOf.mjs";
|
|
|
12
12
|
* @template __proto__ The `[[Prototype]]` of {@link T}. Keys of {@link __proto__} are omitted from the descriptor map type.
|
|
13
13
|
* @since 3.0.0
|
|
14
14
|
*/
|
|
15
|
-
type OwnGetterDescriptorMap<T,
|
|
15
|
+
type OwnGetterDescriptorMap<T, __prototype__ extends object | null> = { [P in OwnKeyOf<T, __prototype__>]: GetterDescriptor<T[P]> };
|
|
16
16
|
//#endregion
|
|
17
17
|
export { OwnGetterDescriptorMap };
|
|
18
18
|
//# sourceMappingURL=OwnGetterDescriptorMap.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnGetterDescriptorMap.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"OwnGetterDescriptorMap.d.mts","names":["T","__prototype__","P","OwnKeyOf","GetterDescriptor"],"sources":["../../../src/utils/reflection/OwnGetterDescriptorMap.d.ts"],"mappings":";;;;;AAaA;;;;;;;;;KAAY,sBAAA,mDAGA,QAAA,CAAS,CAAA,EAAG,aAAA,IAAiB,gBAAA,CAAiB,CAAA,CAAE,CAAA"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OwnKeyOf<typeof NPP, null> === "prototype" | "GetFullPath"
|
|
10
10
|
* @since 3.0.0
|
|
11
11
|
*/
|
|
12
|
-
type OwnKeyOf<T,
|
|
12
|
+
type OwnKeyOf<T, __prototype__ extends object | null> = Exclude<__prototype__ extends null ? keyof T : Exclude<keyof T, keyof __prototype__>, '__proto__'>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { OwnKeyOf };
|
|
15
15
|
//# sourceMappingURL=OwnKeyOf.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnKeyOf.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"OwnKeyOf.d.mts","names":["T","__prototype__","Exclude"],"sources":["../../../src/utils/reflection/OwnKeyOf.d.ts"],"mappings":";;AAUA;;;;;;;;;KAAY,QAAA,2CACR,OAAA,CACA,aAAA,sBACU,CAAA,GACN,OAAA,OACM,CAAA,QACA,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnPropertyDescriptorMap.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"OwnPropertyDescriptorMap.d.mts","names":["T","WithPrototype","PrototypeOrSuperClass","P0","TypedPropertyDescriptor","Omit","Exclude","P1","ClassLike","BaseClass","ClassLike_Unknown"],"sources":["../../../src/utils/reflection/OwnPropertyDescriptorMap.d.ts"],"mappings":";;;;;;;;;;;KAiBY,wBAAA,WAAmC,SAAA,CAAc,iBAAA,KACzD,CAAA,4CACiB,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,EAAA,OAC7C,IAAA,gBACe,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,EAAA,MAC7C,OAAA,sBACuB,CAAA,gBAAiB,uBAAA,CAAwB,CAAA,cAAe,EAAA,YACvE,SAAA,CAAU,SAAA,CAAU,iBAAA"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* The `null` or the `object`-like `[[Prototype]]` of {@link T}.
|
|
8
8
|
* @since 3.0.0
|
|
9
9
|
*/
|
|
10
|
-
type PropertyDescriptorMap<T,
|
|
10
|
+
type PropertyDescriptorMap<T, __prototype__ extends object | null = null> = __prototype__ extends null ? { [P0 in keyof T]: TypedPropertyDescriptor<T[P0]> } : Omit<{ [P0 in keyof T]: TypedPropertyDescriptor<T[P0]> }, keyof { [P1 in keyof __prototype__]: TypedPropertyDescriptor<__prototype__[P1]> }>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { PropertyDescriptorMap };
|
|
13
13
|
//# sourceMappingURL=PropertyDescriptorMap.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyDescriptorMap.d.mts","names":["
|
|
1
|
+
{"version":3,"file":"PropertyDescriptorMap.d.mts","names":["T","__prototype__","P0","TypedPropertyDescriptor","Omit","P1"],"sources":["../../../src/utils/reflection/PropertyDescriptorMap.d.ts"],"mappings":";;AAQA;;;;;;;KAAY,qBAAA,kDACR,aAAA,+BACiB,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,EAAA,OAC7C,IAAA,gBACe,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,EAAA,2BACxB,aAAA,GAAgB,uBAAA,CAAwB,aAAA,CAAc,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterForGetters.d.mts","names":[],"sources":["../../../src/utils/reflection/filterForGetters.ts"],"mappings":";;;;;;iBAcgB,gBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,
|
|
1
|
+
{"version":3,"file":"filterForGetters.d.mts","names":[],"sources":["../../../src/utils/reflection/filterForGetters.ts"],"mappings":";;;;;;iBAcgB,gBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,UAAwB,cAAA,IAE7F,aAAA,EAAe,6BAAA,CAA8B,KAAA,IAC5C,OAAA,CAAQ,sBAAA,CACT,YAAA,CAAa,KAAA,GACb,KAAA,sBAA2B,cAAA,UAA4B,kBAAA,CAAmB,KAAA;AAAA,iBAE5D,gBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,IAEtF,aAAA,EAAe,wBAAA,CAAyB,KAAA,IACvC,OAAA,CAAQ,sBAAA,CAAuB,KAAA,EAAO,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterForGetters.mjs","names":[],"sources":["../../../src/utils/reflection/filterForGetters.ts"],"sourcesContent":["import type {\n BaseClassProto,\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 { OwnGetterDescriptorMap } from './OwnGetterDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\nimport type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';\n\nexport function filterForGetters<\n Class extends ClassLike<ConstructorConstraint<Class> &
|
|
1
|
+
{"version":3,"file":"filterForGetters.mjs","names":[],"sources":["../../../src/utils/reflection/filterForGetters.ts"],"sourcesContent":["import type {\n BaseClassProto as BaseClassPrototype,\n baseClassProto as baseClassPrototype,\n ClassLike,\n ConstructorConstraint,\n InstanceTypeOrSelf,\n SuperClassLike,\n WithProto as WithPrototype,\n} from './inheritance.ts';\nimport type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\nimport type { OwnGetterDescriptorMap } from './OwnGetterDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\nimport type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';\n\nexport function filterForGetters<\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | typeof baseClassPrototype>>,\n>(\n descriptorMap: InstancePropertyDescriptorMap<Class>,\n): Partial<OwnGetterDescriptorMap<\n InstanceType<Class>,\n Class['__proto__'] extends BaseClassPrototype ? null : InstanceTypeOrSelf<Class['__proto__']>\n>>;\nexport function filterForGetters<\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n>(\n descriptorMap: OwnPropertyDescriptorMap<Class>,\n): Partial<OwnGetterDescriptorMap<Class, Class['__proto__']>>;\n/**\n * Iterates through the descriptors object, checking for property descriptors whose `get` is a function.\n * Returns an {@link OwnGetterDescriptorMap} of the getters.\n * If you want only own, non-inherited getters, you must filter sanitize the\n * type the `descriptors` parameter yourself e.g. `Omit<Class, keyof\n * SuperClass>`.\n * @param descriptorMap An object like the return value of Object.getOwnPropertyDescriptors\n * @template Class Any ClassLike type\n * @template T Any `object`-like type.\n * @template [__proto__=null] If {@link Class} is not {@link ClassLike}, the `__proto__` of {@link T}.\n * @returns An {@link OwnGetterDescriptorMap}.\n * @since 3.0.0\n */\nexport function filterForGetters<\n T extends object,\n __prototype__ extends object | null = null,\n>(\n descriptorMap: PropertyDescriptorMap<T, __prototype__> | PropertyDescriptorMap<T>,\n): Partial<OwnGetterDescriptorMap<T, __prototype__>> {\n let getterDescriptorMap: Partial<OwnGetterDescriptorMap<T, __prototype__>> = {};\n for (const key in descriptorMap) {\n const element = descriptorMap[key as keyof typeof descriptorMap];\n if (typeof element.get === 'function') {\n getterDescriptorMap = Object.assign(\n getterDescriptorMap,\n { [key]: element },\n );\n }\n }\n\n return getterDescriptorMap;\n}\n"],"mappings":";;;;;;;;;;;;;;AAwCA,SAAgB,iBAId,eACmD;CACnD,IAAI,sBAAyE,CAAC;CAC9E,KAAK,MAAM,OAAO,eAAe;EAC/B,MAAM,UAAU,cAAc;EAC9B,IAAI,OAAO,QAAQ,QAAQ,YACzB,sBAAsB,OAAO,OAC3B,qBACA,GAAG,MAAM,QAAQ,CACnB;CAEJ;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnPropertyDescriptors.d.mts","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptors.ts"],"mappings":";;;;;;;;AAqBA;;;;;;;;;;;;;;iBAAgB,yBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,
|
|
1
|
+
{"version":3,"file":"getOwnPropertyDescriptors.d.mts","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptors.ts"],"mappings":";;;;;;;;AAqBA;;;;;;;;;;;;;;iBAAgB,yBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,8BAC5D,gBAAA,EAE1B,eAAA,EAAiB,KAAA,EACjB,gBAAA,EAAkB,iBAAA,IAChB,iBAAA,yBACA,6BAAA,CAA8B,KAAA,KAC7B,iBAAA,uBACG,wBAAA,CAAyB,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnPropertyDescriptors.mjs","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptors.ts"],"sourcesContent":["import type { InstanceOrStatic } from '../miscTypes.ts';\nimport type { BaseClassProto, ClassLike, ConstructorConstraint, SuperClassLike, WithProto } from './inheritance.ts';\nimport type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n\n/**\n * Get the property descriptors of the class or constructor similar to {@link Object.getOwnPropertyDescriptors}, but with more options--including recursion.\n * @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @param classDefinition A class or constructor, cast to {@link ClassLike}.\n * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class\n * The typeof {@link classDefinition}.\n * {@link WithProto}<{@link SuperClassLike}> is necessary for walking the\n * prototype chain for both Instance and Static properties.\n * If unspecified, the return type may be incorrect.\n * @returns ({@link instanceOrStatic} === 'Instance') ? {@link InstancePropertyDescriptorMap<Class>}\\\n * : ({@link instanceOrStatic} === 'Static') ? {@link OwnPropertyDescriptorMap<Class>}\\\n * : never\n * @throws {TypeError}\n * @since 3.0.0\n */\nexport function getOwnPropertyDescriptors<\n Class extends ClassLike<ConstructorConstraint<Class> &
|
|
1
|
+
{"version":3,"file":"getOwnPropertyDescriptors.mjs","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptors.ts"],"sourcesContent":["import type { InstanceOrStatic } from '../miscTypes.ts';\nimport type { BaseClassProto as BaseClassPrototype, ClassLike, ConstructorConstraint, SuperClassLike, WithProto as WithPrototype } from './inheritance.ts';\nimport type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n\n/**\n * Get the property descriptors of the class or constructor similar to {@link Object.getOwnPropertyDescriptors}, but with more options--including recursion.\n * @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @param classDefinition A class or constructor, cast to {@link ClassLike}.\n * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class\n * The typeof {@link classDefinition}.\n * {@link WithProto}<{@link SuperClassLike}> is necessary for walking the\n * prototype chain for both Instance and Static properties.\n * If unspecified, the return type may be incorrect.\n * @returns ({@link instanceOrStatic} === 'Instance') ? {@link InstancePropertyDescriptorMap<Class>}\\\n * : ({@link instanceOrStatic} === 'Static') ? {@link OwnPropertyDescriptorMap<Class>}\\\n * : never\n * @throws {TypeError}\n * @since 3.0.0\n */\nexport function getOwnPropertyDescriptors<\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n _InstanceOrStatic extends InstanceOrStatic,\n>(\n classDefinition: Class,\n instanceOrStatic: _InstanceOrStatic,\n): [_InstanceOrStatic] extends ['Instance']\n ? InstancePropertyDescriptorMap<Class>\n : [_InstanceOrStatic] extends ['Static']\n ? OwnPropertyDescriptorMap<Class>\n : never {\n switch (instanceOrStatic) {\n case 'Instance': {\n return Object.getOwnPropertyDescriptors(classDefinition.prototype) as [Extract<typeof instanceOrStatic, 'Instance'>] extends ['Instance']\n ? InstancePropertyDescriptorMap<Class>\n : [_InstanceOrStatic] extends ['Static']\n ? OwnPropertyDescriptorMap<Class>\n : never;\n }\n case 'Static': {\n return Object.getOwnPropertyDescriptors(classDefinition) as [Extract<typeof instanceOrStatic, 'Static'>] extends ['Instance']\n ? InstancePropertyDescriptorMap<Class>\n : [_InstanceOrStatic] extends ['Static']\n ? OwnPropertyDescriptorMap<Class>\n : never;\n }\n default: {\n throw new TypeError('Argument `instanceOrStatic` must be \"Instance\" or \"Static\".');\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BAId,iBACA,kBAKY;CACZ,QAAQ,kBAAR;EACE,KAAK,YACH,OAAO,OAAO,0BAA0B,gBAAgB,SAAS;EAMnE,KAAK,UACH,OAAO,OAAO,0BAA0B,eAAe;EAMzD,SACE,MAAM,IAAI,UAAU,iEAA6D;CAErF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnPropertyDescriptorsRecursively.d.mts","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts"],"mappings":";;;;;;;;;AAuCA;;;;;;;;;;;;KAAY,6BAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,
|
|
1
|
+
{"version":3,"file":"getOwnPropertyDescriptorsRecursively.d.mts","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts"],"mappings":";;;;;;;;;AAuCA;;;;;;;;;;;;KAAY,6BAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,6BAClD,gBAAA,KACvB,iBAAA,yBAA0C,uCAAA,CAAwC,KAAA,EAAO,KAAA,kBACzF,iBAAA,uBAAwC,wBAAA,CAAyB,KAAA;;;;;;;;;;;KAa1D,kCAAA,eACI,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,iEAE9D,OAAA,oCACO,OAAA,gBACnB,KAAA,sBAA2B,cAAA,gBAAkC,cAAA,qCAC7D,KAAA,sBAA2B,cAAA,IAAsB,6BAAA,CAA8B,SAAA,CAAU,KAAA,GAAQ,gBAAA,KAC/F,KAAA,sBAA2B,eAAA,CAAgB,KAAA,kBAEvC,6BAAA,CAA8B,KAAA,EAAO,gBAAA,MAClC,kCAAA,CACD,SAAA,CAAU,OAAA,CAAQ,KAAA,eAAoB,cAAA,IAAsB,SAAA,CAAc,cAAA,GAAiB,cAAA,IAC3F,gBAAA,EACA,KAAA,EACA,SAAA,CAAU,YAAA;;;AA3BgD;AAatE;;;;;;;;;;;iBAgCgB,oCAAA,eAEA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,8BAC5D,gBAAA,gBAEZ,OAAA,eAEd,eAAA,EAAiB,KAAA,EACjB,gBAAA,EAAkB,iBAAA,GACjB,kCAAA,CAAmC,KAAA,EAAO,iBAAA"}
|
|
@@ -16,9 +16,9 @@ import { getPrototypesChainOf } from "./getPrototypeChainOf.mjs";
|
|
|
16
16
|
* @since 3.0.0
|
|
17
17
|
*/
|
|
18
18
|
function getOwnPropertyDescriptorsRecursively(classDefinition, instanceOrStatic) {
|
|
19
|
-
const
|
|
20
|
-
if (isSingleTuple(
|
|
21
|
-
return
|
|
19
|
+
const staticPrototypeChain = getPrototypesChainOf(classDefinition, "classes");
|
|
20
|
+
if (isSingleTuple(staticPrototypeChain)) return [getOwnPropertyDescriptors(staticPrototypeChain[0], instanceOrStatic)];
|
|
21
|
+
return staticPrototypeChain.map((classDefinition) => getOwnPropertyDescriptors(classDefinition, instanceOrStatic));
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Simple utility for single-tuple type assertion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOwnPropertyDescriptorsRecursively.mjs","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts"],"sourcesContent":["import type { Increment } from '../GracefulRecursion.d.ts';\nimport type { InstanceOrStatic, Integer } from '../miscTypes.ts';\nimport { getOwnPropertyDescriptors } from './getOwnPropertyDescriptors.ts';\nimport { getPrototypesChainOf } from './getPrototypeChainOf.ts';\nimport type {\n BaseClass,\n BaseClassProto,\n ClassLike,\n ConstructorConstraint,\n ConstructorLike,\n ProtoChainOfClass,\n SuperClassLike,\n WithProto,\n} from './inheritance.ts';\nimport type { InstanceTypeOrSelfPropertyDescriptorMap } from './InstanceTypeOrSelfPropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n/**\n * JSDoc type imports\n */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { getPrototypeOf as _getPrototypeOf } from './getPrototypeOf.ts';\nimport type { listOwnGetters as _listOwnGetters } from './listOwnGetters.ts';\nimport type { InstancePropertyDescriptorMap as _InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/**\n * A conditional wrapper for {@link InstanceTypeOrSelfPropertyDescriptorMap} and\n * {@link OwnPropertyDescriptorMap}.\n *\n * If {@link _InstanceOrStatic} is 'Instance', {@link InstanceTypeOrSelfPropertyDescriptorMap}.\\\n * Else if {@link _InstanceOrStatic} is 'Static',\n * {@link OwnPropertyDescriptorMap }.\\\n * Else, `never`.\n * @template {ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>} Class\n * A class definition cast to {@link ClassLike}.\n * @template {InstanceOrStatic} _InstanceOrStatic\n * 'Instance' or 'Static'. Determines the return type.\n * @since 3.0.0\n */\nexport type RecursedPropertyDescriptorMap<\n Class extends ConstructorConstraint<Class> &
|
|
1
|
+
{"version":3,"file":"getOwnPropertyDescriptorsRecursively.mjs","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts"],"sourcesContent":["import type { Increment } from '../GracefulRecursion.d.ts';\nimport type { InstanceOrStatic, Integer } from '../miscTypes.ts';\nimport { getOwnPropertyDescriptors } from './getOwnPropertyDescriptors.ts';\nimport { getPrototypesChainOf } from './getPrototypeChainOf.ts';\nimport type {\n BaseClass,\n BaseClassProto as BaseClassPrototype,\n ClassLike,\n ConstructorConstraint,\n ConstructorLike,\n ProtoChainOfClass as PrototypeChainOfClass,\n SuperClassLike,\n WithProto as WithPrototype,\n} from './inheritance.ts';\nimport type { InstanceTypeOrSelfPropertyDescriptorMap } from './InstanceTypeOrSelfPropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n/**\n * JSDoc type imports\n */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { getPrototypeOf as _getPrototypeOf } from './getPrototypeOf.ts';\nimport type { listOwnGetters as _listOwnGetters } from './listOwnGetters.ts';\nimport type { InstancePropertyDescriptorMap as _InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/**\n * A conditional wrapper for {@link InstanceTypeOrSelfPropertyDescriptorMap} and\n * {@link OwnPropertyDescriptorMap}.\n *\n * If {@link _InstanceOrStatic} is 'Instance', {@link InstanceTypeOrSelfPropertyDescriptorMap}.\\\n * Else if {@link _InstanceOrStatic} is 'Static',\n * {@link OwnPropertyDescriptorMap }.\\\n * Else, `never`.\n * @template {ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>} Class\n * A class definition cast to {@link ClassLike}.\n * @template {InstanceOrStatic} _InstanceOrStatic\n * 'Instance' or 'Static'. Determines the return type.\n * @since 3.0.0\n */\nexport type RecursedPropertyDescriptorMap<\n Class extends ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>,\n _InstanceOrStatic extends InstanceOrStatic,\n> = [_InstanceOrStatic] extends ['Instance'] ? InstanceTypeOrSelfPropertyDescriptorMap<Class, Class['__proto__']>\n : [_InstanceOrStatic] extends ['Static'] ? OwnPropertyDescriptorMap<Class>\n : never;\n\n/**\n * An\n * ordered array of {@link OwnPropertyDescriptorMap} or\n * {@link InstancePropertyDescriptorMap} starting with {@link classDefinition}\n * and ending with a {@link BaseClass}.\n * @template {ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>} Class\n * @template {'Instance' | 'Static'} InstanceOrStatic\n * @template {Integer<number>} [Limit=16]\n * @template {Integer<number>} [CurrentLevel=0]\n */\nexport type RecursedPropertyDescriptorMapArray<\n Class extends ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>,\n InstanceOrStatic extends 'Instance' | 'Static',\n Limit extends Integer<number> = 16,\n CurrentLevel extends Integer<number> = 0,\n> = Class['__proto__'] extends BaseClassPrototype['__proto__'] | BaseClassPrototype['__proto__']['__proto__'] ? never\n : Class['__proto__'] extends BaseClassPrototype ? [RecursedPropertyDescriptorMap<BaseClass<Class>, InstanceOrStatic>]\n : Class['__proto__'] extends ConstructorLike<Class['__proto__']>\n ? [\n RecursedPropertyDescriptorMap<Class, InstanceOrStatic>,\n ...RecursedPropertyDescriptorMapArray<\n ClassLike<Exclude<Class['__proto__'], BaseClassPrototype> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n InstanceOrStatic,\n Limit,\n Increment<CurrentLevel>\n >,\n ]\n : never;\n/**\n * Walks the class inheritance chain to get a PropertyDescriptorMap of each class.\n *\n * While you _can_ use this to get an array of getter names/keys, you should use {@link getPrototypeOf} and {@link listOwnGetters}, instead!\n * @template Class Any class definition type-cast to {@link ClassLike}\n * @template _InstanceOrStatic\n * @param classDefinition Any class definition type-cast to {@link ClassLike}\n * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @returns An\n * ordered array of {@link OwnPropertyDescriptorMap} or\n * {@link InstancePropertyDescriptorMap} starting with {@link classDefinition}\n * and ending with a {@link BaseClass}.\n * @since 3.0.0\n */\nexport function getOwnPropertyDescriptorsRecursively<\n // Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>,\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n _InstanceOrStatic extends InstanceOrStatic,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters\n Limit extends Integer<number> = 16,\n>(\n classDefinition: Class,\n instanceOrStatic: _InstanceOrStatic,\n): RecursedPropertyDescriptorMapArray<Class, _InstanceOrStatic> {\n const staticPrototypeChain: PrototypeChainOfClass<Class> = getPrototypesChainOf(classDefinition, 'classes');\n if (isSingleTuple(staticPrototypeChain)) {\n return [\n getOwnPropertyDescriptors(\n staticPrototypeChain[0],\n instanceOrStatic,\n ) as RecursedPropertyDescriptorMap<Class, _InstanceOrStatic>,\n ] as unknown as RecursedPropertyDescriptorMapArray<Class, _InstanceOrStatic, Limit>;\n }\n\n const recursedPropertyDescriptorMapArray = staticPrototypeChain.map(classDefinition =>\n getOwnPropertyDescriptors(\n classDefinition,\n instanceOrStatic,\n ),\n );\n\n return recursedPropertyDescriptorMapArray as RecursedPropertyDescriptorMapArray<Class, _InstanceOrStatic>;\n}\n\n/**\n * Simple utility for single-tuple type assertion\n * @template {T} T T in T[]\n * @param array an array\n * @returns array is [T]\n */\nfunction isSingleTuple<T>(array: T[]): array is [T] {\n return Array.isArray(array) && array.length === 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwFA,SAAgB,qCAOd,iBACA,kBAC8D;CAC9D,MAAM,uBAAqD,qBAAqB,iBAAiB,SAAS;CAC1G,IAAI,cAAc,oBAAoB,GACpC,OAAO,CACL,0BACE,qBAAqB,IACrB,gBACF,CACF;CAUF,OAP2C,qBAAqB,KAAI,oBAClE,0BACE,iBACA,gBACF,CAGsC;AAC1C;;;;;;;AAQA,SAAS,cAAiB,OAA0B;CAClD,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAClD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseClassProto, ClassLike, ConstructorConstraint, ProtoChainOfClass, ProtoChainOfClassInstance, SuperClassLike, WithProto } from "./inheritance.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/reflection/getPrototypeChainOf.d.ts
|
|
4
|
-
type
|
|
4
|
+
type PrototypeChain<Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>, ClassesOrInstances extends "classes" | "classInstances"> = [ClassesOrInstances] extends ["classInstances"] ? ProtoChainOfClassInstance<Class> : [ClassesOrInstances] extends ["classes"] ? ProtoChainOfClass<Class> : never;
|
|
5
5
|
/**
|
|
6
6
|
* Iterate through the class and its base/super classes until an anonymous function is reached. This is the default superclass all classes extend.
|
|
7
7
|
* @template Class Any {@link ClassLike} type.
|
|
@@ -13,7 +13,7 @@ type ProtoChain<Class extends ClassLike<ConstructorConstraint<Class> & WithProto
|
|
|
13
13
|
* `returnType extends 'classInstances' ? ClassLike<T>[] : ClassLike<T>[].map(c => c.prototype)`
|
|
14
14
|
* Excludes default superclasses e.g. anonymous functions, native code.
|
|
15
15
|
*/
|
|
16
|
-
declare function getPrototypesChainOf<Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>, ClassesOrInstances extends "classes" | "classInstances">(classDefinition: Class, returnType: ClassesOrInstances):
|
|
16
|
+
declare function getPrototypesChainOf<Class extends ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>, ClassesOrInstances extends "classes" | "classInstances">(classDefinition: Class, returnType: ClassesOrInstances): PrototypeChain<Class, ClassesOrInstances>;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { getPrototypesChainOf };
|
|
19
19
|
//# sourceMappingURL=getPrototypeChainOf.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrototypeChainOf.d.mts","names":[],"sources":["../../../src/utils/reflection/getPrototypeChainOf.ts"],"mappings":";;;KAeK,
|
|
1
|
+
{"version":3,"file":"getPrototypeChainOf.d.mts","names":[],"sources":["../../../src/utils/reflection/getPrototypeChainOf.ts"],"mappings":";;;KAeK,cAAA,eACW,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,gEAEnF,kBAAA,+BAAiD,yBAAA,CAA8B,KAAA,KAC/E,kBAAA,wBAA0C,iBAAA,CAAsB,KAAA;;;;;;;;;;;;iBAcrD,oBAAA,eACA,SAAA,CAAU,qBAAA,CAAsB,KAAA,IAAS,SAAA,CAAc,cAAA,GAAiB,cAAA,6DAGtF,eAAA,EAAiB,KAAA,EACjB,UAAA,EAAY,kBAAA,GACX,cAAA,CAAe,KAAA,EAAO,kBAAA"}
|
|
@@ -15,11 +15,10 @@ import { isConstructor } from "./isConstructor.mjs";
|
|
|
15
15
|
*/
|
|
16
16
|
function getPrototypesChainOf(classDefinition, returnType) {
|
|
17
17
|
let current = classDefinition;
|
|
18
|
-
let parent;
|
|
19
18
|
const returnValue = [];
|
|
20
19
|
let index = 0;
|
|
21
20
|
while (baseClassProto !== current) {
|
|
22
|
-
parent = getPrototypeOf(current);
|
|
21
|
+
const parent = getPrototypeOf(current);
|
|
23
22
|
if (!isConstructor(current)) break;
|
|
24
23
|
if (returnType === "classInstances") returnValue[index] = current.prototype;
|
|
25
24
|
else returnValue[index] = current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrototypeChainOf.mjs","names":[],"sources":["../../../src/utils/reflection/getPrototypeChainOf.ts"],"sourcesContent":["/* eslint-disable jsdoc/no-defaults */\nimport type { TupleIndices } from '../miscTypes.ts';\nimport { getPrototypeOf } from './getPrototypeOf.ts';\nimport {\n baseClassProto,\n type BaseClassProto,\n type ClassLike,\n type ConstructorConstraint,\n type ProtoChainOfClass,\n type ProtoChainOfClassInstance,\n type SuperClassLike,\n type WithProto,\n} from './inheritance.ts';\nimport { isConstructor } from './isConstructor.ts';\n\ntype
|
|
1
|
+
{"version":3,"file":"getPrototypeChainOf.mjs","names":["baseClassPrototype"],"sources":["../../../src/utils/reflection/getPrototypeChainOf.ts"],"sourcesContent":["/* eslint-disable jsdoc/no-defaults */\nimport type { TupleIndices } from '../miscTypes.ts';\nimport { getPrototypeOf } from './getPrototypeOf.ts';\nimport {\n baseClassProto as baseClassPrototype,\n type BaseClassProto as BaseClassPrototype,\n type ClassLike,\n type ConstructorConstraint,\n type ProtoChainOfClass as PrototypeChainOfClass,\n type ProtoChainOfClassInstance as PrototypeChainOfClassInstance,\n type SuperClassLike,\n type WithProto as WithPrototype,\n} from './inheritance.ts';\nimport { isConstructor } from './isConstructor.ts';\n\ntype PrototypeChain<\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n ClassesOrInstances extends 'classes' | 'classInstances',\n> = [ClassesOrInstances] extends ['classInstances'] ? PrototypeChainOfClassInstance<Class>\n : [ClassesOrInstances] extends ['classes'] ? PrototypeChainOfClass<Class>\n : never;\n\n/**\n * Iterate through the class and its base/super classes until an anonymous function is reached. This is the default superclass all classes extend.\n * @template Class Any {@link ClassLike} type.\n * @template ClassesOrInstances 'classes' or 'classInstances'\n * @param classDefinition Any class type satisfying {@link Class}. This class (or its instance type) is included in the return value.\n * @param [returnType='classes'] Determines return type. If 'classInstances', the return type is an array of the classes' `.prototype`. Else, the classes themselves are returned.\n * @since 3.0.0\n * @returns\n * `returnType extends 'classInstances' ? ClassLike<T>[] : ClassLike<T>[].map(c => c.prototype)`\n * Excludes default superclasses e.g. anonymous functions, native code.\n */\nexport function getPrototypesChainOf<\n Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n ClassesOrInstances extends 'classes' | 'classInstances',\n>(\n classDefinition: Class,\n returnType: ClassesOrInstances,\n): PrototypeChain<Class, ClassesOrInstances> {\n // class definitions or their respective .prototype; exclude default superclasses.\n let current: PrototypeChainOfClass<Class>[TupleIndices<PrototypeChainOfClass<Class>>] = classDefinition as PrototypeChainOfClass<Class>[0 extends TupleIndices<PrototypeChainOfClass<Class>> ? 0 : never];\n const returnValue = [] as unknown as\n PrototypeChain<Class, ClassesOrInstances>;\n let index: TupleIndices<typeof returnValue> = 0 as TupleIndices<typeof returnValue>;\n\n while (baseClassPrototype !== current) {\n const parent: typeof current & WithPrototype<SuperClassLike | BaseClassPrototype> | object\n = getPrototypeOf(current);\n // current is a Class symbol/constructor. Object.getOwnPropertyDescriptors on current will include static properties.\n if (!isConstructor(current))\n break;\n if (returnType === 'classInstances') {\n const instanceOfCurrent = current.prototype as InstanceType<typeof current>;\n\n returnValue[index] = instanceOfCurrent as typeof returnValue[typeof index];\n }\n else {\n returnValue[index] = current as typeof returnValue[typeof index];\n }\n\n /**\n * Assign the super class to current.\n * If the argument is a class, Reflect.getPrototypeOf method returns the\n * superclass.\n */\n if (\n isConstructor(parent)\n && 'name' in parent\n && typeof parent.name === 'string'\n && '' !== parent.name // it's possible for a Function/Constructor to be anonymous...\n ) {\n current = parent as PrototypeChainOfClass<Class>[TupleIndices<PrototypeChainOfClass<Class>>];\n }\n else {\n break;\n }\n index++;\n }\n return returnValue;\n /*\n assuming current is NugetProjectProperties...\n Reflect.getPrototypeOf(current).name is 'MSBuildProjectProperties'\n */\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAgB,qBAId,iBACA,YAC2C;CAE3C,IAAI,UAAoF;CACxF,MAAM,cAAc,CAAC;CAErB,IAAI,QAA0C;CAE9C,OAAOA,mBAAuB,SAAS;EACrC,MAAM,SACF,eAAe,OAAO;EAE1B,IAAI,CAAC,cAAc,OAAO,GACxB;EACF,IAAI,eAAe,kBAGjB,YAAY,SAFc,QAAQ;OAKlC,YAAY,SAAS;;;;;;EAQvB,IACE,cAAc,MAAM,KACjB,UAAU,UACV,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,MAEjB,UAAU;OAGV;EAEF;CACF;CACA,OAAO;AAKT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrototypeOf.d.mts","names":[],"sources":["../../../src/utils/reflection/getPrototypeOf.ts"],"mappings":";;;;;AAOA;;;iBAAgB,cAAA,WACJ,SAAA,
|
|
1
|
+
{"version":3,"file":"getPrototypeOf.d.mts","names":[],"sources":["../../../src/utils/reflection/getPrototypeOf.ts"],"mappings":";;;;;AAOA;;;iBAAgB,cAAA,WACJ,SAAA,CAAc,iBAAA,GACxB,MAAA,EAAQ,CAAA,GAAI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrototypeOf.mjs","names":[],"sources":["../../../src/utils/reflection/getPrototypeOf.ts"],"sourcesContent":["import type { ProtoOrSuperClass, WithProto } from './inheritance.ts';\n\n/**\n * A nearly useless wrapper for {@link Reflect.getPrototypeOf}\n * @param object An object with the internal `__proto__` property present in its type.\n * @returns The `__proto__` of the `object` param.\n */\nexport function getPrototypeOf<\n T extends
|
|
1
|
+
{"version":3,"file":"getPrototypeOf.mjs","names":[],"sources":["../../../src/utils/reflection/getPrototypeOf.ts"],"sourcesContent":["import type { ProtoOrSuperClass as PrototypeOrSuperClass, WithProto as WithPrototype } from './inheritance.ts';\n\n/**\n * A nearly useless wrapper for {@link Reflect.getPrototypeOf}\n * @param object An object with the internal `__proto__` property present in its type.\n * @returns The `__proto__` of the `object` param.\n */\nexport function getPrototypeOf<\n T extends WithPrototype<PrototypeOrSuperClass>,\n>(object: T): T['__proto__'] {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return Reflect.getPrototypeOf(object) as T['__proto__'];\n}\n"],"mappings":";;;;;;AAOA,SAAgB,eAEd,QAA2B;CAE3B,OAAO,QAAQ,eAAe,MAAM;AACtC"}
|
|
@@ -48,7 +48,7 @@ type BaseClass<Class extends ConstructorConstraint<Class>> = IClass<Class> & IBa
|
|
|
48
48
|
* A type representing any unknown constructor.
|
|
49
49
|
* @since 3.0.0
|
|
50
50
|
*/
|
|
51
|
-
type Constructor_Unknown = abstract new (...
|
|
51
|
+
type Constructor_Unknown = abstract new (...arguments_: any[]) => any;
|
|
52
52
|
/**
|
|
53
53
|
* The constraint for constructor types.
|
|
54
54
|
* This is intended for generic type constraints.
|
|
@@ -56,7 +56,7 @@ type Constructor_Unknown = abstract new (...args: any[]) => any;
|
|
|
56
56
|
* @template T Any newable constructor type
|
|
57
57
|
* @since 3.0.0
|
|
58
58
|
*/
|
|
59
|
-
type ConstructorConstraint<T extends abstract new (...
|
|
59
|
+
type ConstructorConstraint<T extends abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>> = abstract new (...arguments_: ConstructorParameters<T>) => InstanceType<T>;
|
|
60
60
|
/**
|
|
61
61
|
* {@link T} is a class constructor or unknown constructor. Else, `never`.
|
|
62
62
|
*
|
|
@@ -165,8 +165,8 @@ type InstanceTypeOrSelf<T extends object | null> = T extends ConstructorLike ? T
|
|
|
165
165
|
* @template __proto__ the type of the an object's `[[Prototype]]`.
|
|
166
166
|
* @since 3.0.0
|
|
167
167
|
*/
|
|
168
|
-
interface WithProto<
|
|
169
|
-
["__proto__"]:
|
|
168
|
+
interface WithProto<__prototype__ extends ProtoOrSuperClass> {
|
|
169
|
+
["__proto__"]: __prototype__;
|
|
170
170
|
}
|
|
171
171
|
//#endregion
|
|
172
172
|
export { BaseClass, BaseClassProto, ClassLike, ClassLike_Unknown, ConstructorConstraint, ConstructorLike, Constructor_Unknown, IClass, InstanceTypeOrSelf, ProtoChainOfClass, ProtoChainOfClassInstance, ProtoChainOfObject, ProtoOrSuperClass, SuperClassLike, WithProto, baseClassProto };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inheritance.d.mts","names":[],"sources":["../../../src/utils/reflection/inheritance.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"inheritance.d.mts","names":[],"sources":["../../../src/utils/reflection/inheritance.ts"],"mappings":";;;;;;;;AAWA;;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;;AAP3B;AAOF;;;;UAQU,UAAA;EARmB;;;;EAAA,CAa1B,WAAA,GAAc,cAAA;EAEf,WAAA,EAAa,mBAAA;IAAwB,IAAA;EAAA;AAAA;;AAAA;AAQvC;;;KAAY,SAAA,eAAwB,qBAAA,CAAsB,KAAA,KACtD,MAAA,CAAO,KAAA,IAAS,UAAA;;;;;KAOR,mBAAA,oBAAuC,UAAA;;;;;;;;KASvC,qBAAA,4BAAiD,UAAA,EAAY,qBAAA,CAAsB,CAAA,MAAO,YAAA,CAAa,CAAA,sBAAuB,UAAA,EAAY,qBAAA,CAAsB,CAAA,MAAO,YAAA,CAAa,CAAA;AAhB5K;AAOpB;;;;AAAmD;AASnD;AAhBoB,KAyBR,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;;AA1DkL;AAShM;;;;;;;;;;;;;;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;;;;;;;;;;;AA3E3D;AAOZ;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;;;;;;;;;;;AA1FnC;KAyGrB,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,uBAAgC,iBAAA;EAAA,CAC9C,WAAA,GAAc,aAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
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":";;;;;;AAyBA,MAAa,iBAAiC,eAAe,OAAuC"}
|
|
1
|
+
{"version":3,"file":"inheritance.mjs","names":[],"sources":["../../../src/utils/reflection/inheritance.ts"],"sourcesContent":["/* eslint-disable unicorn/name-replacements */\nimport 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 (...arguments_: 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 (...arguments_: 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<__prototype__ extends ProtoOrSuperClass> {\n ['__proto__']: __prototype__;\n}\n"],"mappings":";;;;;;AA0BA,MAAa,iBAAiC,eAAe,MAAsC"}
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
* used with the `new` keyword.
|
|
10
10
|
* #### NOTE: Only works when targeting ES6/ES2015 or later.
|
|
11
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
|
|
13
|
-
* @returns `true` if the
|
|
12
|
+
* @param object Anything.
|
|
13
|
+
* @returns `true` if the {@link object} is a constructor. Else, `false`.
|
|
14
14
|
* @since 3.0.0
|
|
15
15
|
* @see https://stackoverflow.com/a/49510834
|
|
16
16
|
*/
|
|
17
|
-
declare function isConstructor(
|
|
17
|
+
declare function isConstructor(object: unknown): object is abstract new (...arguments_: any[]) => any;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { isConstructor };
|
|
20
20
|
//# sourceMappingURL=isConstructor.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isConstructor.d.mts","names":[],"sources":["../../../src/utils/reflection/isConstructor.ts"],"mappings":";;AAgBA
|
|
1
|
+
{"version":3,"file":"isConstructor.d.mts","names":[],"sources":["../../../src/utils/reflection/isConstructor.ts"],"mappings":";;AAgBA;;;;;;;;AAA2E;;;;;;iBAA3D,aAAA,CAAc,MAAA,YAAkB,MAAA,qBAA2B,UAAA"}
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
* used with the `new` keyword.
|
|
10
10
|
* #### NOTE: Only works when targeting ES6/ES2015 or later.
|
|
11
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
|
|
13
|
-
* @returns `true` if the
|
|
12
|
+
* @param object Anything.
|
|
13
|
+
* @returns `true` if the {@link object} is a constructor. Else, `false`.
|
|
14
14
|
* @since 3.0.0
|
|
15
15
|
* @see https://stackoverflow.com/a/49510834
|
|
16
16
|
*/
|
|
17
|
-
function isConstructor(
|
|
18
|
-
if (typeof
|
|
19
|
-
if (/^class\s/.test(
|
|
20
|
-
const prototype =
|
|
17
|
+
function isConstructor(object) {
|
|
18
|
+
if (typeof object !== "function") return false;
|
|
19
|
+
if (/^class\s/.test(object.toString())) return true;
|
|
20
|
+
const prototype = object.prototype;
|
|
21
21
|
if ((typeof prototype === "object" || typeof prototype === "function") && prototype !== null && "constructor" in prototype && typeof prototype.constructor === "function") {
|
|
22
22
|
const _ctor = prototype.constructor;
|
|
23
23
|
const _name = Reflect.getOwnPropertyDescriptor(_ctor, "name");
|
|
24
|
-
return _ctor ===
|
|
24
|
+
return _ctor === object && _name?.writable === false && _name.enumerable === false && _name.configurable === true;
|
|
25
25
|
}
|
|
26
26
|
return false;
|
|
27
27
|
}
|