@powerlines/plugin-alloy 0.26.75 → 0.26.77
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/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/core/components/index.cjs +12 -1
- package/dist/core/components/index.mjs +7 -1
- package/dist/core/components/infrastructure-file.cjs +48 -1
- package/dist/core/components/infrastructure-file.mjs +45 -1
- package/dist/core/components/infrastructure-file.mjs.map +1 -1
- package/dist/core/components/output.cjs +41 -1
- package/dist/core/components/output.mjs +39 -1
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +23 -1
- package/dist/core/components/single-line-comment.mjs +21 -1
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +64 -1
- package/dist/core/components/source-file.mjs +61 -1
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +20 -1
- package/dist/core/components/spacing.mjs +18 -1
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/core/contexts/context.cjs +41 -1
- package/dist/core/contexts/context.mjs +36 -1
- package/dist/core/contexts/context.mjs.map +1 -1
- package/dist/core/contexts/index.cjs +22 -1
- package/dist/core/contexts/index.mjs +5 -1
- package/dist/core/contexts/meta.cjs +41 -1
- package/dist/core/contexts/meta.mjs +36 -1
- package/dist/core/contexts/meta.mjs.map +1 -1
- package/dist/core/contexts/reflection.cjs +80 -1
- package/dist/core/contexts/reflection.mjs +70 -1
- package/dist/core/contexts/reflection.mjs.map +1 -1
- package/dist/core/helpers/code.cjs +34 -1
- package/dist/core/helpers/code.mjs +32 -1
- package/dist/core/helpers/code.mjs.map +1 -1
- package/dist/core/helpers/index.cjs +4 -1
- package/dist/core/helpers/index.mjs +3 -1
- package/dist/core/index.cjs +37 -1
- package/dist/core/index.mjs +14 -1
- package/dist/hcl/components/block-declaration.cjs +34 -1
- package/dist/hcl/components/block-declaration.mjs +32 -1
- package/dist/hcl/components/block-declaration.mjs.map +1 -1
- package/dist/hcl/components/hcl-file.cjs +83 -1
- package/dist/hcl/components/hcl-file.mjs +80 -1
- package/dist/hcl/components/hcl-file.mjs.map +1 -1
- package/dist/hcl/components/index.cjs +11 -1
- package/dist/hcl/components/index.mjs +6 -1
- package/dist/hcl/components/packer-file.cjs +29 -1
- package/dist/hcl/components/packer-file.mjs +27 -1
- package/dist/hcl/components/packer-file.mjs.map +1 -1
- package/dist/hcl/components/terraform-file.cjs +30 -1
- package/dist/hcl/components/terraform-file.mjs +28 -1
- package/dist/hcl/components/terraform-file.mjs.map +1 -1
- package/dist/hcl/index.cjs +12 -1
- package/dist/hcl/index.mjs +7 -1
- package/dist/helpers/capnp.cjs +245 -37
- package/dist/helpers/capnp.mjs +227 -37
- package/dist/helpers/capnp.mjs.map +1 -1
- package/dist/helpers/create-builtin.cjs +20 -1
- package/dist/helpers/create-builtin.mjs +18 -1
- package/dist/helpers/create-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +25 -1
- package/dist/helpers/index.mjs +6 -1
- package/dist/helpers/refkey.cjs +17 -1
- package/dist/helpers/refkey.mjs +15 -1
- package/dist/helpers/refkey.mjs.map +1 -1
- package/dist/helpers/typescript.cjs +43 -19
- package/dist/helpers/typescript.mjs +41 -19
- package/dist/helpers/typescript.mjs.map +1 -1
- package/dist/index.cjs +55 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +29 -1
- package/dist/markdown/components/front-matter.mjs +27 -1
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/heading.cjs +24 -1
- package/dist/markdown/components/heading.mjs +22 -1
- package/dist/markdown/components/heading.mjs.map +1 -1
- package/dist/markdown/components/index.cjs +13 -1
- package/dist/markdown/components/index.mjs +6 -1
- package/dist/markdown/components/markdown-file.cjs +135 -1
- package/dist/markdown/components/markdown-file.mjs +132 -1
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +102 -1
- package/dist/markdown/components/markdown-table.mjs +98 -1
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/markdown/contexts/index.cjs +7 -1
- package/dist/markdown/contexts/index.mjs +3 -1
- package/dist/markdown/contexts/markdown-table.cjs +38 -1
- package/dist/markdown/contexts/markdown-table.mjs +33 -1
- package/dist/markdown/contexts/markdown-table.mjs.map +1 -1
- package/dist/markdown/index.cjs +20 -1
- package/dist/markdown/index.mjs +9 -1
- package/dist/render.cjs +91 -1
- package/dist/render.mjs +88 -1
- package/dist/render.mjs.map +1 -1
- package/dist/types/components.cjs +9 -0
- package/dist/types/components.mjs +9 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/typescript/components/builtin-file.cjs +63 -1
- package/dist/typescript/components/builtin-file.mjs +61 -1
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +306 -1
- package/dist/typescript/components/class-declaration.mjs +299 -1
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +26 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +24 -1
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +43 -1
- package/dist/typescript/components/entry-file.mjs +40 -1
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/index.cjs +64 -1
- package/dist/typescript/components/index.mjs +15 -1
- package/dist/typescript/components/interface-declaration.cjs +239 -1
- package/dist/typescript/components/interface-declaration.mjs +234 -1
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +139 -1
- package/dist/typescript/components/object-declaration.mjs +136 -1
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +32 -1
- package/dist/typescript/components/property-name.mjs +30 -1
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.cjs +13 -3
- package/dist/typescript/components/record-expression.mjs +11 -3
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +331 -1
- package/dist/typescript/components/tsdoc-reflection.mjs +324 -1
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +497 -1
- package/dist/typescript/components/tsdoc.mjs +475 -1
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +39 -1
- package/dist/typescript/components/type-declaration.mjs +37 -1
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +83 -1
- package/dist/typescript/components/type-parameters.mjs +81 -1
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +221 -1
- package/dist/typescript/components/typescript-file.mjs +217 -1
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/index.cjs +4 -1
- package/dist/typescript/contexts/index.mjs +3 -1
- package/dist/typescript/contexts/lexical-scope.cjs +26 -1
- package/dist/typescript/contexts/lexical-scope.mjs +24 -1
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +24 -1
- package/dist/typescript/contexts/member-scope.mjs +22 -1
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.cjs +26 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs +24 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -1
- package/dist/typescript/helpers/index.cjs +6 -1
- package/dist/typescript/helpers/index.mjs +4 -1
- package/dist/typescript/helpers/utilities.cjs +15 -1
- package/dist/typescript/helpers/utilities.mjs +13 -1
- package/dist/typescript/helpers/utilities.mjs.map +1 -1
- package/dist/typescript/index.cjs +73 -1
- package/dist/typescript/index.mjs +21 -1
- package/dist/yaml/components/index.cjs +5 -1
- package/dist/yaml/components/index.mjs +3 -1
- package/dist/yaml/components/yaml-file.cjs +149 -1
- package/dist/yaml/components/yaml-file.mjs +146 -1
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/dist/yaml/index.cjs +6 -1
- package/dist/yaml/index.mjs +4 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-table.mjs","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createContext, createNamedContext, useContext } from \"@alloy-js/core\";\n\nexport interface MarkdownTableColumnContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n index: number;\n name: keyof T;\n align: \"left\" | \"right\" | \"center\";\n width: number;\n}\n\n/**\n * The Powerlines context used in template rendering.\n */\nexport const MarkdownTableColumnContext: ComponentContext<MarkdownTableColumnContextInterface> =\n createNamedContext<MarkdownTableColumnContextInterface>(\n \"MarkdownTableColumn\",\n {} as MarkdownTableColumnContextInterface\n );\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function useMarkdownTableColumn() {\n return useContext<MarkdownTableColumnContextInterface>(\n MarkdownTableColumnContext\n );\n}\n\nexport interface MarkdownTableContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n columns: MarkdownTableColumnContextInterface<T>[];\n data: T[];\n}\n\n/**\n * The Powerlines context used in template rendering.\n */\nexport const MarkdownTableContext: ComponentContext<MarkdownTableContextInterface> =\n createContext<MarkdownTableContextInterface>({\n columns: [],\n data: []\n });\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function useMarkdownTable() {\n return useContext<MarkdownTableContextInterface>(MarkdownTableContext);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-table.mjs","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createContext, createNamedContext, useContext } from \"@alloy-js/core\";\n\nexport interface MarkdownTableColumnContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n index: number;\n name: keyof T;\n align: \"left\" | \"right\" | \"center\";\n width: number;\n}\n\n/**\n * The Powerlines context used in template rendering.\n */\nexport const MarkdownTableColumnContext: ComponentContext<MarkdownTableColumnContextInterface> =\n createNamedContext<MarkdownTableColumnContextInterface>(\n \"MarkdownTableColumn\",\n {} as MarkdownTableColumnContextInterface\n );\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function useMarkdownTableColumn() {\n return useContext<MarkdownTableColumnContextInterface>(\n MarkdownTableColumnContext\n );\n}\n\nexport interface MarkdownTableContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n columns: MarkdownTableColumnContextInterface<T>[];\n data: T[];\n}\n\n/**\n * The Powerlines context used in template rendering.\n */\nexport const MarkdownTableContext: ComponentContext<MarkdownTableContextInterface> =\n createContext<MarkdownTableContextInterface>({\n columns: [],\n data: []\n });\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function useMarkdownTable() {\n return useContext<MarkdownTableContextInterface>(MarkdownTableContext);\n}\n"],"mappings":";;;;;;AAsBA,MAAY,6BAA6B,mBAAW,uBAAA,EAAA,CAAA;;;;;;;AAQlD,QAAA,WAAA,2BAAA;;;;;AAKF,MAAK,uBAAoB,cAAA;CACvB,SAAQ,EAAA;CACR,MAAC,EAAA;;;;;;;AAQH,SAAS,mBAAW;AAClB,QAAE,WAAA,qBAAA"}
|
package/dist/markdown/index.cjs
CHANGED
|
@@ -1 +1,20 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_markdown_components_front_matter = require('./components/front-matter.cjs');
|
|
3
|
+
const require_markdown_components_heading = require('./components/heading.cjs');
|
|
4
|
+
const require_markdown_components_markdown_file = require('./components/markdown-file.cjs');
|
|
5
|
+
const require_markdown_contexts_markdown_table = require('./contexts/markdown-table.cjs');
|
|
6
|
+
const require_markdown_components_markdown_table = require('./components/markdown-table.cjs');
|
|
7
|
+
require('./components/index.cjs');
|
|
8
|
+
require('./contexts/index.cjs');
|
|
9
|
+
|
|
10
|
+
exports.FrontMatter = require_markdown_components_front_matter.FrontMatter;
|
|
11
|
+
exports.Heading = require_markdown_components_heading.Heading;
|
|
12
|
+
exports.MarkdownFile = require_markdown_components_markdown_file.MarkdownFile;
|
|
13
|
+
exports.MarkdownFileHeader = require_markdown_components_markdown_file.MarkdownFileHeader;
|
|
14
|
+
exports.MarkdownTable = require_markdown_components_markdown_table.MarkdownTable;
|
|
15
|
+
exports.MarkdownTableColumn = require_markdown_components_markdown_table.MarkdownTableColumn;
|
|
16
|
+
exports.MarkdownTableColumnContext = require_markdown_contexts_markdown_table.MarkdownTableColumnContext;
|
|
17
|
+
exports.MarkdownTableColumnHeader = require_markdown_components_markdown_table.MarkdownTableColumnHeader;
|
|
18
|
+
exports.MarkdownTableContext = require_markdown_contexts_markdown_table.MarkdownTableContext;
|
|
19
|
+
exports.useMarkdownTable = require_markdown_contexts_markdown_table.useMarkdownTable;
|
|
20
|
+
exports.useMarkdownTableColumn = require_markdown_contexts_markdown_table.useMarkdownTableColumn;
|
package/dist/markdown/index.mjs
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FrontMatter } from "./components/front-matter.mjs";
|
|
2
|
+
import { Heading } from "./components/heading.mjs";
|
|
3
|
+
import { MarkdownFile, MarkdownFileHeader } from "./components/markdown-file.mjs";
|
|
4
|
+
import { MarkdownTableColumnContext, MarkdownTableContext, useMarkdownTable, useMarkdownTableColumn } from "./contexts/markdown-table.mjs";
|
|
5
|
+
import { MarkdownTable, MarkdownTableColumn, MarkdownTableColumnHeader } from "./components/markdown-table.mjs";
|
|
6
|
+
import "./components/index.mjs";
|
|
7
|
+
import "./contexts/index.mjs";
|
|
8
|
+
|
|
9
|
+
export { FrontMatter, Heading, MarkdownFile, MarkdownFileHeader, MarkdownTable, MarkdownTableColumn, MarkdownTableColumnContext, MarkdownTableColumnHeader, MarkdownTableContext, useMarkdownTable, useMarkdownTableColumn };
|
package/dist/render.cjs
CHANGED
|
@@ -1 +1,91 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_core_components_output = require('./core/components/output.cjs');
|
|
4
|
+
require('./core/index.cjs');
|
|
5
|
+
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
6
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
|
|
9
|
+
//#region src/render.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { render } from "@powerlines/plugin-alloy/render";
|
|
16
|
+
*
|
|
17
|
+
* await render(context, <> ... </>);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param context - The Powerlines plugin context.
|
|
21
|
+
* @param children - The children components to render.
|
|
22
|
+
* @returns A promise that resolves when rendering is complete.
|
|
23
|
+
*/
|
|
24
|
+
async function render(context, children) {
|
|
25
|
+
const meta = {};
|
|
26
|
+
const output = await (0, _alloy_js_core.renderAsync)((0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_output.Output, {
|
|
27
|
+
context,
|
|
28
|
+
meta,
|
|
29
|
+
children
|
|
30
|
+
}));
|
|
31
|
+
if (!Object.keys(output).length) context.debug("No output files were rendered by Alloy-js component templates.");
|
|
32
|
+
else {
|
|
33
|
+
context.debug(`Processing ${Object.keys(output).length} rendered output files from Alloy-js component templates.`);
|
|
34
|
+
await (0, _alloy_js_core.traverseOutput)(output, {
|
|
35
|
+
visitDirectory: (directory) => {
|
|
36
|
+
if (context.fs.existsSync(directory.path)) return;
|
|
37
|
+
context.fs.mkdirSync(directory.path);
|
|
38
|
+
},
|
|
39
|
+
visitFile: (file) => {
|
|
40
|
+
if ("contents" in file) {
|
|
41
|
+
const metadata = meta[file.path] ?? {};
|
|
42
|
+
if (metadata.kind === "builtin") {
|
|
43
|
+
if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
|
|
44
|
+
context.emitBuiltinSync(file.contents, metadata.id, {
|
|
45
|
+
skipFormat: metadata.skipFormat,
|
|
46
|
+
storage: metadata.storage,
|
|
47
|
+
extension: (0, _stryke_path_file_path_fns.findFileExtension)(file.path)
|
|
48
|
+
});
|
|
49
|
+
} else if (metadata.kind === "entry") context.emitEntrySync(file.contents, file.path, {
|
|
50
|
+
skipFormat: metadata.skipFormat,
|
|
51
|
+
storage: metadata.storage,
|
|
52
|
+
...metadata.typeDefinition ?? {}
|
|
53
|
+
});
|
|
54
|
+
else if (metadata.kind === "infrastructure") {
|
|
55
|
+
if (!metadata.id) throw new Error(`Infrastructure file "${file.path}" is missing its ID in the render metadata.`);
|
|
56
|
+
context.emitInfrastructureSync(file.contents, metadata.id, {
|
|
57
|
+
skipFormat: metadata.skipFormat,
|
|
58
|
+
storage: metadata.storage,
|
|
59
|
+
extension: (0, _stryke_path_file_path_fns.findFileExtension)(file.path)
|
|
60
|
+
});
|
|
61
|
+
} else context.emitSync(file.contents, file.path, metadata);
|
|
62
|
+
} else context.fs.copySync(file.sourcePath, file.path);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* import { renderString } from "@powerlines/plugin-alloy/render";
|
|
73
|
+
*
|
|
74
|
+
* const output = await renderString(context, <> ... </>);
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param context - The Powerlines plugin context.
|
|
78
|
+
* @param children - The children components to render.
|
|
79
|
+
* @param options - Optional print tree options.
|
|
80
|
+
* @returns The rendered output as a string.
|
|
81
|
+
*/
|
|
82
|
+
function renderString(context, children, options) {
|
|
83
|
+
return (0, _alloy_js_core.printTree)((0, _alloy_js_core.renderTree)((0, _alloy_js_core_jsx_runtime.createComponent)(require_core_components_output.Output, {
|
|
84
|
+
context,
|
|
85
|
+
children
|
|
86
|
+
})), options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.render = render;
|
|
91
|
+
exports.renderString = renderString;
|
package/dist/render.mjs
CHANGED
|
@@ -1,2 +1,89 @@
|
|
|
1
|
-
import{Output as
|
|
1
|
+
import { Output as Output$1 } from "./core/components/output.mjs";
|
|
2
|
+
import "./core/index.mjs";
|
|
3
|
+
import { findFileExtension } from "@stryke/path/file-path-fns";
|
|
4
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { printTree, renderAsync, renderTree, traverseOutput } from "@alloy-js/core";
|
|
6
|
+
|
|
7
|
+
//#region src/render.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context, and write any saved content to the file system.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { render } from "@powerlines/plugin-alloy/render";
|
|
14
|
+
*
|
|
15
|
+
* await render(context, <> ... </>);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param context - The Powerlines plugin context.
|
|
19
|
+
* @param children - The children components to render.
|
|
20
|
+
* @returns A promise that resolves when rendering is complete.
|
|
21
|
+
*/
|
|
22
|
+
async function render(context, children) {
|
|
23
|
+
const meta = {};
|
|
24
|
+
const output = await renderAsync(createComponent(Output$1, {
|
|
25
|
+
context,
|
|
26
|
+
meta,
|
|
27
|
+
children
|
|
28
|
+
}));
|
|
29
|
+
if (!Object.keys(output).length) context.debug("No output files were rendered by Alloy-js component templates.");
|
|
30
|
+
else {
|
|
31
|
+
context.debug(`Processing ${Object.keys(output).length} rendered output files from Alloy-js component templates.`);
|
|
32
|
+
await traverseOutput(output, {
|
|
33
|
+
visitDirectory: (directory) => {
|
|
34
|
+
if (context.fs.existsSync(directory.path)) return;
|
|
35
|
+
context.fs.mkdirSync(directory.path);
|
|
36
|
+
},
|
|
37
|
+
visitFile: (file) => {
|
|
38
|
+
if ("contents" in file) {
|
|
39
|
+
const metadata = meta[file.path] ?? {};
|
|
40
|
+
if (metadata.kind === "builtin") {
|
|
41
|
+
if (!metadata.id) throw new Error(`Built-in file "${file.path}" is missing its ID in the render metadata.`);
|
|
42
|
+
context.emitBuiltinSync(file.contents, metadata.id, {
|
|
43
|
+
skipFormat: metadata.skipFormat,
|
|
44
|
+
storage: metadata.storage,
|
|
45
|
+
extension: findFileExtension(file.path)
|
|
46
|
+
});
|
|
47
|
+
} else if (metadata.kind === "entry") context.emitEntrySync(file.contents, file.path, {
|
|
48
|
+
skipFormat: metadata.skipFormat,
|
|
49
|
+
storage: metadata.storage,
|
|
50
|
+
...metadata.typeDefinition ?? {}
|
|
51
|
+
});
|
|
52
|
+
else if (metadata.kind === "infrastructure") {
|
|
53
|
+
if (!metadata.id) throw new Error(`Infrastructure file "${file.path}" is missing its ID in the render metadata.`);
|
|
54
|
+
context.emitInfrastructureSync(file.contents, metadata.id, {
|
|
55
|
+
skipFormat: metadata.skipFormat,
|
|
56
|
+
storage: metadata.storage,
|
|
57
|
+
extension: findFileExtension(file.path)
|
|
58
|
+
});
|
|
59
|
+
} else context.emitSync(file.contents, file.path, metadata);
|
|
60
|
+
} else context.fs.copySync(file.sourcePath, file.path);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A function to render children components within the [Alloy](https://alloy-framework.github.io) context and return the rendered output as a string.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { renderString } from "@powerlines/plugin-alloy/render";
|
|
71
|
+
*
|
|
72
|
+
* const output = await renderString(context, <> ... </>);
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @param context - The Powerlines plugin context.
|
|
76
|
+
* @param children - The children components to render.
|
|
77
|
+
* @param options - Optional print tree options.
|
|
78
|
+
* @returns The rendered output as a string.
|
|
79
|
+
*/
|
|
80
|
+
function renderString(context, children, options) {
|
|
81
|
+
return printTree(renderTree(createComponent(Output$1, {
|
|
82
|
+
context,
|
|
83
|
+
children
|
|
84
|
+
})), options);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { render, renderString };
|
|
2
89
|
//# sourceMappingURL=render.mjs.map
|
package/dist/render.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.mjs","names":[],"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":[],"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":";;;;;;;;;;;;;;;;;;;;;AAsCA,eAAK,OAAA,SAAA,UAAA;CACJ,MAAA,OAAA,EAAA;CACC,MAAE,SAAa,MAAM,YAAY,gBAAc,UAAA;EACvC;EACN;EACF;EACF,CAAA,CAAA;AACE,KAAA,CAAA,OAAS,KAAQ,OAAA,CAAA,OACjB,SAAU,MAAA,iEAAA;MACV;AACA,UAAU,MAAM,cAAU,OAAQ,KAAQ,OAAC,CAAA,OAAA,2DAAA;AAC3C,QAAM,eAAe,QAAA;GAClB,iBAAiB,cAAS;AACxB,QAAA,QAAQ,GAAA,WAAA,UAAA,KAAA,CACT;;;GAIF,YAAa,SAAA;AACV,QAAG,cAAa,MAAK;KACvB,MAAA,WAAA,KAAA,KAAA,SAAA,EAAA;AACI,SAAA,SAAA,SAAA,WAAA;AACG,UAAA,CAAK,SAAA,GACV,OAAY,IAAA,MAAA,kBAAA,KAAA,KAAA,6CAAA;AAEX,cAAS,gBAAkB,KAAM,UAAG,SAAU,IAAU;OAC3D,YAAA,SAAA;;OAEK,WAAe,kBAAQ,KAAA,KAAA;OAC3B,CAAA;gBACc,SAAG,SAAW,QACxB,SAAM,cAAA,KAAA,UAAA,KAAA,MAAA;MACR,YAAA,SAAA;;MAEA,GAAU,SAAC,kBAAyB,EAAA;MACrC,CAAA;cACc,SAAI,SAAA,kBAAA;AACb,UAAC,CAAA,SAAa,GAChB,OAAM,IAAQ,MAAG,wBAAqB,KAAA,KAAA,6CAAA;AAEpC,cAAK,uBAAa,KAAA,UAAA,SAAA,IAAA;OAChB,YAAU,SAAK;OACf,SAAS,SAAS;OAClB,WAAS,kBAAA,KAAA,KAAA;OACV,CAAC;WAEF,SAAA,SAAA,KAAA,UAAA,KAAA,MAAA,SAAA;UAGF,SAAI,GAAA,SAAY,KAAS,YAAU,KAAA,KAAA;;GAGxC,CAAC;;;;;;;;;;;;;;;;;;AAmBN,SAAc,aAAW,SAAA,UAAuB,SAAI;AAKlD,QAAO,UAJK,WAAA,gBAAA,UAAA;EACF;EACA;EACT,CAAC,CACW,EAAA,QAAA"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/types/components.ts
|
|
2
|
+
/**
|
|
3
|
+
* A type that represents the props of a component that can have children.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A type that requires the `children` prop in a component.
|
|
7
|
+
*/
|
|
8
|
+
//#endregion
|
|
9
|
+
export { };
|
|
2
10
|
//# sourceMappingURL=components.mjs.map
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
|
@@ -1 +1,63 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_core_contexts_context = require('../../core/contexts/context.cjs');
|
|
4
|
+
const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
5
|
+
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
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");
|
|
8
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
9
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
10
|
+
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
11
|
+
|
|
12
|
+
//#region src/typescript/components/builtin-file.tsx
|
|
13
|
+
/**
|
|
14
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The properties for the source file.
|
|
17
|
+
* @returns The rendered source file component.
|
|
18
|
+
*/
|
|
19
|
+
function BuiltinFile(props) {
|
|
20
|
+
const [{ children, imports, builtinImports, id, description, tsx }, rest] = (0, _alloy_js_core.splitProps)(props, [
|
|
21
|
+
"children",
|
|
22
|
+
"imports",
|
|
23
|
+
"builtinImports",
|
|
24
|
+
"id",
|
|
25
|
+
"description",
|
|
26
|
+
"tsx"
|
|
27
|
+
]);
|
|
28
|
+
const context = require_core_contexts_context.usePowerlinesSafe();
|
|
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));
|
|
30
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
31
|
+
get header() {
|
|
32
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFileHeader, {
|
|
33
|
+
get header() {
|
|
34
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDocModule, {
|
|
35
|
+
name: id,
|
|
36
|
+
children: description
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
get children() {
|
|
40
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFileHeaderImports, {
|
|
41
|
+
imports,
|
|
42
|
+
builtinImports
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
get meta() {
|
|
48
|
+
return {
|
|
49
|
+
kind: "builtin",
|
|
50
|
+
extension: tsx ? "tsx" : "ts",
|
|
51
|
+
id: (0, _stryke_path_replace.replaceExtension)(id)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, rest, {
|
|
55
|
+
get path() {
|
|
56
|
+
return path.value;
|
|
57
|
+
},
|
|
58
|
+
children
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.BuiltinFile = BuiltinFile;
|
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
import{usePowerlinesSafe
|
|
1
|
+
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
|
+
import { TSDocModule } from "./tsdoc.mjs";
|
|
3
|
+
import { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports } from "./typescript-file.mjs";
|
|
4
|
+
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
5
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
6
|
+
import { computed, splitProps } from "@alloy-js/core";
|
|
7
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
8
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
9
|
+
|
|
10
|
+
//#region src/typescript/components/builtin-file.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
13
|
+
*
|
|
14
|
+
* @param props - The properties for the source file.
|
|
15
|
+
* @returns The rendered source file component.
|
|
16
|
+
*/
|
|
17
|
+
function BuiltinFile(props) {
|
|
18
|
+
const [{ children, imports, builtinImports, id, description, tsx }, rest] = splitProps(props, [
|
|
19
|
+
"children",
|
|
20
|
+
"imports",
|
|
21
|
+
"builtinImports",
|
|
22
|
+
"id",
|
|
23
|
+
"description",
|
|
24
|
+
"tsx"
|
|
25
|
+
]);
|
|
26
|
+
const context = usePowerlinesSafe();
|
|
27
|
+
const path = computed(() => replacePath(`${!isSet(tsx) ? id : replaceExtension(id)}${hasFileExtension(id) && !isSet(tsx) ? "" : tsx ? ".tsx" : ".ts"}`, context?.builtinsPath));
|
|
28
|
+
return createComponent(TypescriptFile, mergeProps({
|
|
29
|
+
get header() {
|
|
30
|
+
return createComponent(TypescriptFileHeader, {
|
|
31
|
+
get header() {
|
|
32
|
+
return createComponent(TSDocModule, {
|
|
33
|
+
name: id,
|
|
34
|
+
children: description
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
get children() {
|
|
38
|
+
return createComponent(TypescriptFileHeaderImports, {
|
|
39
|
+
imports,
|
|
40
|
+
builtinImports
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
get meta() {
|
|
46
|
+
return {
|
|
47
|
+
kind: "builtin",
|
|
48
|
+
extension: tsx ? "tsx" : "ts",
|
|
49
|
+
id: replaceExtension(id)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, rest, {
|
|
53
|
+
get path() {
|
|
54
|
+
return path.value;
|
|
55
|
+
},
|
|
56
|
+
children
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { BuiltinFile };
|
|
2
62
|
//# sourceMappingURL=builtin-file.mjs.map
|
|
@@ -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":";;;;;;;;;;;;;;;;AAgCA,SAAY,YAAgB,OAAO;CACjC,MAAK,CAAA,EACH,UACA,SACA,gBACA,IACA,aACA,OACA,QAAI,WAAM,OAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA;;CAEZ,MAAI,OAAA,eAAA,YAAA,GAAA,CAAA,MAAA,IAAA,GAAA,KAAA,iBAAA,GAAA,GAAA,iBAAA,GAAA,IAAA,CAAA,MAAA,IAAA,GAAA,KAAA,MAAA,SAAA,SAAA,SAAA,aAAA,CAAA;AACJ,QAAK,gBAAoB,gBAAY,WAAM;EACzC,IAAE,SAAA;AACF,UAAA,gBAAoB,sBAAA;;AAElB,YAAA,gBAAA,aAAA;MACC,MAAW;MACb,UAAA;MACG,CAAA;;IAEA,IAAE,WAAO;AACd,YAAA,gBAAA,6BAAA;;MAED;MACQ,CAAA;;IAEN,CAAA;;EAEF,IAAA,OAAA;AACI,UAAC;IACC,MAAG;IACP,WAAW,MAAO,QAAA;IACf,IAAA,iBAAS,GAAA;IACT;;EAEJ,EAAE,MAAK;EACN,IAAG,OAAA;AACD,UAAI,KAAA;;;EAGR,CAAA,CAAA"}
|