@powerlines/plugin-alloy 0.23.19 → 0.23.21
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.d.cts +1 -1
- package/dist/core/components/output.d.mts +1 -1
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.d.mts +2 -2
- package/dist/core/components/source-file.d.cts +3 -3
- package/dist/core/components/source-file.d.cts.map +1 -1
- package/dist/core/components/source-file.d.mts +1 -1
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.d.cts +2 -2
- package/dist/core/components/spacing.d.cts.map +1 -1
- package/dist/core/contexts/context.d.cts +1 -1
- package/dist/core/contexts/context.d.mts +1 -1
- package/dist/core/contexts/context.mjs.map +1 -1
- package/dist/core/contexts/meta.d.cts +1 -1
- package/dist/core/contexts/meta.d.mts +1 -1
- package/dist/core/contexts/meta.mjs.map +1 -1
- package/dist/helpers/capnp.cjs +3 -3
- package/dist/helpers/capnp.d.cts +1 -1
- package/dist/helpers/capnp.d.mts +1 -1
- package/dist/helpers/capnp.mjs +2 -2
- package/dist/helpers/capnp.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +6 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.d.cts +2 -2
- package/dist/markdown/components/markdown-file.d.cts +3 -3
- package/dist/markdown/components/markdown-file.d.mts +3 -3
- package/dist/markdown/contexts/markdown-table.d.cts.map +1 -1
- package/dist/markdown/contexts/markdown-table.d.mts.map +1 -1
- package/dist/render.cjs +4 -3
- package/dist/render.d.cts +1 -1
- package/dist/render.d.cts.map +1 -1
- package/dist/render.d.mts +1 -1
- package/dist/render.d.mts.map +1 -1
- package/dist/render.mjs +2 -1
- package/dist/render.mjs.map +1 -1
- package/dist/types/components.d.cts +1 -2
- package/dist/types/components.d.cts.map +1 -1
- package/dist/types/components.d.mts +1 -2
- package/dist/types/components.d.mts.map +1 -1
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.d.mts +1 -1
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.cts +2 -2
- package/dist/typescript/components/dynamic-import-statement.d.mts +2 -2
- package/dist/typescript/components/entry-file.d.cts +3 -3
- package/dist/typescript/components/entry-file.d.mts +3 -3
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.d.cts +2 -2
- package/dist/typescript/components/object-declaration.d.cts +3 -3
- package/dist/typescript/components/object-declaration.d.mts +3 -3
- package/dist/typescript/components/property-name.d.cts +2 -2
- package/dist/typescript/components/property-name.d.mts +2 -2
- package/dist/typescript/components/tsdoc-reflection.d.cts +4 -4
- package/dist/typescript/components/tsdoc-reflection.d.cts.map +1 -1
- package/dist/typescript/components/type-declaration.d.cts +2 -2
- package/dist/typescript/components/type-declaration.d.mts +2 -2
- package/dist/typescript/components/type-declaration.d.mts.map +1 -1
- package/dist/typescript/contexts/lexical-scope.d.cts +2 -2
- package/dist/typescript/contexts/lexical-scope.d.mts +2 -2
- package/dist/typescript/contexts/lexical-scope.d.mts.map +1 -1
- package/package.json +9 -9
|
@@ -2,7 +2,7 @@ import { MetaItem } from "../contexts/meta.cjs";
|
|
|
2
2
|
import "../contexts/index.cjs";
|
|
3
3
|
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
4
4
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
5
|
-
import { PluginContext } from "powerlines/types
|
|
5
|
+
import { PluginContext } from "@powerlines/core/types";
|
|
6
6
|
|
|
7
7
|
//#region src/core/components/output.d.ts
|
|
8
8
|
interface OutputProps<TContext extends PluginContext = PluginContext> extends Omit<OutputProps$1, "basePath"> {
|
|
@@ -2,7 +2,7 @@ import { MetaItem } from "../contexts/meta.mjs";
|
|
|
2
2
|
import "../contexts/index.mjs";
|
|
3
3
|
import * as _alloy_js_core1 from "@alloy-js/core";
|
|
4
4
|
import { OutputProps as OutputProps$1 } from "@alloy-js/core";
|
|
5
|
-
import { PluginContext } from "powerlines/types
|
|
5
|
+
import { PluginContext } from "@powerlines/core/types";
|
|
6
6
|
|
|
7
7
|
//#region src/core/components/output.d.ts
|
|
8
8
|
interface OutputProps<TContext extends PluginContext = PluginContext> extends Omit<OutputProps$1, "basePath"> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.mjs","names":["computed","Output","OutputExternal","splitProps","MetaContext","PowerlinesContext","props","children","context","meta","rest","contextRef","_$createComponent","Provider","value","_$mergeProps","basePath","workspaceConfig","workspaceRoot"],"sources":["../../../src/core/components/output.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 type { OutputProps as OutputPropsExternal } from \"@alloy-js/core\";\nimport { computed, Output as OutputExternal, splitProps } from \"@alloy-js/core\";\nimport type { PluginContext } from \"powerlines/types
|
|
1
|
+
{"version":3,"file":"output.mjs","names":["computed","Output","OutputExternal","splitProps","MetaContext","PowerlinesContext","props","children","context","meta","rest","contextRef","_$createComponent","Provider","value","_$mergeProps","basePath","workspaceConfig","workspaceRoot"],"sources":["../../../src/core/components/output.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 type { OutputProps as OutputPropsExternal } from \"@alloy-js/core\";\nimport { computed, Output as OutputExternal, splitProps } from \"@alloy-js/core\";\nimport type { PluginContext } from \"@powerlines/core/types\";\nimport { MetaContext, MetaItem } from \"../contexts\";\nimport { PowerlinesContext } from \"../contexts/context\";\n\nexport interface OutputProps<\n TContext extends PluginContext = PluginContext\n> extends Omit<OutputPropsExternal, \"basePath\"> {\n /**\n * The current Powerlines process context.\n */\n context: TContext;\n\n /**\n * The file metadata collected during rendering.\n */\n meta?: Record<string, MetaItem>;\n}\n\n/**\n * Output component for rendering the Powerlines plugin's output files via templates.\n */\nexport function Output<TContext extends PluginContext = PluginContext>(\n props: OutputProps<TContext>\n) {\n const [{ children, context, meta = {} }, rest] = splitProps(props, [\n \"children\",\n \"context\",\n \"meta\"\n ]);\n\n const contextRef = computed(() => context);\n\n return (\n <MetaContext.Provider value={meta}>\n <PowerlinesContext.Provider value={contextRef.value}>\n <OutputExternal\n {...rest}\n basePath={contextRef.value.workspaceConfig.workspaceRoot}>\n {children}\n </OutputExternal>\n </PowerlinesContext.Provider>\n </MetaContext.Provider>\n );\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core4 from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/core/components/single-line-comment.d.ts
|
|
5
5
|
type SingleLineCommentVariant = "double-slash" | "triple-slash" | "slash-star" | "slash-star-star" | "markdown";
|
|
@@ -15,7 +15,7 @@ interface SingleLineCommentProps extends ComponentProps {
|
|
|
15
15
|
* A single line comment block. The children are rendered as a prose element, which means that they
|
|
16
16
|
* are broken into multiple lines
|
|
17
17
|
*/
|
|
18
|
-
declare function SingleLineComment(props: SingleLineCommentProps):
|
|
18
|
+
declare function SingleLineComment(props: SingleLineCommentProps): _alloy_js_core4.Children;
|
|
19
19
|
declare type __ΩSingleLineCommentVariant = any[];
|
|
20
20
|
declare type __ΩSingleLineCommentProps = any[];
|
|
21
21
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core9 from "@alloy-js/core";
|
|
3
3
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
4
|
-
import { StoragePreset } from "powerlines
|
|
4
|
+
import { StoragePreset } from "powerlines";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
7
7
|
type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
@@ -26,7 +26,7 @@ type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
|
26
26
|
* @param props - The properties for the source file.
|
|
27
27
|
* @returns The rendered source file component.
|
|
28
28
|
*/
|
|
29
|
-
declare function SourceFile(props: SourceFileProps):
|
|
29
|
+
declare function SourceFile(props: SourceFileProps): _alloy_js_core9.Children;
|
|
30
30
|
declare type __ΩSourceFileProps = any[];
|
|
31
31
|
//#endregion
|
|
32
32
|
export { SourceFile, SourceFileProps, __ΩSourceFileProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.d.cts","names":[],"sources":["../../../src/core/components/source-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkCY,eAAA,GAAkB,oBAC5B;;;AADF;;;;EAgBW,OAAA,CAAA,EARG,aAQH;EAAM;AASjB;;;;;SATW;;;;;;;;iBASK,UAAA,QAAkB,kBAAe,
|
|
1
|
+
{"version":3,"file":"source-file.d.cts","names":[],"sources":["../../../src/core/components/source-file.tsx"],"sourcesContent":[],"mappings":";;;;;;KAkCY,eAAA,GAAkB,oBAC5B;;;AADF;;;;EAgBW,OAAA,CAAA,EARG,aAQH;EAAM;AASjB;;;;;SATW;;;;;;;;iBASK,UAAA,QAAkB,kBAAe,eAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
2
|
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
3
3
|
import { SourceFileProps as SourceFileProps$1 } from "@alloy-js/core";
|
|
4
|
-
import { StoragePreset } from "powerlines
|
|
4
|
+
import { StoragePreset } from "powerlines";
|
|
5
5
|
|
|
6
6
|
//#region src/core/components/source-file.d.ts
|
|
7
7
|
type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.mjs","names":["getContext","Show","SourceDirectoryContext","SourceFileContext","splitProps","useContext","useFormatOptions","appendPath","defu","useMeta","SourceFile","props","children","meta","path","header","storage","filetype","reference","metadata","parentDirectory","sourceFile","addContent","printOptions","printWidth","tabWidth","useTabs","insertFinalNewLine","nodeContext","_$createComponent","Provider","value","when","undefined","_$createIntrinsic"],"sources":["../../../src/core/components/source-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 {\n getContext,\n Show,\n SourceDirectoryContext,\n SourceFileContext,\n SourceFileProps as SourceFilePropsExternal,\n splitProps,\n useContext,\n useFormatOptions\n} from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport defu from \"defu\";\nimport type { StoragePreset } from \"powerlines
|
|
1
|
+
{"version":3,"file":"source-file.mjs","names":["getContext","Show","SourceDirectoryContext","SourceFileContext","splitProps","useContext","useFormatOptions","appendPath","defu","useMeta","SourceFile","props","children","meta","path","header","storage","filetype","reference","metadata","parentDirectory","sourceFile","addContent","printOptions","printWidth","tabWidth","useTabs","insertFinalNewLine","nodeContext","_$createComponent","Provider","value","when","undefined","_$createIntrinsic"],"sources":["../../../src/core/components/source-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 {\n getContext,\n Show,\n SourceDirectoryContext,\n SourceFileContext,\n SourceFileProps as SourceFilePropsExternal,\n splitProps,\n useContext,\n useFormatOptions\n} from \"@alloy-js/core\";\nimport { appendPath } from \"@stryke/path/append\";\nimport defu from \"defu\";\nimport type { StoragePreset } from \"powerlines\";\nimport { ComponentProps } from \"../../types/components\";\nimport { useMeta } from \"../contexts/meta\";\n\nexport type SourceFileProps = SourceFilePropsExternal &\n ComponentProps & {\n /**\n * The storage preset for the output files.\n *\n * @remarks\n * If not specified, the output mode will be determined by the provided `output.mode` value.\n */\n storage?: StoragePreset;\n\n /**\n * The metadata associated with the source file.\n *\n * @remarks\n * The values stored in the metadata will be available in the rendering context.\n */\n meta?: Record<string, any>;\n };\n\n/**\n * A base component representing a Powerlines generated source file.\n *\n * @param props - The properties for the source file.\n * @returns The rendered source file component.\n */\nexport function SourceFile(props: SourceFileProps) {\n const [{ children, meta, path, header, storage, filetype, reference }] =\n splitProps(props, [\n \"children\",\n \"meta\",\n \"path\",\n \"header\",\n \"storage\",\n \"filetype\",\n \"reference\"\n ]);\n\n const metadata = useMeta();\n const parentDirectory = useContext(SourceDirectoryContext)!;\n\n const sourceFile: SourceFileContext = {\n path: appendPath(path, parentDirectory.path),\n filetype,\n reference\n };\n parentDirectory?.addContent(sourceFile);\n\n const printOptions = useFormatOptions({\n printWidth: props.printWidth,\n tabWidth: props.tabWidth,\n useTabs: props.useTabs,\n insertFinalNewLine: props.insertFinalNewLine\n });\n\n const nodeContext = getContext()!;\n nodeContext.meta = defu(\n {\n sourceFile,\n printOptions\n },\n meta ?? {}\n );\n\n if (metadata) {\n metadata[sourceFile.path] = {\n storage,\n ...(meta ?? {})\n };\n }\n\n return (\n <SourceFileContext.Provider value={sourceFile}>\n <Show when={header !== undefined}>\n {header}\n <hbr />\n </Show>\n {children}\n </SourceFileContext.Provider>\n );\n}\n"],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core7 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/core/components/spacing.d.ts
|
|
4
4
|
interface SpacingProps {
|
|
@@ -17,7 +17,7 @@ interface SpacingProps {
|
|
|
17
17
|
*/
|
|
18
18
|
declare function Spacing({
|
|
19
19
|
scale
|
|
20
|
-
}: SpacingProps):
|
|
20
|
+
}: SpacingProps): _alloy_js_core7.Children;
|
|
21
21
|
declare type __ΩSpacingProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { Spacing, SpacingProps, __ΩSpacingProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.d.cts","names":[],"sources":["../../../src/core/components/spacing.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,YAAA;;;AAAjB;AAeA;;;;;;;;;;iBAAgB,OAAA;;GAAuB,eAAY,
|
|
1
|
+
{"version":3,"file":"spacing.d.cts","names":[],"sources":["../../../src/core/components/spacing.tsx"],"sourcesContent":[],"mappings":";;;UAoBiB,YAAA;;;AAAjB;AAeA;;;;;;;;;;iBAAgB,OAAA;;GAAuB,eAAY,eAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.mjs","names":["createNamedContext","useContext","PowerlinesContext","usePowerlinesContext","usePowerlinesSafe","powerlines","undefined","usePowerlines","Error"],"sources":["../../../src/core/contexts/context.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 {\n ComponentContext,\n createNamedContext,\n useContext\n} from \"@alloy-js/core\";\nimport type { PluginContext } from \"powerlines
|
|
1
|
+
{"version":3,"file":"context.mjs","names":["createNamedContext","useContext","PowerlinesContext","usePowerlinesContext","usePowerlinesSafe","powerlines","undefined","usePowerlines","Error"],"sources":["../../../src/core/contexts/context.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 {\n ComponentContext,\n createNamedContext,\n useContext\n} from \"@alloy-js/core\";\nimport type { PluginContext } from \"powerlines\";\n\n/**\n * The Powerlines context used in template rendering.\n */\nexport const PowerlinesContext: ComponentContext<PluginContext> =\n createNamedContext<PluginContext>(\"Powerlines\");\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function usePowerlinesContext<\n TContext extends PluginContext = PluginContext\n>(): TContext | undefined {\n return useContext(PowerlinesContext) as TContext | undefined;\n}\n\n/**\n * Hook to safely access the {@link PluginContext | Powerlines context}.\n *\n * @returns The Powerlines context or undefined if not set.\n */\nexport function usePowerlinesSafe<\n TContext extends PluginContext = PluginContext\n>(): TContext | undefined {\n const powerlines = usePowerlinesContext<TContext>();\n\n return powerlines ?? undefined;\n}\n\n/**\n * Hook to access the {@link PluginContext | Powerlines context}.\n *\n * @returns The Powerlines context.\n */\nexport function usePowerlines<\n TContext extends PluginContext = PluginContext\n>(): TContext {\n const powerlines = usePowerlinesSafe<TContext>();\n if (!powerlines) {\n throw new Error(\n \"Powerlines - Context is not set. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return powerlines;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.mjs","names":["createNamedContext","useContext","MetaContext","useMetaContext","useMetaSafe","meta","undefined","useMeta","Error"],"sources":["../../../src/core/contexts/meta.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 {\n ComponentContext,\n createNamedContext,\n useContext\n} from \"@alloy-js/core\";\nimport type { StoragePreset } from \"powerlines
|
|
1
|
+
{"version":3,"file":"meta.mjs","names":["createNamedContext","useContext","MetaContext","useMetaContext","useMetaSafe","meta","undefined","useMeta","Error"],"sources":["../../../src/core/contexts/meta.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 {\n ComponentContext,\n createNamedContext,\n useContext\n} from \"@alloy-js/core\";\nimport type { StoragePreset } from \"powerlines\";\n\nexport interface MetaItem {\n /**\n * The kind of metadata item.\n */\n kind?: \"builtin\" | \"entry\" | string;\n\n /**\n * Whether to skip formatting for this output.\n */\n skipFormat?: boolean;\n\n /**\n * The storage preset or adapter name for the output files.\n *\n * @remarks\n * If not specified, the output mode will be determined by the provided `output.mode` value.\n */\n storage?: StoragePreset | string;\n\n [key: string]: any;\n}\n\n/**\n * The Powerlines meta context used to determine metadata of files generated during rendering.\n */\nexport const MetaContext: ComponentContext<Record<string, MetaItem>> =\n createNamedContext<Record<string, MetaItem>>(\"Meta\");\n\n/**\n * Hook to access the Powerlines Context.\n *\n * @returns The Context.\n */\nexport function useMetaContext(): Record<string, MetaItem> | undefined {\n return useContext(MetaContext);\n}\n\n/**\n * Hook to safely access the render context's metadata.\n *\n * @returns The Powerlines context or undefined if not set.\n */\nexport function useMetaSafe(): Record<string, MetaItem> | undefined {\n const meta = useMetaContext();\n\n return meta ?? undefined;\n}\n\n/**\n * Hook to access the render context's metadata.\n *\n * @returns The Powerlines context.\n */\nexport function useMeta(): Record<string, MetaItem> {\n const meta = useMetaSafe();\n if (!meta) {\n throw new Error(\n \"Powerlines metadata is not available in the rendering context. Please make sure the Alloy components are being provided to an invocation of the `render` function added to plugins by `@powerlines/plugin-alloy`.\"\n );\n }\n\n return meta;\n}\n"],"mappings":""}
|
package/dist/helpers/capnp.cjs
CHANGED
|
@@ -22,7 +22,7 @@ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
|
22
22
|
let node_buffer = require("node:buffer");
|
|
23
23
|
let node_child_process = require("node:child_process");
|
|
24
24
|
let node_util = require("node:util");
|
|
25
|
-
let
|
|
25
|
+
let powerlines_utils = require("powerlines/utils");
|
|
26
26
|
|
|
27
27
|
//#region src/helpers/capnp.ts
|
|
28
28
|
/**
|
|
@@ -39,7 +39,7 @@ async function compile(context, options = {}) {
|
|
|
39
39
|
dts: false,
|
|
40
40
|
schemas: (0, __stryke_path_join.joinPaths)(context.artifactsPath, "schemas"),
|
|
41
41
|
tsconfig: context.tsconfig,
|
|
42
|
-
projectRoot: context.config.
|
|
42
|
+
projectRoot: context.config.root,
|
|
43
43
|
workspaceRoot: context.workspaceConfig.workspaceRoot,
|
|
44
44
|
tty: true
|
|
45
45
|
});
|
|
@@ -118,7 +118,7 @@ async function generateCapnpId() {
|
|
|
118
118
|
}
|
|
119
119
|
async function generateCapnp(context, reflection, options) {
|
|
120
120
|
return `${(await generateCapnpId()).trim()};
|
|
121
|
-
${(0,
|
|
121
|
+
${(0, powerlines_utils.getBaseFileHeader)(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
|
|
122
122
|
${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
|
|
123
123
|
`.trim();
|
|
124
124
|
}
|
package/dist/helpers/capnp.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, PluginContext } from "powerlines
|
|
1
|
+
import { Context, PluginContext } from "powerlines";
|
|
2
2
|
import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty, Type, TypeEnum, TypeUnion } from "@powerlines/deepkit/vendor/type";
|
|
3
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
4
4
|
|
package/dist/helpers/capnp.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty, Type, TypeEnum, TypeUnion } from "@powerlines/deepkit/vendor/type";
|
|
2
|
-
import { Context, PluginContext } from "powerlines
|
|
2
|
+
import { Context, PluginContext } from "powerlines";
|
|
3
3
|
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/capnp.d.ts
|
package/dist/helpers/capnp.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { isString } from "@stryke/type-checks/is-string";
|
|
|
20
20
|
import { Buffer } from "node:buffer";
|
|
21
21
|
import { exec } from "node:child_process";
|
|
22
22
|
import { promisify } from "node:util";
|
|
23
|
-
import { getBaseFileHeader } from "powerlines/
|
|
23
|
+
import { getBaseFileHeader } from "powerlines/utils";
|
|
24
24
|
|
|
25
25
|
//#region src/helpers/capnp.ts
|
|
26
26
|
/**
|
|
@@ -37,7 +37,7 @@ async function compile(context, options = {}) {
|
|
|
37
37
|
dts: false,
|
|
38
38
|
schemas: joinPaths(context.artifactsPath, "schemas"),
|
|
39
39
|
tsconfig: context.tsconfig,
|
|
40
|
-
projectRoot: context.config.
|
|
40
|
+
projectRoot: context.config.root,
|
|
41
41
|
workspaceRoot: context.workspaceConfig.workspaceRoot,
|
|
42
42
|
tty: true
|
|
43
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capnp.mjs","names":["getUnionTypes","kindToName","getClassName","memberNameToString","ReflectionKind","capnpc","resolveOptions","toArray","getUniqueBy","StormJSON","joinPaths","camelCase","getWords","pascalCase","titleCase","isBigInt","isNull","isNumber","isString","isUndefined","defu","Buffer","exec","promisify","getBaseFileHeader","compile","context","options","opts","ts","js","dts","schemas","artifactsPath","tsconfig","projectRoot","config","workspaceRoot","workspaceConfig","tty","resolvedOptions","Error","join","stringifyCapnpDefaultValue","property","value","stringifyCapnpValue","type","getDefaultValue","kind","string","literal","String","enum","array","stringify","object","objectLiteral","replaceAll","getCapnpEnumTypes","unique","values","filter","enumMember","length","isVoidType","void","never","null","undefined","symbol","getCapnpUnionTypes","isCapnpStringUnion","some","member","LARGE_BUFFER","execAsync","generateCapnpId","stdout","windowsHide","maxBuffer","killSignal","generateCapnp","reflection","capnpId","trim","replace","getMethods","generateCapnpStruct","generateCapnpInterface","structName","name","getTitle","getName","generateCapnpEnums","generateCapnpSchema","interfaceName","formatEnumName","enums","getProperties","prop","isIgnored","union","sort","a","b","isReadonly","getNameAsString","localeCompare","map","enumeration","generateCapnpEnumSchema","index","indexCounter","generateCapnpPropertySchema","methods","generateCapnpMethodSchema","class","classType","Map","Date","methodName","reflectionClass","getParameters","param","generateCapnpPrimitive","getType","hasDefault","getReturnType","getDescription","generateCapnpPropertyComment","result","relaxed","reduce","ret","word","includes","substring","lastIndexOf","current","getSubType","typeArguments","ArrayBuffer","typeName","indexType","types","enumType","Object","entries","key","Set","bigint","number","regexp","boolean"],"sources":["../../src/helpers/capnp.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUnionTypes, kindToName } from \"@powerlines/deepkit/utilities\";\nimport { getClassName } from \"@powerlines/deepkit/vendor/core\";\nimport {\n memberNameToString,\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeEnum,\n TypeLiteral,\n TypeUnion\n} from \"@powerlines/deepkit/vendor/type\";\nimport { capnpc } from \"@stryke/capnp/compile\";\nimport { resolveOptions } from \"@stryke/capnp/helpers\";\nimport type { CapnpcOptions, CapnpcResult } from \"@stryke/capnp/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { getWords } from \"@stryke/string-format/get-words\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport defu from \"defu\";\nimport { Buffer } from \"node:buffer\";\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { getBaseFileHeader } from \"powerlines/lib/utilities/file-header\";\nimport { Context, PluginContext } from \"powerlines/types/context\";\n\n/**\n * Compiles a Cap'n Proto schema into TypeScript definitions.\n *\n * @param context - The context containing the project and workspace information.\n * @param options - The options for compiling the schema.\n * @returns A promise that resolves to the compiled schema.\n */\nexport async function compile(\n context: Context,\n options: Partial<CapnpcOptions> = {}\n): Promise<CapnpcResult> {\n const opts = defu(options, {\n ts: true,\n js: false,\n dts: false,\n schemas: joinPaths(context.artifactsPath, \"schemas\"),\n tsconfig: context.tsconfig,\n projectRoot: context.config.projectRoot,\n workspaceRoot: context.workspaceConfig.workspaceRoot,\n tty: true\n }) as Parameters<typeof resolveOptions>[0];\n\n const resolvedOptions = await resolveOptions(opts);\n if (!resolvedOptions) {\n throw new Error(\n `✖ No Cap'n Proto schema files found in the specified source paths: ${toArray(\n opts.schemas\n ).join(\", \")}.`\n );\n }\n\n return capnpc(resolvedOptions);\n}\n\n/**\n * Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.\n *\n * @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpDefaultValue(\n property: ReflectionProperty | ReflectionParameter,\n value?: any\n): string {\n return stringifyCapnpValue(\n property.type,\n value ?? property.getDefaultValue()\n );\n}\n\n/**\n * Converts any {@link Type}'s actual value to string representation.\n *\n * @param type - The {@link Type} of the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpValue(type: Type, value: any): string {\n return type.kind === ReflectionKind.string ||\n (type.kind === ReflectionKind.literal && isString(type.literal))\n ? `\"${String(value)}\"`\n : type.kind === ReflectionKind.enum\n ? `${camelCase(String(value))}`\n : type.kind === ReflectionKind.array\n ? StormJSON.stringify(value)\n : type.kind === ReflectionKind.object ||\n type.kind === ReflectionKind.objectLiteral\n ? StormJSON.stringify(value).replaceAll(\"{\", \"(\").replaceAll(\"}\", \")\")\n : String(value);\n}\n\n/**\n * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.\n *\n * @param type - The TypeEnum to evaluate.\n * @returns A string representation of the property.\n */\nexport function getCapnpEnumTypes(type: Type): \"Text\" | \"Float32\" | null {\n if (type.kind !== ReflectionKind.enum) {\n return null;\n }\n\n const unique = getUniqueBy(\n type.values.filter(value => !isUndefined(value) && !isNull(value)),\n enumMember => (isString(enumMember) ? \"Text\" : \"Float32\")\n );\n if (unique.length === 0) {\n return null;\n }\n\n return unique[0] && isString(unique[0]) ? \"Text\" : \"Float32\";\n}\n\n/**\n * Determines if a Type is a `Void` type in a Cap'n Proto schema.\n *\n * @param type - The Type to check.\n * @returns True if the Type is a `Void` type, false otherwise.\n */\nexport function isVoidType(type: Type): boolean {\n return (\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n );\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function getCapnpUnionTypes(type: Type): Type[] {\n return getUnionTypes(type);\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns An array of Cap'n Proto primitive types.\n */\nexport function isCapnpStringUnion(type: Type): boolean {\n return getCapnpUnionTypes(type).some(\n member => member.kind === ReflectionKind.string\n );\n}\n\nexport const LARGE_BUFFER = 1024 * 1000000;\nexport type IOType = \"overlapped\" | \"pipe\" | \"ignore\" | \"inherit\";\nexport type StdioOptions =\n | IOType\n | Array<IOType | \"ipc\" | number | null | undefined>;\n\nconst execAsync = promisify(exec);\n\nexport async function generateCapnpId() {\n const { stdout } = await execAsync(\"capnp id\", {\n windowsHide: true,\n maxBuffer: LARGE_BUFFER,\n killSignal: \"SIGTERM\"\n });\n\n return stdout;\n}\n\nexport interface GenerateCapnpOptions {\n name?: string;\n}\n\nexport async function generateCapnp(\n context: PluginContext,\n reflection: ReflectionClass<any>,\n options: GenerateCapnpOptions\n) {\n const capnpId = await generateCapnpId();\n\n return `${capnpId.trim()};\n${getBaseFileHeader(context)\n .replace(/^\\r*\\n*/g, \"\")\n .replaceAll(\"//\", \"#\")}\n${\n reflection.getMethods().length === 0\n ? generateCapnpStruct(reflection, options)\n : generateCapnpInterface(reflection, options)\n}\n`.trim();\n}\n\nexport interface GenerateCapnpStructOptions extends GenerateCapnpOptions {\n indexCounter?: () => number;\n}\n\nexport function generateCapnpStruct(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const structName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}struct ${pascalCase(structName)} {\n # Struct definition for ${titleCase(structName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nexport function generateCapnpInterface(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const interfaceName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}interface ${pascalCase(interfaceName)} {\n # Interface definition for ${titleCase(interfaceName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nfunction formatEnumName(name: string) {\n return pascalCase(`${name}_Type`);\n}\n\nfunction generateCapnpEnums(reflection: ReflectionClass<any>): string {\n const enums = reflection\n .getProperties()\n .filter(\n prop =>\n !prop.isIgnored() &&\n (prop.type.kind === ReflectionKind.enum ||\n (prop.type.kind === ReflectionKind.union &&\n getCapnpUnionTypes(prop.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1))\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n );\n if (enums.length === 0) {\n return \"\";\n }\n\n return `${enums\n .map(enumeration =>\n generateCapnpEnumSchema(\n enumeration.type as TypeEnum | TypeUnion,\n formatEnumName(enumeration.getNameAsString())\n )\n )\n .join(\"\\n\\n\")}\n\n`;\n}\n\nexport function generateCapnpSchema(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n let index = 0;\n const indexCounter: () => number = options?.indexCounter ?? (() => index++);\n\n return `${reflection\n .getProperties()\n .filter(prop => !prop.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(prop => generateCapnpPropertySchema(prop, indexCounter))\n .join(\" \\n\\n\\t\")}${reflection\n .getMethods()\n .filter(methods => !methods.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? String(b.getName()).localeCompare(String(a.getName()))\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(methods => generateCapnpMethodSchema(methods, indexCounter))\n .join(\" \\n\\n\\t\")}${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class && prop.type.classType === Map\n )\n ? `\n struct Map(Key, Value) {\n entries @0 :List(Entry);\n\n struct Entry {\n key @0 :Key;\n value @1 :Value;\n }\n }`\n : \"\"\n }${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class &&\n prop.type.classType === Date\n )\n ? `\n struct Date {\n # A standard Gregorian calendar date.\n\n year @0 :Int16;\n # The year - Must include the century.\n # Negative value indicates BC.\n\n month @1 :UInt8; # The month, 1-12\n\n day @2 :UInt8; # The day of the month, 1-30\n\n hour @3 :UInt8; # The hour of the day, 0-23\n\n minute @4 :UInt8; # The minute of the hour, 0-59\n\n second @5 :UInt8; # The second of the minute, 0-59\n\n millisecond @6 :UInt16; # Milliseconds of the second, 0-999\n }`\n : \"\"\n }`;\n}\n\nexport function generateCapnpMethodSchema(\n reflection: ReflectionMethod,\n indexCounter: () => number\n): string {\n const methodName =\n reflection.getTitle() || typeof reflection.getName() === \"string\"\n ? String(reflection.getName())\n : \"\";\n if (!methodName) {\n throw new Error(\n `Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`\n );\n }\n\n return `${camelCase(methodName)} @${indexCounter()} (${reflection\n .getParameters()\n .map(param => {\n return `${camelCase(\n param.getName()\n )} :${generateCapnpPrimitive(param.getType())}${\n param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : \"\"\n }`;\n })\n .join(\", \")})${\n isVoidType(reflection.getReturnType())\n ? \"\"\n : ` -> (${kindToName(\n reflection.getReturnType().kind\n )}: ${generateCapnpPrimitive(reflection.getReturnType())})`\n }; # ${(\n reflection.getDescription() ||\n `The ${titleCase(\n reflection.reflectionClass.getTitle() ||\n reflection.reflectionClass.getName()\n )} interface ${titleCase(methodName)} method.`\n ).replaceAll(\"\\n\", \". \")}`;\n}\n\nfunction generateCapnpPropertyComment(reflection: ReflectionProperty) {\n const result = getWords(\n reflection.getDescription() ||\n `A schema property for ${titleCase(\n reflection.getTitle() || reflection.getNameAsString()\n )} field.`,\n {\n relaxed: true\n }\n )\n .reduce((ret, word) => {\n let length = ret.length;\n if (ret.includes(\"\\n\")) {\n length = ret.substring(ret.lastIndexOf(\"\\n\") + 1).length;\n }\n\n const current = word.trim();\n if (length + current.length > 60) {\n ret += `\\n\\t# ${current}`;\n } else {\n ret += ` ${current}`;\n }\n return ret;\n }, \"\")\n .trim();\n if (result.length > 0) {\n return `\\t# ${result}`;\n }\n\n return \"\";\n}\n\nfunction generateCapnpPropertySchema(\n reflection: ReflectionProperty,\n indexCounter: () => number\n): string {\n if (reflection.type.kind === ReflectionKind.union) {\n if (getCapnpUnionTypes(reflection.type).length === 0) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;\n${generateCapnpPropertyComment(reflection)}`;\n } else if (\n getCapnpUnionTypes(reflection.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1\n ) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} :union {\n${getCapnpUnionTypes(reflection.type)\n .map(\n type =>\n ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(\n type\n )};`\n )\n .join(\"\\n\")}\n }\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.array) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.class) {\n if (reflection.type.classType === Map) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Map(${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length === 0 ||\n !reflection.type.typeArguments[0]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[0])\n }, ${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length < 2 ||\n !reflection.type.typeArguments[1]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[1])\n })${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Date) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Buffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === ArrayBuffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.objectLiteral) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.enum) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(\n reflection.getType()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n}\n\nexport function generateCapnpEnumSchema(\n type: TypeEnum | TypeUnion,\n name: string\n): string {\n if (type.kind === ReflectionKind.union) {\n return generateCapnpEnumSchema(\n {\n kind: ReflectionKind.enum,\n indexType: type,\n enum: (type.types as TypeLiteral[]).reduce<\n Record<string, string | number>\n >((ret, type) => {\n if (isString(type.literal) || isNumber(type.literal)) {\n ret[camelCase(String(type.literal))] = type.literal;\n }\n\n return ret;\n }, {}),\n values: (\n getCapnpUnionTypes(type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ) as TypeLiteral[]\n ).map(type => type.literal as string | number)\n },\n name\n );\n }\n\n let index = 0;\n const indexCounter: () => number = () => index++;\n\n const enumType = getCapnpEnumTypes(type);\n if (!enumType) {\n return \"\";\n }\n\n return `enum ${pascalCase(name)} {\n${\n type.enum && Object.entries(type.enum).length > 0\n ? Object.entries(type.enum)\n .filter(([, value]) => value !== null && value !== undefined)\n .map(([key]) => ` ${camelCase(key)} @${indexCounter()};`)\n .join(\"\\n\")\n : type.values\n .filter(value => value !== null && value !== undefined)\n .map(\n value =>\n `${\n enumType === \"Text\" && value\n ? camelCase(String(value))\n : `${\n type.typeName ? `${camelCase(type.typeName)}_` : \"\"\n }${value || \"\"}`\n } @${indexCounter()};`\n )\n .join(\"\\n\")\n}\n }`;\n}\n\n/**\n * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.\n *\n * @param type - The Deepkit Type to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function generateCapnpPrimitive(type: Type): string {\n return type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n ? \"Void\"\n : type.kind === ReflectionKind.class && type.classType === Date\n ? \"Date\"\n : type.kind === ReflectionKind.class && type.classType === Set\n ? `List(${\n type.typeArguments && type.typeArguments[0]\n ? generateCapnpPrimitive(type.typeArguments[0])\n : \"Data\"\n })`\n : type.kind === ReflectionKind.bigint\n ? \"UInt64\"\n : type.kind === ReflectionKind.number\n ? \"Float64\"\n : type.kind === ReflectionKind.string ||\n type.kind === ReflectionKind.regexp\n ? \"Text\"\n : type.kind === ReflectionKind.boolean\n ? \"Bool\"\n : type.kind === ReflectionKind.literal\n ? isNumber(type.literal)\n ? \"Float64\"\n : isBigInt(type.literal)\n ? \"UInt64\"\n : isString(type.literal)\n ? \"Text\"\n : typeof type.literal === \"boolean\"\n ? \"Bool\"\n : \"Data\"\n : \"Data\";\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"capnp.mjs","names":["getUnionTypes","kindToName","getClassName","memberNameToString","ReflectionKind","capnpc","resolveOptions","toArray","getUniqueBy","StormJSON","joinPaths","camelCase","getWords","pascalCase","titleCase","isBigInt","isNull","isNumber","isString","isUndefined","defu","Buffer","exec","promisify","getBaseFileHeader","compile","context","options","opts","ts","js","dts","schemas","artifactsPath","tsconfig","projectRoot","config","root","workspaceRoot","workspaceConfig","tty","resolvedOptions","Error","join","stringifyCapnpDefaultValue","property","value","stringifyCapnpValue","type","getDefaultValue","kind","string","literal","String","enum","array","stringify","object","objectLiteral","replaceAll","getCapnpEnumTypes","unique","values","filter","enumMember","length","isVoidType","void","never","null","undefined","symbol","getCapnpUnionTypes","isCapnpStringUnion","some","member","LARGE_BUFFER","execAsync","generateCapnpId","stdout","windowsHide","maxBuffer","killSignal","generateCapnp","reflection","capnpId","trim","replace","getMethods","generateCapnpStruct","generateCapnpInterface","structName","name","getTitle","getName","generateCapnpEnums","generateCapnpSchema","interfaceName","formatEnumName","enums","getProperties","prop","isIgnored","union","sort","a","b","isReadonly","getNameAsString","localeCompare","map","enumeration","generateCapnpEnumSchema","index","indexCounter","generateCapnpPropertySchema","methods","generateCapnpMethodSchema","class","classType","Map","Date","methodName","reflectionClass","getParameters","param","generateCapnpPrimitive","getType","hasDefault","getReturnType","getDescription","generateCapnpPropertyComment","result","relaxed","reduce","ret","word","includes","substring","lastIndexOf","current","getSubType","typeArguments","ArrayBuffer","typeName","indexType","types","enumType","Object","entries","key","Set","bigint","number","regexp","boolean"],"sources":["../../src/helpers/capnp.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUnionTypes, kindToName } from \"@powerlines/deepkit/utilities\";\nimport { getClassName } from \"@powerlines/deepkit/vendor/core\";\nimport {\n memberNameToString,\n ReflectionClass,\n ReflectionKind,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeEnum,\n TypeLiteral,\n TypeUnion\n} from \"@powerlines/deepkit/vendor/type\";\nimport { capnpc } from \"@stryke/capnp/compile\";\nimport { resolveOptions } from \"@stryke/capnp/helpers\";\nimport type { CapnpcOptions, CapnpcResult } from \"@stryke/capnp/types\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { getWords } from \"@stryke/string-format/get-words\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport defu from \"defu\";\nimport { Buffer } from \"node:buffer\";\nimport { exec } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Context, PluginContext } from \"powerlines\";\nimport { getBaseFileHeader } from \"powerlines/utils\";\n\n/**\n * Compiles a Cap'n Proto schema into TypeScript definitions.\n *\n * @param context - The context containing the project and workspace information.\n * @param options - The options for compiling the schema.\n * @returns A promise that resolves to the compiled schema.\n */\nexport async function compile(\n context: Context,\n options: Partial<CapnpcOptions> = {}\n): Promise<CapnpcResult> {\n const opts = defu(options, {\n ts: true,\n js: false,\n dts: false,\n schemas: joinPaths(context.artifactsPath, \"schemas\"),\n tsconfig: context.tsconfig,\n projectRoot: context.config.root,\n workspaceRoot: context.workspaceConfig.workspaceRoot,\n tty: true\n }) as Parameters<typeof resolveOptions>[0];\n\n const resolvedOptions = await resolveOptions(opts);\n if (!resolvedOptions) {\n throw new Error(\n `✖ No Cap'n Proto schema files found in the specified source paths: ${toArray(\n opts.schemas\n ).join(\", \")}.`\n );\n }\n\n return capnpc(resolvedOptions);\n}\n\n/**\n * Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.\n *\n * @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpDefaultValue(\n property: ReflectionProperty | ReflectionParameter,\n value?: any\n): string {\n return stringifyCapnpValue(\n property.type,\n value ?? property.getDefaultValue()\n );\n}\n\n/**\n * Converts any {@link Type}'s actual value to string representation.\n *\n * @param type - The {@link Type} of the value to stringify.\n * @param value - The value to stringify.\n * @returns A string representation of the value.\n */\nexport function stringifyCapnpValue(type: Type, value: any): string {\n return type.kind === ReflectionKind.string ||\n (type.kind === ReflectionKind.literal && isString(type.literal))\n ? `\"${String(value)}\"`\n : type.kind === ReflectionKind.enum\n ? `${camelCase(String(value))}`\n : type.kind === ReflectionKind.array\n ? StormJSON.stringify(value)\n : type.kind === ReflectionKind.object ||\n type.kind === ReflectionKind.objectLiteral\n ? StormJSON.stringify(value).replaceAll(\"{\", \"(\").replaceAll(\"}\", \")\")\n : String(value);\n}\n\n/**\n * Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.\n *\n * @param type - The TypeEnum to evaluate.\n * @returns A string representation of the property.\n */\nexport function getCapnpEnumTypes(type: Type): \"Text\" | \"Float32\" | null {\n if (type.kind !== ReflectionKind.enum) {\n return null;\n }\n\n const unique = getUniqueBy(\n type.values.filter(value => !isUndefined(value) && !isNull(value)),\n enumMember => (isString(enumMember) ? \"Text\" : \"Float32\")\n );\n if (unique.length === 0) {\n return null;\n }\n\n return unique[0] && isString(unique[0]) ? \"Text\" : \"Float32\";\n}\n\n/**\n * Determines if a Type is a `Void` type in a Cap'n Proto schema.\n *\n * @param type - The Type to check.\n * @returns True if the Type is a `Void` type, false otherwise.\n */\nexport function isVoidType(type: Type): boolean {\n return (\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n );\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function getCapnpUnionTypes(type: Type): Type[] {\n return getUnionTypes(type);\n}\n\n/**\n * Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.\n *\n * @param type - The {@link TypeUnion} to convert.\n * @returns An array of Cap'n Proto primitive types.\n */\nexport function isCapnpStringUnion(type: Type): boolean {\n return getCapnpUnionTypes(type).some(\n member => member.kind === ReflectionKind.string\n );\n}\n\nexport const LARGE_BUFFER = 1024 * 1000000;\nexport type IOType = \"overlapped\" | \"pipe\" | \"ignore\" | \"inherit\";\nexport type StdioOptions =\n | IOType\n | Array<IOType | \"ipc\" | number | null | undefined>;\n\nconst execAsync = promisify(exec);\n\nexport async function generateCapnpId() {\n const { stdout } = await execAsync(\"capnp id\", {\n windowsHide: true,\n maxBuffer: LARGE_BUFFER,\n killSignal: \"SIGTERM\"\n });\n\n return stdout;\n}\n\nexport interface GenerateCapnpOptions {\n name?: string;\n}\n\nexport async function generateCapnp(\n context: PluginContext,\n reflection: ReflectionClass<any>,\n options: GenerateCapnpOptions\n) {\n const capnpId = await generateCapnpId();\n\n return `${capnpId.trim()};\n${getBaseFileHeader(context)\n .replace(/^\\r*\\n*/g, \"\")\n .replaceAll(\"//\", \"#\")}\n${\n reflection.getMethods().length === 0\n ? generateCapnpStruct(reflection, options)\n : generateCapnpInterface(reflection, options)\n}\n`.trim();\n}\n\nexport interface GenerateCapnpStructOptions extends GenerateCapnpOptions {\n indexCounter?: () => number;\n}\n\nexport function generateCapnpStruct(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const structName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}struct ${pascalCase(structName)} {\n # Struct definition for ${titleCase(structName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nexport function generateCapnpInterface(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n const interfaceName =\n options?.name ||\n reflection.getTitle() ||\n reflection.getClassName() ||\n reflection.getName();\n\n return `${generateCapnpEnums(reflection)}interface ${pascalCase(interfaceName)} {\n # Interface definition for ${titleCase(interfaceName)}.\n\n ${generateCapnpSchema(reflection, options)}\n}\n`;\n}\n\nfunction formatEnumName(name: string) {\n return pascalCase(`${name}_Type`);\n}\n\nfunction generateCapnpEnums(reflection: ReflectionClass<any>): string {\n const enums = reflection\n .getProperties()\n .filter(\n prop =>\n !prop.isIgnored() &&\n (prop.type.kind === ReflectionKind.enum ||\n (prop.type.kind === ReflectionKind.union &&\n getCapnpUnionTypes(prop.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1))\n )\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n );\n if (enums.length === 0) {\n return \"\";\n }\n\n return `${enums\n .map(enumeration =>\n generateCapnpEnumSchema(\n enumeration.type as TypeEnum | TypeUnion,\n formatEnumName(enumeration.getNameAsString())\n )\n )\n .join(\"\\n\\n\")}\n\n`;\n}\n\nexport function generateCapnpSchema(\n reflection: ReflectionClass<any>,\n options: GenerateCapnpStructOptions = {}\n): string {\n let index = 0;\n const indexCounter: () => number = options?.indexCounter ?? (() => index++);\n\n return `${reflection\n .getProperties()\n .filter(prop => !prop.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? b.getNameAsString().localeCompare(a.getNameAsString())\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(prop => generateCapnpPropertySchema(prop, indexCounter))\n .join(\" \\n\\n\\t\")}${reflection\n .getMethods()\n .filter(methods => !methods.isIgnored())\n .sort((a, b) =>\n (a.isReadonly() && b.isReadonly()) || (!a.isReadonly() && !b.isReadonly())\n ? String(b.getName()).localeCompare(String(a.getName()))\n : a.isReadonly()\n ? 1\n : -1\n )\n .map(methods => generateCapnpMethodSchema(methods, indexCounter))\n .join(\" \\n\\n\\t\")}${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class && prop.type.classType === Map\n )\n ? `\n struct Map(Key, Value) {\n entries @0 :List(Entry);\n\n struct Entry {\n key @0 :Key;\n value @1 :Value;\n }\n }`\n : \"\"\n }${\n reflection\n .getProperties()\n .some(\n prop =>\n prop.type.kind === ReflectionKind.class &&\n prop.type.classType === Date\n )\n ? `\n struct Date {\n # A standard Gregorian calendar date.\n\n year @0 :Int16;\n # The year - Must include the century.\n # Negative value indicates BC.\n\n month @1 :UInt8; # The month, 1-12\n\n day @2 :UInt8; # The day of the month, 1-30\n\n hour @3 :UInt8; # The hour of the day, 0-23\n\n minute @4 :UInt8; # The minute of the hour, 0-59\n\n second @5 :UInt8; # The second of the minute, 0-59\n\n millisecond @6 :UInt16; # Milliseconds of the second, 0-999\n }`\n : \"\"\n }`;\n}\n\nexport function generateCapnpMethodSchema(\n reflection: ReflectionMethod,\n indexCounter: () => number\n): string {\n const methodName =\n reflection.getTitle() || typeof reflection.getName() === \"string\"\n ? String(reflection.getName())\n : \"\";\n if (!methodName) {\n throw new Error(\n `Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`\n );\n }\n\n return `${camelCase(methodName)} @${indexCounter()} (${reflection\n .getParameters()\n .map(param => {\n return `${camelCase(\n param.getName()\n )} :${generateCapnpPrimitive(param.getType())}${\n param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : \"\"\n }`;\n })\n .join(\", \")})${\n isVoidType(reflection.getReturnType())\n ? \"\"\n : ` -> (${kindToName(\n reflection.getReturnType().kind\n )}: ${generateCapnpPrimitive(reflection.getReturnType())})`\n }; # ${(\n reflection.getDescription() ||\n `The ${titleCase(\n reflection.reflectionClass.getTitle() ||\n reflection.reflectionClass.getName()\n )} interface ${titleCase(methodName)} method.`\n ).replaceAll(\"\\n\", \". \")}`;\n}\n\nfunction generateCapnpPropertyComment(reflection: ReflectionProperty) {\n const result = getWords(\n reflection.getDescription() ||\n `A schema property for ${titleCase(\n reflection.getTitle() || reflection.getNameAsString()\n )} field.`,\n {\n relaxed: true\n }\n )\n .reduce((ret, word) => {\n let length = ret.length;\n if (ret.includes(\"\\n\")) {\n length = ret.substring(ret.lastIndexOf(\"\\n\") + 1).length;\n }\n\n const current = word.trim();\n if (length + current.length > 60) {\n ret += `\\n\\t# ${current}`;\n } else {\n ret += ` ${current}`;\n }\n return ret;\n }, \"\")\n .trim();\n if (result.length > 0) {\n return `\\t# ${result}`;\n }\n\n return \"\";\n}\n\nfunction generateCapnpPropertySchema(\n reflection: ReflectionProperty,\n indexCounter: () => number\n): string {\n if (reflection.type.kind === ReflectionKind.union) {\n if (getCapnpUnionTypes(reflection.type).length === 0) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Void;\n${generateCapnpPropertyComment(reflection)}`;\n } else if (\n getCapnpUnionTypes(reflection.type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ).length === 1\n ) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} :union {\n${getCapnpUnionTypes(reflection.type)\n .map(\n type =>\n ` ${kindToName(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(\n type\n )};`\n )\n .join(\"\\n\")}\n }\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.array) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.class) {\n if (reflection.type.classType === Map) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Map(${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length === 0 ||\n !reflection.type.typeArguments[0]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[0])\n }, ${\n !reflection.type.typeArguments ||\n reflection.type.typeArguments.length < 2 ||\n !reflection.type.typeArguments[1]\n ? \"Data\"\n : generateCapnpPrimitive(reflection.type.typeArguments[1])\n })${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Date) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === Buffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.classType === ArrayBuffer) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :Data${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName || getClassName(reflection.type.classType)\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n } else if (reflection.type.kind === ReflectionKind.objectLiteral) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )}${generateCapnpStruct(reflection.reflectionClass, {\n name: pascalCase(\n reflection.type.typeName ||\n memberNameToString(reflection.getNameAsString())\n )\n })}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n } else if (reflection.type.kind === ReflectionKind.enum) {\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${pascalCase(\n reflection.getNameAsString()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n }\n\n return `${camelCase(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(\n reflection.getType()\n )}${\n reflection.hasDefault()\n ? ` = ${stringifyCapnpDefaultValue(reflection)}`\n : \"\"\n };\n${generateCapnpPropertyComment(reflection)}`;\n}\n\nexport function generateCapnpEnumSchema(\n type: TypeEnum | TypeUnion,\n name: string\n): string {\n if (type.kind === ReflectionKind.union) {\n return generateCapnpEnumSchema(\n {\n kind: ReflectionKind.enum,\n indexType: type,\n enum: (type.types as TypeLiteral[]).reduce<\n Record<string, string | number>\n >((ret, type) => {\n if (isString(type.literal) || isNumber(type.literal)) {\n ret[camelCase(String(type.literal))] = type.literal;\n }\n\n return ret;\n }, {}),\n values: (\n getCapnpUnionTypes(type).filter(\n type =>\n type.kind === ReflectionKind.literal &&\n (isString(type.literal) || isNumber(type.literal))\n ) as TypeLiteral[]\n ).map(type => type.literal as string | number)\n },\n name\n );\n }\n\n let index = 0;\n const indexCounter: () => number = () => index++;\n\n const enumType = getCapnpEnumTypes(type);\n if (!enumType) {\n return \"\";\n }\n\n return `enum ${pascalCase(name)} {\n${\n type.enum && Object.entries(type.enum).length > 0\n ? Object.entries(type.enum)\n .filter(([, value]) => value !== null && value !== undefined)\n .map(([key]) => ` ${camelCase(key)} @${indexCounter()};`)\n .join(\"\\n\")\n : type.values\n .filter(value => value !== null && value !== undefined)\n .map(\n value =>\n `${\n enumType === \"Text\" && value\n ? camelCase(String(value))\n : `${\n type.typeName ? `${camelCase(type.typeName)}_` : \"\"\n }${value || \"\"}`\n } @${indexCounter()};`\n )\n .join(\"\\n\")\n}\n }`;\n}\n\n/**\n * Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.\n *\n * @param type - The Deepkit Type to convert.\n * @returns A string representation of the Cap'n Proto primitive type.\n */\nexport function generateCapnpPrimitive(type: Type): string {\n return type.kind === ReflectionKind.never ||\n type.kind === ReflectionKind.void ||\n type.kind === ReflectionKind.null ||\n type.kind === ReflectionKind.undefined ||\n type.kind === ReflectionKind.symbol\n ? \"Void\"\n : type.kind === ReflectionKind.class && type.classType === Date\n ? \"Date\"\n : type.kind === ReflectionKind.class && type.classType === Set\n ? `List(${\n type.typeArguments && type.typeArguments[0]\n ? generateCapnpPrimitive(type.typeArguments[0])\n : \"Data\"\n })`\n : type.kind === ReflectionKind.bigint\n ? \"UInt64\"\n : type.kind === ReflectionKind.number\n ? \"Float64\"\n : type.kind === ReflectionKind.string ||\n type.kind === ReflectionKind.regexp\n ? \"Text\"\n : type.kind === ReflectionKind.boolean\n ? \"Bool\"\n : type.kind === ReflectionKind.literal\n ? isNumber(type.literal)\n ? \"Float64\"\n : isBigInt(type.literal)\n ? \"UInt64\"\n : isString(type.literal)\n ? \"Text\"\n : typeof type.literal === \"boolean\"\n ? \"Bool\"\n : \"Data\"\n : \"Data\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgdA,UAAA,EAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -21,10 +21,10 @@ const plugin = (options = {}) => {
|
|
|
21
21
|
typescript: true,
|
|
22
22
|
...options
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
resolve: { external: [/^@alloy-js\//] },
|
|
25
|
+
tsdown: {
|
|
25
26
|
inputOptions: { transform: { jsx: "preserve" } },
|
|
26
|
-
plugins: [(0, __alloy_js_rollup_plugin.default)()]
|
|
27
|
-
external: [/^@alloy-js\//]
|
|
27
|
+
plugins: [(0, __alloy_js_rollup_plugin.default)()]
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AlloyPluginContext, AlloyPluginOptions } from "./types/plugin.cjs";
|
|
2
|
-
import { Plugin } from "powerlines
|
|
2
|
+
import { Plugin } from "powerlines";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
|
-
|
|
5
|
+
declare module "powerlines" {
|
|
6
|
+
interface UserConfig {
|
|
7
|
+
alloy?: AlloyPluginOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* Alloy-js plugin for Powerlines.
|
|
8
12
|
*
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;IAqB6E,KAAA,CAAA,EAIjE,kBAJiE;EAAA;;;;AAc7E;;;;AA2Dc,cA3DD,MA2DC,EAAA,CAAA,iBA1DK,kBA0DL,GA1D0B,kBA0D1B,CAAA,CAAA,OAAA,CAAA,EAxDH,kBAwDG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AlloyPluginContext, AlloyPluginOptions } from "./types/plugin.mjs";
|
|
2
|
-
import { Plugin } from "powerlines
|
|
2
|
+
import { Plugin } from "powerlines";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
|
-
|
|
5
|
+
declare module "powerlines" {
|
|
6
|
+
interface UserConfig {
|
|
7
|
+
alloy?: AlloyPluginOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
6
10
|
/**
|
|
7
11
|
* Alloy-js plugin for Powerlines.
|
|
8
12
|
*
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;IAqB6E,KAAA,CAAA,EAIjE,kBAJiE;EAAA;;;;AAc7E;;;;AA2Dc,cA3DD,MA2DC,EAAA,CAAA,iBA1DK,kBA0DL,GA1D0B,kBA0D1B,CAAA,CAAA,OAAA,CAAA,EAxDH,kBAwDG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -18,10 +18,10 @@ const plugin = (options = {}) => {
|
|
|
18
18
|
typescript: true,
|
|
19
19
|
...options
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
resolve: { external: [/^@alloy-js\//] },
|
|
22
|
+
tsdown: {
|
|
22
23
|
inputOptions: { transform: { jsx: "preserve" } },
|
|
23
|
-
plugins: [rollupPlugin()]
|
|
24
|
-
external: [/^@alloy-js\//]
|
|
24
|
+
plugins: [rollupPlugin()]
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
},
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["rollupPlugin","StormJSON","plugin","options","name","config","debug","alloy","typescript","
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["rollupPlugin","StormJSON","plugin","options","name","config","debug","alloy","typescript","resolve","external","tsdown","inputOptions","transform","jsx","plugins","configResolved","tsconfig","tsconfigJson","compilerOptions","jsxImportSource","fs","write","tsconfigFilePath","stringify"],"sources":["../src/index.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 rollupPlugin from \"@alloy-js/rollup-plugin\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport type { Plugin } from \"powerlines\";\nimport type { AlloyPluginContext, AlloyPluginOptions } from \"./types/plugin\";\n\ndeclare module \"powerlines\" {\n export interface UserConfig {\n alloy?: AlloyPluginOptions;\n }\n}\n\n/**\n * Alloy-js plugin for Powerlines.\n *\n * @param options - The Alloy-js plugin user configuration options.\n * @returns A Powerlines plugin that integrates Alloy-js transformations.\n */\nexport const plugin = <\n TContext extends AlloyPluginContext = AlloyPluginContext\n>(\n options: AlloyPluginOptions = {}\n) => {\n return [\n {\n name: \"alloy\",\n config() {\n this.debug(\n \"Updating configuration options to support Alloy-js builds.\"\n );\n\n return {\n alloy: {\n typescript: true,\n ...options\n },\n resolve: {\n external: [/^@alloy-js\\//]\n },\n tsdown: {\n inputOptions: {\n transform: {\n jsx: \"preserve\"\n }\n },\n plugins: [rollupPlugin()]\n }\n };\n },\n async configResolved() {\n this.debug(\"Ensuring TypeScript configuration is set up for Alloy-js.\");\n if (\n this.tsconfig.tsconfigJson.compilerOptions?.jsx !== \"preserve\" ||\n this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource !==\n \"@alloy-js/core\"\n ) {\n this.tsconfig.tsconfigJson.compilerOptions ??= {};\n\n if (this.tsconfig.tsconfigJson.compilerOptions.jsx !== \"preserve\") {\n this.tsconfig.tsconfigJson.compilerOptions.jsx = \"preserve\";\n }\n\n if (\n this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource !==\n \"@alloy-js/core\"\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource =\n \"@alloy-js/core\";\n }\n\n await this.fs.write(\n this.tsconfig.tsconfigFilePath,\n StormJSON.stringify(this.tsconfig.tsconfigJson)\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core4 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/markdown/components/front-matter.d.ts
|
|
4
4
|
interface FrontMatterProps {
|
|
@@ -9,7 +9,7 @@ interface FrontMatterProps {
|
|
|
9
9
|
*
|
|
10
10
|
* @see https://jekyllrb.com/docs/front-matter/
|
|
11
11
|
*/
|
|
12
|
-
declare function FrontMatter(props: FrontMatterProps):
|
|
12
|
+
declare function FrontMatter(props: FrontMatterProps): _alloy_js_core4.Children;
|
|
13
13
|
declare type __ΩFrontMatterProps = any[];
|
|
14
14
|
//#endregion
|
|
15
15
|
export { FrontMatter, FrontMatterProps, __ΩFrontMatterProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps, SourceFileHeaderProps } from "../../types/components.cjs";
|
|
2
2
|
import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.cjs";
|
|
3
3
|
import { FrontMatterProps } from "./front-matter.cjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _alloy_js_core5 from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/markdown/components/markdown-file.d.ts
|
|
7
7
|
type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps & MarkdownFileHeaderProps;
|
|
@@ -11,7 +11,7 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps &
|
|
|
11
11
|
* @param props - The properties for the source file.
|
|
12
12
|
* @returns The rendered source file component.
|
|
13
13
|
*/
|
|
14
|
-
declare function MarkdownFile(props: MarkdownFileProps):
|
|
14
|
+
declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core5.Children;
|
|
15
15
|
type MarkdownFileHeaderProps = SourceFileHeaderProps & {
|
|
16
16
|
frontMatter?: FrontMatterProps["data"];
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ type MarkdownFileHeaderProps = SourceFileHeaderProps & {
|
|
|
21
21
|
* @param props - The properties for the source file header.
|
|
22
22
|
* @returns The rendered source file header.
|
|
23
23
|
*/
|
|
24
|
-
declare function MarkdownFileHeader(props: MarkdownFileHeaderProps):
|
|
24
|
+
declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core5.Children;
|
|
25
25
|
declare type __ΩMarkdownFileProps = any[];
|
|
26
26
|
declare type __ΩMarkdownFileHeaderProps = any[];
|
|
27
27
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps, SourceFileHeaderProps } from "../../types/components.mjs";
|
|
2
2
|
import { SourceFileProps as SourceFileProps$1 } from "../../core/components/source-file.mjs";
|
|
3
3
|
import { FrontMatterProps } from "./front-matter.mjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
5
5
|
|
|
6
6
|
//#region src/markdown/components/markdown-file.d.ts
|
|
7
7
|
type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps & MarkdownFileHeaderProps;
|
|
@@ -11,7 +11,7 @@ type MarkdownFileProps = Omit<SourceFileProps$1, "filetype"> & ComponentProps &
|
|
|
11
11
|
* @param props - The properties for the source file.
|
|
12
12
|
* @returns The rendered source file component.
|
|
13
13
|
*/
|
|
14
|
-
declare function MarkdownFile(props: MarkdownFileProps):
|
|
14
|
+
declare function MarkdownFile(props: MarkdownFileProps): _alloy_js_core2.Children;
|
|
15
15
|
type MarkdownFileHeaderProps = SourceFileHeaderProps & {
|
|
16
16
|
frontMatter?: FrontMatterProps["data"];
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ type MarkdownFileHeaderProps = SourceFileHeaderProps & {
|
|
|
21
21
|
* @param props - The properties for the source file header.
|
|
22
22
|
* @returns The rendered source file header.
|
|
23
23
|
*/
|
|
24
|
-
declare function MarkdownFileHeader(props: MarkdownFileHeaderProps):
|
|
24
|
+
declare function MarkdownFileHeader(props: MarkdownFileHeaderProps): _alloy_js_core2.Children;
|
|
25
25
|
declare type __ΩMarkdownFileProps = any[];
|
|
26
26
|
declare type __ΩMarkdownFileHeaderProps = any[];
|
|
27
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-table.d.cts","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":[],"mappings":";;;UAqBiB,8CACL,sBAAsB;;EADjB,IAAA,EAAA,MAIH,CAJG;EACL,KAAA,EAAA,MAAA,GAAA,OAAA,GAAA,QAAA;EAAsB,KAAA,EAAA,MAAA;;;AAWlC;AAWA;AAMiB,cAjBJ,0BAiBiC,EAjBL,gBAiBK,CAjBY,mCAiBZ,CAAA;;;;;;AAIrC,iBAVO,sBAAA,CAAA,CAUP,EAV6B,mCAU7B,CAV6B,MAU7B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAMI,UAVI,6BAUmC,CAAA,UATxC,MASwC,CAAA,
|
|
1
|
+
{"version":3,"file":"markdown-table.d.cts","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":[],"mappings":";;;UAqBiB,8CACL,sBAAsB;;EADjB,IAAA,EAAA,MAIH,CAJG;EACL,KAAA,EAAA,MAAA,GAAA,OAAA,GAAA,QAAA;EAAsB,KAAA,EAAA,MAAA;;;AAWlC;AAWA;AAMiB,cAjBJ,0BAiBiC,EAjBL,gBAiBK,CAjBY,mCAiBZ,CAAA;;;;;;AAIrC,iBAVO,sBAAA,CAAA,CAUP,EAV6B,mCAU7B,CAV6B,MAU7B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAMI,UAVI,6BAUmC,CAAA,UATxC,MASwC,CAAA,MAAjB,EAAA,GAAA,CAAA,GATD,MASC,CAAA,MAAgB,EAAA,GAAA,CAAA,CAAA,CAAA;EAWnC,OAAA,EAlBL,mCAkBqB,CAlBe,CAkBf,CAAA,EAAA;QAjBxB;;;;;cAMK,sBAAsB,iBAAiB;;;;;;iBAWpC,gBAAA,CAAA,GAAgB,8BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-table.d.mts","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":[],"mappings":";;;UAqBiB,8CACL,sBAAsB;;EADjB,IAAA,EAAA,MAIH,CAJG;EACL,KAAA,EAAA,MAAA,GAAA,OAAA,GAAA,QAAA;EAAsB,KAAA,EAAA,MAAA;;;AAWlC;AAWA;AAMiB,cAjBJ,0BAiBiC,EAjBL,gBAiBK,CAjBY,mCAiBZ,CAAA;;;;;;AAIrC,iBAVO,sBAAA,CAAA,CAUP,EAV6B,mCAU7B,CAV6B,MAU7B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAMI,UAVI,6BAUmC,CAAA,UATxC,MASwC,CAAA,
|
|
1
|
+
{"version":3,"file":"markdown-table.d.mts","names":[],"sources":["../../../src/markdown/contexts/markdown-table.ts"],"sourcesContent":[],"mappings":";;;UAqBiB,8CACL,sBAAsB;;EADjB,IAAA,EAAA,MAIH,CAJG;EACL,KAAA,EAAA,MAAA,GAAA,OAAA,GAAA,QAAA;EAAsB,KAAA,EAAA,MAAA;;;AAWlC;AAWA;AAMiB,cAjBJ,0BAiBiC,EAjBL,gBAiBK,CAjBY,mCAiBZ,CAAA;;;;;;AAIrC,iBAVO,sBAAA,CAAA,CAUP,EAV6B,mCAU7B,CAV6B,MAU7B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,GAAA,SAAA;AAMI,UAVI,6BAUmC,CAAA,UATxC,MASwC,CAAA,MAAA,EAAjB,GAAA,CAAA,GATD,MASC,CAAA,MAAgB,EAAA,GAAA,CAAA,CAAA,CAAA;EAWnC,OAAA,EAlBL,mCAkBqB,CAlBe,CAkBf,CAAA,EAAA;QAjBxB;;;;;cAMK,sBAAsB,iBAAiB;;;;;;iBAWpC,gBAAA,CAAA,GAAgB,8BAAA"}
|
package/dist/render.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_core_components_output = require('./core/components/output.cjs');
|
|
3
|
+
require('./core/index.cjs');
|
|
2
4
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
5
|
let __alloy_js_core = require("@alloy-js/core");
|
|
4
|
-
let __powerlines_plugin_alloy_core_components_output = require("@powerlines/plugin-alloy/core/components/output");
|
|
5
6
|
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
6
7
|
|
|
7
8
|
//#region src/render.tsx
|
|
@@ -21,7 +22,7 @@ let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
|
21
22
|
*/
|
|
22
23
|
async function render(context, children) {
|
|
23
24
|
const meta = {};
|
|
24
|
-
const output = await (0, __alloy_js_core.renderAsync)((0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
25
|
+
const output = await (0, __alloy_js_core.renderAsync)((0, __alloy_js_core_jsx_runtime.createComponent)(require_core_components_output.Output, {
|
|
25
26
|
context,
|
|
26
27
|
meta,
|
|
27
28
|
children
|
|
@@ -71,7 +72,7 @@ async function render(context, children) {
|
|
|
71
72
|
* @returns The rendered output as a string.
|
|
72
73
|
*/
|
|
73
74
|
function renderString(context, children, options) {
|
|
74
|
-
return (0, __alloy_js_core.printTree)((0, __alloy_js_core.renderTree)((0, __alloy_js_core_jsx_runtime.createComponent)(
|
|
75
|
+
return (0, __alloy_js_core.printTree)((0, __alloy_js_core.renderTree)((0, __alloy_js_core_jsx_runtime.createComponent)(require_core_components_output.Output, {
|
|
75
76
|
context,
|
|
76
77
|
children
|
|
77
78
|
})), options);
|
package/dist/render.d.cts
CHANGED
package/dist/render.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"render.d.cts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA+EA;;;;;;iBA/EsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA6EJ,8BAA8B,wBACnC,oBACC,oBACA"}
|
package/dist/render.d.mts
CHANGED
package/dist/render.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.mts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"render.d.mts","names":[],"sources":["../src/render.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA4CA;;;;;;AA+EA;;;;;;iBA/EsB,wBAAwB,wBACnC,oBACC,WAAQ;;;;;;;;;;;;;;;;iBA6EJ,8BAA8B,wBACnC,oBACC,oBACA"}
|
package/dist/render.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Output as Output$1 } from "./core/components/output.mjs";
|
|
2
|
+
import "./core/index.mjs";
|
|
1
3
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
4
|
import { printTree, renderAsync, renderTree, traverseOutput } from "@alloy-js/core";
|
|
3
|
-
import { Output as Output$1 } from "@powerlines/plugin-alloy/core/components/output";
|
|
4
5
|
import { findFileExtension } from "@stryke/path/file-path-fns";
|
|
5
6
|
|
|
6
7
|
//#region src/render.tsx
|
package/dist/render.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.mjs","names":["printTree","renderAsync","renderTree","traverseOutput","
|
|
1
|
+
{"version":3,"file":"render.mjs","names":["printTree","renderAsync","renderTree","traverseOutput","findFileExtension","Output","render","context","children","meta","output","_$createComponent","Object","keys","length","debug","visitDirectory","directory","fs","existsSync","path","mkdirSync","visitFile","file","metadata","kind","id","Error","emitBuiltinSync","contents","skipFormat","storage","extension","emitEntrySync","typeDefinition","emitSync","copySync","sourcePath","renderString","options","tree"],"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 {\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,7 +1,6 @@
|
|
|
1
1
|
import { Children, Context } from "@alloy-js/core";
|
|
2
|
-
import { StoragePreset } from "powerlines
|
|
2
|
+
import { ResolvedEntryTypeDefinition, StoragePreset } from "powerlines";
|
|
3
3
|
import { SourceFileContext } from "@alloy-js/typescript";
|
|
4
|
-
import { ResolvedEntryTypeDefinition } from "powerlines/types/resolved";
|
|
5
4
|
|
|
6
5
|
//#region src/types/components.d.ts
|
|
7
6
|
interface CopyOutputFile {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.cts","names":[],"sources":["../../src/types/components.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.d.cts","names":[],"sources":["../../src/types/components.ts"],"sourcesContent":[],"mappings":";;;;;UAsBiB,cAAA;;EAAA,IAAA,EAAA,MAAA;EAcA,UAAA,EAAA,MAAe;EAepB;;;;;;EAOM,MAAA,CAAA,EAzBP,aAyBO;AAElB;AAMiB,UA9BA,eAAA,CA8BkB;EAIlB,IAAA,EAAA,MAAA,GAAA,OAAA,GAAoB,SAAA;EAIpB,IAAA,EAAA,MAAA;EAIA,QAAA,EAAA,MAAA;EAKA,QAAA,EAAA,MAAc;EAEhB;;;;;;EAF+B,MAAA,CAAA,EAnCnC,aAmCmC;AAwB9C;AAOY,KA/DA,UAAA,GA+DA,CA9DP,eA8DiC,GAAA;EAAQ,IAAA,EAAA,MAAA;CAAL,CAAA,GAAA,CA7DpC,eA6DoC,GAAA;EACzB,IAAA,EAAA,OAAA;EAAL,cAAA,CAAA,EA5DY,2BA4DZ;CAAT,CAAA,GAAA,CA1DG,eA0DH,GAAA;EAAQ,IAAA,EAAA,SAAA;EAEO,EAAA,EAAA,MAAA;AAOjB,CAAA,CAAA,GAlEI,cAkEa;AACC,UAjED,eAAA,CAiEC;EACA,IAAA,EAAA,WAAA;EAEO,IAAA,EAAA,MAAA;EAAR,QAAA,EAAA,CAjEJ,eAiEI,GAjEc,UAiEd,CAAA,EAAA;;AAGA,UAjEA,kBAAA,CAiEwB;EAO7B,cAAA,EAvEM,2BAuEe;;AAEf,UAtED,oBAAA,CAsEC;EAFkB,EAAA,EAAA,MAAA;;AAKnB,UArEA,mBAAA,CAqEsB;SApE9B;;UAGQ,qBAAA;;;;UAKA,aAAA,SAAsB;;eAExB;;;;cAKD;;;;YAKF;;;;aAKC;MACP;;;;;UAMW,cAAA;aACJ;;;;;KAMD,0BAAA,GAA6B,KAAK,8BAC5C,SAAS,KAAK;UAEC,wBAAA,SAAiC;;;;;;UAOjC;kBACC;kBACA;;iBAED,QAAQ;;UAGR,wBAAA;;;;;;KAOL,qBAAA,GAAwB,+BAElB,MAAM;UAGP,qBAAA,SAA8B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Children, Context } from "@alloy-js/core";
|
|
2
2
|
import { SourceFileContext as SourceFileContext$1 } from "@alloy-js/typescript";
|
|
3
|
-
import { StoragePreset } from "powerlines
|
|
4
|
-
import { ResolvedEntryTypeDefinition } from "powerlines/types/resolved";
|
|
3
|
+
import { ResolvedEntryTypeDefinition, StoragePreset } from "powerlines";
|
|
5
4
|
|
|
6
5
|
//#region src/types/components.d.ts
|
|
7
6
|
interface CopyOutputFile {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.mts","names":[],"sources":["../../src/types/components.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.d.mts","names":[],"sources":["../../src/types/components.ts"],"sourcesContent":[],"mappings":";;;;;UAsBiB,cAAA;;EAAA,IAAA,EAAA,MAAA;EAcA,UAAA,EAAA,MAAe;EAepB;;;;;;EAOM,MAAA,CAAA,EAzBP,aAyBO;AAElB;AAMiB,UA9BA,eAAA,CA8BkB;EAIlB,IAAA,EAAA,MAAA,GAAA,OAAA,GAAoB,SAAA;EAIpB,IAAA,EAAA,MAAA;EAIA,QAAA,EAAA,MAAA;EAKA,QAAA,EAAA,MAAc;EAEhB;;;;;;EAF+B,MAAA,CAAA,EAnCnC,aAmCmC;AAwB9C;AAOY,KA/DA,UAAA,GA+DA,CA9DP,eA8DiC,GAAA;EAAQ,IAAA,EAAA,MAAA;CAAL,CAAA,GAAA,CA7DpC,eA6DoC,GAAA;EACzB,IAAA,EAAA,OAAA;EAAL,cAAA,CAAA,EA5DY,2BA4DZ;CAAT,CAAA,GAAA,CA1DG,eA0DH,GAAA;EAAQ,IAAA,EAAA,SAAA;EAEO,EAAA,EAAA,MAAA;AAOjB,CAAA,CAAA,GAlEI,cAkEa;AACC,UAjED,eAAA,CAiEC;EACA,IAAA,EAAA,WAAA;EAEO,IAAA,EAAA,MAAA;EAAR,QAAA,EAAA,CAjEJ,eAiEI,GAjEc,UAiEd,CAAA,EAAA;;AAGA,UAjEA,kBAAA,CAiEwB;EAO7B,cAAA,EAvEM,2BAuEe;;AAEf,UAtED,oBAAA,CAsEC;EAFkB,EAAA,EAAA,MAAA;;AAKnB,UArEA,mBAAA,CAqEsB;SApE9B;;UAGQ,qBAAA;;;;UAKA,aAAA,SAAsB;;eAExB;;;;cAKD;;;;YAKF;;;;aAKC;MACP;;;;;UAMW,cAAA;aACJ;;;;;KAMD,0BAAA,GAA6B,KAAK,8BAC5C,SAAS,KAAK;UAEC,wBAAA,SAAiC;;;;;;UAOjC;kBACC;kBACA;;iBAED,QAAQ;;UAGR,wBAAA;;;;;;KAOL,qBAAA,GAAwB,+BAElB,MAAM;UAGP,qBAAA,SAA8B"}
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrintTreeOptions } from "@alloy-js/core";
|
|
2
|
-
import { PluginContext } from "powerlines
|
|
2
|
+
import { PluginContext } from "powerlines";
|
|
3
3
|
import { BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types/plugin";
|
|
4
4
|
|
|
5
5
|
//#region src/types/plugin.d.ts
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrintTreeOptions } from "@alloy-js/core";
|
|
2
|
-
import { PluginContext } from "powerlines
|
|
2
|
+
import { PluginContext } from "powerlines";
|
|
3
3
|
import { BabelPluginResolvedConfig, BabelPluginUserConfig } from "@powerlines/plugin-babel/types/plugin";
|
|
4
4
|
|
|
5
5
|
//#region src/types/plugin.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TSDocModuleProps } from "./tsdoc.cjs";
|
|
2
2
|
import { TypescriptFileProps } from "./typescript-file.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alloy_js_core20 from "@alloy-js/core";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/builtin-file.d.ts
|
|
6
6
|
type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
|
|
@@ -28,7 +28,7 @@ type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProp
|
|
|
28
28
|
* @param props - The properties for the source file.
|
|
29
29
|
* @returns The rendered source file component.
|
|
30
30
|
*/
|
|
31
|
-
declare function BuiltinFile(props: BuiltinFileProps):
|
|
31
|
+
declare function BuiltinFile(props: BuiltinFileProps): _alloy_js_core20.Children;
|
|
32
32
|
declare type __ΩBuiltinFileProps = any[];
|
|
33
33
|
//#endregion
|
|
34
34
|
export { BuiltinFile, BuiltinFileProps, __ΩBuiltinFileProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core19 from "@alloy-js/core";
|
|
2
2
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/components/dynamic-import-statement.d.ts
|
|
@@ -26,7 +26,7 @@ interface DynamicImportStatementProps extends Omit<VarDeclarationProps, "initial
|
|
|
26
26
|
* @param props - The properties for the dynamic import statement.
|
|
27
27
|
* @returns A `VarDeclaration` component representing the dynamic import statement.
|
|
28
28
|
*/
|
|
29
|
-
declare function DynamicImportStatement(props: DynamicImportStatementProps):
|
|
29
|
+
declare function DynamicImportStatement(props: DynamicImportStatementProps): _alloy_js_core19.Children;
|
|
30
30
|
declare type __ΩDynamicImportStatementProps = any[];
|
|
31
31
|
//#endregion
|
|
32
32
|
export { DynamicImportStatement, DynamicImportStatementProps, __ΩDynamicImportStatementProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core18 from "@alloy-js/core";
|
|
2
2
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/components/dynamic-import-statement.d.ts
|
|
@@ -26,7 +26,7 @@ interface DynamicImportStatementProps extends Omit<VarDeclarationProps, "initial
|
|
|
26
26
|
* @param props - The properties for the dynamic import statement.
|
|
27
27
|
* @returns A `VarDeclaration` component representing the dynamic import statement.
|
|
28
28
|
*/
|
|
29
|
-
declare function DynamicImportStatement(props: DynamicImportStatementProps):
|
|
29
|
+
declare function DynamicImportStatement(props: DynamicImportStatementProps): _alloy_js_core18.Children;
|
|
30
30
|
declare type __ΩDynamicImportStatementProps = any[];
|
|
31
31
|
//#endregion
|
|
32
32
|
export { DynamicImportStatement, DynamicImportStatementProps, __ΩDynamicImportStatementProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypescriptFileProps } from "./typescript-file.cjs";
|
|
2
|
-
import * as
|
|
3
|
-
import { ResolvedEntryTypeDefinition } from "powerlines
|
|
2
|
+
import * as _alloy_js_core18 from "@alloy-js/core";
|
|
3
|
+
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/entry-file.d.ts
|
|
6
6
|
type EntryFileProps = TypescriptFileProps & {
|
|
@@ -21,7 +21,7 @@ type EntryFileProps = TypescriptFileProps & {
|
|
|
21
21
|
* @param props - The properties for the source file.
|
|
22
22
|
* @returns The rendered source file component.
|
|
23
23
|
*/
|
|
24
|
-
declare function EntryFile(props: EntryFileProps):
|
|
24
|
+
declare function EntryFile(props: EntryFileProps): _alloy_js_core18.Children;
|
|
25
25
|
declare type __ΩEntryFileProps = any[];
|
|
26
26
|
//#endregion
|
|
27
27
|
export { EntryFile, EntryFileProps, __ΩEntryFileProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypescriptFileProps } from "./typescript-file.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import { ResolvedEntryTypeDefinition } from "powerlines
|
|
2
|
+
import * as _alloy_js_core19 from "@alloy-js/core";
|
|
3
|
+
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/entry-file.d.ts
|
|
6
6
|
type EntryFileProps = TypescriptFileProps & {
|
|
@@ -21,7 +21,7 @@ type EntryFileProps = TypescriptFileProps & {
|
|
|
21
21
|
* @param props - The properties for the source file.
|
|
22
22
|
* @returns The rendered source file component.
|
|
23
23
|
*/
|
|
24
|
-
declare function EntryFile(props: EntryFileProps):
|
|
24
|
+
declare function EntryFile(props: EntryFileProps): _alloy_js_core19.Children;
|
|
25
25
|
declare type __ΩEntryFileProps = any[];
|
|
26
26
|
//#endregion
|
|
27
27
|
export { EntryFile, EntryFileProps, __ΩEntryFileProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-file.mjs","names":["computed","splitProps","appendPath","hasFileExtension","replaceExtension","replacePath","isSet","defu","usePowerlinesSafe","TypescriptFile","EntryFile","props","children","meta","tsx","path","typeDefinition","rest","context","fullPath","entryPath","workspaceConfig","workspaceRoot","_$createComponent","_$mergeProps","value","kind"],"sources":["../../../src/typescript/components/entry-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 { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport defu from \"defu\";\nimport { ResolvedEntryTypeDefinition } from \"powerlines
|
|
1
|
+
{"version":3,"file":"entry-file.mjs","names":["computed","splitProps","appendPath","hasFileExtension","replaceExtension","replacePath","isSet","defu","usePowerlinesSafe","TypescriptFile","EntryFile","props","children","meta","tsx","path","typeDefinition","rest","context","fullPath","entryPath","workspaceConfig","workspaceRoot","_$createComponent","_$mergeProps","value","kind"],"sources":["../../../src/typescript/components/entry-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 { appendPath } from \"@stryke/path/append\";\nimport { hasFileExtension } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport defu from \"defu\";\nimport { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { TypescriptFile, TypescriptFileProps } from \"./typescript-file\";\n\nexport type EntryFileProps = TypescriptFileProps & {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n\n /**\n * Render metadata information about the entrypoint\n */\n typeDefinition?: ResolvedEntryTypeDefinition;\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 EntryFile(props: EntryFileProps) {\n const [{ children, meta, tsx, path, typeDefinition }, rest] = splitProps(\n props,\n [\"children\", \"meta\", \"tsx\", \"path\", \"typeDefinition\"]\n );\n\n const context = usePowerlinesSafe();\n const fullPath = computed(() =>\n context\n ? appendPath(\n `${\n !isSet(tsx) ? path : replaceExtension(path)\n }${tsx ? \".tsx\" : hasFileExtension(path) ? \"\" : \".ts\"}`,\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n )\n : path\n );\n\n return (\n <TypescriptFile\n {...rest}\n path={fullPath.value}\n meta={defu(\n {\n kind: \"entry\"\n },\n meta ?? {},\n {\n typeDefinition\n }\n )}>\n {children}\n </TypescriptFile>\n );\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core17 from "@alloy-js/core";
|
|
3
3
|
import { Children, Namekey, Refkey } from "@alloy-js/core";
|
|
4
4
|
import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
5
5
|
import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
|
|
@@ -35,7 +35,7 @@ interface InterfaceDeclarationPropertyProps extends Omit<InterfaceMemberProps, "
|
|
|
35
35
|
interface InterfaceExpressionProps {
|
|
36
36
|
children?: Children;
|
|
37
37
|
}
|
|
38
|
-
declare const InterfaceExpression:
|
|
38
|
+
declare const InterfaceExpression: _alloy_js_core17.Component<InterfaceExpressionProps>;
|
|
39
39
|
interface InterfaceMemberPropsBase {
|
|
40
40
|
type?: Children;
|
|
41
41
|
children?: Children;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core15 from "@alloy-js/core";
|
|
3
3
|
import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
4
4
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
5
5
|
|
|
@@ -17,11 +17,11 @@ interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* Generates a TypeScript object for the given reflection class.
|
|
19
19
|
*/
|
|
20
|
-
declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>):
|
|
20
|
+
declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>): _alloy_js_core15.Children;
|
|
21
21
|
/**
|
|
22
22
|
* Generates a TypeScript object property for the given reflection class.
|
|
23
23
|
*/
|
|
24
|
-
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps):
|
|
24
|
+
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): _alloy_js_core15.Children;
|
|
25
25
|
declare type __ΩComputedRef = any[];
|
|
26
26
|
declare type __ΩObjectDeclarationProps = any[];
|
|
27
27
|
declare type __ΩObjectDeclarationPropertyProps = any[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core15 from "@alloy-js/core";
|
|
3
3
|
import { ReflectionClass, ReflectionProperty } from "@powerlines/deepkit/vendor/type";
|
|
4
4
|
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
5
5
|
|
|
@@ -17,11 +17,11 @@ interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* Generates a TypeScript object for the given reflection class.
|
|
19
19
|
*/
|
|
20
|
-
declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>):
|
|
20
|
+
declare function ObjectDeclaration<T extends Record<string, any> = Record<string, any>>(props: ObjectDeclarationProps<T>): _alloy_js_core15.Children;
|
|
21
21
|
/**
|
|
22
22
|
* Generates a TypeScript object property for the given reflection class.
|
|
23
23
|
*/
|
|
24
|
-
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps):
|
|
24
|
+
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): _alloy_js_core15.Children;
|
|
25
25
|
declare type __ΩComputedRef = any[];
|
|
26
26
|
declare type __ΩObjectDeclarationProps = any[];
|
|
27
27
|
declare type __ΩObjectDeclarationPropertyProps = any[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core14 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/typescript/components/property-name.d.ts
|
|
4
4
|
interface PropertyNameProps {
|
|
@@ -17,7 +17,7 @@ interface PropertyNameProps {
|
|
|
17
17
|
* @remarks
|
|
18
18
|
* If the name is not a valid JavaScript identifier, it will be quoted. If a `name` prop is provided, it will be used as the property name. Otherwise, the name will be taken from the {@link (MemberDeclarationContext:variable)}.
|
|
19
19
|
*/
|
|
20
|
-
declare function PropertyName(props: PropertyNameProps):
|
|
20
|
+
declare function PropertyName(props: PropertyNameProps): _alloy_js_core14.Children;
|
|
21
21
|
declare type __ΩPropertyNameProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { PropertyName, PropertyNameProps, __ΩPropertyNameProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core14 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/typescript/components/property-name.d.ts
|
|
4
4
|
interface PropertyNameProps {
|
|
@@ -17,7 +17,7 @@ interface PropertyNameProps {
|
|
|
17
17
|
* @remarks
|
|
18
18
|
* If the name is not a valid JavaScript identifier, it will be quoted. If a `name` prop is provided, it will be used as the property name. Otherwise, the name will be taken from the {@link (MemberDeclarationContext:variable)}.
|
|
19
19
|
*/
|
|
20
|
-
declare function PropertyName(props: PropertyNameProps):
|
|
20
|
+
declare function PropertyName(props: PropertyNameProps): _alloy_js_core14.Children;
|
|
21
21
|
declare type __ΩPropertyNameProps = any[];
|
|
22
22
|
//#endregion
|
|
23
23
|
export { PropertyName, PropertyNameProps, __ΩPropertyNameProps };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { TSDocProps } from "./tsdoc.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alloy_js_core11 from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/components/tsdoc-reflection.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Generates a TypeScript interface property for the given reflection class.
|
|
7
7
|
*/
|
|
8
|
-
declare function TSDocReflectionClass<T extends Record<string, any> = Record<string, any>>(props: TSDocProps):
|
|
8
|
+
declare function TSDocReflectionClass<T extends Record<string, any> = Record<string, any>>(props: TSDocProps): _alloy_js_core11.Children;
|
|
9
9
|
/**
|
|
10
10
|
* Generates a TypeScript interface property for the given reflection class.
|
|
11
11
|
*/
|
|
12
|
-
declare function TSDocReflectionProperty(props: TSDocProps):
|
|
12
|
+
declare function TSDocReflectionProperty(props: TSDocProps): _alloy_js_core11.Children;
|
|
13
13
|
/**
|
|
14
14
|
* Generates a TypeScript interface property for the given reflection class.
|
|
15
15
|
*/
|
|
16
|
-
declare function TSDocReflectionMethod(props: TSDocProps):
|
|
16
|
+
declare function TSDocReflectionMethod(props: TSDocProps): _alloy_js_core11.Children;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { TSDocReflectionClass, TSDocReflectionMethod, TSDocReflectionProperty };
|
|
19
19
|
//# sourceMappingURL=tsdoc-reflection.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc-reflection.d.cts","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCgB,iBAAA,oBAAoB,CAAA,UACxB,MADwB,CAAA,MAAA,EAAA,GAAA,CAAA,GACF,MADE,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAE3B,UAF2B,CAAA,EAEjB,
|
|
1
|
+
{"version":3,"file":"tsdoc-reflection.d.cts","names":[],"sources":["../../../src/typescript/components/tsdoc-reflection.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCgB,iBAAA,oBAAoB,CAAA,UACxB,MADwB,CAAA,MAAA,EAAA,GAAA,CAAA,GACF,MADE,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA,KAAA,EAE3B,UAF2B,CAAA,EAEjB,gBAAA,CAAA,QAFiB;;;;AAEjB,iBAyEH,uBAAA,CAzEG,KAAA,EAyE4B,UAzE5B,CAAA,EAyEsC,gBAAA,CAAA,QAzEtC;;AAyEnB;AA8BA;iBAAgB,qBAAA,QAA6B,aAAU,gBAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core10 from "@alloy-js/core";
|
|
2
2
|
import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/components/type-declaration.d.ts
|
|
@@ -11,7 +11,7 @@ interface TypeDeclarationProps extends CommonDeclarationProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.
|
|
13
13
|
*/
|
|
14
|
-
declare const TypeDeclaration:
|
|
14
|
+
declare const TypeDeclaration: _alloy_js_core10.Component<TypeDeclarationProps>;
|
|
15
15
|
declare type __ΩTypeDeclarationProps = any[];
|
|
16
16
|
//#endregion
|
|
17
17
|
export { TypeDeclaration, TypeDeclarationProps, __ΩTypeDeclarationProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core9 from "@alloy-js/core";
|
|
2
2
|
import { CommonDeclarationProps, TypeParameterDescriptor } from "@alloy-js/typescript";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/components/type-declaration.d.ts
|
|
@@ -11,7 +11,7 @@ interface TypeDeclarationProps extends CommonDeclarationProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.
|
|
13
13
|
*/
|
|
14
|
-
declare const TypeDeclaration:
|
|
14
|
+
declare const TypeDeclaration: _alloy_js_core9.Component<TypeDeclarationProps>;
|
|
15
15
|
declare type __ΩTypeDeclarationProps = any[];
|
|
16
16
|
//#endregion
|
|
17
17
|
export { TypeDeclaration, TypeDeclarationProps, __ΩTypeDeclarationProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/type-declaration.tsx"],"sourcesContent":[],"mappings":";;;;UA4BiB,oBAAA,SAA6B;;;AAA9C;EAUa,cAAA,CAAA,EANM,uBAMS,EAAA,GAAA,MAAA,EAAA;;;;;cAAf,iBAAe,
|
|
1
|
+
{"version":3,"file":"type-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/type-declaration.tsx"],"sourcesContent":[],"mappings":";;;;UA4BiB,oBAAA,SAA6B;;;AAA9C;EAUa,cAAA,CAAA,EANM,uBAMS,EAAA,GAAA,MAAA,EAAA;;;;;cAAf,iBAAe,eAAA,CAAA,UAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core8 from "@alloy-js/core";
|
|
2
2
|
import { ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/contexts/lexical-scope.d.ts
|
|
@@ -8,7 +8,7 @@ type LexicalScopeProps = LexicalScopePropsWithScopeValue | LexicalScopePropsWith
|
|
|
8
8
|
/**
|
|
9
9
|
* A lexical scope for TypeScript, which contains declaration spaces for types and values. Declaration components will create symbols in this scope.
|
|
10
10
|
*/
|
|
11
|
-
declare function LexicalScope(props: LexicalScopeProps):
|
|
11
|
+
declare function LexicalScope(props: LexicalScopeProps): _alloy_js_core8.Children;
|
|
12
12
|
declare type __ΩLexicalScopePropsWithScopeValue = any[];
|
|
13
13
|
declare type __ΩLexicalScopePropsWithScopeInfo = any[];
|
|
14
14
|
declare type __ΩLexicalScopeProps = any[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core10 from "@alloy-js/core";
|
|
2
2
|
import { ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
3
3
|
|
|
4
4
|
//#region src/typescript/contexts/lexical-scope.d.ts
|
|
@@ -8,7 +8,7 @@ type LexicalScopeProps = LexicalScopePropsWithScopeValue | LexicalScopePropsWith
|
|
|
8
8
|
/**
|
|
9
9
|
* A lexical scope for TypeScript, which contains declaration spaces for types and values. Declaration components will create symbols in this scope.
|
|
10
10
|
*/
|
|
11
|
-
declare function LexicalScope(props: LexicalScopeProps):
|
|
11
|
+
declare function LexicalScope(props: LexicalScopeProps): _alloy_js_core10.Children;
|
|
12
12
|
declare type __ΩLexicalScopePropsWithScopeValue = any[];
|
|
13
13
|
declare type __ΩLexicalScopePropsWithScopeInfo = any[];
|
|
14
14
|
declare type __ΩLexicalScopeProps = any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-scope.d.mts","names":[],"sources":["../../../src/typescript/contexts/lexical-scope.tsx"],"sourcesContent":[],"mappings":";;;;UAqBiB,+BAAA,SAAwC;UACxC,8BAAA,SAAuC,oBADxD;AACiB,KAEL,iBAAA,GACR,+BAHoD,GAIpD,8BAJsE;AAE1E;AAOA;;iBAAgB,YAAA,QAAoB,oBAAiB,
|
|
1
|
+
{"version":3,"file":"lexical-scope.d.mts","names":[],"sources":["../../../src/typescript/contexts/lexical-scope.tsx"],"sourcesContent":[],"mappings":";;;;UAqBiB,+BAAA,SAAwC;UACxC,8BAAA,SAAuC,oBADxD;AACiB,KAEL,iBAAA,GACR,+BAHoD,GAIpD,8BAJsE;AAE1E;AAOA;;iBAAgB,YAAA,QAAoB,oBAAiB,gBAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-alloy",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various Alloy framework components and helper utilities.",
|
|
6
6
|
"repository": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"default": "./dist/index.mjs"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
+
"./*": "./*",
|
|
58
59
|
"./core": {
|
|
59
60
|
"require": {
|
|
60
61
|
"types": "./dist/core/index.d.cts",
|
|
@@ -391,7 +392,6 @@
|
|
|
391
392
|
"default": "./dist/markdown/contexts/markdown-table.mjs"
|
|
392
393
|
}
|
|
393
394
|
},
|
|
394
|
-
"./package.json": "./package.json",
|
|
395
395
|
"./render": {
|
|
396
396
|
"require": {
|
|
397
397
|
"types": "./dist/render.d.cts",
|
|
@@ -754,9 +754,9 @@
|
|
|
754
754
|
"@alloy-js/markdown": "0.23.0-dev.1",
|
|
755
755
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
756
756
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
757
|
-
"@powerlines/deepkit": "^0.6.
|
|
758
|
-
"@powerlines/plugin-babel": "^0.12.
|
|
759
|
-
"@storm-software/config-tools": "^1.189.
|
|
757
|
+
"@powerlines/deepkit": "^0.6.71",
|
|
758
|
+
"@powerlines/plugin-babel": "^0.12.300",
|
|
759
|
+
"@storm-software/config-tools": "^1.189.10",
|
|
760
760
|
"@stryke/capnp": "^0.12.68",
|
|
761
761
|
"@stryke/convert": "^0.6.40",
|
|
762
762
|
"@stryke/fs": "^0.33.43",
|
|
@@ -768,14 +768,14 @@
|
|
|
768
768
|
"@stryke/types": "^0.10.39",
|
|
769
769
|
"@stryke/unique-id": "^0.3.54",
|
|
770
770
|
"defu": "^6.1.4",
|
|
771
|
-
"powerlines": "^0.
|
|
771
|
+
"powerlines": "^0.39.0",
|
|
772
772
|
"prettier": "^3.8.1",
|
|
773
773
|
"unctx": "^2.5.0"
|
|
774
774
|
},
|
|
775
775
|
"devDependencies": {
|
|
776
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
777
|
-
"@types/node": "^25.3.
|
|
776
|
+
"@powerlines/plugin-plugin": "^0.12.242",
|
|
777
|
+
"@types/node": "^25.3.2"
|
|
778
778
|
},
|
|
779
779
|
"publishConfig": { "access": "public" },
|
|
780
|
-
"gitHead": "
|
|
780
|
+
"gitHead": "0dcb16f054b8a69915b074578e6d4dfa3ecc1529"
|
|
781
781
|
}
|