@powerlines/plugin-alloy 0.25.27 → 0.25.29

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 (91) hide show
  1. package/dist/core/components/output.cjs +7 -19
  2. package/dist/core/components/output.mjs +7 -19
  3. package/dist/core/components/output.mjs.map +1 -1
  4. package/dist/core/components/single-line-comment.cjs +8 -7
  5. package/dist/core/components/single-line-comment.mjs +8 -7
  6. package/dist/core/components/single-line-comment.mjs.map +1 -1
  7. package/dist/core/components/source-file.cjs +7 -12
  8. package/dist/core/components/source-file.mjs +7 -12
  9. package/dist/core/components/source-file.mjs.map +1 -1
  10. package/dist/core/components/spacing.cjs +6 -7
  11. package/dist/core/components/spacing.mjs +6 -7
  12. package/dist/core/components/spacing.mjs.map +1 -1
  13. package/dist/core/contexts/context.mjs.map +1 -1
  14. package/dist/core/contexts/meta.mjs.map +1 -1
  15. package/dist/core/contexts/reflection.mjs.map +1 -1
  16. package/dist/core/helpers/code.mjs.map +1 -1
  17. package/dist/helpers/capnp.mjs.map +1 -1
  18. package/dist/helpers/create-builtin.mjs.map +1 -1
  19. package/dist/helpers/refkey.mjs.map +1 -1
  20. package/dist/helpers/typescript.mjs.map +1 -1
  21. package/dist/index.cjs +6 -3
  22. package/dist/index.d.cts.map +1 -1
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +6 -3
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/markdown/components/front-matter.cjs +9 -14
  27. package/dist/markdown/components/front-matter.mjs +9 -14
  28. package/dist/markdown/components/front-matter.mjs.map +1 -1
  29. package/dist/markdown/components/markdown-file.cjs +41 -89
  30. package/dist/markdown/components/markdown-file.mjs +41 -89
  31. package/dist/markdown/components/markdown-file.mjs.map +1 -1
  32. package/dist/markdown/components/markdown-table.cjs +20 -52
  33. package/dist/markdown/components/markdown-table.mjs +20 -52
  34. package/dist/markdown/components/markdown-table.mjs.map +1 -1
  35. package/dist/markdown/contexts/markdown-table.mjs.map +1 -1
  36. package/dist/render.cjs +4 -10
  37. package/dist/render.mjs +4 -10
  38. package/dist/render.mjs.map +1 -1
  39. package/dist/typescript/components/builtin-file.cjs +9 -31
  40. package/dist/typescript/components/builtin-file.mjs +9 -31
  41. package/dist/typescript/components/builtin-file.mjs.map +1 -1
  42. package/dist/typescript/components/class-declaration.cjs +80 -193
  43. package/dist/typescript/components/class-declaration.mjs +80 -193
  44. package/dist/typescript/components/class-declaration.mjs.map +1 -1
  45. package/dist/typescript/components/dynamic-import-statement.cjs +1 -2
  46. package/dist/typescript/components/dynamic-import-statement.mjs +1 -2
  47. package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
  48. package/dist/typescript/components/entry-file.cjs +3 -10
  49. package/dist/typescript/components/entry-file.mjs +3 -10
  50. package/dist/typescript/components/entry-file.mjs.map +1 -1
  51. package/dist/typescript/components/infrastructure-file.cjs +3 -10
  52. package/dist/typescript/components/infrastructure-file.mjs +3 -10
  53. package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
  54. package/dist/typescript/components/interface-declaration.cjs +47 -134
  55. package/dist/typescript/components/interface-declaration.mjs +47 -134
  56. package/dist/typescript/components/interface-declaration.mjs.map +1 -1
  57. package/dist/typescript/components/object-declaration.cjs +35 -79
  58. package/dist/typescript/components/object-declaration.mjs +35 -79
  59. package/dist/typescript/components/object-declaration.mjs.map +1 -1
  60. package/dist/typescript/components/property-name.cjs +3 -3
  61. package/dist/typescript/components/property-name.mjs +3 -3
  62. package/dist/typescript/components/property-name.mjs.map +1 -1
  63. package/dist/typescript/components/record-expression.mjs.map +1 -1
  64. package/dist/typescript/components/tsdoc-reflection.cjs +53 -232
  65. package/dist/typescript/components/tsdoc-reflection.mjs +53 -232
  66. package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
  67. package/dist/typescript/components/tsdoc.cjs +140 -306
  68. package/dist/typescript/components/tsdoc.mjs +140 -306
  69. package/dist/typescript/components/tsdoc.mjs.map +1 -1
  70. package/dist/typescript/components/type-declaration.cjs +9 -22
  71. package/dist/typescript/components/type-declaration.mjs +9 -22
  72. package/dist/typescript/components/type-declaration.mjs.map +1 -1
  73. package/dist/typescript/components/type-parameters.cjs +33 -60
  74. package/dist/typescript/components/type-parameters.mjs +33 -60
  75. package/dist/typescript/components/type-parameters.mjs.map +1 -1
  76. package/dist/typescript/components/typescript-file.cjs +65 -155
  77. package/dist/typescript/components/typescript-file.mjs +65 -155
  78. package/dist/typescript/components/typescript-file.mjs.map +1 -1
  79. package/dist/typescript/contexts/lexical-scope.cjs +1 -7
  80. package/dist/typescript/contexts/lexical-scope.mjs +1 -7
  81. package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
  82. package/dist/typescript/contexts/member-scope.cjs +2 -7
  83. package/dist/typescript/contexts/member-scope.mjs +2 -7
  84. package/dist/typescript/contexts/member-scope.mjs.map +1 -1
  85. package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -1
  86. package/dist/typescript/helpers/utilities.mjs.map +1 -1
  87. package/dist/yaml/components/yaml-file.cjs +48 -103
  88. package/dist/yaml/components/yaml-file.mjs +48 -103
  89. package/dist/yaml/components/yaml-file.mjs.map +1 -1
  90. package/package.json +7 -7
  91. package/dist/_virtual/_rolldown/runtime.mjs +0 -3
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
3
  const require_typescript_components_tsdoc = require('./tsdoc.cjs');
