@powerlines/plugin-date 0.12.136 → 0.12.138

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.
Files changed (38) hide show
  1. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +20 -0
  2. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +19 -0
  3. package/dist/plugin-alloy/src/core/components/source-file.cjs +60 -0
  4. package/dist/plugin-alloy/src/core/components/source-file.mjs +58 -0
  5. package/dist/plugin-alloy/src/core/contexts/context.cjs +50 -1
  6. package/dist/plugin-alloy/src/core/contexts/context.mjs +46 -2
  7. package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
  8. package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
  9. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
  10. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
  11. package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
  12. package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
  13. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
  14. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
  15. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
  16. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
  17. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
  18. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
  19. package/dist/plugin-alloy/src/types/components.d.mts +1 -1
  20. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +47 -0
  21. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +46 -0
  22. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +75 -0
  23. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +73 -0
  24. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +359 -0
  25. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +350 -0
  26. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +142 -0
  27. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +139 -0
  28. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +53 -0
  29. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +52 -0
  30. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +94 -0
  31. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +93 -0
  32. package/dist/plugin-env/src/components/docs.cjs +3 -3
  33. package/dist/plugin-env/src/components/docs.mjs +3 -3
  34. package/dist/plugin-env/src/components/env.cjs +151 -40
  35. package/dist/plugin-env/src/components/env.mjs +126 -15
  36. package/dist/powerlines/src/lib/build/esbuild.mjs +1 -1
  37. package/dist/powerlines/src/lib/entry.mjs +1 -1
  38. package/package.json +5 -5
