@powerlines/plugin-alloy 0.18.49 → 0.18.52

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 (152) hide show
  1. package/dist/core/components/index.cjs +7 -0
  2. package/dist/core/components/index.d.cts +4 -0
  3. package/dist/core/components/index.d.mts +4 -0
  4. package/dist/core/components/index.mjs +5 -0
  5. package/dist/core/components/output.cjs +2 -2
  6. package/dist/core/components/output.d.cts +23 -0
  7. package/dist/core/components/output.d.mts +23 -0
  8. package/dist/core/components/output.mjs +4 -4
  9. package/dist/core/components/single-line-comment.cjs +22 -0
  10. package/dist/core/components/single-line-comment.d.cts +22 -0
  11. package/dist/core/components/single-line-comment.d.mts +22 -0
  12. package/dist/core/components/single-line-comment.mjs +21 -0
  13. package/dist/core/components/source-file.cjs +64 -0
  14. package/dist/core/components/source-file.d.cts +32 -0
  15. package/dist/core/components/source-file.d.mts +32 -0
  16. package/dist/core/components/source-file.mjs +62 -0
  17. package/dist/core/contexts/context.cjs +50 -1
  18. package/dist/core/contexts/context.d.cts +71 -0
  19. package/dist/core/contexts/context.d.mts +71 -0
  20. package/dist/core/contexts/context.mjs +46 -2
  21. package/dist/core/contexts/index.cjs +17 -0
  22. package/dist/core/contexts/index.d.cts +3 -0
  23. package/dist/core/contexts/index.d.mts +3 -0
  24. package/dist/core/contexts/index.mjs +4 -0
  25. package/dist/core/contexts/reflection.cjs +68 -0
  26. package/dist/core/contexts/reflection.d.cts +52 -0
  27. package/dist/core/contexts/reflection.d.mts +52 -0
  28. package/dist/core/contexts/reflection.mjs +60 -0
  29. package/dist/core/index.cjs +25 -0
  30. package/dist/core/index.d.cts +7 -0
  31. package/dist/core/index.d.mts +8 -0
  32. package/dist/core/index.mjs +9 -0
  33. package/dist/helpers/capnp.cjs +276 -0
  34. package/dist/helpers/capnp.d.cts +87 -0
  35. package/dist/helpers/capnp.d.mts +87 -0
  36. package/dist/helpers/capnp.mjs +259 -0
  37. package/dist/helpers/create-builtin.cjs +19 -0
  38. package/dist/helpers/create-builtin.d.cts +15 -0
  39. package/dist/helpers/create-builtin.d.mts +15 -0
  40. package/dist/helpers/create-builtin.mjs +18 -0
  41. package/dist/helpers/index.cjs +24 -0
  42. package/dist/helpers/index.d.cts +5 -0
  43. package/dist/helpers/index.d.mts +5 -0
  44. package/dist/helpers/index.mjs +6 -0
  45. package/dist/helpers/refkey.cjs +16 -0
  46. package/dist/helpers/refkey.d.cts +13 -0
  47. package/dist/helpers/refkey.d.mts +13 -0
  48. package/dist/helpers/refkey.mjs +15 -0
  49. package/dist/helpers/typescript.cjs +46 -0
  50. package/dist/helpers/typescript.d.cts +25 -0
  51. package/dist/helpers/typescript.d.mts +25 -0
  52. package/dist/helpers/typescript.mjs +45 -0
  53. package/dist/index.cjs +2 -2
  54. package/dist/markdown/components/index.cjs +8 -0
  55. package/dist/markdown/components/index.d.cts +3 -0
  56. package/dist/markdown/components/index.d.mts +3 -0
  57. package/dist/markdown/components/index.mjs +4 -0
  58. package/dist/markdown/components/markdown-file.cjs +116 -0
  59. package/dist/markdown/components/markdown-file.d.cts +23 -0
  60. package/dist/markdown/components/markdown-file.d.mts +23 -0
  61. package/dist/markdown/components/markdown-file.mjs +114 -0
  62. package/dist/markdown/components/markdown-table.cjs +101 -0
  63. package/dist/markdown/components/markdown-table.d.cts +27 -0
  64. package/dist/markdown/components/markdown-table.d.mts +27 -0
  65. package/dist/markdown/components/markdown-table.mjs +98 -0
  66. package/dist/markdown/contexts/index.cjs +6 -0
  67. package/dist/markdown/contexts/index.d.cts +2 -0
  68. package/dist/markdown/contexts/index.d.mts +2 -0
  69. package/dist/markdown/contexts/index.mjs +3 -0
  70. package/dist/markdown/contexts/markdown-table.cjs +37 -0
  71. package/dist/markdown/contexts/markdown-table.d.cts +37 -0
  72. package/dist/markdown/contexts/markdown-table.d.mts +37 -0
  73. package/dist/markdown/contexts/markdown-table.mjs +33 -0
  74. package/dist/markdown/index.cjs +15 -0
  75. package/dist/markdown/index.d.cts +4 -0
  76. package/dist/markdown/index.d.mts +6 -0
  77. package/dist/markdown/index.mjs +7 -0
  78. package/dist/powerlines/src/types/api.d.cts +3 -3
  79. package/dist/powerlines/src/types/api.d.mts +3 -3
  80. package/dist/powerlines/src/types/build.d.cts +10 -10
  81. package/dist/powerlines/src/types/build.d.mts +10 -10
  82. package/dist/powerlines/src/types/commands.d.cts +1 -1
  83. package/dist/powerlines/src/types/commands.d.mts +1 -1
  84. package/dist/powerlines/src/types/config.d.cts +2 -2
  85. package/dist/powerlines/src/types/config.d.mts +2 -2
  86. package/dist/powerlines/src/types/context.d.cts +5 -5
  87. package/dist/powerlines/src/types/context.d.mts +5 -5
  88. package/dist/powerlines/src/types/hooks.d.cts +1 -1
  89. package/dist/powerlines/src/types/hooks.d.mts +1 -1
  90. package/dist/powerlines/src/types/plugin.d.cts +5 -5
  91. package/dist/powerlines/src/types/plugin.d.mts +5 -5
  92. package/dist/powerlines/src/types/resolved.d.cts +1 -1
  93. package/dist/powerlines/src/types/resolved.d.mts +1 -1
  94. package/dist/powerlines/src/types/unplugin.d.cts +1 -1
  95. package/dist/powerlines/src/types/unplugin.d.mts +1 -1
  96. package/dist/types/components.cjs +0 -0
  97. package/dist/types/components.d.cts +142 -0
  98. package/dist/types/components.d.mts +142 -0
  99. package/dist/types/components.mjs +1 -0
  100. package/dist/types/index.cjs +0 -0
  101. package/dist/types/index.d.cts +3 -0
  102. package/dist/types/index.d.mts +3 -0
  103. package/dist/types/index.mjs +1 -0
  104. package/dist/types/plugin.cjs +0 -0
  105. package/dist/types/plugin.d.cts +9 -1
  106. package/dist/types/plugin.d.mts +9 -1
  107. package/dist/types/plugin.mjs +1 -0
  108. package/dist/typescript/components/builtin-file.cjs +62 -0
  109. package/dist/typescript/components/builtin-file.d.cts +34 -0
  110. package/dist/typescript/components/builtin-file.d.mts +34 -0
  111. package/dist/typescript/components/builtin-file.mjs +61 -0
  112. package/dist/typescript/components/dynamic-import-statement.cjs +25 -0
  113. package/dist/typescript/components/dynamic-import-statement.d.cts +32 -0
  114. package/dist/typescript/components/dynamic-import-statement.d.mts +32 -0
  115. package/dist/typescript/components/dynamic-import-statement.mjs +24 -0
  116. package/dist/typescript/components/entry-file.cjs +41 -0
  117. package/dist/typescript/components/entry-file.d.cts +27 -0
  118. package/dist/typescript/components/entry-file.d.mts +27 -0
  119. package/dist/typescript/components/entry-file.mjs +39 -0
  120. package/dist/typescript/components/index.cjs +44 -0
  121. package/dist/typescript/components/index.d.cts +10 -0
  122. package/dist/typescript/components/index.d.mts +10 -0
  123. package/dist/typescript/components/index.mjs +11 -0
  124. package/dist/typescript/components/record-expression.cjs +12 -0
  125. package/dist/typescript/components/record-expression.d.cts +12 -0
  126. package/dist/typescript/components/record-expression.d.mts +12 -0
  127. package/dist/typescript/components/record-expression.mjs +11 -0
  128. package/dist/typescript/components/tsdoc-reflection.cjs +177 -0
  129. package/dist/typescript/components/tsdoc-reflection.d.cts +18 -0
  130. package/dist/typescript/components/tsdoc-reflection.d.mts +18 -0
  131. package/dist/typescript/components/tsdoc-reflection.mjs +174 -0
  132. package/dist/typescript/components/tsdoc.cjs +481 -0
  133. package/dist/typescript/components/tsdoc.d.cts +163 -0
  134. package/dist/typescript/components/tsdoc.d.mts +163 -0
  135. package/dist/typescript/components/tsdoc.mjs +461 -0
  136. package/dist/typescript/components/typescript-file.cjs +216 -0
  137. package/dist/typescript/components/typescript-file.d.cts +49 -0
  138. package/dist/typescript/components/typescript-file.d.mts +49 -0
  139. package/dist/typescript/components/typescript-file.mjs +213 -0
  140. package/dist/typescript/components/typescript-interface.cjs +69 -0
  141. package/dist/typescript/components/typescript-interface.d.cts +25 -0
  142. package/dist/typescript/components/typescript-interface.d.mts +25 -0
  143. package/dist/typescript/components/typescript-interface.mjs +67 -0
  144. package/dist/typescript/components/typescript-object.cjs +125 -0
  145. package/dist/typescript/components/typescript-object.d.cts +26 -0
  146. package/dist/typescript/components/typescript-object.d.mts +26 -0
  147. package/dist/typescript/components/typescript-object.mjs +123 -0
  148. package/dist/typescript/index.cjs +45 -0
  149. package/dist/typescript/index.d.cts +11 -0
  150. package/dist/typescript/index.d.mts +11 -0
  151. package/dist/typescript/index.mjs +12 -0
  152. package/package.json +5 -5