4
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
5
  let _alloy_js_core = require("@alloy-js/core");
7
6
  let _alloy_js_typescript = require("@alloy-js/typescript");
8
7
 
@@ -12,27 +11,15 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
12
11
  */
13
12
  const TypeDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(function TypeDeclaration(props) {
14
13
  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
- }))];
14
+ return <>
15
+ <_alloy_js_core.Show when={Boolean(doc)}>
16
+ <require_typescript_components_tsdoc.TSDoc heading={doc} />
17
+ </_alloy_js_core.Show>
18
+ <_alloy_js_typescript.Declaration {...rest} kind="type" nameKind="type">
19
+ type <_alloy_js_core.Name />
20
+ {typeParameters && <require_typescript_components_type_parameters.TypeParameters parameters={typeParameters} />} = {children};
21
+ </_alloy_js_typescript.Declaration>
22
+ </>;
36
23
  });
37
24
 
38
25
  //#endregion
@@ -1,6 +1,5 @@
1
1
  import { TSDoc } from "./tsdoc.mjs";
2
2
  import { TypeParameters } from "./type-parameters.mjs";
3
- import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
3
  import { Name, Show } from "@alloy-js/core";
5
4
  import { Declaration as Declaration$1, ensureTypeRefContext } from "@alloy-js/typescript";
6
5
 
@@ -10,27 +9,15 @@ import { Declaration as Declaration$1, ensureTypeRefContext } from "@alloy-js/ty
10
9
  */
11
10
  const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(props) {
12
11
  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
- }))];
12
+ return <>
13
+ <Show when={Boolean(doc)}>
14
+ <TSDoc heading={doc} />
15
+ </Show>
16
+ <Declaration$1 {...rest} kind="type" nameKind="type">
17
+ type <Name />
18
+ {typeParameters && <TypeParameters parameters={typeParameters} />} = {children};
19
+ </Declaration$1>
20
+ </>;
34
21
  });
35
22
 
