@powerlines/plugin-react 0.1.134 → 0.1.136
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 +29 -0
- package/dist/components/index.cjs +2 -3
- package/dist/components/index.d.cts +1 -3
- package/dist/components/index.d.mts +1 -4
- package/dist/components/index.mjs +1 -2
- package/dist/components/react-optimized.cjs +48 -2
- package/dist/components/react-optimized.d.cts +13 -2
- package/dist/components/react-optimized.d.mts +13 -3
- package/dist/components/react-optimized.mjs +45 -1
- package/dist/deepkit/schemas/reflection.cjs +3940 -0
- package/dist/{plugin-CJdK9GYW.d.cts → deepkit/schemas/reflection.d.cts} +1 -331
- package/dist/{plugin-Noy_HIP5.d.mts → deepkit/schemas/reflection.d.mts} +59 -389
- package/dist/deepkit/schemas/reflection.mjs +3938 -0
- package/dist/deepkit/schemas/reflection2.cjs +4112 -0
- package/dist/deepkit/schemas/reflection2.mjs +4110 -0
- package/dist/deepkit/src/capnp.cjs +913 -0
- package/dist/deepkit/src/capnp.mjs +911 -0
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
- package/dist/deepkit/src/reflect-type.cjs +22 -0
- package/dist/deepkit/src/reflect-type.mjs +20 -0
- package/dist/deepkit/src/resolve-reflections.cjs +16 -0
- package/dist/deepkit/src/resolve-reflections.mjs +15 -0
- package/dist/deepkit/src/transformer.cjs +52 -0
- package/dist/deepkit/src/transformer.mjs +49 -0
- package/dist/deepkit/src/transpile.cjs +29 -0
- package/dist/deepkit/src/transpile.mjs +27 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/utilities.cjs +66 -0
- package/dist/deepkit/src/utilities.mjs +65 -0
- package/dist/index.cjs +16 -11295
- package/dist/index.d.cts +6 -7
- package/dist/index.d.mts +6 -8
- package/dist/index.mjs +7 -11280
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
- package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
- package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
- package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
- package/dist/plugin-alloy/src/index.cjs +99 -0
- package/dist/plugin-alloy/src/index.mjs +97 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
- package/dist/plugin-alloy/src/types/components.d.cts +23 -0
- package/dist/{components-Bs3-ohmM.d.mts → plugin-alloy/src/types/components.d.mts} +2 -1
- package/dist/plugin-alloy/src/types/index.d.cts +2 -0
- package/dist/plugin-alloy/src/types/index.d.mts +2 -0
- package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
- package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
- package/dist/plugin-automd/src/index.cjs +101 -0
- package/dist/plugin-automd/src/index.mjs +98 -0
- package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
- package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
- package/dist/plugin-automd/src/types/toc.d.cts +33 -0
- package/dist/plugin-automd/src/types/toc.d.mts +33 -0
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
- package/dist/plugin-babel/src/helpers/index.cjs +5 -0
- package/dist/plugin-babel/src/helpers/index.mjs +7 -0
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
- package/dist/plugin-babel/src/helpers/options.cjs +50 -0
- package/dist/plugin-babel/src/helpers/options.mjs +47 -0
- package/dist/plugin-babel/src/index.cjs +91 -0
- package/dist/plugin-babel/src/index.mjs +89 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
- package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
- package/dist/plugin-env/src/babel/index.cjs +1 -0
- package/dist/plugin-env/src/babel/index.mjs +3 -0
- package/dist/plugin-env/src/babel/plugin.cjs +121 -0
- package/dist/plugin-env/src/babel/plugin.mjs +119 -0
- package/dist/plugin-env/src/components/docs.cjs +9 -0
- package/dist/plugin-env/src/components/docs.mjs +11 -0
- package/dist/plugin-env/src/components/env.cjs +575 -0
- package/dist/plugin-env/src/components/env.mjs +572 -0
- package/dist/plugin-env/src/components/index.cjs +2 -0
- package/dist/plugin-env/src/components/index.mjs +4 -0
- package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
- package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
- package/dist/plugin-env/src/helpers/index.cjs +6 -0
- package/dist/plugin-env/src/helpers/index.mjs +8 -0
- package/dist/plugin-env/src/helpers/load.cjs +83 -0
- package/dist/plugin-env/src/helpers/load.mjs +80 -0
- package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
- package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
- package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
- package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
- package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
- package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
- package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
- package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
- package/dist/plugin-env/src/index.cjs +175 -0
- package/dist/plugin-env/src/index.mjs +173 -0
- package/dist/plugin-env/src/types/plugin.d.cts +152 -0
- package/dist/plugin-env/src/types/plugin.d.mts +153 -0
- package/dist/{runtime-B8Zgz0Kb.d.cts → plugin-env/src/types/runtime.d.cts} +2 -2
- package/dist/{runtime-BFnA_zZ8.d.mts → plugin-env/src/types/runtime.d.mts} +2 -2
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
- package/dist/powerlines/src/lib/entry.cjs +12 -0
- package/dist/powerlines/src/lib/entry.mjs +14 -0
- package/dist/powerlines/src/lib/logger.cjs +41 -0
- package/dist/powerlines/src/lib/logger.mjs +39 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
- package/dist/powerlines/src/types/babel.d.cts +22 -0
- package/dist/powerlines/src/types/babel.d.mts +22 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +147 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +387 -0
- package/dist/powerlines/src/types/config.d.mts +388 -0
- package/dist/powerlines/src/types/context.d.cts +414 -0
- package/dist/powerlines/src/types/context.d.mts +416 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +83 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -3
- package/dist/types/index.d.cts +2 -5
- package/dist/types/index.d.mts +2 -6
- package/dist/types/index.mjs +0 -4
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +72 -3
- package/dist/types/plugin.d.mts +72 -4
- package/dist/types/plugin.mjs +0 -2
- package/dist/types/runtime.cjs +0 -1
- package/dist/types/runtime.d.cts +14 -3
- package/dist/types/runtime.d.mts +14 -3
- package/dist/types/runtime.mjs +0 -2
- package/package.json +6 -6
- package/dist/components-BWLXb7a2.cjs +0 -0
- package/dist/components-D-mbfYAe.mjs +0 -1
- package/dist/index-B8OHl-c_.d.mts +0 -1
- package/dist/index-CFG0_wK4.d.cts +0 -1
- package/dist/index-DNLi60D-.d.mts +0 -1
- package/dist/index-_wQ5ClJU.d.cts +0 -1
- package/dist/plugin-jZ9N9Mz-.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/react-optimized-BpFTLlx0.mjs +0 -937
- package/dist/react-optimized-CVXQfO40.d.mts +0 -88
- package/dist/react-optimized-Kv14o38g.cjs +0 -1078
- package/dist/react-optimized-NGRcJkqA.d.cts +0 -105
- package/dist/resolved-CTt23qfE.d.cts +0 -1795
- package/dist/resolved-Nive48eM.d.mts +0 -1796
- package/dist/runtime-B-KyPHeI.d.mts +0 -15
- package/dist/runtime-BKY6WvHV.mjs +0 -1
- package/dist/runtime-Bp9G0scd.cjs +0 -0
- package/dist/runtime-Dm--tkdO.d.cts +0 -15
- package/dist/types--fVOUYBq.mjs +0 -1
- package/dist/types-a8gm_IaQ.cjs +0 -0
|
@@ -1,937 +0,0 @@
|
|
|
1
|
-
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
3
|
-
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
4
|
-
import defu from "defu";
|
|
5
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
6
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
7
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
8
|
-
import { For, List, Prose, Scope, Show, SourceDirectoryContext, SourceFileContext, childrenArray, code, computed, createContext, createNamedContext, getContext, refkey, splitProps, useContext, useFormatOptions, useScope } from "@alloy-js/core";
|
|
9
|
-
import { StormJSON } from "@stryke/json/storm-json";
|
|
10
|
-
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
11
|
-
import { appendPath } from "@stryke/path/append";
|
|
12
|
-
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
13
|
-
import { isNull } from "@stryke/type-checks/is-null";
|
|
14
|
-
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
15
|
-
import { FunctionDeclaration, ImportStatements, PackageContext, SourceFileContext as SourceFileContext$1, TSModuleScope, getSourceDirectoryData, useSourceFile } from "@alloy-js/typescript";
|
|
16
|
-
import { isSet } from "@stryke/type-checks/is-set";
|
|
17
|
-
import { isBoolean } from "@stryke/type-checks/is-boolean";
|
|
18
|
-
|
|
19
|
-
//#region ../plugin-alloy/src/core/contexts/context.ts
|
|
20
|
-
/**
|
|
21
|
-
* The Powerlines context used in template rendering.
|
|
22
|
-
*/
|
|
23
|
-
const PowerlinesContext = createNamedContext("powerlines");
|
|
24
|
-
/**
|
|
25
|
-
* Hook to access the Powerlines Context.
|
|
26
|
-
*
|
|
27
|
-
* @returns The Context.
|
|
28
|
-
*/
|
|
29
|
-
function usePowerlinesContext() {
|
|
30
|
-
return useContext(PowerlinesContext);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Hook to safely access the {@link PluginContext | Powerlines context}.
|
|
34
|
-
*
|
|
35
|
-
* @returns The Powerlines context or undefined if not set.
|
|
36
|
-
*/
|
|
37
|
-
function usePowerlinesSafe() {
|
|
38
|
-
return usePowerlinesContext()?.ref?.value;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Hook to access the {@link PluginContext | Powerlines context}.
|
|
42
|
-
*
|
|
43
|
-
* @returns The Powerlines context.
|
|
44
|
-
*/
|
|
45
|
-
function usePowerlines() {
|
|
46
|
-
const powerlines = usePowerlinesSafe();
|
|
47
|
-
if (!powerlines) throw new Error("Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
48
|
-
return powerlines;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Hook to safely access the render context's metadata.
|
|
52
|
-
*
|
|
53
|
-
* @returns The Powerlines context or undefined if not set.
|
|
54
|
-
*/
|
|
55
|
-
function useMetaSafe() {
|
|
56
|
-
return usePowerlinesContext()?.meta?.value;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Hook to access the render context's metadata.
|
|
60
|
-
*
|
|
61
|
-
* @returns The Powerlines context.
|
|
62
|
-
*/
|
|
63
|
-
function useMeta() {
|
|
64
|
-
const meta = useMetaSafe();
|
|
65
|
-
if (!meta) throw new Error("Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
66
|
-
return meta;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region ../deepkit/src/utilities.ts
|
|
71
|
-
/**
|
|
72
|
-
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
73
|
-
*
|
|
74
|
-
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
75
|
-
* @param value - The value to stringify.
|
|
76
|
-
* @returns A string representation of the value.
|
|
77
|
-
*/
|
|
78
|
-
function stringifyDefaultValue(property, value) {
|
|
79
|
-
return stringifyValue(property.type, value ?? property.getDefaultValue());
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Stringifies a value as a string.
|
|
83
|
-
*
|
|
84
|
-
* @param value - The value to stringify.
|
|
85
|
-
* @returns A string representation of the value.
|
|
86
|
-
*/
|
|
87
|
-
function stringifyStringValue(value) {
|
|
88
|
-
return `"${String(value).replaceAll("\"", "\\\"")}"`;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Converts any {@link Type}'s actual value to string representation.
|
|
92
|
-
*
|
|
93
|
-
* @param type - The {@link Type} of the value to stringify.
|
|
94
|
-
* @param value - The value to stringify.
|
|
95
|
-
* @returns A string representation of the value.
|
|
96
|
-
*/
|
|
97
|
-
function stringifyValue(type, value) {
|
|
98
|
-
return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type.kind === ReflectionKind.boolean ? String(value).trim().toLowerCase() === "true" ? "true" : "false" : type.kind === ReflectionKind.string || type.kind === ReflectionKind.literal && isString(type.literal) ? stringifyStringValue(value) : type.kind === ReflectionKind.enum ? getEnumReflectionType(type).kind === ReflectionKind.string ? stringifyStringValue(value) : `${String(value)}` : type.kind === ReflectionKind.union ? isStringUnion(type) ? stringifyStringValue(value) : `${String(value)}` : type.kind === ReflectionKind.array ? stringifyStringValue(StormJSON.stringify(value)) : type.kind === ReflectionKind.object || type.kind === ReflectionKind.objectLiteral ? StormJSON.stringify(value) : type.kind === ReflectionKind.property || type.kind === ReflectionKind.parameter ? stringifyValue(type.type, value) : String(value);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Converts a {@link TypeEnum} to its underlying primitive type representation.
|
|
102
|
-
*
|
|
103
|
-
* @param type - The {@link TypeEnum} to evaluate.
|
|
104
|
-
* @returns A string representation of the primitive type.
|
|
105
|
-
*/
|
|
106
|
-
function getEnumReflectionType(type) {
|
|
107
|
-
if (type.kind !== ReflectionKind.enum) throw new Error(`Expected a TypeEnum, but received ${type.kind}.`);
|
|
108
|
-
const unique = getUniqueBy(type.values.filter((value) => value !== void 0 && value !== null), (enumMember) => isString(enumMember) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number });
|
|
109
|
-
if (unique.length === 0) throw new Error(`No valid enum members could be found.`);
|
|
110
|
-
return unique[0] && isString(unique[0]) ? { kind: ReflectionKind.string } : { kind: ReflectionKind.number };
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Converts a {@link TypeUnion} to its underlying primitive type representation.
|
|
114
|
-
*
|
|
115
|
-
* @param type - The {@link TypeUnion} to evaluate.
|
|
116
|
-
* @returns A string representation of the primitive type.
|
|
117
|
-
*/
|
|
118
|
-
function getUnionTypes(type) {
|
|
119
|
-
if (type.kind === ReflectionKind.union && type.types.length > 0) return getUniqueBy(type.types, (member) => member.kind);
|
|
120
|
-
throw new Error(`Expected a TypeUnion, but received ${type.kind}.`);
|
|
121
|
-
}
|
|
122
|
-
function isStringUnion(type) {
|
|
123
|
-
return getUnionTypes(type).some((member) => member.kind === ReflectionKind.string || member.kind === ReflectionKind.literal && isString(member.literal));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region ../plugin-alloy/src/helpers/refkey.ts
|
|
128
|
-
/**
|
|
129
|
-
* 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.
|
|
130
|
-
*
|
|
131
|
-
* @remarks
|
|
132
|
-
* 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`
|
|
133
|
-
*/
|
|
134
|
-
function refkey$1(...args) {
|
|
135
|
-
return refkey("powerlines", ...args);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region ../plugin-alloy/src/typescript/components/tsdoc.tsx
|
|
140
|
-
/**
|
|
141
|
-
* Generates a TypeScript interface for the given reflection class.
|
|
142
|
-
*/
|
|
143
|
-
function TSDoc(props) {
|
|
144
|
-
const [{ children, heading }] = splitProps(props, ["children", "heading"]);
|
|
145
|
-
return [
|
|
146
|
-
"/**",
|
|
147
|
-
createIntrinsic("align", {
|
|
148
|
-
string: " * ",
|
|
149
|
-
get children() {
|
|
150
|
-
return [
|
|
151
|
-
createIntrinsic("hbr", {}),
|
|
152
|
-
createComponent(Show, {
|
|
153
|
-
get when() {
|
|
154
|
-
return !isUndefined(heading);
|
|
155
|
-
},
|
|
156
|
-
get children() {
|
|
157
|
-
return [
|
|
158
|
-
heading,
|
|
159
|
-
createIntrinsic("hbr", {}),
|
|
160
|
-
createComponent(Show, {
|
|
161
|
-
get when() {
|
|
162
|
-
return memo(() => !!!isUndefined(children))() && childrenArray(() => children).length > 0;
|
|
163
|
-
},
|
|
164
|
-
get children() {
|
|
165
|
-
return createIntrinsic("hbr", {});
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
}),
|
|
171
|
-
createComponent(Show, {
|
|
172
|
-
get when() {
|
|
173
|
-
return memo(() => !!!isUndefined(children))() && childrenArray(() => children).length > 0;
|
|
174
|
-
},
|
|
175
|
-
get children() {
|
|
176
|
-
return createComponent(List, { get children() {
|
|
177
|
-
return childrenArray(() => children);
|
|
178
|
-
} });
|
|
179
|
-
}
|
|
180
|
-
})
|
|
181
|
-
];
|
|
182
|
-
}
|
|
183
|
-
}),
|
|
184
|
-
createIntrinsic("hbr", {}),
|
|
185
|
-
` */`,
|
|
186
|
-
createIntrinsic("hbr", {})
|
|
187
|
-
];
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Create a TSDoc `@<props.tag>` tag.
|
|
191
|
-
*/
|
|
192
|
-
function TSDocTag(props) {
|
|
193
|
-
const [{ children, tag }] = splitProps(props, ["children", "tag"]);
|
|
194
|
-
return [
|
|
195
|
-
`@${tag} `,
|
|
196
|
-
createComponent(Show, {
|
|
197
|
-
get when() {
|
|
198
|
-
return Boolean(children);
|
|
199
|
-
},
|
|
200
|
-
get children() {
|
|
201
|
-
return createIntrinsic("align", {
|
|
202
|
-
width: 2,
|
|
203
|
-
get children() {
|
|
204
|
-
return createComponent(Prose, { children });
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}),
|
|
209
|
-
createIntrinsic("hbr", {})
|
|
210
|
-
];
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Create a TSDoc `@title` tag.
|
|
214
|
-
*/
|
|
215
|
-
function TSDocTitle(props) {
|
|
216
|
-
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
217
|
-
return createComponent(TSDocTag, mergeProps(rest, {
|
|
218
|
-
tag: "title",
|
|
219
|
-
children
|
|
220
|
-
}));
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Create a TSDoc `@domain` tag.
|
|
224
|
-
*/
|
|
225
|
-
function TSDocDomain(props) {
|
|
226
|
-
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
227
|
-
return createComponent(TSDocTag, mergeProps(rest, {
|
|
228
|
-
tag: "domain",
|
|
229
|
-
children
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Create a TSDoc `@alias` tag.
|
|
234
|
-
*/
|
|
235
|
-
function TSDocAlias(props) {
|
|
236
|
-
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
237
|
-
return createComponent(TSDocTag, mergeProps(rest, {
|
|
238
|
-
tag: "alias",
|
|
239
|
-
children
|
|
240
|
-
}));
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Create a TSDoc `@permission` tag.
|
|
244
|
-
*/
|
|
245
|
-
function TSDocPermission(props) {
|
|
246
|
-
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
247
|
-
return createComponent(TSDocTag, mergeProps(rest, {
|
|
248
|
-
tag: "permission",
|
|
249
|
-
children
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Create a TSDoc `@defaultValue` tag.
|
|
254
|
-
*/
|
|
255
|
-
function TSDocDefaultValue(props) {
|
|
256
|
-
return [
|
|
257
|
-
"@defaultValue ",
|
|
258
|
-
createComponent(Show, {
|
|
259
|
-
get when() {
|
|
260
|
-
return !isUndefined(props.value);
|
|
261
|
-
},
|
|
262
|
-
get children() {
|
|
263
|
-
return createIntrinsic("align", {
|
|
264
|
-
width: 2,
|
|
265
|
-
get children() {
|
|
266
|
-
return createComponent(Prose, { get children() {
|
|
267
|
-
return stringifyDefaultValue(props.value);
|
|
268
|
-
} });
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}),
|
|
273
|
-
createIntrinsic("hbr", {})
|
|
274
|
-
];
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Create a TSDoc `@remarks` tag.
|
|
278
|
-
*/
|
|
279
|
-
function TSDocRemarks(props) {
|
|
280
|
-
return [
|
|
281
|
-
"@remarks ",
|
|
282
|
-
createIntrinsic("hbr", {}),
|
|
283
|
-
createComponent(List, {
|
|
284
|
-
hardline: true,
|
|
285
|
-
get children() {
|
|
286
|
-
return childrenArray(() => props.children);
|
|
287
|
-
}
|
|
288
|
-
})
|
|
289
|
-
];
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Create a TSDoc `@see` tag.
|
|
293
|
-
*/
|
|
294
|
-
function TSDocLink(props) {
|
|
295
|
-
return createComponent(TSDocTag, mergeProps(props, { tag: "see" }));
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Create a TSDoc `@example` tag.
|
|
299
|
-
*/
|
|
300
|
-
function TSDocExample(props) {
|
|
301
|
-
const [{ tsx, fenced = true, language, children }] = splitProps(props, [
|
|
302
|
-
"tsx",
|
|
303
|
-
"fenced",
|
|
304
|
-
"language",
|
|
305
|
-
"children"
|
|
306
|
-
]);
|
|
307
|
-
return [
|
|
308
|
-
"@example ",
|
|
309
|
-
createIntrinsic("hbr", {}),
|
|
310
|
-
createComponent(Show, {
|
|
311
|
-
when: fenced,
|
|
312
|
-
get children() {
|
|
313
|
-
return [
|
|
314
|
-
"```",
|
|
315
|
-
language || (tsx ? "tsx" : "ts"),
|
|
316
|
-
createIntrinsic("hbr", {})
|
|
317
|
-
];
|
|
318
|
-
}
|
|
319
|
-
}),
|
|
320
|
-
children,
|
|
321
|
-
createComponent(Show, {
|
|
322
|
-
when: fenced,
|
|
323
|
-
get children() {
|
|
324
|
-
return [createIntrinsic("hbr", {}), "```"];
|
|
325
|
-
}
|
|
326
|
-
})
|
|
327
|
-
];
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Create a TSDoc `@readonly` tag.
|
|
331
|
-
*/
|
|
332
|
-
function TSDocReadonly() {
|
|
333
|
-
return createComponent(TSDocTag, { tag: "readonly" });
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Create a TSDoc `@internal` tag.
|
|
337
|
-
*/
|
|
338
|
-
function TSDocInternal() {
|
|
339
|
-
return createComponent(TSDocTag, { tag: "internal" });
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Create a TSDoc `@ignore` tag.
|
|
343
|
-
*/
|
|
344
|
-
function TSDocIgnore() {
|
|
345
|
-
return createComponent(TSDocTag, { tag: "ignore" });
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Create a TSDoc `@hidden` tag.
|
|
349
|
-
*/
|
|
350
|
-
function TSDocHidden() {
|
|
351
|
-
return createComponent(TSDocTag, { tag: "hidden" });
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Generates a TypeScript interface property for the given reflection class.
|
|
355
|
-
*/
|
|
356
|
-
function TSDocAttributesTags(props) {
|
|
357
|
-
const [{ title, alias, permission, domain, readonly, internal, ignore, hidden, defaultValue }] = splitProps(props, [
|
|
358
|
-
"title",
|
|
359
|
-
"alias",
|
|
360
|
-
"permission",
|
|
361
|
-
"domain",
|
|
362
|
-
"readonly",
|
|
363
|
-
"internal",
|
|
364
|
-
"ignore",
|
|
365
|
-
"hidden",
|
|
366
|
-
"defaultValue"
|
|
367
|
-
]);
|
|
368
|
-
return [
|
|
369
|
-
createComponent(Show, {
|
|
370
|
-
get when() {
|
|
371
|
-
return isSetString(title);
|
|
372
|
-
},
|
|
373
|
-
get children() {
|
|
374
|
-
return createComponent(TSDocTitle, { children: title });
|
|
375
|
-
}
|
|
376
|
-
}),
|
|
377
|
-
createComponent(Show, {
|
|
378
|
-
get when() {
|
|
379
|
-
return !isUndefined(alias) && alias.length > 0;
|
|
380
|
-
},
|
|
381
|
-
get children() {
|
|
382
|
-
return createComponent(For, {
|
|
383
|
-
each: alias ?? [],
|
|
384
|
-
children: (alias$1) => createComponent(TSDocAlias, { children: alias$1 })
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
}),
|
|
388
|
-
createComponent(Show, {
|
|
389
|
-
get when() {
|
|
390
|
-
return isSetString(domain);
|
|
391
|
-
},
|
|
392
|
-
get children() {
|
|
393
|
-
return createComponent(TSDocDomain, { children: domain });
|
|
394
|
-
}
|
|
395
|
-
}),
|
|
396
|
-
createComponent(Show, {
|
|
397
|
-
get when() {
|
|
398
|
-
return !isUndefined(permission) && permission.length > 0;
|
|
399
|
-
},
|
|
400
|
-
get children() {
|
|
401
|
-
return createComponent(For, {
|
|
402
|
-
each: permission ?? [],
|
|
403
|
-
children: (permission$1) => createComponent(TSDocPermission, { children: permission$1 })
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}),
|
|
407
|
-
createComponent(Show, {
|
|
408
|
-
when: readonly === true,
|
|
409
|
-
get children() {
|
|
410
|
-
return createComponent(TSDocReadonly, {});
|
|
411
|
-
}
|
|
412
|
-
}),
|
|
413
|
-
createComponent(Show, {
|
|
414
|
-
when: internal === true,
|
|
415
|
-
get children() {
|
|
416
|
-
return createComponent(TSDocInternal, {});
|
|
417
|
-
}
|
|
418
|
-
}),
|
|
419
|
-
createComponent(Show, {
|
|
420
|
-
when: ignore === true,
|
|
421
|
-
get children() {
|
|
422
|
-
return createComponent(TSDocIgnore, {});
|
|
423
|
-
}
|
|
424
|
-
}),
|
|
425
|
-
createComponent(Show, {
|
|
426
|
-
when: hidden === true,
|
|
427
|
-
get children() {
|
|
428
|
-
return createComponent(TSDocHidden, {});
|
|
429
|
-
}
|
|
430
|
-
}),
|
|
431
|
-
createComponent(Show, {
|
|
432
|
-
get when() {
|
|
433
|
-
return !isUndefined(defaultValue);
|
|
434
|
-
},
|
|
435
|
-
get children() {
|
|
436
|
-
return createComponent(TSDocDefaultValue, { value: defaultValue });
|
|
437
|
-
}
|
|
438
|
-
})
|
|
439
|
-
];
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Create a TSDoc parameter set off with `@param`.
|
|
443
|
-
*/
|
|
444
|
-
function TSDocParam(props) {
|
|
445
|
-
return [
|
|
446
|
-
"@param ",
|
|
447
|
-
createComponent(TSDocParamName, {
|
|
448
|
-
get name() {
|
|
449
|
-
return props.name;
|
|
450
|
-
},
|
|
451
|
-
get optional() {
|
|
452
|
-
return props.optional;
|
|
453
|
-
},
|
|
454
|
-
get defaultValue() {
|
|
455
|
-
return props.defaultValue;
|
|
456
|
-
}
|
|
457
|
-
}),
|
|
458
|
-
createComponent(TSDocParamDescription, { get children() {
|
|
459
|
-
return props.children;
|
|
460
|
-
} })
|
|
461
|
-
];
|
|
462
|
-
}
|
|
463
|
-
function TSDocParamName(props) {
|
|
464
|
-
return [
|
|
465
|
-
createComponent(Show, {
|
|
466
|
-
get when() {
|
|
467
|
-
return props.optional;
|
|
468
|
-
},
|
|
469
|
-
children: "["
|
|
470
|
-
}),
|
|
471
|
-
memo(() => props.name),
|
|
472
|
-
createComponent(Show, {
|
|
473
|
-
get when() {
|
|
474
|
-
return Boolean(props.defaultValue);
|
|
475
|
-
},
|
|
476
|
-
get children() {
|
|
477
|
-
return ["=", memo(() => props.defaultValue)];
|
|
478
|
-
}
|
|
479
|
-
}),
|
|
480
|
-
createComponent(Show, {
|
|
481
|
-
get when() {
|
|
482
|
-
return props.optional;
|
|
483
|
-
},
|
|
484
|
-
children: "]"
|
|
485
|
-
})
|
|
486
|
-
];
|
|
487
|
-
}
|
|
488
|
-
function TSDocParamDescription(props) {
|
|
489
|
-
return createComponent(Show, {
|
|
490
|
-
get when() {
|
|
491
|
-
return Boolean(props.children);
|
|
492
|
-
},
|
|
493
|
-
get children() {
|
|
494
|
-
return [" - ", createIntrinsic("align", {
|
|
495
|
-
width: 2,
|
|
496
|
-
get children() {
|
|
497
|
-
return createComponent(Prose, { get children() {
|
|
498
|
-
return props.children;
|
|
499
|
-
} });
|
|
500
|
-
}
|
|
501
|
-
})];
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Create a TSDoc `@returns` tag.
|
|
507
|
-
*/
|
|
508
|
-
function TSDocReturns(props) {
|
|
509
|
-
return createComponent(TSDocTag, mergeProps(props, { tag: "returns" }));
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Create a TSDoc `@throws` tag.
|
|
513
|
-
*/
|
|
514
|
-
function TSDocThrows(props) {
|
|
515
|
-
return createComponent(TSDocTag, mergeProps(props, { tag: "throws" }));
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Generates a TSDoc `@module` tag for the given module name.
|
|
519
|
-
*/
|
|
520
|
-
function TSDocModule(props) {
|
|
521
|
-
const [{ children, name, prefix }] = splitProps(props, [
|
|
522
|
-
"children",
|
|
523
|
-
"name",
|
|
524
|
-
"prefix"
|
|
525
|
-
]);
|
|
526
|
-
const context = usePowerlines();
|
|
527
|
-
return [
|
|
528
|
-
"/**",
|
|
529
|
-
createIntrinsic("align", {
|
|
530
|
-
string: " * ",
|
|
531
|
-
get children() {
|
|
532
|
-
return [
|
|
533
|
-
createIntrinsic("hbr", {}),
|
|
534
|
-
createComponent(Show, {
|
|
535
|
-
get when() {
|
|
536
|
-
return Boolean(children);
|
|
537
|
-
},
|
|
538
|
-
get children() {
|
|
539
|
-
return [
|
|
540
|
-
createComponent(List, {
|
|
541
|
-
hardline: true,
|
|
542
|
-
get children() {
|
|
543
|
-
return childrenArray(() => children);
|
|
544
|
-
}
|
|
545
|
-
}),
|
|
546
|
-
createIntrinsic("hbr", {}),
|
|
547
|
-
createIntrinsic("hbr", {})
|
|
548
|
-
];
|
|
549
|
-
}
|
|
550
|
-
}),
|
|
551
|
-
"@module ",
|
|
552
|
-
memo(() => prefix || context?.config.output.builtinPrefix),
|
|
553
|
-
":",
|
|
554
|
-
name
|
|
555
|
-
];
|
|
556
|
-
}
|
|
557
|
-
}),
|
|
558
|
-
createIntrinsic("hbr", {}),
|
|
559
|
-
` */`
|
|
560
|
-
];
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
//#endregion
|
|
564
|
-
//#region ../plugin-alloy/src/core/components/single-line-comment.tsx
|
|
565
|
-
/**
|
|
566
|
-
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
567
|
-
* are broken into multiple lines
|
|
568
|
-
*/
|
|
569
|
-
function SingleLineComment(props) {
|
|
570
|
-
const { variant = "double-slash", children } = props;
|
|
571
|
-
const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
|
|
572
|
-
return [commentStart, createIntrinsic("align", {
|
|
573
|
-
string: commentStart,
|
|
574
|
-
get children() {
|
|
575
|
-
return [createComponent(Prose, { children }), variant === "slash-star" || variant === "slash-star-star" ? " */ " : variant === "markdown" ? " -->" : ""];
|
|
576
|
-
}
|
|
577
|
-
})];
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
//#endregion
|
|
581
|
-
//#region ../plugin-alloy/src/core/contexts/reflection.ts
|
|
582
|
-
/**
|
|
583
|
-
* The reflection class context used in template rendering.
|
|
584
|
-
*/
|
|
585
|
-
const ReflectionClassContext = createContext();
|
|
586
|
-
/**
|
|
587
|
-
* Hook to access the Reflection context.
|
|
588
|
-
*
|
|
589
|
-
* @returns A reactive version of the current reflection.
|
|
590
|
-
*/
|
|
591
|
-
function useReflectionClass() {
|
|
592
|
-
const context = useContext(ReflectionClassContext);
|
|
593
|
-
if (!context) throw new Error("Powerlines - ReflectionClass Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
594
|
-
return context;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* The reflection property context used in template rendering.
|
|
598
|
-
*/
|
|
599
|
-
const ReflectionPropertyContext = createNamedContext("reflection-property");
|
|
600
|
-
/**
|
|
601
|
-
* Hook to access the Reflection Property context.
|
|
602
|
-
*
|
|
603
|
-
* @returns A reactive version of the current reflection.
|
|
604
|
-
*/
|
|
605
|
-
function useReflectionProperty() {
|
|
606
|
-
const context = useContext(ReflectionPropertyContext);
|
|
607
|
-
if (!context) throw new Error("Powerlines - Reflection Property Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
|
|
608
|
-
return context;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* The reflection method context used in template rendering.
|
|
612
|
-
*/
|
|
613
|
-
const ReflectionMethodContext = createNamedContext("reflection-method");
|
|
614
|
-
/**
|
|
615
|
-
* The reflection parameter context used in template rendering.
|
|
616
|
-
*/
|
|
617
|
-
const ReflectionParameterContext = createNamedContext("reflection-parameter");
|
|
618
|
-
|
|
619
|
-
//#endregion
|
|
620
|
-
//#region ../plugin-alloy/src/core/components/source-file.tsx
|
|
621
|
-
/**
|
|
622
|
-
* A base component representing a Powerlines generated source file.
|
|
623
|
-
*
|
|
624
|
-
* @param props - The properties for the source file.
|
|
625
|
-
* @returns The rendered source file component.
|
|
626
|
-
*/
|
|
627
|
-
function SourceFile(props) {
|
|
628
|
-
const [{ children, meta, path, header, storage, filetype, reference }] = splitProps(props, [
|
|
629
|
-
"children",
|
|
630
|
-
"meta",
|
|
631
|
-
"path",
|
|
632
|
-
"header",
|
|
633
|
-
"storage",
|
|
634
|
-
"filetype",
|
|
635
|
-
"reference"
|
|
636
|
-
]);
|
|
637
|
-
const metadata = useMeta();
|
|
638
|
-
const parentDirectory = useContext(SourceDirectoryContext);
|
|
639
|
-
const sourceFile = {
|
|
640
|
-
path: appendPath(path, parentDirectory.path),
|
|
641
|
-
filetype,
|
|
642
|
-
reference
|
|
643
|
-
};
|
|
644
|
-
parentDirectory?.addContent(sourceFile);
|
|
645
|
-
const printOptions = useFormatOptions({
|
|
646
|
-
printWidth: props.printWidth,
|
|
647
|
-
tabWidth: props.tabWidth,
|
|
648
|
-
useTabs: props.useTabs,
|
|
649
|
-
insertFinalNewLine: props.insertFinalNewLine
|
|
650
|
-
});
|
|
651
|
-
const nodeContext = getContext();
|
|
652
|
-
nodeContext.meta = defu({
|
|
653
|
-
sourceFile,
|
|
654
|
-
printOptions
|
|
655
|
-
}, meta ?? {});
|
|
656
|
-
metadata[sourceFile.path] = {
|
|
657
|
-
storage,
|
|
658
|
-
...meta ?? {}
|
|
659
|
-
};
|
|
660
|
-
return createComponent(SourceFileContext.Provider, {
|
|
661
|
-
value: sourceFile,
|
|
662
|
-
get children() {
|
|
663
|
-
return [createComponent(Show, {
|
|
664
|
-
when: header !== void 0,
|
|
665
|
-
get children() {
|
|
666
|
-
return [header, createIntrinsic("hbr", {})];
|
|
667
|
-
}
|
|
668
|
-
}), children];
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
|
|
675
|
-
/**
|
|
676
|
-
* A base component representing a Powerlines generated Typescript source file.
|
|
677
|
-
*
|
|
678
|
-
* @param props - The properties for the source file.
|
|
679
|
-
* @returns The rendered source file component.
|
|
680
|
-
*/
|
|
681
|
-
function TypescriptFile(props) {
|
|
682
|
-
const [{ children, path, imports, tsx, header, hashbang }, rest] = splitProps(props, [
|
|
683
|
-
"children",
|
|
684
|
-
"path",
|
|
685
|
-
"imports",
|
|
686
|
-
"tsx",
|
|
687
|
-
"header",
|
|
688
|
-
"hashbang"
|
|
689
|
-
]);
|
|
690
|
-
const directoryContext = useContext(SourceDirectoryContext);
|
|
691
|
-
const sdData = getSourceDirectoryData(directoryContext);
|
|
692
|
-
const modulePath = appendPath(path, directoryContext.path);
|
|
693
|
-
const scope = new TSModuleScope(modulePath, useScope());
|
|
694
|
-
sdData.modules.add(scope);
|
|
695
|
-
const pkg = useContext(PackageContext);
|
|
696
|
-
if (pkg) pkg.scope.addModule(scope);
|
|
697
|
-
if (props.export) {
|
|
698
|
-
if (pkg) if (isBoolean(props.export)) pkg.scope.addExport(modulePath, scope);
|
|
699
|
-
else pkg.scope.addExport(props.export, scope);
|
|
700
|
-
}
|
|
701
|
-
return createComponent(SourceFileContext$1.Provider, {
|
|
702
|
-
value: { scope },
|
|
703
|
-
get children() {
|
|
704
|
-
return createComponent(Scope, {
|
|
705
|
-
value: scope,
|
|
706
|
-
get children() {
|
|
707
|
-
return createComponent(SourceFile, mergeProps(rest, {
|
|
708
|
-
path: modulePath,
|
|
709
|
-
get header() {
|
|
710
|
-
return header ?? createComponent(TypescriptFileHeader, {
|
|
711
|
-
hashbang,
|
|
712
|
-
get children() {
|
|
713
|
-
return createComponent(TypescriptFileHeaderImports, {
|
|
714
|
-
imports,
|
|
715
|
-
scope
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
},
|
|
720
|
-
filetype: tsx ? "tsx" : "typescript",
|
|
721
|
-
children
|
|
722
|
-
}));
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
730
|
-
*
|
|
731
|
-
* @param props - The properties for the source file header.
|
|
732
|
-
* @returns The rendered source file header.
|
|
733
|
-
*/
|
|
734
|
-
function TypescriptFileHeader(props) {
|
|
735
|
-
const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
|
|
736
|
-
const context = usePowerlines();
|
|
737
|
-
return [
|
|
738
|
-
createComponent(Show, {
|
|
739
|
-
get when() {
|
|
740
|
-
return Boolean(hashbang);
|
|
741
|
-
},
|
|
742
|
-
get children() {
|
|
743
|
-
return [memo(() => hashbang === true ? code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang), createIntrinsic("hbr", {})];
|
|
744
|
-
}
|
|
745
|
-
}),
|
|
746
|
-
createComponent(Show, {
|
|
747
|
-
get when() {
|
|
748
|
-
return Boolean(header);
|
|
749
|
-
},
|
|
750
|
-
get children() {
|
|
751
|
-
return [header, createIntrinsic("hbr", {})];
|
|
752
|
-
}
|
|
753
|
-
}),
|
|
754
|
-
createIntrinsic("hbr", {}),
|
|
755
|
-
createComponent(Show, {
|
|
756
|
-
get when() {
|
|
757
|
-
return Boolean(disableEslint);
|
|
758
|
-
},
|
|
759
|
-
get children() {
|
|
760
|
-
return [createComponent(SingleLineComment, {
|
|
761
|
-
variant: "slash-star",
|
|
762
|
-
children: "eslint-disable"
|
|
763
|
-
}), createIntrinsic("hbr", {})];
|
|
764
|
-
}
|
|
765
|
-
}),
|
|
766
|
-
createComponent(Show, {
|
|
767
|
-
get when() {
|
|
768
|
-
return Boolean(disablePrettier);
|
|
769
|
-
},
|
|
770
|
-
get children() {
|
|
771
|
-
return [createComponent(SingleLineComment, {
|
|
772
|
-
variant: "slash-star",
|
|
773
|
-
children: "prettier-ignore"
|
|
774
|
-
}), createIntrinsic("hbr", {})];
|
|
775
|
-
}
|
|
776
|
-
}),
|
|
777
|
-
createComponent(Show, {
|
|
778
|
-
get when() {
|
|
779
|
-
return Boolean(disableBiome);
|
|
780
|
-
},
|
|
781
|
-
get children() {
|
|
782
|
-
return [createComponent(SingleLineComment, { children: "biome-ignore lint: disable" }), createIntrinsic("hbr", {})];
|
|
783
|
-
}
|
|
784
|
-
}),
|
|
785
|
-
createComponent(Show, {
|
|
786
|
-
get when() {
|
|
787
|
-
return Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome);
|
|
788
|
-
},
|
|
789
|
-
get children() {
|
|
790
|
-
return createIntrinsic("hbr", {});
|
|
791
|
-
}
|
|
792
|
-
}),
|
|
793
|
-
createComponent(Show, {
|
|
794
|
-
get when() {
|
|
795
|
-
return Boolean(children);
|
|
796
|
-
},
|
|
797
|
-
get children() {
|
|
798
|
-
return [children, createIntrinsic("hbr", {})];
|
|
799
|
-
}
|
|
800
|
-
}),
|
|
801
|
-
createComponent(SingleLineComment, { get children() {
|
|
802
|
-
return code`Generated by ${titleCase(context?.config.framework) || "Powerlines"}`;
|
|
803
|
-
} }),
|
|
804
|
-
createIntrinsic("hbr", {}),
|
|
805
|
-
createComponent(SingleLineComment, { children: code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
|
|
806
|
-
createIntrinsic("hbr", {})
|
|
807
|
-
];
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* Renders the header for a Powerlines Typescript source file.
|
|
811
|
-
*
|
|
812
|
-
* @param props - The properties for the source file header.
|
|
813
|
-
* @returns The rendered source file header.
|
|
814
|
-
*/
|
|
815
|
-
function TypescriptFileHeaderImports(props) {
|
|
816
|
-
const { imports } = props;
|
|
817
|
-
const context = usePowerlines();
|
|
818
|
-
const sourceFile = useSourceFile();
|
|
819
|
-
const scope = props.scope ?? sourceFile.scope;
|
|
820
|
-
return createComponent(Show, {
|
|
821
|
-
get when() {
|
|
822
|
-
return scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0;
|
|
823
|
-
},
|
|
824
|
-
get children() {
|
|
825
|
-
return [
|
|
826
|
-
createComponent(Show, {
|
|
827
|
-
get when() {
|
|
828
|
-
return !!imports && Object.keys(imports).length > 0;
|
|
829
|
-
},
|
|
830
|
-
get children() {
|
|
831
|
-
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, imported]) => {
|
|
832
|
-
return code`import ${imported === null ? "" : imported.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !isString(i) && i.default).length > 0 && imported.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${imported.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module}";`;
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
}),
|
|
836
|
-
createComponent(Show, {
|
|
837
|
-
get when() {
|
|
838
|
-
return scope.importedModules.size > 0;
|
|
839
|
-
},
|
|
840
|
-
get children() {
|
|
841
|
-
return createComponent(ImportStatements, { get records() {
|
|
842
|
-
return scope.importedModules;
|
|
843
|
-
} });
|
|
844
|
-
}
|
|
845
|
-
}),
|
|
846
|
-
createIntrinsic("hbr", {})
|
|
847
|
-
];
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region ../plugin-alloy/src/typescript/components/builtin-file.tsx
|
|
854
|
-
/**
|
|
855
|
-
* A base component representing a Powerlines generated Typescript source file.
|
|
856
|
-
*
|
|
857
|
-
* @param props - The properties for the source file.
|
|
858
|
-
* @returns The rendered source file component.
|
|
859
|
-
*/
|
|
860
|
-
function BuiltinFile(props) {
|
|
861
|
-
const [{ children, imports, id, description, tsx }, rest] = splitProps(props, [
|
|
862
|
-
"children",
|
|
863
|
-
"imports",
|
|
864
|
-
"id",
|
|
865
|
-
"description",
|
|
866
|
-
"tsx"
|
|
867
|
-
]);
|
|
868
|
-
const context = usePowerlines();
|
|
869
|
-
const path = computed(() => replacePath(`${!isSet(tsx) ? id : replaceExtension(id)}${hasFileExtension(id) && !isSet(tsx) ? "" : tsx ? ".tsx" : ".ts"}`, context.builtinsPath));
|
|
870
|
-
return createComponent(TypescriptFile, mergeProps({
|
|
871
|
-
get header() {
|
|
872
|
-
return createComponent(TypescriptFileHeader, {
|
|
873
|
-
get header() {
|
|
874
|
-
return createComponent(TSDocModule, {
|
|
875
|
-
name: id,
|
|
876
|
-
children: description
|
|
877
|
-
});
|
|
878
|
-
},
|
|
879
|
-
get children() {
|
|
880
|
-
return createComponent(TypescriptFileHeaderImports, { imports });
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
},
|
|
884
|
-
get meta() {
|
|
885
|
-
return {
|
|
886
|
-
kind: "builtin",
|
|
887
|
-
id: replaceExtension(id)
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
}, rest, {
|
|
891
|
-
get path() {
|
|
892
|
-
return path.value;
|
|
893
|
-
},
|
|
894
|
-
children
|
|
895
|
-
}));
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
//#endregion
|
|
899
|
-
//#region src/components/react-optimized.tsx
|
|
900
|
-
const isOptimizationEnabledRefkey = refkey$1("isOptimizationEnabled");
|
|
901
|
-
/**
|
|
902
|
-
* Generates the `react/optimized` builtin module for the Powerlines project.
|
|
903
|
-
*/
|
|
904
|
-
function ReactOptimizedBuiltin(props) {
|
|
905
|
-
const [{ override }, rest] = splitProps(props, ["override"]);
|
|
906
|
-
return createComponent(BuiltinFile, mergeProps(rest, {
|
|
907
|
-
id: "react/optimized",
|
|
908
|
-
description: "A built-in module to provide access to environment configuration to determine React optimizations.",
|
|
909
|
-
get imports() {
|
|
910
|
-
return defu({ $builtins: { env: ["env", "isDevelopment"] } }, rest.imports ?? {});
|
|
911
|
-
},
|
|
912
|
-
get children() {
|
|
913
|
-
return [createComponent(TSDoc, {
|
|
914
|
-
heading: "A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.",
|
|
915
|
-
get children() {
|
|
916
|
-
return [createComponent(TSDocLink, { children: `https://react.dev/reference/react-compiler/gating` }), createComponent(TSDocReturns, { children: `A boolean indicating if the React compiler's optimizations should be used.` })];
|
|
917
|
-
}
|
|
918
|
-
}), createComponent(FunctionDeclaration, {
|
|
919
|
-
refkey: isOptimizationEnabledRefkey,
|
|
920
|
-
async: false,
|
|
921
|
-
"export": true,
|
|
922
|
-
name: "isOptimizationEnabled",
|
|
923
|
-
returnType: "boolean",
|
|
924
|
-
get children() {
|
|
925
|
-
return [createComponent(Show, {
|
|
926
|
-
when: override !== void 0,
|
|
927
|
-
fallback: code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `,
|
|
928
|
-
children: code`return ${override};`
|
|
929
|
-
}), createIntrinsic("hbr", {})];
|
|
930
|
-
}
|
|
931
|
-
})];
|
|
932
|
-
}
|
|
933
|
-
}));
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
//#endregion
|
|
937
|
-
export { PowerlinesContext as _, useReflectionClass as a, TSDocAttributesTags as c, TSDocParam as d, TSDocRemarks as f, stringifyDefaultValue as g, refkey$1 as h, ReflectionPropertyContext as i, TSDocExample as l, TSDocThrows as m, BuiltinFile as n, useReflectionProperty as o, TSDocReturns as p, ReflectionClassContext as r, TSDoc as s, ReactOptimizedBuiltin as t, TSDocLink as u, usePowerlines as v };
|