@powerlines/plugin-alloy 0.25.29 → 0.25.31
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/core/components/output.cjs +12 -7
- package/dist/core/components/output.mjs +12 -7
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +5 -8
- package/dist/core/components/single-line-comment.mjs +5 -8
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +8 -7
- package/dist/core/components/source-file.mjs +8 -7
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +5 -6
- package/dist/core/components/spacing.mjs +5 -6
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +12 -9
- package/dist/markdown/components/front-matter.mjs +12 -9
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/markdown-file.cjs +57 -41
- package/dist/markdown/components/markdown-file.mjs +57 -41
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +31 -20
- package/dist/markdown/components/markdown-table.mjs +31 -20
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/render.cjs +10 -4
- package/dist/render.mjs +10 -4
- package/dist/render.mjs.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +21 -9
- package/dist/typescript/components/builtin-file.mjs +21 -9
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +112 -79
- package/dist/typescript/components/class-declaration.mjs +112 -79
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +6 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +6 -1
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +7 -3
- package/dist/typescript/components/entry-file.mjs +7 -3
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/infrastructure-file.cjs +7 -3
- package/dist/typescript/components/infrastructure-file.mjs +7 -3
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +83 -47
- package/dist/typescript/components/interface-declaration.mjs +83 -47
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +48 -36
- package/dist/typescript/components/object-declaration.mjs +48 -36
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +2 -2
- package/dist/typescript/components/property-name.mjs +3 -3
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +112 -54
- package/dist/typescript/components/tsdoc-reflection.mjs +112 -54
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +211 -140
- package/dist/typescript/components/tsdoc.mjs +211 -140
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +17 -9
- package/dist/typescript/components/type-declaration.mjs +17 -9
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +33 -33
- package/dist/typescript/components/type-parameters.mjs +33 -33
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +90 -65
- package/dist/typescript/components/typescript-file.mjs +90 -65
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/lexical-scope.cjs +5 -1
- package/dist/typescript/contexts/lexical-scope.mjs +5 -1
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +5 -2
- package/dist/typescript/contexts/member-scope.mjs +5 -2
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/yaml/components/yaml-file.cjs +58 -48
- package/dist/yaml/components/yaml-file.mjs +58 -48
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -9,6 +9,7 @@ require('../helpers/index.cjs');
|
|
|
9
9
|
const require_typescript_components_property_name = require('./property-name.cjs');
|
|
10
10
|
const require_typescript_components_type_parameters = require('./type-parameters.cjs');
|
|
11
11
|
let _alloy_js_core = require("@alloy-js/core");
|
|
12
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
12
13
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
13
14
|
|
|
14
15
|
//#region src/typescript/components/class-declaration.tsx
|
|
@@ -43,14 +44,18 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
43
44
|
* ```
|
|
44
45
|
*/
|
|
45
46
|
function ClassDeclaration(props) {
|
|
46
|
-
const extendsPart = props.extends &&
|
|
47
|
-
const implementsPart = props.implements && props.implements.length > 0 &&
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
const extendsPart = props.extends && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [" extends ", props.extends] });
|
|
48
|
+
const implementsPart = props.implements && props.implements.length > 0 && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [
|
|
49
|
+
" ",
|
|
50
|
+
"implements",
|
|
51
|
+
" ",
|
|
52
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.For, {
|
|
53
|
+
each: props.implements,
|
|
54
|
+
comma: true,
|
|
55
|
+
space: true,
|
|
56
|
+
children: (implement) => implement
|
|
57
|
+
})
|
|
58
|
+
] });
|
|
54
59
|
const sym = (0, _alloy_js_typescript.createTypeAndValueSymbol)(props.name, {
|
|
55
60
|
refkeys: props.refkey,
|
|
56
61
|
export: props.export,
|
|
@@ -59,19 +64,27 @@ function ClassDeclaration(props) {
|
|
|
59
64
|
hasInstanceMembers: true,
|
|
60
65
|
namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("class")
|
|
61
66
|
});
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
68
|
+
when: Boolean(props.doc),
|
|
69
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_tsdoc.TSDoc, { heading: props.doc })
|
|
70
|
+
}), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.Declaration, {
|
|
71
|
+
symbol: sym,
|
|
72
|
+
export: props.export,
|
|
73
|
+
default: props.default,
|
|
74
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(require_typescript_contexts_member_scope.MemberScope, {
|
|
75
|
+
ownerSymbol: sym,
|
|
76
|
+
children: [
|
|
77
|
+
props.abstract && _alloy_js_core.code`abstract `,
|
|
78
|
+
" class ",
|
|
79
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Name, {}),
|
|
80
|
+
props.typeParameters && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_type_parameters.TypeParameters, { parameters: props.typeParameters }),
|
|
81
|
+
extendsPart,
|
|
82
|
+
implementsPart,
|
|
83
|
+
" ",
|
|
84
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Block, { children: props.children })
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
})] });
|
|
75
88
|
}
|
|
76
89
|
ClassDeclaration.TypeParameters = require_typescript_components_type_parameters.TypeParameters;
|
|
77
90
|
/**
|
|
@@ -88,20 +101,21 @@ function ClassMember(props) {
|
|
|
88
101
|
tsFlags,
|
|
89
102
|
namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("class-member-data")
|
|
90
103
|
});
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
105
|
+
when: Boolean(props.doc),
|
|
106
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_tsdoc.TSDoc, { heading: props.doc })
|
|
107
|
+
}), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.MemberDeclaration, {
|
|
108
|
+
symbol: sym,
|
|
109
|
+
children: [
|
|
110
|
+
props.public && "public ",
|
|
111
|
+
props.private && "private ",
|
|
112
|
+
props.protected && "protected ",
|
|
113
|
+
props.abstract && "abstract ",
|
|
114
|
+
props.override && "override ",
|
|
115
|
+
props.static && "static ",
|
|
116
|
+
props.children
|
|
117
|
+
]
|
|
118
|
+
})] });
|
|
105
119
|
}
|
|
106
120
|
/**
|
|
107
121
|
* Generates a TypeScript class field declaration for the given reflection class.
|
|
@@ -111,16 +125,25 @@ function ClassMember(props) {
|
|
|
111
125
|
*/
|
|
112
126
|
function ClassField(props) {
|
|
113
127
|
const optionality = props.optional ? "?" : "";
|
|
114
|
-
const typeSection = props.type &&
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
const typeSection = props.type && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [
|
|
129
|
+
optionality,
|
|
130
|
+
": ",
|
|
131
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.TypeRefContext, { children: props.type })
|
|
132
|
+
] });
|
|
133
|
+
const initializerSection = props.children && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [" = ", props.children] });
|
|
118
134
|
const nullish = props.nullish ?? props.optional;
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(ClassMember, {
|
|
136
|
+
...props,
|
|
137
|
+
nullish,
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_property_name.PropertyName, {
|
|
140
|
+
private: props.isPrivateMember,
|
|
141
|
+
name: props.isPrivateMember ? props.name : void 0
|
|
142
|
+
}),
|
|
143
|
+
typeSection,
|
|
144
|
+
initializerSection
|
|
145
|
+
]
|
|
146
|
+
});
|
|
124
147
|
}
|
|
125
148
|
/**
|
|
126
149
|
* Generates a TypeScript class property setter declaration for the given reflection class.
|
|
@@ -129,19 +152,21 @@ function ClassField(props) {
|
|
|
129
152
|
* @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.
|
|
130
153
|
*/
|
|
131
154
|
function ClassPropertySet(props) {
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(ClassMember, {
|
|
156
|
+
...props,
|
|
157
|
+
children: [
|
|
158
|
+
"set ",
|
|
159
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_property_name.PropertyName, { name: props.name }),
|
|
160
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(require_typescript_contexts_lexical_scope.LexicalScope, { children: [
|
|
161
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.CallSignature, { parameters: [{
|
|
162
|
+
name: "value",
|
|
163
|
+
type: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.TypeRefContext, { children: props.type })
|
|
164
|
+
}] }),
|
|
165
|
+
" ",
|
|
166
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Block, { children: props.children })
|
|
167
|
+
] })
|
|
168
|
+
]
|
|
169
|
+
}) });
|
|
145
170
|
}
|
|
146
171
|
/**
|
|
147
172
|
* Generates a TypeScript class property getter declaration for the given reflection class.
|
|
@@ -150,14 +175,18 @@ function ClassPropertySet(props) {
|
|
|
150
175
|
* @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.
|
|
151
176
|
*/
|
|
152
177
|
function ClassPropertyGet(props) {
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
178
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(ClassMember, {
|
|
179
|
+
...props,
|
|
180
|
+
children: [
|
|
181
|
+
"get ",
|
|
182
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_property_name.PropertyName, { name: props.name }),
|
|
183
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(require_typescript_contexts_lexical_scope.LexicalScope, { children: [
|
|
184
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.CallSignature, { returnType: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.TypeRefContext, { children: props.type }) }),
|
|
185
|
+
" ",
|
|
186
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Block, { children: props.children })
|
|
187
|
+
] })
|
|
188
|
+
]
|
|
189
|
+
});
|
|
161
190
|
}
|
|
162
191
|
/**
|
|
163
192
|
* Generates a TypeScript class method declaration for the given reflection class.
|
|
@@ -168,20 +197,24 @@ function ClassPropertyGet(props) {
|
|
|
168
197
|
function ClassMethod(props) {
|
|
169
198
|
const callProps = require_typescript_helpers_get_call_signature_props.getCallSignatureProps(props);
|
|
170
199
|
const [_, rest] = (0, _alloy_js_core.splitProps)(props, ["doc"]);
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
201
|
+
when: Boolean(props.doc),
|
|
202
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_tsdoc.TSDoc, {
|
|
203
|
+
heading: props.doc,
|
|
204
|
+
children: Array.isArray(rest.parameters) && /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_tsdoc.TSDocParams, { parameters: rest.parameters })
|
|
205
|
+
})
|
|
206
|
+
}), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(ClassMember, {
|
|
207
|
+
...rest,
|
|
208
|
+
children: [
|
|
209
|
+
props.async && "async ",
|
|
210
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_property_name.PropertyName, {}),
|
|
211
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(require_typescript_contexts_lexical_scope.LexicalScope, { children: [
|
|
212
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.CallSignature, { ...callProps }),
|
|
213
|
+
" ",
|
|
214
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Block, { children: props.children })
|
|
215
|
+
] })
|
|
216
|
+
]
|
|
217
|
+
})] });
|
|
185
218
|
}
|
|
186
219
|
|
|
187
220
|
//#endregion
|
|
@@ -7,6 +7,7 @@ import "../helpers/index.mjs";
|
|
|
7
7
|
import { PropertyName } from "./property-name.mjs";
|
|
8
8
|
import { TypeParameters } from "./type-parameters.mjs";
|
|
9
9
|
import { Block, For, MemberDeclaration, Name, Show, code, splitProps } from "@alloy-js/core";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
10
11
|
import { CallSignature, Declaration as Declaration$1, TSSymbolFlags, TypeRefContext, createMemberSymbol, createTypeAndValueSymbol, useTSNamePolicy } from "@alloy-js/typescript";
|
|
11
12
|
|
|
12
13
|
//#region src/typescript/components/class-declaration.tsx
|
|
@@ -41,14 +42,18 @@ import { CallSignature, Declaration as Declaration$1, TSSymbolFlags, TypeRefCont
|
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
44
|
function ClassDeclaration(props) {
|
|
44
|
-
const extendsPart = props.extends &&
|
|
45
|
-
const implementsPart = props.implements && props.implements.length > 0 &&
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const extendsPart = props.extends && /* @__PURE__ */ jsxs(Fragment, { children: [" extends ", props.extends] });
|
|
46
|
+
const implementsPart = props.implements && props.implements.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
" ",
|
|
48
|
+
"implements",
|
|
49
|
+
" ",
|
|
50
|
+
/* @__PURE__ */ jsx(For, {
|
|
51
|
+
each: props.implements,
|
|
52
|
+
comma: true,
|
|
53
|
+
space: true,
|
|
54
|
+
children: (implement) => implement
|
|
55
|
+
})
|
|
56
|
+
] });
|
|
52
57
|
const sym = createTypeAndValueSymbol(props.name, {
|
|
53
58
|
refkeys: props.refkey,
|
|
54
59
|
export: props.export,
|
|
@@ -57,19 +62,27 @@ function ClassDeclaration(props) {
|
|
|
57
62
|
hasInstanceMembers: true,
|
|
58
63
|
namePolicy: useTSNamePolicy().for("class")
|
|
59
64
|
});
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Show, {
|
|
66
|
+
when: Boolean(props.doc),
|
|
67
|
+
children: /* @__PURE__ */ jsx(TSDoc, { heading: props.doc })
|
|
68
|
+
}), /* @__PURE__ */ jsx(Declaration$1, {
|
|
69
|
+
symbol: sym,
|
|
70
|
+
export: props.export,
|
|
71
|
+
default: props.default,
|
|
72
|
+
children: /* @__PURE__ */ jsxs(MemberScope$1, {
|
|
73
|
+
ownerSymbol: sym,
|
|
74
|
+
children: [
|
|
75
|
+
props.abstract && code`abstract `,
|
|
76
|
+
" class ",
|
|
77
|
+
/* @__PURE__ */ jsx(Name, {}),
|
|
78
|
+
props.typeParameters && /* @__PURE__ */ jsx(TypeParameters, { parameters: props.typeParameters }),
|
|
79
|
+
extendsPart,
|
|
80
|
+
implementsPart,
|
|
81
|
+
" ",
|
|
82
|
+
/* @__PURE__ */ jsx(Block, { children: props.children })
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
})] });
|
|
73
86
|
}
|
|
74
87
|
ClassDeclaration.TypeParameters = TypeParameters;
|
|
75
88
|
/**
|
|
@@ -86,20 +99,21 @@ function ClassMember(props) {
|
|
|
86
99
|
tsFlags,
|
|
87
100
|
namePolicy: useTSNamePolicy().for("class-member-data")
|
|
88
101
|
});
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Show, {
|
|
103
|
+
when: Boolean(props.doc),
|
|
104
|
+
children: /* @__PURE__ */ jsx(TSDoc, { heading: props.doc })
|
|
105
|
+
}), /* @__PURE__ */ jsxs(MemberDeclaration, {
|
|
106
|
+
symbol: sym,
|
|
107
|
+
children: [
|
|
108
|
+
props.public && "public ",
|
|
109
|
+
props.private && "private ",
|
|
110
|
+
props.protected && "protected ",
|
|
111
|
+
props.abstract && "abstract ",
|
|
112
|
+
props.override && "override ",
|
|
113
|
+
props.static && "static ",
|
|
114
|
+
props.children
|
|
115
|
+
]
|
|
116
|
+
})] });
|
|
103
117
|
}
|
|
104
118
|
/**
|
|
105
119
|
* Generates a TypeScript class field declaration for the given reflection class.
|
|
@@ -109,16 +123,25 @@ function ClassMember(props) {
|
|
|
109
123
|
*/
|
|
110
124
|
function ClassField(props) {
|
|
111
125
|
const optionality = props.optional ? "?" : "";
|
|
112
|
-
const typeSection = props.type &&
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
const typeSection = props.type && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
|
+
optionality,
|
|
128
|
+
": ",
|
|
129
|
+
/* @__PURE__ */ jsx(TypeRefContext, { children: props.type })
|
|
130
|
+
] });
|
|
131
|
+
const initializerSection = props.children && /* @__PURE__ */ jsxs(Fragment, { children: [" = ", props.children] });
|
|
116
132
|
const nullish = props.nullish ?? props.optional;
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
return /* @__PURE__ */ jsxs(ClassMember, {
|
|
134
|
+
...props,
|
|
135
|
+
nullish,
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsx(PropertyName, {
|
|
138
|
+
private: props.isPrivateMember,
|
|
139
|
+
name: props.isPrivateMember ? props.name : void 0
|
|
140
|
+
}),
|
|
141
|
+
typeSection,
|
|
142
|
+
initializerSection
|
|
143
|
+
]
|
|
144
|
+
});
|
|
122
145
|
}
|
|
123
146
|
/**
|
|
124
147
|
* Generates a TypeScript class property setter declaration for the given reflection class.
|
|
@@ -127,19 +150,21 @@ function ClassField(props) {
|
|
|
127
150
|
* @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.
|
|
128
151
|
*/
|
|
129
152
|
function ClassPropertySet(props) {
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(ClassMember, {
|
|
154
|
+
...props,
|
|
155
|
+
children: [
|
|
156
|
+
"set ",
|
|
157
|
+
/* @__PURE__ */ jsx(PropertyName, { name: props.name }),
|
|
158
|
+
/* @__PURE__ */ jsxs(LexicalScope, { children: [
|
|
159
|
+
/* @__PURE__ */ jsx(CallSignature, { parameters: [{
|
|
160
|
+
name: "value",
|
|
161
|
+
type: /* @__PURE__ */ jsx(TypeRefContext, { children: props.type })
|
|
162
|
+
}] }),
|
|
163
|
+
" ",
|
|
164
|
+
/* @__PURE__ */ jsx(Block, { children: props.children })
|
|
165
|
+
] })
|
|
166
|
+
]
|
|
167
|
+
}) });
|
|
143
168
|
}
|
|
144
169
|
/**
|
|
145
170
|
* Generates a TypeScript class property getter declaration for the given reflection class.
|
|
@@ -148,14 +173,18 @@ function ClassPropertySet(props) {
|
|
|
148
173
|
* @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.
|
|
149
174
|
*/
|
|
150
175
|
function ClassPropertyGet(props) {
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
176
|
+
return /* @__PURE__ */ jsxs(ClassMember, {
|
|
177
|
+
...props,
|
|
178
|
+
children: [
|
|
179
|
+
"get ",
|
|
180
|
+
/* @__PURE__ */ jsx(PropertyName, { name: props.name }),
|
|
181
|
+
/* @__PURE__ */ jsxs(LexicalScope, { children: [
|
|
182
|
+
/* @__PURE__ */ jsx(CallSignature, { returnType: /* @__PURE__ */ jsx(TypeRefContext, { children: props.type }) }),
|
|
183
|
+
" ",
|
|
184
|
+
/* @__PURE__ */ jsx(Block, { children: props.children })
|
|
185
|
+
] })
|
|
186
|
+
]
|
|
187
|
+
});
|
|
159
188
|
}
|
|
160
189
|
/**
|
|
161
190
|
* Generates a TypeScript class method declaration for the given reflection class.
|
|
@@ -166,20 +195,24 @@ function ClassPropertyGet(props) {
|
|
|
166
195
|
function ClassMethod(props) {
|
|
167
196
|
const callProps = getCallSignatureProps(props);
|
|
168
197
|
const [_, rest] = splitProps(props, ["doc"]);
|
|
169
|
-
return
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
198
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Show, {
|
|
199
|
+
when: Boolean(props.doc),
|
|
200
|
+
children: /* @__PURE__ */ jsx(TSDoc, {
|
|
201
|
+
heading: props.doc,
|
|
202
|
+
children: Array.isArray(rest.parameters) && /* @__PURE__ */ jsx(TSDocParams, { parameters: rest.parameters })
|
|
203
|
+
})
|
|
204
|
+
}), /* @__PURE__ */ jsxs(ClassMember, {
|
|
205
|
+
...rest,
|
|
206
|
+
children: [
|
|
207
|
+
props.async && "async ",
|
|
208
|
+
/* @__PURE__ */ jsx(PropertyName, {}),
|
|
209
|
+
/* @__PURE__ */ jsxs(LexicalScope, { children: [
|
|
210
|
+
/* @__PURE__ */ jsx(CallSignature, { ...callProps }),
|
|
211
|
+
" ",
|
|
212
|
+
/* @__PURE__ */ jsx(Block, { children: props.children })
|
|
213
|
+
] })
|
|
214
|
+
]
|
|
215
|
+
})] });
|
|
183
216
|
}
|
|
184
217
|
|
|
185
218
|
//#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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,cAAc,MAAM,WAAW,EAAE,UAAU,MAAM,QAAQ;CAC/D,MAAM,iBAAiB,MAAM,cAAc,MAAM,WAAW,SAAS,KACnE,EAAE;OACC,IAAI;iBACM,IAAI;MACf,CAAC,IAAI,MAAM,MAAM,YAAY,MAAM,MAAM;UACtC,cAAa,UAAU;MAC1B,EAAE,IAAI;IACR;CAEF,MAAM,MAAM,yBAAyB,MAAM,MAAM;EAC/C,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,oBAAoB;EACpB,YAAY,iBAAiB,CAAC,IAAI,QAAQ;EAC3C,CAAC;AAEF,QACE,EAAE;MACA,CAAC,KAAK,MA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Aa,CAAC,CAAC,OAAO,MAAM,SAAS,EAAE,MAAM;QAClE,EAAE,aAAa;MACjB,EAAE,YAAY;IAChB"}
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,cAAc,MAAM,WAAW,4CAAE,aAAU,MAAM,QAAW;CAClE,MAAM,iBAAiB,MAAM,cAAc,MAAM,WAAW,SAAS,KACnE;EACG;EAAI;EACM;EACX,oBAAC,KAAD;GAAK,MAAM,MAAM;GAAY;GAAM;cAChC,cAAa;GACV;EACL;CAEL,MAAM,MAAM,yBAAyB,MAAM,MAAM;EAC/C,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,oBAAoB;EACpB,YAAY,iBAAiB,CAAC,IAAI,QAAQ;EAC3C,CAAC;AAEF,QACE,4CACE,oBAAC,MAAD;EAAM,MAAM,QAAQ,MAAM,IAAI;YAC5B,oBAAC,OAAD,EAAO,SAAS,MAAM,KAAO;EACxB,GACP,oBAACA,eAAD;EAAa,QAAQ;EAAK,QAAQ,MAAM;EAAQ,SAAS,MAAM;YAC7D,qBAACC,eAAD;GAAa,aAAa;aAA1B;IACG,MAAM,YAAY,IAAI;IAAY;IAAO,oBAAC,MAAD,EAAQ;IACjD,MAAM,kBACL,oBAAC,gBAAD,EAAgB,YAAY,MAAM,gBAAkB;IAErD;IACA;IAAe;IAAC,oBAAC,OAAD,YAAQ,MAAM,UAAiB;IACpC;;EACF,EACb;;AAIP,iBAAiB,iBAAiB;;;;;;;AA0BlC,SAAgB,YAAY,OAAyB;CACnD,IAAI,UAAU,cAAc;AAC5B,KAAI,MAAM,QACR,YAAW,cAAc;CAG3B,MAAM,MAAM,mBAAmB,MAAM,MAAM,OAAO;EAChD,SAAS,MAAM;EACf;EACA,YAAY,iBAAiB,CAAC,IAAI,oBAAoB;EACvD,CAAC;AA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IACH,oBAAC,OAAD,YAAQ,MAAM,UAAiB;IAClB;GACH;;;;;;;;;AAkBlB,SAAgB,YAAY,OAAyB;CACnD,MAAM,YAAY,sBAAsB,MAAM;CAC9C,MAAM,CAAC,GAAG,QAAQ,WAAW,OAAO,CAAC,MAAM,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,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let _alloy_js_core = require("@alloy-js/core");
|
|
4
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
6
|
|
|
6
7
|
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
@@ -18,7 +19,11 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
18
19
|
*/
|
|
19
20
|
function DynamicImportStatement(props) {
|
|
20
21
|
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
21
|
-
return
|
|
22
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_typescript.VarDeclaration, {
|
|
23
|
+
const: isConst,
|
|
24
|
+
...rest,
|
|
25
|
+
initializer: _alloy_js_core.code`await import("${importPath}").then(m => m.${exportName});`
|
|
26
|
+
});
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { code } from "@alloy-js/core";
|
|
2
|
+
import { jsx } from "@alloy-js/core/jsx-runtime";
|
|
2
3
|
import { VarDeclaration } from "@alloy-js/typescript";
|
|
3
4
|
|
|
4
5
|
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
@@ -16,7 +17,11 @@ import { VarDeclaration } from "@alloy-js/typescript";
|
|
|
16
17
|
*/
|
|
17
18
|
function DynamicImportStatement(props) {
|
|
18
19
|
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
19
|
-
return
|
|
20
|
+
return /* @__PURE__ */ jsx(VarDeclaration, {
|
|
21
|
+
const: isConst,
|
|
22
|
+
...rest,
|
|
23
|
+
initializer: code`await import("${importPath}").then(m => m.${exportName});`
|
|
24
|
+
});
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
//#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":";;;;;;;;;;;;;;;;;AAkDA,SAAgB,uBAAuB,OAAoC;CACzE,MAAM,EACJ,YACA,aAAa,WACb,OAAO,UAAU,MACjB,GAAG,SACD;AAEJ,QACE,oBAAC,gBAAD;EACE,OAAO;EACP,GAAI;EACJ,aAAa,IAAI,iBAAiB,WAAW,iBAAiB,WAAW;EAAsB"}
|