36
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"type-declaration.mjs","names":["Name","Show","Declaration","ensureTypeRefContext","TSDoc","TypeParameters","TypeDeclaration","props","children","doc","typeParameters","rest","_$createComponent","when","Boolean","heading","_$mergeProps","kind","nameKind","_$memo","parameters"],"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":["Declaration"],"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":";;;;;;;;;AAsCA,MAAa,kBAAkB,qBAAqB,SAAS,gBAC3D,OACA;CACA,MAAM,EAAE,UAAU,KAAK,gBAAgB,GAAG,SAAS;AAEnD,QACE,EAAE;MACA,CAAC,KAAK,MAAM,QAAQ,IAAI,EAAE;QACxB,CAAC,MAAM,SAAS,OAAO;MACzB,EAAE,KAAK;MACP,CAACA,kBAAgB,MAAM,YAAY,gBAAgB;aAC5C,CAAC,OAAO;SACZ,kBACC,CAAC,eAAe,YAAY,mBAC5B,IAAI,SAAS;MACjB,EAAEA,cAAY;IAChB;EAEF"}
@@ -1,51 +1,31 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
3
  let _alloy_js_core = require("@alloy-js/core");
5
4
  let _alloy_js_typescript = require("@alloy-js/typescript");
6
5
 
7
6
  //#region src/typescript/components/type-parameters.tsx
8
- /** Props for type parameters */
9
7
  function typeParameter(param) {
10
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
11
- when: typeof param === "object",
12
- get fallback() {
13
- return [param];
14
- },
15
- get children() {
16
- return [(0, _alloy_js_core_jsx_runtime.createIntrinsic)("group", { get children() {
17
- return [
18
- (0, _alloy_js_core_jsx_runtime.memo)(() => param.name),
19
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
20
- get when() {
21
- return !!param.extends;
22
- },
23
- get children() {
24
- return [
25
- " ",
26
- "extends",
27
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("indent", { get children() {
28
- return [" ", (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeRefContext, { get children() {
29
- return param.extends;
30
- } })];
31
- } })
32
- ];
33
- }
34
- }),
35
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
36
- get when() {
37
- return !!param.default;
38
- },
39
- get children() {
40
- return [" = ", (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeRefContext, { get children() {
41
- return param.default;
42
- } })];
43
- }
44
- })
45
- ];
46
- } }), " "];
47
- }
48
- });
8
+ return <_alloy_js_core.Show when={typeof param === "object"} fallback={<>{param}</>}>
9
+ <group>
10
+ {param.name}
11
+ <_alloy_js_core.Show when={!!param.extends}>
12
+ {" "}
13
+ extends
14
+ <indent>
15
+ {" "}
16
+ <_alloy_js_typescript.TypeRefContext>
17
+ {param.extends}
18
+ </_alloy_js_typescript.TypeRefContext>
19
+ </indent>
20
+ </_alloy_js_core.Show>
21
+ <_alloy_js_core.Show when={!!param.default}>
22
+ {" = "}
23
+ <_alloy_js_typescript.TypeRefContext>
24
+ {param.default}
25
+ </_alloy_js_typescript.TypeRefContext>
26
+ </_alloy_js_core.Show>
27
+ </group>{" "}
28
+ </_alloy_js_core.Show>;
49
29
  }