@@ -0,0 +1,350 @@
1
+ import { usePowerlines } from "../../core/contexts/context.mjs";
2
+ import { stringifyDefaultValue } from "../../../../deepkit/src/utilities.mjs";
3
+ import { For, List, Prose, Show, childrenArray, splitProps } from "@alloy-js/core";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { isSetString } from "@stryke/type-checks/is-set-string";
6
+ import { isUndefined } from "@stryke/type-checks/is-undefined";
7
+
8
+ //#region ../plugin-alloy/src/typescript/components/tsdoc.tsx
9
+ /**
10
+ * Generates a TypeScript interface for the given reflection class.
11
+ */
12
+ function TSDoc(props) {
13
+ const [{ children, heading }] = splitProps(props, ["children", "heading"]);
14
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
15
+ "/**",
16
+ /* @__PURE__ */ jsxs("align", {
17
+ string: " * ",
18
+ children: [
19
+ /* @__PURE__ */ jsx("hbr", {}),
20
+ /* @__PURE__ */ jsxs(Show, {
21
+ when: !isUndefined(heading),
22
+ children: [
23
+ heading,
24
+ /* @__PURE__ */ jsx("hbr", {}),
25
+ /* @__PURE__ */ jsx(Show, {
26
+ when: !isUndefined(children) && childrenArray(() => children).length > 0,
27
+ children: /* @__PURE__ */ jsx("hbr", {})
28
+ })
29
+ ]
30
+ }),
31
+ /* @__PURE__ */ jsx(Show, {
32
+ when: !isUndefined(children) && childrenArray(() => children).length > 0,
33
+ children: /* @__PURE__ */ jsx(List, { children: childrenArray(() => children) })
34
+ })
35
+ ]
36
+ }),
37
+ /* @__PURE__ */ jsx("hbr", {}),
38
+ ` */`,
39
+ /* @__PURE__ */ jsx("hbr", {})
40
+ ] });
41
+ }
42
+ /**
43
+ * Create a TSDoc `@<props.tag>` tag.
44
+ */
45
+ function TSDocTag(props) {
46
+ const [{ children, tag }] = splitProps(props, ["children", "tag"]);
47
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
48
+ `@${tag} `,
49
+ /* @__PURE__ */ jsx(Show, {
50
+ when: Boolean(children),
51
+ children: /* @__PURE__ */ jsx("align", {
52
+ width: 2,
53
+ children: /* @__PURE__ */ jsx(Prose, { children })
54
+ })
55
+ }),
56
+ /* @__PURE__ */ jsx("hbr", {})
57
+ ] });
58
+ }
59
+ /**
60
+ * Create a TSDoc `@title` tag.
61
+ */
62
+ function TSDocTitle(props) {
63
+ const [{ children }, rest] = splitProps(props, ["children"]);
64
+ return /* @__PURE__ */ jsx(TSDocTag, {
65
+ ...rest,
66
+ tag: "title",
67
+ children
68
+ });
69
+ }
70
+ /**
71
+ * Create a TSDoc `@domain` tag.
72
+ */
73
+ function TSDocDomain(props) {
74
+ const [{ children }, rest] = splitProps(props, ["children"]);
75
+ return /* @__PURE__ */ jsx(TSDocTag, {
76
+ ...rest,
77
+ tag: "domain",
78
+ children
79
+ });
80
+ }
81
+ /**
82
+ * Create a TSDoc `@alias` tag.
83
+ */
84
+ function TSDocAlias(props) {
85
+ const [{ children }, rest] = splitProps(props, ["children"]);
86
+ return /* @__PURE__ */ jsx(TSDocTag, {
87
+ ...rest,
88
+ tag: "alias",
89
+ children
90
+ });
91
+ }
92
+ /**
93
+ * Create a TSDoc `@permission` tag.
94
+ */
95
+ function TSDocPermission(props) {
96
+ const [{ children }, rest] = splitProps(props, ["children"]);
97
+ return /* @__PURE__ */ jsx(TSDocTag, {
98
+ ...rest,
99
+ tag: "permission",
100
+ children
101
+ });
102
+ }
103
+ /**
104
+ * Create a TSDoc `@defaultValue` tag.
105
+ */
106
+ function TSDocDefaultValue(props) {
107
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
108
+ "@defaultValue ",
109
+ /* @__PURE__ */ jsx(Show, {
110
+ when: !isUndefined(props.value),
111
+ children: /* @__PURE__ */ jsx("align", {
112
+ width: 2,
113
+ children: /* @__PURE__ */ jsx(Prose, { children: stringifyDefaultValue(props.value) })
114
+ })
115
+ }),
116
+ /* @__PURE__ */ jsx("hbr", {})
117
+ ] });
118
+ }
119
+ /**
120
+ * Create a TSDoc `@remarks` tag.
121
+ */
122
+ function TSDocRemarks(props) {
123
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
124
+ "@remarks ",
125
+ /* @__PURE__ */ jsx("hbr", {}),
126
+ /* @__PURE__ */ jsx(List, {
127
+ hardline: true,
128
+ children: childrenArray(() => props.children)
129
+ })
130
+ ] });
131
+ }
132
+ /**
133
+ * Create a TSDoc `@see` tag.
134
+ */
135
+ function TSDocLink(props) {
136
+ return /* @__PURE__ */ jsx(TSDocTag, {
137
+ ...props,
138
+ tag: "see"
139
+ });
140
+ }
141
+ /**
142
+ * Create a TSDoc `@example` tag.
143
+ */
144
+ function TSDocExample(props) {
145
+ const [{ tsx, fenced = true, language, children }] = splitProps(props, [
146
+ "tsx",
147
+ "fenced",
148
+ "language",
149
+ "children"
150
+ ]);
151
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
152
+ "@example ",
153
+ /* @__PURE__ */ jsx("hbr", {}),
154
+ /* @__PURE__ */ jsxs(Show, {
155
+ when: fenced,
156
+ children: [
157
+ "```",
158
+ language || (tsx ? "tsx" : "ts"),
159
+ /* @__PURE__ */ jsx("hbr", {})
160
+ ]
161
+ }),
162
+ children,
163
+ /* @__PURE__ */ jsxs(Show, {
164
+ when: fenced,
165
+ children: [/* @__PURE__ */ jsx("hbr", {}), "```"]
166
+ })
167
+ ] });
168
+ }
169
+ /**
170
+ * Create a TSDoc `@readonly` tag.
171
+ */
172
+ function TSDocReadonly() {
173
+ return /* @__PURE__ */ jsx(TSDocTag, { tag: "readonly" });
174
+ }
175
+ /**
176
+ * Create a TSDoc `@internal` tag.
177
+ */
178
+ function TSDocInternal() {
179
+ return /* @__PURE__ */ jsx(TSDocTag, { tag: "internal" });
180
+ }
181
+ /**
182
+ * Create a TSDoc `@ignore` tag.
183
+ */
184
+ function TSDocIgnore() {
185
+ return /* @__PURE__ */ jsx(TSDocTag, { tag: "ignore" });
186
+ }
187
+ /**
188
+ * Create a TSDoc `@hidden` tag.
189
+ */
190
+ function TSDocHidden() {
191
+ return /* @__PURE__ */ jsx(TSDocTag, { tag: "hidden" });
192
+ }
193
+ /**
194
+ * Generates a TypeScript interface property for the given reflection class.
195
+ */
196
+ function TSDocAttributesTags(props) {
197
+ const [{ title, alias, permission, domain, readonly, internal, ignore, hidden, defaultValue }] = splitProps(props, [
198
+ "title",
199
+ "alias",
200
+ "permission",
201
+ "domain",
202
+ "readonly",
203
+ "internal",
204
+ "ignore",
205
+ "hidden",
206
+ "defaultValue"
207
+ ]);
208
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
209
+ /* @__PURE__ */ jsx(Show, {
210
+ when: isSetString(title),
211
+ children: /* @__PURE__ */ jsx(TSDocTitle, { children: title })
212
+ }),
213
+ /* @__PURE__ */ jsx(Show, {
214
+ when: !isUndefined(alias) && alias.length > 0,
215
+ children: /* @__PURE__ */ jsx(For, {
216
+ each: alias ?? [],
217
+ children: (alias$1) => /* @__PURE__ */ jsx(TSDocAlias, { children: alias$1 })
218
+ })
219
+ }),
220
+ /* @__PURE__ */ jsx(Show, {
221
+ when: isSetString(domain),
222
+ children: /* @__PURE__ */ jsx(TSDocDomain, { children: domain })
223
+ }),
224
+ /* @__PURE__ */ jsx(Show, {
225
+ when: !isUndefined(permission) && permission.length > 0,
226
+ children: /* @__PURE__ */ jsx(For, {
227
+ each: permission ?? [],
228
+ children: (permission$1) => /* @__PURE__ */ jsx(TSDocPermission, { children: permission$1 })
229
+ })
230
+ }),
231
+ /* @__PURE__ */ jsx(Show, {
232
+ when: readonly === true,
233
+ children: /* @__PURE__ */ jsx(TSDocReadonly, {})
234
+ }),
235
+ /* @__PURE__ */ jsx(Show, {
236
+ when: internal === true,
237
+ children: /* @__PURE__ */ jsx(TSDocInternal, {})
238
+ }),
239
+ /* @__PURE__ */ jsx(Show, {
240
+ when: ignore === true,
241
+ children: /* @__PURE__ */ jsx(TSDocIgnore, {})
242
+ }),
243
+ /* @__PURE__ */ jsx(Show, {
244
+ when: hidden === true,
245
+ children: /* @__PURE__ */ jsx(TSDocHidden, {})
246
+ }),
247
+ /* @__PURE__ */ jsx(Show, {
248
+ when: !isUndefined(defaultValue),
249
+ children: /* @__PURE__ */ jsx(TSDocDefaultValue, { value: defaultValue })
250
+ })
251
+ ] });
252
+ }
253
+ /**
254
+ * Create a TSDoc parameter set off with `@param`.
255
+ */
256
+ function TSDocParam(props) {
257
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
258
+ "@param ",
259
+ /* @__PURE__ */ jsx(TSDocParamName, {
260
+ name: props.name,
261
+ optional: props.optional,
262
+ defaultValue: props.defaultValue
263
+ }),
264
+ /* @__PURE__ */ jsx(TSDocParamDescription, { children: props.children })
265
+ ] });
266
+ }
267
+ function TSDocParamName(props) {
268
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
269
+ /* @__PURE__ */ jsx(Show, {
270
+ when: props.optional,
271
+ children: "["
272
+ }),
273
+ props.name,
274
+ /* @__PURE__ */ jsxs(Show, {
275
+ when: Boolean(props.defaultValue),
276
+ children: ["=", props.defaultValue]
277
+ }),
278
+ /* @__PURE__ */ jsx(Show, {
279
+ when: props.optional,
280
+ children: "]"
281
+ })
282
+ ] });
283
+ }
284
+ function TSDocParamDescription(props) {
285
+ return /* @__PURE__ */ jsxs(Show, {
286
+ when: Boolean(props.children),
287
+ children: [" - ", /* @__PURE__ */ jsx("align", {
288
+ width: 2,
289
+ children: /* @__PURE__ */ jsx(Prose, { children: props.children })
290
+ })]
291
+ });
292
+ }
293
+ /**
294
+ * Create a TSDoc `@returns` tag.
295
+ */
296
+ function TSDocReturns(props) {
297
+ return /* @__PURE__ */ jsx(TSDocTag, {
298
+ ...props,
299
+ tag: "returns"
300
+ });
301
+ }
302
+ /**
303
+ * Create a TSDoc `@throws` tag.
304
+ */
305
+ function TSDocThrows(props) {
306
+ return /* @__PURE__ */ jsx(TSDocTag, {
307
+ ...props,
308
+ tag: "throws"
309
+ });
310
+ }
311
+ /**
312
+ * Generates a TSDoc `@module` tag for the given module name.
313
+ */
314
+ function TSDocModule(props) {
315
+ const [{ children, name, prefix }] = splitProps(props, [
316
+ "children",
317
+ "name",
318
+ "prefix"
319
+ ]);
320
+ const context = usePowerlines();
321
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
322
+ "/**",
323
+ /* @__PURE__ */ jsxs("align", {
324
+ string: " * ",
325
+ children: [
326
+ /* @__PURE__ */ jsx("hbr", {}),
327
+ /* @__PURE__ */ jsxs(Show, {
328
+ when: Boolean(children),
329
+ children: [
330
+ /* @__PURE__ */ jsx(List, {
331
+ hardline: true,
332
+ children: childrenArray(() => children)
333
+ }),
334
+ /* @__PURE__ */ jsx("hbr", {}),
335
+ /* @__PURE__ */ jsx("hbr", {})
336
+ ]
337
+ }),
338
+ "@module ",
339
+ prefix || context?.config.output.builtinPrefix,
340
+ ":",
341
+ name
342
+ ]
343
+ }),
344
+ /* @__PURE__ */ jsx("hbr", {}),
345
+ ` */`
346
+ ] });
347
+ }
348
+
349
+ //#endregion
350
+ export { TSDoc, TSDocAttributesTags, TSDocExample, TSDocLink, TSDocModule, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows };
@@ -0,0 +1,142 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_context = require('../../core/contexts/context.cjs');
3
+ const require_single_line_comment = require('../../core/components/single-line-comment.cjs');
4
+ const require_source_file = require('../../core/components/source-file.cjs');
5
+ let __alloy_js_core = require("@alloy-js/core");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let __stryke_path_append = require("@stryke/path/append");
8
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
9
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
+ let __alloy_js_typescript = require("@alloy-js/typescript");
11
+ let __stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
12
+
13
+ //#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
14
+ /**
15
+ * A base component representing a Powerlines generated Typescript source file.
16
+ *
17
+ * @param props - The properties for the source file.
18
+ * @returns The rendered source file component.
19
+ */
20
+ function TypescriptFile(props) {
21
+ const [{ children, path, imports, tsx, header, hashbang }, rest] = (0, __alloy_js_core.splitProps)(props, [
22
+ "children",
23
+ "path",
24
+ "imports",
25
+ "tsx",
26
+ "header",
27
+ "hashbang"
28
+ ]);
29
+ const directoryContext = (0, __alloy_js_core.useContext)(__alloy_js_core.SourceDirectoryContext);
30
+ const sdData = (0, __alloy_js_typescript.getSourceDirectoryData)(directoryContext);
31
+ const modulePath = (0, __stryke_path_append.appendPath)(path, directoryContext.path);
32
+ const scope = new __alloy_js_typescript.TSModuleScope(modulePath, (0, __alloy_js_core.useScope)());
33
+ sdData.modules.add(scope);
34
+ const pkg = (0, __alloy_js_core.useContext)(__alloy_js_typescript.PackageContext);
35
+ if (pkg) pkg.scope.addModule(scope);
36
+ if (props.export) {
37
+ if (pkg) if ((0, __stryke_type_checks_is_boolean.isBoolean)(props.export)) pkg.scope.addExport(modulePath, scope);
38
+ else pkg.scope.addExport(props.export, scope);
39
+ }
40
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.SourceFileContext.Provider, {
41
+ value: { scope },
42
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Scope, {
43
+ value: scope,
44
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_source_file.SourceFile, {
45
+ ...rest,
46
+ path: modulePath,
47
+ header: header ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptFileHeader, {
48
+ hashbang,
49
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptFileHeaderImports, {
50
+ imports,
51
+ scope
52
+ })
53
+ }),
54
+ filetype: tsx ? "tsx" : "typescript",
55
+ children
56
+ })
57
+ })
58
+ });
59
+ }
60
+ /**
61
+ * Renders the header for a Powerlines Typescript source file.
62
+ *
63
+ * @param props - The properties for the source file header.
64
+ * @returns The rendered source file header.
65
+ */
66
+ function TypescriptFileHeader(props) {
67
+ const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
68
+ const context = require_context.usePowerlines();
69
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
70
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
71
+ when: Boolean(hashbang),
72
+ children: [hashbang === true ? __alloy_js_core.code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
73
+ }),
74
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
75
+ when: Boolean(header),
76
+ children: [header, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
77
+ }),
78
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {}),
79
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
80
+ when: Boolean(disableEslint),
81
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, {
82
+ variant: "slash-star",
83
+ children: "eslint-disable"
84
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
85
+ }),
86
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
87
+ when: Boolean(disablePrettier),
88
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, {
89
+ variant: "slash-star",
90
+ children: "prettier-ignore"
91
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
92
+ }),
93
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
94
+ when: Boolean(disableBiome),
95
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: "biome-ignore lint: disable" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})]
96
+ }),
97
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
98
+ when: Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome),
99
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
100
+ }),
101
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
102
+ when: Boolean(children),
103
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})] })
104
+ }),
105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: __alloy_js_core.code`Generated by ${(0, __stryke_string_format_title_case.titleCase)(context?.config.framework) || "Powerlines"}` }),
106
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {}),
107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_single_line_comment.SingleLineComment, { children: __alloy_js_core.code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
108
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
109
+ ] });
110
+ }
111
+ /**
112
+ * Renders the header for a Powerlines Typescript source file.
113
+ *
114
+ * @param props - The properties for the source file header.
115
+ * @returns The rendered source file header.
116
+ */
117
+ function TypescriptFileHeaderImports(props) {
118
+ const { imports } = props;
119
+ const sourceFile = (0, __alloy_js_typescript.useSourceFile)();
120
+ const scope = props.scope ?? sourceFile.scope;
121
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(__alloy_js_core.Show, {
122
+ when: scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0,
123
+ children: [
124
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
125
+ when: !!imports && Object.keys(imports).length > 0,
126
+ children: Object.entries(imports ?? {}).map(([module$1, imported]) => {
127
+ return __alloy_js_core.code`import ${imported === null ? "" : imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !(0, __stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => (0, __stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${imported.map((i) => (0, __stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module$1}";`;
128
+ })
129
+ }),
130
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.Show, {
131
+ when: scope.importedModules.size > 0,
132
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.ImportStatements, { records: scope.importedModules })
133
+ }),
134
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hbr", {})
135
+ ]
136
+ });
137
+ }
138
+
139
+ //#endregion
140
+ exports.TypescriptFile = TypescriptFile;
141
+ exports.TypescriptFileHeader = TypescriptFileHeader;
142
+ exports.TypescriptFileHeaderImports = TypescriptFileHeaderImports;
@@ -0,0 +1,139 @@
1
+ import { usePowerlines } from "../../core/contexts/context.mjs";
2
+ import { SingleLineComment } from "../../core/components/single-line-comment.mjs";
3
+ import { SourceFile } from "../../core/components/source-file.mjs";
4
+ import { Scope, Show, SourceDirectoryContext, code, splitProps, useContext, useScope } from "@alloy-js/core";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { appendPath } from "@stryke/path/append";
7
+ import { titleCase } from "@stryke/string-format/title-case";
8
+ import { isString } from "@stryke/type-checks/is-string";
9
+ import { ImportStatements, PackageContext, SourceFileContext as SourceFileContext$1, TSModuleScope, getSourceDirectoryData, useSourceFile } from "@alloy-js/typescript";
10
+ import { isBoolean } from "@stryke/type-checks/is-boolean";
11
+
12
+ //#region ../plugin-alloy/src/typescript/components/typescript-file.tsx
13
+ /**
14
+ * A base component representing a Powerlines generated Typescript source file.
15
+ *
16
+ * @param props - The properties for the source file.
17
+ * @returns The rendered source file component.
18
+ */
19
+ function TypescriptFile(props) {
20
+ const [{ children, path, imports, tsx, header, hashbang }, rest] = splitProps(props, [
21
+ "children",
22
+ "path",
23
+ "imports",
24
+ "tsx",
25
+ "header",
26
+ "hashbang"
27
+ ]);
28
+ const directoryContext = useContext(SourceDirectoryContext);
29
+ const sdData = getSourceDirectoryData(directoryContext);
30
+ const modulePath = appendPath(path, directoryContext.path);
31
+ const scope = new TSModuleScope(modulePath, useScope());
32
+ sdData.modules.add(scope);
33
+ const pkg = useContext(PackageContext);
34
+ if (pkg) pkg.scope.addModule(scope);
35
+ if (props.export) {
36
+ if (pkg) if (isBoolean(props.export)) pkg.scope.addExport(modulePath, scope);
37
+ else pkg.scope.addExport(props.export, scope);
38
+ }
39
+ return /* @__PURE__ */ jsx(SourceFileContext$1.Provider, {
40
+ value: { scope },
41
+ children: /* @__PURE__ */ jsx(Scope, {
42
+ value: scope,
43
+ children: /* @__PURE__ */ jsx(SourceFile, {
44
+ ...rest,
45
+ path: modulePath,
46
+ header: header ?? /* @__PURE__ */ jsx(TypescriptFileHeader, {
47
+ hashbang,
48
+ children: /* @__PURE__ */ jsx(TypescriptFileHeaderImports, {
49
+ imports,
50
+ scope
51
+ })
52
+ }),
53
+ filetype: tsx ? "tsx" : "typescript",
54
+ children
55
+ })
56
+ })
57
+ });
58
+ }
59
+ /**
60
+ * Renders the header for a Powerlines Typescript source file.
61
+ *
62
+ * @param props - The properties for the source file header.
63
+ * @returns The rendered source file header.
64
+ */
65
+ function TypescriptFileHeader(props) {
66
+ const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
67
+ const context = usePowerlines();
68
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
69
+ /* @__PURE__ */ jsxs(Show, {
70
+ when: Boolean(hashbang),
71
+ children: [hashbang === true ? code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang, /* @__PURE__ */ jsx("hbr", {})]
72
+ }),
73
+ /* @__PURE__ */ jsxs(Show, {
74
+ when: Boolean(header),
75
+ children: [header, /* @__PURE__ */ jsx("hbr", {})]
76
+ }),
77
+ /* @__PURE__ */ jsx("hbr", {}),
78
+ /* @__PURE__ */ jsxs(Show, {
79
+ when: Boolean(disableEslint),
80
+ children: [/* @__PURE__ */ jsx(SingleLineComment, {
81
+ variant: "slash-star",
82
+ children: "eslint-disable"
83
+ }), /* @__PURE__ */ jsx("hbr", {})]
84
+ }),
85
+ /* @__PURE__ */ jsxs(Show, {
86
+ when: Boolean(disablePrettier),
87
+ children: [/* @__PURE__ */ jsx(SingleLineComment, {
88
+ variant: "slash-star",
89
+ children: "prettier-ignore"
90
+ }), /* @__PURE__ */ jsx("hbr", {})]
91
+ }),
92
+ /* @__PURE__ */ jsxs(Show, {
93
+ when: Boolean(disableBiome),
94
+ children: [/* @__PURE__ */ jsx(SingleLineComment, { children: "biome-ignore lint: disable" }), /* @__PURE__ */ jsx("hbr", {})]
95
+ }),
96
+ /* @__PURE__ */ jsx(Show, {
97
+ when: Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome),
98
+ children: /* @__PURE__ */ jsx("hbr", {})
99
+ }),
100
+ /* @__PURE__ */ jsx(Show, {
101
+ when: Boolean(children),
102
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx("hbr", {})] })
103
+ }),
104
+ /* @__PURE__ */ jsx(SingleLineComment, { children: code`Generated by ${titleCase(context?.config.framework) || "Powerlines"}` }),
105
+ /* @__PURE__ */ jsx("hbr", {}),
106
+ /* @__PURE__ */ jsx(SingleLineComment, { children: code`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command` }),
107
+ /* @__PURE__ */ jsx("hbr", {})
108
+ ] });
109
+ }
110
+ /**
111
+ * Renders the header for a Powerlines Typescript source file.
112
+ *
113
+ * @param props - The properties for the source file header.
114
+ * @returns The rendered source file header.
115
+ */
116
+ function TypescriptFileHeaderImports(props) {
117
+ const { imports } = props;
118
+ const sourceFile = useSourceFile();
119
+ const scope = props.scope ?? sourceFile.scope;
120
+ return /* @__PURE__ */ jsxs(Show, {
121
+ when: scope.importedModules.size > 0 || !!imports && Object.keys(imports).length > 0,
122
+ children: [
123
+ /* @__PURE__ */ jsx(Show, {
124
+ when: !!imports && Object.keys(imports).length > 0,
125
+ children: Object.entries(imports ?? {}).map(([module, imported]) => {
126
+ return code`import ${imported === null ? "" : imported.filter((i) => !isString(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (imported.filter((i) => !isString(i) && i.default).length > 0 && imported.filter((i) => isString(i) || !i.default).length > 0 ? ", " : "") + (imported.filter((i) => isString(i) || !i.default).length > 0 ? `{ ${imported.map((i) => isString(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")} from "${module}";`;
127
+ })
128
+ }),
129
+ /* @__PURE__ */ jsx(Show, {
130
+ when: scope.importedModules.size > 0,
131
+ children: /* @__PURE__ */ jsx(ImportStatements, { records: scope.importedModules })
132
+ }),
133
+ /* @__PURE__ */ jsx("hbr", {})
134
+ ]
135
+ });
136
+ }
137
+
138
+ //#endregion
139
+ export { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports };
@@ -0,0 +1,53 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_type = require('../../../../deepkit/src/vendor/type.cjs');
3
+ const require_reflection = require('../../core/contexts/reflection.cjs');
4
+ const require_tsdoc_reflection = require('./tsdoc-reflection.cjs');
5
+ let __alloy_js_core = require("@alloy-js/core");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
8
+ let __alloy_js_typescript = require("@alloy-js/typescript");
9
+ let __stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
10
+
11
+ //#region ../plugin-alloy/src/typescript/components/typescript-interface.tsx
12
+ /**
13
+ * Generates a TypeScript interface for the given reflection class.
14
+ */
15
+ function TypeScriptInterface(props) {
16
+ const [{ name, reflection }, rest] = (0, __alloy_js_core.splitProps)(props, ["name", "reflection"]);
17
+ const interfaceName = (0, __alloy_js_core.computed)(() => (0, __stryke_string_format_pascal_case.pascalCase)(((0, __stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection.getName()));
18
+ const properties = reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1);
19
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionClassContext.Provider, {
20
+ value: { reflection },
21
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionClass, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.InterfaceDeclaration, {
22
+ export: true,
23
+ name: interfaceName.value,
24
+ ...rest,
25
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_core.For, {
26
+ each: properties,
27
+ doubleHardline: true,
28
+ semicolon: true,
29
+ children: (prop) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypescriptInterfaceProperty, { property: prop })
30
+ })
31
+ })]
32
+ });
33
+ }
34
+ /**
35
+ * Generates a TypeScript interface property for the given reflection class.
36
+ */
37
+ function TypescriptInterfaceProperty(props) {
38
+ const [{ property }, rest] = (0, __alloy_js_core.splitProps)(props, ["property"]);
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_reflection.ReflectionPropertyContext.Provider, {
40
+ value: property,
41
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_tsdoc_reflection.TSDocReflectionProperty, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__alloy_js_typescript.InterfaceMember, {
42
+ name: property.getNameAsString(),
43
+ readonly: property.isReadonly(),
44
+ optional: property.isOptional(),
45
+ nullish: property.isNullable(),
46
+ type: (0, require_type.type_exports.stringifyType)(property.getType()),
47
+ ...rest
48
+ })]
49
+ });
50
+ }
51
+
52
+ //#endregion
53
+ exports.TypeScriptInterface = TypeScriptInterface;