@@ -0,0 +1,7 @@
1
+ const require_core_components_output = require('./output.cjs');
2
+ const require_core_components_single_line_comment = require('./single-line-comment.cjs');
3
+ const require_core_components_source_file = require('./source-file.cjs');
4
+
5
+ exports.Output = require_core_components_output.Output;
6
+ exports.SingleLineComment = require_core_components_single_line_comment.SingleLineComment;
7
+ exports.SourceFile = require_core_components_source_file.SourceFile;
@@ -0,0 +1,4 @@
1
+ import { Output, OutputProps, __ΩOutputProps } from "./output.cjs";
2
+ import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./single-line-comment.cjs";
3
+ import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./source-file.cjs";
4
+ export { Output, OutputProps, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, __ΩOutputProps, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps };
@@ -0,0 +1,4 @@
1
+ import { Output, OutputProps, __ΩOutputProps } from "./output.mjs";
2
+ import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./single-line-comment.mjs";
3
+ import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./source-file.mjs";
4
+ export { Output, OutputProps, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, __ΩOutputProps, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps };
@@ -0,0 +1,5 @@
1
+ import { Output } from "./output.mjs";
2
+ import { SingleLineComment } from "./single-line-comment.mjs";
3
+ import { SourceFile } from "./source-file.mjs";
4
+
5
+ export { Output, SingleLineComment, SourceFile };
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_context = require('../contexts/context.cjs');
2
+ const require_core_contexts_context = require('../contexts/context.cjs');
3
3
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
4
  let __alloy_js_core = require("@alloy-js/core");