50
30
  /**
51
31
  * Represent type parameters
@@ -58,25 +38,18 @@ function typeParameter(param) {
58
38
  function TypeParameters(props) {
59
39
  if (props.children) return props.children;
60
40
  if (!props.parameters) return;
61
- return [
62
- "<",
63
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("group", { get children() {
64
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Indent, {
65
- softline: true,
66
- get children() {
67
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
68
- get each() {
69
- return props.parameters;
70
- },
71
- comma: true,
72
- line: true,
73
- children: (param) => typeParameter(param)
74
- }), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("ifBreak", { children: "," })];
75
- }
76
- });
77
- } }),
78
- ">"
79
- ];
41
+ return <>
42
+ {"<"}
43
+ <group>
44
+ <_alloy_js_core.Indent softline>
45
+ <_alloy_js_core.For each={props.parameters} comma line>
46
+ {(param) => typeParameter(param)}
47
+ </_alloy_js_core.For>
48
+ <ifBreak>,</ifBreak>
49
+ </_alloy_js_core.Indent>
50
+ </group>
51
+ {">"}
52
+ </>;
80
53
  }
81
54
 
82
55
  //#endregion
@@ -1,49 +1,29 @@
1
- import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
2
1
  import { For, Indent, Show } from "@alloy-js/core";
3
2
  import { TypeRefContext } from "@alloy-js/typescript";
4
3
 
5
4
  //#region src/typescript/components/type-parameters.tsx
6
- /** Props for type parameters */
7
5
  function typeParameter(param) {
8
- return createComponent(Show, {
9
- when: typeof param === "object",
10
- get fallback() {
11
- return [param];
12
- },
13
- get children() {
14
- return [createIntrinsic("group", { get children() {
15
- return [
16
- memo(() => param.name),
17
- createComponent(Show, {
18
- get when() {
19
- return !!param.extends;
20
- },
21
- get children() {
22
- return [
23
- " ",
24
- "extends",
25
- createIntrinsic("indent", { get children() {
26
- return [" ", createComponent(TypeRefContext, { get children() {
27
- return param.extends;
28
- } })];
29
- } })
30
- ];
31
- }
32
- }),
33
- createComponent(Show, {
34
- get when() {
35
- return !!param.default;
36
- },
37
- get children() {
38
- return [" = ", createComponent(TypeRefContext, { get children() {
39
- return param.default;
40
- } })];
41
- }
42
- })
43
- ];
44
- } }), " "];
45
- }
46
- });
6
+ return <Show when={typeof param === "object"} fallback={<>{param}</>}>
7
+ <group>
8
+ {param.name}
9
+ <Show when={!!param.extends}>
10
+ {" "}
11
+ extends
12
+ <indent>
13
+ {" "}
14
+ <TypeRefContext>
15
+ {param.extends}
16
+ </TypeRefContext>
17
+ </indent>
18
+ </Show>
19
+ <Show when={!!param.default}>
20
+ {" = "}
21
+ <TypeRefContext>
22
+ {param.default}
23
+ </TypeRefContext>
24
+ </Show>
25
+ </group>{" "}
26
+ </Show>;
47
27
  }
