@powerlines/plugin-alloy 0.25.33 → 0.25.35
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/README.md +1 -1
- package/dist/core/components/output.cjs +17 -10
- package/dist/core/components/output.mjs +17 -10
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +6 -4
- package/dist/core/components/single-line-comment.mjs +6 -4
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +10 -6
- package/dist/core/components/source-file.mjs +10 -6
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +6 -4
- package/dist/core/components/spacing.mjs +6 -4
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/index.cjs +13 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +12 -17
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +9 -7
- package/dist/markdown/components/front-matter.mjs +9 -7
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/markdown-file.cjs +76 -44
- package/dist/markdown/components/markdown-file.mjs +76 -44
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +49 -28
- package/dist/markdown/components/markdown-table.mjs +49 -28
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/render.cjs +3 -3
- package/dist/render.mjs +4 -4
- package/dist/render.mjs.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +29 -19
- package/dist/typescript/components/builtin-file.mjs +30 -20
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +165 -100
- package/dist/typescript/components/class-declaration.mjs +165 -100
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +2 -6
- package/dist/typescript/components/dynamic-import-statement.mjs +2 -6
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +9 -6
- package/dist/typescript/components/entry-file.mjs +10 -7
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/infrastructure-file.cjs +9 -6
- package/dist/typescript/components/infrastructure-file.mjs +10 -7
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +121 -70
- package/dist/typescript/components/interface-declaration.mjs +121 -70
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +76 -44
- package/dist/typescript/components/object-declaration.mjs +76 -44
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +3 -3
- package/dist/typescript/components/property-name.mjs +3 -3
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +225 -104
- package/dist/typescript/components/tsdoc-reflection.mjs +225 -104
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +255 -160
- package/dist/typescript/components/tsdoc.mjs +255 -160
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +20 -15
- package/dist/typescript/components/type-declaration.mjs +20 -15
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +55 -29
- package/dist/typescript/components/type-parameters.mjs +55 -29
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +145 -80
- package/dist/typescript/components/typescript-file.mjs +145 -80
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/lexical-scope.cjs +5 -3
- package/dist/typescript/contexts/lexical-scope.mjs +5 -3
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +5 -3
- package/dist/typescript/contexts/member-scope.mjs +5 -3
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/yaml/components/yaml-file.cjs +92 -47
- package/dist/yaml/components/yaml-file.mjs +92 -47
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/package.json +16 -17
|
@@ -6,8 +6,8 @@ import { getCallSignatureProps } from "../helpers/get-call-signature-props.mjs";
|
|
|
6
6
|
import "../helpers/index.mjs";
|
|
7
7
|
import { PropertyName } from "./property-name.mjs";
|
|
8
8
|
import { TypeParameters } from "./type-parameters.mjs";
|
|
9
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
9
10
|
import { Block, For, MemberDeclaration, Name, Show, code, splitProps } from "@alloy-js/core";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
11
11
|
import { CallSignature, Declaration as Declaration$1, TSSymbolFlags, TypeRefContext, createMemberSymbol, createTypeAndValueSymbol, useTSNamePolicy } from "@alloy-js/typescript";
|
|
12
12
|
|
|
13
13
|
//#region src/typescript/components/class-declaration.tsx
|
|
@@ -42,18 +42,20 @@ import { CallSignature, Declaration as Declaration$1, TSSymbolFlags, TypeRefCont
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
function ClassDeclaration(props) {
|
|
45
|
-
const extendsPart = props.extends &&
|
|
46
|
-
const implementsPart = props.implements && props.implements.length > 0 &&
|
|
45
|
+
const extendsPart = props.extends && [" extends ", memo(() => props.extends)];
|
|
46
|
+
const implementsPart = props.implements && props.implements.length > 0 && [
|
|
47
47
|
" ",
|
|
48
48
|
"implements",
|
|
49
49
|
" ",
|
|
50
|
-
|
|
51
|
-
each
|
|
50
|
+
createComponent(For, {
|
|
51
|
+
get each() {
|
|
52
|
+
return props.implements;
|
|
53
|
+
},
|
|
52
54
|
comma: true,
|
|
53
55
|
space: true,
|
|
54
56
|
children: (implement) => implement
|
|
55
57
|
})
|
|
56
|
-
]
|
|
58
|
+
];
|
|
57
59
|
const sym = createTypeAndValueSymbol(props.name, {
|
|
58
60
|
refkeys: props.refkey,
|
|
59
61
|
export: props.export,
|
|
@@ -62,27 +64,45 @@ function ClassDeclaration(props) {
|
|
|
62
64
|
hasInstanceMembers: true,
|
|
63
65
|
namePolicy: useTSNamePolicy().for("class")
|
|
64
66
|
});
|
|
65
|
-
return
|
|
66
|
-
when
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
return [createComponent(Show, {
|
|
68
|
+
get when() {
|
|
69
|
+
return Boolean(props.doc);
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return createComponent(TSDoc, { get heading() {
|
|
73
|
+
return props.doc;
|
|
74
|
+
} });
|
|
75
|
+
}
|
|
76
|
+
}), createComponent(Declaration$1, {
|
|
69
77
|
symbol: sym,
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
get ["export"]() {
|
|
79
|
+
return props.export;
|
|
80
|
+
},
|
|
81
|
+
get ["default"]() {
|
|
82
|
+
return props.default;
|
|
83
|
+
},
|
|
84
|
+
get children() {
|
|
85
|
+
return createComponent(MemberScope$1, {
|
|
86
|
+
ownerSymbol: sym,
|
|
87
|
+
get children() {
|
|
88
|
+
return [
|
|
89
|
+
memo(() => props.abstract && code`abstract `),
|
|
90
|
+
" class ",
|
|
91
|
+
createComponent(Name, {}),
|
|
92
|
+
memo(() => memo(() => !!props.typeParameters)() && createComponent(TypeParameters, { get parameters() {
|
|
93
|
+
return props.typeParameters;
|
|
94
|
+
} })),
|
|
95
|
+
extendsPart,
|
|
96
|
+
implementsPart,
|
|
97
|
+
" ",
|
|
98
|
+
createComponent(Block, { get children() {
|
|
99
|
+
return props.children;
|
|
100
|
+
} })
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
})];
|
|
86
106
|
}
|
|
87
107
|
ClassDeclaration.TypeParameters = TypeParameters;
|
|
88
108
|
/**
|
|
@@ -99,21 +119,29 @@ function ClassMember(props) {
|
|
|
99
119
|
tsFlags,
|
|
100
120
|
namePolicy: useTSNamePolicy().for("class-member-data")
|
|
101
121
|
});
|
|
102
|
-
return
|
|
103
|
-
when
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
return [createComponent(Show, {
|
|
123
|
+
get when() {
|
|
124
|
+
return Boolean(props.doc);
|
|
125
|
+
},
|
|
126
|
+
get children() {
|
|
127
|
+
return createComponent(TSDoc, { get heading() {
|
|
128
|
+
return props.doc;
|
|
129
|
+
} });
|
|
130
|
+
}
|
|
131
|
+
}), createComponent(MemberDeclaration, {
|
|
106
132
|
symbol: sym,
|
|
107
|
-
children
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
133
|
+
get children() {
|
|
134
|
+
return [
|
|
135
|
+
memo(() => props.public && "public "),
|
|
136
|
+
memo(() => props.private && "private "),
|
|
137
|
+
memo(() => props.protected && "protected "),
|
|
138
|
+
memo(() => props.abstract && "abstract "),
|
|
139
|
+
memo(() => props.override && "override "),
|
|
140
|
+
memo(() => props.static && "static "),
|
|
141
|
+
memo(() => props.children)
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
})];
|
|
117
145
|
}
|
|
118
146
|
/**
|
|
119
147
|
* Generates a TypeScript class field declaration for the given reflection class.
|
|
@@ -123,25 +151,31 @@ function ClassMember(props) {
|
|
|
123
151
|
*/
|
|
124
152
|
function ClassField(props) {
|
|
125
153
|
const optionality = props.optional ? "?" : "";
|
|
126
|
-
const typeSection = props.type &&
|
|
154
|
+
const typeSection = props.type && [
|
|
127
155
|
optionality,
|
|
128
156
|
": ",
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
nullish,
|
|
136
|
-
children
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
createComponent(TypeRefContext, { get children() {
|
|
158
|
+
return props.type;
|
|
159
|
+
} })
|
|
160
|
+
];
|
|
161
|
+
const initializerSection = props.children && [" = ", memo(() => props.children)];
|
|
162
|
+
return createComponent(ClassMember, mergeProps(props, {
|
|
163
|
+
nullish: props.nullish ?? props.optional,
|
|
164
|
+
get children() {
|
|
165
|
+
return [
|
|
166
|
+
createComponent(PropertyName, {
|
|
167
|
+
get ["private"]() {
|
|
168
|
+
return props.isPrivateMember;
|
|
169
|
+
},
|
|
170
|
+
get name() {
|
|
171
|
+
return props.isPrivateMember ? props.name : void 0;
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
typeSection,
|
|
175
|
+
initializerSection
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
145
179
|
}
|
|
146
180
|
/**
|
|
147
181
|
* Generates a TypeScript class property setter declaration for the given reflection class.
|
|
@@ -150,21 +184,30 @@ function ClassField(props) {
|
|
|
150
184
|
* @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.
|
|
151
185
|
*/
|
|
152
186
|
function ClassPropertySet(props) {
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
children: [
|
|
187
|
+
return [createComponent(ClassMember, mergeProps(props, { get children() {
|
|
188
|
+
return [
|
|
156
189
|
"set ",
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
190
|
+
createComponent(PropertyName, { get name() {
|
|
191
|
+
return props.name;
|
|
192
|
+
} }),
|
|
193
|
+
createComponent(LexicalScope, { get children() {
|
|
194
|
+
return [
|
|
195
|
+
createComponent(CallSignature, { get parameters() {
|
|
196
|
+
return [{
|
|
197
|
+
name: "value",
|
|
198
|
+
type: createComponent(TypeRefContext, { get children() {
|
|
199
|
+
return props.type;
|
|
200
|
+
} })
|
|
201
|
+
}];
|
|
202
|
+
} }),
|
|
203
|
+
" ",
|
|
204
|
+
createComponent(Block, { get children() {
|
|
205
|
+
return props.children;
|
|
206
|
+
} })
|
|
207
|
+
];
|
|
208
|
+
} })
|
|
209
|
+
];
|
|
210
|
+
} }))];
|
|
168
211
|
}
|
|
169
212
|
/**
|
|
170
213
|
* Generates a TypeScript class property getter declaration for the given reflection class.
|
|
@@ -173,18 +216,27 @@ function ClassPropertySet(props) {
|
|
|
173
216
|
* @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.
|
|
174
217
|
*/
|
|
175
218
|
function ClassPropertyGet(props) {
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
children: [
|
|
219
|
+
return createComponent(ClassMember, mergeProps(props, { get children() {
|
|
220
|
+
return [
|
|
179
221
|
"get ",
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
222
|
+
createComponent(PropertyName, { get name() {
|
|
223
|
+
return props.name;
|
|
224
|
+
} }),
|
|
225
|
+
createComponent(LexicalScope, { get children() {
|
|
226
|
+
return [
|
|
227
|
+
createComponent(CallSignature, { get returnType() {
|
|
228
|
+
return createComponent(TypeRefContext, { get children() {
|
|
229
|
+
return props.type;
|
|
230
|
+
} });
|
|
231
|
+
} }),
|
|
232
|
+
" ",
|
|
233
|
+
createComponent(Block, { get children() {
|
|
234
|
+
return props.children;
|
|
235
|
+
} })
|
|
236
|
+
];
|
|
237
|
+
} })
|
|
238
|
+
];
|
|
239
|
+
} }));
|
|
188
240
|
}
|
|
189
241
|
/**
|
|
190
242
|
* Generates a TypeScript class method declaration for the given reflection class.
|
|
@@ -195,24 +247,37 @@ function ClassPropertyGet(props) {
|
|
|
195
247
|
function ClassMethod(props) {
|
|
196
248
|
const callProps = getCallSignatureProps(props);
|
|
197
249
|
const [_, rest] = splitProps(props, ["doc"]);
|
|
198
|
-
return
|
|
199
|
-
when
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
250
|
+
return [createComponent(Show, {
|
|
251
|
+
get when() {
|
|
252
|
+
return Boolean(props.doc);
|
|
253
|
+
},
|
|
254
|
+
get children() {
|
|
255
|
+
return createComponent(TSDoc, {
|
|
256
|
+
get heading() {
|
|
257
|
+
return props.doc;
|
|
258
|
+
},
|
|
259
|
+
get children() {
|
|
260
|
+
return memo(() => !!Array.isArray(rest.parameters))() && createComponent(TSDocParams, { get parameters() {
|
|
261
|
+
return rest.parameters;
|
|
262
|
+
} });
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}), createComponent(ClassMember, mergeProps(rest, { get children() {
|
|
267
|
+
return [
|
|
268
|
+
memo(() => props.async && "async "),
|
|
269
|
+
createComponent(PropertyName, {}),
|
|
270
|
+
createComponent(LexicalScope, { get children() {
|
|
271
|
+
return [
|
|
272
|
+
createComponent(CallSignature, callProps),
|
|
273
|
+
" ",
|
|
274
|
+
createComponent(Block, { get children() {
|
|
275
|
+
return props.children;
|
|
276
|
+
} })
|
|
277
|
+
];
|
|
278
|
+
} })
|
|
279
|
+
];
|
|
280
|
+
} }))];
|
|
216
281
|
}
|
|
217
282
|
|
|
218
283
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-declaration.mjs","names":["Declaration","MemberScope"],"sources":["../../../src/typescript/components/class-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n code,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n CallSignature,\n CallSignatureProps,\n CommonDeclarationProps,\n createMemberSymbol,\n createTypeAndValueSymbol,\n Declaration,\n TSSymbolFlags,\n TypeParameterDescriptor,\n TypeRefContext,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport { LexicalScope } from \"../contexts\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { getCallSignatureProps } from \"../helpers\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc, TSDocParams } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\n/**\n * Props for the ClassDeclaration component, which represents a TypeScript class declaration\n */\nexport interface ClassDeclarationProps extends CommonDeclarationProps {\n /**\n * An indication of whether this class is abstract\n */\n abstract?: boolean;\n\n /**\n * An optional class that this class extends. This will be rendered as an `extends` clause in the class declaration\n */\n extends?: Children;\n\n /**\n * Optional interfaces that this class implements. This will be rendered as an `implements` clause in the class declaration\n */\n implements?: Children[];\n\n /**\n * The generic type parameters of the class.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Create a TypeScript class declaration.\n *\n * @example\n * ```tsx\n * const myPetRefkey = refkey();\n * const Animal = refkey();\n * const staticMember = refkey();\n * const instanceMember = refkey();\n *\n * <ClassDeclaration name=\"Animal\" refkey={Animal}>\n * <ClassMember public static name=\"something\" type=\"string\" refkey={staticMember}>\n * \"hello\"\n * </ClassMember>\n * <ClassMember public name=\"kind\" type=\"string\" />\n * <ClassMember public name=\"name\" type=\"string\" refkey={instanceMember} />\n * <ClassConstructor parameters=\"name: string\">\n * this.name = name;\n * </ClassConstructor>\n * </ClassDeclaration>\n *\n * <VarDeclaration const name=\"myPet\" refkey={myPetRefkey}>\n * new {Animal}();\n * </VarDeclaration>\n *\n * {staticMember}; // Animal.something\n * <MemberReference path={[myPetRefkey, instanceMember]} /> // myPet.name\n * {memberRefkey(myPetRefkey, instanceMember)}\n * ```\n */\nexport function ClassDeclaration(props: ClassDeclarationProps) {\n const extendsPart = props.extends && <> extends {props.extends}</>;\n const implementsPart = props.implements && props.implements.length > 0 && (\n <>\n {\" \"}\n implements{\" \"}\n <For each={props.implements} comma space>\n {implement => implement}\n </For>\n </>\n );\n const sym = createTypeAndValueSymbol(props.name, {\n refkeys: props.refkey,\n export: props.export,\n default: props.default,\n metadata: props.metadata,\n hasInstanceMembers: true,\n namePolicy: useTSNamePolicy().for(\"class\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration symbol={sym} export={props.export} default={props.default}>\n <MemberScope ownerSymbol={sym}>\n {props.abstract && code`abstract `} class <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}\n {implementsPart} <Block>{props.children}</Block>\n </MemberScope>\n </Declaration>\n </>\n );\n}\n\nClassDeclaration.TypeParameters = TypeParameters;\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n */\nexport interface ClassMemberProps {\n name: string | Namekey;\n refkey?: Refkey;\n public?: boolean;\n private?: boolean;\n protected?: boolean;\n jsPrivate?: boolean;\n static?: boolean;\n abstract?: boolean;\n children?: Children;\n doc?: Children;\n nullish?: boolean;\n override?: boolean;\n}\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n *\n * @param props - The properties of the class member, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class member declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMember(props: ClassMemberProps) {\n let tsFlags = TSSymbolFlags.None;\n if (props.nullish) {\n tsFlags |= TSSymbolFlags.Nullish;\n }\n\n const sym = createMemberSymbol(props.name, props, {\n refkeys: props.refkey,\n tsFlags,\n namePolicy: useTSNamePolicy().for(\"class-member-data\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <MemberDeclaration symbol={sym}>\n {props.public && \"public \"}\n {props.private && \"private \"}\n {props.protected && \"protected \"}\n {props.abstract && \"abstract \"}\n {props.override && \"override \"}\n {props.static && \"static \"}\n {props.children}\n </MemberDeclaration>\n </>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassFieldProps extends ClassMemberProps {\n name: string;\n type?: Children;\n optional?: boolean;\n children?: Children;\n isPrivateMember?: boolean;\n}\n\n/**\n * Generates a TypeScript class field declaration for the given reflection class.\n *\n * @param props - The properties of the class field, including its name, type, optionality, and other modifiers.\n * @returns A JSX element representing the class field declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassField(props: ClassFieldProps) {\n const optionality = props.optional ? \"?\" : \"\";\n const typeSection = props.type && (\n <>\n {optionality}: <TypeRefContext>{props.type}</TypeRefContext>\n </>\n );\n const initializerSection = props.children && <> = {props.children}</>;\n const nullish = props.nullish ?? props.optional;\n\n return (\n <ClassMember {...props} nullish={nullish}>\n <PropertyName\n private={props.isPrivateMember}\n name={props.isPrivateMember ? props.name : undefined}\n />\n {typeSection}\n {initializerSection}\n </ClassMember>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassPropertyProps extends ClassMemberProps {\n name: string;\n type?: Children;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class property setter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertySet(props: ClassPropertyProps) {\n return (\n <>\n <ClassMember {...props}>\n {\"set \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n parameters={[\n {\n name: \"value\",\n type: <TypeRefContext>{props.type}</TypeRefContext>\n }\n ]}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n\n/**\n * Generates a TypeScript class property getter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertyGet(props: ClassPropertyProps) {\n return (\n <ClassMember {...props}>\n {\"get \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n returnType={<TypeRefContext>{props.type}</TypeRefContext>}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n );\n}\n\n/**\n * Props for a class method, which is a specific type of class member that represents a function defined within the class.\n */\nexport interface ClassMethodProps extends ClassMemberProps, CallSignatureProps {\n async?: boolean;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class method declaration for the given reflection class.\n *\n * @param props - The properties of the class method, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class method declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMethod(props: ClassMethodProps) {\n const callProps = getCallSignatureProps(props);\n const [_, rest] = splitProps(props, [\"doc\"]);\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc}>\n {Array.isArray(rest.parameters) && (\n <TSDocParams parameters={rest.parameters} />\n )}\n </TSDoc>\n </Show>\n <ClassMember {...rest}>\n {props.async && \"async \"}\n <PropertyName />\n <LexicalScope>\n <CallSignature {...callProps} /> <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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M,CAAC;AAE5C,QACE,4CACE,oBAAC,MAAD;EAAM,MAAM,QAAQ,MAAM,IAAI;YAC5B,oBAAC,OAAD;GAAO,SAAS,MAAM;aACnB,MAAM,QAAQ,KAAK,WAAW,IAC7B,oBAAC,aAAD,EAAa,YAAY,KAAK,YAAc;GAExC;EACH,GACP,qBAAC,aAAD;EAAa,GAAI;YAAjB;GACG,MAAM,SAAS;GAChB,oBAAC,cAAD,EAAgB;GAChB,qBAAC,cAAD;IACE,oBAAC,eAAD,EAAe,GAAI,WAAa;;IAAC,oBAAC,OAAD,YAAQ,MAAM,UAAiB;IACnD;GACH;IACb"}
|
|
1
|
+
{"version":3,"file":"class-declaration.mjs","names":[],"sources":["../../../src/typescript/components/class-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Block,\n Children,\n code,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n CallSignature,\n CallSignatureProps,\n CommonDeclarationProps,\n createMemberSymbol,\n createTypeAndValueSymbol,\n Declaration,\n TSSymbolFlags,\n TypeParameterDescriptor,\n TypeRefContext,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport { LexicalScope } from \"../contexts\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { getCallSignatureProps } from \"../helpers\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc, TSDocParams } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\n/**\n * Props for the ClassDeclaration component, which represents a TypeScript class declaration\n */\nexport interface ClassDeclarationProps extends CommonDeclarationProps {\n /**\n * An indication of whether this class is abstract\n */\n abstract?: boolean;\n\n /**\n * An optional class that this class extends. This will be rendered as an `extends` clause in the class declaration\n */\n extends?: Children;\n\n /**\n * Optional interfaces that this class implements. This will be rendered as an `implements` clause in the class declaration\n */\n implements?: Children[];\n\n /**\n * The generic type parameters of the class.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Create a TypeScript class declaration.\n *\n * @example\n * ```tsx\n * const myPetRefkey = refkey();\n * const Animal = refkey();\n * const staticMember = refkey();\n * const instanceMember = refkey();\n *\n * <ClassDeclaration name=\"Animal\" refkey={Animal}>\n * <ClassMember public static name=\"something\" type=\"string\" refkey={staticMember}>\n * \"hello\"\n * </ClassMember>\n * <ClassMember public name=\"kind\" type=\"string\" />\n * <ClassMember public name=\"name\" type=\"string\" refkey={instanceMember} />\n * <ClassConstructor parameters=\"name: string\">\n * this.name = name;\n * </ClassConstructor>\n * </ClassDeclaration>\n *\n * <VarDeclaration const name=\"myPet\" refkey={myPetRefkey}>\n * new {Animal}();\n * </VarDeclaration>\n *\n * {staticMember}; // Animal.something\n * <MemberReference path={[myPetRefkey, instanceMember]} /> // myPet.name\n * {memberRefkey(myPetRefkey, instanceMember)}\n * ```\n */\nexport function ClassDeclaration(props: ClassDeclarationProps) {\n const extendsPart = props.extends && <> extends {props.extends}</>;\n const implementsPart = props.implements && props.implements.length > 0 && (\n <>\n {\" \"}\n implements{\" \"}\n <For each={props.implements} comma space>\n {implement => implement}\n </For>\n </>\n );\n const sym = createTypeAndValueSymbol(props.name, {\n refkeys: props.refkey,\n export: props.export,\n default: props.default,\n metadata: props.metadata,\n hasInstanceMembers: true,\n namePolicy: useTSNamePolicy().for(\"class\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration symbol={sym} export={props.export} default={props.default}>\n <MemberScope ownerSymbol={sym}>\n {props.abstract && code`abstract `} class <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}\n {implementsPart} <Block>{props.children}</Block>\n </MemberScope>\n </Declaration>\n </>\n );\n}\n\nClassDeclaration.TypeParameters = TypeParameters;\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n */\nexport interface ClassMemberProps {\n name: string | Namekey;\n refkey?: Refkey;\n public?: boolean;\n private?: boolean;\n protected?: boolean;\n jsPrivate?: boolean;\n static?: boolean;\n abstract?: boolean;\n children?: Children;\n doc?: Children;\n nullish?: boolean;\n override?: boolean;\n}\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n *\n * @param props - The properties of the class member, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class member declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMember(props: ClassMemberProps) {\n let tsFlags = TSSymbolFlags.None;\n if (props.nullish) {\n tsFlags |= TSSymbolFlags.Nullish;\n }\n\n const sym = createMemberSymbol(props.name, props, {\n refkeys: props.refkey,\n tsFlags,\n namePolicy: useTSNamePolicy().for(\"class-member-data\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <MemberDeclaration symbol={sym}>\n {props.public && \"public \"}\n {props.private && \"private \"}\n {props.protected && \"protected \"}\n {props.abstract && \"abstract \"}\n {props.override && \"override \"}\n {props.static && \"static \"}\n {props.children}\n </MemberDeclaration>\n </>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassFieldProps extends ClassMemberProps {\n name: string;\n type?: Children;\n optional?: boolean;\n children?: Children;\n isPrivateMember?: boolean;\n}\n\n/**\n * Generates a TypeScript class field declaration for the given reflection class.\n *\n * @param props - The properties of the class field, including its name, type, optionality, and other modifiers.\n * @returns A JSX element representing the class field declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassField(props: ClassFieldProps) {\n const optionality = props.optional ? \"?\" : \"\";\n const typeSection = props.type && (\n <>\n {optionality}: <TypeRefContext>{props.type}</TypeRefContext>\n </>\n );\n const initializerSection = props.children && <> = {props.children}</>;\n const nullish = props.nullish ?? props.optional;\n\n return (\n <ClassMember {...props} nullish={nullish}>\n <PropertyName\n private={props.isPrivateMember}\n name={props.isPrivateMember ? props.name : undefined}\n />\n {typeSection}\n {initializerSection}\n </ClassMember>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassPropertyProps extends ClassMemberProps {\n name: string;\n type?: Children;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class property setter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertySet(props: ClassPropertyProps) {\n return (\n <>\n <ClassMember {...props}>\n {\"set \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n parameters={[\n {\n name: \"value\",\n type: <TypeRefContext>{props.type}</TypeRefContext>\n }\n ]}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n\n/**\n * Generates a TypeScript class property getter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertyGet(props: ClassPropertyProps) {\n return (\n <ClassMember {...props}>\n {\"get \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n returnType={<TypeRefContext>{props.type}</TypeRefContext>}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n );\n}\n\n/**\n * Props for a class method, which is a specific type of class member that represents a function defined within the class.\n */\nexport interface ClassMethodProps extends ClassMemberProps, CallSignatureProps {\n async?: boolean;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class method declaration for the given reflection class.\n *\n * @param props - The properties of the class method, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class method declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMethod(props: ClassMethodProps) {\n const callProps = getCallSignatureProps(props);\n const [_, rest] = splitProps(props, [\"doc\"]);\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc}>\n {Array.isArray(rest.parameters) && (\n <TSDocParams parameters={rest.parameters} />\n )}\n </TSDoc>\n </Show>\n <ClassMember {...rest}>\n {props.async && \"async \"}\n <PropertyName />\n <LexicalScope>\n <CallSignature {...callProps} /> <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,SAAC,iBAAA,OAAA;CACC,MAAE,cAAiB,MAAM,WAAQ,CAAA,aAAe,WAAA,MAAA,QAAA,CAAA;CAChD,MAAI,iBAAmB,MAAM,cAAO,MAAW,WAAa,SAAS,KAAA;EAAA;EAAA;EAAa;EAAA,gBAAA,KAAA;GAChF,IAAI,OAAK;AACP,WAAC,MAAW;;GAEd,OAAE;GACF,OAAE;GACF,WAAQ,cAAW;GACpB,CAAC;EAAC;CACH,MAAG,MAAA,yBAAgB,MAAA,MAAA;EACpB,SAAA,MAAA;EACG,QAAA,MAAc;EACd,SAAM,MAAS;EACf,UAAC,MAAc;EAClB,oBAAA;EACG,YAAY,iBAAa,CAAA,IAAA,QAAA;EAC1B,CAAC;AACF,QAAE,CAAA,gBAAwB,MAAE;EAC1B,IAAC,OAAA;AACH,UAAA,QAAA,MAAA,IAAA;;EAEA,IAAM,WAAW;AACjB,UAAM,gBAAuB,OAAA,EAC1B,IAAA,UAAA;AACK,WAAA,MAAA;MAEH,CAAA;;EAEJ,CAAC,EAAE,gBAAK,eAAA;EACP,QAAE;EACH,KAAA,YAAA;AACD,UAAW,MAAC;;EAEV,KAAA,aAAc;AACd,UAAS,MAAM;;EAEf,IAAA,WAAA;AACA,UAAA,gB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Y,OAAA;CACpB,MAAM,YAAW,sBAAA,MAAA;CACjB,MAAI,CAAA,GAAA,QAAA,WAAA,OAAA,CAAA,MAAA,CAAA;AACJ,QAAC,CAAA,gBAAA,MAAA;EACH,IAAA,OAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
4
3
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
6
|
|
|
7
7
|
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
@@ -19,11 +19,7 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
19
19
|
*/
|
|
20
20
|
function DynamicImportStatement(props) {
|
|
21
21
|
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
22
|
-
return
|
|
23
|
-
const: isConst,
|
|
24
|
-
...rest,
|
|
25
|
-
initializer: _alloy_js_core.code`await import("${importPath}").then(m => m.${exportName});`
|
|
26
|
-
});
|
|
22
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)({ "const": isConst }, rest, { initializer: _alloy_js_core.code`await import("${importPath}").then(m => m.${exportName});` }));
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
1
2
|
import { code } from "@alloy-js/core";
|
|
2
|
-
import { jsx } from "@alloy-js/core/jsx-runtime";
|
|
3
3
|
import { VarDeclaration } from "@alloy-js/typescript";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
@@ -17,11 +17,7 @@ import { VarDeclaration } from "@alloy-js/typescript";
|
|
|
17
17
|
*/
|
|
18
18
|
function DynamicImportStatement(props) {
|
|
19
19
|
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
20
|
-
return
|
|
21
|
-
const: isConst,
|
|
22
|
-
...rest,
|
|
23
|
-
initializer: code`await import("${importPath}").then(m => m.${exportName});`
|
|
24
|
-
});
|
|
20
|
+
return createComponent(VarDeclaration, mergeProps({ "const": isConst }, rest, { initializer: code`await import("${importPath}").then(m => m.${exportName});` }));
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-import-statement.mjs","names":[],"sources":["../../../src/typescript/components/dynamic-import-statement.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { VarDeclaration, VarDeclarationProps } from \"@alloy-js/typescript\";\n\nexport interface DynamicImportStatementProps extends Omit<\n VarDeclarationProps,\n \"initializer\"\n> {\n /**\n * The path of the module to import.\n */\n importPath: string;\n\n /**\n * The name of the export to import from the module.\n *\n * @defaultValue \"default\"\n */\n exportName?: string;\n}\n\n/**\n * Generates a dynamic import statement for a given module path and export name.\n *\n * @example\n * ```tsx\n * <DynamicImportStatement importPath=\"./my-module\" exportName=\"myExport\" const={true} name=\"myVar\" />\n * // const myVar = await import(\"./my-module\").then(m => m.myExport);\n * ```\n *\n * @param props - The properties for the dynamic import statement.\n * @returns A `VarDeclaration` component representing the dynamic import statement.\n */\nexport function DynamicImportStatement(props: DynamicImportStatementProps) {\n const {\n importPath,\n exportName = \"default\",\n const: isConst = true,\n ...rest\n } = props;\n\n return (\n <VarDeclaration\n const={isConst}\n {...rest}\n initializer={code`await import(\"${importPath}\").then(m => m.${exportName});`}></VarDeclaration>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dynamic-import-statement.mjs","names":[],"sources":["../../../src/typescript/components/dynamic-import-statement.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { VarDeclaration, VarDeclarationProps } from \"@alloy-js/typescript\";\n\nexport interface DynamicImportStatementProps extends Omit<\n VarDeclarationProps,\n \"initializer\"\n> {\n /**\n * The path of the module to import.\n */\n importPath: string;\n\n /**\n * The name of the export to import from the module.\n *\n * @defaultValue \"default\"\n */\n exportName?: string;\n}\n\n/**\n * Generates a dynamic import statement for a given module path and export name.\n *\n * @example\n * ```tsx\n * <DynamicImportStatement importPath=\"./my-module\" exportName=\"myExport\" const={true} name=\"myVar\" />\n * // const myVar = await import(\"./my-module\").then(m => m.myExport);\n * ```\n *\n * @param props - The properties for the dynamic import statement.\n * @returns A `VarDeclaration` component representing the dynamic import statement.\n */\nexport function DynamicImportStatement(props: DynamicImportStatementProps) {\n const {\n importPath,\n exportName = \"default\",\n const: isConst = true,\n ...rest\n } = props;\n\n return (\n <VarDeclaration\n const={isConst}\n {...rest}\n initializer={code`await import(\"${importPath}\").then(m => m.${exportName});`}></VarDeclaration>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+CA,SAAgB,uBAAqB,OAA4B;CAC/D,MAAE,EACF,YACF,aAAgB,WACd,OAAM,UAAA,MACJ,GAAA,SACA;AACF,QAAO,gBAAgB,gBAAA,WAAA,EACrB,SAAG,SACJ,EAAE,MAAM,gFAET,CAAA,CAAA"}
|
|
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_core_contexts_context = require('../../core/contexts/context.cjs');
|
|
4
4
|
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
5
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
6
5
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
6
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
8
|
let _stryke_path_append = require("@stryke/path/append");
|
|
9
9
|
let defu = require("defu");
|
|
10
10
|
defu = require_runtime.__toESM(defu);
|
|
@@ -28,12 +28,15 @@ function EntryFile(props) {
|
|
|
28
28
|
]);
|
|
29
29
|
const context = require_core_contexts_context.usePowerlinesSafe();
|
|
30
30
|
const fullPath = (0, _alloy_js_core.computed)(() => context ? (0, _stryke_path_append.appendPath)(`${!(0, _stryke_type_checks_is_set.isSet)(tsx) ? path : (0, _stryke_path_replace.replaceExtension)(path)}${tsx ? ".tsx" : (0, _stryke_path_file_path_fns.hasFileExtension)(path) ? "" : ".ts"}`, (0, _stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot)) : path);
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
32
|
+
get path() {
|
|
33
|
+
return fullPath.value;
|
|
34
|
+
},
|
|
35
|
+
get meta() {
|
|
36
|
+
return (0, defu.default)({ kind: "entry" }, meta ?? {}, { typeDefinition });
|
|
37
|
+
},
|
|
35
38
|
children
|
|
36
|
-
});
|
|
39
|
+
}));
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
2
|
import { TypescriptFile } from "./typescript-file.mjs";
|
|
3
|
-
import { computed, splitProps } from "@alloy-js/core";
|
|
4
3
|
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
5
|
-
import {
|
|
4
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { computed, splitProps } from "@alloy-js/core";
|
|
6
6
|
import { appendPath } from "@stryke/path/append";
|
|
7
7
|
import defu from "defu";
|
|
8
8
|
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
@@ -25,12 +25,15 @@ function EntryFile(props) {
|
|
|
25
25
|
]);
|
|
26
26
|
const context = usePowerlinesSafe();
|
|
27
27
|
const fullPath = computed(() => context ? appendPath(`${!isSet(tsx) ? path : replaceExtension(path)}${tsx ? ".tsx" : hasFileExtension(path) ? "" : ".ts"}`, replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)) : path);
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return createComponent(TypescriptFile, mergeProps(rest, {
|
|
29
|
+
get path() {
|
|
30
|
+
return fullPath.value;
|
|
31
|
+
},
|
|
32
|
+
get meta() {
|
|
33
|
+
return defu({ kind: "entry" }, meta ?? {}, { typeDefinition });
|
|
34
|
+
},
|
|
32
35
|
children
|
|
33
|
-
});
|
|
36
|
+
}));
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-file.mjs","names":[],"sources":["../../../src/typescript/components/entry-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, splitProps } from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport defu from \"defu\";\nimport { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { TypescriptFile, TypescriptFileProps } from \"./typescript-file\";\n\nexport type EntryFileProps = TypescriptFileProps & {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n\n /**\n * Render metadata information about the entrypoint\n */\n typeDefinition?: ResolvedEntryTypeDefinition;\n};\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function EntryFile(props: EntryFileProps) {\n const [{ children, meta, tsx, path, typeDefinition }, rest] = splitProps(\n props,\n [\"children\", \"meta\", \"tsx\", \"path\", \"typeDefinition\"]\n );\n\n const context = usePowerlinesSafe();\n const fullPath = computed(() =>\n context\n ? appendPath(\n `${\n !isSet(tsx) ? path : replaceExtension(path)\n }${tsx ? \".tsx\" : hasFileExtension(path) ? \"\" : \".ts\"}`,\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n )\n : path\n );\n\n return (\n <TypescriptFile\n {...rest}\n path={fullPath.value}\n meta={defu(\n {\n kind: \"entry\"\n },\n meta ?? {},\n {\n typeDefinition\n }\n )}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"entry-file.mjs","names":[],"sources":["../../../src/typescript/components/entry-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, splitProps } from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport defu from \"defu\";\nimport { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { TypescriptFile, TypescriptFileProps } from \"./typescript-file\";\n\nexport type EntryFileProps = TypescriptFileProps & {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n\n /**\n * Render metadata information about the entrypoint\n */\n typeDefinition?: ResolvedEntryTypeDefinition;\n};\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function EntryFile(props: EntryFileProps) {\n const [{ children, meta, tsx, path, typeDefinition }, rest] = splitProps(\n props,\n [\"children\", \"meta\", \"tsx\", \"path\", \"typeDefinition\"]\n );\n\n const context = usePowerlinesSafe();\n const fullPath = computed(() =>\n context\n ? appendPath(\n `${\n !isSet(tsx) ? path : replaceExtension(path)\n }${tsx ? \".tsx\" : hasFileExtension(path) ? \"\" : \".ts\"}`,\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n )\n : path\n );\n\n return (\n <TypescriptFile\n {...rest}\n path={fullPath.value}\n meta={defu(\n {\n kind: \"entry\"\n },\n meta ?? {},\n {\n typeDefinition\n }\n )}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,CAAC,EACL,UACA,MACD,WAED,kBACA,QAAM,WAAW,OAAY;EAAC;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;CAC9B,MAAE,UAAA,mBAAA;CACF,MAAM,WAAU,eAAA,UAAA,WAAA,GAAA,CAAA,MAAA,IAAA,GAAA,OAAA,iBAAA,KAAA,GAAA,MAAA,SAAA,iBAAA,KAAA,GAAA,KAAA,SAAA,YAAA,QAAA,WAAA,QAAA,gBAAA,cAAA,CAAA,GAAA,KAAA;AAChB,QAAO,gBAAG,gBAAA,WAAA,MAAA;EACR,IAAI,OAAK;AACP,UAAO,SAAQ;;EAEjB,IAAI,OAAA;AACF,UAAE,KAAA,EACL,MAAA,yBAEK,gBACH,CAAA;;EAEO;EACT,CAAC,CAAC"}
|
|
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_core_contexts_context = require('../../core/contexts/context.cjs');
|
|
4
4
|
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
5
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
6
5
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
6
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
8
|
let _stryke_path_append = require("@stryke/path/append");
|
|
9
9
|
let defu = require("defu");
|
|
10
10
|
defu = require_runtime.__toESM(defu);
|
|
@@ -25,12 +25,15 @@ function InfrastructureFile(props) {
|
|
|
25
25
|
]);
|
|
26
26
|
const context = require_core_contexts_context.usePowerlinesSafe();
|
|
27
27
|
const fullPath = (0, _alloy_js_core.computed)(() => context ? (0, _stryke_path_append.appendPath)((0, _stryke_path_file_path_fns.hasFileExtension)(id) ? "" : ".ts", (0, _stryke_path_replace.replacePath)(context.infrastructurePath, context.workspaceConfig.workspaceRoot)) : id);
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
29
|
+
get path() {
|
|
30
|
+
return fullPath.value;
|
|
31
|
+
},
|
|
32
|
+
get meta() {
|
|
33
|
+
return (0, defu.default)({ kind: "infrastructure" }, meta ?? {});
|
|
34
|
+
},
|
|
32
35
|
children
|
|
33
|
-
});
|
|
36
|
+
}));
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
//#endregion
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
2
|
import { TypescriptFile } from "./typescript-file.mjs";
|
|
3
|
-
import { computed, splitProps } from "@alloy-js/core";
|
|
4
3
|
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
5
|
-
import {
|
|
4
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { computed, splitProps } from "@alloy-js/core";
|
|
6
6
|
import { appendPath } from "@stryke/path/append";
|
|
7
7
|
import defu from "defu";
|
|
8
8
|
import { replacePath } from "@stryke/path/replace";
|
|
@@ -22,12 +22,15 @@ function InfrastructureFile(props) {
|
|
|
22
22
|
]);
|
|
23
23
|
const context = usePowerlinesSafe();
|
|
24
24
|
const fullPath = computed(() => context ? appendPath(hasFileExtension(id) ? "" : ".ts", replacePath(context.infrastructurePath, context.workspaceConfig.workspaceRoot)) : id);
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
return createComponent(TypescriptFile, mergeProps(rest, {
|
|
26
|
+
get path() {
|
|
27
|
+
return fullPath.value;
|
|
28
|
+
},
|
|
29
|
+
get meta() {
|
|
30
|
+
return defu({ kind: "infrastructure" }, meta ?? {});
|
|
31
|
+
},
|
|
29
32
|
children
|
|
30
|
-
});
|
|
33
|
+
}));
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infrastructure-file.mjs","names":[],"sources":["../../../src/typescript/components/infrastructure-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, splitProps } from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { TypescriptFile, TypescriptFileProps } from \"./typescript-file\";\n\nexport type InfrastructureFileProps = Omit<TypescriptFileProps, \"path\"> & {\n /**\n * The infrastructure module identifier.\n */\n id: string;\n};\n\n/**\n * A base component representing a Powerlines generated Typescript infrastructure file.\n *\n * @param props - The properties for the infrastructure file.\n * @returns The rendered infrastructure file component.\n */\nexport function InfrastructureFile(props: InfrastructureFileProps) {\n const [{ children, meta, id }, rest] = splitProps(props, [\n \"children\",\n \"meta\",\n \"id\"\n ]);\n\n const context = usePowerlinesSafe();\n const fullPath = computed(() =>\n context\n ? appendPath(\n hasFileExtension(id) ? \"\" : \".ts\",\n replacePath(\n context.infrastructurePath,\n context.workspaceConfig.workspaceRoot\n )\n )\n : id\n );\n\n return (\n <TypescriptFile\n {...rest}\n path={fullPath.value}\n meta={defu(\n {\n kind: \"infrastructure\"\n },\n meta ?? {}\n )}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAgB,mBAAmB,OAAgC;CACjE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"infrastructure-file.mjs","names":[],"sources":["../../../src/typescript/components/infrastructure-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { computed, splitProps } from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport defu from \"defu\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { TypescriptFile, TypescriptFileProps } from \"./typescript-file\";\n\nexport type InfrastructureFileProps = Omit<TypescriptFileProps, \"path\"> & {\n /**\n * The infrastructure module identifier.\n */\n id: string;\n};\n\n/**\n * A base component representing a Powerlines generated Typescript infrastructure file.\n *\n * @param props - The properties for the infrastructure file.\n * @returns The rendered infrastructure file component.\n */\nexport function InfrastructureFile(props: InfrastructureFileProps) {\n const [{ children, meta, id }, rest] = splitProps(props, [\n \"children\",\n \"meta\",\n \"id\"\n ]);\n\n const context = usePowerlinesSafe();\n const fullPath = computed(() =>\n context\n ? appendPath(\n hasFileExtension(id) ? \"\" : \".ts\",\n replacePath(\n context.infrastructurePath,\n context.workspaceConfig.workspaceRoot\n )\n )\n : id\n );\n\n return (\n <TypescriptFile\n {...rest}\n path={fullPath.value}\n meta={defu(\n {\n kind: \"infrastructure\"\n },\n meta ?? {}\n )}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAgB,mBAAmB,OAAgC;CACjE,MAAM,CAAC,EACL,UACA,MACA,MACA,QAAA,WAAA,OAAA;EAAA;EAAA;EAAA;EAAA,CAAA;;CAEF,MAAM,WAAU,eAAA,UAAmB,WAAA,iBAAA,GAAA,GAAA,KAAA,OAAA,YAAA,QAAA,oBAAA,QAAA,gBAAA,cAAA,CAAA,GAAA,GAAA;AACnC,QAAM,gBAAmB,gBAAK,WAAA,MAAA;EAC5B,IAAA,OAAA;AACE,UAAE,SAAU;;EAEd,IAAI,OAAE;AACJ,UAAM,KAAA,EACJ,MAAI,kBACL,EAAE,QAAC,EAAA,CAAA;;EAEF;EACL,CAAA,CAAA"}
|