@powerlines/plugin-alloy 0.15.4 → 0.15.5
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/dist/_virtual/rolldown_runtime.cjs +8 -0
- package/dist/_virtual/rolldown_runtime.mjs +0 -2
- package/dist/core/components/index.cjs +1 -1
- package/dist/core/components/index.mjs +1 -1
- package/dist/core/components/output.d.cts +2 -2
- package/dist/core/components/output.d.mts +2 -2
- package/dist/core/components/single-line-comment.d.cts +2 -2
- package/dist/core/components/single-line-comment.d.mts +2 -2
- package/dist/core/components/source-file.d.cts +2 -2
- package/dist/core/components/source-file.d.mts +2 -2
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/deepkit/src/utilities.cjs +113 -0
- package/dist/deepkit/src/utilities.mjs +109 -0
- package/dist/deepkit/src/vendor/core.cjs +20 -0
- package/dist/deepkit/src/vendor/core.mjs +11 -0
- package/dist/deepkit/src/vendor/type.cjs +20 -0
- package/dist/deepkit/src/vendor/type.mjs +11 -0
- package/dist/helpers/capnp.cjs +33 -33
- package/dist/helpers/capnp.mjs +29 -29
- package/dist/helpers/index.cjs +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/typescript.cjs +3 -3
- package/dist/helpers/typescript.mjs +2 -2
- package/dist/index.cjs +22 -16
- package/dist/index.mjs +22 -16
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-file.d.mts +3 -3
- package/dist/markdown/components/markdown-table.d.cts +4 -4
- package/dist/markdown/components/markdown-table.d.mts +4 -4
- package/dist/powerlines/src/lib/utilities/file-header.cjs +13 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +12 -0
- package/dist/powerlines/src/types/config.d.cts +12 -0
- package/dist/powerlines/src/types/config.d.mts +12 -0
- package/dist/powerlines/src/types/resolved.d.cts +1 -1
- package/dist/powerlines/src/types/resolved.d.mts +1 -1
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/builtin-file.d.mts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
- package/dist/typescript/components/entry-file.d.cts +2 -2
- package/dist/typescript/components/entry-file.d.mts +2 -2
- package/dist/typescript/components/tsdoc-reflection.cjs +2 -2
- package/dist/typescript/components/tsdoc-reflection.d.cts +4 -4
- package/dist/typescript/components/tsdoc-reflection.d.mts +4 -4
- package/dist/typescript/components/tsdoc-reflection.mjs +2 -2
- package/dist/typescript/components/tsdoc.cjs +2 -2
- package/dist/typescript/components/tsdoc.mjs +1 -1
- package/dist/typescript/components/typescript-file.cjs +2 -2
- package/dist/typescript/components/typescript-file.mjs +2 -2
- package/dist/typescript/components/typescript-interface.cjs +3 -3
- package/dist/typescript/components/typescript-interface.d.cts +3 -3
- package/dist/typescript/components/typescript-interface.d.mts +3 -3
- package/dist/typescript/components/typescript-interface.mjs +3 -3
- package/dist/typescript/components/typescript-object.cjs +5 -5
- package/dist/typescript/components/typescript-object.d.cts +3 -3
- package/dist/typescript/components/typescript-object.d.mts +3 -3
- package/dist/typescript/components/typescript-object.mjs +4 -4
- package/dist/vendor.cjs +12594 -0
- package/dist/vendor.d.cts +1 -0
- package/dist/vendor.d.ts +1 -0
- package/dist/vendor.js +12424 -0
- package/package.json +23 -7
|
@@ -19,6 +19,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
}
|
|
20
20
|
return to;
|
|
21
21
|
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget, symbols) => {
|
|
23
|
+
if (symbols) {
|
|
24
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
}
|
|
27
|
+
__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
|
|
28
|
+
};
|
|
22
29
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
30
|
value: mod,
|
|
24
31
|
enumerable: true
|
|
@@ -26,4 +33,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
33
|
|
|
27
34
|
//#endregion
|
|
28
35
|
|
|
36
|
+
exports.__reExport = __reExport;
|
|
29
37
|
exports.__toESM = __toESM;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
const require_core_components_output = require('./output.cjs');
|
|
1
2
|
const require_core_components_single_line_comment = require('./single-line-comment.cjs');
|
|
2
3
|
const require_core_components_source_file = require('./source-file.cjs');
|
|
3
|
-
const require_core_components_output = require('./output.cjs');
|
|
4
4
|
|
|
5
5
|
exports.Output = require_core_components_output.Output;
|
|
6
6
|
exports.SingleLineComment = require_core_components_single_line_comment.SingleLineComment;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
3
3
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/core/components/output.d.ts
|
|
@@ -12,7 +12,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext> extends Ou
|
|
|
12
12
|
/**
|
|
13
13
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
14
14
|
*/
|
|
15
|
-
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>):
|
|
15
|
+
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core1.Children;
|
|
16
16
|
declare type __ΩOutputProps = any[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginContext } from "../../powerlines/src/types/context.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core6 from "@alloy-js/core";
|
|
3
3
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/core/components/output.d.ts
|
|
@@ -12,7 +12,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext> extends Ou
|
|
|
12
12
|
/**
|
|
13
13
|
* Output component for rendering the Powerlines plugin's output files via templates.
|
|
14
14
|
*/
|
|
15
|
-
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>):
|
|
15
|
+
declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core6.Children;
|
|
16
16
|
declare type __ΩOutputProps = any[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { Output, OutputProps, __ΩOutputProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core16 from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/components/single-line-comment.d.ts
|
|
5
5
|
type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
|
|
@@ -15,7 +15,7 @@ interface SingleLineCommentProps extends ComponentProps {
|
|
|
15
15
|
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
16
16
|
* are broken into multiple lines
|
|
17
17
|
*/
|
|
18
|
-
declare function SingleLineComment(props: SingleLineCommentProps):
|
|
18
|
+
declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core16.Children;
|
|
19
19
|
declare type __ΩSingleLineCommentVariant = any[];
|
|
20
20
|
declare type __ΩSingleLineCommentProps = any[];
|
|
21
21
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/components/single-line-comment.d.ts
|
|
5
5
|
type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
|
|
@@ -15,7 +15,7 @@ interface SingleLineCommentProps extends ComponentProps {
|
|
|
15
15
|
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
16
16
|
* are broken into multiple lines
|
|
17
17
|
*/
|
|
18
|
-
declare function SingleLineComment(props: SingleLineCommentProps):
|
|
18
|
+
declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core0.Children;
|
|
19
19
|
declare type __ΩSingleLineCommentVariant = any[];
|
|
20
20
|
declare type __ΩSingleLineCommentProps = any[];
|
|
21
21
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePreset } from "../../powerlines/src/types/fs.cjs";
|
|
2
2
|
import { ComponentProps } from "../../types/components.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core15 from "@alloy-js/core";
|
|
4
4
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
@@ -25,7 +25,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
25
25
|
* @param props - The properties for the source file.
|
|
26
26
|
* @returns The rendered source file component.
|
|
27
27
|
*/
|
|
28
|
-
declare function SourceFile(props: SourceFileProps):
|
|
28
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core15.Children;
|
|
29
29
|
declare type __ΩSourceFileProps = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoragePreset } from "../../powerlines/src/types/fs.mjs";
|
|
2
2
|
import { ComponentProps } from "../../types/components.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
4
4
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
@@ -25,7 +25,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
25
25
|
* @param props - The properties for the source file.
|
|
26
26
|
* @returns The rendered source file component.
|
|
27
27
|
*/
|
|
28
|
-
declare function SourceFile(props: SourceFileProps):
|
|
28
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core0.Children;
|
|
29
29
|
declare type __ΩSourceFileProps = any[];
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_core_contexts_context = require('./contexts/context.cjs');
|
|
2
|
+
const require_core_components_output = require('./components/output.cjs');
|
|
2
3
|
const require_core_components_single_line_comment = require('./components/single-line-comment.cjs');
|
|
3
4
|
const require_core_components_source_file = require('./components/source-file.cjs');
|
|
4
|
-
const require_core_contexts_reflection = require('./contexts/reflection.cjs');
|
|
5
|
-
const require_core_components_output = require('./components/output.cjs');
|
|
6
5
|
require('./components/index.cjs');
|
|
6
|
+
const require_core_contexts_reflection = require('./contexts/reflection.cjs');
|
|
7
7
|
require('./contexts/index.cjs');
|
|
8
8
|
|
|
9
9
|
exports.Output = require_core_components_output.Output;
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PowerlinesContext, usePowerlines, usePowerlinesContext } from "./contexts/context.mjs";
|
|
2
|
+
import { Output } from "./components/output.mjs";
|
|
2
3
|
import { SingleLineComment } from "./components/single-line-comment.mjs";
|
|
3
4
|
import { SourceFile } from "./components/source-file.mjs";
|
|
4
|
-
import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
|
|
5
|
-
import { Output } from "./components/output.mjs";
|
|
6
5
|
import "./components/index.mjs";
|
|
6
|
+
import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
|
|
7
7
|
import "./contexts/index.mjs";
|
|
8
8
|
|
|
9
9
|
export { Output, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SourceFile, usePowerlines, usePowerlinesContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_type = require('./vendor/type.cjs');
|
|
3
|
+
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
4
|
+
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
5
|
+
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
6
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
7
|
+
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
8
|
+
|
|
9
|
+
//#region ../deepkit/src/utilities.ts
|
|
10
|
+
/**
|
|
11
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
12
|
+
*
|
|
13
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
14
|
+
* @param value - The value to stringify.
|
|
15
|
+
* @returns A string representation of the value.
|
|
16
|
+
*/
|
|
17
|
+
function stringifyDefaultValue(property, value) {
|
|
18
|
+
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Stringifies a value as a string.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to stringify.
|
|
24
|
+
* @returns A string representation of the value.
|
|
25
|
+
*/
|
|
26
|
+
function stringifyStringValue(value) {
|
|
27
|
+
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
31
|
+
*
|
|
32
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
33
|
+
* @param value - The value to stringify.
|
|
34
|
+
* @returns A string representation of the value.
|
|
35
|
+
*/
|
|
36
|
+
function stringifyValue(type, value) {
|
|
37
|
+
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind === require_type.type_exports.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === require_type.type_exports.ReflectionKind.string || type.kind === require_type.type_exports.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? stringifyStringValue(value) : type.kind === require_type.type_exports.ReflectionKind.enum ? getEnumReflectionType(type).kind === require_type.type_exports.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === require_type.type_exports.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === require_type.type_exports.ReflectionKind.array ? stringifyStringValue(__stryke_json_storm_json.StormJSON.stringify(value)) : type.kind === require_type.type_exports.ReflectionKind.object || type.kind === require_type.type_exports.ReflectionKind.objectLiteral ? __stryke_json_storm_json.StormJSON.stringify(value) : type.kind === require_type.type_exports.ReflectionKind.property || type.kind === require_type.type_exports.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
41
|
+
*
|
|
42
|
+
* @param type - The {@link TypeEnum} to evaluate.
|
|
43
|
+
* @returns A string representation of the primitive type.
|
|
44
|
+
*/
|
|
45
|
+
function getEnumReflectionType(type) {
|
|
46
|
+
if (type.kind !== require_type.type_exports.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
47
|
+
const unique = (0, __stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => (0, __stryke_type_checks_is_string.isString)(enumMember) ? { kind: require_type.type_exports.ReflectionKind.string } : { kind: require_type.type_exports.ReflectionKind.number });
|
|
48
|
+
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
49
|
+
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind: require_type.type_exports.ReflectionKind.string } : { kind: require_type.type_exports.ReflectionKind.number };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
53
|
+
*
|
|
54
|
+
* @param type - The {@link TypeUnion} to evaluate.
|
|
55
|
+
* @returns A string representation of the primitive type.
|
|
56
|
+
*/
|
|
57
|
+
function getUnionTypes(type) {
|
|
58
|
+
if (type.kind === require_type.type_exports.ReflectionKind.union && type.types.length > 0) return (0, __stryke_helpers_get_unique.getUniqueBy)(type.types, (member) => member.kind);
|
|
59
|
+
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
60
|
+
}
|
|
61
|
+
function isStringUnion(type) {
|
|
62
|
+
return getUnionTypes(type).some((member) => member.kind === require_type.type_exports.ReflectionKind.string || member.kind === require_type.type_exports.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(member.literal));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Converts a ReflectionKind to its string representation.
|
|
66
|
+
*
|
|
67
|
+
* @param kind - The {@link ReflectionKind} to convert.
|
|
68
|
+
* @returns A string representation of the kind.
|
|
69
|
+
*/
|
|
70
|
+
function kindToName(kind) {
|
|
71
|
+
if (kind === require_type.type_exports.ReflectionKind.void) return "void";
|
|
72
|
+
else if (kind === require_type.type_exports.ReflectionKind.never) return "never";
|
|
73
|
+
else if (kind === require_type.type_exports.ReflectionKind.null) return "null";
|
|
74
|
+
else if (kind === require_type.type_exports.ReflectionKind.undefined) return "undefined";
|
|
75
|
+
else if (kind === require_type.type_exports.ReflectionKind.symbol) return "symbol";
|
|
76
|
+
else if (kind === require_type.type_exports.ReflectionKind.bigint) return "bigint";
|
|
77
|
+
else if (kind === require_type.type_exports.ReflectionKind.number) return "number";
|
|
78
|
+
else if (kind === require_type.type_exports.ReflectionKind.string) return "string";
|
|
79
|
+
else if (kind === require_type.type_exports.ReflectionKind.boolean) return "boolean";
|
|
80
|
+
else if (kind === require_type.type_exports.ReflectionKind.literal) return "literal";
|
|
81
|
+
else if (kind === require_type.type_exports.ReflectionKind.class) return "class";
|
|
82
|
+
else if (kind === require_type.type_exports.ReflectionKind.array) return "array";
|
|
83
|
+
else if (kind === require_type.type_exports.ReflectionKind.object) return "object";
|
|
84
|
+
else if (kind === require_type.type_exports.ReflectionKind.objectLiteral) return "objectLiteral";
|
|
85
|
+
else if (kind === require_type.type_exports.ReflectionKind.union) return "union";
|
|
86
|
+
else if (kind === require_type.type_exports.ReflectionKind.enum) return "enum";
|
|
87
|
+
else if (kind === require_type.type_exports.ReflectionKind.regexp) return "regexp";
|
|
88
|
+
else if (kind === require_type.type_exports.ReflectionKind.templateLiteral) return "templateLiteral";
|
|
89
|
+
else if (kind === require_type.type_exports.ReflectionKind.property) return "property";
|
|
90
|
+
else if (kind === require_type.type_exports.ReflectionKind.method) return "method";
|
|
91
|
+
else if (kind === require_type.type_exports.ReflectionKind.function) return "function";
|
|
92
|
+
else if (kind === require_type.type_exports.ReflectionKind.parameter) return "parameter";
|
|
93
|
+
else if (kind === require_type.type_exports.ReflectionKind.promise) return "promise";
|
|
94
|
+
else if (kind === require_type.type_exports.ReflectionKind.typeParameter) return "typeParameter";
|
|
95
|
+
else if (kind === require_type.type_exports.ReflectionKind.tuple) return "tuple";
|
|
96
|
+
else if (kind === require_type.type_exports.ReflectionKind.tupleMember) return "tupleMember";
|
|
97
|
+
else if (kind === require_type.type_exports.ReflectionKind.enumMember) return "enumMember";
|
|
98
|
+
else if (kind === require_type.type_exports.ReflectionKind.rest) return "rest";
|
|
99
|
+
else if (kind === require_type.type_exports.ReflectionKind.indexSignature) return "indexSignature";
|
|
100
|
+
else if (kind === require_type.type_exports.ReflectionKind.propertySignature) return "propertySignature";
|
|
101
|
+
else if (kind === require_type.type_exports.ReflectionKind.methodSignature) return "methodSignature";
|
|
102
|
+
else if (kind === require_type.type_exports.ReflectionKind.infer) return "infer";
|
|
103
|
+
else if (kind === require_type.type_exports.ReflectionKind.callSignature) return "callSignature";
|
|
104
|
+
else if (kind === require_type.type_exports.ReflectionKind.any) return "any";
|
|
105
|
+
else if (kind === require_type.type_exports.ReflectionKind.intersection) return "intersection";
|
|
106
|
+
return "unknown";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
exports.getUnionTypes = getUnionTypes;
|
|
111
|
+
exports.kindToName = kindToName;
|
|
112
|
+
exports.stringifyDefaultValue = stringifyDefaultValue;
|
|
113
|
+
exports.stringifyValue = stringifyValue;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type_exports } from "./vendor/type.mjs";
|
|
2
|
+
import { StormJSON } from "@stryke/json/storm-json";
|
|
3
|
+
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
4
|
+
import { isNull } from "@stryke/type-checks/is-null";
|
|
5
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
6
|
+
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
7
|
+
|
|
8
|
+
//#region ../deepkit/src/utilities.ts
|
|
9
|
+
/**
|
|
10
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
11
|
+
*
|
|
12
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
13
|
+
* @param value - The value to stringify.
|
|
14
|
+
* @returns A string representation of the value.
|
|
15
|
+
*/
|
|
16
|
+
function stringifyDefaultValue(property, value) {
|
|
17
|
+
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stringifies a value as a string.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The value to stringify.
|
|
23
|
+
* @returns A string representation of the value.
|
|
24
|
+
*/
|
|
25
|
+
function stringifyStringValue(value) {
|
|
26
|
+
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
30
|
+
*
|
|
31
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
32
|
+
* @param value - The value to stringify.
|
|
33
|
+
* @returns A string representation of the value.
|
|
34
|
+
*/
|
|
35
|
+
function stringifyValue(type, value) {
|
|
36
|
+
return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind === type_exports.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === type_exports.ReflectionKind.string || type.kind === type_exports.ReflectionKind.literal && isString(type.literal) ? stringifyStringValue(value) : type.kind === type_exports.ReflectionKind.enum ? getEnumReflectionType(type).kind === type_exports.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === type_exports.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === type_exports.ReflectionKind.array ? stringifyStringValue(StormJSON.stringify(value)) : type.kind === type_exports.ReflectionKind.object || type.kind === type_exports.ReflectionKind.objectLiteral ? StormJSON.stringify(value) : type.kind === type_exports.ReflectionKind.property || type.kind === type_exports.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
40
|
+
*
|
|
41
|
+
* @param type - The {@link TypeEnum} to evaluate.
|
|
42
|
+
* @returns A string representation of the primitive type.
|
|
43
|
+
*/
|
|
44
|
+
function getEnumReflectionType(type) {
|
|
45
|
+
if (type.kind !== type_exports.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
46
|
+
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind: type_exports.ReflectionKind.string } : { kind: type_exports.ReflectionKind.number });
|
|
47
|
+
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
48
|
+
return unique[0] && isString(unique[0]) ? { kind: type_exports.ReflectionKind.string } : { kind: type_exports.ReflectionKind.number };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
52
|
+
*
|
|
53
|
+
* @param type - The {@link TypeUnion} to evaluate.
|
|
54
|
+
* @returns A string representation of the primitive type.
|
|
55
|
+
*/
|
|
56
|
+
function getUnionTypes(type) {
|
|
57
|
+
if (type.kind === type_exports.ReflectionKind.union && type.types.length > 0) return getUniqueBy(type.types, (member) => member.kind);
|
|
58
|
+
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
59
|
+
}
|
|
60
|
+
function isStringUnion(type) {
|
|
61
|
+
return getUnionTypes(type).some((member) => member.kind === type_exports.ReflectionKind.string || member.kind === type_exports.ReflectionKind.literal && isString(member.literal));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Converts a ReflectionKind to its string representation.
|
|
65
|
+
*
|
|
66
|
+
* @param kind - The {@link ReflectionKind} to convert.
|
|
67
|
+
* @returns A string representation of the kind.
|
|
68
|
+
*/
|
|
69
|
+
function kindToName(kind) {
|
|
70
|
+
if (kind === type_exports.ReflectionKind.void) return "void";
|
|
71
|
+
else if (kind === type_exports.ReflectionKind.never) return "never";
|
|
72
|
+
else if (kind === type_exports.ReflectionKind.null) return "null";
|
|
73
|
+
else if (kind === type_exports.ReflectionKind.undefined) return "undefined";
|
|
74
|
+
else if (kind === type_exports.ReflectionKind.symbol) return "symbol";
|
|
75
|
+
else if (kind === type_exports.ReflectionKind.bigint) return "bigint";
|
|
76
|
+
else if (kind === type_exports.ReflectionKind.number) return "number";
|
|
77
|
+
else if (kind === type_exports.ReflectionKind.string) return "string";
|
|
78
|
+
else if (kind === type_exports.ReflectionKind.boolean) return "boolean";
|
|
79
|
+
else if (kind === type_exports.ReflectionKind.literal) return "literal";
|
|
80
|
+
else if (kind === type_exports.ReflectionKind.class) return "class";
|
|
81
|
+
else if (kind === type_exports.ReflectionKind.array) return "array";
|
|
82
|
+
else if (kind === type_exports.ReflectionKind.object) return "object";
|
|
83
|
+
else if (kind === type_exports.ReflectionKind.objectLiteral) return "objectLiteral";
|
|
84
|
+
else if (kind === type_exports.ReflectionKind.union) return "union";
|
|
85
|
+
else if (kind === type_exports.ReflectionKind.enum) return "enum";
|
|
86
|
+
else if (kind === type_exports.ReflectionKind.regexp) return "regexp";
|
|
87
|
+
else if (kind === type_exports.ReflectionKind.templateLiteral) return "templateLiteral";
|
|
88
|
+
else if (kind === type_exports.ReflectionKind.property) return "property";
|
|
89
|
+
else if (kind === type_exports.ReflectionKind.method) return "method";
|
|
90
|
+
else if (kind === type_exports.ReflectionKind.function) return "function";
|
|
91
|
+
else if (kind === type_exports.ReflectionKind.parameter) return "parameter";
|
|
92
|
+
else if (kind === type_exports.ReflectionKind.promise) return "promise";
|
|
93
|
+
else if (kind === type_exports.ReflectionKind.typeParameter) return "typeParameter";
|
|
94
|
+
else if (kind === type_exports.ReflectionKind.tuple) return "tuple";
|
|
95
|
+
else if (kind === type_exports.ReflectionKind.tupleMember) return "tupleMember";
|
|
96
|
+
else if (kind === type_exports.ReflectionKind.enumMember) return "enumMember";
|
|
97
|
+
else if (kind === type_exports.ReflectionKind.rest) return "rest";
|
|
98
|
+
else if (kind === type_exports.ReflectionKind.indexSignature) return "indexSignature";
|
|
99
|
+
else if (kind === type_exports.ReflectionKind.propertySignature) return "propertySignature";
|
|
100
|
+
else if (kind === type_exports.ReflectionKind.methodSignature) return "methodSignature";
|
|
101
|
+
else if (kind === type_exports.ReflectionKind.infer) return "infer";
|
|
102
|
+
else if (kind === type_exports.ReflectionKind.callSignature) return "callSignature";
|
|
103
|
+
else if (kind === type_exports.ReflectionKind.any) return "any";
|
|
104
|
+
else if (kind === type_exports.ReflectionKind.intersection) return "intersection";
|
|
105
|
+
return "unknown";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { getUnionTypes, kindToName, stringifyDefaultValue, stringifyValue };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../deepkit/src/vendor/core.ts
|
|
4
|
+
var core_exports = {};
|
|
5
|
+
require_rolldown_runtime.__reExport(core_exports, require("@deepkit/core"));
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, 'core_exports', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return core_exports;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var __deepkit_core = require("@deepkit/core");
|
|
15
|
+
Object.keys(__deepkit_core).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return __deepkit_core[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __reExport } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
|
|
3
|
+
export * from "@deepkit/core"
|
|
4
|
+
|
|
5
|
+
//#region ../deepkit/src/vendor/core.ts
|
|
6
|
+
var core_exports = {};
|
|
7
|
+
import * as import___deepkit_core from "@deepkit/core";
|
|
8
|
+
__reExport(core_exports, import___deepkit_core);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { core_exports };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../deepkit/src/vendor/type.ts
|
|
4
|
+
var type_exports = {};
|
|
5
|
+
require_rolldown_runtime.__reExport(type_exports, require("@deepkit/type"));
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
Object.defineProperty(exports, 'type_exports', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return type_exports;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var __deepkit_type = require("@deepkit/type");
|
|
15
|
+
Object.keys(__deepkit_type).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return __deepkit_type[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __reExport } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
|
|
3
|
+
export * from "@deepkit/type"
|
|
4
|
+
|
|
5
|
+
//#region ../deepkit/src/vendor/type.ts
|
|
6
|
+
var type_exports = {};
|
|
7
|
+
import * as import___deepkit_type from "@deepkit/type";
|
|
8
|
+
__reExport(type_exports, import___deepkit_type);
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type_exports };
|