@powerlines/plugin-env 0.15.2 → 0.15.4
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/components/docs.cjs +3 -70
- package/dist/components/docs.d.cts +1 -8
- package/dist/components/docs.d.mts +1 -8
- package/dist/components/docs.mjs +2 -68
- package/dist/components/env.cjs +4 -574
- package/dist/components/env.d.cts +2 -19
- package/dist/components/env.d.mts +3 -19
- package/dist/components/env.mjs +2 -570
- package/dist/components/index.cjs +7 -5
- package/dist/components/index.d.cts +4 -2
- package/dist/components/index.d.mts +5 -2
- package/dist/components/index.mjs +4 -2
- package/dist/{plugin-alloy/src/types/components.d.cts → components-8W0Zgj0y.d.mts} +2 -1
- package/dist/components-C9bYrQVK.cjs +0 -0
- package/dist/components-CNIQFfeK.mjs +1 -0
- package/dist/create-reflection-resource-BNYxBgW2.mjs +9846 -0
- package/dist/create-reflection-resource-BWYhmX7O.cjs +10085 -0
- package/dist/docs-5r844zC1.d.mts +9 -0
- package/dist/docs-B66b9li3.mjs +219 -0
- package/dist/docs-_MmTNBQX.d.cts +9 -0
- package/dist/docs-hBlKCRWK.cjs +224 -0
- package/dist/env-BPodCdD1.d.cts +116 -0
- package/dist/env-IQvgnabX.mjs +1578 -0
- package/dist/env-cO4BUDn1.cjs +1596 -0
- package/dist/env-zhzvpUI5.d.mts +98 -0
- package/dist/index-BXxhKmeA.d.mts +1 -0
- package/dist/index-Cc7fCJU9.d.mts +1 -0
- package/dist/index-CqdNToYT.d.cts +1 -0
- package/dist/index-DWPDThxu.d.cts +1 -0
- package/dist/index.cjs +702 -77
- package/dist/index.d.cts +185 -12
- package/dist/index.d.mts +190 -17
- package/dist/index.mjs +648 -28
- package/dist/{deepkit/schemas/reflection.d.mts → plugin-BaInAuAh.d.mts} +326 -59
- package/dist/{deepkit/schemas/reflection.d.cts → plugin-BwuEBScL.d.cts} +268 -1
- package/dist/plugin-D3B5E_Hg.mjs +1 -0
- package/dist/plugin-D5qyQPqC.cjs +0 -0
- package/dist/resolved-BZG2cwRG.d.cts +1789 -0
- package/dist/resolved-V5COsfDu.d.mts +1791 -0
- package/dist/runtime-Bisl_1Ja.cjs +0 -0
- package/dist/runtime-Q8Ni8SeN.d.cts +794 -0
- package/dist/runtime-azNoeKr-.mjs +1 -0
- package/dist/runtime-qZ0Z2kEd.d.mts +794 -0
- package/dist/types/index.cjs +3 -0
- package/dist/types/index.d.cts +4 -2
- package/dist/types/index.d.mts +5 -2
- package/dist/types/index.mjs +4 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +3 -156
- package/dist/types/plugin.d.mts +4 -158
- package/dist/types/plugin.mjs +2 -0
- package/dist/types/runtime.cjs +1 -0
- package/dist/types/runtime.d.cts +2 -793
- package/dist/types/runtime.d.mts +2 -793
- package/dist/types/runtime.mjs +2 -0
- package/dist/types-DwElXV6q.mjs +1 -0
- package/dist/types-MYBaygjr.cjs +0 -0
- package/package.json +7 -7
- package/dist/_virtual/rolldown_runtime.cjs +0 -37
- package/dist/_virtual/rolldown_runtime.mjs +0 -29
- package/dist/babel/index.cjs +0 -1
- package/dist/babel/index.d.mts +0 -1
- package/dist/babel/index.mjs +0 -3
- package/dist/babel/plugin.cjs +0 -121
- package/dist/babel/plugin.d.cts +0 -7
- package/dist/babel/plugin.d.mts +0 -9
- package/dist/babel/plugin.mjs +0 -119
- package/dist/deepkit/schemas/reflection.cjs +0 -3940
- package/dist/deepkit/schemas/reflection.mjs +0 -3938
- package/dist/deepkit/schemas/reflection2.cjs +0 -4112
- package/dist/deepkit/schemas/reflection2.mjs +0 -4110
- package/dist/deepkit/src/capnp.cjs +0 -913
- package/dist/deepkit/src/capnp.mjs +0 -911
- package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
- package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
- package/dist/deepkit/src/reflect-type.cjs +0 -22
- package/dist/deepkit/src/reflect-type.mjs +0 -20
- package/dist/deepkit/src/resolve-reflections.cjs +0 -16
- package/dist/deepkit/src/resolve-reflections.mjs +0 -15
- package/dist/deepkit/src/transformer.cjs +0 -52
- package/dist/deepkit/src/transformer.mjs +0 -49
- package/dist/deepkit/src/transpile.cjs +0 -29
- package/dist/deepkit/src/transpile.mjs +0 -27
- package/dist/deepkit/src/types.d.cts +0 -10
- package/dist/deepkit/src/types.d.mts +0 -10
- package/dist/deepkit/src/utilities.cjs +0 -66
- package/dist/deepkit/src/utilities.mjs +0 -65
- package/dist/deepkit/src/vendor/type-compiler/index.cjs +0 -38
- package/dist/deepkit/src/vendor/type-compiler/index.mjs +0 -19
- package/dist/deepkit/src/vendor/type.cjs +0 -20
- package/dist/deepkit/src/vendor/type.d.cts +0 -7
- package/dist/deepkit/src/vendor/type.d.mts +0 -7
- package/dist/deepkit/src/vendor/type.mjs +0 -11
- package/dist/helpers/automd-generator.cjs +0 -22
- package/dist/helpers/automd-generator.mjs +0 -21
- package/dist/helpers/create-reflection-resource.cjs +0 -55
- package/dist/helpers/create-reflection-resource.d.cts +0 -15
- package/dist/helpers/create-reflection-resource.d.mts +0 -15
- package/dist/helpers/create-reflection-resource.mjs +0 -54
- package/dist/helpers/index.cjs +0 -6
- package/dist/helpers/index.d.mts +0 -6
- package/dist/helpers/index.mjs +0 -8
- package/dist/helpers/load.cjs +0 -83
- package/dist/helpers/load.d.cts +0 -35
- package/dist/helpers/load.d.mts +0 -36
- package/dist/helpers/load.mjs +0 -80
- package/dist/helpers/persistence.cjs +0 -214
- package/dist/helpers/persistence.d.cts +0 -84
- package/dist/helpers/persistence.d.mts +0 -84
- package/dist/helpers/persistence.mjs +0 -202
- package/dist/helpers/reflect.cjs +0 -111
- package/dist/helpers/reflect.d.cts +0 -46
- package/dist/helpers/reflect.d.mts +0 -46
- package/dist/helpers/reflect.mjs +0 -103
- package/dist/helpers/source-file-env.cjs +0 -28
- package/dist/helpers/source-file-env.d.cts +0 -8
- package/dist/helpers/source-file-env.d.mts +0 -8
- package/dist/helpers/source-file-env.mjs +0 -26
- package/dist/helpers/template-helpers.cjs +0 -42
- package/dist/helpers/template-helpers.d.cts +0 -15
- package/dist/helpers/template-helpers.d.mts +0 -15
- package/dist/helpers/template-helpers.mjs +0 -41
- package/dist/plugin-alloy/src/core/components/output.cjs +0 -45
- package/dist/plugin-alloy/src/core/components/output.mjs +0 -44
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -22
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -21
- package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -64
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +0 -23
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +0 -23
- package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -62
- package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
- package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
- package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
- package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
- package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
- package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
- package/dist/plugin-alloy/src/index.cjs +0 -93
- package/dist/plugin-alloy/src/index.mjs +0 -91
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -115
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -114
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -39
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -38
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -18
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
- package/dist/plugin-alloy/src/types/components.d.mts +0 -25
- package/dist/plugin-alloy/src/types/index.d.mts +0 -2
- package/dist/plugin-alloy/src/types/plugin.d.cts +0 -37
- package/dist/plugin-alloy/src/types/plugin.d.mts +0 -37
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -57
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +0 -25
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +0 -26
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -56
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -126
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -124
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -442
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +0 -27
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +0 -28
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -433
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -194
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +0 -14
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +0 -15
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -191
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -68
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +0 -11
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +0 -12
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -67
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -124
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -123
- package/dist/plugin-automd/src/index.cjs +0 -101
- package/dist/plugin-automd/src/index.mjs +0 -98
- package/dist/plugin-automd/src/types/plugin.d.cts +0 -38
- package/dist/plugin-automd/src/types/plugin.d.mts +0 -40
- package/dist/plugin-automd/src/types/toc.d.cts +0 -33
- package/dist/plugin-automd/src/types/toc.d.mts +0 -33
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
- package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
- package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
- package/dist/plugin-babel/src/helpers/index.cjs +0 -5
- package/dist/plugin-babel/src/helpers/index.mjs +0 -7
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
- package/dist/plugin-babel/src/helpers/options.cjs +0 -50
- package/dist/plugin-babel/src/helpers/options.mjs +0 -47
- package/dist/plugin-babel/src/index.cjs +0 -91
- package/dist/plugin-babel/src/index.mjs +0 -89
- package/dist/plugin-babel/src/types/index.d.mts +0 -1
- package/dist/plugin-babel/src/types/plugin.d.cts +0 -15
- package/dist/plugin-babel/src/types/plugin.d.mts +0 -15
- package/dist/powerlines/schemas/fs.d.mts +0 -1
- package/dist/powerlines/src/api.d.mts +0 -7
- package/dist/powerlines/src/index.d.mts +0 -12
- package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -5
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
- package/dist/powerlines/src/lib/entry.cjs +0 -12
- package/dist/powerlines/src/lib/entry.mjs +0 -14
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
- package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
- package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
- package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
- package/dist/powerlines/src/types/api.d.mts +0 -5
- package/dist/powerlines/src/types/babel.d.cts +0 -23
- package/dist/powerlines/src/types/babel.d.mts +0 -23
- package/dist/powerlines/src/types/build.d.cts +0 -145
- package/dist/powerlines/src/types/build.d.mts +0 -147
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/config.d.cts +0 -380
- package/dist/powerlines/src/types/config.d.mts +0 -381
- package/dist/powerlines/src/types/context.d.cts +0 -414
- package/dist/powerlines/src/types/context.d.mts +0 -416
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/index.d.mts +0 -12
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -83
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
- package/dist/powerlines/src/types/unplugin.d.mts +0 -7
|
@@ -0,0 +1,1596 @@
|
|
|
1
|
+
const require_create_reflection_resource = require('./create-reflection-resource-BWYhmX7O.cjs');
|
|
2
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
4
|
+
let __alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
6
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
7
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
8
|
+
let defu = require("defu");
|
|
9
|
+
defu = require_create_reflection_resource.__toESM(defu);
|
|
10
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
11
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
12
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
13
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
14
|
+
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
15
|
+
let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
16
|
+
let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
17
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
18
|
+
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
19
|
+
let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
20
|
+
let __stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
|
|
21
|
+
let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
22
|
+
|
|
23
|
+
//#region ../deepkit/src/utilities.ts
|
|
24
|
+
/**
|
|
25
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
26
|
+
*
|
|
27
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
28
|
+
* @param value - The value to stringify.
|
|
29
|
+
* @returns A string representation of the value.
|
|
30
|
+
*/
|
|
31
|
+
function stringifyDefaultValue(property, value) {
|
|
32
|
+
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Stringifies a value as a string.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The value to stringify.
|
|
38
|
+
* @returns A string representation of the value.
|
|
39
|
+
*/
|
|
40
|
+
function stringifyStringValue(value) {
|
|
41
|
+
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
45
|
+
*
|
|
46
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
47
|
+
* @param value - The value to stringify.
|
|
48
|
+
* @returns A string representation of the value.
|
|
49
|
+
*/
|
|
50
|
+
function stringifyValue(type, value) {
|
|
51
|
+
return (0, __stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, __stryke_type_checks_is_null.isNull)(value) ? "null" : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(type.literal) ? stringifyStringValue(value) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.enum ? getEnumReflectionType(type).kind === __powerlines_deepkit_vendor_type.ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.array ? stringifyStringValue(__stryke_json_storm_json.StormJSON.stringify(value)) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.object || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral ? __stryke_json_storm_json.StormJSON.stringify(value) : type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.property || type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
55
|
+
*
|
|
56
|
+
* @param type - The {@link TypeEnum} to evaluate.
|
|
57
|
+
* @returns A string representation of the primitive type.
|
|
58
|
+
*/
|
|
59
|
+
function getEnumReflectionType(type) {
|
|
60
|
+
if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
61
|
+
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: __powerlines_deepkit_vendor_type.ReflectionKind.string } : { kind: __powerlines_deepkit_vendor_type.ReflectionKind.number });
|
|
62
|
+
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
63
|
+
return unique[0] && (0, __stryke_type_checks_is_string.isString)(unique[0]) ? { kind: __powerlines_deepkit_vendor_type.ReflectionKind.string } : { kind: __powerlines_deepkit_vendor_type.ReflectionKind.number };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
67
|
+
*
|
|
68
|
+
* @param type - The {@link TypeUnion} to evaluate.
|
|
69
|
+
* @returns A string representation of the primitive type.
|
|
70
|
+
*/
|
|
71
|
+
function getUnionTypes(type) {
|
|
72
|
+
if (type.kind === __powerlines_deepkit_vendor_type.ReflectionKind.union && type.types.length > 0) return (0, __stryke_helpers_get_unique.getUniqueBy)(type.types, (member) => member.kind);
|
|
73
|
+
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
74
|
+
}
|
|
75
|
+
function isStringUnion(type) {
|
|
76
|
+
return getUnionTypes(type).some((member) => member.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string || member.kind === __powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, __stryke_type_checks_is_string.isString)(member.literal));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region ../plugin-alloy/src/helpers/refkey.ts
|
|
81
|
+
/**
|
|
82
|
+
* Create a refkey for the provided arguments. Passing no arguments returns a fresh refkey that is guaranteed to be unique. Otherwise, the arguments passed will be used to create a refkey for those values. Providing the same arguments will always return the same refkey.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* Values are compared using the SameValueZero algorithm, which considers objects the same if they are reference identical, and primitives the same if they are the same value, with the exception of `NaN`, which is always considered equal to other `NaN` values, and `-0`, which is considered identical to `+0`
|
|
86
|
+
*/
|
|
87
|
+
function refkey(...args) {
|
|
88
|
+
return (0, __alloy_js_core.refkey)("powerlines", ...args);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../plugin-alloy/src/typescript/components/tsdoc.tsx
|
|
93
|
+
/**
|
|
94
|
+
* Generates a TypeScript interface for the given reflection class.
|
|
95
|
+
*/
|
|
96
|
+
function TSDoc(props) {
|
|
97
|
+
const [{ children, heading }] = (0, __alloy_js_core.splitProps)(props, ["children", "heading"]);
|
|
98
|
+
return [
|
|
99
|
+
"/**",
|
|
100
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
101
|
+
string: " * ",
|
|
102
|
+
get children() {
|
|
103
|
+
return [
|
|
104
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
105
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
106
|
+
get when() {
|
|
107
|
+
return !(0, __stryke_type_checks_is_undefined.isUndefined)(heading);
|
|
108
|
+
},
|
|
109
|
+
get children() {
|
|
110
|
+
return [
|
|
111
|
+
heading,
|
|
112
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
113
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
114
|
+
get when() {
|
|
115
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!!(0, __stryke_type_checks_is_undefined.isUndefined)(children))() && (0, __alloy_js_core.childrenArray)(() => children).length > 0;
|
|
116
|
+
},
|
|
117
|
+
get children() {
|
|
118
|
+
return (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {});
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
125
|
+
get when() {
|
|
126
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!!(0, __stryke_type_checks_is_undefined.isUndefined)(children))() && (0, __alloy_js_core.childrenArray)(() => children).length > 0;
|
|
127
|
+
},
|
|
128
|
+
get children() {
|
|
129
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.List, { get children() {
|
|
130
|
+
return (0, __alloy_js_core.childrenArray)(() => children);
|
|
131
|
+
} });
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
138
|
+
` */`,
|
|
139
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Create a TSDoc `@<props.tag>` tag.
|
|
144
|
+
*/
|
|
145
|
+
function TSDocTag(props) {
|
|
146
|
+
const [{ children, tag }] = (0, __alloy_js_core.splitProps)(props, ["children", "tag"]);
|
|
147
|
+
return [
|
|
148
|
+
`@${tag} `,
|
|
149
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
150
|
+
get when() {
|
|
151
|
+
return Boolean(children);
|
|
152
|
+
},
|
|
153
|
+
get children() {
|
|
154
|
+
return (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
155
|
+
width: 2,
|
|
156
|
+
get children() {
|
|
157
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Prose, { children });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
162
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Create a TSDoc `@title` tag.
|
|
167
|
+
*/
|
|
168
|
+
function TSDocTitle(props) {
|
|
169
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
170
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
171
|
+
tag: "title",
|
|
172
|
+
children
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Create a TSDoc `@domain` tag.
|
|
177
|
+
*/
|
|
178
|
+
function TSDocDomain(props) {
|
|
179
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
180
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
181
|
+
tag: "domain",
|
|
182
|
+
children
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Create a TSDoc `@alias` tag.
|
|
187
|
+
*/
|
|
188
|
+
function TSDocAlias(props) {
|
|
189
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
190
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
191
|
+
tag: "alias",
|
|
192
|
+
children
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Create a TSDoc `@permission` tag.
|
|
197
|
+
*/
|
|
198
|
+
function TSDocPermission(props) {
|
|
199
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
200
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
201
|
+
tag: "permission",
|
|
202
|
+
children
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Create a TSDoc `@defaultValue` tag.
|
|
207
|
+
*/
|
|
208
|
+
function TSDocDefaultValue(props) {
|
|
209
|
+
return [
|
|
210
|
+
"@defaultValue ",
|
|
211
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
212
|
+
get when() {
|
|
213
|
+
return !(0, __stryke_type_checks_is_undefined.isUndefined)(props.value);
|
|
214
|
+
},
|
|
215
|
+
get children() {
|
|
216
|
+
return (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
217
|
+
width: 2,
|
|
218
|
+
get children() {
|
|
219
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Prose, { get children() {
|
|
220
|
+
return stringifyDefaultValue(props.value);
|
|
221
|
+
} });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
226
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Create a TSDoc `@remarks` tag.
|
|
231
|
+
*/
|
|
232
|
+
function TSDocRemarks(props) {
|
|
233
|
+
return [
|
|
234
|
+
"@remarks ",
|
|
235
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
236
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.List, {
|
|
237
|
+
hardline: true,
|
|
238
|
+
get children() {
|
|
239
|
+
return (0, __alloy_js_core.childrenArray)(() => props.children);
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Create a TSDoc `@see` tag.
|
|
246
|
+
*/
|
|
247
|
+
function TSDocLink(props) {
|
|
248
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, { tag: "see" }));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Create a TSDoc `@example` tag.
|
|
252
|
+
*/
|
|
253
|
+
function TSDocExample(props) {
|
|
254
|
+
const [{ tsx, fenced = true, language, children }] = (0, __alloy_js_core.splitProps)(props, [
|
|
255
|
+
"tsx",
|
|
256
|
+
"fenced",
|
|
257
|
+
"language",
|
|
258
|
+
"children"
|
|
259
|
+
]);
|
|
260
|
+
return [
|
|
261
|
+
"@example ",
|
|
262
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
263
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
264
|
+
when: fenced,
|
|
265
|
+
get children() {
|
|
266
|
+
return [
|
|
267
|
+
"```",
|
|
268
|
+
language || (tsx ? "tsx" : "ts"),
|
|
269
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
}),
|
|
273
|
+
children,
|
|
274
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
275
|
+
when: fenced,
|
|
276
|
+
get children() {
|
|
277
|
+
return [(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}), "```"];
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Create a TSDoc `@readonly` tag.
|
|
284
|
+
*/
|
|
285
|
+
function TSDocReadonly() {
|
|
286
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, { tag: "readonly" });
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Create a TSDoc `@internal` tag.
|
|
290
|
+
*/
|
|
291
|
+
function TSDocInternal() {
|
|
292
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, { tag: "internal" });
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Create a TSDoc `@ignore` tag.
|
|
296
|
+
*/
|
|
297
|
+
function TSDocIgnore() {
|
|
298
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, { tag: "ignore" });
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Create a TSDoc `@hidden` tag.
|
|
302
|
+
*/
|
|
303
|
+
function TSDocHidden() {
|
|
304
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, { tag: "hidden" });
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
308
|
+
*/
|
|
309
|
+
function TSDocAttributesTags(props) {
|
|
310
|
+
const [{ title, alias, permission, domain, readonly, internal, ignore, hidden, defaultValue }] = (0, __alloy_js_core.splitProps)(props, [
|
|
311
|
+
"title",
|
|
312
|
+
"alias",
|
|
313
|
+
"permission",
|
|
314
|
+
"domain",
|
|
315
|
+
"readonly",
|
|
316
|
+
"internal",
|
|
317
|
+
"ignore",
|
|
318
|
+
"hidden",
|
|
319
|
+
"defaultValue"
|
|
320
|
+
]);
|
|
321
|
+
return [
|
|
322
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
323
|
+
get when() {
|
|
324
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(title);
|
|
325
|
+
},
|
|
326
|
+
get children() {
|
|
327
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTitle, { children: title });
|
|
328
|
+
}
|
|
329
|
+
}),
|
|
330
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
331
|
+
get when() {
|
|
332
|
+
return !(0, __stryke_type_checks_is_undefined.isUndefined)(alias) && alias.length > 0;
|
|
333
|
+
},
|
|
334
|
+
get children() {
|
|
335
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
336
|
+
each: alias ?? [],
|
|
337
|
+
children: (alias$1) => (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocAlias, { children: alias$1 })
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
341
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
342
|
+
get when() {
|
|
343
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(domain);
|
|
344
|
+
},
|
|
345
|
+
get children() {
|
|
346
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocDomain, { children: domain });
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
349
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
350
|
+
get when() {
|
|
351
|
+
return !(0, __stryke_type_checks_is_undefined.isUndefined)(permission) && permission.length > 0;
|
|
352
|
+
},
|
|
353
|
+
get children() {
|
|
354
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
355
|
+
each: permission ?? [],
|
|
356
|
+
children: (permission$1) => (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocPermission, { children: permission$1 })
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}),
|
|
360
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
361
|
+
when: readonly === true,
|
|
362
|
+
get children() {
|
|
363
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReadonly, {});
|
|
364
|
+
}
|
|
365
|
+
}),
|
|
366
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
367
|
+
when: internal === true,
|
|
368
|
+
get children() {
|
|
369
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocInternal, {});
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
373
|
+
when: ignore === true,
|
|
374
|
+
get children() {
|
|
375
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocIgnore, {});
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
379
|
+
when: hidden === true,
|
|
380
|
+
get children() {
|
|
381
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocHidden, {});
|
|
382
|
+
}
|
|
383
|
+
}),
|
|
384
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
385
|
+
get when() {
|
|
386
|
+
return !(0, __stryke_type_checks_is_undefined.isUndefined)(defaultValue);
|
|
387
|
+
},
|
|
388
|
+
get children() {
|
|
389
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocDefaultValue, { value: defaultValue });
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Create a TSDoc parameter set off with `@param`.
|
|
396
|
+
*/
|
|
397
|
+
function TSDocParam(props) {
|
|
398
|
+
return [
|
|
399
|
+
"@param ",
|
|
400
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocParamName, {
|
|
401
|
+
get name() {
|
|
402
|
+
return props.name;
|
|
403
|
+
},
|
|
404
|
+
get optional() {
|
|
405
|
+
return props.optional;
|
|
406
|
+
},
|
|
407
|
+
get defaultValue() {
|
|
408
|
+
return props.defaultValue;
|
|
409
|
+
}
|
|
410
|
+
}),
|
|
411
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocParamDescription, { get children() {
|
|
412
|
+
return props.children;
|
|
413
|
+
} })
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
function TSDocParamName(props) {
|
|
417
|
+
return [
|
|
418
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
419
|
+
get when() {
|
|
420
|
+
return props.optional;
|
|
421
|
+
},
|
|
422
|
+
children: "["
|
|
423
|
+
}),
|
|
424
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => props.name),
|
|
425
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
426
|
+
get when() {
|
|
427
|
+
return Boolean(props.defaultValue);
|
|
428
|
+
},
|
|
429
|
+
get children() {
|
|
430
|
+
return ["=", (0, __alloy_js_core_jsx_runtime.memo)(() => props.defaultValue)];
|
|
431
|
+
}
|
|
432
|
+
}),
|
|
433
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
434
|
+
get when() {
|
|
435
|
+
return props.optional;
|
|
436
|
+
},
|
|
437
|
+
children: "]"
|
|
438
|
+
})
|
|
439
|
+
];
|
|
440
|
+
}
|
|
441
|
+
function TSDocParamDescription(props) {
|
|
442
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
443
|
+
get when() {
|
|
444
|
+
return Boolean(props.children);
|
|
445
|
+
},
|
|
446
|
+
get children() {
|
|
447
|
+
return [" - ", (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
448
|
+
width: 2,
|
|
449
|
+
get children() {
|
|
450
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Prose, { get children() {
|
|
451
|
+
return props.children;
|
|
452
|
+
} });
|
|
453
|
+
}
|
|
454
|
+
})];
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Create a TSDoc `@returns` tag.
|
|
460
|
+
*/
|
|
461
|
+
function TSDocReturns(props) {
|
|
462
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, { tag: "returns" }));
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Create a TSDoc `@throws` tag.
|
|
466
|
+
*/
|
|
467
|
+
function TSDocThrows(props) {
|
|
468
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocTag, (0, __alloy_js_core_jsx_runtime.mergeProps)(props, { tag: "throws" }));
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Generates a TSDoc `@module` tag for the given module name.
|
|
472
|
+
*/
|
|
473
|
+
function TSDocModule(props) {
|
|
474
|
+
const [{ children, name, prefix }] = (0, __alloy_js_core.splitProps)(props, [
|
|
475
|
+
"children",
|
|
476
|
+
"name",
|
|
477
|
+
"prefix"
|
|
478
|
+
]);
|
|
479
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
480
|
+
return [
|
|
481
|
+
"/**",
|
|
482
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
|
|
483
|
+
string: " * ",
|
|
484
|
+
get children() {
|
|
485
|
+
return [
|
|
486
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
487
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
488
|
+
get when() {
|
|
489
|
+
return Boolean(children);
|
|
490
|
+
},
|
|
491
|
+
get children() {
|
|
492
|
+
return [
|
|
493
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.List, {
|
|
494
|
+
hardline: true,
|
|
495
|
+
get children() {
|
|
496
|
+
return (0, __alloy_js_core.childrenArray)(() => children);
|
|
497
|
+
}
|
|
498
|
+
}),
|
|
499
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
500
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
}),
|
|
504
|
+
"@module ",
|
|
505
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => prefix || context?.config.output.builtinPrefix),
|
|
506
|
+
":",
|
|
507
|
+
name
|
|
508
|
+
];
|
|
509
|
+
}
|
|
510
|
+
}),
|
|
511
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
512
|
+
` */`
|
|
513
|
+
];
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
|
|
518
|
+
/**
|
|
519
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
520
|
+
*
|
|
521
|
+
* @param props - The properties for the source file.
|
|
522
|
+
* @returns The rendered source file component.
|
|
523
|
+
*/
|
|
524
|
+
function TypescriptFile(props) {
|
|
525
|
+
const [{ children, path, imports, tsx, header, hashbang }, rest] = (0, __alloy_js_core.splitProps)(props, [
|
|
526
|
+
"children",
|
|
527
|
+
"path",
|
|
528
|
+
"imports",
|
|
529
|
+
"tsx",
|
|
530
|
+
"header",
|
|
531
|
+
"hashbang"
|
|
532
|
+
]);
|
|
533
|
+
const directoryContext = (0, __alloy_js_core.useContext)(__alloy_js_core.SourceDirectoryContext);
|
|
534
|
+
const sdData = (0, __alloy_js_typescript.getSourceDirectoryData)(directoryContext);
|
|
535
|
+
const modulePath = (0, __stryke_path_append.appendPath)(path, directoryContext.path);
|
|
536
|
+
const scope = new __alloy_js_typescript.TSModuleScope(modulePath, (0, __alloy_js_core.useScope)());
|
|
537
|
+
sdData.modules.add(scope);
|
|
538
|
+
const pkg = (0, __alloy_js_core.useContext)(__alloy_js_typescript.PackageContext);
|
|
539
|
+
if (pkg) pkg.scope.addModule(scope);
|
|
540
|
+
if (props.export) {
|
|
541
|
+
if (pkg) if ((0, __stryke_type_checks_is_boolean.isBoolean)(props.export)) pkg.scope.addExport(modulePath, scope);
|
|
542
|
+
else pkg.scope.addExport(props.export, scope);
|
|
543
|
+
}
|
|
544
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.SourceFileContext.Provider, {
|
|
545
|
+
value: { scope },
|
|
546
|
+
get children() {
|
|
547
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Scope, {
|
|
548
|
+
value: scope,
|
|
549
|
+
get children() {
|
|
550
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SourceFile, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
551
|
+
path: modulePath,
|
|
552
|
+
get header() {
|
|
553
|
+
return header ?? (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeader, {
|
|
554
|
+
hashbang,
|
|
555
|
+
get children() {
|
|
556
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeaderImports, {
|
|
557
|
+
imports,
|
|
558
|
+
scope
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
filetype: tsx ? "tsx" : "typescript",
|
|
564
|
+
children
|
|
565
|
+
}));
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Renders the header for a Powerlines Typescript source file.
|
|
573
|
+
*
|
|
574
|
+
* @param props - The properties for the source file header.
|
|
575
|
+
* @returns The rendered source file header.
|
|
576
|
+
*/
|
|
577
|
+
function TypescriptFileHeader(props) {
|
|
578
|
+
const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
|
|
579
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
580
|
+
return [
|
|
581
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
582
|
+
get when() {
|
|
583
|
+
return Boolean(hashbang);
|
|
584
|
+
},
|
|
585
|
+
get children() {
|
|
586
|
+
return [(0, __alloy_js_core_jsx_runtime.memo)(() => hashbang === true ? __alloy_js_core.code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
587
|
+
}
|
|
588
|
+
}),
|
|
589
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
590
|
+
get when() {
|
|
591
|
+
return Boolean(header);
|
|
592
|
+
},
|
|
593
|
+
get children() {
|
|
594
|
+
return [header, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
595
|
+
}
|
|
596
|
+
}),
|
|
597
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
598
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
599
|
+
get when() {
|
|
600
|
+
return Boolean(disableEslint);
|
|
601
|
+
},
|
|
602
|
+
get children() {
|
|
603
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SingleLineComment, {
|
|
604
|
+
variant: "slash-star",
|
|
605
|
+
children: "eslint-disable"
|
|
606
|
+
}), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
607
|
+
}
|
|
608
|
+
}),
|
|
609
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
610
|
+
get when() {
|
|
611
|
+
return Boolean(disablePrettier);
|
|
612
|
+
},
|
|
613
|
+
get children() {
|
|
614
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SingleLineComment, {
|
|
615
|
+
variant: "slash-star",
|
|
616
|
+
children: "prettier-ignore"
|
|
617
|
+
}), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
618
|
+
}
|
|
619
|
+
}),
|
|
620
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
621
|
+
get when() {
|
|
622
|
+
return Boolean(disableBiome);
|
|
623
|
+
},
|
|
624
|
+
get children() {
|
|
625
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SingleLineComment, { children: "biome-ignore lint: disable" }), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
626
|
+
}
|
|
627
|
+
}),
|
|
628
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
629
|
+
get when() {
|
|
630
|
+
return Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome);
|
|
631
|
+
},
|
|
632
|
+
get children() {
|
|
633
|
+
return (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {});
|
|
634
|
+
}
|
|
635
|
+
}),
|
|
636
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
637
|
+
get when() {
|
|
638
|
+
return Boolean(children);
|
|
639
|
+
},
|
|
640
|
+
get children() {
|
|
641
|
+
return [children, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
642
|
+
}
|
|
643
|
+
}),
|
|
644
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SingleLineComment, { get children() {
|
|
645
|
+
return __alloy_js_core.code`Generated by ${(0, __stryke_string_format_title_case.titleCase)(context?.config.framework) || "Powerlines"}`;
|
|
646
|
+
} }),
|
|
647
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
648
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.SingleLineComment, { children: __alloy_js_core.code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
|
|
649
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
650
|
+
];
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Renders the header for a Powerlines Typescript source file.
|
|
654
|
+
*
|
|
655
|
+
* @param props - The properties for the source file header.
|
|
656
|
+
* @returns The rendered source file header.
|
|
657
|
+
*/
|
|
658
|
+
function TypescriptFileHeaderImports(props) {
|
|
659
|
+
const { imports } = props;
|
|
660
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
661
|
+
const sourceFile = (0, __alloy_js_typescript.useSourceFile)();
|
|
662
|
+
const scope = props.scope ?? sourceFile.scope;
|
|
663
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
664
|
+
get when() {
|
|
665
|
+
return scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0;
|
|
666
|
+
},
|
|
667
|
+
get children() {
|
|
668
|
+
return [
|
|
669
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
670
|
+
get when() {
|
|
671
|
+
return !!imports && Object.keys(imports).length > 0;
|
|
672
|
+
},
|
|
673
|
+
get children() {
|
|
674
|
+
return Object.entries(imports ?? {}).filter(([key]) => key !== "$builtins").concat(imports && imports.$builtins ? Object.entries(imports.$builtins).map(([key, entry]) => [key.includes(":") ? key : `${context.config.output.builtinPrefix}:${key}`, entry]) : []).map(([module$1, imported]) => {
|
|
675
|
+
return __alloy_js_core.code`import ${imported === null ? "" : imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${imported.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module$1}";`;
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
}),
|
|
679
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
680
|
+
get when() {
|
|
681
|
+
return scope.importedModules.size > 0;
|
|
682
|
+
},
|
|
683
|
+
get children() {
|
|
684
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ImportStatements, { get records() {
|
|
685
|
+
return scope.importedModules;
|
|
686
|
+
} });
|
|
687
|
+
}
|
|
688
|
+
}),
|
|
689
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
690
|
+
];
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region ../plugin-alloy/src/typescript/components/builtin-file.tsx
|
|
697
|
+
/**
|
|
698
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
699
|
+
*
|
|
700
|
+
* @param props - The properties for the source file.
|
|
701
|
+
* @returns The rendered source file component.
|
|
702
|
+
*/
|
|
703
|
+
function BuiltinFile(props) {
|
|
704
|
+
const [{ children, imports, id, description, tsx }, rest] = (0, __alloy_js_core.splitProps)(props, [
|
|
705
|
+
"children",
|
|
706
|
+
"imports",
|
|
707
|
+
"id",
|
|
708
|
+
"description",
|
|
709
|
+
"tsx"
|
|
710
|
+
]);
|
|
711
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
712
|
+
const path = (0, __alloy_js_core.computed)(() => (0, __stryke_path_replace.replacePath)(`${!(0, __stryke_type_checks_is_set.isSet)(tsx) ? id : (0, __stryke_path_replace.replaceExtension)(id)}${(0, __stryke_path_file_path_fns.hasFileExtension)(id) && !(0, __stryke_type_checks_is_set.isSet)(tsx) ? "" : tsx ? ".tsx" : ".ts"}`, context.builtinsPath));
|
|
713
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({
|
|
714
|
+
get header() {
|
|
715
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeader, {
|
|
716
|
+
get header() {
|
|
717
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocModule, {
|
|
718
|
+
name: id,
|
|
719
|
+
children: description
|
|
720
|
+
});
|
|
721
|
+
},
|
|
722
|
+
get children() {
|
|
723
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeaderImports, { imports });
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
get meta() {
|
|
728
|
+
return {
|
|
729
|
+
kind: "builtin",
|
|
730
|
+
id: (0, __stryke_path_replace.replaceExtension)(id)
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
}, rest, {
|
|
734
|
+
get path() {
|
|
735
|
+
return path.value;
|
|
736
|
+
},
|
|
737
|
+
children
|
|
738
|
+
}));
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region ../plugin-alloy/src/typescript/components/tsdoc-reflection.tsx
|
|
743
|
+
/**
|
|
744
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
745
|
+
*/
|
|
746
|
+
function TSDocReflectionClass(props) {
|
|
747
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
748
|
+
const reflectionClass = require_create_reflection_resource.useReflectionClass();
|
|
749
|
+
const title = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.getTitle() || (0, __stryke_string_format_title_case.titleCase)(reflectionClass.reflection.getName()));
|
|
750
|
+
const alias = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.getAlias());
|
|
751
|
+
const domain = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.getDomain());
|
|
752
|
+
const permission = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.getPermission());
|
|
753
|
+
const readonly = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.isReadonly());
|
|
754
|
+
const internal = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.isInternal());
|
|
755
|
+
const ignore = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.isIgnored());
|
|
756
|
+
const hidden = (0, __alloy_js_core.computed)(() => reflectionClass.reflection.isHidden());
|
|
757
|
+
if (!reflectionClass.reflection.getName()) return null;
|
|
758
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, (0, __alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
759
|
+
get heading() {
|
|
760
|
+
return reflectionClass.reflection.getDescription();
|
|
761
|
+
},
|
|
762
|
+
get children() {
|
|
763
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
764
|
+
get when() {
|
|
765
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(title.value) || !(0, __stryke_type_checks_is_undefined.isUndefined)(alias.value) && alias.value.length > 0 || !(0, __stryke_type_checks_is_undefined.isUndefined)(permission.value) && permission.value.length > 0 || (0, __stryke_type_checks_is_set_string.isSetString)(domain.value) || !(0, __stryke_type_checks_is_undefined.isUndefined)(readonly.value) || !(0, __stryke_type_checks_is_undefined.isUndefined)(internal.value) || !(0, __stryke_type_checks_is_undefined.isUndefined)(ignore.value) || !(0, __stryke_type_checks_is_undefined.isUndefined)(hidden.value);
|
|
766
|
+
},
|
|
767
|
+
get children() {
|
|
768
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocAttributesTags, {
|
|
769
|
+
get title() {
|
|
770
|
+
return title.value;
|
|
771
|
+
},
|
|
772
|
+
get alias() {
|
|
773
|
+
return alias.value;
|
|
774
|
+
},
|
|
775
|
+
get domain() {
|
|
776
|
+
return domain.value;
|
|
777
|
+
},
|
|
778
|
+
get permission() {
|
|
779
|
+
return permission.value;
|
|
780
|
+
},
|
|
781
|
+
get readonly() {
|
|
782
|
+
return readonly.value;
|
|
783
|
+
},
|
|
784
|
+
get internal() {
|
|
785
|
+
return internal.value;
|
|
786
|
+
},
|
|
787
|
+
get ignore() {
|
|
788
|
+
return ignore.value;
|
|
789
|
+
},
|
|
790
|
+
get hidden() {
|
|
791
|
+
return hidden.value;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
796
|
+
get when() {
|
|
797
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!Boolean(children))() && (0, __alloy_js_core.childrenArray)(() => children).length > 0;
|
|
798
|
+
},
|
|
799
|
+
get children() {
|
|
800
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.List, { get children() {
|
|
801
|
+
return (0, __alloy_js_core.childrenArray)(() => children);
|
|
802
|
+
} });
|
|
803
|
+
}
|
|
804
|
+
})];
|
|
805
|
+
}
|
|
806
|
+
}));
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
810
|
+
*/
|
|
811
|
+
function TSDocReflectionProperty(props) {
|
|
812
|
+
const [{ children }, rest] = (0, __alloy_js_core.splitProps)(props, ["children"]);
|
|
813
|
+
const context = require_create_reflection_resource.useReflectionProperty();
|
|
814
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, (0, __alloy_js_core_jsx_runtime.mergeProps)({ get heading() {
|
|
815
|
+
return context.getDescription();
|
|
816
|
+
} }, rest, { get children() {
|
|
817
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocAttributesTags, {
|
|
818
|
+
get title() {
|
|
819
|
+
return context.getTitle();
|
|
820
|
+
},
|
|
821
|
+
get alias() {
|
|
822
|
+
return context.getAlias();
|
|
823
|
+
},
|
|
824
|
+
get domain() {
|
|
825
|
+
return context.getDomain();
|
|
826
|
+
},
|
|
827
|
+
get permission() {
|
|
828
|
+
return context.getPermission();
|
|
829
|
+
},
|
|
830
|
+
get readonly() {
|
|
831
|
+
return context.isReadonly();
|
|
832
|
+
},
|
|
833
|
+
get internal() {
|
|
834
|
+
return context.isInternal();
|
|
835
|
+
},
|
|
836
|
+
get ignore() {
|
|
837
|
+
return context.isIgnored();
|
|
838
|
+
},
|
|
839
|
+
get hidden() {
|
|
840
|
+
return context.isHidden();
|
|
841
|
+
}
|
|
842
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
843
|
+
get when() {
|
|
844
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!Boolean(children))() && (0, __alloy_js_core.childrenArray)(() => children).length > 0;
|
|
845
|
+
},
|
|
846
|
+
get children() {
|
|
847
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.List, { get children() {
|
|
848
|
+
return (0, __alloy_js_core.childrenArray)(() => children);
|
|
849
|
+
} });
|
|
850
|
+
}
|
|
851
|
+
})];
|
|
852
|
+
} }));
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region ../plugin-alloy/src/typescript/components/typescript-interface.tsx
|
|
857
|
+
/**
|
|
858
|
+
* Generates a TypeScript interface for the given reflection class.
|
|
859
|
+
*/
|
|
860
|
+
function TypeScriptInterface(props) {
|
|
861
|
+
const [{ name, reflection }, rest] = (0, __alloy_js_core.splitProps)(props, ["name", "reflection"]);
|
|
862
|
+
const interfaceName = (0, __alloy_js_core.computed)(() => (0, __stryke_string_format_pascal_case.pascalCase)(((0, __stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection.getName()));
|
|
863
|
+
const properties = reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
864
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.ReflectionClassContext.Provider, {
|
|
865
|
+
value: { reflection },
|
|
866
|
+
get children() {
|
|
867
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionClass, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, (0, __alloy_js_core_jsx_runtime.mergeProps)({
|
|
868
|
+
"export": true,
|
|
869
|
+
get name() {
|
|
870
|
+
return interfaceName.value;
|
|
871
|
+
}
|
|
872
|
+
}, rest, { get children() {
|
|
873
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
874
|
+
each: properties,
|
|
875
|
+
doubleHardline: true,
|
|
876
|
+
semicolon: true,
|
|
877
|
+
children: (prop) => (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptInterfaceProperty, { property: prop })
|
|
878
|
+
});
|
|
879
|
+
} }))];
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
885
|
+
*/
|
|
886
|
+
function TypescriptInterfaceProperty(props) {
|
|
887
|
+
const [{ property }, rest] = (0, __alloy_js_core.splitProps)(props, ["property"]);
|
|
888
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.ReflectionPropertyContext.Provider, {
|
|
889
|
+
value: property,
|
|
890
|
+
get children() {
|
|
891
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionProperty, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, (0, __alloy_js_core_jsx_runtime.mergeProps)({
|
|
892
|
+
get name() {
|
|
893
|
+
return property.getNameAsString();
|
|
894
|
+
},
|
|
895
|
+
get readonly() {
|
|
896
|
+
return property.isReadonly();
|
|
897
|
+
},
|
|
898
|
+
get optional() {
|
|
899
|
+
return property.isOptional();
|
|
900
|
+
},
|
|
901
|
+
get nullish() {
|
|
902
|
+
return property.isNullable();
|
|
903
|
+
},
|
|
904
|
+
get type() {
|
|
905
|
+
return (0, __powerlines_deepkit_vendor_type.stringifyType)(property.getType());
|
|
906
|
+
}
|
|
907
|
+
}, rest))];
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region ../plugin-alloy/src/typescript/components/typescript-object.tsx
|
|
914
|
+
/**
|
|
915
|
+
* Generates a TypeScript object for the given reflection class.
|
|
916
|
+
*/
|
|
917
|
+
function TypescriptObject(props) {
|
|
918
|
+
if (!props.reflection?.value) return null;
|
|
919
|
+
const objectName = (0, __alloy_js_core.computed)(() => (0, __stryke_string_format_camel_case.camelCase)(((0, __stryke_type_checks_is_string.isString)(props.name) ? props.name : props.name.toString()) || props.reflection.value.getName()));
|
|
920
|
+
const objectType = (0, __alloy_js_core.computed)(() => props.type || (0, __stryke_string_format_pascal_case.pascalCase)(props.reflection.value.getName()));
|
|
921
|
+
const properties = (0, __alloy_js_core.computed)(() => props.reflection.value.getProperties().filter((item) => !item.isIgnored() && !(0, __stryke_type_checks_is_undefined.isUndefined)(props.defaultValue?.value?.[item.getNameAsString()] ?? item.getAlias().reduce((ret, alias) => {
|
|
922
|
+
if ((0, __stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, __stryke_type_checks_is_undefined.isUndefined)(props.defaultValue?.value?.[alias])) return props.defaultValue?.value?.[alias];
|
|
923
|
+
return ret;
|
|
924
|
+
}, void 0) ?? item.getDefaultValue())).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1));
|
|
925
|
+
const TypeSymbolSlot = (0, __alloy_js_core.createSymbolSlot)();
|
|
926
|
+
const ValueTypeSymbolSlot = (0, __alloy_js_core.createSymbolSlot)();
|
|
927
|
+
const sym = (0, __alloy_js_typescript.createValueSymbol)(props.name, {
|
|
928
|
+
refkeys: props.refkey,
|
|
929
|
+
default: props.default,
|
|
930
|
+
export: props.export,
|
|
931
|
+
metadata: props.metadata,
|
|
932
|
+
tsFlags: props.nullish ? __alloy_js_typescript.TSSymbolFlags.Nullish : __alloy_js_typescript.TSSymbolFlags.None,
|
|
933
|
+
type: props.type ? TypeSymbolSlot.firstSymbol : void 0,
|
|
934
|
+
namePolicy: (0, __alloy_js_typescript.useTSNamePolicy)().for("variable")
|
|
935
|
+
});
|
|
936
|
+
if (!props.type) ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
937
|
+
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
938
|
+
const type = props.type ? (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeRefContext, { get children() {
|
|
939
|
+
return [": ", (0, __alloy_js_core_jsx_runtime.createComponent)(TypeSymbolSlot, { get children() {
|
|
940
|
+
return props.type;
|
|
941
|
+
} })];
|
|
942
|
+
} }) : void 0;
|
|
943
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
944
|
+
get when() {
|
|
945
|
+
return !!props.reflection.value;
|
|
946
|
+
},
|
|
947
|
+
get children() {
|
|
948
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.ReflectionClassContext.Provider, {
|
|
949
|
+
get value() {
|
|
950
|
+
return {
|
|
951
|
+
reflection: props.reflection.value,
|
|
952
|
+
override: {
|
|
953
|
+
name: objectName.value,
|
|
954
|
+
type: objectType.value,
|
|
955
|
+
defaultValue: props.defaultValue?.value
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
},
|
|
959
|
+
get children() {
|
|
960
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
961
|
+
get when() {
|
|
962
|
+
return !!objectName.value && !!objectType.value;
|
|
963
|
+
},
|
|
964
|
+
get children() {
|
|
965
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionClass, {}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Declaration, {
|
|
966
|
+
symbol: sym,
|
|
967
|
+
get children() {
|
|
968
|
+
return [
|
|
969
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => props.export ? "export " : ""),
|
|
970
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => props.default ? "default " : ""),
|
|
971
|
+
keyword,
|
|
972
|
+
" ",
|
|
973
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Name, {}),
|
|
974
|
+
type,
|
|
975
|
+
" =",
|
|
976
|
+
" ",
|
|
977
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(ValueTypeSymbolSlot, { get children() {
|
|
978
|
+
return props.initializer ?? props.children ?? (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ObjectExpression, { get children() {
|
|
979
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
980
|
+
get each() {
|
|
981
|
+
return properties.value ?? [];
|
|
982
|
+
},
|
|
983
|
+
comma: true,
|
|
984
|
+
doubleHardline: true,
|
|
985
|
+
children: (prop) => (0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptObjectProperty, { property: prop })
|
|
986
|
+
});
|
|
987
|
+
} });
|
|
988
|
+
} })
|
|
989
|
+
];
|
|
990
|
+
}
|
|
991
|
+
})];
|
|
992
|
+
}
|
|
993
|
+
}), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Generates a TypeScript object property for the given reflection class.
|
|
1001
|
+
*/
|
|
1002
|
+
function TypescriptObjectProperty(props) {
|
|
1003
|
+
const [{ property }] = (0, __alloy_js_core.splitProps)(props, ["property"]);
|
|
1004
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_create_reflection_resource.ReflectionPropertyContext.Provider, {
|
|
1005
|
+
value: property,
|
|
1006
|
+
get children() {
|
|
1007
|
+
return [
|
|
1008
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReflectionProperty, {}),
|
|
1009
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ObjectProperty, {
|
|
1010
|
+
get name() {
|
|
1011
|
+
return property.getNameAsString();
|
|
1012
|
+
},
|
|
1013
|
+
get value() {
|
|
1014
|
+
return stringifyDefaultValue(property);
|
|
1015
|
+
}
|
|
1016
|
+
}),
|
|
1017
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
1018
|
+
];
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/components/env.tsx
|
|
1025
|
+
/**
|
|
1026
|
+
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
1027
|
+
*/
|
|
1028
|
+
function EnvTypeDefinition(props) {
|
|
1029
|
+
const [{ defaultValue, reflection }] = (0, __alloy_js_core.splitProps)(props, ["defaultValue", "reflection"]);
|
|
1030
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
1031
|
+
return [
|
|
1032
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TypeScriptInterface, {
|
|
1033
|
+
name: " EnvBase",
|
|
1034
|
+
"extends": ["EnvInterface"],
|
|
1035
|
+
defaultValue,
|
|
1036
|
+
reflection,
|
|
1037
|
+
"export": true
|
|
1038
|
+
}),
|
|
1039
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1040
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1041
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
1042
|
+
name: "Env",
|
|
1043
|
+
"export": true,
|
|
1044
|
+
get children() {
|
|
1045
|
+
return __alloy_js_core.code` {
|
|
1046
|
+
[Key in keyof EnvBase as Key ${context?.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
1047
|
+
}
|
|
1048
|
+
`;
|
|
1049
|
+
}
|
|
1050
|
+
})
|
|
1051
|
+
];
|
|
1052
|
+
}
|
|
1053
|
+
function ConfigPropertyConditional(props) {
|
|
1054
|
+
const [{ context, name }] = (0, __alloy_js_core.splitProps)(props, ["context", "name"]);
|
|
1055
|
+
if (!context) return null;
|
|
1056
|
+
return __alloy_js_core.code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
1057
|
+
}
|
|
1058
|
+
function ConfigPropertyGet(props) {
|
|
1059
|
+
const [{ context, property, index }] = (0, __alloy_js_core.splitProps)(props, [
|
|
1060
|
+
"context",
|
|
1061
|
+
"property",
|
|
1062
|
+
"index"
|
|
1063
|
+
]);
|
|
1064
|
+
if (!context) return null;
|
|
1065
|
+
return [index === 0 ? (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
1066
|
+
get condition() {
|
|
1067
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1068
|
+
get name() {
|
|
1069
|
+
return property.getNameAsString();
|
|
1070
|
+
},
|
|
1071
|
+
context
|
|
1072
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1073
|
+
get when() {
|
|
1074
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
1075
|
+
},
|
|
1076
|
+
get children() {
|
|
1077
|
+
return [__alloy_js_core.code` || `, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1078
|
+
get each() {
|
|
1079
|
+
return property.getAlias();
|
|
1080
|
+
},
|
|
1081
|
+
joiner: __alloy_js_core.code` || `,
|
|
1082
|
+
children: (alias) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1083
|
+
name: alias,
|
|
1084
|
+
context
|
|
1085
|
+
})
|
|
1086
|
+
})];
|
|
1087
|
+
}
|
|
1088
|
+
})];
|
|
1089
|
+
},
|
|
1090
|
+
get children() {
|
|
1091
|
+
return __alloy_js_core.code`return target["${property.getNameAsString()}"];`;
|
|
1092
|
+
}
|
|
1093
|
+
}) : (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
1094
|
+
get condition() {
|
|
1095
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1096
|
+
get name() {
|
|
1097
|
+
return property.getNameAsString();
|
|
1098
|
+
},
|
|
1099
|
+
context
|
|
1100
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1101
|
+
get when() {
|
|
1102
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
1103
|
+
},
|
|
1104
|
+
get children() {
|
|
1105
|
+
return [__alloy_js_core.code` || `, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1106
|
+
get each() {
|
|
1107
|
+
return property.getAlias();
|
|
1108
|
+
},
|
|
1109
|
+
joiner: __alloy_js_core.code` || `,
|
|
1110
|
+
children: (alias) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1111
|
+
name: alias,
|
|
1112
|
+
context
|
|
1113
|
+
})
|
|
1114
|
+
})];
|
|
1115
|
+
}
|
|
1116
|
+
})];
|
|
1117
|
+
},
|
|
1118
|
+
get children() {
|
|
1119
|
+
return __alloy_js_core.code`return target["${property.getNameAsString()}"];`;
|
|
1120
|
+
}
|
|
1121
|
+
})];
|
|
1122
|
+
}
|
|
1123
|
+
function ConfigPropertySet(props) {
|
|
1124
|
+
const [{ context, property, index }] = (0, __alloy_js_core.splitProps)(props, [
|
|
1125
|
+
"context",
|
|
1126
|
+
"property",
|
|
1127
|
+
"index"
|
|
1128
|
+
]);
|
|
1129
|
+
if (!context) return null;
|
|
1130
|
+
return [index === 0 ? (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
1131
|
+
get condition() {
|
|
1132
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1133
|
+
get name() {
|
|
1134
|
+
return property.getNameAsString();
|
|
1135
|
+
},
|
|
1136
|
+
context
|
|
1137
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1138
|
+
get when() {
|
|
1139
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
1140
|
+
},
|
|
1141
|
+
get children() {
|
|
1142
|
+
return [__alloy_js_core.code` || `, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1143
|
+
get each() {
|
|
1144
|
+
return property.getAlias();
|
|
1145
|
+
},
|
|
1146
|
+
joiner: __alloy_js_core.code` || `,
|
|
1147
|
+
children: (alias) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1148
|
+
name: alias,
|
|
1149
|
+
context
|
|
1150
|
+
})
|
|
1151
|
+
})];
|
|
1152
|
+
}
|
|
1153
|
+
})];
|
|
1154
|
+
},
|
|
1155
|
+
get children() {
|
|
1156
|
+
return __alloy_js_core.code`
|
|
1157
|
+
target["${property.getNameAsString()}"] = newValue;
|
|
1158
|
+
return true;
|
|
1159
|
+
`;
|
|
1160
|
+
}
|
|
1161
|
+
}) : (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
1162
|
+
get condition() {
|
|
1163
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1164
|
+
get name() {
|
|
1165
|
+
return property.getNameAsString();
|
|
1166
|
+
},
|
|
1167
|
+
context
|
|
1168
|
+
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1169
|
+
get when() {
|
|
1170
|
+
return (0, __alloy_js_core_jsx_runtime.memo)(() => !!property.getAlias())() && property.getAlias().length > 0;
|
|
1171
|
+
},
|
|
1172
|
+
get children() {
|
|
1173
|
+
return [__alloy_js_core.code` || `, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1174
|
+
get each() {
|
|
1175
|
+
return property.getAlias();
|
|
1176
|
+
},
|
|
1177
|
+
joiner: __alloy_js_core.code` || `,
|
|
1178
|
+
children: (alias) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyConditional, {
|
|
1179
|
+
name: alias,
|
|
1180
|
+
context
|
|
1181
|
+
})
|
|
1182
|
+
})];
|
|
1183
|
+
}
|
|
1184
|
+
})];
|
|
1185
|
+
},
|
|
1186
|
+
get children() {
|
|
1187
|
+
return __alloy_js_core.code`
|
|
1188
|
+
target["${property.getNameAsString()}"] = newValue;
|
|
1189
|
+
return true;
|
|
1190
|
+
`;
|
|
1191
|
+
}
|
|
1192
|
+
})];
|
|
1193
|
+
}
|
|
1194
|
+
const createEnvRefkey = refkey("createEnv");
|
|
1195
|
+
const envRefkey = refkey("env");
|
|
1196
|
+
const envSerializerRefkey = refkey("EnvSerializer");
|
|
1197
|
+
/**
|
|
1198
|
+
* Generates the environment configuration module for the Powerlines project.
|
|
1199
|
+
*/
|
|
1200
|
+
function EnvBuiltin(props) {
|
|
1201
|
+
const [{ defaultConfig, children }, rest] = (0, __alloy_js_core.splitProps)(props, ["defaultConfig", "children"]);
|
|
1202
|
+
const context = require_create_reflection_resource.usePowerlines();
|
|
1203
|
+
const defaultValue = (0, __alloy_js_core.computed)(() => context && require_create_reflection_resource.loadEnvFromContext(context, process.env));
|
|
1204
|
+
const reflection = require_create_reflection_resource.createReflectionResource(context);
|
|
1205
|
+
const envInstance = (0, __alloy_js_core.computed)(() => {
|
|
1206
|
+
return new __powerlines_deepkit_vendor_type.ReflectionClass({
|
|
1207
|
+
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
1208
|
+
description: `The initial environment configuration state for the ${(0, __stryke_string_format_title_case.titleCase)(context?.config?.name)} project.`,
|
|
1209
|
+
types: []
|
|
1210
|
+
}, reflection.data ?? void 0);
|
|
1211
|
+
});
|
|
1212
|
+
const reflectionGetProperties = (0, __alloy_js_core.computed)(() => reflection.data?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
1213
|
+
const reflectionSetProperties = (0, __alloy_js_core.computed)(() => reflection.data?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
1214
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(BuiltinFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({
|
|
1215
|
+
id: "env",
|
|
1216
|
+
description: "The Powerlines environment configuration module provides an interface to define environment configuration parameters."
|
|
1217
|
+
}, rest, {
|
|
1218
|
+
get imports() {
|
|
1219
|
+
return (0, defu.default)({
|
|
1220
|
+
"@powerlines/deepkit/vendor/type": [
|
|
1221
|
+
"Type",
|
|
1222
|
+
"stringify",
|
|
1223
|
+
"serializer",
|
|
1224
|
+
"serializeFunction",
|
|
1225
|
+
"deserializeFunction",
|
|
1226
|
+
"ReflectionKind",
|
|
1227
|
+
"TemplateState",
|
|
1228
|
+
"Serializer",
|
|
1229
|
+
"TypeProperty",
|
|
1230
|
+
"TypePropertySignature"
|
|
1231
|
+
],
|
|
1232
|
+
"@powerlines/plugin-env/types/runtime": [{ name: "EnvInterface" }]
|
|
1233
|
+
}, rest.imports ?? {});
|
|
1234
|
+
},
|
|
1235
|
+
get children() {
|
|
1236
|
+
return [
|
|
1237
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1238
|
+
get when() {
|
|
1239
|
+
return !(0, __stryke_type_checks_is_null.isNull)(reflection.data);
|
|
1240
|
+
},
|
|
1241
|
+
get children() {
|
|
1242
|
+
return [
|
|
1243
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(EnvTypeDefinition, {
|
|
1244
|
+
get defaultValue() {
|
|
1245
|
+
return defaultValue.value;
|
|
1246
|
+
},
|
|
1247
|
+
get reflection() {
|
|
1248
|
+
return reflection.data;
|
|
1249
|
+
}
|
|
1250
|
+
}),
|
|
1251
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1252
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
1253
|
+
];
|
|
1254
|
+
}
|
|
1255
|
+
}),
|
|
1256
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TypescriptObject, {
|
|
1257
|
+
name: "initialEnv",
|
|
1258
|
+
type: "Partial<EnvBase>",
|
|
1259
|
+
defaultValue,
|
|
1260
|
+
reflection: envInstance,
|
|
1261
|
+
"export": true,
|
|
1262
|
+
"const": true
|
|
1263
|
+
}),
|
|
1264
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1265
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1266
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1267
|
+
heading: "The environment configuration serializer for the Powerlines application.",
|
|
1268
|
+
get children() {
|
|
1269
|
+
return [
|
|
1270
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
1271
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
1272
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
1273
|
+
];
|
|
1274
|
+
}
|
|
1275
|
+
}),
|
|
1276
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ClassDeclaration, {
|
|
1277
|
+
refkey: envSerializerRefkey,
|
|
1278
|
+
name: "EnvSerializer",
|
|
1279
|
+
"extends": "Serializer",
|
|
1280
|
+
"export": true,
|
|
1281
|
+
get children() {
|
|
1282
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ClassMethod, {
|
|
1283
|
+
name: "constructor",
|
|
1284
|
+
"public": true,
|
|
1285
|
+
children: __alloy_js_core.code`
|
|
1286
|
+
super("env");
|
|
1287
|
+
|
|
1288
|
+
this.deserializeRegistry.register(
|
|
1289
|
+
ReflectionKind.boolean,
|
|
1290
|
+
(type: Type, state: TemplateState) => {
|
|
1291
|
+
state.addSetter(
|
|
1292
|
+
\`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
);
|
|
1296
|
+
`
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
}),
|
|
1300
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1301
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1302
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1303
|
+
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
1304
|
+
get children() {
|
|
1305
|
+
return [
|
|
1306
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
1307
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
1308
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
1309
|
+
];
|
|
1310
|
+
}
|
|
1311
|
+
}),
|
|
1312
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1313
|
+
name: "envSerializer",
|
|
1314
|
+
"export": false,
|
|
1315
|
+
"const": true,
|
|
1316
|
+
get initializer() {
|
|
1317
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.NewExpression, {
|
|
1318
|
+
args: [],
|
|
1319
|
+
target: "EnvSerializer"
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
}),
|
|
1323
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1324
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1325
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1326
|
+
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
1327
|
+
get children() {
|
|
1328
|
+
return [
|
|
1329
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: `The resulting JSON object can be stringified using JSON.stringify().` }),
|
|
1330
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
1331
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
1332
|
+
];
|
|
1333
|
+
}
|
|
1334
|
+
}),
|
|
1335
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1336
|
+
name: "serializeEnv",
|
|
1337
|
+
"export": true,
|
|
1338
|
+
"const": true,
|
|
1339
|
+
initializer: "serializeFunction<EnvBase>(envSerializer)"
|
|
1340
|
+
}),
|
|
1341
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1342
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1343
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1344
|
+
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
1345
|
+
get children() {
|
|
1346
|
+
return [
|
|
1347
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
1348
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
1349
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
1350
|
+
];
|
|
1351
|
+
}
|
|
1352
|
+
}),
|
|
1353
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1354
|
+
name: "deserializeEnv",
|
|
1355
|
+
"export": true,
|
|
1356
|
+
"const": true,
|
|
1357
|
+
initializer: "deserializeFunction<EnvBase>(envSerializer)"
|
|
1358
|
+
}),
|
|
1359
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1360
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1361
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1362
|
+
heading: "Initializes the Powerlines environment configuration module.",
|
|
1363
|
+
get children() {
|
|
1364
|
+
return [
|
|
1365
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
1366
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocParam, {
|
|
1367
|
+
name: "environmentConfig",
|
|
1368
|
+
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
1369
|
+
}),
|
|
1370
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
1371
|
+
];
|
|
1372
|
+
}
|
|
1373
|
+
}),
|
|
1374
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1375
|
+
get when() {
|
|
1376
|
+
return Boolean(context?.entryPath);
|
|
1377
|
+
},
|
|
1378
|
+
get children() {
|
|
1379
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
1380
|
+
refkey: createEnvRefkey,
|
|
1381
|
+
async: false,
|
|
1382
|
+
"export": true,
|
|
1383
|
+
name: "createEnv",
|
|
1384
|
+
parameters: [{
|
|
1385
|
+
name: "environmentConfig",
|
|
1386
|
+
type: `Partial<Env>`,
|
|
1387
|
+
optional: false,
|
|
1388
|
+
default: "{}"
|
|
1389
|
+
}],
|
|
1390
|
+
returnType: "Env",
|
|
1391
|
+
get children() {
|
|
1392
|
+
return [
|
|
1393
|
+
__alloy_js_core.code`
|
|
1394
|
+
return new Proxy<Env>(
|
|
1395
|
+
deserializeEnv({
|
|
1396
|
+
...initialEnv,
|
|
1397
|
+
...environmentConfig
|
|
1398
|
+
}) as Env,
|
|
1399
|
+
{
|
|
1400
|
+
get: (target: EnvBase, propertyName: string) => { `,
|
|
1401
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1402
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1403
|
+
each: reflectionGetProperties,
|
|
1404
|
+
children: (property, index) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertyGet, {
|
|
1405
|
+
index,
|
|
1406
|
+
context,
|
|
1407
|
+
property
|
|
1408
|
+
})
|
|
1409
|
+
}),
|
|
1410
|
+
__alloy_js_core.code`
|
|
1411
|
+
return undefined;
|
|
1412
|
+
}, `,
|
|
1413
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1414
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1415
|
+
__alloy_js_core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
|
|
1416
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1417
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
1418
|
+
each: reflectionSetProperties,
|
|
1419
|
+
ender: __alloy_js_core.code` else `,
|
|
1420
|
+
children: (property, index) => (0, __alloy_js_core_jsx_runtime.createComponent)(ConfigPropertySet, {
|
|
1421
|
+
index,
|
|
1422
|
+
context,
|
|
1423
|
+
property
|
|
1424
|
+
})
|
|
1425
|
+
}),
|
|
1426
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1427
|
+
__alloy_js_core.code`return false;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
);
|
|
1431
|
+
`
|
|
1432
|
+
];
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
}),
|
|
1437
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1438
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1439
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1440
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1441
|
+
refkey: envRefkey,
|
|
1442
|
+
name: "env",
|
|
1443
|
+
type: "Env",
|
|
1444
|
+
"export": true,
|
|
1445
|
+
"const": true,
|
|
1446
|
+
get initializer() {
|
|
1447
|
+
return [__alloy_js_core.code`createEnv(${defaultConfig || "{}"} as Partial<Env>);`];
|
|
1448
|
+
}
|
|
1449
|
+
}),
|
|
1450
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1451
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1452
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1453
|
+
"export": true,
|
|
1454
|
+
"const": true,
|
|
1455
|
+
name: "isCI",
|
|
1456
|
+
doc: "Detect if the application is running in a CI environment.",
|
|
1457
|
+
initializer: __alloy_js_core.code`Boolean(
|
|
1458
|
+
env.CI ||
|
|
1459
|
+
env.RUN_ID ||
|
|
1460
|
+
env.AGOLA_GIT_REF ||
|
|
1461
|
+
env.AC_APPCIRCLE ||
|
|
1462
|
+
env.APPVEYOR ||
|
|
1463
|
+
env.CODEBUILD ||
|
|
1464
|
+
env.TF_BUILD ||
|
|
1465
|
+
env.bamboo_planKey ||
|
|
1466
|
+
env.BITBUCKET_COMMIT ||
|
|
1467
|
+
env.BITRISE_IO ||
|
|
1468
|
+
env.BUDDY_WORKSPACE_ID ||
|
|
1469
|
+
env.BUILDKITE ||
|
|
1470
|
+
env.CIRCLECI ||
|
|
1471
|
+
env.CIRRUS_CI ||
|
|
1472
|
+
env.CF_BUILD_ID ||
|
|
1473
|
+
env.CM_BUILD_ID ||
|
|
1474
|
+
env.CI_NAME ||
|
|
1475
|
+
env.DRONE ||
|
|
1476
|
+
env.DSARI ||
|
|
1477
|
+
env.EARTHLY_CI ||
|
|
1478
|
+
env.EAS_BUILD ||
|
|
1479
|
+
env.GERRIT_PROJECT ||
|
|
1480
|
+
env.GITEA_ACTIONS ||
|
|
1481
|
+
env.GITHUB_ACTIONS ||
|
|
1482
|
+
env.GITLAB_CI ||
|
|
1483
|
+
env.GOCD ||
|
|
1484
|
+
env.BUILDER_OUTPUT ||
|
|
1485
|
+
env.HARNESS_BUILD_ID ||
|
|
1486
|
+
env.JENKINS_URL ||
|
|
1487
|
+
env.LAYERCI ||
|
|
1488
|
+
env.MAGNUM ||
|
|
1489
|
+
env.NETLIFY ||
|
|
1490
|
+
env.NEVERCODE ||
|
|
1491
|
+
env.PROW_JOB_ID ||
|
|
1492
|
+
env.RELEASE_BUILD_ID ||
|
|
1493
|
+
env.RENDER ||
|
|
1494
|
+
env.SAILCI ||
|
|
1495
|
+
env.HUDSON ||
|
|
1496
|
+
env.SCREWDRIVER ||
|
|
1497
|
+
env.SEMAPHORE ||
|
|
1498
|
+
env.SOURCEHUT ||
|
|
1499
|
+
env.STRIDER ||
|
|
1500
|
+
env.TASK_ID ||
|
|
1501
|
+
env.RUN_ID ||
|
|
1502
|
+
env.TEAMCITY_VERSION ||
|
|
1503
|
+
env.TRAVIS ||
|
|
1504
|
+
env.VELA ||
|
|
1505
|
+
env.NOW_BUILDER ||
|
|
1506
|
+
env.APPCENTER_BUILD_ID ||
|
|
1507
|
+
env.CI_XCODE_PROJECT ||
|
|
1508
|
+
env.XCS || false
|
|
1509
|
+
);
|
|
1510
|
+
`
|
|
1511
|
+
}),
|
|
1512
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1513
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1514
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(TSDoc, {
|
|
1515
|
+
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
1516
|
+
get children() {
|
|
1517
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(TSDocRemarks, { children: __alloy_js_core.code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, Storm Software generally only allows a value in the following list:
|
|
1518
|
+
- \`production\`
|
|
1519
|
+
- \`test\`
|
|
1520
|
+
- \`development\`` });
|
|
1521
|
+
}
|
|
1522
|
+
}),
|
|
1523
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1524
|
+
"export": true,
|
|
1525
|
+
"const": true,
|
|
1526
|
+
name: "mode",
|
|
1527
|
+
initializer: __alloy_js_core.code`String(env.MODE) || "production"; `
|
|
1528
|
+
}),
|
|
1529
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1530
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1531
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1532
|
+
"export": true,
|
|
1533
|
+
"const": true,
|
|
1534
|
+
name: "isProduction",
|
|
1535
|
+
doc: "Detect if the application is running in \\\"production\\\\\" mode",
|
|
1536
|
+
initializer: __alloy_js_core.code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
1537
|
+
}),
|
|
1538
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1539
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1540
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1541
|
+
"export": true,
|
|
1542
|
+
"const": true,
|
|
1543
|
+
name: "isTest",
|
|
1544
|
+
doc: "Detect if the application is running in \"test\" mode",
|
|
1545
|
+
initializer: __alloy_js_core.code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
1546
|
+
}),
|
|
1547
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1548
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1549
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1550
|
+
"export": true,
|
|
1551
|
+
"const": true,
|
|
1552
|
+
name: "isDevelopment",
|
|
1553
|
+
doc: "Detect if the application is running in \"development\" mode",
|
|
1554
|
+
initializer: __alloy_js_core.code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
1555
|
+
}),
|
|
1556
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1557
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1558
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
1559
|
+
"export": true,
|
|
1560
|
+
"const": true,
|
|
1561
|
+
name: "isDebug",
|
|
1562
|
+
doc: "Detect if the application is running in \"debug\" mode",
|
|
1563
|
+
initializer: __alloy_js_core.code`Boolean(isDevelopment && env.DEBUG); `
|
|
1564
|
+
}),
|
|
1565
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1566
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1567
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
1568
|
+
get when() {
|
|
1569
|
+
return Boolean(children);
|
|
1570
|
+
},
|
|
1571
|
+
children
|
|
1572
|
+
})
|
|
1573
|
+
];
|
|
1574
|
+
}
|
|
1575
|
+
}));
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
//#endregion
|
|
1579
|
+
Object.defineProperty(exports, 'EnvBuiltin', {
|
|
1580
|
+
enumerable: true,
|
|
1581
|
+
get: function () {
|
|
1582
|
+
return EnvBuiltin;
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
Object.defineProperty(exports, 'EnvTypeDefinition', {
|
|
1586
|
+
enumerable: true,
|
|
1587
|
+
get: function () {
|
|
1588
|
+
return EnvTypeDefinition;
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
Object.defineProperty(exports, 'stringifyDefaultValue', {
|
|
1592
|
+
enumerable: true,
|
|
1593
|
+
get: function () {
|
|
1594
|
+
return stringifyDefaultValue;
|
|
1595
|
+
}
|
|
1596
|
+
});
|