5
5
  let __stryke_path_replace = require("@stryke/path/replace");
@@ -23,7 +23,7 @@ function Output(props) {
23
23
  return basePathRef.value;
24
24
  },
25
25
  get children() {
26
- return (0, __alloy_js_core_jsx_runtime.createComponent)(require_context.PowerlinesContext.Provider, {
26
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_context.PowerlinesContext.Provider, {
27
27
  value: {
28
28
  ref: contextRef,
29
29
  meta: metaRef
@@ -0,0 +1,23 @@
1
+ import { PluginContext } from "../../powerlines/src/types/context.cjs";
2
+ import { MetaItem } from "../contexts/context.cjs";
3
+ import * as _alloy_js_core0 from "@alloy-js/core";
4
+ import { OutputProps as OutputProps$1 } from "@alloy-js/core";
5
+
6
+ //#region src/core/components/output.d.ts
7
+ interface OutputProps<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>> extends OutputProps$1 {
8
+ /**
9
+ * The current Powerlines process context.
10
+ */
11
+ context: TContext;
12
+ /**
13
+ * Metadata for the current render.
14
+ */
15
+ meta?: TMeta;
16
+ }
17
+ /**
18
+ * Output component for rendering the Powerlines plugin's output files via templates.
19
+ */
20
+ declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>): _alloy_js_core0.Children;
21
+ declare type __ΩOutputProps = any[];
22
+ //#endregion
23
+ export { Output, OutputProps, __ΩOutputProps };
@@ -0,0 +1,23 @@
1
+ import { PluginContext } from "../../powerlines/src/types/context.mjs";
2
+ import { MetaItem } from "../contexts/context.mjs";
3
+ import * as _alloy_js_core0 from "@alloy-js/core";
4
+ import { OutputProps as OutputProps$1 } from "@alloy-js/core";
5
+
6
+ //#region src/core/components/output.d.ts
7
+ interface OutputProps<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>> extends OutputProps$1 {
8
+ /**
9
+ * The current Powerlines process context.
10
+ */
11
+ context: TContext;
12
+ /**
13
+ * Metadata for the current render.
14
+ */
15
+ meta?: TMeta;
16
+ }
17
+ /**
18
+ * Output component for rendering the Powerlines plugin's output files via templates.
19
+ */
20
+ declare function Output<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(props: OutputProps<TContext, TMeta>): _alloy_js_core0.Children;
21
+ declare type __ΩOutputProps = any[];
22
+ //#endregion
23
+ export { Output, OutputProps, __ΩOutputProps };
@@ -1,13 +1,13 @@
1
1
  import { PowerlinesContext } from "../contexts/context.mjs";
2
2
  import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { Output, Show, computed, ref, splitProps } from "@alloy-js/core";
3
+ import { Output as Output$1, Show, computed, ref, splitProps } from "@alloy-js/core";
4
4
  import { replacePath } from "@stryke/path/replace";
5
5
 
6
6
  //#region src/core/components/output.tsx
7
7
  /**
8
8
  * Output component for rendering the Powerlines plugin's output files via templates.
9
9
  */
10
- function Output$1(props) {
10
+ function Output(props) {
11
11
  const [{ children, context, meta, basePath }, rest] = splitProps(props, [
12
12
  "children",
13
13
  "context",
@@ -17,7 +17,7 @@ function Output$1(props) {
17
17
  const contextRef = ref(context);
18
18
  const metaRef = ref(meta ?? {});
19
19
  const basePathRef = computed(() => basePath ? replacePath(basePath, contextRef.value.workspaceConfig.workspaceRoot) : contextRef.value.workspaceConfig.workspaceRoot);
20
- return createComponent(Output, mergeProps(rest, {
20
+ return createComponent(Output$1, mergeProps(rest, {
21
21
  get basePath() {
22
22
  return basePathRef.value;
23
23
  },
@@ -41,4 +41,4 @@ function Output$1(props) {
41
41
  }
42
42
 
43
43
  //#endregion
44
- export { Output$1 as Output };
44
+ export { Output };
@@ -0,0 +1,22 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
+ let __alloy_js_core = require("@alloy-js/core");
4
+
5
+ //#region src/core/components/single-line-comment.tsx
6
+ /**
7
+ * A single line comment block. The children are rendered as a prose element, which means that they
8
+ * are broken into multiple lines
9
+ */
10
+ function SingleLineComment(props) {
11
+ const { variant = "double-slash", children } = props;
12
+ const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
13
+ return [commentStart, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("align", {
14
+ string: commentStart,
15
+ get children() {
16
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Prose, { children }), variant === "slash-star" || variant === "slash-star-star" ? " */ " : variant === "markdown" ? " -->" : ""];
17
+ }
18
+ })];
19
+ }
20
+
21
+ //#endregion
22
+ exports.SingleLineComment = SingleLineComment;
@@ -0,0 +1,22 @@
1
+ import { ComponentProps } from "../../types/components.cjs";
2
+ import * as _alloy_js_core1 from "@alloy-js/core";
3
+
4
+ //#region src/core/components/single-line-comment.d.ts
5
+ type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
6
+ interface SingleLineCommentProps extends ComponentProps {
7
+ /**
8
+ * The variant of the single line comment.
9
+ *
10
+ * @defaultValue "double-slash"
11
+ */
12
+ variant?: SingleLineCommentVariant;
13
+ }
14
+ /**
15
+ * A single line comment block. The children are rendered as a prose element, which means that they
16
+ * are broken into multiple lines
17
+ */
18
+ declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core1.Children;
19
+ declare type __ΩSingleLineCommentVariant = any[];
20
+ declare type __ΩSingleLineCommentProps = any[];
21
+ //#endregion
22
+ export { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant };
@@ -0,0 +1,22 @@
1
+ import { ComponentProps } from "../../types/components.mjs";
2
+ import * as _alloy_js_core0 from "@alloy-js/core";
3
+
4
+ //#region src/core/components/single-line-comment.d.ts
5
+ type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
6
+ interface SingleLineCommentProps extends ComponentProps {
7
+ /**
8
+ * The variant of the single line comment.
9
+ *
10
+ * @defaultValue "double-slash"
11
+ */
12
+ variant?: SingleLineCommentVariant;
13
+ }
14
+ /**
15
+ * A single line comment block. The children are rendered as a prose element, which means that they
16
+ * are broken into multiple lines
17
+ */
18
+ declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core0.Children;
19
+ declare type __ΩSingleLineCommentVariant = any[];
20
+ declare type __ΩSingleLineCommentProps = any[];
21
+ //#endregion
22
+ export { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant };
@@ -0,0 +1,21 @@
1
+ import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { Prose } from "@alloy-js/core";
3
+
4
+ //#region src/core/components/single-line-comment.tsx
5
+ /**
6
+ * A single line comment block. The children are rendered as a prose element, which means that they
7
+ * are broken into multiple lines
8
+ */
9
+ function SingleLineComment(props) {
10
+ const { variant = "double-slash", children } = props;
11
+ const commentStart = variant === "slash-star" ? "/* " : variant === "slash-star-star" ? "/** " : variant === "triple-slash" ? "/// " : variant === "markdown" ? "<!-- " : "// ";
12
+ return [commentStart, createIntrinsic("align", {
13
+ string: commentStart,
14
+ get children() {
15
+ return [createComponent(Prose, { children }), variant === "slash-star" || variant === "slash-star-star" ? " */ " : variant === "markdown" ? " -->" : ""];
16
+ }
17
+ })];
18
+ }
19
+
20
+ //#endregion
21
+ export { SingleLineComment };
@@ -0,0 +1,64 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_core_contexts_context = require('../contexts/context.cjs');
3
+ require('../contexts/index.cjs');
4
+ let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let __alloy_js_core = require("@alloy-js/core");
6
+ let __stryke_path_append = require("@stryke/path/append");
7
+ let defu = require("defu");
8
+ defu = require_rolldown_runtime.__toESM(defu);
9
+
10
+ //#region src/core/components/source-file.tsx
11
+ /**
12
+ * A base component representing a Powerlines generated source file.
13
+ *
14
+ * @param props - The properties for the source file.
15
+ * @returns The rendered source file component.
16
+ */
17
+ function SourceFile(props) {
18
+ const [{ children, meta, path, header, storage, filetype, reference }] = (0, __alloy_js_core.splitProps)(props, [
19
+ "children",
20
+ "meta",
21
+ "path",
22
+ "header",
23
+ "storage",
24
+ "filetype",
25
+ "reference"
26
+ ]);
27
+ const metadata = require_core_contexts_context.useMetaSafe();
28
+ const parentDirectory = (0, __alloy_js_core.useContext)(__alloy_js_core.SourceDirectoryContext);
29
+ const sourceFile = {
30
+ path: (0, __stryke_path_append.appendPath)(path, parentDirectory.path),
31
+ filetype,
32
+ reference
33
+ };
34
+ parentDirectory?.addContent(sourceFile);
35
+ const printOptions = (0, __alloy_js_core.useFormatOptions)({
36
+ printWidth: props.printWidth,
37
+ tabWidth: props.tabWidth,
38
+ useTabs: props.useTabs,
39
+ insertFinalNewLine: props.insertFinalNewLine
40
+ });
41
+ const nodeContext = (0, __alloy_js_core.getContext)();
42
+ nodeContext.meta = (0, defu.default)({
43
+ sourceFile,
44
+ printOptions
45
+ }, meta ?? {});
46
+ if (metadata) metadata[sourceFile.path] = {
47
+ storage,
48
+ ...meta ?? {}
49
+ };
50
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.SourceFileContext.Provider, {
51
+ value: sourceFile,
52
+ get children() {
53
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
54
+ when: header !== void 0,
55
+ get children() {
56
+ return [header, (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
57
+ }
58
+ }), children];
59
+ }
60
+ });
61
+ }
62
+
63
+ //#endregion
64
+ exports.SourceFile = SourceFile;
@@ -0,0 +1,32 @@
1
+ import { StoragePreset } from "../../powerlines/src/types/fs.cjs";
2
+ import { ComponentProps } from "../../types/components.cjs";
3
+ import * as _alloy_js_core7 from "@alloy-js/core";
4
+ import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
5
+
6
+ //#region src/core/components/source-file.d.ts
7
+ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
8
+ /**
9
+ * The storage preset for the output files.
10
+ *
11
+ * @remarks
12
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
13
+ */
14
+ storage?: StoragePreset;
15
+ /**
16
+ * The metadata associated with the source file.
17
+ *
18
+ * @remarks
19
+ * The values stored in the metadata will be available in the rendering context.
20
+ */
21
+ meta?: Record<string, any>;
22
+ };
23
+ /**
24
+ * A base component representing a Powerlines generated source file.
25
+ *
26
+ * @param props - The properties for the source file.
27
+ * @returns The rendered source file component.
28
+ */
29
+ declare function SourceFile(props: SourceFileProps): _alloy_js_core7.Children;
30
+ declare type __ΩSourceFileProps = any[];
31
+ //#endregion
32
+ export { SourceFile, SourceFileProps, __ΩSourceFileProps };
@@ -0,0 +1,32 @@
1
+ import { StoragePreset } from "../../powerlines/src/types/fs.mjs";
2
+ import { ComponentProps } from "../../types/components.mjs";
3
+ import * as _alloy_js_core9 from "@alloy-js/core";
4
+ import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
5
+
6
+ //#region src/core/components/source-file.d.ts
7
+ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
8
+ /**
9
+ * The storage preset for the output files.
10
+ *
11
+ * @remarks
12
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
13
+ */
14
+ storage?: StoragePreset;
15
+ /**
16
+ * The metadata associated with the source file.
17
+ *
18
+ * @remarks
19
+ * The values stored in the metadata will be available in the rendering context.
20
+ */
21
+ meta?: Record<string, any>;
22
+ };
23
+ /**
24
+ * A base component representing a Powerlines generated source file.
25
+ *
26
+ * @param props - The properties for the source file.
27
+ * @returns The rendered source file component.
28
+ */
29
+ declare function SourceFile(props: SourceFileProps): _alloy_js_core9.Children;
30
+ declare type __ΩSourceFileProps = any[];
31
+ //#endregion
32
+ export { SourceFile, SourceFileProps, __ΩSourceFileProps };
@@ -0,0 +1,62 @@
1
+ import { useMetaSafe } from "../contexts/context.mjs";
2
+ import "../contexts/index.mjs";
3
+ import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
4
+ import { Show, SourceDirectoryContext, SourceFileContext, getContext, splitProps, useContext, useFormatOptions } from "@alloy-js/core";
5
+ import { appendPath } from "@stryke/path/append";
6
+ import defu from "defu";
7
+
8
+ //#region src/core/components/source-file.tsx
9
+ /**
10
+ * A base component representing a Powerlines generated source file.
11
+ *
12
+ * @param props - The properties for the source file.
13
+ * @returns The rendered source file component.
14
+ */
15
+ function SourceFile(props) {
16
+ const [{ children, meta, path, header, storage, filetype, reference }] = splitProps(props, [
17
+ "children",
18
+ "meta",
19
+ "path",
20
+ "header",
21
+ "storage",
22
+ "filetype",
23
+ "reference"
24
+ ]);
25
+ const metadata = useMetaSafe();
26
+ const parentDirectory = useContext(SourceDirectoryContext);
27
+ const sourceFile = {
28
+ path: appendPath(path, parentDirectory.path),
29
+ filetype,
30
+ reference
31
+ };
32
+ parentDirectory?.addContent(sourceFile);
33
+ const printOptions = useFormatOptions({
34
+ printWidth: props.printWidth,
35
+ tabWidth: props.tabWidth,
36
+ useTabs: props.useTabs,
37
+ insertFinalNewLine: props.insertFinalNewLine
38
+ });
39
+ const nodeContext = getContext();
40
+ nodeContext.meta = defu({
41
+ sourceFile,
42
+ printOptions
43
+ }, meta ?? {});
44
+ if (metadata) metadata[sourceFile.path] = {
45
+ storage,
46
+ ...meta ?? {}
47
+ };
48
+ return createComponent(SourceFileContext.Provider, {
49
+ value: sourceFile,
50
+ get children() {
51
+ return [createComponent(Show, {
52
+ when: header !== void 0,
53
+ get children() {
54
+ return [header, createIntrinsic("hbr", {})];
55
+ }
56
+ }), children];
57
+ }
58
+ });
59
+ }
60
+
61
+ //#endregion
62
+ export { SourceFile };
@@ -6,6 +6,55 @@ let __alloy_js_core = require("@alloy-js/core");
6
6
  * The Powerlines context used in template rendering.
7
7
  */
8
8
  const PowerlinesContext = (0, __alloy_js_core.createNamedContext)("powerlines");
9
+ /**
10
+ * Hook to access the Powerlines Context.
11
+ *
12
+ * @returns The Context.
13
+ */
14
+ function usePowerlinesContext() {
15
+ return (0, __alloy_js_core.useContext)(PowerlinesContext);
16
+ }
17
+ /**
18
+ * Hook to safely access the {@link PluginContext | Powerlines context}.
19
+ *
20
+ * @returns The Powerlines context or undefined if not set.
21
+ */
22
+ function usePowerlinesSafe() {
23
+ return usePowerlinesContext()?.ref?.value;
24
+ }
25
+ /**
26
+ * Hook to access the {@link PluginContext | Powerlines context}.
27
+ *
28
+ * @returns The Powerlines context.
29
+ */
30
+ function usePowerlines() {
31
+ const powerlines = usePowerlinesSafe();
32
+ if (!powerlines) throw new Error("Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
33
+ return powerlines;
34
+ }
35
+ /**
36
+ * Hook to safely access the render context's metadata.
37
+ *
38
+ * @returns The Powerlines context or undefined if not set.
39
+ */
40
+ function useMetaSafe() {
41
+ return usePowerlinesContext()?.meta?.value;
42
+ }
43
+ /**
44
+ * Hook to access the render context's metadata.
45
+ *
46
+ * @returns The Powerlines context.
47
+ */
48
+ function useMeta() {
49
+ const meta = useMetaSafe();
50
+ if (!meta) throw new Error("Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
51
+ return meta;
52
+ }
9
53
 
10
54
  //#endregion
11
- exports.PowerlinesContext = PowerlinesContext;
55
+ exports.PowerlinesContext = PowerlinesContext;
56
+ exports.useMeta = useMeta;
57
+ exports.useMetaSafe = useMetaSafe;
58
+ exports.usePowerlines = usePowerlines;
59
+ exports.usePowerlinesContext = usePowerlinesContext;
60
+ exports.usePowerlinesSafe = usePowerlinesSafe;
@@ -0,0 +1,71 @@
1
+ import { StoragePreset } from "../../powerlines/src/types/fs.cjs";
2
+ import { PluginContext } from "../../powerlines/src/types/context.cjs";
3
+ import { ComponentContext, Ref } from "@alloy-js/core";
4
+
5
+ //#region src/core/contexts/context.d.ts
6
+ interface MetaItem {
7
+ /**
8
+ * The kind of metadata item.
9
+ */
10
+ kind?: "builtin" | "entry" | string;
11
+ /**
12
+ * Whether to skip formatting for this output.
13
+ */
14
+ skipFormat?: boolean;
15
+ /**
16
+ * The storage preset or adapter name for the output files.
17
+ *
18
+ * @remarks
19
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
20
+ */
21
+ storage?: StoragePreset | string;
22
+ [key: string]: any;
23
+ }
24
+ interface PowerlinesContextInterface<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>> {
25
+ /**
26
+ * The current Powerlines context.
27
+ */
28
+ ref: Ref<TContext>;
29
+ /**
30
+ * The current render metadata.
31
+ */
32
+ meta: Ref<TMeta>;
33
+ }
34
+ /**
35
+ * The Powerlines context used in template rendering.
36
+ */
37
+ declare const PowerlinesContext: ComponentContext<PowerlinesContextInterface<any, any>>;
38
+ /**
39
+ * Hook to access the Powerlines Context.
40
+ *
41
+ * @returns The Context.
42
+ */
43
+ declare function usePowerlinesContext<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): PowerlinesContextInterface<TContext, TMeta> | undefined;
44
+ /**
45
+ * Hook to safely access the {@link PluginContext | Powerlines context}.
46
+ *
47
+ * @returns The Powerlines context or undefined if not set.
48
+ */
49
+ declare function usePowerlinesSafe<TContext extends PluginContext = PluginContext>(): TContext | undefined;
50
+ /**
51
+ * Hook to access the {@link PluginContext | Powerlines context}.
52
+ *
53
+ * @returns The Powerlines context.
54
+ */
55
+ declare function usePowerlines<TContext extends PluginContext = PluginContext>(): TContext;
56
+ /**
57
+ * Hook to safely access the render context's metadata.
58
+ *
59
+ * @returns The Powerlines context or undefined if not set.
60
+ */
61
+ declare function useMetaSafe<TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): TMeta | undefined;
62
+ /**
63
+ * Hook to access the render context's metadata.
64
+ *
65
+ * @returns The Powerlines context.
66
+ */
67
+ declare function useMeta<TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): TMeta;
68
+ declare type __ΩMetaItem = any[];
69
+ declare type __ΩPowerlinesContextInterface = any[];
70
+ //#endregion
71
+ export { MetaItem, PowerlinesContext, PowerlinesContextInterface, __ΩMetaItem, __ΩPowerlinesContextInterface, useMeta, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe };
@@ -0,0 +1,71 @@
1
+ import { StoragePreset } from "../../powerlines/src/types/fs.mjs";
2
+ import { PluginContext } from "../../powerlines/src/types/context.mjs";
3
+ import { ComponentContext, Ref } from "@alloy-js/core";
4
+
5
+ //#region src/core/contexts/context.d.ts
6
+ interface MetaItem {
7
+ /**
8
+ * The kind of metadata item.
9
+ */
10
+ kind?: "builtin" | "entry" | string;
11
+ /**
12
+ * Whether to skip formatting for this output.
13
+ */
14
+ skipFormat?: boolean;
15
+ /**
16
+ * The storage preset or adapter name for the output files.
17
+ *
18
+ * @remarks
19
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
20
+ */
21
+ storage?: StoragePreset | string;
22
+ [key: string]: any;
23
+ }
24
+ interface PowerlinesContextInterface<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>> {
25
+ /**
26
+ * The current Powerlines context.
27
+ */
28
+ ref: Ref<TContext>;
29
+ /**
30
+ * The current render metadata.
31
+ */
32
+ meta: Ref<TMeta>;
33
+ }
34
+ /**
35
+ * The Powerlines context used in template rendering.
36
+ */
37
+ declare const PowerlinesContext: ComponentContext<PowerlinesContextInterface<any, any>>;
38
+ /**
39
+ * Hook to access the Powerlines Context.
40
+ *
41
+ * @returns The Context.
42
+ */
43
+ declare function usePowerlinesContext<TContext extends PluginContext = PluginContext, TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): PowerlinesContextInterface<TContext, TMeta> | undefined;
44
+ /**
45
+ * Hook to safely access the {@link PluginContext | Powerlines context}.
46
+ *
47
+ * @returns The Powerlines context or undefined if not set.
48
+ */
49
+ declare function usePowerlinesSafe<TContext extends PluginContext = PluginContext>(): TContext | undefined;
50
+ /**
51
+ * Hook to access the {@link PluginContext | Powerlines context}.
52
+ *
53
+ * @returns The Powerlines context.
54
+ */
55
+ declare function usePowerlines<TContext extends PluginContext = PluginContext>(): TContext;
56
+ /**
57
+ * Hook to safely access the render context's metadata.
58
+ *
59
+ * @returns The Powerlines context or undefined if not set.
60
+ */
61
+ declare function useMetaSafe<TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): TMeta | undefined;
62
+ /**
63
+ * Hook to access the render context's metadata.
64
+ *
65
+ * @returns The Powerlines context.
66
+ */
67
+ declare function useMeta<TMeta extends Record<string, MetaItem> = Record<string, MetaItem>>(): TMeta;
68
+ declare type __ΩMetaItem = any[];
69
+ declare type __ΩPowerlinesContextInterface = any[];
70
+ //#endregion
71
+ export { MetaItem, PowerlinesContext, PowerlinesContextInterface, __ΩMetaItem, __ΩPowerlinesContextInterface, useMeta, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe };
@@ -1,10 +1,54 @@
1
- import { createNamedContext } from "@alloy-js/core";
1
+ import { createNamedContext, useContext } from "@alloy-js/core";
2
2
 
3
3
  //#region src/core/contexts/context.ts
4
4
  /**
5
5
  * The Powerlines context used in template rendering.
6
6
  */
7
7
  const PowerlinesContext = createNamedContext("powerlines");
8
+ /**
9
+ * Hook to access the Powerlines Context.
10
+ *
11
+ * @returns The Context.
12
+ */
13
+ function usePowerlinesContext() {
14
+ return useContext(PowerlinesContext);
15
+ }
16
+ /**
17
+ * Hook to safely access the {@link PluginContext | Powerlines context}.
18
+ *
19
+ * @returns The Powerlines context or undefined if not set.
20
+ */
21
+ function usePowerlinesSafe() {
22
+ return usePowerlinesContext()?.ref?.value;
23
+ }
24
+ /**
25
+ * Hook to access the {@link PluginContext | Powerlines context}.
26
+ *
27
+ * @returns The Powerlines context.
28
+ */
29
+ function usePowerlines() {
30
+ const powerlines = usePowerlinesSafe();
31
+ if (!powerlines) throw new Error("Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
32
+ return powerlines;
33
+ }
34
+ /**
35
+ * Hook to safely access the render context's metadata.
36
+ *
37
+ * @returns The Powerlines context or undefined if not set.
38
+ */
39
+ function useMetaSafe() {
40
+ return usePowerlinesContext()?.meta?.value;
41
+ }
42
+ /**
43
+ * Hook to access the render context's metadata.
44
+ *
45
+ * @returns The Powerlines context.
46
+ */
47
+ function useMeta() {
48
+ const meta = useMetaSafe();
49
+ if (!meta) throw new Error("Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.");
50
+ return meta;
51
+ }
8
52
 
9
53
  //#endregion
10
- export { PowerlinesContext };
54
+ export { PowerlinesContext, useMeta, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe };