@powerlines/plugin-alloy 0.26.76 → 0.26.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/core/components/index.cjs +12 -1
- package/dist/core/components/index.mjs +7 -1
- package/dist/core/components/infrastructure-file.cjs +48 -1
- package/dist/core/components/infrastructure-file.mjs +45 -1
- package/dist/core/components/infrastructure-file.mjs.map +1 -1
- package/dist/core/components/output.cjs +41 -1
- package/dist/core/components/output.mjs +39 -1
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +23 -1
- package/dist/core/components/single-line-comment.mjs +21 -1
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +64 -1
- package/dist/core/components/source-file.mjs +61 -1
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +20 -1
- package/dist/core/components/spacing.mjs +18 -1
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/core/contexts/context.cjs +41 -1
- package/dist/core/contexts/context.mjs +36 -1
- package/dist/core/contexts/context.mjs.map +1 -1
- package/dist/core/contexts/index.cjs +22 -1
- package/dist/core/contexts/index.mjs +5 -1
- package/dist/core/contexts/meta.cjs +41 -1
- package/dist/core/contexts/meta.mjs +36 -1
- package/dist/core/contexts/meta.mjs.map +1 -1
- package/dist/core/contexts/reflection.cjs +80 -1
- package/dist/core/contexts/reflection.mjs +70 -1
- package/dist/core/contexts/reflection.mjs.map +1 -1
- package/dist/core/helpers/code.cjs +34 -1
- package/dist/core/helpers/code.mjs +32 -1
- package/dist/core/helpers/code.mjs.map +1 -1
- package/dist/core/helpers/index.cjs +4 -1
- package/dist/core/helpers/index.mjs +3 -1
- package/dist/core/index.cjs +37 -1
- package/dist/core/index.mjs +14 -1
- package/dist/hcl/components/block-declaration.cjs +34 -1
- package/dist/hcl/components/block-declaration.mjs +32 -1
- package/dist/hcl/components/block-declaration.mjs.map +1 -1
- package/dist/hcl/components/hcl-file.cjs +83 -1
- package/dist/hcl/components/hcl-file.mjs +80 -1
- package/dist/hcl/components/hcl-file.mjs.map +1 -1
- package/dist/hcl/components/index.cjs +11 -1
- package/dist/hcl/components/index.mjs +6 -1
- package/dist/hcl/components/packer-file.cjs +29 -1
- package/dist/hcl/components/packer-file.mjs +27 -1
- package/dist/hcl/components/packer-file.mjs.map +1 -1
- package/dist/hcl/components/terraform-file.cjs +30 -1
- package/dist/hcl/components/terraform-file.mjs +28 -1
- package/dist/hcl/components/terraform-file.mjs.map +1 -1
- package/dist/hcl/index.cjs +12 -1
- package/dist/hcl/index.mjs +7 -1
- package/dist/helpers/capnp.cjs +245 -37
- package/dist/helpers/capnp.mjs +227 -37
- package/dist/helpers/capnp.mjs.map +1 -1
- package/dist/helpers/create-builtin.cjs +20 -1
- package/dist/helpers/create-builtin.mjs +18 -1
- package/dist/helpers/create-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +25 -1
- package/dist/helpers/index.mjs +6 -1
- package/dist/helpers/refkey.cjs +17 -1
- package/dist/helpers/refkey.mjs +15 -1
- package/dist/helpers/refkey.mjs.map +1 -1
- package/dist/helpers/typescript.cjs +43 -19
- package/dist/helpers/typescript.mjs +41 -19
- package/dist/helpers/typescript.mjs.map +1 -1
- package/dist/index.cjs +55 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +29 -1
- package/dist/markdown/components/front-matter.mjs +27 -1
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/heading.cjs +24 -1
- package/dist/markdown/components/heading.mjs +22 -1
- package/dist/markdown/components/heading.mjs.map +1 -1
- package/dist/markdown/components/index.cjs +13 -1
- package/dist/markdown/components/index.mjs +6 -1
- package/dist/markdown/components/markdown-file.cjs +135 -1
- package/dist/markdown/components/markdown-file.mjs +132 -1
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +102 -1
- package/dist/markdown/components/markdown-table.mjs +98 -1
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/markdown/contexts/index.cjs +7 -1
- package/dist/markdown/contexts/index.mjs +3 -1
- package/dist/markdown/contexts/markdown-table.cjs +38 -1
- package/dist/markdown/contexts/markdown-table.mjs +33 -1
- package/dist/markdown/contexts/markdown-table.mjs.map +1 -1
- package/dist/markdown/index.cjs +20 -1
- package/dist/markdown/index.mjs +9 -1
- package/dist/render.cjs +91 -1
- package/dist/render.mjs +88 -1
- package/dist/render.mjs.map +1 -1
- package/dist/types/components.cjs +9 -0
- package/dist/types/components.mjs +9 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/typescript/components/builtin-file.cjs +63 -1
- package/dist/typescript/components/builtin-file.mjs +61 -1
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +306 -1
- package/dist/typescript/components/class-declaration.mjs +299 -1
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +26 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +24 -1
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +43 -1
- package/dist/typescript/components/entry-file.mjs +40 -1
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/index.cjs +64 -1
- package/dist/typescript/components/index.mjs +15 -1
- package/dist/typescript/components/interface-declaration.cjs +239 -1
- package/dist/typescript/components/interface-declaration.mjs +234 -1
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +139 -1
- package/dist/typescript/components/object-declaration.mjs +136 -1
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +32 -1
- package/dist/typescript/components/property-name.mjs +30 -1
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.cjs +13 -3
- package/dist/typescript/components/record-expression.mjs +11 -3
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +331 -1
- package/dist/typescript/components/tsdoc-reflection.mjs +324 -1
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +497 -1
- package/dist/typescript/components/tsdoc.mjs +475 -1
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +39 -1
- package/dist/typescript/components/type-declaration.mjs +37 -1
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +83 -1
- package/dist/typescript/components/type-parameters.mjs +81 -1
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +221 -1
- package/dist/typescript/components/typescript-file.mjs +217 -1
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/index.cjs +4 -1
- package/dist/typescript/contexts/index.mjs +3 -1
- package/dist/typescript/contexts/lexical-scope.cjs +26 -1
- package/dist/typescript/contexts/lexical-scope.mjs +24 -1
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +24 -1
- package/dist/typescript/contexts/member-scope.mjs +22 -1
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.cjs +26 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs +24 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -1
- package/dist/typescript/helpers/index.cjs +6 -1
- package/dist/typescript/helpers/index.mjs +4 -1
- package/dist/typescript/helpers/utilities.cjs +15 -1
- package/dist/typescript/helpers/utilities.mjs +13 -1
- package/dist/typescript/helpers/utilities.mjs.map +1 -1
- package/dist/typescript/index.cjs +73 -1
- package/dist/typescript/index.mjs +21 -1
- package/dist/yaml/components/index.cjs +5 -1
- package/dist/yaml/components/index.mjs +3 -1
- package/dist/yaml/components/yaml-file.cjs +149 -1
- package/dist/yaml/components/yaml-file.mjs +146 -1
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/dist/yaml/index.cjs +6 -1
- package/dist/yaml/index.mjs +4 -1
- package/package.json +6 -6
|
@@ -1,2 +1,476 @@
|
|
|
1
|
-
import{usePowerlinesSafe
|
|
1
|
+
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
|
+
import { Spacing } from "../../core/components/spacing.mjs";
|
|
3
|
+
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { For, List, Prose, Show, childrenArray, computed, splitProps } from "@alloy-js/core";
|
|
5
|
+
import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
|
|
6
|
+
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
7
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
8
|
+
|
|
9
|
+
//#region src/typescript/components/tsdoc.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Generates a TypeScript interface for the given reflection class.
|
|
12
|
+
*/
|
|
13
|
+
function TSDoc(props) {
|
|
14
|
+
const [{ children, heading }] = splitProps(props, ["children", "heading"]);
|
|
15
|
+
return [
|
|
16
|
+
"/**",
|
|
17
|
+
createIntrinsic("align", {
|
|
18
|
+
string: " * ",
|
|
19
|
+
get children() {
|
|
20
|
+
return [
|
|
21
|
+
createIntrinsic("hbr", {}),
|
|
22
|
+
createComponent(Show, {
|
|
23
|
+
get when() {
|
|
24
|
+
return !isUndefined(heading);
|
|
25
|
+
},
|
|
26
|
+
children: heading
|
|
27
|
+
}),
|
|
28
|
+
createComponent(Show, {
|
|
29
|
+
get when() {
|
|
30
|
+
return memo(() => !!!isUndefined(children))() && childrenArray(() => children).filter(Boolean).length > 0;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return [createComponent(Show, {
|
|
34
|
+
get when() {
|
|
35
|
+
return !isUndefined(heading);
|
|
36
|
+
},
|
|
37
|
+
get children() {
|
|
38
|
+
return createComponent(Spacing, {});
|
|
39
|
+
}
|
|
40
|
+
}), createComponent(List, {
|
|
41
|
+
hardline: false,
|
|
42
|
+
softline: true,
|
|
43
|
+
get children() {
|
|
44
|
+
return childrenArray(() => children);
|
|
45
|
+
}
|
|
46
|
+
})];
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
createIntrinsic("hbr", {}),
|
|
53
|
+
`*/`,
|
|
54
|
+
createIntrinsic("hbr", {})
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a TSDoc `@<props.tag>` tag.
|
|
59
|
+
*/
|
|
60
|
+
function TSDocTag(props) {
|
|
61
|
+
const [{ children, tag }] = splitProps(props, ["children", "tag"]);
|
|
62
|
+
return [
|
|
63
|
+
`@${tag} `,
|
|
64
|
+
createComponent(Show, {
|
|
65
|
+
get when() {
|
|
66
|
+
return Boolean(children);
|
|
67
|
+
},
|
|
68
|
+
get children() {
|
|
69
|
+
return createIntrinsic("align", {
|
|
70
|
+
width: 2,
|
|
71
|
+
get children() {
|
|
72
|
+
return createComponent(Prose, { children });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
createIntrinsic("sbr", {})
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A component that creates a TSDoc block with `@param` tags for each parameter.
|
|
82
|
+
*/
|
|
83
|
+
function TSDocParams(props) {
|
|
84
|
+
return createComponent(For, {
|
|
85
|
+
each: normalizeParametersForDoc(props.parameters),
|
|
86
|
+
children: (param) => createComponent(TSDocParam, {
|
|
87
|
+
get name() {
|
|
88
|
+
return param.name;
|
|
89
|
+
},
|
|
90
|
+
get optional() {
|
|
91
|
+
return param.optional;
|
|
92
|
+
},
|
|
93
|
+
get children() {
|
|
94
|
+
return param.doc;
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function normalizeParametersForDoc(parameters) {
|
|
100
|
+
if (parameters.some((p) => typeof p === "string")) return [];
|
|
101
|
+
return parameters;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Create a TSDoc `@title` tag.
|
|
105
|
+
*/
|
|
106
|
+
function TSDocTitle(props) {
|
|
107
|
+
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
108
|
+
return createComponent(TSDocTag, mergeProps(rest, {
|
|
109
|
+
tag: "title",
|
|
110
|
+
children
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a TSDoc `@domain` tag.
|
|
115
|
+
*/
|
|
116
|
+
function TSDocDomain(props) {
|
|
117
|
+
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
118
|
+
return createComponent(TSDocTag, mergeProps(rest, {
|
|
119
|
+
tag: "domain",
|
|
120
|
+
children
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create a TSDoc `@alias` tag.
|
|
125
|
+
*/
|
|
126
|
+
function TSDocAlias(props) {
|
|
127
|
+
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
128
|
+
return createComponent(TSDocTag, mergeProps(rest, {
|
|
129
|
+
tag: "alias",
|
|
130
|
+
children
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a TSDoc `@permission` tag.
|
|
135
|
+
*/
|
|
136
|
+
function TSDocPermission(props) {
|
|
137
|
+
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
138
|
+
return createComponent(TSDocTag, mergeProps(rest, {
|
|
139
|
+
tag: "permission",
|
|
140
|
+
children
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a TSDoc `@defaultValue` tag.
|
|
145
|
+
*/
|
|
146
|
+
function TSDocDefaultValue(props) {
|
|
147
|
+
const [{ type, defaultValue }] = splitProps(props, ["type", "defaultValue"]);
|
|
148
|
+
return ["@defaultValue ", createComponent(Show, {
|
|
149
|
+
get when() {
|
|
150
|
+
return !isUndefined(defaultValue);
|
|
151
|
+
},
|
|
152
|
+
get children() {
|
|
153
|
+
return createIntrinsic("align", {
|
|
154
|
+
width: 2,
|
|
155
|
+
get children() {
|
|
156
|
+
return createComponent(Prose, { get children() {
|
|
157
|
+
return stringifyDefaultValue(type, defaultValue);
|
|
158
|
+
} });
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
})];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Create a TSDoc `@remarks` tag.
|
|
166
|
+
*/
|
|
167
|
+
function TSDocRemarks(props) {
|
|
168
|
+
return [
|
|
169
|
+
"@remarks ",
|
|
170
|
+
createIntrinsic("hbr", {}),
|
|
171
|
+
createComponent(List, {
|
|
172
|
+
hardline: false,
|
|
173
|
+
softline: true,
|
|
174
|
+
get children() {
|
|
175
|
+
return childrenArray(() => props.children);
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Create a TSDoc `@see` tag.
|
|
182
|
+
*/
|
|
183
|
+
function TSDocLink(props) {
|
|
184
|
+
return createComponent(TSDocTag, mergeProps(props, { tag: "see" }));
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Create a TSDoc `@example` tag.
|
|
188
|
+
*/
|
|
189
|
+
function TSDocExample(props) {
|
|
190
|
+
const [{ tsx, fenced = true, language, children }] = splitProps(props, [
|
|
191
|
+
"tsx",
|
|
192
|
+
"fenced",
|
|
193
|
+
"language",
|
|
194
|
+
"children"
|
|
195
|
+
]);
|
|
196
|
+
return [
|
|
197
|
+
"@example ",
|
|
198
|
+
createIntrinsic("hbr", {}),
|
|
199
|
+
createComponent(Show, {
|
|
200
|
+
when: fenced,
|
|
201
|
+
get children() {
|
|
202
|
+
return [
|
|
203
|
+
"```",
|
|
204
|
+
language || (tsx ? "tsx" : "ts"),
|
|
205
|
+
createIntrinsic("hbr", {})
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
}),
|
|
209
|
+
children,
|
|
210
|
+
createComponent(Show, {
|
|
211
|
+
when: fenced,
|
|
212
|
+
get children() {
|
|
213
|
+
return [createIntrinsic("hbr", {}), "```"];
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create a TSDoc `@readonly` tag.
|
|
220
|
+
*/
|
|
221
|
+
function TSDocReadonly() {
|
|
222
|
+
return createComponent(TSDocTag, { tag: "readonly" });
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Create a TSDoc `@internal` tag.
|
|
226
|
+
*/
|
|
227
|
+
function TSDocInternal() {
|
|
228
|
+
return createComponent(TSDocTag, { tag: "internal" });
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create a TSDoc `@ignore` tag.
|
|
232
|
+
*/
|
|
233
|
+
function TSDocIgnore() {
|
|
234
|
+
return createComponent(TSDocTag, { tag: "ignore" });
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Create a TSDoc `@hidden` tag.
|
|
238
|
+
*/
|
|
239
|
+
function TSDocHidden() {
|
|
240
|
+
return createComponent(TSDocTag, { tag: "hidden" });
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create a TSDoc `@runtime` tag.
|
|
244
|
+
*/
|
|
245
|
+
function TSDocRuntime() {
|
|
246
|
+
return createComponent(TSDocTag, { tag: "runtime" });
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
250
|
+
*/
|
|
251
|
+
function TSDocAttributesTags(props) {
|
|
252
|
+
const [{ type, alias, permission, readonly, internal, ignore, hidden, runtime, defaultValue }] = splitProps(props, [
|
|
253
|
+
"type",
|
|
254
|
+
"alias",
|
|
255
|
+
"permission",
|
|
256
|
+
"readonly",
|
|
257
|
+
"internal",
|
|
258
|
+
"ignore",
|
|
259
|
+
"hidden",
|
|
260
|
+
"runtime",
|
|
261
|
+
"defaultValue"
|
|
262
|
+
]);
|
|
263
|
+
const title = computed(() => props.title?.trim() || "");
|
|
264
|
+
const domain = computed(() => props.domain?.trim() || "");
|
|
265
|
+
return [
|
|
266
|
+
createComponent(Show, {
|
|
267
|
+
get when() {
|
|
268
|
+
return isSetString(title.value);
|
|
269
|
+
},
|
|
270
|
+
get children() {
|
|
271
|
+
return createComponent(TSDocTitle, { get children() {
|
|
272
|
+
return title.value;
|
|
273
|
+
} });
|
|
274
|
+
}
|
|
275
|
+
}),
|
|
276
|
+
createComponent(Show, {
|
|
277
|
+
get when() {
|
|
278
|
+
return memo(() => !!(!isUndefined(alias) && alias.length > 0))() && alias.some((a) => isSetString(a?.trim()));
|
|
279
|
+
},
|
|
280
|
+
get children() {
|
|
281
|
+
return createComponent(For, {
|
|
282
|
+
get each() {
|
|
283
|
+
return alias?.filter((a) => isSetString(a?.trim())) ?? [];
|
|
284
|
+
},
|
|
285
|
+
children: (alias) => createComponent(TSDocAlias, { children: alias })
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}),
|
|
289
|
+
createComponent(Show, {
|
|
290
|
+
get when() {
|
|
291
|
+
return isSetString(domain.value);
|
|
292
|
+
},
|
|
293
|
+
get children() {
|
|
294
|
+
return createComponent(TSDocDomain, { get children() {
|
|
295
|
+
return domain.value;
|
|
296
|
+
} });
|
|
297
|
+
}
|
|
298
|
+
}),
|
|
299
|
+
createComponent(Show, {
|
|
300
|
+
get when() {
|
|
301
|
+
return memo(() => !!(!isUndefined(permission) && permission.length > 0))() && permission.some((p) => isSetString(p?.trim()));
|
|
302
|
+
},
|
|
303
|
+
get children() {
|
|
304
|
+
return createComponent(For, {
|
|
305
|
+
get each() {
|
|
306
|
+
return permission?.filter((p) => isSetString(p?.trim())) ?? [];
|
|
307
|
+
},
|
|
308
|
+
children: (permission) => createComponent(TSDocPermission, { children: permission })
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}),
|
|
312
|
+
createComponent(Show, {
|
|
313
|
+
when: readonly === true,
|
|
314
|
+
get children() {
|
|
315
|
+
return createComponent(TSDocReadonly, {});
|
|
316
|
+
}
|
|
317
|
+
}),
|
|
318
|
+
createComponent(Show, {
|
|
319
|
+
when: internal === true,
|
|
320
|
+
get children() {
|
|
321
|
+
return createComponent(TSDocInternal, {});
|
|
322
|
+
}
|
|
323
|
+
}),
|
|
324
|
+
createComponent(Show, {
|
|
325
|
+
when: ignore === true,
|
|
326
|
+
get children() {
|
|
327
|
+
return createComponent(TSDocIgnore, {});
|
|
328
|
+
}
|
|
329
|
+
}),
|
|
330
|
+
createComponent(Show, {
|
|
331
|
+
when: hidden === true,
|
|
332
|
+
get children() {
|
|
333
|
+
return createComponent(TSDocHidden, {});
|
|
334
|
+
}
|
|
335
|
+
}),
|
|
336
|
+
createComponent(Show, {
|
|
337
|
+
when: runtime === true,
|
|
338
|
+
get children() {
|
|
339
|
+
return createComponent(TSDocRuntime, {});
|
|
340
|
+
}
|
|
341
|
+
}),
|
|
342
|
+
createComponent(Show, {
|
|
343
|
+
get when() {
|
|
344
|
+
return memo(() => !!(runtime !== true && !isUndefined(type)))() && !isUndefined(defaultValue);
|
|
345
|
+
},
|
|
346
|
+
get children() {
|
|
347
|
+
return createComponent(TSDocDefaultValue, {
|
|
348
|
+
type,
|
|
349
|
+
defaultValue
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
];
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Create a TSDoc parameter set off with `@param`.
|
|
357
|
+
*/
|
|
358
|
+
function TSDocParam(props) {
|
|
359
|
+
return [
|
|
360
|
+
"@param ",
|
|
361
|
+
createComponent(TSDocParamName, {
|
|
362
|
+
get name() {
|
|
363
|
+
return props.name;
|
|
364
|
+
},
|
|
365
|
+
get optional() {
|
|
366
|
+
return props.optional;
|
|
367
|
+
},
|
|
368
|
+
get defaultValue() {
|
|
369
|
+
return props.defaultValue;
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
createComponent(TSDocParamDescription, { get children() {
|
|
373
|
+
return props.children;
|
|
374
|
+
} })
|
|
375
|
+
];
|
|
376
|
+
}
|
|
377
|
+
function TSDocParamName(props) {
|
|
378
|
+
return [
|
|
379
|
+
createComponent(Show, {
|
|
380
|
+
get when() {
|
|
381
|
+
return props.optional;
|
|
382
|
+
},
|
|
383
|
+
children: "["
|
|
384
|
+
}),
|
|
385
|
+
memo(() => props.name),
|
|
386
|
+
createComponent(Show, {
|
|
387
|
+
get when() {
|
|
388
|
+
return Boolean(props.defaultValue);
|
|
389
|
+
},
|
|
390
|
+
get children() {
|
|
391
|
+
return ["=", memo(() => props.defaultValue)];
|
|
392
|
+
}
|
|
393
|
+
}),
|
|
394
|
+
createComponent(Show, {
|
|
395
|
+
get when() {
|
|
396
|
+
return props.optional;
|
|
397
|
+
},
|
|
398
|
+
children: "]"
|
|
399
|
+
})
|
|
400
|
+
];
|
|
401
|
+
}
|
|
402
|
+
function TSDocParamDescription(props) {
|
|
403
|
+
return createComponent(Show, {
|
|
404
|
+
get when() {
|
|
405
|
+
return Boolean(props.children);
|
|
406
|
+
},
|
|
407
|
+
get children() {
|
|
408
|
+
return [" - ", createIntrinsic("align", {
|
|
409
|
+
width: 2,
|
|
410
|
+
get children() {
|
|
411
|
+
return createComponent(Prose, { get children() {
|
|
412
|
+
return props.children;
|
|
413
|
+
} });
|
|
414
|
+
}
|
|
415
|
+
})];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Create a TSDoc `@returns` tag.
|
|
421
|
+
*/
|
|
422
|
+
function TSDocReturns(props) {
|
|
423
|
+
return createComponent(TSDocTag, mergeProps(props, { tag: "returns" }));
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Create a TSDoc `@throws` tag.
|
|
427
|
+
*/
|
|
428
|
+
function TSDocThrows(props) {
|
|
429
|
+
return createComponent(TSDocTag, mergeProps(props, { tag: "throws" }));
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Generates a TSDoc `@module` tag for the given module name.
|
|
433
|
+
*/
|
|
434
|
+
function TSDocModule(props) {
|
|
435
|
+
const [{ children, name, prefix }] = splitProps(props, [
|
|
436
|
+
"children",
|
|
437
|
+
"name",
|
|
438
|
+
"prefix"
|
|
439
|
+
]);
|
|
440
|
+
const context = usePowerlinesSafe();
|
|
441
|
+
return [
|
|
442
|
+
"/**",
|
|
443
|
+
createIntrinsic("align", {
|
|
444
|
+
string: " * ",
|
|
445
|
+
get children() {
|
|
446
|
+
return [
|
|
447
|
+
createIntrinsic("hbr", {}),
|
|
448
|
+
createComponent(Show, {
|
|
449
|
+
get when() {
|
|
450
|
+
return Boolean(children);
|
|
451
|
+
},
|
|
452
|
+
get children() {
|
|
453
|
+
return [createComponent(List, {
|
|
454
|
+
hardline: false,
|
|
455
|
+
softline: true,
|
|
456
|
+
get children() {
|
|
457
|
+
return childrenArray(() => children);
|
|
458
|
+
}
|
|
459
|
+
}), createComponent(Spacing, {})];
|
|
460
|
+
}
|
|
461
|
+
}),
|
|
462
|
+
"@module ",
|
|
463
|
+
memo(() => prefix || context?.config?.framework || "powerlines"),
|
|
464
|
+
":",
|
|
465
|
+
name
|
|
466
|
+
];
|
|
467
|
+
}
|
|
468
|
+
}),
|
|
469
|
+
createIntrinsic("hbr", {}),
|
|
470
|
+
` */`
|
|
471
|
+
];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
//#endregion
|
|
475
|
+
export { TSDoc, TSDocAlias, TSDocAttributesTags, TSDocDefaultValue, TSDocDomain, TSDocExample, TSDocHidden, TSDocIgnore, TSDocInternal, TSDocLink, TSDocModule, TSDocParam, TSDocParams, TSDocPermission, TSDocReadonly, TSDocRemarks, TSDocReturns, TSDocRuntime, TSDocTag, TSDocThrows, TSDocTitle };
|
|
2
476
|
//# sourceMappingURL=tsdoc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc.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 Children,\n childrenArray,\n computed,\n For,\n List,\n Prose,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport { JSDocExampleProps, ParameterDescriptor } from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport {\n ReflectionKind,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport interface TSDocProps extends ComponentProps {\n heading?: Children;\n}\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function TSDoc(props: TSDocProps) {\n const [{ children, heading }] = splitProps(props, [\"children\", \"heading\"]);\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={!isUndefined(heading)}>{heading}</Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={!isUndefined(heading)}>\n <Spacing />\n </Show>\n <List hardline={false} softline={true}>\n {childrenArray(() => children)}\n </List>\n </Show>\n </align>\n <hbr />\n {`*/`}\n <hbr />\n </>\n );\n}\n\nexport interface TSDocTagProps extends ComponentProps {\n tag: string;\n}\n\n/**\n * Create a TSDoc `@<props.tag>` tag.\n */\nexport function TSDocTag(props: TSDocTagProps) {\n const [{ children, tag }] = splitProps(props, [\"children\", \"tag\"]);\n\n return (\n <>\n {`@${tag} `}\n <Show when={Boolean(children)}>\n <align width={2}>\n <Prose>{children}</Prose>\n </align>\n </Show>\n <sbr />\n </>\n );\n}\n\nexport interface TSDocParamsProps {\n parameters: ParameterDescriptor[] | string[];\n}\n\n/**\n * A component that creates a TSDoc block with `@param` tags for each parameter.\n */\nexport function TSDocParams(props: TSDocParamsProps) {\n const parameters = normalizeParametersForDoc(props.parameters);\n\n return (\n <For each={parameters}>\n {param => (\n <TSDocParam name={param.name} optional={param.optional}>\n {param.doc}\n </TSDocParam>\n )}\n </For>\n );\n}\n\nfunction normalizeParametersForDoc(\n parameters: ParameterDescriptor[] | string[]\n): ParameterDescriptor[] {\n if (parameters.some(p => typeof p === \"string\")) {\n return [];\n }\n\n return parameters as ParameterDescriptor[];\n}\n\n/**\n * Create a TSDoc `@title` tag.\n */\nexport function TSDocTitle(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"title\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@domain` tag.\n */\nexport function TSDocDomain(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"domain\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@alias` tag.\n */\nexport function TSDocAlias(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"alias\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@permission` tag.\n */\nexport function TSDocPermission(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"permission\">\n {children}\n </TSDocTag>\n );\n}\n\nexport interface TSDocDefaultValueProps extends ComponentProps {\n type: ReflectionKind | ReflectionProperty | ReflectionParameter;\n defaultValue: any;\n}\n\n/**\n * Create a TSDoc `@defaultValue` tag.\n */\nexport function TSDocDefaultValue(props: TSDocDefaultValueProps) {\n const [{ type, defaultValue }] = splitProps(props, [\"type\", \"defaultValue\"]);\n\n return (\n <>\n {\"@defaultValue \"}\n <Show when={!isUndefined(defaultValue)}>\n <align width={2}>\n <Prose>{stringifyDefaultValue(type, defaultValue)}</Prose>\n </align>\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@remarks` tag.\n */\nexport function TSDocRemarks(props: ComponentProps) {\n return (\n <>\n {\"@remarks \"}\n <hbr />\n <List hardline={false} softline={true}>\n {childrenArray(() => props.children)}\n </List>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@see` tag.\n */\nexport function TSDocLink(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"see\" />;\n}\n\nexport interface TSDocExampleProps extends JSDocExampleProps {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n}\n\n/**\n * Create a TSDoc `@example` tag.\n */\nexport function TSDocExample(props: TSDocExampleProps) {\n const [{ tsx, fenced = true, language, children }] = splitProps(props, [\n \"tsx\",\n \"fenced\",\n \"language\",\n \"children\"\n ]);\n\n return (\n <>\n {\"@example \"}\n <hbr />\n <Show when={fenced}>\n ```{language || (tsx ? \"tsx\" : \"ts\")}\n <hbr />\n </Show>\n {children}\n <Show when={fenced}>\n <hbr />\n ```\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@readonly` tag.\n */\nexport function TSDocReadonly() {\n return <TSDocTag tag=\"readonly\" />;\n}\n\n/**\n * Create a TSDoc `@internal` tag.\n */\nexport function TSDocInternal() {\n return <TSDocTag tag=\"internal\" />;\n}\n\n/**\n * Create a TSDoc `@ignore` tag.\n */\nexport function TSDocIgnore() {\n return <TSDocTag tag=\"ignore\" />;\n}\n\n/**\n * Create a TSDoc `@hidden` tag.\n */\nexport function TSDocHidden() {\n return <TSDocTag tag=\"hidden\" />;\n}\n\n/**\n * Create a TSDoc `@runtime` tag.\n */\nexport function TSDocRuntime() {\n return <TSDocTag tag=\"runtime\" />;\n}\n\nexport interface TSDocAttributesTagsProps {\n type?: ReflectionKind | ReflectionProperty | ReflectionParameter;\n title?: string;\n alias?: string[];\n permission?: string[];\n domain?: string;\n readonly?: boolean;\n internal?: boolean;\n ignore?: boolean;\n hidden?: boolean;\n runtime?: boolean;\n defaultValue?: any;\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function TSDocAttributesTags(props: TSDocAttributesTagsProps) {\n const [\n {\n type,\n alias,\n permission,\n readonly,\n internal,\n ignore,\n hidden,\n runtime,\n defaultValue\n }\n ] = splitProps(props, [\n \"type\",\n \"alias\",\n \"permission\",\n \"readonly\",\n \"internal\",\n \"ignore\",\n \"hidden\",\n \"runtime\",\n \"defaultValue\"\n ]);\n\n const title = computed(() => props.title?.trim() || \"\");\n const domain = computed(() => props.domain?.trim() || \"\");\n\n return (\n <>\n <Show when={isSetString(title.value)}>\n <TSDocTitle>{title.value}</TSDocTitle>\n </Show>\n <Show\n when={\n !isUndefined(alias) &&\n alias.length > 0 &&\n alias.some(a => isSetString(a?.trim()))\n }>\n <For each={alias?.filter(a => isSetString(a?.trim())) ?? []}>\n {alias => <TSDocAlias>{alias}</TSDocAlias>}\n </For>\n </Show>\n <Show when={isSetString(domain.value)}>\n <TSDocDomain>{domain.value}</TSDocDomain>\n </Show>\n <Show\n when={\n !isUndefined(permission) &&\n permission.length > 0 &&\n permission.some(p => isSetString(p?.trim()))\n }>\n <For each={permission?.filter(p => isSetString(p?.trim())) ?? []}>\n {permission => <TSDocPermission>{permission}</TSDocPermission>}\n </For>\n </Show>\n <Show when={readonly === true}>\n <TSDocReadonly />\n </Show>\n <Show when={internal === true}>\n <TSDocInternal />\n </Show>\n <Show when={ignore === true}>\n <TSDocIgnore />\n </Show>\n <Show when={hidden === true}>\n <TSDocHidden />\n </Show>\n <Show when={runtime === true}>\n <TSDocRuntime />\n </Show>\n <Show\n when={\n runtime !== true && !isUndefined(type) && !isUndefined(defaultValue)\n }>\n <TSDocDefaultValue\n type={\n type as ReflectionKind | ReflectionProperty | ReflectionParameter\n }\n defaultValue={defaultValue}\n />\n </Show>\n </>\n );\n}\n\nexport interface TSDocParamProps {\n name: Children;\n children?: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\n/**\n * Create a TSDoc parameter set off with `@param`.\n */\nexport function TSDocParam(props: TSDocParamProps) {\n return (\n <>\n {\"@param \"}\n <TSDocParamName\n name={props.name}\n optional={props.optional}\n defaultValue={props.defaultValue}\n />\n <TSDocParamDescription children={props.children} />\n </>\n );\n}\n\ninterface TSDocParamNameProps {\n name: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\nfunction TSDocParamName(props: TSDocParamNameProps) {\n return (\n <>\n <Show when={props.optional}>{\"[\"}</Show>\n {props.name}\n <Show when={Boolean(props.defaultValue)}>={props.defaultValue}</Show>\n <Show when={props.optional}>{\"]\"}</Show>\n </>\n );\n}\n\ninterface TSDocParamDescriptionProps {\n children?: Children;\n}\n\nfunction TSDocParamDescription(props: TSDocParamDescriptionProps) {\n return (\n <Show when={Boolean(props.children)}>\n {\" - \"}\n <align width={2}>\n <Prose>{props.children}</Prose>\n </align>\n </Show>\n );\n}\n\n/**\n * Create a TSDoc `@returns` tag.\n */\nexport function TSDocReturns(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"returns\" />;\n}\n\n/**\n * Create a TSDoc `@throws` tag.\n */\nexport function TSDocThrows(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"throws\" />;\n}\n\nexport interface TSDocModuleProps extends ComponentProps {\n /**\n * The prefix for the builtin module name\n *\n * @remarks\n * This value is populated from the Powerlines configuration output builtin prefix by default.\n *\n * @example\n * ```ts\n * /**\n * @module powerlines:my-module\n * \\/\n * ```\n */\n prefix?: string;\n\n /**\n * The name of the module\n *\n * @remarks\n * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.\n *\n * @example\n * ```ts\n * import { MyModule } from \"powerlines:my-module\";\n * ```\n */\n name: Children;\n}\n\n/**\n * Generates a TSDoc `@module` tag for the given module name.\n */\nexport function TSDocModule(props: TSDocModuleProps) {\n const [{ children, name, prefix }] = splitProps(props, [\n \"children\",\n \"name\",\n \"prefix\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={Boolean(children)}>\n <List hardline={false} softline={true}>\n {childrenArray(() => children)}\n </List>\n <Spacing />\n </Show>\n {\"@module \"}\n {prefix || context?.config?.framework || \"powerlines\"}:{name}\n </align>\n <hbr />\n {` */`}\n </>\n );\n}\n"],"mappings":"siBA+BA,SAAgB,EAAA,EAAA,CACd,GAAA,CAAA,CACA,WACA,YACK,EAAE,EAAc,CAAA,WAAc,UAAW,CAAC,CACjD,MAAS,CAAA,MAAA,EAAqB,QAAY,CAC1C,OAAS,MACT,IAAQ,UAAC,CACH,MAAG,CAAA,EAAuB,MAAM,EAAA,CAAA,CAAM,EAAW,EAAA,YAEhD,MAAU,CAAA,EAAW,EAAQ,EAEpC,SAAA,SAEE,IAAA,MAAA,CACC,OAAY,MAAW,CAAA,EAAkB,EAAM,CAAA,EAAA,EAAW,MAAK,EAAA,CAAA,OAAA,QAAA,CAAA,OAAA,GAE3D,IAAA,UAAe,CACZ,MAAC,CAAA,EAAuB,EAAA,YAEzB,MAAA,CAAA,EAAA,EAAA,EAED,IAAA,UAAA,CACK,OAAQ,EAAI,EAAA,EAAA,CAAA,EAEhB,CAAA,CAAK,EAAkB,EAAC,CACxB,SAAA,GAC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I,UAAU,CACZ,MAAE,CAAA,IAAA,MAAoB,EAAA,aAAY,CAAA,EAErC,CAAC,CAAE,EAAC,EAAsB,CACzB,IAAE,MAAA,CACH,OAAA,EAAA,uBAGH,CAAA,CAAA,CAEA,SAAE,EAAkB,EAAA,CAClB,OAAA,EAAuB,EAAA,CACzB,IAAA,MAAA,qBAGE,IAAM,UAAC,CACJ,MAAA,CAAA,MAAA,EAAA,QAAA,CACE,MAAK,EACL,IAAK,UAAK,CACV,OAAU,EAAe,EAAA,CACpB,IAAI,UAAQ,CAClB,OAAA,EAAA,UAEN,CAAA,EAEA,CAAA,CAAS,EAET,CAAA,CAMA,SAAa,EAAS,EAAA,CACpB,OAAO,EAAa,EAAW,EAAK,EAAA,CAClC,IAAI,UACL,CAAC,CAAC,CAML,SAAE,EAAA,EAAA,CACF,OAAO,EAAS,EAAoB,EAAc,EAAE,CAClD,IAAO,SACT,CAAA,CAAA,CAKA,SAAgB,EAAY,EAAO,CACjC,GAAM,CAAC,CACT,WAAA,OAEA,WACI,EAAA,EAAA,CAAA,WAAA,OAAA,SAAA,CAAA,CACI,EAAQ,GAAgB,CAC9B,MAAC,CAAA,MAAA,EAAA,QAAA,CACC,OAAE,MACF,IAAC,UAAc,CAChB,MAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACG,IAAA,MAAA,CACE,MAAA,EAAA,GAED,IAAA,UAAO,CACP,MAAA,CAAA,EAAA,EAAA,CACA,SAAA,GACH,SAAA,GACO,IAAA,UAAM,kBAGR,CAAA,CAAK,EAAO,EAAA,EAAA,CAAA,CAAA,EAEf,CAAA,CAAA,WAAA,MAAA,GAAA,GAAA,QAAA,WAAA,aAAA,CAAA,IAAA,EAAA,EAEH,CAAA,CAAA,EAAA,MAAA,EAAA,CAAA,CAAA,MAAA"}
|
|
1
|
+
{"version":3,"file":"tsdoc.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc.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 Children,\n childrenArray,\n computed,\n For,\n List,\n Prose,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport { JSDocExampleProps, ParameterDescriptor } from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport {\n ReflectionKind,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport interface TSDocProps extends ComponentProps {\n heading?: Children;\n}\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function TSDoc(props: TSDocProps) {\n const [{ children, heading }] = splitProps(props, [\"children\", \"heading\"]);\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={!isUndefined(heading)}>{heading}</Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={!isUndefined(heading)}>\n <Spacing />\n </Show>\n <List hardline={false} softline={true}>\n {childrenArray(() => children)}\n </List>\n </Show>\n </align>\n <hbr />\n {`*/`}\n <hbr />\n </>\n );\n}\n\nexport interface TSDocTagProps extends ComponentProps {\n tag: string;\n}\n\n/**\n * Create a TSDoc `@<props.tag>` tag.\n */\nexport function TSDocTag(props: TSDocTagProps) {\n const [{ children, tag }] = splitProps(props, [\"children\", \"tag\"]);\n\n return (\n <>\n {`@${tag} `}\n <Show when={Boolean(children)}>\n <align width={2}>\n <Prose>{children}</Prose>\n </align>\n </Show>\n <sbr />\n </>\n );\n}\n\nexport interface TSDocParamsProps {\n parameters: ParameterDescriptor[] | string[];\n}\n\n/**\n * A component that creates a TSDoc block with `@param` tags for each parameter.\n */\nexport function TSDocParams(props: TSDocParamsProps) {\n const parameters = normalizeParametersForDoc(props.parameters);\n\n return (\n <For each={parameters}>\n {param => (\n <TSDocParam name={param.name} optional={param.optional}>\n {param.doc}\n </TSDocParam>\n )}\n </For>\n );\n}\n\nfunction normalizeParametersForDoc(\n parameters: ParameterDescriptor[] | string[]\n): ParameterDescriptor[] {\n if (parameters.some(p => typeof p === \"string\")) {\n return [];\n }\n\n return parameters as ParameterDescriptor[];\n}\n\n/**\n * Create a TSDoc `@title` tag.\n */\nexport function TSDocTitle(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"title\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@domain` tag.\n */\nexport function TSDocDomain(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"domain\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@alias` tag.\n */\nexport function TSDocAlias(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"alias\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@permission` tag.\n */\nexport function TSDocPermission(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"permission\">\n {children}\n </TSDocTag>\n );\n}\n\nexport interface TSDocDefaultValueProps extends ComponentProps {\n type: ReflectionKind | ReflectionProperty | ReflectionParameter;\n defaultValue: any;\n}\n\n/**\n * Create a TSDoc `@defaultValue` tag.\n */\nexport function TSDocDefaultValue(props: TSDocDefaultValueProps) {\n const [{ type, defaultValue }] = splitProps(props, [\"type\", \"defaultValue\"]);\n\n return (\n <>\n {\"@defaultValue \"}\n <Show when={!isUndefined(defaultValue)}>\n <align width={2}>\n <Prose>{stringifyDefaultValue(type, defaultValue)}</Prose>\n </align>\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@remarks` tag.\n */\nexport function TSDocRemarks(props: ComponentProps) {\n return (\n <>\n {\"@remarks \"}\n <hbr />\n <List hardline={false} softline={true}>\n {childrenArray(() => props.children)}\n </List>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@see` tag.\n */\nexport function TSDocLink(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"see\" />;\n}\n\nexport interface TSDocExampleProps extends JSDocExampleProps {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n}\n\n/**\n * Create a TSDoc `@example` tag.\n */\nexport function TSDocExample(props: TSDocExampleProps) {\n const [{ tsx, fenced = true, language, children }] = splitProps(props, [\n \"tsx\",\n \"fenced\",\n \"language\",\n \"children\"\n ]);\n\n return (\n <>\n {\"@example \"}\n <hbr />\n <Show when={fenced}>\n ```{language || (tsx ? \"tsx\" : \"ts\")}\n <hbr />\n </Show>\n {children}\n <Show when={fenced}>\n <hbr />\n ```\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@readonly` tag.\n */\nexport function TSDocReadonly() {\n return <TSDocTag tag=\"readonly\" />;\n}\n\n/**\n * Create a TSDoc `@internal` tag.\n */\nexport function TSDocInternal() {\n return <TSDocTag tag=\"internal\" />;\n}\n\n/**\n * Create a TSDoc `@ignore` tag.\n */\nexport function TSDocIgnore() {\n return <TSDocTag tag=\"ignore\" />;\n}\n\n/**\n * Create a TSDoc `@hidden` tag.\n */\nexport function TSDocHidden() {\n return <TSDocTag tag=\"hidden\" />;\n}\n\n/**\n * Create a TSDoc `@runtime` tag.\n */\nexport function TSDocRuntime() {\n return <TSDocTag tag=\"runtime\" />;\n}\n\nexport interface TSDocAttributesTagsProps {\n type?: ReflectionKind | ReflectionProperty | ReflectionParameter;\n title?: string;\n alias?: string[];\n permission?: string[];\n domain?: string;\n readonly?: boolean;\n internal?: boolean;\n ignore?: boolean;\n hidden?: boolean;\n runtime?: boolean;\n defaultValue?: any;\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function TSDocAttributesTags(props: TSDocAttributesTagsProps) {\n const [\n {\n type,\n alias,\n permission,\n readonly,\n internal,\n ignore,\n hidden,\n runtime,\n defaultValue\n }\n ] = splitProps(props, [\n \"type\",\n \"alias\",\n \"permission\",\n \"readonly\",\n \"internal\",\n \"ignore\",\n \"hidden\",\n \"runtime\",\n \"defaultValue\"\n ]);\n\n const title = computed(() => props.title?.trim() || \"\");\n const domain = computed(() => props.domain?.trim() || \"\");\n\n return (\n <>\n <Show when={isSetString(title.value)}>\n <TSDocTitle>{title.value}</TSDocTitle>\n </Show>\n <Show\n when={\n !isUndefined(alias) &&\n alias.length > 0 &&\n alias.some(a => isSetString(a?.trim()))\n }>\n <For each={alias?.filter(a => isSetString(a?.trim())) ?? []}>\n {alias => <TSDocAlias>{alias}</TSDocAlias>}\n </For>\n </Show>\n <Show when={isSetString(domain.value)}>\n <TSDocDomain>{domain.value}</TSDocDomain>\n </Show>\n <Show\n when={\n !isUndefined(permission) &&\n permission.length > 0 &&\n permission.some(p => isSetString(p?.trim()))\n }>\n <For each={permission?.filter(p => isSetString(p?.trim())) ?? []}>\n {permission => <TSDocPermission>{permission}</TSDocPermission>}\n </For>\n </Show>\n <Show when={readonly === true}>\n <TSDocReadonly />\n </Show>\n <Show when={internal === true}>\n <TSDocInternal />\n </Show>\n <Show when={ignore === true}>\n <TSDocIgnore />\n </Show>\n <Show when={hidden === true}>\n <TSDocHidden />\n </Show>\n <Show when={runtime === true}>\n <TSDocRuntime />\n </Show>\n <Show\n when={\n runtime !== true && !isUndefined(type) && !isUndefined(defaultValue)\n }>\n <TSDocDefaultValue\n type={\n type as ReflectionKind | ReflectionProperty | ReflectionParameter\n }\n defaultValue={defaultValue}\n />\n </Show>\n </>\n );\n}\n\nexport interface TSDocParamProps {\n name: Children;\n children?: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\n/**\n * Create a TSDoc parameter set off with `@param`.\n */\nexport function TSDocParam(props: TSDocParamProps) {\n return (\n <>\n {\"@param \"}\n <TSDocParamName\n name={props.name}\n optional={props.optional}\n defaultValue={props.defaultValue}\n />\n <TSDocParamDescription children={props.children} />\n </>\n );\n}\n\ninterface TSDocParamNameProps {\n name: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\nfunction TSDocParamName(props: TSDocParamNameProps) {\n return (\n <>\n <Show when={props.optional}>{\"[\"}</Show>\n {props.name}\n <Show when={Boolean(props.defaultValue)}>={props.defaultValue}</Show>\n <Show when={props.optional}>{\"]\"}</Show>\n </>\n );\n}\n\ninterface TSDocParamDescriptionProps {\n children?: Children;\n}\n\nfunction TSDocParamDescription(props: TSDocParamDescriptionProps) {\n return (\n <Show when={Boolean(props.children)}>\n {\" - \"}\n <align width={2}>\n <Prose>{props.children}</Prose>\n </align>\n </Show>\n );\n}\n\n/**\n * Create a TSDoc `@returns` tag.\n */\nexport function TSDocReturns(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"returns\" />;\n}\n\n/**\n * Create a TSDoc `@throws` tag.\n */\nexport function TSDocThrows(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"throws\" />;\n}\n\nexport interface TSDocModuleProps extends ComponentProps {\n /**\n * The prefix for the builtin module name\n *\n * @remarks\n * This value is populated from the Powerlines configuration output builtin prefix by default.\n *\n * @example\n * ```ts\n * /**\n * @module powerlines:my-module\n * \\/\n * ```\n */\n prefix?: string;\n\n /**\n * The name of the module\n *\n * @remarks\n * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.\n *\n * @example\n * ```ts\n * import { MyModule } from \"powerlines:my-module\";\n * ```\n */\n name: Children;\n}\n\n/**\n * Generates a TSDoc `@module` tag for the given module name.\n */\nexport function TSDocModule(props: TSDocModuleProps) {\n const [{ children, name, prefix }] = splitProps(props, [\n \"children\",\n \"name\",\n \"prefix\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={Boolean(children)}>\n <List hardline={false} softline={true}>\n {childrenArray(() => children)}\n </List>\n <Spacing />\n </Show>\n {\"@module \"}\n {prefix || context?.config?.framework || \"powerlines\"}:{name}\n </align>\n <hbr />\n {` */`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAAgB,MAAA,OAAA;CACd,MAAA,CAAA,EACA,UACA,aACK,WAAE,OAAc,CAAA,YAAc,UAAW,CAAC;AACjD,QAAS;EAAA;EAAA,gBAAqB,SAAY;GAC1C,QAAS;GACT,IAAQ,WAAC;AACH,WAAG;KAAA,gBAAuB,OAAM,EAAA,CAAA;KAAM,gBAAW,MAAA;;AAEhD,cAAU,CAAA,YAAW,QAAQ;;MAEpC,UAAA;;;MAEE,IAAA,OAAA;AACC,cAAY,WAAW,CAAA,CAAA,CAAA,YAAkB,SAAM,CAAA,EAAA,IAAW,oBAAK,SAAA,CAAA,OAAA,QAAA,CAAA,SAAA;;MAE3D,IAAA,WAAe;AACZ,cAAC,CAAA,gBAAuB,MAAA;;AAEzB,gBAAA,CAAA,YAAA,QAAA;;QAED,IAAA,WAAA;AACK,gBAAQ,gBAAI,SAAA,EAAA,CAAA;;QAEhB,CAAA,EAAK,gBAAkB,MAAC;QACxB,UAAA;QACC,UAAK;QACH,IAAC,WAAY;AACb,gBAAA,oBAA6B,SAAQ;;QAEtC,CAAA,CAAA;;MAEJ,CAAC;KAAC;;GAEN,CAAC;EAAE,gBAAO,OAAkB,EAAE,CAAA;EAAA;EAAS,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAK1C,SAAW,SAAA,OAAA;CACT,MAAK,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object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
4
|
+
const require_typescript_components_type_parameters = require('./type-parameters.cjs');
|
|
5
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
7
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
+
|
|
9
|
+
//#region src/typescript/components/type-declaration.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.
|
|
12
|
+
*/
|
|
13
|
+
const TypeDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(function TypeDeclaration(props) {
|
|
14
|
+
const { children, doc, typeParameters, ...rest } = props;
|
|
15
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
16
|
+
get when() {
|
|
17
|
+
return Boolean(doc);
|
|
18
|
+
},
|
|
19
|
+
get children() {
|
|
20
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, { heading: doc });
|
|
21
|
+
}
|
|
22
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.Declaration, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
23
|
+
kind: "type",
|
|
24
|
+
nameKind: "type",
|
|
25
|
+
get children() {
|
|
26
|
+
return [
|
|
27
|
+
"type ",
|
|
28
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Name, {}),
|
|
29
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => typeParameters && (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_type_parameters.TypeParameters, { parameters: typeParameters })),
|
|
30
|
+
" = ",
|
|
31
|
+
children,
|
|
32
|
+
";"
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
}))];
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.TypeDeclaration = TypeDeclaration;
|
|
@@ -1,2 +1,38 @@
|
|
|
1
|
-
import{TSDoc
|
|
1
|
+
import { TSDoc } from "./tsdoc.mjs";
|
|
2
|
+
import { TypeParameters } from "./type-parameters.mjs";
|
|
3
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { Name, Show } from "@alloy-js/core";
|
|
5
|
+
import { Declaration as Declaration$1, ensureTypeRefContext } from "@alloy-js/typescript";
|
|
6
|
+
|
|
7
|
+
//#region src/typescript/components/type-declaration.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.
|
|
10
|
+
*/
|
|
11
|
+
const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(props) {
|
|
12
|
+
const { children, doc, typeParameters, ...rest } = props;
|
|
13
|
+
return [createComponent(Show, {
|
|
14
|
+
get when() {
|
|
15
|
+
return Boolean(doc);
|
|
16
|
+
},
|
|
17
|
+
get children() {
|
|
18
|
+
return createComponent(TSDoc, { heading: doc });
|
|
19
|
+
}
|
|
20
|
+
}), createComponent(Declaration$1, mergeProps(rest, {
|
|
21
|
+
kind: "type",
|
|
22
|
+
nameKind: "type",
|
|
23
|
+
get children() {
|
|
24
|
+
return [
|
|
25
|
+
"type ",
|
|
26
|
+
createComponent(Name, {}),
|
|
27
|
+
memo(() => typeParameters && createComponent(TypeParameters, { parameters: typeParameters })),
|
|
28
|
+
" = ",
|
|
29
|
+
children,
|
|
30
|
+
";"
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
}))];
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { TypeDeclaration };
|
|
2
38
|
//# sourceMappingURL=type-declaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration.mjs","names":[],"sources":["../../../src/typescript/components/type-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 { Name, Show } from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TypeParameterDescriptor\n} from \"@alloy-js/typescript\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface TypeDeclarationProps extends CommonDeclarationProps {\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.\n */\nexport const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(\n props: TypeDeclarationProps\n) {\n const { children, doc, typeParameters, ...rest } = props;\n\n return (\n <>\n <Show when={Boolean(doc)}>\n <TSDoc heading={doc} />\n </Show>\n <Declaration {...rest} kind=\"type\" nameKind=\"type\">\n type <Name />\n {typeParameters && (\n <TypeParameters parameters={typeParameters} />\n )} = {children};\n </Declaration>\n </>\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"type-declaration.mjs","names":[],"sources":["../../../src/typescript/components/type-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 { Name, Show } from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TypeParameterDescriptor\n} from \"@alloy-js/typescript\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface TypeDeclarationProps extends CommonDeclarationProps {\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.\n */\nexport const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(\n props: TypeDeclarationProps\n) {\n const { children, doc, typeParameters, ...rest } = props;\n\n return (\n <>\n <Show when={Boolean(doc)}>\n <TSDoc heading={doc} />\n </Show>\n <Declaration {...rest} kind=\"type\" nameKind=\"type\">\n type <Name />\n {typeParameters && (\n <TypeParameters parameters={typeParameters} />\n )} = {children};\n </Declaration>\n </>\n );\n});\n"],"mappings":";;;;;;;;;;AA0BA,MAAS,kBAAsB,qBAAmB,SAAA,gBAAA,OAAA;SAElD,UACI,KACA,gBACA,GAAA,SACF;AACF,QAAA,CAAA,gBAAA,MAAA;;AAEE,UAAA,QAAA,IAAA;;EAEA,IAAA,WAAA;AACI,UAAO,gBAAkB,OAAA,EACvB,SAAC,KACP,CAAA;;;EAGA,MAAO;EACL,UAAC;EACD,IAAG,WAAW;AACZ,UAAG;IAAK;IAAS,gBAAO,MAAA,EAAA,CAAA;IAAA,WAAA,kBAAA,gBAAA,gBAAA,EACtB,YAAI,gBACL,CAAA,CAAA;IAAA;IAAW;IAAU;IAAC;;EAE1B,CAAC,CAAC,CAAC;EACJ"}
|