48
28
  /**
49
29
  * Represent type parameters
@@ -56,25 +36,18 @@ function typeParameter(param) {
56
36
  function TypeParameters(props) {
57
37
  if (props.children) return props.children;
58
38
  if (!props.parameters) return;
59
- return [
60
- "<",
61
- createIntrinsic("group", { get children() {
62
- return createComponent(Indent, {
63
- softline: true,
64
- get children() {
65
- return [createComponent(For, {
66
- get each() {
67
- return props.parameters;
68
- },
69
- comma: true,
70
- line: true,
71
- children: (param) => typeParameter(param)
72
- }), createIntrinsic("ifBreak", { children: "," })];
73
- }
74
- });
75
- } }),
76
- ">"
77
- ];
39
+ return <>
40
+ {"<"}
41
+ <group>
42
+ <Indent softline>
43
+ <For each={props.parameters} comma line>
44
+ {(param) => typeParameter(param)}
45
+ </For>
46
+ <ifBreak>,</ifBreak>
47
+ </Indent>
48
+ </group>
49
+ {">"}
50
+ </>;
78
51
  }
79
52
 
80
53
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"type-parameters.mjs","names":["For","Indent","Show","TypeRefContext","typeParameter","param","_$createComponent","when","fallback","children","_$createIntrinsic","_$memo","name","extends","default","TypeParameters","props","parameters","undefined","softline","each","comma","line"],"sources":["../../../src/typescript/components/type-parameters.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 { Children, For, Indent, Show } from \"@alloy-js/core\";\nimport { TypeParameterDescriptor, TypeRefContext } from \"@alloy-js/typescript\";\n\n/** Props for type parameters */\nexport interface TypeParametersProps {\n /** Parameters */\n parameters?: TypeParameterDescriptor[] | string[];\n /** Jsx Children */\n children?: Children;\n}\n\nfunction typeParameter(param: TypeParameterDescriptor | string) {\n return (\n <Show when={typeof param === \"object\"} fallback={<>{param}</>}>\n <group>\n {(param as TypeParameterDescriptor).name}\n <Show when={!!(param as TypeParameterDescriptor).extends}>\n {\" \"}\n extends\n <indent>\n {\" \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).extends}\n </TypeRefContext>\n </indent>\n </Show>\n <Show when={!!(param as TypeParameterDescriptor).default}>\n {\" = \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).default}\n </TypeRefContext>\n </Show>\n </group>{\" \"}\n </Show>\n );\n}\n\n/**\n * Represent type parameters\n *\n * @example\n * ```ts\n * <A, B extends string>\n * ```\n */\nexport function TypeParameters(props: TypeParametersProps) {\n if (props.children) {\n return props.children;\n }\n\n if (!props.parameters) {\n return undefined;\n }\n\n return (\n <>\n {\"<\"}\n <group>\n <Indent softline>\n <For each={props.parameters} comma line>\n {param => typeParameter(param)}\n </For>\n <ifBreak>,</ifBreak>\n </Indent>\n </group>\n {\">\"}\n </>\n );\n}\n"],"mappings":";;;;;;SA+B6D,cAAA,OAAA;8BAAA;EAAA,MAAA,OAAA,UAAA;EAAA,IAAA,WAAA;AAAA,UAAA,CAAA,MAAA;;EAAA,IAAA,WAAA;AAAA,UAAA,CAAA,gBAAA,SAAA,EAAA,IAAA,WAAA;AAAA,WAAA;KAAA,WAAA,MAEbM,KAAAA;KAAAA,sBACnC;MAAA,IAAA,OAAA;AAAA,cAAA,CAAA,CAAA,MAAA;;MAAA,IAAA,WAAA;AAAA,cAAA;;QAAA;QAAA,gBAAA,UAAA,EAAA,IAAA,WAAA;AAAA,gBAAA,MAAA,gCAAA,EAAA,IAAA,WAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKAH;EAAAA,gBAAAA,SAAAA,EAAAA,IAAAA,WAAAA;AAAAA,UAAAA;;;;;;;;;;;;;;EAC4C;EAAA"}
1
+ {"version":3,"file":"type-parameters.mjs","names":[],"sources":["../../../src/typescript/components/type-parameters.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 { Children, For, Indent, Show } from \"@alloy-js/core\";\nimport { TypeParameterDescriptor, TypeRefContext } from \"@alloy-js/typescript\";\n\n/** Props for type parameters */\nexport interface TypeParametersProps {\n /** Parameters */\n parameters?: TypeParameterDescriptor[] | string[];\n /** Jsx Children */\n children?: Children;\n}\n\nfunction typeParameter(param: TypeParameterDescriptor | string) {\n return (\n <Show when={typeof param === \"object\"} fallback={<>{param}</>}>\n <group>\n {(param as TypeParameterDescriptor).name}\n <Show when={!!(param as TypeParameterDescriptor).extends}>\n {\" \"}\n extends\n <indent>\n {\" \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).extends}\n </TypeRefContext>\n </indent>\n </Show>\n <Show when={!!(param as TypeParameterDescriptor).default}>\n {\" = \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).default}\n </TypeRefContext>\n </Show>\n </group>{\" \"}\n </Show>\n );\n}\n\n/**\n * Represent type parameters\n *\n * @example\n * ```ts\n * <A, B extends string>\n * ```\n */\nexport function TypeParameters(props: TypeParametersProps) {\n if (props.children) {\n return props.children;\n }\n\n if (!props.parameters) {\n return undefined;\n }\n\n return (\n <>\n {\"<\"}\n <group>\n <Indent softline>\n <For each={props.parameters} comma line>\n {param => typeParameter(param)}\n </For>\n <ifBreak>,</ifBreak>\n </Indent>\n </group>\n {\">\"}\n </>\n );\n}\n"],"mappings":";;;;AA6BA,SAAS,cAAc,OAAyC;AAC9D,QACE,CAAC,KAAK,MAAM,OAAO,UAAU,UAAU,UAAU,GAAG,MAAM,KAAK;MAC7D,CAAC,MAAM;SACH,MAAkC,KAAK;QACzC,CAAC,KAAK,MAAM,CAAC,CAAE,MAAkC,SAAS;WACvD,IAAI;;UAEL,CAAC,OAAO;aACL,IAAI;YACL,CAAC,eAAe;eACZ,MAAkC,QAAQ;YAC9C,EAAE,eAAe;UACnB,EAAE,OAAO;QACX,EAAE,KAAK;QACP,CAAC,KAAK,MAAM,CAAC,CAAE,MAAkC,SAAS;WACvD,MAAM;UACP,CAAC,eAAe;aACZ,MAAkC,QAAQ;UAC9C,EAAE,eAAe;QACnB,EAAE,KAAK;MACT,EAAE,OAAO,IAAI;IACf,EAAE;;;;;;;;;;AAYN,SAAgB,eAAe,OAA4B;AACzD,KAAI,MAAM,SACR,QAAO,MAAM;AAGf,KAAI,CAAC,MAAM,WACT;AAGF,QACE,EAAE;OACC,IAAI;MACL,CAAC,MAAM;QACL,CAAC,OAAO,SAAS;UACf,CAAC,IAAI,MAAM,MAAM,YAAY,MAAM,KAAK;cACrC,UAAS,cAAc,MAAM,CAAC;UACjC,EAAE,IAAI;UACN,CAAC,QAAQ,CAAC,EAAE,QAAQ;QACtB,EAAE,OAAO;MACX,EAAE,MAAM;OACP,IAAI;IACP"}
@@ -3,7 +3,6 @@ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
3
  const require_core_contexts_context = require('../../core/contexts/context.cjs');
4
4
  const require_core_components_single_line_comment = require('../../core/components/single-line-comment.cjs');
5
5
  const require_core_components_source_file = require('../../core/components/source-file.cjs');
6
- let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
7
6
  let _alloy_js_core = require("@alloy-js/core");
8
7
  let _stryke_path_append = require("@stryke/path/append");
9
8
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
@@ -41,33 +40,15 @@ function TypescriptFile(props) {
41
40
  if (pkg) if ((0, _stryke_type_checks_is_boolean.isBoolean)(props.export)) pkg.scope.addExport(modulePath, scope);
42
41
  else pkg.scope.addExport(props.export, scope);
43
42
  }
44
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.SourceFileContext.Provider, {
45
- value: { scope },
46
- get children() {
47
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Scope, {
48
- value: scope,
49
- get children() {
50
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_source_file.SourceFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
51
- path: modulePath,
52
- get header() {
53
- return header ?? (0, _alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeader, {
54
- hashbang,
55
- get children() {
56
- return (0, _alloy_js_core_jsx_runtime.createComponent)(TypescriptFileHeaderImports, {
57
- imports,
58
- builtinImports,
59
- scope
60
- });
61
- }
62
- });
63
- },
64
- filetype: tsx ? "tsx" : "typescript",
65
- children
66
- }));
67
- }
68
- });
69
- }
70
- });
43
+ return <_alloy_js_typescript.SourceFileContext.Provider value={{ scope }}>
44
+ <_alloy_js_core.Scope value={scope}>
45
+ <require_core_components_source_file.SourceFile {...rest} path={modulePath} header={header ?? <TypescriptFileHeader hashbang={hashbang}>
46
+ <TypescriptFileHeaderImports imports={imports} builtinImports={builtinImports} scope={scope} />
47
+ </TypescriptFileHeader>} filetype={tsx ? "tsx" : "typescript"}>
48
+ {children}
49
+ </require_core_components_source_file.SourceFile>
50
+ </_alloy_js_core.Scope>
51
+ </_alloy_js_typescript.SourceFileContext.Provider>;
71
52
  }
72
53
  /**
73
54
  * Renders the header for a Powerlines Typescript source file.
@@ -78,79 +59,46 @@ function TypescriptFile(props) {
78
59
  function TypescriptFileHeader(props) {
79
60
  const { header, hashbang, disableEslint = true, disableBiome = true, disablePrettier = false, children } = props;
80
61
  const context = require_core_contexts_context.usePowerlinesSafe();
81
- return [
82
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
83
- get when() {
84
- return Boolean(hashbang);
85
- },
86
- get children() {
87
- return [(0, _alloy_js_core_jsx_runtime.memo)(() => hashbang === true ? _alloy_js_core.code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
88
- }
89
- }),
90
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
91
- get when() {
92
- return Boolean(header);
93
- },
94
- get children() {
95
- return [header, (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
96
- }
97
- }),
98
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
99
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
100
- get when() {
101
- return Boolean(disableEslint);
102
- },
103
- get children() {
104
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, {
105
- variant: "slash-star",
106
- children: "eslint-disable"
107
- }), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
108
- }
109
- }),
110
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
111
- get when() {
112
- return Boolean(disablePrettier);
113
- },
114
- get children() {
115
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, {
116
- variant: "slash-star",
117
- children: "prettier-ignore"
118
- }), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
119
- }
120
- }),
121
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
122
- get when() {
123
- return Boolean(disableBiome);
124
- },
125
- get children() {
126
- return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, { children: "biome-ignore lint: disable" }), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
127
- }
128
- }),
129
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
130
- get when() {
131
- return Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome);
132
- },
133
- get children() {
134
- return (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {});
135
- }
136
- }),
137
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
138
- get when() {
139
- return Boolean(children);
140
- },
141
- get children() {
142
- return [children, (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
143
- }
144
- }),
145
- (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, { get children() {
146
- return `Generated by ${(0, _stryke_string_format_title_case.titleCase)(context?.config?.framework) || "Powerlines"}`;
147
- } }),
148
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
149
- (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, { get children() {
150
- return (0, powerlines_utils.getFileHeaderWarning)(context);
151
- } }),
152
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
153
- ];
62
+ return <>
63
+ <_alloy_js_core.Show when={Boolean(hashbang)}>
64
+ {hashbang === true ? _alloy_js_core.code`#!/usr/bin/env ${context?.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node` : hashbang}
65
+ <hbr />
66
+ </_alloy_js_core.Show>
67
+ <_alloy_js_core.Show when={Boolean(header)}>
68
+ {header}
69
+ <hbr />
70
+ </_alloy_js_core.Show>
71
+ <hbr />
72
+ <_alloy_js_core.Show when={Boolean(disableEslint)}>
73
+ <require_core_components_single_line_comment.SingleLineComment variant="slash-star">
74
+ {"eslint-disable"}
75
+ </require_core_components_single_line_comment.SingleLineComment>
76
+ <hbr />
77
+ </_alloy_js_core.Show>
78
+ <_alloy_js_core.Show when={Boolean(disablePrettier)}>
79
+ <require_core_components_single_line_comment.SingleLineComment variant="slash-star">
80
+ {"prettier-ignore"}
81
+ </require_core_components_single_line_comment.SingleLineComment>
82
+ <hbr />
83
+ </_alloy_js_core.Show>
84
+ <_alloy_js_core.Show when={Boolean(disableBiome)}>
85
+ <require_core_components_single_line_comment.SingleLineComment>{"biome-ignore lint: disable"}</require_core_components_single_line_comment.SingleLineComment>
86
+ <hbr />
87
+ </_alloy_js_core.Show>
88
+ <_alloy_js_core.Show when={Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome)}>
89
+ <hbr />
90
+ </_alloy_js_core.Show>
91
+ <_alloy_js_core.Show when={Boolean(children)}>
92
+ <>
93
+ {children}
94
+ <hbr />
95
+ </>
96
+ </_alloy_js_core.Show>
97
+ <require_core_components_single_line_comment.SingleLineComment>{`Generated by ${(0, _stryke_string_format_title_case.titleCase)(context?.config?.framework) || "Powerlines"}`}</require_core_components_single_line_comment.SingleLineComment>
98
+ <hbr />
99
+ <require_core_components_single_line_comment.SingleLineComment>{(0, powerlines_utils.getFileHeaderWarning)(context)}</require_core_components_single_line_comment.SingleLineComment>
100
+ <hbr />
101
+ </>;
154
102
  }
155
103
  /**
156
104
  * Renders the header for a Powerlines Typescript source file.
@@ -169,60 +117,22 @@ function TypescriptFileHeaderImports(props) {
169
117
  const builtinImports = (0, _alloy_js_core.computed)(() => {
170
118
  return Object.fromEntries(Object.entries(builtinImportsProps ?? {}).map(([module, importItem]) => [module, Array.isArray(importItem) ? (0, _stryke_helpers_get_unique.getUniqueBy)(importItem, (i) => (0, _stryke_type_checks_is_string.isString)(i) ? i : i.alias || i.name) : importItem]));
171
119
  });
172
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
173
- get when() {
174
- return scope.importedModules.size > 0 || !!imports.value && Object.keys(imports.value).length > 0 || !!builtinImports.value && Object.keys(builtinImports.value).length > 0;
175
- },
176
- get children() {
177
- return [
178
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
179
- get when() {
180
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!!!imports.value)() && Object.keys(imports.value).length > 0;
181
- },
182
- get children() {
183
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
184
- get each() {
185
- return Object.entries(imports.value ?? {});
186
- },
187
- hardline: true,
188
- get ender() {
189
- return (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {});
190
- },
191
- children: ([module, importItem]) => _alloy_js_core.code`import ${importItem === null ? "" : (0, _stryke_type_checks_is_string.isString)(importItem) ? importItem : `${importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).map((i) => (0, _stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module}";`
192
- });
193
- }
194
- }),
195
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
196
- get when() {
197
- return (0, _alloy_js_core_jsx_runtime.memo)(() => !!builtinImports.value)() && Object.keys(builtinImports.value).length > 0;
198
- },
199
- get children() {
200
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
201
- get each() {
202
- return Object.entries(builtinImports.value ?? {});
203
- },
204
- hardline: true,
205
- get ender() {
206
- return (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {});
207
- },
208
- children: ([module, importItem]) => _alloy_js_core.code`import ${importItem === null ? "" : (0, _stryke_type_checks_is_string.isString)(importItem) ? importItem : `${importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).map((i) => (0, _stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module.includes(":") ? module : `${context?.config?.framework || "powerlines"}:${module}`}";`
209
- });
210
- }
211
- }),
212
- (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
213
- get when() {
214
- return scope.importedModules.size > 0;
215
- },
216
- get children() {
217
- return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ImportStatements, { get records() {
218
- return scope.importedModules;
219
- } });
220
- }
221
- }),
222
- (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
223
- ];
224
- }
225
- });
120
+ return <_alloy_js_core.Show when={scope.importedModules.size > 0 || !!imports.value && Object.keys(imports.value).length > 0 || !!builtinImports.value && Object.keys(builtinImports.value).length > 0}>
121
+ <_alloy_js_core.Show when={!!imports.value && Object.keys(imports.value).length > 0}>
122
+ <_alloy_js_core.For each={Object.entries(imports.value ?? {})} hardline ender={<hbr />}>
123
+ {([module, importItem]) => _alloy_js_core.code`import ${importItem === null ? "" : (0, _stryke_type_checks_is_string.isString)(importItem) ? importItem : `${importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).map((i) => (0, _stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module}";`}
124
+ </_alloy_js_core.For>
125
+ </_alloy_js_core.Show>
126
+ <_alloy_js_core.Show when={builtinImports.value && Object.keys(builtinImports.value).length > 0}>
127
+ <_alloy_js_core.For each={Object.entries(builtinImports.value ?? {})} hardline ender={<hbr />}>
128
+ {([module, importItem]) => _alloy_js_core.code`import ${importItem === null ? "" : (0, _stryke_type_checks_is_string.isString)(importItem) ? importItem : `${importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).map((i) => i.alias ? i.alias : i.name).join(", ") + (importItem.filter((i) => !(0, _stryke_type_checks_is_string.isString)(i) && i.default).length > 0 && importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? ", " : "") + (importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).length > 0 ? `{ ${importItem.filter((i) => (0, _stryke_type_checks_is_string.isString)(i) || !i.default).map((i) => (0, _stryke_type_checks_is_string.isString)(i) ? i : i.alias ? `${i.name} as ${i.alias}` : i.name).join(", ")} }` : "")}`} from "${module.includes(":") ? module : `${context?.config?.framework || "powerlines"}:${module}`}";`}
129
+ </_alloy_js_core.For>
130
+ </_alloy_js_core.Show>
131
+ <_alloy_js_core.Show when={scope.importedModules.size > 0}>
132
+ <_alloy_js_typescript.ImportStatements records={scope.importedModules} />
133
+ </_alloy_js_core.Show>
134
+ <hbr />
135
+ </_alloy_js_core.Show>;
226
136
  }
227
137
 
228
138
  //#endregion