@powerlines/plugin-alloy 0.25.29 → 0.25.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/output.cjs +12 -7
- package/dist/core/components/output.mjs +12 -7
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +5 -8
- package/dist/core/components/single-line-comment.mjs +5 -8
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +8 -7
- package/dist/core/components/source-file.mjs +8 -7
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +5 -6
- package/dist/core/components/spacing.mjs +5 -6
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +12 -9
- package/dist/markdown/components/front-matter.mjs +12 -9
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/markdown-file.cjs +57 -41
- package/dist/markdown/components/markdown-file.mjs +57 -41
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +31 -20
- package/dist/markdown/components/markdown-table.mjs +31 -20
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/render.cjs +10 -4
- package/dist/render.mjs +10 -4
- package/dist/render.mjs.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +21 -9
- package/dist/typescript/components/builtin-file.mjs +21 -9
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +112 -79
- package/dist/typescript/components/class-declaration.mjs +112 -79
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +6 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +6 -1
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +7 -3
- package/dist/typescript/components/entry-file.mjs +7 -3
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/infrastructure-file.cjs +7 -3
- package/dist/typescript/components/infrastructure-file.mjs +7 -3
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +83 -47
- package/dist/typescript/components/interface-declaration.mjs +83 -47
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +48 -36
- package/dist/typescript/components/object-declaration.mjs +48 -36
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +2 -2
- package/dist/typescript/components/property-name.mjs +3 -3
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +112 -54
- package/dist/typescript/components/tsdoc-reflection.mjs +112 -54
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +211 -140
- package/dist/typescript/components/tsdoc.mjs +211 -140
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +17 -9
- package/dist/typescript/components/type-declaration.mjs +17 -9
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +33 -33
- package/dist/typescript/components/type-parameters.mjs +33 -33
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +90 -65
- package/dist/typescript/components/typescript-file.mjs +90 -65
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/lexical-scope.cjs +5 -1
- package/dist/typescript/contexts/lexical-scope.mjs +5 -1
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +5 -2
- package/dist/typescript/contexts/member-scope.mjs +5 -2
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/yaml/components/yaml-file.cjs +58 -48
- package/dist/yaml/components/yaml-file.mjs +58 -48
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -3,6 +3,7 @@ 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 { Show, splitProps } from "@alloy-js/core";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
6
7
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
7
8
|
import { getFileHeaderWarning } from "powerlines/utils";
|
|
8
9
|
import { Link } from "@alloy-js/markdown";
|
|
@@ -21,9 +22,17 @@ function MarkdownFile(props) {
|
|
|
21
22
|
"storage",
|
|
22
23
|
"frontMatter"
|
|
23
24
|
]);
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return /* @__PURE__ */ jsx(SourceFile, {
|
|
26
|
+
header: /* @__PURE__ */ jsx(MarkdownFileHeader, { frontMatter }),
|
|
27
|
+
...rest,
|
|
28
|
+
filetype: "md",
|
|
29
|
+
reference: Link,
|
|
30
|
+
storage,
|
|
31
|
+
children: /* @__PURE__ */ jsx(Show, {
|
|
32
|
+
when: Boolean(children),
|
|
33
|
+
children
|
|
34
|
+
})
|
|
35
|
+
});
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
38
|
* Renders the header for a Powerlines Typescript source file.
|
|
@@ -40,44 +49,51 @@ function MarkdownFileHeader(props) {
|
|
|
40
49
|
"frontMatter"
|
|
41
50
|
]);
|
|
42
51
|
const context = usePowerlinesSafe();
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx(Show, {
|
|
54
|
+
when: isSetObject(frontMatter) && Object.keys(frontMatter).length > 0,
|
|
55
|
+
children: /* @__PURE__ */ jsx(FrontMatter, { data: frontMatter })
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
58
|
+
when: Boolean(disableEslint),
|
|
59
|
+
children: [/* @__PURE__ */ jsx(SingleLineComment, {
|
|
60
|
+
variant: "markdown",
|
|
61
|
+
children: "eslint-disable"
|
|
62
|
+
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
65
|
+
when: Boolean(disablePrettier),
|
|
66
|
+
children: [/* @__PURE__ */ jsx(SingleLineComment, {
|
|
67
|
+
variant: "markdown",
|
|
68
|
+
children: "prettier-ignore"
|
|
69
|
+
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsxs(Show, {
|
|
72
|
+
when: Boolean(disableBiome),
|
|
73
|
+
children: [/* @__PURE__ */ jsx(SingleLineComment, {
|
|
74
|
+
variant: "markdown",
|
|
75
|
+
children: "biome-ignore lint: disable"
|
|
76
|
+
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx(Show, {
|
|
79
|
+
when: Boolean(disableEslint) || Boolean(disablePrettier) || Boolean(disableBiome),
|
|
80
|
+
children: /* @__PURE__ */ jsx("hbr", {})
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ jsx(Show, {
|
|
83
|
+
when: Boolean(children),
|
|
84
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [children, /* @__PURE__ */ jsx("hbr", {})] })
|
|
85
|
+
}),
|
|
86
|
+
/* @__PURE__ */ jsx(SingleLineComment, {
|
|
87
|
+
variant: "markdown",
|
|
88
|
+
children: `Generated by ${titleCase(context?.config?.framework) || "Powerlines"}`
|
|
89
|
+
}),
|
|
90
|
+
/* @__PURE__ */ jsx("hbr", {}),
|
|
91
|
+
/* @__PURE__ */ jsx(SingleLineComment, {
|
|
92
|
+
variant: "markdown",
|
|
93
|
+
children: getFileHeaderWarning(context)
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ jsx("hbr", {})
|
|
96
|
+
] });
|
|
81
97
|
}
|
|
82
98
|
|
|
83
99
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-file.mjs","names":[],"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":"
|
|
1
|
+
{"version":3,"file":"markdown-file.mjs","names":[],"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":";;;;;;;;;;;;;;;;;;AAuCA,SAAgB,aAAa,OAA0B;CACrD,MAAM,CAAC,EAAE,UAAU,SAAS,eAAe,QAAQ,WAAW,OAAO;EACnE;EACA;EACA;EACD,CAAC;AAEF,QACE,oBAAC,YAAD;EACE,QAAQ,oBAAC,oBAAD,EAAiC,aAAe;EACxD,GAAI;EACJ,UAAS;EACT,WAAW;EACF;YACT,oBAAC,MAAD;GAAM,MAAM,QAAQ,SAAS;GAAG;GAAgB;EACrC;;;;;;;;AAcjB,SAAgB,mBAAmB,OAAgC;CACjE,MAAM,CACJ,EACE,UACA,gBAAgB,MAChB,eAAe,MACf,kBAAkB,OAClB,iBAEA,WAAW,OAAO;EACpB;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,UAAU,mBAAmB;AAEnC,QACE;EACE,oBAAC,MAAD;GACE,MAAM,YAAY,YAAY,IAAI,OAAO,KAAK,YAAY,CAAC,SAAS;aACpE,oBAAC,aAAD,EAAa,MAAM,aAAgB;GAC9B;EACP,qBAAC,MAAD;GAAM,MAAM,QAAQ,cAAc;aAAlC,CACE,oBAAC,mBAAD;IAAmB,SAAQ;cACxB;IACiB,GACpB,oBAAC,OAAD,EAAO,EACF;;EACP,qBAAC,MAAD;GAAM,MAAM,QAAQ,gBAAgB;aAApC,CACE,oBAAC,mBAAD;IAAmB,SAAQ;cACxB;IACiB,GACpB,oBAAC,OAAD,EAAO,EACF;;EACP,qBAAC,MAAD;GAAM,MAAM,QAAQ,aAAa;aAAjC,CACE,oBAAC,mBAAD;IAAmB,SAAQ;cACxB;IACiB,GACpB,oBAAC,OAAD,EAAO,EACF;;EACP,oBAAC,MAAD;GACE,MACE,QAAQ,cAAc,IACtB,QAAQ,gBAAgB,IACxB,QAAQ,aAAa;aAEvB,oBAAC,OAAD,EAAO;GACF;EACP,oBAAC,MAAD;GAAM,MAAM,QAAQ,SAAS;aAC3B,4CACG,UACD,oBAAC,OAAD,EAAO,EACN;GACE;EACP,oBAAC,mBAAD;GAAmB,SAAQ;aAAY,gBACrC,UAAU,SAAS,QAAQ,UAAU,IAAI;GACpB;EACvB,oBAAC,OAAD,EAAO;EACP,oBAAC,mBAAD;GAAmB,SAAQ;aACxB,qBAAqB,QAAS;GACb;EACpB,oBAAC,OAAD,EAAO;EACN"}
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_markdown_contexts_markdown_table = require('../contexts/markdown-table.cjs');
|
|
4
4
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
6
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
6
7
|
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
7
8
|
|
|
@@ -17,12 +18,16 @@ function MarkdownTable(props) {
|
|
|
17
18
|
align: "left",
|
|
18
19
|
width: 20
|
|
19
20
|
})));
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_markdown_contexts_markdown_table.MarkdownTableContext.Provider, {
|
|
22
|
+
value: {
|
|
23
|
+
columns: columns.value,
|
|
24
|
+
data
|
|
25
|
+
},
|
|
26
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
27
|
+
when: Boolean(children),
|
|
28
|
+
children
|
|
29
|
+
})
|
|
30
|
+
});
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* Component that provides a context for rendering markdown tables.
|
|
@@ -42,26 +47,32 @@ function MarkdownTableColumn(props) {
|
|
|
42
47
|
const textLength = (0, _alloy_js_core.computed)(() => {
|
|
43
48
|
return (children ? children.toString() : "").length;
|
|
44
49
|
});
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_core.Prose, { children: [
|
|
51
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
52
|
+
when: indexRef.value === 0,
|
|
53
|
+
children: "|"
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
56
|
+
when: Boolean(children),
|
|
57
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Prose, { children: _alloy_js_core.code`${alignRef.value === "left" ? " ".repeat(widthRef.value - textLength.value - 1) : " "}${children}${alignRef.value === "right" ? " ".repeat(widthRef.value - textLength.value - 1) : " "}` })
|
|
58
|
+
}),
|
|
59
|
+
"|"
|
|
60
|
+
] });
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
63
|
* Component that provides a context for rendering markdown tables.
|
|
55
64
|
*/
|
|
56
65
|
function MarkdownTableColumnHeader(props) {
|
|
57
66
|
const [{ children, name }, rest] = (0, _alloy_js_core.splitProps)(props, ["children", "name"]);
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(MarkdownTableColumn, {
|
|
68
|
+
...rest,
|
|
69
|
+
name,
|
|
70
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
71
|
+
fallback: (0, _stryke_string_format_title_case.titleCase)(name, { useDescriptions: false }),
|
|
72
|
+
when: !(0, _stryke_type_checks_is_undefined.isUndefined)(children),
|
|
73
|
+
children
|
|
74
|
+
})
|
|
75
|
+
}) });
|
|
65
76
|
}
|
|
66
77
|
|
|
67
78
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MarkdownTableContext, useMarkdownTable } from "../contexts/markdown-table.mjs";
|
|
2
2
|
import { Prose, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
3
4
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
4
5
|
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
5
6
|
|
|
@@ -15,12 +16,16 @@ function MarkdownTable(props) {
|
|
|
15
16
|
align: "left",
|
|
16
17
|
width: 20
|
|
17
18
|
})));
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
return /* @__PURE__ */ jsx(MarkdownTableContext.Provider, {
|
|
20
|
+
value: {
|
|
21
|
+
columns: columns.value,
|
|
22
|
+
data
|
|
23
|
+
},
|
|
24
|
+
children: /* @__PURE__ */ jsx(Show, {
|
|
25
|
+
when: Boolean(children),
|
|
26
|
+
children
|
|
27
|
+
})
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
26
31
|
* Component that provides a context for rendering markdown tables.
|
|
@@ -40,26 +45,32 @@ function MarkdownTableColumn(props) {
|
|
|
40
45
|
const textLength = computed(() => {
|
|
41
46
|
return (children ? children.toString() : "").length;
|
|
42
47
|
});
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
return /* @__PURE__ */ jsxs(Prose, { children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Show, {
|
|
50
|
+
when: indexRef.value === 0,
|
|
51
|
+
children: "|"
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ jsx(Show, {
|
|
54
|
+
when: Boolean(children),
|
|
55
|
+
children: /* @__PURE__ */ jsx(Prose, { children: code`${alignRef.value === "left" ? " ".repeat(widthRef.value - textLength.value - 1) : " "}${children}${alignRef.value === "right" ? " ".repeat(widthRef.value - textLength.value - 1) : " "}` })
|
|
56
|
+
}),
|
|
57
|
+
"|"
|
|
58
|
+
] });
|
|
50
59
|
}
|
|
51
60
|
/**
|
|
52
61
|
* Component that provides a context for rendering markdown tables.
|
|
53
62
|
*/
|
|
54
63
|
function MarkdownTableColumnHeader(props) {
|
|
55
64
|
const [{ children, name }, rest] = splitProps(props, ["children", "name"]);
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MarkdownTableColumn, {
|
|
66
|
+
...rest,
|
|
67
|
+
name,
|
|
68
|
+
children: /* @__PURE__ */ jsx(Show, {
|
|
69
|
+
fallback: titleCase(name, { useDescriptions: false }),
|
|
70
|
+
when: !isUndefined(children),
|
|
71
|
+
children
|
|
72
|
+
})
|
|
73
|
+
}) });
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-table.mjs","names":[],"sources":["../../../src/markdown/components/markdown-table.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, computed, Prose, Show, splitProps } from \"@alloy-js/core\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { ComponentProps } from \"../../types/components\";\nimport {\n MarkdownTableColumnContextInterface,\n MarkdownTableContext,\n useMarkdownTable\n} from \"../contexts/markdown-table\";\n\nexport interface MarkdownTableProps<\n T extends Record<string, any> = Record<string, any>\n> extends ComponentProps {\n data: T[];\n}\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTable<\n T extends Record<string, any> = Record<string, any>\n>(props: MarkdownTableProps<T>) {\n const [{ children, data }] = splitProps(props, [\"children\", \"data\"]);\n\n const columns = computed(() =>\n Object.keys(data).map((name: string, index: number) => ({\n index,\n name,\n align: \"left\" as const,\n width: 20\n }))\n );\n\n return (\n <MarkdownTableContext.Provider value={{ columns: columns.value, data }}>\n <Show when={Boolean(children)}>{children}</Show>\n </MarkdownTableContext.Provider>\n );\n}\n\nexport type MarkdownTableColumnProps = ComponentProps &\n Partial<Pick<MarkdownTableColumnContextInterface, \"align\">> &\n Required<Pick<MarkdownTableColumnContextInterface, \"name\">> & {\n width?: number;\n };\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTableColumn(props: MarkdownTableColumnProps) {\n const [{ children, width, align, name }] = splitProps(props, [\n \"children\",\n \"width\",\n \"align\",\n \"name\"\n ]);\n\n const tableContext = useMarkdownTable();\n const columnRef = computed(() =>\n tableContext?.columns.find(c => c.name === name)\n );\n\n const indexRef = computed(() => columnRef.value?.index ?? 0);\n const alignRef = computed(() => columnRef.value?.align ?? align ?? \"left\");\n const widthRef = computed(() => columnRef.value?.width ?? width ?? 20);\n\n const textLength = computed(() => {\n const content = children ? children.toString() : \"\";\n\n return content.length;\n });\n\n return (\n <Prose>\n <Show when={indexRef.value === 0}>{\"|\"}</Show>\n <Show when={Boolean(children)}>\n <Prose>{code`${\n alignRef.value === \"left\"\n ? \" \".repeat(widthRef.value - textLength.value - 1)\n : \" \"\n }${children}${\n alignRef.value === \"right\"\n ? \" \".repeat(widthRef.value - textLength.value - 1)\n : \" \"\n }`}</Prose>\n </Show>\n {\"|\"}\n </Prose>\n );\n}\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTableColumnHeader(props: MarkdownTableColumnProps) {\n const [{ children, name }, rest] = splitProps(props, [\"children\", \"name\"]);\n\n return (\n <>\n <MarkdownTableColumn {...rest} name={name}>\n <Show\n fallback={titleCase(name, {\n useDescriptions: false\n })}\n when={!isUndefined(children)}>\n {children}\n </Show>\n </MarkdownTableColumn>\n </>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-table.mjs","names":[],"sources":["../../../src/markdown/components/markdown-table.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, computed, Prose, Show, splitProps } from \"@alloy-js/core\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { ComponentProps } from \"../../types/components\";\nimport {\n MarkdownTableColumnContextInterface,\n MarkdownTableContext,\n useMarkdownTable\n} from \"../contexts/markdown-table\";\n\nexport interface MarkdownTableProps<\n T extends Record<string, any> = Record<string, any>\n> extends ComponentProps {\n data: T[];\n}\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTable<\n T extends Record<string, any> = Record<string, any>\n>(props: MarkdownTableProps<T>) {\n const [{ children, data }] = splitProps(props, [\"children\", \"data\"]);\n\n const columns = computed(() =>\n Object.keys(data).map((name: string, index: number) => ({\n index,\n name,\n align: \"left\" as const,\n width: 20\n }))\n );\n\n return (\n <MarkdownTableContext.Provider value={{ columns: columns.value, data }}>\n <Show when={Boolean(children)}>{children}</Show>\n </MarkdownTableContext.Provider>\n );\n}\n\nexport type MarkdownTableColumnProps = ComponentProps &\n Partial<Pick<MarkdownTableColumnContextInterface, \"align\">> &\n Required<Pick<MarkdownTableColumnContextInterface, \"name\">> & {\n width?: number;\n };\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTableColumn(props: MarkdownTableColumnProps) {\n const [{ children, width, align, name }] = splitProps(props, [\n \"children\",\n \"width\",\n \"align\",\n \"name\"\n ]);\n\n const tableContext = useMarkdownTable();\n const columnRef = computed(() =>\n tableContext?.columns.find(c => c.name === name)\n );\n\n const indexRef = computed(() => columnRef.value?.index ?? 0);\n const alignRef = computed(() => columnRef.value?.align ?? align ?? \"left\");\n const widthRef = computed(() => columnRef.value?.width ?? width ?? 20);\n\n const textLength = computed(() => {\n const content = children ? children.toString() : \"\";\n\n return content.length;\n });\n\n return (\n <Prose>\n <Show when={indexRef.value === 0}>{\"|\"}</Show>\n <Show when={Boolean(children)}>\n <Prose>{code`${\n alignRef.value === \"left\"\n ? \" \".repeat(widthRef.value - textLength.value - 1)\n : \" \"\n }${children}${\n alignRef.value === \"right\"\n ? \" \".repeat(widthRef.value - textLength.value - 1)\n : \" \"\n }`}</Prose>\n </Show>\n {\"|\"}\n </Prose>\n );\n}\n\n/**\n * Component that provides a context for rendering markdown tables.\n */\nexport function MarkdownTableColumnHeader(props: MarkdownTableColumnProps) {\n const [{ children, name }, rest] = splitProps(props, [\"children\", \"name\"]);\n\n return (\n <>\n <MarkdownTableColumn {...rest} name={name}>\n <Show\n fallback={titleCase(name, {\n useDescriptions: false\n })}\n when={!isUndefined(children)}>\n {children}\n </Show>\n </MarkdownTableColumn>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAgB,cAEd,OAA8B;CAC9B,MAAM,CAAC,EAAE,UAAU,UAAU,WAAW,OAAO,CAAC,YAAY,OAAO,CAAC;CAEpE,MAAM,UAAU,eACd,OAAO,KAAK,KAAK,CAAC,KAAK,MAAc,WAAmB;EACtD;EACA;EACA,OAAO;EACP,OAAO;EACR,EAAE,CACJ;AAED,QACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;GAAE,SAAS,QAAQ;GAAO;GAAM;YACpE,oBAAC,MAAD;GAAM,MAAM,QAAQ,SAAS;GAAG;GAAgB;EAClB;;;;;AAapC,SAAgB,oBAAoB,OAAiC;CACnE,MAAM,CAAC,EAAE,UAAU,OAAO,OAAO,UAAU,WAAW,OAAO;EAC3D;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,eAAe,kBAAkB;CACvC,MAAM,YAAY,eAChB,cAAc,QAAQ,MAAK,MAAK,EAAE,SAAS,KAAK,CACjD;CAED,MAAM,WAAW,eAAe,UAAU,OAAO,SAAS,EAAE;CAC5D,MAAM,WAAW,eAAe,UAAU,OAAO,SAAS,SAAS,OAAO;CAC1E,MAAM,WAAW,eAAe,UAAU,OAAO,SAAS,SAAS,GAAG;CAEtE,MAAM,aAAa,eAAe;AAGhC,UAFgB,WAAW,SAAS,UAAU,GAAG,IAElC;GACf;AAEF,QACE,qBAAC,OAAD;EACE,oBAAC,MAAD;GAAM,MAAM,SAAS,UAAU;aAAI;GAAW;EAC9C,oBAAC,MAAD;GAAM,MAAM,QAAQ,SAAS;aAC3B,oBAAC,OAAD,YAAQ,IAAI,GACV,SAAS,UAAU,SACf,IAAI,OAAO,SAAS,QAAQ,WAAW,QAAQ,EAAE,GACjD,MACH,WACD,SAAS,UAAU,UACf,IAAI,OAAO,SAAS,QAAQ,WAAW,QAAQ,EAAE,GACjD,OACK;GACN;EACN;EACK;;;;;AAOZ,SAAgB,0BAA0B,OAAiC;CACzE,MAAM,CAAC,EAAE,UAAU,QAAQ,QAAQ,WAAW,OAAO,CAAC,YAAY,OAAO,CAAC;AAE1E,QACE,0CACE,oBAAC,qBAAD;EAAqB,GAAI;EAAY;YACnC,oBAAC,MAAD;GACE,UAAU,UAAU,MAAM,EACxB,iBAAiB,OAClB,CAAC;GACF,MAAM,CAAC,YAAY,SAAS;GAC3B;GACI;EACa,GACrB"}
|
package/dist/render.cjs
CHANGED
|
@@ -4,6 +4,7 @@ const require_core_components_output = require('./core/components/output.cjs');
|
|
|
4
4
|
require('./core/index.cjs');
|
|
5
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
6
6
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
8
|
|
|
8
9
|
//#region src/render.tsx
|
|
9
10
|
/**
|
|
@@ -22,9 +23,11 @@ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
|
22
23
|
*/
|
|
23
24
|
async function render(context, children) {
|
|
24
25
|
const meta = {};
|
|
25
|
-
const output = await (0, _alloy_js_core.renderAsync)(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const output = await (0, _alloy_js_core.renderAsync)(/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_core_components_output.Output, {
|
|
27
|
+
context,
|
|
28
|
+
meta,
|
|
29
|
+
children
|
|
30
|
+
}));
|
|
28
31
|
if (!Object.keys(output).length) context.debug("No output files were rendered by Alloy-js component templates.");
|
|
29
32
|
else {
|
|
30
33
|
context.debug(`Processing ${Object.keys(output).length} rendered output files from Alloy-js component templates.`);
|
|
@@ -77,7 +80,10 @@ async function render(context, children) {
|
|
|
77
80
|
* @returns The rendered output as a string.
|
|
78
81
|
*/
|
|
79
82
|
function renderString(context, children, options) {
|
|
80
|
-
return (0, _alloy_js_core.printTree)((0, _alloy_js_core.renderTree)(
|
|
83
|
+
return (0, _alloy_js_core.printTree)((0, _alloy_js_core.renderTree)(/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_core_components_output.Output, {
|
|
84
|
+
context,
|
|
85
|
+
children
|
|
86
|
+
})), options);
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
//#endregion
|
package/dist/render.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { Output as Output$1 } from "./core/components/output.mjs";
|
|
|
2
2
|
import "./core/index.mjs";
|
|
3
3
|
import { printTree, renderAsync, renderTree, traverseOutput } from "@alloy-js/core";
|
|
4
4
|
import { findFileExtension } from "@stryke/path/file-path-fns";
|
|
5
|
+
import { jsx } from "@alloy-js/core/jsx-runtime";
|
|
5
6
|
|
|
6
7
|
//#region src/render.tsx
|
|
7
8
|
/**
|
|
@@ -20,9 +21,11 @@ import { findFileExtension } from "@stryke/path/file-path-fns";
|
|
|
20
21
|
*/
|
|
21
22
|
async function render(context, children) {
|
|
22
23
|
const meta = {};
|
|
23
|
-
const output = await renderAsync(
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const output = await renderAsync(/* @__PURE__ */ jsx(Output$1, {
|
|
25
|
+
context,
|
|
26
|
+
meta,
|
|
27
|
+
children
|
|
28
|
+
}));
|
|
26
29
|
if (!Object.keys(output).length) context.debug("No output files were rendered by Alloy-js component templates.");
|
|
27
30
|
else {
|
|
28
31
|
context.debug(`Processing ${Object.keys(output).length} rendered output files from Alloy-js component templates.`);
|
|
@@ -75,7 +78,10 @@ async function render(context, children) {
|
|
|
75
78
|
* @returns The rendered output as a string.
|
|
76
79
|
*/
|
|
77
80
|
function renderString(context, children, options) {
|
|
78
|
-
return printTree(renderTree(
|
|
81
|
+
return printTree(renderTree(/* @__PURE__ */ jsx(Output$1, {
|
|
82
|
+
context,
|
|
83
|
+
children
|
|
84
|
+
})), options);
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
//#endregion
|
package/dist/render.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.mjs","names":["Output"],"sources":["../src/render.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n printTree,\n PrintTreeOptions,\n renderAsync,\n renderTree,\n traverseOutput\n} from \"@alloy-js/core\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { PluginContext } from \"powerlines\";\nimport { MetaItem, Output } from \"./core\";\n\n/**\n * A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and write any saved content to the file system.\n *\n * @example\n * ```tsx\n * import { render } from \"@powerlines/plugin-alloy/render\";\n *\n * await render(context, <> ... </>);\n * ```\n *\n * @param context - The Powerlines plugin context.\n * @param children - The children components to render.\n * @returns A promise that resolves when rendering is complete.\n */\nexport async function render<TContext extends PluginContext>(\n context: TContext,\n children: Children\n) {\n const meta = {} as Record<string, MetaItem>;\n const output = await renderAsync(\n <Output<TContext> context={context} meta={meta}>\n {children}\n </Output>\n );\n\n if (!Object.keys(output).length) {\n context.debug(\n \"No output files were rendered by Alloy-js component templates.\"\n );\n } else {\n context.debug(\n `Processing ${\n Object.keys(output).length\n } rendered output files from Alloy-js component templates.`\n );\n\n await traverseOutput(output, {\n visitDirectory: directory => {\n if (context.fs.existsSync(directory.path)) {\n return;\n }\n\n context.fs.mkdirSync(directory.path);\n },\n visitFile: file => {\n if (\"contents\" in file) {\n const metadata = meta[file.path] ?? {};\n if (metadata.kind === \"builtin\") {\n if (!metadata.id) {\n throw new Error(\n `Built-in file \"${\n file.path\n }\" is missing its ID in the render metadata.`\n );\n }\n\n context.emitBuiltinSync(file.contents, metadata.id, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n extension: findFileExtension(file.path)\n });\n } else if (metadata.kind === \"entry\") {\n context.emitEntrySync(file.contents, file.path, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n ...(metadata.typeDefinition ?? {})\n });\n } else if (metadata.kind === \"infrastructure\") {\n if (!metadata.id) {\n throw new Error(\n `Infrastructure file \"${\n file.path\n }\" is missing its ID in the render metadata.`\n );\n }\n\n context.emitInfrastructureSync(file.contents, metadata.id, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n extension: findFileExtension(file.path)\n });\n } else {\n context.emitSync(file.contents, file.path, metadata);\n }\n } else {\n context.fs.copySync(file.sourcePath, file.path);\n }\n }\n });\n }\n}\n\n/**\n * A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.\n *\n * @example\n * ```tsx\n * import { renderString } from \"@powerlines/plugin-alloy/render\";\n *\n * const output = await renderString(context, <> ... </>);\n * ```\n *\n * @param context - The Powerlines plugin context.\n * @param children - The children components to render.\n * @param options - Optional print tree options.\n * @returns The rendered output as a string.\n */\nexport function renderString<TContext extends PluginContext>(\n context: TContext,\n children: Children,\n options?: PrintTreeOptions\n) {\n const tree = renderTree(\n <Output<TContext> context={context}>{children}</Output>\n );\n\n return printTree(tree, options);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.mjs","names":["Output"],"sources":["../src/render.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n printTree,\n PrintTreeOptions,\n renderAsync,\n renderTree,\n traverseOutput\n} from \"@alloy-js/core\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { PluginContext } from \"powerlines\";\nimport { MetaItem, Output } from \"./core\";\n\n/**\n * A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and write any saved content to the file system.\n *\n * @example\n * ```tsx\n * import { render } from \"@powerlines/plugin-alloy/render\";\n *\n * await render(context, <> ... </>);\n * ```\n *\n * @param context - The Powerlines plugin context.\n * @param children - The children components to render.\n * @returns A promise that resolves when rendering is complete.\n */\nexport async function render<TContext extends PluginContext>(\n context: TContext,\n children: Children\n) {\n const meta = {} as Record<string, MetaItem>;\n const output = await renderAsync(\n <Output<TContext> context={context} meta={meta}>\n {children}\n </Output>\n );\n\n if (!Object.keys(output).length) {\n context.debug(\n \"No output files were rendered by Alloy-js component templates.\"\n );\n } else {\n context.debug(\n `Processing ${\n Object.keys(output).length\n } rendered output files from Alloy-js component templates.`\n );\n\n await traverseOutput(output, {\n visitDirectory: directory => {\n if (context.fs.existsSync(directory.path)) {\n return;\n }\n\n context.fs.mkdirSync(directory.path);\n },\n visitFile: file => {\n if (\"contents\" in file) {\n const metadata = meta[file.path] ?? {};\n if (metadata.kind === \"builtin\") {\n if (!metadata.id) {\n throw new Error(\n `Built-in file \"${\n file.path\n }\" is missing its ID in the render metadata.`\n );\n }\n\n context.emitBuiltinSync(file.contents, metadata.id, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n extension: findFileExtension(file.path)\n });\n } else if (metadata.kind === \"entry\") {\n context.emitEntrySync(file.contents, file.path, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n ...(metadata.typeDefinition ?? {})\n });\n } else if (metadata.kind === \"infrastructure\") {\n if (!metadata.id) {\n throw new Error(\n `Infrastructure file \"${\n file.path\n }\" is missing its ID in the render metadata.`\n );\n }\n\n context.emitInfrastructureSync(file.contents, metadata.id, {\n skipFormat: metadata.skipFormat,\n storage: metadata.storage,\n extension: findFileExtension(file.path)\n });\n } else {\n context.emitSync(file.contents, file.path, metadata);\n }\n } else {\n context.fs.copySync(file.sourcePath, file.path);\n }\n }\n });\n }\n}\n\n/**\n * A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.\n *\n * @example\n * ```tsx\n * import { renderString } from \"@powerlines/plugin-alloy/render\";\n *\n * const output = await renderString(context, <> ... </>);\n * ```\n *\n * @param context - The Powerlines plugin context.\n * @param children - The children components to render.\n * @param options - Optional print tree options.\n * @returns The rendered output as a string.\n */\nexport function renderString<TContext extends PluginContext>(\n context: TContext,\n children: Children,\n options?: PrintTreeOptions\n) {\n const tree = renderTree(\n <Output<TContext> context={context}>{children}</Output>\n );\n\n return printTree(tree, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4CA,eAAsB,OACpB,SACA,UACA;CACA,MAAM,OAAO,EAAE;CACf,MAAM,SAAS,MAAM,YACnB,oBAACA,UAAD;EAA2B;EAAe;EACvC;EACM,EACV;AAED,KAAI,CAAC,OAAO,KAAK,OAAO,CAAC,OACvB,SAAQ,MACN,iEACD;MACI;AACL,UAAQ,MACN,cACE,OAAO,KAAK,OAAO,CAAC,OACrB,2DACF;AAED,QAAM,eAAe,QAAQ;GAC3B,iBAAgB,cAAa;AAC3B,QAAI,QAAQ,GAAG,WAAW,UAAU,KAAK,CACvC;AAGF,YAAQ,GAAG,UAAU,UAAU,KAAK;;GAEtC,YAAW,SAAQ;AACjB,QAAI,cAAc,MAAM;KACtB,MAAM,WAAW,KAAK,KAAK,SAAS,EAAE;AACtC,SAAI,SAAS,SAAS,WAAW;AAC/B,UAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MACR,kBACE,KAAK,KACN,6CACF;AAGH,cAAQ,gBAAgB,KAAK,UAAU,SAAS,IAAI;OAClD,YAAY,SAAS;OACrB,SAAS,SAAS;OAClB,WAAW,kBAAkB,KAAK,KAAK;OACxC,CAAC;gBACO,SAAS,SAAS,QAC3B,SAAQ,cAAc,KAAK,UAAU,KAAK,MAAM;MAC9C,YAAY,SAAS;MACrB,SAAS,SAAS;MAClB,GAAI,SAAS,kBAAkB,EAAE;MAClC,CAAC;cACO,SAAS,SAAS,kBAAkB;AAC7C,UAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MACR,wBACE,KAAK,KACN,6CACF;AAGH,cAAQ,uBAAuB,KAAK,UAAU,SAAS,IAAI;OACzD,YAAY,SAAS;OACrB,SAAS,SAAS;OAClB,WAAW,kBAAkB,KAAK,KAAK;OACxC,CAAC;WAEF,SAAQ,SAAS,KAAK,UAAU,KAAK,MAAM,SAAS;UAGtD,SAAQ,GAAG,SAAS,KAAK,YAAY,KAAK,KAAK;;GAGpD,CAAC;;;;;;;;;;;;;;;;;;AAmBN,SAAgB,aACd,SACA,UACA,SACA;AAKA,QAAO,UAJM,WACX,oBAACA,UAAD;EAA2B;EAAU;EAAkB,EACxD,EAEsB,QAAQ"}
|
|
@@ -5,6 +5,7 @@ const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
|
5
5
|
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
6
6
|
let _alloy_js_core = require("@alloy-js/core");
|
|
7
7
|
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
8
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
8
9
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
9
10
|
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
10
11
|
|
|
@@ -26,15 +27,26 @@ function BuiltinFile(props) {
|
|
|
26
27
|
]);
|
|
27
28
|
const context = require_core_contexts_context.usePowerlinesSafe();
|
|
28
29
|
const path = (0, _alloy_js_core.computed)(() => (0, _stryke_path_replace.replacePath)(`${!(0, _stryke_type_checks_is_set.isSet)(tsx) ? id : (0, _stryke_path_replace.replaceExtension)(id)}${(0, _stryke_path_file_path_fns.hasFileExtension)(id) && !(0, _stryke_type_checks_is_set.isSet)(tsx) ? "" : tsx ? ".tsx" : ".ts"}`, context?.builtinsPath));
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_typescript_file.TypescriptFile, {
|
|
31
|
+
header: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_typescript_file.TypescriptFileHeader, {
|
|
32
|
+
header: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_tsdoc.TSDocModule, {
|
|
33
|
+
name: id,
|
|
34
|
+
children: description
|
|
35
|
+
}),
|
|
36
|
+
children: /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_typescript_components_typescript_file.TypescriptFileHeaderImports, {
|
|
37
|
+
imports,
|
|
38
|
+
builtinImports
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
meta: {
|
|
42
|
+
kind: "builtin",
|
|
43
|
+
extension: tsx ? "tsx" : "ts",
|
|
44
|
+
id: (0, _stryke_path_replace.replaceExtension)(id)
|
|
45
|
+
},
|
|
46
|
+
...rest,
|
|
47
|
+
path: path.value,
|
|
48
|
+
children
|
|
49
|
+
});
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
//#endregion
|
|
@@ -3,6 +3,7 @@ import { TSDocModule } from "./tsdoc.mjs";
|
|
|
3
3
|
import { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports } from "./typescript-file.mjs";
|
|
4
4
|
import { computed, splitProps } from "@alloy-js/core";
|
|
5
5
|
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
6
|
+
import { jsx } from "@alloy-js/core/jsx-runtime";
|
|
6
7
|
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
7
8
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
8
9
|
|
|
@@ -24,15 +25,26 @@ function BuiltinFile(props) {
|
|
|
24
25
|
]);
|
|
25
26
|
const context = usePowerlinesSafe();
|
|
26
27
|
const path = computed(() => replacePath(`${!isSet(tsx) ? id : replaceExtension(id)}${hasFileExtension(id) && !isSet(tsx) ? "" : tsx ? ".tsx" : ".ts"}`, context?.builtinsPath));
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
return /* @__PURE__ */ jsx(TypescriptFile, {
|
|
29
|
+
header: /* @__PURE__ */ jsx(TypescriptFileHeader, {
|
|
30
|
+
header: /* @__PURE__ */ jsx(TSDocModule, {
|
|
31
|
+
name: id,
|
|
32
|
+
children: description
|
|
33
|
+
}),
|
|
34
|
+
children: /* @__PURE__ */ jsx(TypescriptFileHeaderImports, {
|
|
35
|
+
imports,
|
|
36
|
+
builtinImports
|
|
37
|
+
})
|
|
38
|
+
}),
|
|
39
|
+
meta: {
|
|
40
|
+
kind: "builtin",
|
|
41
|
+
extension: tsx ? "tsx" : "ts",
|
|
42
|
+
id: replaceExtension(id)
|
|
43
|
+
},
|
|
44
|
+
...rest,
|
|
45
|
+
path: path.value,
|
|
46
|
+
children
|
|
47
|
+
});
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-file.mjs","names":[],"sources":["../../../src/typescript/components/builtin-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 { computed, splitProps } from \"@alloy-js/core\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport type { TSDocModuleProps } from \"./tsdoc\";\nimport { TSDocModule } from \"./tsdoc\";\nimport {\n TypescriptFile,\n TypescriptFileHeader,\n TypescriptFileHeaderImports,\n TypescriptFileProps\n} from \"./typescript-file\";\n\nexport type BuiltinFileProps = Omit<TypescriptFileProps, \"path\"> &\n Omit<TSDocModuleProps, \"name\"> & {\n /**\n * The runtime module identifier.\n *\n * @remarks\n * This value will be included after the \\`storm:\\` prefix in the import statement.\n */\n id: string;\n\n /**\n * The description for the builtin module.\n */\n description?: string;\n\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n };\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function BuiltinFile(props: BuiltinFileProps) {\n const [{ children, imports, builtinImports, id, description, tsx }, rest] =\n splitProps(props, [\n \"children\",\n \"imports\",\n \"builtinImports\",\n \"id\",\n \"description\",\n \"tsx\"\n ]);\n\n const context = usePowerlinesSafe();\n const path = computed(() =>\n replacePath(\n `${!isSet(tsx) ? id : replaceExtension(id)}${\n hasFileExtension(id) && !isSet(tsx) ? \"\" : tsx ? \".tsx\" : \".ts\"\n }`,\n context?.builtinsPath\n )\n );\n\n return (\n <TypescriptFile\n header={\n <TypescriptFileHeader\n header={<TSDocModule name={id}>{description}</TSDocModule>}>\n <TypescriptFileHeaderImports\n imports={imports}\n builtinImports={builtinImports}\n />\n </TypescriptFileHeader>\n }\n meta={{\n kind: \"builtin\",\n extension: tsx ? \"tsx\" : \"ts\",\n id: replaceExtension(id)\n }}\n {...rest}\n path={path.value}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtin-file.mjs","names":[],"sources":["../../../src/typescript/components/builtin-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 { computed, splitProps } from \"@alloy-js/core\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport type { TSDocModuleProps } from \"./tsdoc\";\nimport { TSDocModule } from \"./tsdoc\";\nimport {\n TypescriptFile,\n TypescriptFileHeader,\n TypescriptFileHeaderImports,\n TypescriptFileProps\n} from \"./typescript-file\";\n\nexport type BuiltinFileProps = Omit<TypescriptFileProps, \"path\"> &\n Omit<TSDocModuleProps, \"name\"> & {\n /**\n * The runtime module identifier.\n *\n * @remarks\n * This value will be included after the \\`storm:\\` prefix in the import statement.\n */\n id: string;\n\n /**\n * The description for the builtin module.\n */\n description?: string;\n\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n };\n\n/**\n * A base component representing a Powerlines generated Typescript source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function BuiltinFile(props: BuiltinFileProps) {\n const [{ children, imports, builtinImports, id, description, tsx }, rest] =\n splitProps(props, [\n \"children\",\n \"imports\",\n \"builtinImports\",\n \"id\",\n \"description\",\n \"tsx\"\n ]);\n\n const context = usePowerlinesSafe();\n const path = computed(() =>\n replacePath(\n `${!isSet(tsx) ? id : replaceExtension(id)}${\n hasFileExtension(id) && !isSet(tsx) ? \"\" : tsx ? \".tsx\" : \".ts\"\n }`,\n context?.builtinsPath\n )\n );\n\n return (\n <TypescriptFile\n header={\n <TypescriptFileHeader\n header={<TSDocModule name={id}>{description}</TSDocModule>}>\n <TypescriptFileHeaderImports\n imports={imports}\n builtinImports={builtinImports}\n />\n </TypescriptFileHeader>\n }\n meta={{\n kind: \"builtin\",\n extension: tsx ? \"tsx\" : \"ts\",\n id: replaceExtension(id)\n }}\n {...rest}\n path={path.value}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6DA,SAAgB,YAAY,OAAyB;CACnD,MAAM,CAAC,EAAE,UAAU,SAAS,gBAAgB,IAAI,aAAa,OAAO,QAClE,WAAW,OAAO;EAChB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEJ,MAAM,UAAU,mBAAmB;CACnC,MAAM,OAAO,eACX,YACE,GAAG,CAAC,MAAM,IAAI,GAAG,KAAK,iBAAiB,GAAG,GACxC,iBAAiB,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,KAAK,MAAM,SAAS,SAE5D,SAAS,aACV,CACF;AAED,QACE,oBAAC,gBAAD;EACE,QACE,oBAAC,sBAAD;GACE,QAAQ,oBAAC,aAAD;IAAa,MAAM;cAAK;IAA0B;aAC1D,oBAAC,6BAAD;IACW;IACO;IAChB;GACmB;EAEzB,MAAM;GACJ,MAAM;GACN,WAAW,MAAM,QAAQ;GACzB,IAAI,iBAAiB,GAAG;GACzB;EACD,GAAI;EACJ,MAAM,KAAK;EACV;EACc"}
|