@powerlines/plugin-alloy 0.24.5 → 0.25.0

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 (88) hide show
  1. package/dist/core/components/output.d.cts +2 -2
  2. package/dist/core/components/single-line-comment.cjs +1 -1
  3. package/dist/core/components/single-line-comment.d.cts +3 -3
  4. package/dist/core/components/single-line-comment.d.cts.map +1 -1
  5. package/dist/core/components/single-line-comment.d.mts +1 -1
  6. package/dist/core/components/single-line-comment.d.mts.map +1 -1
  7. package/dist/core/components/single-line-comment.mjs +1 -1
  8. package/dist/core/components/single-line-comment.mjs.map +1 -1
  9. package/dist/core/components/source-file.d.cts +2 -2
  10. package/dist/core/components/source-file.d.cts.map +1 -1
  11. package/dist/core/components/spacing.d.cts +2 -2
  12. package/dist/core/components/spacing.d.cts.map +1 -1
  13. package/dist/helpers/capnp.cjs +1 -1
  14. package/dist/helpers/capnp.mjs +2 -2
  15. package/dist/helpers/capnp.mjs.map +1 -1
  16. package/dist/markdown/components/front-matter.d.cts +2 -2
  17. package/dist/markdown/components/front-matter.d.cts.map +1 -1
  18. package/dist/markdown/components/markdown-file.cjs +2 -9
  19. package/dist/markdown/components/markdown-file.d.cts +3 -3
  20. package/dist/markdown/components/markdown-file.d.cts.map +1 -1
  21. package/dist/markdown/components/markdown-file.d.mts +3 -3
  22. package/dist/markdown/components/markdown-file.d.mts.map +1 -1
  23. package/dist/markdown/components/markdown-file.mjs +3 -10
  24. package/dist/markdown/components/markdown-file.mjs.map +1 -1
  25. package/dist/markdown/components/markdown-table.d.cts +4 -4
  26. package/dist/markdown/components/markdown-table.d.cts.map +1 -1
  27. package/dist/markdown/components/markdown-table.d.mts +4 -4
  28. package/dist/render.cjs +8 -1
  29. package/dist/render.d.cts.map +1 -1
  30. package/dist/render.d.mts.map +1 -1
  31. package/dist/render.mjs +8 -1
  32. package/dist/render.mjs.map +1 -1
  33. package/dist/typescript/components/builtin-file.d.cts +2 -2
  34. package/dist/typescript/components/builtin-file.d.mts +2 -2
  35. package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
  36. package/dist/typescript/components/dynamic-import-statement.d.cts.map +1 -1
  37. package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
  38. package/dist/typescript/components/entry-file.d.cts +2 -2
  39. package/dist/typescript/components/entry-file.d.mts +2 -2
  40. package/dist/typescript/components/index.cjs +2 -0
  41. package/dist/typescript/components/index.d.cts +2 -1
  42. package/dist/typescript/components/index.d.mts +2 -1
  43. package/dist/typescript/components/index.mjs +2 -1
  44. package/dist/typescript/components/infrastructure-file.cjs +39 -0
  45. package/dist/typescript/components/infrastructure-file.d.cts +21 -0
  46. package/dist/typescript/components/infrastructure-file.d.cts.map +1 -0
  47. package/dist/typescript/components/infrastructure-file.d.mts +21 -0
  48. package/dist/typescript/components/infrastructure-file.d.mts.map +1 -0
  49. package/dist/typescript/components/infrastructure-file.mjs +38 -0
  50. package/dist/typescript/components/infrastructure-file.mjs.map +1 -0
  51. package/dist/typescript/components/interface-declaration.d.cts +2 -2
  52. package/dist/typescript/components/interface-declaration.d.cts.map +1 -1
  53. package/dist/typescript/components/interface-declaration.d.mts +2 -2
  54. package/dist/typescript/components/object-declaration.d.cts +3 -3
  55. package/dist/typescript/components/property-name.d.cts +2 -2
  56. package/dist/typescript/components/property-name.d.mts +2 -2
  57. package/dist/typescript/components/tsdoc-reflection.d.cts +7 -7
  58. package/dist/typescript/components/tsdoc-reflection.d.cts.map +1 -1
  59. package/dist/typescript/components/tsdoc-reflection.d.mts +7 -7
  60. package/dist/typescript/components/tsdoc.d.cts.map +1 -1
  61. package/dist/typescript/components/type-declaration.d.cts +2 -2
  62. package/dist/typescript/components/typescript-file.cjs +2 -9
  63. package/dist/typescript/components/typescript-file.d.cts.map +1 -1
  64. package/dist/typescript/components/typescript-file.d.mts.map +1 -1
  65. package/dist/typescript/components/typescript-file.mjs +2 -9
  66. package/dist/typescript/components/typescript-file.mjs.map +1 -1
  67. package/dist/typescript/contexts/lexical-scope.d.cts +2 -2
  68. package/dist/typescript/contexts/lexical-scope.d.cts.map +1 -1
  69. package/dist/typescript/index.cjs +2 -0
  70. package/dist/typescript/index.d.cts +2 -1
  71. package/dist/typescript/index.d.mts +2 -1
  72. package/dist/typescript/index.mjs +2 -1
  73. package/dist/yaml/components/index.cjs +4 -0
  74. package/dist/yaml/components/index.d.cts +2 -0
  75. package/dist/yaml/components/index.d.mts +2 -0
  76. package/dist/yaml/components/index.mjs +3 -0
  77. package/dist/yaml/components/yaml-file.cjs +148 -0
  78. package/dist/yaml/components/yaml-file.d.cts +34 -0
  79. package/dist/yaml/components/yaml-file.d.cts.map +1 -0
  80. package/dist/yaml/components/yaml-file.d.mts +34 -0
  81. package/dist/yaml/components/yaml-file.d.mts.map +1 -0
  82. package/dist/yaml/components/yaml-file.mjs +147 -0
  83. package/dist/yaml/components/yaml-file.mjs.map +1 -0
  84. package/dist/yaml/index.cjs +5 -0
  85. package/dist/yaml/index.d.cts +3 -0
  86. package/dist/yaml/index.d.mts +3 -0
  87. package/dist/yaml/index.mjs +4 -0
  88. package/package.json +72 -16
@@ -1,6 +1,6 @@
1
1
  import { MetaItem } from "../contexts/meta.cjs";
2
2
  import "../contexts/index.cjs";
3
- import * as _alloy_js_core14 from "@alloy-js/core";
3
+ import * as _alloy_js_core13 from "@alloy-js/core";
4
4
  import { OutputProps as OutputProps$1 } from "@alloy-js/core";
5
5
  import { PluginContext } from "@powerlines/core";
6
6
 
@@ -18,7 +18,7 @@ interface OutputProps<TContext extends PluginContext = PluginContext> extends Om
18
18
  /**
19
19
  * Output component for rendering the Powerlines plugin's output files via templates.
20
20
  */
21
- declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core14.Children;
21
+ declare function Output<TContext extends PluginContext = PluginContext>(props: OutputProps<TContext>): _alloy_js_core13.Children;
22
22
  declare type __ΩOutputProps = any[];
23
23
  //#endregion
24
24
  export { Output, OutputProps, __ΩOutputProps };
@@ -9,7 +9,7 @@ let __alloy_js_core = require("@alloy-js/core");
9
9
  */
10
10
  function SingleLineComment(props) {
11
11
  const { variant = "double-slash", children } = props;
12
- const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
12
+ const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : variant === "yaml" ? "# " : "// ";
13
13
  return [commentStart, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
14
14
  string: commentStart,
15
15
  get children() {
@@ -1,8 +1,8 @@
1
1
  import { ComponentProps } from "../../types/components.cjs";
2
- import * as _alloy_js_core15 from "@alloy-js/core";
2
+ import * as _alloy_js_core11 from "@alloy-js/core";
3
3
 
4
4
  //#region src/core/components/single-line-comment.d.ts
5
- type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
5
+ type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown" | "yaml";
6
6
  interface SingleLineCommentProps extends ComponentProps {
7
7
  /**
8
8
  * The variant of the single line comment.
@@ -15,7 +15,7 @@ interface SingleLineCommentProps extends ComponentProps {
15
15
  * A single line comment block. The children are rendered as a prose element, which means that they
16
16
  * are broken into multiple lines
17
17
  */
18
- declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core15.Children;
18
+ declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core11.Children;
19
19
  declare type __ΩSingleLineCommentVariant = any[];
20
20
  declare type __ΩSingleLineCommentProps = any[];
21
21
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"single-line-comment.d.cts","names":[],"sources":["../../../src/core/components/single-line-comment.tsx"],"sourcesContent":[],"mappings":";;;;KAqBY,wBAAA;UAOK,sBAAA,SAA+B;;AAPhD;AAOA;AAaA;;YAPY;;;;;;iBAOI,iBAAA,QAAyB,yBAAsB,gBAAA,CAAA"}
1
+ {"version":3,"file":"single-line-comment.d.cts","names":[],"sources":["../../../src/core/components/single-line-comment.tsx"],"sourcesContent":[],"mappings":";;;;KAqBY,wBAAA;UAQK,sBAAA,SAA+B;;AARhD;AAQA;AAaA;;YAPY;;;;;;iBAOI,iBAAA,QAAyB,yBAAsB,gBAAA,CAAA"}
@@ -2,7 +2,7 @@ import { ComponentProps } from "../../types/components.mjs";
2
2
  import * as _alloy_js_core1 from "@alloy-js/core";
3
3
 
4
4
  //#region src/core/components/single-line-comment.d.ts
5
- type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
5
+ type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown" | "yaml";
6
6
  interface SingleLineCommentProps extends ComponentProps {
7
7
  /**
8
8
  * The variant of the single line comment.
@@ -1 +1 @@
1
- {"version":3,"file":"single-line-comment.d.mts","names":[],"sources":["../../../src/core/components/single-line-comment.tsx"],"sourcesContent":[],"mappings":";;;;KAqBY,wBAAA;UAOK,sBAAA,SAA+B;;AAPhD;AAOA;AAaA;;YAPY;;;;;;iBAOI,iBAAA,QAAyB,yBAAsB,eAAA,CAAA"}
1
+ {"version":3,"file":"single-line-comment.d.mts","names":[],"sources":["../../../src/core/components/single-line-comment.tsx"],"sourcesContent":[],"mappings":";;;;KAqBY,wBAAA;UAQK,sBAAA,SAA+B;;AARhD;AAQA;AAaA;;YAPY;;;;;;iBAOI,iBAAA,QAAyB,yBAAsB,eAAA,CAAA"}
@@ -8,7 +8,7 @@ import { Prose } from "@alloy-js/core";
8
8
  */
9
9
  function SingleLineComment(props) {
10
10
  const { variant = "double-slash", children } = props;
11
- const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
11
+ const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : variant === "yaml" ? "# " : "// ";
12
12
  return [commentStart, createIntrinsic("align", {
13
13
  string: commentStart,
14
14
  get children() {
@@ -1 +1 @@
1
- {"version":3,"file":"single-line-comment.mjs","names":["Prose","SingleLineComment","props","variant","children","commentStart","_$createIntrinsic","string","_$createComponent"],"sources":["../../../src/core/components/single-line-comment.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 { Prose } from \"@alloy-js/core\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport type SingleLineCommentVariant =\n | \"double-slash\"\n | \"triple-slash\"\n | \"slash-star\"\n | \"slash-star-star\"\n | \"markdown\";\n\nexport interface SingleLineCommentProps extends ComponentProps {\n /**\n * The variant of the single line comment.\n *\n * @defaultValue \"double-slash\"\n */\n variant?: SingleLineCommentVariant;\n}\n\n/**\n * A single line comment block. The children are rendered as a prose element, which means that they\n * are broken into multiple lines\n */\nexport function SingleLineComment(props: SingleLineCommentProps) {\n const { variant = \"double-slash\", children } = props;\n\n const commentStart =\n variant === \"slash-star\"\n ? \"/* \"\n : variant === \"slash-star-star\"\n ? \"/** \"\n : variant === \"triple-slash\"\n ? \"/// \"\n : variant === \"markdown\"\n ? \"<!-- \"\n : \"// \";\n\n return (\n <>\n {commentStart}\n <align string={commentStart}>\n <Prose>{children}</Prose>\n\n {variant === \"slash-star\" || variant === \"slash-star-star\"\n ? \" */ \"\n : variant === \"markdown\"\n ? \" -->\"\n : \"\"}\n </align>\n </>\n );\n}\n"],"mappings":""}
1
+ {"version":3,"file":"single-line-comment.mjs","names":["Prose","SingleLineComment","props","variant","children","commentStart","_$createIntrinsic","string","_$createComponent"],"sources":["../../../src/core/components/single-line-comment.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 { Prose } from \"@alloy-js/core\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport type SingleLineCommentVariant =\n | \"double-slash\"\n | \"triple-slash\"\n | \"slash-star\"\n | \"slash-star-star\"\n | \"markdown\"\n | \"yaml\";\n\nexport interface SingleLineCommentProps extends ComponentProps {\n /**\n * The variant of the single line comment.\n *\n * @defaultValue \"double-slash\"\n */\n variant?: SingleLineCommentVariant;\n}\n\n/**\n * A single line comment block. The children are rendered as a prose element, which means that they\n * are broken into multiple lines\n */\nexport function SingleLineComment(props: SingleLineCommentProps) {\n const { variant = \"double-slash\", children } = props;\n\n const commentStart =\n variant === \"slash-star\"\n ? \"/* \"\n : variant === \"slash-star-star\"\n ? \"/** \"\n : variant === \"triple-slash\"\n ? \"/// \"\n : variant === \"markdown\"\n ? \"<!-- \"\n : variant === \"yaml\"\n ? \"# \"\n : \"// \";\n\n return (\n <>\n {commentStart}\n <align string={commentStart}>\n <Prose>{children}</Prose>\n\n {variant === \"slash-star\" || variant === \"slash-star-star\"\n ? \" */ \"\n : variant === \"markdown\"\n ? \" -->\"\n : \"\"}\n </align>\n </>\n );\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from "../../types/components.cjs";
2
- import * as _alloy_js_core13 from "@alloy-js/core";
2
+ import * as _alloy_js_core7 from "@alloy-js/core";
3
3
  import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
4
4
  import { StoragePreset } from "powerlines";
5
5
 
@@ -26,7 +26,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
26
26
  * @param props - The properties for the source file.
27
27
  * @returns The rendered source file component.
28
28
  */
29
- declare function SourceFile(props: SourceFileProps): _alloy_js_core13.Children;
29
+ declare function SourceFile(props: SourceFileProps): _alloy_js_core7.Children;
30
30
  declare type __ΩSourceFileProps = any[];
31
31
  //#endregion
32
32
  export { SourceFile, SourceFileProps, __ΩSourceFileProps };
@@ -1 +1 @@
1
- {"version":3,"file":"source-file.d.cts","names":[],"sources":["../../../src/core/components/source-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkCY,eAAA,GAAkB,oBAC5B;;;AADF;;;;EAgBW,OAAA,CAAA,EARG,aAQH;EAAM;AASjB;;;;;SATW;;;;;;;;iBASK,UAAA,QAAkB,kBAAe,gBAAA,CAAA"}
1
+ {"version":3,"file":"source-file.d.cts","names":[],"sources":["../../../src/core/components/source-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkCY,eAAA,GAAkB,oBAC5B;;;AADF;;;;EAgBW,OAAA,CAAA,EARG,aAQH;EAAM;AASjB;;;;;SATW;;;;;;;;iBASK,UAAA,QAAkB,kBAAe,eAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core12 from "@alloy-js/core";
1
+ import * as _alloy_js_core6 from "@alloy-js/core";
2
2
 
3
3
  //#region src/core/components/spacing.d.ts
4
4
  interface SpacingProps {
@@ -17,7 +17,7 @@ interface SpacingProps {
17
17
  */
18
18
  declare function Spacing({
19
19
  scale
20
- }: SpacingProps): _alloy_js_core12.Children;
20
+ }: SpacingProps): _alloy_js_core6.Children;
21
21
  declare type __ΩSpacingProps = any[];
22
22
  //#endregion
23
23
  export { Spacing, SpacingProps, __ΩSpacingProps };
@@ -1 +1 @@
1
- {"version":3,"file":"spacing.d.cts","names":[],"sources":["../../../src/core/components/spacing.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,YAAA;;;AAAjB;AAeA;;;;;;;;;;iBAAgB,OAAA;;GAAuB,eAAY,gBAAA,CAAA"}
1
+ {"version":3,"file":"spacing.d.cts","names":[],"sources":["../../../src/core/components/spacing.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,YAAA;;;AAAjB;AAeA;;;;;;;;;;iBAAgB,OAAA;;GAAuB,eAAY,eAAA,CAAA"}
@@ -118,7 +118,7 @@ async function generateCapnpId() {
118
118
  }
119
119
  async function generateCapnp(context, reflection, options) {
120
120
  return `${(await generateCapnpId()).trim()};
121
- ${(0, powerlines_utils.getBaseFileHeader)(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
121
+ ${(0, powerlines_utils.getFileHeader)(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
122
122
  ${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
123
123
  `.trim();
124
124
  }
@@ -20,7 +20,7 @@ import { isString } from "@stryke/type-checks/is-string";
20
20
  import { Buffer } from "node:buffer";
21
21
  import { exec } from "node:child_process";
22
22
  import { promisify } from "node:util";
23
- import { getBaseFileHeader } from "powerlines/utils";
23
+ import { getFileHeader } from "powerlines/utils";
24
24
 
25
25
  //#region src/helpers/capnp.ts
26
26
  /**
@@ -116,7 +116,7 @@ async function generateCapnpId() {
116
116
  }
117
117
  async function generateCapnp(context, reflection, options) {
118
118
  return `${(await generateCapnpId()).trim()};
119
- ${getBaseFileHeader(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
119
+ ${getFileHeader(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
120
120
  ${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
121
121
  `.trim();
122
122
  }
@@ -1 +1 @@
1
- {"version":3,"file":"capnp.mjs","names":["getUnionTypes","kindToName","getClassName","memberNameToString","ReflectionKind","capnpc","resolveOptions","toArray","getUniqueBy","StormJSON","joinPaths","camelCase","getWords","pascalCase","titleCase","isBigInt","isNull","isNumber","isString","isUndefined","defu","Buffer","exec","promisify","getBaseFileHeader","compile","context","options","opts","ts","js","dts","schemas","artifactsPath","tsconfig","projectRoot","config","root","workspaceRoot","workspaceConfig","tty","resolvedOptions","Error","join","stringifyCapnpDefaultValue","property","value","stringifyCapnpValue","type","getDefaultValue","kind","string","literal","String","enum","array","stringify","object","objectLiteral","replaceAll","getCapnpEnumTypes","unique","values","filter","enumMember","length","isVoidType","void","never","null","undefined","symbol","getCapnpUnionTypes","isCapnpStringUnion","some","member","LARGE_BUFFER","execAsync","generateCapnpId","stdout","windowsHide","maxBuffer","killSignal","generateCapnp","reflection","capnpId","trim","replace","getMethods","generateCapnpStruct","generateCapnpInterface","structName","name","getTitle","getName","generateCapnpEnums","generateCapnpSchema","interfaceName","formatEnumName","enums","getProperties","prop","isIgnored","union","sort","a","b","isReadonly","getNameAsString","localeCompare","map","enumeration","generateCapnpEnumSchema","index","indexCounter","generateCapnpPropertySchema","methods","generateCapnpMethodSchema","class","classType","Map","Date","methodName","reflectionClass","getParameters","param","generateCapnpPrimitive","getType","hasDefault","getReturnType","getDescription","generateCapnpPropertyComment","result","relaxed","reduce","ret","word","includes","substring","lastIndexOf","current","getSubType","typeArguments","ArrayBuffer","typeName","indexType","types","enumType","Object","entries","key","Set","bigint","number","regexp","boolean"],"sources":["../../src/helpers/capnp.ts"],"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 { getUnionTypes, kindToName } from \"@powerlines/deepkit/utilities\";\nimport { getClassName } from \"@powerlines/deepkit/vendor/core\";\nimport {\n memberNameToString,\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeEnum,\n TypeLiteral,\n TypeUnion\n} from \"@powerlines/deepkit/vendor/type\";\nimport { capnpc } from \"@stryke/capnp/compile\";\nimport { resolveOptions } from \"@stryke/capnp/helpers\";\nimport type { CapnpcOptions, CapnpcResult } from \"@stryke/capnp/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { getWords } from \"@stryke/string-format/get-words\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport defu from \"defu\";\nimport { Buffer } from \"node:buffer\";\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Context, PluginContext } from \"powerlines\";\nimport { getBaseFileHeader } from \"powerlines/utils\";\n\n/**\n * Compiles a Cap'n Proto schema into TypeScript definitions.\n *\n * @param context - The context containing the project and workspace information.\n * @param options - The options for compiling the schema.\n * @returns A promise that resolves to the compiled schema.\n */\nexport async function compile(\n context: Context,\n options: Partial<CapnpcOptions> = {}\n): Promise<CapnpcResult> {\n const opts = defu(options, {\n ts: true,\n js: false,\n dts: false,\n schemas: joinPaths(context.artifactsPath, \"schemas\"),\n tsconfig: context.tsconfig,\n projectRoot: context.config.root,\n workspaceRoot: context.workspaceConfig.workspaceRoot,\n tty: true\n }) as Parameters<typeof resolveOptions>[0];\n\n const resolvedOptions = await resolveOptions(opts);\n if (!resolvedOptions) {\n throw new Error(\n `✖ No Cap'n Proto schema files found in the specified source paths: ${toArray(\n opts.schemas\n ).join(\", \")}.`\n );\n }\n\n return capnpc(resolvedOptions);\n}\n\n/**\n * Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.\n *\n * @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpDefaultValue(\n property: ReflectionProperty | ReflectionParameter,\n value?: any\n): string {\n return stringifyCapnpValue(\n property.type,\n value ?? property.getDefaultValue()\n );\n}\n\n/**\n * Converts any {@link Type}'s actual value to string representation.\n *\n * @param type - The {@link Type} of the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpValue(type: Type, value: any): string {\n return type.kind === ReflectionKind.string ||\n (type.kind === ReflectionKind.literal && isString(type.literal))\n ? `\"${String(value)}\"`\n : type.kind === ReflectionKind.enum\n ? `${camelCase(String(value))}`\n : type.kind === ReflectionKind.array\n ? StormJSON.stringify(value)\n : type.kind === ReflectionKind.object ||\n type.kind === ReflectionKind.objectLiteral\n ? StormJSON.stringify(value).replaceAll(\"{\", \"(\").replaceAll(\"}\", \")\")\n : String(value);\n}\n\n/**\n * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.\n *\n * @param type - The TypeEnum to evaluate.\n * @returns A string representation of the property.\n */\nexport function getCapnpEnumTypes(type: Type): \"Text\" | \"Float32\" | null {\n if (type.kind !== ReflectionKind.enum) {\n return null;\n }\n\n const unique = getUniqueBy(\n type.values.filter(value => !isUndefined(value) && !isNull(value)),\n enumMember => (isString(enumMember) ? \"Text\" : \"Float32\")\n );\n if (unique.length === 0) {\n return null;\n }\n\n return unique[0] && isString(unique[0]) ? \"Text\" : \"Float32\";\n}\n\n/**\n * Determines if a Type is a `Void` type in a Cap'n Proto schema.\n *\n * @param type - The Type to check.\n * @returns True if the Type is a `Void` type, false otherwise.\n */\nexport function isVoidType(type: Type): boolean {\n return (\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n );\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function getCapnpUnionTypes(type: Type): Type[] {\n return getUnionTypes(type);\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns An array of Cap'n Proto primitive types.\n */\nexport function isCapnpStringUnion(type: Type): boolean {\n return getCapnpUnionTypes(type).some(\n member => member.kind === ReflectionKind.string\n );\n}\n\nexport const LARGE_BUFFER = 1024 * 1000000;\nexport type IOType = \"overlapped\" | \"pipe\" | \"ignore\" | \"inherit\";\nexport type StdioOptions =\n | IOType\n | Array<IOType | \"ipc\" | number | null | undefined>;\n\nconst execAsync = promisify(exec);\n\nexport async function generateCapnpId() {\n const { stdout } = await execAsync(\"capnp id\", {\n windowsHide: true,\n maxBuffer: LARGE_BUFFER,\n killSignal: \"SIGTERM\"\n });\n\n return stdout;\n}\n\nexport interface GenerateCapnpOptions {\n name?: string;\n}\n\nexport async function generateCapnp(\n context: PluginContext,\n reflection: ReflectionClass<any>,\n options: GenerateCapnpOptions\n) {\n const capnpId = await generateCapnpId();\n\n return `${capnpId.trim()};\n${getBaseFileHeader(context)\n .replace(/^\\r*\\n*/g, \"\")\n .replaceAll(\"//\", \"#\")}\n${\n reflection.getMethods().length === 0\n ? generateCapnpStruct(reflection, options)\n : generateCapnpInterface(reflection, options)\n}\n`.trim();\n}\n\nexport interface GenerateCapnpStructOptions extends GenerateCapnpOptions {\n indexCounter?: () => number;\n}\n\nexport function generateCapnpStruct(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const structName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}struct ${pascalCase(structName)} {\n # Struct definition for ${titleCase(structName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nexport function generateCapnpInterface(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const interfaceName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}interface ${pascalCase(interfaceName)} {\n # Interface definition for ${titleCase(interfaceName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nfunction formatEnumName(name: string) {\n return pascalCase(`${name}_Type`);\n}\n\nfunction generateCapnpEnums(reflection: ReflectionClass<any>): string {\n const enums = reflection\n .getProperties()\n .filter(\n prop =>\n !prop.isIgnored() &&\n (prop.type.kind === ReflectionKind.enum ||\n (prop.type.kind === ReflectionKind.union &&\n getCapnpUnionTypes(prop.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1))\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n );\n if (enums.length === 0) {\n return \"\";\n }\n\n return `${enums\n .map(enumeration =>\n generateCapnpEnumSchema(\n enumeration.type as TypeEnum | TypeUnion,\n formatEnumName(enumeration.getNameAsString())\n )\n )\n .join(\"\\n\\n\")}\n\n`;\n}\n\nexport function generateCapnpSchema(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n let index = 0;\n const indexCounter: () => number = options?.indexCounter ?? (() => index++);\n\n return `${reflection\n .getProperties()\n .filter(prop => !prop.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(prop => generateCapnpPropertySchema(prop, indexCounter))\n .join(\" \\n\\n\\t\")}${reflection\n .getMethods()\n .filter(methods => !methods.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? String(b.getName()).localeCompare(String(a.getName()))\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(methods => generateCapnpMethodSchema(methods, indexCounter))\n .join(\" \\n\\n\\t\")}${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class && prop.type.classType === Map\n )\n ? `\n struct Map(Key, Value) {\n entries @0 :List(Entry);\n\n struct Entry {\n key @0 :Key;\n value @1 :Value;\n }\n }`\n : \"\"\n }${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class &&\n prop.type.classType === Date\n )\n ? `\n struct Date {\n # A standard Gregorian calendar date.\n\n year @0 :Int16;\n # The year - Must include the century.\n # Negative value indicates BC.\n\n month @1 :UInt8; # The month, 1-12\n\n day @2 :UInt8; # The day of the month, 1-30\n\n hour @3 :UInt8; # The hour of the day, 0-23\n\n minute @4 :UInt8; # The minute of the hour, 0-59\n\n second @5 :UInt8; # The second of the minute, 0-59\n\n millisecond @6 :UInt16; # Milliseconds of the second, 0-999\n }`\n : \"\"\n }`;\n}\n\nexport function generateCapnpMethodSchema(\n reflection: ReflectionMethod,\n indexCounter: () => number\n): string {\n const methodName =\n reflection.getTitle() || typeof reflection.getName() === \"string\"\n ? String(reflection.getName())\n : \"\";\n if (!methodName) {\n throw new Error(\n `Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`\n );\n }\n\n return `${camelCase(methodName)} @${indexCounter()} (${reflection\n .getParameters()\n .map(param => {\n return `${camelCase(\n param.getName()\n )} :${generateCapnpPrimitive(param.getType())}${\n param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : \"\"\n }`;\n })\n .join(\", \")})${\n isVoidType(reflection.getReturnType())\n ? \"\"\n : ` -> (${kindToName(\n reflection.getReturnType().kind\n )}: ${generateCapnpPrimitive(reflection.getReturnType())})`\n }; # ${(\n reflection.getDescription() ||\n `The ${titleCase(\n reflection.reflectionClass.getTitle() ||\n reflection.reflectionClass.getName()\n )} interface ${titleCase(methodName)} method.`\n ).replaceAll(\"\\n\", \". \")}`;\n}\n\nfunction generateCapnpPropertyComment(reflection: ReflectionProperty) {\n const result = getWords(\n reflection.getDescription() ||\n `A schema property for ${titleCase(\n reflection.getTitle() || reflection.getNameAsString()\n )} field.`,\n {\n relaxed: true\n }\n )\n .reduce((ret, word) => {\n let length = ret.length;\n if (ret.includes(\"\\n\")) {\n length = ret.substring(ret.lastIndexOf(\"\\n\") + 1).length;\n }\n\n const current = word.trim();\n if (length + current.length > 60) {\n ret += `\\n\\t# ${current}`;\n } else {\n ret += ` ${current}`;\n }\n return ret;\n }, \"\")\n .trim();\n if (result.length > 0) {\n return `\\t# ${result}`;\n }\n\n return \"\";\n}\n\nfunction generateCapnpPropertySchema(\n reflection: ReflectionProperty,\n indexCounter: () => number\n): string {\n if (reflection.type.kind === ReflectionKind.union) {\n if (getCapnpUnionTypes(reflection.type).length === 0) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;\n${generateCapnpPropertyComment(reflection)}`;\n } else if (\n getCapnpUnionTypes(reflection.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1\n ) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} :union {\n${getCapnpUnionTypes(reflection.type)\n .map(\n type =>\n ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(\n type\n )};`\n )\n .join(\"\\n\")}\n }\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.array) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.class) {\n if (reflection.type.classType === Map) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Map(${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length === 0 ||\n !reflection.type.typeArguments[0]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[0])\n }, ${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length < 2 ||\n !reflection.type.typeArguments[1]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[1])\n })${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Date) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Buffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === ArrayBuffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.objectLiteral) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.enum) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(\n reflection.getType()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n}\n\nexport function generateCapnpEnumSchema(\n type: TypeEnum | TypeUnion,\n name: string\n): string {\n if (type.kind === ReflectionKind.union) {\n return generateCapnpEnumSchema(\n {\n kind: ReflectionKind.enum,\n indexType: type,\n enum: (type.types as TypeLiteral[]).reduce<\n Record<string, string | number>\n >((ret, type) => {\n if (isString(type.literal) || isNumber(type.literal)) {\n ret[camelCase(String(type.literal))] = type.literal;\n }\n\n return ret;\n }, {}),\n values: (\n getCapnpUnionTypes(type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ) as TypeLiteral[]\n ).map(type => type.literal as string | number)\n },\n name\n );\n }\n\n let index = 0;\n const indexCounter: () => number = () => index++;\n\n const enumType = getCapnpEnumTypes(type);\n if (!enumType) {\n return \"\";\n }\n\n return `enum ${pascalCase(name)} {\n${\n type.enum && Object.entries(type.enum).length > 0\n ? Object.entries(type.enum)\n .filter(([, value]) => value !== null && value !== undefined)\n .map(([key]) => ` ${camelCase(key)} @${indexCounter()};`)\n .join(\"\\n\")\n : type.values\n .filter(value => value !== null && value !== undefined)\n .map(\n value =>\n `${\n enumType === \"Text\" && value\n ? camelCase(String(value))\n : `${\n type.typeName ? `${camelCase(type.typeName)}_` : \"\"\n }${value || \"\"}`\n } @${indexCounter()};`\n )\n .join(\"\\n\")\n}\n }`;\n}\n\n/**\n * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.\n *\n * @param type - The Deepkit Type to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function generateCapnpPrimitive(type: Type): string {\n return type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n ? \"Void\"\n : type.kind === ReflectionKind.class && type.classType === Date\n ? \"Date\"\n : type.kind === ReflectionKind.class && type.classType === Set\n ? `List(${\n type.typeArguments && type.typeArguments[0]\n ? generateCapnpPrimitive(type.typeArguments[0])\n : \"Data\"\n })`\n : type.kind === ReflectionKind.bigint\n ? \"UInt64\"\n : type.kind === ReflectionKind.number\n ? \"Float64\"\n : type.kind === ReflectionKind.string ||\n type.kind === ReflectionKind.regexp\n ? \"Text\"\n : type.kind === ReflectionKind.boolean\n ? \"Bool\"\n : type.kind === ReflectionKind.literal\n ? isNumber(type.literal)\n ? \"Float64\"\n : isBigInt(type.literal)\n ? \"UInt64\"\n : isString(type.literal)\n ? \"Text\"\n : typeof type.literal === \"boolean\"\n ? \"Bool\"\n : \"Data\"\n : \"Data\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgdA,UAAA,EAAA"}
1
+ {"version":3,"file":"capnp.mjs","names":["getUnionTypes","kindToName","getClassName","memberNameToString","ReflectionKind","capnpc","resolveOptions","toArray","getUniqueBy","StormJSON","joinPaths","camelCase","getWords","pascalCase","titleCase","isBigInt","isNull","isNumber","isString","isUndefined","defu","Buffer","exec","promisify","getFileHeader","compile","context","options","opts","ts","js","dts","schemas","artifactsPath","tsconfig","projectRoot","config","root","workspaceRoot","workspaceConfig","tty","resolvedOptions","Error","join","stringifyCapnpDefaultValue","property","value","stringifyCapnpValue","type","getDefaultValue","kind","string","literal","String","enum","array","stringify","object","objectLiteral","replaceAll","getCapnpEnumTypes","unique","values","filter","enumMember","length","isVoidType","void","never","null","undefined","symbol","getCapnpUnionTypes","isCapnpStringUnion","some","member","LARGE_BUFFER","execAsync","generateCapnpId","stdout","windowsHide","maxBuffer","killSignal","generateCapnp","reflection","capnpId","trim","replace","getMethods","generateCapnpStruct","generateCapnpInterface","structName","name","getTitle","getName","generateCapnpEnums","generateCapnpSchema","interfaceName","formatEnumName","enums","getProperties","prop","isIgnored","union","sort","a","b","isReadonly","getNameAsString","localeCompare","map","enumeration","generateCapnpEnumSchema","index","indexCounter","generateCapnpPropertySchema","methods","generateCapnpMethodSchema","class","classType","Map","Date","methodName","reflectionClass","getParameters","param","generateCapnpPrimitive","getType","hasDefault","getReturnType","getDescription","generateCapnpPropertyComment","result","relaxed","reduce","ret","word","includes","substring","lastIndexOf","current","getSubType","typeArguments","ArrayBuffer","typeName","indexType","types","enumType","Object","entries","key","Set","bigint","number","regexp","boolean"],"sources":["../../src/helpers/capnp.ts"],"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 { getUnionTypes, kindToName } from \"@powerlines/deepkit/utilities\";\nimport { getClassName } from \"@powerlines/deepkit/vendor/core\";\nimport {\n memberNameToString,\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeEnum,\n TypeLiteral,\n TypeUnion\n} from \"@powerlines/deepkit/vendor/type\";\nimport { capnpc } from \"@stryke/capnp/compile\";\nimport { resolveOptions } from \"@stryke/capnp/helpers\";\nimport type { CapnpcOptions, CapnpcResult } from \"@stryke/capnp/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { getWords } from \"@stryke/string-format/get-words\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport defu from \"defu\";\nimport { Buffer } from \"node:buffer\";\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Context, PluginContext } from \"powerlines\";\nimport { getFileHeader } from \"powerlines/utils\";\n\n/**\n * Compiles a Cap'n Proto schema into TypeScript definitions.\n *\n * @param context - The context containing the project and workspace information.\n * @param options - The options for compiling the schema.\n * @returns A promise that resolves to the compiled schema.\n */\nexport async function compile(\n context: Context,\n options: Partial<CapnpcOptions> = {}\n): Promise<CapnpcResult> {\n const opts = defu(options, {\n ts: true,\n js: false,\n dts: false,\n schemas: joinPaths(context.artifactsPath, \"schemas\"),\n tsconfig: context.tsconfig,\n projectRoot: context.config.root,\n workspaceRoot: context.workspaceConfig.workspaceRoot,\n tty: true\n }) as Parameters<typeof resolveOptions>[0];\n\n const resolvedOptions = await resolveOptions(opts);\n if (!resolvedOptions) {\n throw new Error(\n `✖ No Cap'n Proto schema files found in the specified source paths: ${toArray(\n opts.schemas\n ).join(\", \")}.`\n );\n }\n\n return capnpc(resolvedOptions);\n}\n\n/**\n * Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.\n *\n * @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpDefaultValue(\n property: ReflectionProperty | ReflectionParameter,\n value?: any\n): string {\n return stringifyCapnpValue(\n property.type,\n value ?? property.getDefaultValue()\n );\n}\n\n/**\n * Converts any {@link Type}'s actual value to string representation.\n *\n * @param type - The {@link Type} of the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpValue(type: Type, value: any): string {\n return type.kind === ReflectionKind.string ||\n (type.kind === ReflectionKind.literal && isString(type.literal))\n ? `\"${String(value)}\"`\n : type.kind === ReflectionKind.enum\n ? `${camelCase(String(value))}`\n : type.kind === ReflectionKind.array\n ? StormJSON.stringify(value)\n : type.kind === ReflectionKind.object ||\n type.kind === ReflectionKind.objectLiteral\n ? StormJSON.stringify(value).replaceAll(\"{\", \"(\").replaceAll(\"}\", \")\")\n : String(value);\n}\n\n/**\n * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.\n *\n * @param type - The TypeEnum to evaluate.\n * @returns A string representation of the property.\n */\nexport function getCapnpEnumTypes(type: Type): \"Text\" | \"Float32\" | null {\n if (type.kind !== ReflectionKind.enum) {\n return null;\n }\n\n const unique = getUniqueBy(\n type.values.filter(value => !isUndefined(value) && !isNull(value)),\n enumMember => (isString(enumMember) ? \"Text\" : \"Float32\")\n );\n if (unique.length === 0) {\n return null;\n }\n\n return unique[0] && isString(unique[0]) ? \"Text\" : \"Float32\";\n}\n\n/**\n * Determines if a Type is a `Void` type in a Cap'n Proto schema.\n *\n * @param type - The Type to check.\n * @returns True if the Type is a `Void` type, false otherwise.\n */\nexport function isVoidType(type: Type): boolean {\n return (\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n );\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function getCapnpUnionTypes(type: Type): Type[] {\n return getUnionTypes(type);\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns An array of Cap'n Proto primitive types.\n */\nexport function isCapnpStringUnion(type: Type): boolean {\n return getCapnpUnionTypes(type).some(\n member => member.kind === ReflectionKind.string\n );\n}\n\nexport const LARGE_BUFFER = 1024 * 1000000;\nexport type IOType = \"overlapped\" | \"pipe\" | \"ignore\" | \"inherit\";\nexport type StdioOptions =\n | IOType\n | Array<IOType | \"ipc\" | number | null | undefined>;\n\nconst execAsync = promisify(exec);\n\nexport async function generateCapnpId() {\n const { stdout } = await execAsync(\"capnp id\", {\n windowsHide: true,\n maxBuffer: LARGE_BUFFER,\n killSignal: \"SIGTERM\"\n });\n\n return stdout;\n}\n\nexport interface GenerateCapnpOptions {\n name?: string;\n}\n\nexport async function generateCapnp(\n context: PluginContext,\n reflection: ReflectionClass<any>,\n options: GenerateCapnpOptions\n) {\n const capnpId = await generateCapnpId();\n\n return `${capnpId.trim()};\n${getFileHeader(context)\n .replace(/^\\r*\\n*/g, \"\")\n .replaceAll(\"//\", \"#\")}\n${\n reflection.getMethods().length === 0\n ? generateCapnpStruct(reflection, options)\n : generateCapnpInterface(reflection, options)\n}\n`.trim();\n}\n\nexport interface GenerateCapnpStructOptions extends GenerateCapnpOptions {\n indexCounter?: () => number;\n}\n\nexport function generateCapnpStruct(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const structName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}struct ${pascalCase(structName)} {\n # Struct definition for ${titleCase(structName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nexport function generateCapnpInterface(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const interfaceName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}interface ${pascalCase(interfaceName)} {\n # Interface definition for ${titleCase(interfaceName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nfunction formatEnumName(name: string) {\n return pascalCase(`${name}_Type`);\n}\n\nfunction generateCapnpEnums(reflection: ReflectionClass<any>): string {\n const enums = reflection\n .getProperties()\n .filter(\n prop =>\n !prop.isIgnored() &&\n (prop.type.kind === ReflectionKind.enum ||\n (prop.type.kind === ReflectionKind.union &&\n getCapnpUnionTypes(prop.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1))\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n );\n if (enums.length === 0) {\n return \"\";\n }\n\n return `${enums\n .map(enumeration =>\n generateCapnpEnumSchema(\n enumeration.type as TypeEnum | TypeUnion,\n formatEnumName(enumeration.getNameAsString())\n )\n )\n .join(\"\\n\\n\")}\n\n`;\n}\n\nexport function generateCapnpSchema(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n let index = 0;\n const indexCounter: () => number = options?.indexCounter ?? (() => index++);\n\n return `${reflection\n .getProperties()\n .filter(prop => !prop.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(prop => generateCapnpPropertySchema(prop, indexCounter))\n .join(\" \\n\\n\\t\")}${reflection\n .getMethods()\n .filter(methods => !methods.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? String(b.getName()).localeCompare(String(a.getName()))\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(methods => generateCapnpMethodSchema(methods, indexCounter))\n .join(\" \\n\\n\\t\")}${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class && prop.type.classType === Map\n )\n ? `\n struct Map(Key, Value) {\n entries @0 :List(Entry);\n\n struct Entry {\n key @0 :Key;\n value @1 :Value;\n }\n }`\n : \"\"\n }${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class &&\n prop.type.classType === Date\n )\n ? `\n struct Date {\n # A standard Gregorian calendar date.\n\n year @0 :Int16;\n # The year - Must include the century.\n # Negative value indicates BC.\n\n month @1 :UInt8; # The month, 1-12\n\n day @2 :UInt8; # The day of the month, 1-30\n\n hour @3 :UInt8; # The hour of the day, 0-23\n\n minute @4 :UInt8; # The minute of the hour, 0-59\n\n second @5 :UInt8; # The second of the minute, 0-59\n\n millisecond @6 :UInt16; # Milliseconds of the second, 0-999\n }`\n : \"\"\n }`;\n}\n\nexport function generateCapnpMethodSchema(\n reflection: ReflectionMethod,\n indexCounter: () => number\n): string {\n const methodName =\n reflection.getTitle() || typeof reflection.getName() === \"string\"\n ? String(reflection.getName())\n : \"\";\n if (!methodName) {\n throw new Error(\n `Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`\n );\n }\n\n return `${camelCase(methodName)} @${indexCounter()} (${reflection\n .getParameters()\n .map(param => {\n return `${camelCase(\n param.getName()\n )} :${generateCapnpPrimitive(param.getType())}${\n param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : \"\"\n }`;\n })\n .join(\", \")})${\n isVoidType(reflection.getReturnType())\n ? \"\"\n : ` -> (${kindToName(\n reflection.getReturnType().kind\n )}: ${generateCapnpPrimitive(reflection.getReturnType())})`\n }; # ${(\n reflection.getDescription() ||\n `The ${titleCase(\n reflection.reflectionClass.getTitle() ||\n reflection.reflectionClass.getName()\n )} interface ${titleCase(methodName)} method.`\n ).replaceAll(\"\\n\", \". \")}`;\n}\n\nfunction generateCapnpPropertyComment(reflection: ReflectionProperty) {\n const result = getWords(\n reflection.getDescription() ||\n `A schema property for ${titleCase(\n reflection.getTitle() || reflection.getNameAsString()\n )} field.`,\n {\n relaxed: true\n }\n )\n .reduce((ret, word) => {\n let length = ret.length;\n if (ret.includes(\"\\n\")) {\n length = ret.substring(ret.lastIndexOf(\"\\n\") + 1).length;\n }\n\n const current = word.trim();\n if (length + current.length > 60) {\n ret += `\\n\\t# ${current}`;\n } else {\n ret += ` ${current}`;\n }\n return ret;\n }, \"\")\n .trim();\n if (result.length > 0) {\n return `\\t# ${result}`;\n }\n\n return \"\";\n}\n\nfunction generateCapnpPropertySchema(\n reflection: ReflectionProperty,\n indexCounter: () => number\n): string {\n if (reflection.type.kind === ReflectionKind.union) {\n if (getCapnpUnionTypes(reflection.type).length === 0) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;\n${generateCapnpPropertyComment(reflection)}`;\n } else if (\n getCapnpUnionTypes(reflection.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1\n ) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} :union {\n${getCapnpUnionTypes(reflection.type)\n .map(\n type =>\n ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(\n type\n )};`\n )\n .join(\"\\n\")}\n }\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.array) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.class) {\n if (reflection.type.classType === Map) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Map(${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length === 0 ||\n !reflection.type.typeArguments[0]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[0])\n }, ${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length < 2 ||\n !reflection.type.typeArguments[1]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[1])\n })${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Date) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Buffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === ArrayBuffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.objectLiteral) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.enum) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(\n reflection.getType()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n}\n\nexport function generateCapnpEnumSchema(\n type: TypeEnum | TypeUnion,\n name: string\n): string {\n if (type.kind === ReflectionKind.union) {\n return generateCapnpEnumSchema(\n {\n kind: ReflectionKind.enum,\n indexType: type,\n enum: (type.types as TypeLiteral[]).reduce<\n Record<string, string | number>\n >((ret, type) => {\n if (isString(type.literal) || isNumber(type.literal)) {\n ret[camelCase(String(type.literal))] = type.literal;\n }\n\n return ret;\n }, {}),\n values: (\n getCapnpUnionTypes(type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ) as TypeLiteral[]\n ).map(type => type.literal as string | number)\n },\n name\n );\n }\n\n let index = 0;\n const indexCounter: () => number = () => index++;\n\n const enumType = getCapnpEnumTypes(type);\n if (!enumType) {\n return \"\";\n }\n\n return `enum ${pascalCase(name)} {\n${\n type.enum && Object.entries(type.enum).length > 0\n ? Object.entries(type.enum)\n .filter(([, value]) => value !== null && value !== undefined)\n .map(([key]) => ` ${camelCase(key)} @${indexCounter()};`)\n .join(\"\\n\")\n : type.values\n .filter(value => value !== null && value !== undefined)\n .map(\n value =>\n `${\n enumType === \"Text\" && value\n ? camelCase(String(value))\n : `${\n type.typeName ? `${camelCase(type.typeName)}_` : \"\"\n }${value || \"\"}`\n } @${indexCounter()};`\n )\n .join(\"\\n\")\n}\n }`;\n}\n\n/**\n * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.\n *\n * @param type - The Deepkit Type to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function generateCapnpPrimitive(type: Type): string {\n return type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n ? \"Void\"\n : type.kind === ReflectionKind.class && type.classType === Date\n ? \"Date\"\n : type.kind === ReflectionKind.class && type.classType === Set\n ? `List(${\n type.typeArguments && type.typeArguments[0]\n ? generateCapnpPrimitive(type.typeArguments[0])\n : \"Data\"\n })`\n : type.kind === ReflectionKind.bigint\n ? \"UInt64\"\n : type.kind === ReflectionKind.number\n ? \"Float64\"\n : type.kind === ReflectionKind.string ||\n type.kind === ReflectionKind.regexp\n ? \"Text\"\n : type.kind === ReflectionKind.boolean\n ? \"Bool\"\n : type.kind === ReflectionKind.literal\n ? isNumber(type.literal)\n ? \"Float64\"\n : isBigInt(type.literal)\n ? \"UInt64\"\n : isString(type.literal)\n ? \"Text\"\n : typeof type.literal === \"boolean\"\n ? \"Bool\"\n : \"Data\"\n : \"Data\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgdA,UAAA,EAAA"}
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core21 from "@alloy-js/core";
1
+ import * as _alloy_js_core5 from "@alloy-js/core";
2
2
 
3
3
  //#region src/markdown/components/front-matter.d.ts
4
4
  interface FrontMatterProps {
@@ -9,7 +9,7 @@ interface FrontMatterProps {
9
9
  *
10
10
  * @see https://jekyllrb.com/docs/front-matter/
11
11
  */
12
- declare function FrontMatter(props: FrontMatterProps): _alloy_js_core21.Children;
12
+ declare function FrontMatter(props: FrontMatterProps): _alloy_js_core5.Children;
13
13
  declare type __ΩFrontMatterProps = any[];
14
14
  //#endregion
15
15
  export { FrontMatter, FrontMatterProps, __ΩFrontMatterProps };
@@ -1 +1 @@
1
- {"version":3,"file":"front-matter.d.cts","names":[],"sources":["../../../src/markdown/components/front-matter.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,gBAAA;QACT;;AADR;AASA;;;;iBAAgB,WAAA,QAAmB,mBAAgB,gBAAA,CAAA"}
1
+ {"version":3,"file":"front-matter.d.cts","names":[],"sources":["../../../src/markdown/components/front-matter.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,gBAAA;QACT;;AADR;AASA;;;;iBAAgB,WAAA,QAAmB,mBAAgB,eAAA,CAAA"}
@@ -6,6 +6,7 @@ const require_markdown_components_front_matter = require('./front-matter.cjs');
6
6
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
7
7
  let __alloy_js_core = require("@alloy-js/core");
8
8
  let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
9
+ let powerlines_utils = require("powerlines/utils");
9
10
  let __alloy_js_markdown = require("@alloy-js/markdown");
10
11
  let __stryke_type_checks = require("@stryke/type-checks");
11
12
 
@@ -121,15 +122,7 @@ function MarkdownFileHeader(props) {
121
122
  (0, __alloy_js_core_jsx_runtime.createComponent)(require_core_components_single_line_comment.SingleLineComment, {
122
123
  variant: "markdown",
123
124
  get children() {
124
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
125
- get when() {
126
- return context?.config.output?.overwrite !== false;
127
- },
128
- get fallback() {
129
- return __alloy_js_core.code`This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${(0, __stryke_string_format_title_case.titleCase)(context?.config?.framework) || "Powerlines"} while the \`output.overwrite\` option is set to \`true\`.`;
130
- },
131
- children: __alloy_js_core.code`Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.`
132
- });
125
+ return (0, powerlines_utils.getFileHeaderWarning)(context);
133
126
  }
134
127
  }),
135
128
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps, SourceFileHeaderProps } from "../../types/components.cjs";
2
2
  import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.cjs";
3
3
  import { FrontMatterProps } from "./front-matter.cjs";
4
- import * as _alloy_js_core22 from "@alloy-js/core";
4
+ import * as _alloy_js_core23 from "@alloy-js/core";
5
5
 
6
6
  //#region src/markdown/components/markdown-file.d.ts
7
7
  type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps & MarkdownFileHeaderProps;
@@ -11,7 +11,7 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps &
11
11
  * @param props - The properties for the source file.
12
12
  * @returns The rendered source file component.
13
13
  */
14
- declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core22.Children;
14
+ declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core23.Children;
15
15
  type MarkdownFileHeaderProps = SourceFileHeaderProps & {
16
16
  frontMatter?: FrontMatterProps["data"];
17
17
  };
@@ -21,7 +21,7 @@ type MarkdownFileHeaderProps = SourceFileHeaderProps & {
21
21
  * @param props - The properties for the source file header.
22
22
  * @returns The rendered source file header.
23
23
  */
24
- declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core22.Children;
24
+ declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core23.Children;
25
25
  declare type __ΩMarkdownFileProps = any[];
26
26
  declare type __ΩMarkdownFileHeaderProps = any[];
27
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-file.d.cts","names":[],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KA4BY,iBAAA,GAAoB,KAAK,iCACnC,iBACA;;;AAFF;;;;AAEE,iBAQc,YAAA,CARd,KAAA,EAQkC,iBARlC,CAAA,EAQmD,gBAAA,CAAA,QARnD;AAAuB,KA2Bb,uBAAA,GAA0B,qBA3Bb,GAAA;EAQT,WAAA,CAAA,EAoBA,gBApBoB,CAAA,MAAA,CAAA;AAmBpC,CAAA;AAUA;;;;;;iBAAgB,kBAAA,QAA0B,0BAAuB,gBAAA,CAAA"}
1
+ {"version":3,"file":"markdown-file.d.cts","names":[],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KA6BY,iBAAA,GAAoB,KAAK,iCACnC,iBACA;;;AAFF;;;;AAEE,iBAQc,YAAA,CARd,KAAA,EAQkC,iBARlC,CAAA,EAQmD,gBAAA,CAAA,QARnD;AAAuB,KA2Bb,uBAAA,GAA0B,qBA3Bb,GAAA;EAQT,WAAA,CAAA,EAoBA,gBApBoB,CAAA,MAAA,CAAA;AAmBpC,CAAA;AAUA;;;;;;iBAAgB,kBAAA,QAA0B,0BAAuB,gBAAA,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps, SourceFileHeaderProps } from "../../types/components.mjs";
2
2
  import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.mjs";
3
3
  import { FrontMatterProps } from "./front-matter.mjs";
4
- import * as _alloy_js_core3 from "@alloy-js/core";
4
+ import * as _alloy_js_core6 from "@alloy-js/core";
5
5
 
6
6
  //#region src/markdown/components/markdown-file.d.ts
7
7
  type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps & MarkdownFileHeaderProps;
@@ -11,7 +11,7 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps &
11
11
  * @param props - The properties for the source file.
12
12
  * @returns The rendered source file component.
13
13
  */
14
- declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core3.Children;
14
+ declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core6.Children;
15
15
  type MarkdownFileHeaderProps = SourceFileHeaderProps & {
16
16
  frontMatter?: FrontMatterProps["data"];
17
17
  };
@@ -21,7 +21,7 @@ type MarkdownFileHeaderProps = SourceFileHeaderProps & {
21
21
  * @param props - The properties for the source file header.
22
22
  * @returns The rendered source file header.
23
23
  */
24
- declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core3.Children;
24
+ declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core6.Children;
25
25
  declare type __ΩMarkdownFileProps = any[];
26
26
  declare type __ΩMarkdownFileHeaderProps = any[];
27
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-file.d.mts","names":[],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KA4BY,iBAAA,GAAoB,KAAK,iCACnC,iBACA;;;AAFF;;;;AAEE,iBAQc,YAAA,CARd,KAAA,EAQkC,iBARlC,CAAA,EAQmD,eAAA,CAAA,QARnD;AAAuB,KA2Bb,uBAAA,GAA0B,qBA3Bb,GAAA;EAQT,WAAA,CAAA,EAoBA,gBApBoB,CAAA,MAAA,CAAA;AAmBpC,CAAA;AAUA;;;;;;iBAAgB,kBAAA,QAA0B,0BAAuB,eAAA,CAAA"}
1
+ {"version":3,"file":"markdown-file.d.mts","names":[],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KA6BY,iBAAA,GAAoB,KAAK,iCACnC,iBACA;;;AAFF;;;;AAEE,iBAQc,YAAA,CARd,KAAA,EAQkC,iBARlC,CAAA,EAQmD,eAAA,CAAA,QARnD;AAAuB,KA2Bb,uBAAA,GAA0B,qBA3Bb,GAAA;EAQT,WAAA,CAAA,EAoBA,gBApBoB,CAAA,MAAA,CAAA;AAmBpC,CAAA;AAUA;;;;;;iBAAgB,kBAAA,QAA0B,0BAAuB,eAAA,CAAA"}
@@ -3,8 +3,9 @@ import { SingleLineComment } from "../../core/components/single-line-comment.mjs
3
3
  import { SourceFile } from "../../core/components/source-file.mjs";
4
4
  import { FrontMatter } from "./front-matter.mjs";
5
5
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
6
- import { Show, code, splitProps } from "@alloy-js/core";
6
+ import { Show, splitProps } from "@alloy-js/core";
7
7
  import { titleCase } from "@stryke/string-format/title-case";
8
+ import { getFileHeaderWarning } from "powerlines/utils";
8
9
  import { Link } from "@alloy-js/markdown";
9
10
  import { isSetObject } from "@stryke/type-checks";
10
11
 
@@ -120,15 +121,7 @@ function MarkdownFileHeader(props) {
120
121
  createComponent(SingleLineComment, {
121
122
  variant: "markdown",
122
123
  get children() {
123
- return createComponent(Show, {
124
- get when() {
125
- return context?.config.output?.overwrite !== false;
126
- },
127
- get fallback() {
128
- return code`This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(context?.config?.framework) || "Powerlines"} while the \`output.overwrite\` option is set to \`true\`.`;
129
- },
130
- children: code`Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.`
131
- });
124
+ return getFileHeaderWarning(context);
132
125
  }
133
126
  }),
134
127
  createIntrinsic("hbr", {})
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-file.mjs","names":["code","Show","splitProps","Link","titleCase","isSetObject","SingleLineComment","SourceFile","usePowerlinesSafe","FrontMatter","MarkdownFile","props","children","storage","frontMatter","rest","_$createComponent","_$mergeProps","header","MarkdownFileHeader","filetype","reference","when","Boolean","disableEslint","disableBiome","disablePrettier","context","_$memo","Object","keys","length","data","variant","_$createIntrinsic","config","framework","output","overwrite","fallback","Date","toLocaleString"],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport { Link } from \"@alloy-js/markdown\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks\";\nimport { SingleLineComment } from \"../../core/components/single-line-comment\";\nimport { SourceFile, SourceFileProps } from \"../../core/components/source-file\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps, SourceFileHeaderProps } from \"../../types/components\";\nimport { FrontMatter, FrontMatterProps } from \"./front-matter\";\n\nexport type MarkdownFileProps = Omit<SourceFileProps, \"filetype\"> &\n ComponentProps &\n MarkdownFileHeaderProps;\n\n/**\n * A base component representing a Powerlines generated markdown source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function MarkdownFile(props: MarkdownFileProps) {\n const [{ children, storage, frontMatter }, rest] = splitProps(props, [\n \"children\",\n \"storage\",\n \"frontMatter\"\n ]);\n\n return (\n <SourceFile\n header={<MarkdownFileHeader frontMatter={frontMatter} />}\n {...rest}\n filetype=\"md\"\n reference={Link}\n storage={storage}>\n <Show when={Boolean(children)}>{children}</Show>\n </SourceFile>\n );\n}\n\nexport type MarkdownFileHeaderProps = SourceFileHeaderProps & {\n frontMatter?: FrontMatterProps[\"data\"];\n};\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function MarkdownFileHeader(props: MarkdownFileHeaderProps) {\n const [\n {\n children,\n disableEslint = true,\n disableBiome = true,\n disablePrettier = false,\n frontMatter\n }\n ] = splitProps(props, [\n \"children\",\n \"disableEslint\",\n \"disableBiome\",\n \"disablePrettier\",\n \"frontMatter\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n <Show\n when={isSetObject(frontMatter) && Object.keys(frontMatter).length > 0}>\n <FrontMatter data={frontMatter!} />\n </Show>\n <Show when={Boolean(disableEslint)}>\n <SingleLineComment variant=\"markdown\">\n {\"eslint-disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disablePrettier)}>\n <SingleLineComment variant=\"markdown\">\n {\"prettier-ignore\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disableBiome)}>\n <SingleLineComment variant=\"markdown\">\n {\"biome-ignore lint: disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show\n when={\n Boolean(disableEslint) ||\n Boolean(disablePrettier) ||\n Boolean(disableBiome)\n }>\n <hbr />\n </Show>\n <Show when={Boolean(children)}>\n <>\n {children}\n <hbr />\n </>\n </Show>\n <SingleLineComment variant=\"markdown\">{`Generated by ${\n titleCase(context?.config?.framework) || \"Powerlines\"\n }`}</SingleLineComment>\n <hbr />\n <SingleLineComment variant=\"markdown\">\n <Show\n when={context?.config.output?.overwrite !== false}\n fallback={code`This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(context?.config?.framework) || \"Powerlines\"} while the \\`output.overwrite\\` option is set to \\`true\\`.`}>\n {code`Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`}\n </Show>\n </SingleLineComment>\n <hbr />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;SAoDgB,aAAA;CAAA,MAAA,CAAA,EAAA,UAAA,SAAA,eAAA,QAAA,WAAA,OAAA;EAAA;;;;AAAA,QAAA,gBAAA,YAAA,WAAA,EAAA,IAAA,SAAA;AAAA,SAAA,gBAAA,oBAAA,EAAA,aAAA,CAAA;IAAA,QAAA;EAAA,UAAA;EAAA,WAAA;EAAA;EAAA,IAAA,WAAA;AAAA,UAAA,sBAAA;IAAA,IAAA,OAAA;AAAA,YAAEuB,QAAQX,SAAS;;IAAA;IAAA,CAAA;;EAAA,CAAA,CAAA;;;;;;;;;yDA8CO,wBAAAI,wBACjCV,WAAAA,OAAAA;EAAAA;EAAAA;;;;GAAAA;OAAAA,UAAAA,mBAAAA;;kBAAAA,MAAAA;GAAAA,IAAkB2B,OAAAA;AAAAA,WAAAA,WAAAA,CAAAA,CAAAA,YAAAA,YAAAA,CAAAA,EAAAA,IAAAA,OAAAA,KAAAA,YAAAA,CAAAA,SAAAA;;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,gBAAAA,aAAAA,EAAAA,MAAAA,aAAAA,CAAAA;;GAAAA,CAAAA;EAAAA,gBAAAA,MAAAA;GAAAA,IAAAA,OAAAA;AAAAA,WAAAA,QAAAA,cAAAA;;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,CAAAA,gBAAAA,mBAAO;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAAA,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,gBAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,gBAAA,mBAAA;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAKlB,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,aAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,gBAAA,mBAAA;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,sBAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,cAAA,IAAA,QAAA,gBAAA,IAAA,QAAA,aAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,gBAAA,OAAA,EAAA,CAAA;;GAAA,CAAA;EAAA,gBAAA,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,SAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,UAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAAuB,mBAAA;GAAA,SAAA;GAAA,IAAA,WAAA;AAAA,WAAA,gBAAA,UAAA,SAAA,QAAA,UAAA,IAAA;;GAAA,CAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA,gBAEAC,mBAAAA;GAAAA,SAAAA;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,gBAAAA,MAAAA;KAAAA,IAAAA,OAAAA;AAAAA,aAAAA,SAAAA,OAAAA,QAAAA,cAAAA;;KAAAA,IAAAA,WAAAA;AAAAA,aAAAA,IAAAA,+CAAAA,IAAAA,MAAAA,EAAAA,gBAAAA,CAAAA,mCAAAA,UAAAA,SAAAA,QAAAA,UAAAA,IAAAA,aAAAA;;KAAAA,UAAAA,IAAAA;KAK3B,CAAA;;GAAA,CAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA"}
1
+ {"version":3,"file":"markdown-file.mjs","names":["Show","splitProps","Link","titleCase","isSetObject","getFileHeaderWarning","SingleLineComment","SourceFile","usePowerlinesSafe","FrontMatter","MarkdownFile","props","children","storage","frontMatter","rest","_$createComponent","_$mergeProps","header","MarkdownFileHeader","filetype","reference","when","Boolean","disableEslint","disableBiome","disablePrettier","context","_$memo","Object","keys","length","data","variant","_$createIntrinsic","config","framework"],"sources":["../../../src/markdown/components/markdown-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Show, splitProps } from \"@alloy-js/core\";\nimport { Link } from \"@alloy-js/markdown\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks\";\nimport { getFileHeaderWarning } from \"powerlines/utils\";\nimport { SingleLineComment } from \"../../core/components/single-line-comment\";\nimport { SourceFile, SourceFileProps } from \"../../core/components/source-file\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps, SourceFileHeaderProps } from \"../../types/components\";\nimport { FrontMatter, FrontMatterProps } from \"./front-matter\";\n\nexport type MarkdownFileProps = Omit<SourceFileProps, \"filetype\"> &\n ComponentProps &\n MarkdownFileHeaderProps;\n\n/**\n * A base component representing a Powerlines generated markdown source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function MarkdownFile(props: MarkdownFileProps) {\n const [{ children, storage, frontMatter }, rest] = splitProps(props, [\n \"children\",\n \"storage\",\n \"frontMatter\"\n ]);\n\n return (\n <SourceFile\n header={<MarkdownFileHeader frontMatter={frontMatter} />}\n {...rest}\n filetype=\"md\"\n reference={Link}\n storage={storage}>\n <Show when={Boolean(children)}>{children}</Show>\n </SourceFile>\n );\n}\n\nexport type MarkdownFileHeaderProps = SourceFileHeaderProps & {\n frontMatter?: FrontMatterProps[\"data\"];\n};\n\n/**\n * Renders the header for a Powerlines Typescript source file.\n *\n * @param props - The properties for the source file header.\n * @returns The rendered source file header.\n */\nexport function MarkdownFileHeader(props: MarkdownFileHeaderProps) {\n const [\n {\n children,\n disableEslint = true,\n disableBiome = true,\n disablePrettier = false,\n frontMatter\n }\n ] = splitProps(props, [\n \"children\",\n \"disableEslint\",\n \"disableBiome\",\n \"disablePrettier\",\n \"frontMatter\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n <Show\n when={isSetObject(frontMatter) && Object.keys(frontMatter).length > 0}>\n <FrontMatter data={frontMatter!} />\n </Show>\n <Show when={Boolean(disableEslint)}>\n <SingleLineComment variant=\"markdown\">\n {\"eslint-disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disablePrettier)}>\n <SingleLineComment variant=\"markdown\">\n {\"prettier-ignore\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show when={Boolean(disableBiome)}>\n <SingleLineComment variant=\"markdown\">\n {\"biome-ignore lint: disable\"}\n </SingleLineComment>\n <hbr />\n </Show>\n <Show\n when={\n Boolean(disableEslint) ||\n Boolean(disablePrettier) ||\n Boolean(disableBiome)\n }>\n <hbr />\n </Show>\n <Show when={Boolean(children)}>\n <>\n {children}\n <hbr />\n </>\n </Show>\n <SingleLineComment variant=\"markdown\">{`Generated by ${\n titleCase(context?.config?.framework) || \"Powerlines\"\n }`}</SingleLineComment>\n <hbr />\n <SingleLineComment variant=\"markdown\">\n {getFileHeaderWarning(context!)}\n </SingleLineComment>\n <hbr />\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;SAqDgB,aAAA;CAAA,MAAA,CAAA,EAAA,UAAA,SAAA,eAAA,QAAA,WAAA,OAAA;EAAA;;;;AAAA,QAAA,gBAAA,YAAA,WAAA,EAAA,IAAA,SAAA;AAAA,SAAA,gBAAA,oBAAA,EAAA,aAAA,CAAA;IAAA,QAAA;EAAA,UAAA;EAAA,WAAA;EAAA;EAAA,IAAA,WAAA;AAAA,UAAA,sBAAA;IAAA,IAAA,OAAA;AAAA,YAAEuB,QAAQX,SAAS;;IAAA;IAAA,CAAA;;EAAA,CAAA,CAAA;;;;;;;;;yDA8CO,wBAAAI,wBACjCV,WAAAA,OAAAA;EAAAA;EAAAA;;;;GAAAA;OAAAA,UAAAA,mBAAAA;;kBAAAA,MAAAA;GAAAA,IAAkB2B,OAAAA;AAAAA,WAAAA,WAAAA,CAAAA,CAAAA,YAAAA,YAAAA,CAAAA,EAAAA,IAAAA,OAAAA,KAAAA,YAAAA,CAAAA,SAAAA;;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,gBAAAA,aAAAA,EAAAA,MAAAA,aAAAA,CAAAA;;GAAAA,CAAAA;EAAAA,gBAAAA,MAAAA;GAAAA,IAAAA,OAAAA;AAAAA,WAAAA,QAAAA,cAAAA;;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,CAAAA,gBAAAA,mBAAO;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAAA,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,gBAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,gBAAA,mBAAA;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAKlB,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,aAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,gBAAA,mBAAA;KAAA,SAAA;KAAA,UAAA;KAAA,CAAA,EAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,sBAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,cAAA,IAAA,QAAA,gBAAA,IAAA,QAAA,aAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,gBAAA,OAAA,EAAA,CAAA;;GAAA,CAAA;EAAA,gBAAA,MAAA;GAAA,IAAA,OAAA;AAAA,WAAA,QAAA,SAAA;;GAAA,IAAA,WAAA;AAAA,WAAA,CAAA,UAAA,gBAAA,OAAA,EAAA,CAAA,CAAA;;GAAA,CAAA;EAAA,gBAAuB,mBAAA;GAAA,SAAA;GAAA,IAAA,WAAA;AAAA,WAAA,gBAAA,UAAA,SAAA,QAAA,UAAA,IAAA;;GAAA,CAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA,gBAEAC,mBAAAA;GAAAA,SAAAA;GAAAA,IAAAA,WAAAA;AAAAA,WAAAA,qBAAAA,QAAAA;;GAAAA,CAAAA;EAAAA,gBAAAA,OAAAA,EAAAA,CAAAA;EAAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps } from "../../types/components.cjs";
2
2
  import { MarkdownTableColumnContextInterface } from "../contexts/markdown-table.cjs";
3
- import * as _alloy_js_core17 from "@alloy-js/core";
3
+ import * as _alloy_js_core0 from "@alloy-js/core";
4
4
 
5
5
  //#region src/markdown/components/markdown-table.d.ts
6
6
  interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>> extends ComponentProps {
@@ -9,18 +9,18 @@ interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>
9
9
  /**
10
10
  * Component that provides a context for rendering markdown tables.
11
11
  */
12
- declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core17.Children;
12
+ declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core0.Children;
13
13
  type MarkdownTableColumnProps = ComponentProps & Partial<Pick<MarkdownTableColumnContextInterface, "align">> & Required<Pick<MarkdownTableColumnContextInterface, "name">> & {
14
14
  width?: number;
15
15
  };
16
16
  /**
17
17
  * Component that provides a context for rendering markdown tables.
18
18
  */
19
- declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core17.Children;
19
+ declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core0.Children;
20
20
  /**
21
21
  * Component that provides a context for rendering markdown tables.
22
22
  */
23
- declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core17.Children;
23
+ declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core0.Children;
24
24
  declare type __ΩMarkdownTableProps = any[];
25
25
  declare type __ΩMarkdownTableColumnProps = any[];
26
26
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-table.d.cts","names":[],"sources":["../../../src/markdown/components/markdown-table.tsx"],"sourcesContent":[],"mappings":";;;;;UA4BiB,6BACL,sBAAsB,6BACxB;QACF;;AAHR;;;AAGQ,iBAMQ,aANR,CAAA,UAOI,MAPJ,CAAA,MAAA,EAAA,GAAA,CAAA,GAO0B,MAP1B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAQC,kBARD,CAQoB,CARpB,CAAA,CAAA,EAQmB,gBAAA,CAAG,QARtB;AADE,KA4BE,wBAAA,GAA2B,cA5B7B,GA6BR,OA7BQ,CA6BA,IA7BA,CA6BK,mCA7BL,EAAA,OAAA,CAAA,CAAA,GA8BR,QA9BQ,CA8BC,IA9BD,CA8BM,mCA9BN,EAAA,MAAA,CAAA,CAAA,GAAA;EAAc,KAAA,CAAA,EAAA,MAAA;AAOxB,CAAA;;;;AAES,iBA4BO,mBAAA,CA5BP,KAAA,EA4BkC,wBA5BlC,CAAA,EA4B0D,gBAAA,CAAA,QA5B1D;;;AAmBT;AAAuC,iBAsDvB,yBAAA,CAtDuB,KAAA,EAsDU,wBAtDV,CAAA,EAsDkC,gBAAA,CAAA,QAtDlC;AACxB,qCAAA,GAAA,EAAA;AAAL,2CAAA,GAAA,EAAA"}
1
+ {"version":3,"file":"markdown-table.d.cts","names":[],"sources":["../../../src/markdown/components/markdown-table.tsx"],"sourcesContent":[],"mappings":";;;;;UA4BiB,6BACL,sBAAsB,6BACxB;QACF;;AAHR;;;AAGQ,iBAMQ,aANR,CAAA,UAOI,MAPJ,CAAA,MAAA,EAAA,GAAA,CAAA,GAO0B,MAP1B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAQC,kBARD,CAQoB,CARpB,CAAA,CAAA,EAQmB,eAAA,CAAG,QARtB;AADE,KA4BE,wBAAA,GAA2B,cA5B7B,GA6BR,OA7BQ,CA6BA,IA7BA,CA6BK,mCA7BL,EAAA,OAAA,CAAA,CAAA,GA8BR,QA9BQ,CA8BC,IA9BD,CA8BM,mCA9BN,EAAA,MAAA,CAAA,CAAA,GAAA;EAAc,KAAA,CAAA,EAAA,MAAA;AAOxB,CAAA;;;;AAES,iBA4BO,mBAAA,CA5BP,KAAA,EA4BkC,wBA5BlC,CAAA,EA4B0D,eAAA,CAAA,QA5B1D;;;AAmBT;AAAuC,iBAsDvB,yBAAA,CAtDuB,KAAA,EAsDU,wBAtDV,CAAA,EAsDkC,eAAA,CAAA,QAtDlC;AACxB,qCAAA,GAAA,EAAA;AAAL,2CAAA,GAAA,EAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps } from "../../types/components.mjs";
2
2
  import { MarkdownTableColumnContextInterface } from "../contexts/markdown-table.mjs";
3
- import * as _alloy_js_core5 from "@alloy-js/core";
3
+ import * as _alloy_js_core3 from "@alloy-js/core";
4
4
 
5
5
  //#region src/markdown/components/markdown-table.d.ts
6
6
  interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>> extends ComponentProps {
@@ -9,18 +9,18 @@ interface MarkdownTableProps<T extends Record<string, any> = Record<string, any>
9
9
  /**
10
10
  * Component that provides a context for rendering markdown tables.
11
11
  */
12
- declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core5.Children;
12
+ declare function MarkdownTable<T extends Record<string, any> = Record<string, any>>(props: MarkdownTableProps<T>): _alloy_js_core3.Children;
13
13
  type MarkdownTableColumnProps = ComponentProps & Partial<Pick<MarkdownTableColumnContextInterface, "align">> & Required<Pick<MarkdownTableColumnContextInterface, "name">> & {
14
14
  width?: number;
15
15
  };
16
16
  /**
17
17
  * Component that provides a context for rendering markdown tables.
18
18
  */
19
- declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core5.Children;
19
+ declare function MarkdownTableColumn(props: MarkdownTableColumnProps): _alloy_js_core3.Children;
20
20
  /**
21
21
  * Component that provides a context for rendering markdown tables.
22
22
  */
23
- declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core5.Children;
23
+ declare function MarkdownTableColumnHeader(props: MarkdownTableColumnProps): _alloy_js_core3.Children;
24
24
  declare type __ΩMarkdownTableProps = any[];
25
25
  declare type __ΩMarkdownTableColumnProps = any[];
26
26
  //#endregion
package/dist/render.cjs CHANGED
@@ -50,7 +50,14 @@ async function render(context, children) {
50
50
  storage: metadata.storage,
51
51
  ...metadata.typeDefinition ?? {}
52
52
  });
53
- else context.emitSync(file.contents, file.path, metadata);
53
+ else if (metadata.kind === "infrastructure") {
54
+ if (!metadata.id) throw new Error(`Infrastructure file "${file.path}" is missing its ID in the render metadata.`);
55
+ context.emitInfrastructureSync(file.contents, metadata.id, {
56
+ skipFormat: metadata.skipFormat,
57
+ storage: metadata.storage,
58
+ extension: (0, __stryke_path_file_path_fns.findFileExtension)(file.path)
59
+ });
60
+ } else context.emitSync(file.contents, file.path, metadata);
54
61
  } else context.fs.copySync(file.sourcePath, file.path);
55
62
  }
56
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA+EA;;;;;;iBA/EsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA6EJ,8BAA8B,wBACnC,oBACC,oBACA"}
1
+ {"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA6FA;;;;;;iBA7FsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA2FJ,8BAA8B,wBACnC,oBACC,oBACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.mts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA+EA;;;;;;iBA/EsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA6EJ,8BAA8B,wBACnC,oBACC,oBACA"}
1
+ {"version":3,"file":"render.d.mts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA6FA;;;;;;iBA7FsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA2FJ,8BAA8B,wBACnC,oBACC,oBACA"}
package/dist/render.mjs CHANGED
@@ -49,7 +49,14 @@ async function render(context, children) {
49
49
  storage: metadata.storage,
50
50
  ...metadata.typeDefinition ?? {}
51
51
  });
52
- else context.emitSync(file.contents, file.path, metadata);
52
+ else if (metadata.kind === "infrastructure") {
53
+ if (!metadata.id) throw new Error(`Infrastructure file "${file.path}" is missing its ID in the render metadata.`);
54
+ context.emitInfrastructureSync(file.contents, metadata.id, {
55
+ skipFormat: metadata.skipFormat,
56
+ storage: metadata.storage,
57
+ extension: findFileExtension(file.path)
58
+ });
59
+ } else context.emitSync(file.contents, file.path, metadata);
53
60
  } else context.fs.copySync(file.sourcePath, file.path);
54
61
  }
55
62
  });