@powerlines/plugin-alloy 0.25.49 → 0.25.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/core/components/index.cjs +10 -0
- package/dist/core/components/index.d.cts +5 -0
- package/dist/core/components/index.d.mts +5 -0
- package/dist/core/components/index.mjs +6 -0
- package/dist/core/components/output.cjs +41 -0
- package/dist/core/components/output.d.cts +24 -0
- package/dist/core/components/output.d.cts.map +1 -0
- package/dist/core/components/output.d.mts +24 -0
- package/dist/core/components/output.d.mts.map +1 -0
- package/dist/core/components/output.mjs +40 -0
- package/dist/core/components/output.mjs.map +1 -0
- package/dist/core/components/single-line-comment.cjs +23 -0
- package/dist/core/components/single-line-comment.d.cts +23 -0
- package/dist/core/components/single-line-comment.d.cts.map +1 -0
- package/dist/core/components/single-line-comment.d.mts +23 -0
- package/dist/core/components/single-line-comment.d.mts.map +1 -0
- package/dist/core/components/single-line-comment.mjs +22 -0
- package/dist/core/components/single-line-comment.mjs.map +1 -0
- package/dist/core/components/source-file.cjs +64 -0
- package/dist/core/components/source-file.d.cts +33 -0
- package/dist/core/components/source-file.d.cts.map +1 -0
- package/dist/core/components/source-file.d.mts +33 -0
- package/dist/core/components/source-file.d.mts.map +1 -0
- package/dist/core/components/source-file.mjs +62 -0
- package/dist/core/components/source-file.mjs.map +1 -0
- package/dist/core/components/spacing.cjs +20 -0
- package/dist/core/components/spacing.d.cts +24 -0
- package/dist/core/components/spacing.d.cts.map +1 -0
- package/dist/core/components/spacing.d.mts +24 -0
- package/dist/core/components/spacing.d.mts.map +1 -0
- package/dist/core/components/spacing.mjs +19 -0
- package/dist/core/components/spacing.mjs.map +1 -0
- package/dist/core/contexts/context.cjs +41 -0
- package/dist/core/contexts/context.d.cts +29 -0
- package/dist/core/contexts/context.d.cts.map +1 -0
- package/dist/core/contexts/context.d.mts +29 -0
- package/dist/core/contexts/context.d.mts.map +1 -0
- package/dist/core/contexts/context.mjs +37 -0
- package/dist/core/contexts/context.mjs.map +1 -0
- package/dist/core/contexts/index.cjs +21 -0
- package/dist/core/contexts/index.d.cts +4 -0
- package/dist/core/contexts/index.d.mts +4 -0
- package/dist/core/contexts/index.mjs +5 -0
- package/dist/core/contexts/meta.cjs +41 -0
- package/dist/core/contexts/meta.d.cts +48 -0
- package/dist/core/contexts/meta.d.cts.map +1 -0
- package/dist/core/contexts/meta.d.mts +48 -0
- package/dist/core/contexts/meta.d.mts.map +1 -0
- package/dist/core/contexts/meta.mjs +37 -0
- package/dist/core/contexts/meta.mjs.map +1 -0
- package/dist/core/contexts/reflection.cjs +69 -0
- package/dist/core/contexts/reflection.d.cts +53 -0
- package/dist/core/contexts/reflection.d.cts.map +1 -0
- package/dist/core/contexts/reflection.d.mts +53 -0
- package/dist/core/contexts/reflection.d.mts.map +1 -0
- package/dist/core/contexts/reflection.mjs +61 -0
- package/dist/core/contexts/reflection.mjs.map +1 -0
- package/dist/core/helpers/code.cjs +34 -0
- package/dist/core/helpers/code.d.cts +29 -0
- package/dist/core/helpers/code.d.cts.map +1 -0
- package/dist/core/helpers/code.d.mts +29 -0
- package/dist/core/helpers/code.d.mts.map +1 -0
- package/dist/core/helpers/code.mjs +33 -0
- package/dist/core/helpers/code.mjs.map +1 -0
- package/dist/core/helpers/index.cjs +4 -0
- package/dist/core/helpers/index.d.cts +2 -0
- package/dist/core/helpers/index.d.mts +2 -0
- package/dist/core/helpers/index.mjs +3 -0
- package/dist/core/index.cjs +34 -0
- package/dist/core/index.d.cts +9 -0
- package/dist/core/index.d.mts +9 -0
- package/dist/core/index.mjs +13 -0
- package/dist/helpers/capnp.cjs +277 -0
- package/dist/helpers/capnp.d.cts +87 -0
- package/dist/helpers/capnp.d.cts.map +1 -0
- package/dist/helpers/capnp.d.mts +87 -0
- package/dist/helpers/capnp.d.mts.map +1 -0
- package/dist/helpers/capnp.mjs +260 -0
- package/dist/helpers/capnp.mjs.map +1 -0
- package/dist/helpers/create-builtin.cjs +20 -0
- package/dist/helpers/create-builtin.d.cts +16 -0
- package/dist/helpers/create-builtin.d.cts.map +1 -0
- package/dist/helpers/create-builtin.d.mts +16 -0
- package/dist/helpers/create-builtin.d.mts.map +1 -0
- package/dist/helpers/create-builtin.mjs +19 -0
- package/dist/helpers/create-builtin.mjs.map +1 -0
- package/dist/helpers/index.cjs +25 -0
- package/dist/helpers/index.d.cts +5 -0
- package/dist/helpers/index.d.mts +5 -0
- package/dist/helpers/index.mjs +6 -0
- package/dist/helpers/refkey.cjs +17 -0
- package/dist/helpers/refkey.d.cts +13 -0
- package/dist/helpers/refkey.d.cts.map +1 -0
- package/dist/helpers/refkey.d.mts +13 -0
- package/dist/helpers/refkey.d.mts.map +1 -0
- package/dist/helpers/refkey.mjs +16 -0
- package/dist/helpers/refkey.mjs.map +1 -0
- package/dist/helpers/typescript.cjs +47 -0
- package/dist/helpers/typescript.d.cts +26 -0
- package/dist/helpers/typescript.d.cts.map +1 -0
- package/dist/helpers/typescript.d.mts +26 -0
- package/dist/helpers/typescript.d.mts.map +1 -0
- package/dist/helpers/typescript.mjs +46 -0
- package/dist/helpers/typescript.mjs.map +1 -0
- package/dist/index.cjs +48 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/markdown/components/front-matter.cjs +29 -0
- package/dist/markdown/components/front-matter.d.cts +16 -0
- package/dist/markdown/components/front-matter.d.cts.map +1 -0
- package/dist/markdown/components/front-matter.d.mts +16 -0
- package/dist/markdown/components/front-matter.d.mts.map +1 -0
- package/dist/markdown/components/front-matter.mjs +28 -0
- package/dist/markdown/components/front-matter.mjs.map +1 -0
- package/dist/markdown/components/index.cjs +11 -0
- package/dist/markdown/components/index.d.cts +4 -0
- package/dist/markdown/components/index.d.mts +4 -0
- package/dist/markdown/components/index.mjs +5 -0
- package/dist/markdown/components/markdown-file.cjs +135 -0
- package/dist/markdown/components/markdown-file.d.cts +29 -0
- package/dist/markdown/components/markdown-file.d.cts.map +1 -0
- package/dist/markdown/components/markdown-file.d.mts +29 -0
- package/dist/markdown/components/markdown-file.d.mts.map +1 -0
- package/dist/markdown/components/markdown-file.mjs +133 -0
- package/dist/markdown/components/markdown-file.mjs.map +1 -0
- package/dist/markdown/components/markdown-table.cjs +102 -0
- package/dist/markdown/components/markdown-table.d.cts +28 -0
- package/dist/markdown/components/markdown-table.d.cts.map +1 -0
- package/dist/markdown/components/markdown-table.d.mts +28 -0
- package/dist/markdown/components/markdown-table.d.mts.map +1 -0
- package/dist/markdown/components/markdown-table.mjs +99 -0
- package/dist/markdown/components/markdown-table.mjs.map +1 -0
- package/dist/markdown/contexts/index.cjs +7 -0
- package/dist/markdown/contexts/index.d.cts +2 -0
- package/dist/markdown/contexts/index.d.mts +2 -0
- package/dist/markdown/contexts/index.mjs +3 -0
- package/dist/markdown/contexts/markdown-table.cjs +38 -0
- package/dist/markdown/contexts/markdown-table.d.cts +38 -0
- package/dist/markdown/contexts/markdown-table.d.cts.map +1 -0
- package/dist/markdown/contexts/markdown-table.d.mts +38 -0
- package/dist/markdown/contexts/markdown-table.d.mts.map +1 -0
- package/dist/markdown/contexts/markdown-table.mjs +34 -0
- package/dist/markdown/contexts/markdown-table.mjs.map +1 -0
- package/dist/markdown/index.cjs +18 -0
- package/dist/markdown/index.d.cts +5 -0
- package/dist/markdown/index.d.mts +5 -0
- package/dist/markdown/index.mjs +8 -0
- package/dist/render.cjs +91 -0
- package/dist/render.d.cts +38 -0
- package/dist/render.d.cts.map +1 -0
- package/dist/render.d.mts +38 -0
- package/dist/render.d.mts.map +1 -0
- package/dist/render.mjs +89 -0
- package/dist/render.mjs.map +1 -0
- package/dist/types/components.cjs +0 -0
- package/dist/types/components.d.cts +142 -0
- package/dist/types/components.d.cts.map +1 -0
- package/dist/types/components.d.mts +142 -0
- package/dist/types/components.d.mts.map +1 -0
- package/dist/types/components.mjs +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +39 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +39 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +1 -0
- package/dist/typescript/components/builtin-file.cjs +63 -0
- package/dist/typescript/components/builtin-file.d.cts +35 -0
- package/dist/typescript/components/builtin-file.d.cts.map +1 -0
- package/dist/typescript/components/builtin-file.d.mts +35 -0
- package/dist/typescript/components/builtin-file.d.mts.map +1 -0
- package/dist/typescript/components/builtin-file.mjs +62 -0
- package/dist/typescript/components/builtin-file.mjs.map +1 -0
- package/dist/typescript/components/class-declaration.cjs +291 -0
- package/dist/typescript/components/class-declaration.d.cts +145 -0
- package/dist/typescript/components/class-declaration.d.cts.map +1 -0
- package/dist/typescript/components/class-declaration.d.mts +145 -0
- package/dist/typescript/components/class-declaration.d.mts.map +1 -0
- package/dist/typescript/components/class-declaration.mjs +285 -0
- package/dist/typescript/components/class-declaration.mjs.map +1 -0
- package/dist/typescript/components/dynamic-import-statement.cjs +26 -0
- package/dist/typescript/components/dynamic-import-statement.d.cts +33 -0
- package/dist/typescript/components/dynamic-import-statement.d.cts.map +1 -0
- package/dist/typescript/components/dynamic-import-statement.d.mts +33 -0
- package/dist/typescript/components/dynamic-import-statement.d.mts.map +1 -0
- package/dist/typescript/components/dynamic-import-statement.mjs +25 -0
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -0
- package/dist/typescript/components/entry-file.cjs +43 -0
- package/dist/typescript/components/entry-file.d.cts +28 -0
- package/dist/typescript/components/entry-file.d.cts.map +1 -0
- package/dist/typescript/components/entry-file.d.mts +28 -0
- package/dist/typescript/components/entry-file.d.mts.map +1 -0
- package/dist/typescript/components/entry-file.mjs +41 -0
- package/dist/typescript/components/entry-file.mjs.map +1 -0
- package/dist/typescript/components/index.cjs +65 -0
- package/dist/typescript/components/index.d.cts +15 -0
- package/dist/typescript/components/index.d.mts +15 -0
- package/dist/typescript/components/index.mjs +16 -0
- package/dist/typescript/components/infrastructure-file.cjs +40 -0
- package/dist/typescript/components/infrastructure-file.d.cts +21 -0
- package/dist/typescript/components/infrastructure-file.d.cts.map +1 -0
- package/dist/typescript/components/infrastructure-file.d.mts +21 -0
- package/dist/typescript/components/infrastructure-file.d.mts.map +1 -0
- package/dist/typescript/components/infrastructure-file.mjs +38 -0
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -0
- package/dist/typescript/components/interface-declaration.cjs +229 -0
- package/dist/typescript/components/interface-declaration.d.cts +86 -0
- package/dist/typescript/components/interface-declaration.d.cts.map +1 -0
- package/dist/typescript/components/interface-declaration.d.mts +86 -0
- package/dist/typescript/components/interface-declaration.d.mts.map +1 -0
- package/dist/typescript/components/interface-declaration.mjs +225 -0
- package/dist/typescript/components/interface-declaration.mjs.map +1 -0
- package/dist/typescript/components/object-declaration.cjs +128 -0
- package/dist/typescript/components/object-declaration.d.cts +30 -0
- package/dist/typescript/components/object-declaration.d.cts.map +1 -0
- package/dist/typescript/components/object-declaration.d.mts +30 -0
- package/dist/typescript/components/object-declaration.d.mts.map +1 -0
- package/dist/typescript/components/object-declaration.mjs +126 -0
- package/dist/typescript/components/object-declaration.mjs.map +1 -0
- package/dist/typescript/components/property-name.cjs +32 -0
- package/dist/typescript/components/property-name.d.cts +24 -0
- package/dist/typescript/components/property-name.d.cts.map +1 -0
- package/dist/typescript/components/property-name.d.mts +24 -0
- package/dist/typescript/components/property-name.d.mts.map +1 -0
- package/dist/typescript/components/property-name.mjs +31 -0
- package/dist/typescript/components/property-name.mjs.map +1 -0
- package/dist/typescript/components/record-expression.cjs +13 -0
- package/dist/typescript/components/record-expression.d.cts +13 -0
- package/dist/typescript/components/record-expression.d.cts.map +1 -0
- package/dist/typescript/components/record-expression.d.mts +13 -0
- package/dist/typescript/components/record-expression.d.mts.map +1 -0
- package/dist/typescript/components/record-expression.mjs +12 -0
- package/dist/typescript/components/record-expression.mjs.map +1 -0
- package/dist/typescript/components/tsdoc-reflection.cjs +310 -0
- package/dist/typescript/components/tsdoc-reflection.d.cts +44 -0
- package/dist/typescript/components/tsdoc-reflection.d.cts.map +1 -0
- package/dist/typescript/components/tsdoc-reflection.d.mts +44 -0
- package/dist/typescript/components/tsdoc-reflection.d.mts.map +1 -0
- package/dist/typescript/components/tsdoc-reflection.mjs +304 -0
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -0
- package/dist/typescript/components/tsdoc.cjs +477 -0
- package/dist/typescript/components/tsdoc.d.cts +164 -0
- package/dist/typescript/components/tsdoc.d.cts.map +1 -0
- package/dist/typescript/components/tsdoc.d.mts +164 -0
- package/dist/typescript/components/tsdoc.d.mts.map +1 -0
- package/dist/typescript/components/tsdoc.mjs +457 -0
- package/dist/typescript/components/tsdoc.mjs.map +1 -0
- package/dist/typescript/components/type-declaration.cjs +39 -0
- package/dist/typescript/components/type-declaration.d.cts +18 -0
- package/dist/typescript/components/type-declaration.d.cts.map +1 -0
- package/dist/typescript/components/type-declaration.d.mts +18 -0
- package/dist/typescript/components/type-declaration.d.mts.map +1 -0
- package/dist/typescript/components/type-declaration.mjs +38 -0
- package/dist/typescript/components/type-declaration.mjs.map +1 -0
- package/dist/typescript/components/type-parameters.cjs +82 -0
- package/dist/typescript/components/type-parameters.d.cts +24 -0
- package/dist/typescript/components/type-parameters.d.cts.map +1 -0
- package/dist/typescript/components/type-parameters.d.mts +24 -0
- package/dist/typescript/components/type-parameters.d.mts.map +1 -0
- package/dist/typescript/components/type-parameters.mjs +81 -0
- package/dist/typescript/components/type-parameters.mjs.map +1 -0
- package/dist/typescript/components/typescript-file.cjs +221 -0
- package/dist/typescript/components/typescript-file.d.cts +50 -0
- package/dist/typescript/components/typescript-file.d.cts.map +1 -0
- package/dist/typescript/components/typescript-file.d.mts +50 -0
- package/dist/typescript/components/typescript-file.d.mts.map +1 -0
- package/dist/typescript/components/typescript-file.mjs +218 -0
- package/dist/typescript/components/typescript-file.mjs.map +1 -0
- package/dist/typescript/contexts/index.cjs +4 -0
- package/dist/typescript/contexts/index.d.cts +2 -0
- package/dist/typescript/contexts/index.d.mts +2 -0
- package/dist/typescript/contexts/index.mjs +3 -0
- package/dist/typescript/contexts/lexical-scope.cjs +26 -0
- package/dist/typescript/contexts/lexical-scope.d.cts +17 -0
- package/dist/typescript/contexts/lexical-scope.d.cts.map +1 -0
- package/dist/typescript/contexts/lexical-scope.d.mts +17 -0
- package/dist/typescript/contexts/lexical-scope.d.mts.map +1 -0
- package/dist/typescript/contexts/lexical-scope.mjs +25 -0
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -0
- package/dist/typescript/contexts/member-scope.cjs +24 -0
- package/dist/typescript/contexts/member-scope.d.cts +20 -0
- package/dist/typescript/contexts/member-scope.d.cts.map +1 -0
- package/dist/typescript/contexts/member-scope.d.mts +20 -0
- package/dist/typescript/contexts/member-scope.d.mts.map +1 -0
- package/dist/typescript/contexts/member-scope.mjs +23 -0
- package/dist/typescript/contexts/member-scope.mjs.map +1 -0
- package/dist/typescript/helpers/get-call-signature-props.cjs +26 -0
- package/dist/typescript/helpers/get-call-signature-props.d.cts +14 -0
- package/dist/typescript/helpers/get-call-signature-props.d.cts.map +1 -0
- package/dist/typescript/helpers/get-call-signature-props.d.mts +14 -0
- package/dist/typescript/helpers/get-call-signature-props.d.mts.map +1 -0
- package/dist/typescript/helpers/get-call-signature-props.mjs +25 -0
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -0
- package/dist/typescript/helpers/index.cjs +6 -0
- package/dist/typescript/helpers/index.d.cts +3 -0
- package/dist/typescript/helpers/index.d.mts +3 -0
- package/dist/typescript/helpers/index.mjs +4 -0
- package/dist/typescript/helpers/utilities.cjs +15 -0
- package/dist/typescript/helpers/utilities.d.cts +11 -0
- package/dist/typescript/helpers/utilities.d.cts.map +1 -0
- package/dist/typescript/helpers/utilities.d.mts +11 -0
- package/dist/typescript/helpers/utilities.d.mts.map +1 -0
- package/dist/typescript/helpers/utilities.mjs +14 -0
- package/dist/typescript/helpers/utilities.mjs.map +1 -0
- package/dist/typescript/index.cjs +74 -0
- package/dist/typescript/index.d.cts +18 -0
- package/dist/typescript/index.d.mts +18 -0
- package/dist/typescript/index.mjs +22 -0
- package/dist/yaml/components/index.cjs +5 -0
- package/dist/yaml/components/index.d.cts +2 -0
- package/dist/yaml/components/index.d.mts +2 -0
- package/dist/yaml/components/index.mjs +3 -0
- package/dist/yaml/components/yaml-file.cjs +149 -0
- package/dist/yaml/components/yaml-file.d.cts +34 -0
- package/dist/yaml/components/yaml-file.d.cts.map +1 -0
- package/dist/yaml/components/yaml-file.d.mts +34 -0
- package/dist/yaml/components/yaml-file.d.mts.map +1 -0
- package/dist/yaml/components/yaml-file.mjs +147 -0
- package/dist/yaml/components/yaml-file.mjs.map +1 -0
- package/dist/yaml/index.cjs +6 -0
- package/dist/yaml/index.d.cts +2 -0
- package/dist/yaml/index.d.mts +2 -0
- package/dist/yaml/index.mjs +4 -0
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection.mjs","names":[],"sources":["../../../src/core/contexts/reflection.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createContext, createNamedContext, useContext } from \"@alloy-js/core\";\nimport type {\n ReflectionClass,\n ReflectionMethod,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { ReflectionOverrideInterface } from \"../../types/components\";\n\nexport interface ReflectionClassContextInterface<\n T extends Record<string, any> = Record<string, any>\n> {\n reflection: ReflectionClass<T>;\n override?: ReflectionOverrideInterface<T>;\n}\n\n/**\n * The reflection class context used in template rendering.\n */\nexport const ReflectionClassContext: ComponentContext<\n ReflectionClassContextInterface<any>\n> = createContext<ReflectionClassContextInterface<any>>();\n\n/**\n * Hook to access the Reflection context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionClass<\n T extends Record<string, any> = Record<string, any>\n>() {\n const context = useContext<ReflectionClassContextInterface<T>>(\n ReflectionClassContext\n )!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - ReflectionClass 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 context;\n}\n\n/**\n * The reflection property context used in template rendering.\n */\nexport const ReflectionPropertyContext: ComponentContext<ReflectionProperty> =\n createNamedContext<ReflectionProperty>(\"ReflectionProperty\");\n\n/**\n * Hook to access the Reflection Property context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionProperty() {\n const context = useContext<ReflectionProperty>(ReflectionPropertyContext)!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Property 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 context;\n}\n\n/**\n * The reflection method context used in template rendering.\n */\nexport const ReflectionMethodContext: ComponentContext<ReflectionMethod> =\n createNamedContext<ReflectionMethod>(\"ReflectionMethod\");\n\n/**\n * Hook to access the Reflection Method context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionMethod() {\n const context = useContext<ReflectionMethod>(ReflectionMethodContext)!;\n\n if (!context) {\n throw new Error(\n \"Powerlines - Reflection Method 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 context;\n}\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ReflectionParameterContext: ComponentContext<ReflectionParameter> =\n createNamedContext<ReflectionParameter>(\"ReflectionParameter\");\n\n/**\n * Hook to access the Reflection Parameter context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useReflectionParameter() {\n return useContext<ReflectionParameter>(ReflectionParameterContext)!;\n}\n"],"mappings":";;;;;;AAsCA,MAAa,yBAET,eAAqD;;;;;;AAOzD,SAAgB,qBAEZ;CACF,MAAM,UAAU,WACd,uBACD;AAED,KAAI,CAAC,QACH,OAAM,IAAI,MACR,sMACD;AAGH,QAAO;;;;;AAMT,MAAa,4BACX,mBAAuC,qBAAqB;;;;;;AAO9D,SAAgB,wBAAwB;CACtC,MAAM,UAAU,WAA+B,0BAA0B;AAEzE,KAAI,CAAC,QACH,OAAM,IAAI,MACR,0MACD;AAGH,QAAO;;;;;AAMT,MAAa,0BACX,mBAAqC,mBAAmB;;;;;;AAO1D,SAAgB,sBAAsB;CACpC,MAAM,UAAU,WAA6B,wBAAwB;AAErE,KAAI,CAAC,QACH,OAAM,IAAI,MACR,wMACD;AAGH,QAAO;;;;;AAMT,MAAa,6BACX,mBAAwC,sBAAsB;;;;;;AAOhE,SAAgB,yBAAyB;AACvC,QAAO,WAAgC,2BAA2B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
4
|
+
|
|
5
|
+
//#region src/core/helpers/code.ts
|
|
6
|
+
/**
|
|
7
|
+
* Turn the provided string template into Children by replacing literal line
|
|
8
|
+
* breaks with hardlines and automatically indenting indented content. Similar
|
|
9
|
+
* in spirit to the `<code>` element in HTML.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link text} for a similar function which treats whitespace similar to
|
|
12
|
+
* JSX template bodies.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* code`
|
|
17
|
+
* function greet(name: string) {
|
|
18
|
+
* console.log("Hello, " + name + "!");
|
|
19
|
+
* }
|
|
20
|
+
* `
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param template - The template string to be processed into Children.
|
|
24
|
+
* @param substitutions - Any interpolated values within the template, which will be treated as Children and properly indented.
|
|
25
|
+
* @returns A Children representation of the provided template string, with proper handling of line breaks and indentation.
|
|
26
|
+
* @throws Will throw an error if the provided template contains only whitespace, as this is likely a mistake and would cause a less recognizable "Cannot read properties of undefined" exception later in the processing.
|
|
27
|
+
*/
|
|
28
|
+
function code(template, ...substitutions) {
|
|
29
|
+
if (template.filter((seg) => seg.trim()).length === 0 && substitutions.length === 0) throw new Error("The `code` function cannot be used with a template that contains only whitespace. Please provide a non-empty template.");
|
|
30
|
+
return (0, _alloy_js_core.code)(template, ...substitutions);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.code = code;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/core/helpers/code.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Turn the provided string template into Children by replacing literal line
|
|
6
|
+
* breaks with hardlines and automatically indenting indented content. Similar
|
|
7
|
+
* in spirit to the `<code>` element in HTML.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link text} for a similar function which treats whitespace similar to
|
|
10
|
+
* JSX template bodies.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* code`
|
|
15
|
+
* function greet(name: string) {
|
|
16
|
+
* console.log("Hello, " + name + "!");
|
|
17
|
+
* }
|
|
18
|
+
* `
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param template - The template string to be processed into Children.
|
|
22
|
+
* @param substitutions - Any interpolated values within the template, which will be treated as Children and properly indented.
|
|
23
|
+
* @returns A Children representation of the provided template string, with proper handling of line breaks and indentation.
|
|
24
|
+
* @throws Will throw an error if the provided template contains only whitespace, as this is likely a mistake and would cause a less recognizable "Cannot read properties of undefined" exception later in the processing.
|
|
25
|
+
*/
|
|
26
|
+
declare function code(template: TemplateStringsArray, ...substitutions: Children[]): Children;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { code };
|
|
29
|
+
//# sourceMappingURL=code.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.cts","names":[],"sources":["../../../src/core/helpers/code.ts"],"mappings":";;;;;AA0CA;;;;;;;;;;;;;;;;;;;;iBAAgB,IAAA,CACd,QAAA,EAAU,oBAAA,KACP,aAAA,EAAe,QAAA,KACjB,QAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/core/helpers/code.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Turn the provided string template into Children by replacing literal line
|
|
6
|
+
* breaks with hardlines and automatically indenting indented content. Similar
|
|
7
|
+
* in spirit to the `<code>` element in HTML.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link text} for a similar function which treats whitespace similar to
|
|
10
|
+
* JSX template bodies.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* code`
|
|
15
|
+
* function greet(name: string) {
|
|
16
|
+
* console.log("Hello, " + name + "!");
|
|
17
|
+
* }
|
|
18
|
+
* `
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param template - The template string to be processed into Children.
|
|
22
|
+
* @param substitutions - Any interpolated values within the template, which will be treated as Children and properly indented.
|
|
23
|
+
* @returns A Children representation of the provided template string, with proper handling of line breaks and indentation.
|
|
24
|
+
* @throws Will throw an error if the provided template contains only whitespace, as this is likely a mistake and would cause a less recognizable "Cannot read properties of undefined" exception later in the processing.
|
|
25
|
+
*/
|
|
26
|
+
declare function code(template: TemplateStringsArray, ...substitutions: Children[]): Children;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { code };
|
|
29
|
+
//# sourceMappingURL=code.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.mts","names":[],"sources":["../../../src/core/helpers/code.ts"],"mappings":";;;;;AA0CA;;;;;;;;;;;;;;;;;;;;iBAAgB,IAAA,CACd,QAAA,EAAU,oBAAA,KACP,aAAA,EAAe,QAAA,KACjB,QAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { code as code$1 } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
//#region src/core/helpers/code.ts
|
|
4
|
+
/**
|
|
5
|
+
* Turn the provided string template into Children by replacing literal line
|
|
6
|
+
* breaks with hardlines and automatically indenting indented content. Similar
|
|
7
|
+
* in spirit to the `<code>` element in HTML.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link text} for a similar function which treats whitespace similar to
|
|
10
|
+
* JSX template bodies.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* code`
|
|
15
|
+
* function greet(name: string) {
|
|
16
|
+
* console.log("Hello, " + name + "!");
|
|
17
|
+
* }
|
|
18
|
+
* `
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param template - The template string to be processed into Children.
|
|
22
|
+
* @param substitutions - Any interpolated values within the template, which will be treated as Children and properly indented.
|
|
23
|
+
* @returns A Children representation of the provided template string, with proper handling of line breaks and indentation.
|
|
24
|
+
* @throws Will throw an error if the provided template contains only whitespace, as this is likely a mistake and would cause a less recognizable "Cannot read properties of undefined" exception later in the processing.
|
|
25
|
+
*/
|
|
26
|
+
function code(template, ...substitutions) {
|
|
27
|
+
if (template.filter((seg) => seg.trim()).length === 0 && substitutions.length === 0) throw new Error("The `code` function cannot be used with a template that contains only whitespace. Please provide a non-empty template.");
|
|
28
|
+
return code$1(template, ...substitutions);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { code };
|
|
33
|
+
//# sourceMappingURL=code.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.mjs","names":["baseCode"],"sources":["../../../src/core/helpers/code.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 { code as baseCode, Children } from \"@alloy-js/core\";\n\n/**\n * Turn the provided string template into Children by replacing literal line\n * breaks with hardlines and automatically indenting indented content. Similar\n * in spirit to the `<code>` element in HTML.\n *\n * @see {@link text} for a similar function which treats whitespace similar to\n * JSX template bodies.\n *\n * @example\n * ```ts\n * code`\n * function greet(name: string) {\n * console.log(\"Hello, \" + name + \"!\");\n * }\n * `\n * ```\n *\n * @param template - The template string to be processed into Children.\n * @param substitutions - Any interpolated values within the template, which will be treated as Children and properly indented.\n * @returns A Children representation of the provided template string, with proper handling of line breaks and indentation.\n * @throws Will throw an error if the provided template contains only whitespace, as this is likely a mistake and would cause a less recognizable \"Cannot read properties of undefined\" exception later in the processing.\n */\nexport function code(\n template: TemplateStringsArray,\n ...substitutions: Children[]\n): Children {\n if (\n template.filter(seg => seg.trim()).length === 0 &&\n substitutions.length === 0\n ) {\n throw new Error(\n \"The `code` function cannot be used with a template that contains only whitespace. Please provide a non-empty template.\"\n );\n }\n\n return baseCode(template, ...substitutions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,KACd,UACA,GAAG,eACO;AACV,KACE,SAAS,QAAO,QAAO,IAAI,MAAM,CAAC,CAAC,WAAW,KAC9C,cAAc,WAAW,EAEzB,OAAM,IAAI,MACR,yHACD;AAGH,QAAOA,OAAS,UAAU,GAAG,cAAc"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_core_contexts_context = require('./contexts/context.cjs');
|
|
3
|
+
const require_core_contexts_meta = require('./contexts/meta.cjs');
|
|
4
|
+
const require_core_contexts_reflection = require('./contexts/reflection.cjs');
|
|
5
|
+
require('./contexts/index.cjs');
|
|
6
|
+
const require_core_components_output = require('./components/output.cjs');
|
|
7
|
+
const require_core_components_single_line_comment = require('./components/single-line-comment.cjs');
|
|
8
|
+
const require_core_components_source_file = require('./components/source-file.cjs');
|
|
9
|
+
const require_core_components_spacing = require('./components/spacing.cjs');
|
|
10
|
+
require('./components/index.cjs');
|
|
11
|
+
const require_core_helpers_code = require('./helpers/code.cjs');
|
|
12
|
+
require('./helpers/index.cjs');
|
|
13
|
+
|
|
14
|
+
exports.MetaContext = require_core_contexts_meta.MetaContext;
|
|
15
|
+
exports.Output = require_core_components_output.Output;
|
|
16
|
+
exports.PowerlinesContext = require_core_contexts_context.PowerlinesContext;
|
|
17
|
+
exports.ReflectionClassContext = require_core_contexts_reflection.ReflectionClassContext;
|
|
18
|
+
exports.ReflectionMethodContext = require_core_contexts_reflection.ReflectionMethodContext;
|
|
19
|
+
exports.ReflectionParameterContext = require_core_contexts_reflection.ReflectionParameterContext;
|
|
20
|
+
exports.ReflectionPropertyContext = require_core_contexts_reflection.ReflectionPropertyContext;
|
|
21
|
+
exports.SingleLineComment = require_core_components_single_line_comment.SingleLineComment;
|
|
22
|
+
exports.SourceFile = require_core_components_source_file.SourceFile;
|
|
23
|
+
exports.Spacing = require_core_components_spacing.Spacing;
|
|
24
|
+
exports.code = require_core_helpers_code.code;
|
|
25
|
+
exports.useMeta = require_core_contexts_meta.useMeta;
|
|
26
|
+
exports.useMetaContext = require_core_contexts_meta.useMetaContext;
|
|
27
|
+
exports.useMetaSafe = require_core_contexts_meta.useMetaSafe;
|
|
28
|
+
exports.usePowerlines = require_core_contexts_context.usePowerlines;
|
|
29
|
+
exports.usePowerlinesContext = require_core_contexts_context.usePowerlinesContext;
|
|
30
|
+
exports.usePowerlinesSafe = require_core_contexts_context.usePowerlinesSafe;
|
|
31
|
+
exports.useReflectionClass = require_core_contexts_reflection.useReflectionClass;
|
|
32
|
+
exports.useReflectionMethod = require_core_contexts_reflection.useReflectionMethod;
|
|
33
|
+
exports.useReflectionParameter = require_core_contexts_reflection.useReflectionParameter;
|
|
34
|
+
exports.useReflectionProperty = require_core_contexts_reflection.useReflectionProperty;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.cjs";
|
|
2
|
+
import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.cjs";
|
|
3
|
+
import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.cjs";
|
|
4
|
+
import { Output, OutputProps, __ΩOutputProps } from "./components/output.cjs";
|
|
5
|
+
import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.cjs";
|
|
6
|
+
import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.cjs";
|
|
7
|
+
import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.cjs";
|
|
8
|
+
import { code } from "./helpers/code.cjs";
|
|
9
|
+
export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.mjs";
|
|
2
|
+
import { MetaContext, MetaItem, __ΩMetaItem, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.mjs";
|
|
3
|
+
import { ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, __ΩReflectionClassContextInterface, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
|
|
4
|
+
import { Output, OutputProps, __ΩOutputProps } from "./components/output.mjs";
|
|
5
|
+
import { SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant } from "./components/single-line-comment.mjs";
|
|
6
|
+
import { SourceFile, SourceFileProps, __ΩSourceFileProps } from "./components/source-file.mjs";
|
|
7
|
+
import { Spacing, SpacingProps, __ΩSpacingProps } from "./components/spacing.mjs";
|
|
8
|
+
import { code } from "./helpers/code.mjs";
|
|
9
|
+
export { MetaContext, MetaItem, Output, OutputProps, PowerlinesContext, ReflectionClassContext, ReflectionClassContextInterface, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SingleLineCommentProps, SingleLineCommentVariant, SourceFile, SourceFileProps, Spacing, SpacingProps, __ΩMetaItem, __ΩOutputProps, __ΩReflectionClassContextInterface, __ΩSingleLineCommentProps, __ΩSingleLineCommentVariant, __ΩSourceFileProps, __ΩSpacingProps, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PowerlinesContext, usePowerlines, usePowerlinesContext, usePowerlinesSafe } from "./contexts/context.mjs";
|
|
2
|
+
import { MetaContext, useMeta, useMetaContext, useMetaSafe } from "./contexts/meta.mjs";
|
|
3
|
+
import { ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty } from "./contexts/reflection.mjs";
|
|
4
|
+
import "./contexts/index.mjs";
|
|
5
|
+
import { Output } from "./components/output.mjs";
|
|
6
|
+
import { SingleLineComment } from "./components/single-line-comment.mjs";
|
|
7
|
+
import { SourceFile } from "./components/source-file.mjs";
|
|
8
|
+
import { Spacing } from "./components/spacing.mjs";
|
|
9
|
+
import "./components/index.mjs";
|
|
10
|
+
import { code } from "./helpers/code.mjs";
|
|
11
|
+
import "./helpers/index.mjs";
|
|
12
|
+
|
|
13
|
+
export { MetaContext, Output, PowerlinesContext, ReflectionClassContext, ReflectionMethodContext, ReflectionParameterContext, ReflectionPropertyContext, SingleLineComment, SourceFile, Spacing, code, useMeta, useMetaContext, useMetaSafe, usePowerlines, usePowerlinesContext, usePowerlinesSafe, useReflectionClass, useReflectionMethod, useReflectionParameter, useReflectionProperty };
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let defu = require("defu");
|
|
4
|
+
defu = require_runtime.__toESM(defu);
|
|
5
|
+
let _powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
6
|
+
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
7
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
8
|
+
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
9
|
+
let _powerlines_deepkit_vendor_core = require("@powerlines/deepkit/vendor/core");
|
|
10
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
11
|
+
let _stryke_capnp_compile = require("@stryke/capnp/compile");
|
|
12
|
+
let _stryke_capnp_helpers = require("@stryke/capnp/helpers");
|
|
13
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
14
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
15
|
+
let _stryke_json = require("@stryke/json");
|
|
16
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
17
|
+
let _stryke_string_format_get_words = require("@stryke/string-format/get-words");
|
|
18
|
+
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
19
|
+
let _stryke_type_checks_is_bigint = require("@stryke/type-checks/is-bigint");
|
|
20
|
+
let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
21
|
+
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
22
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
23
|
+
let node_buffer = require("node:buffer");
|
|
24
|
+
let node_child_process = require("node:child_process");
|
|
25
|
+
let node_util = require("node:util");
|
|
26
|
+
let powerlines_utils = require("powerlines/utils");
|
|
27
|
+
|
|
28
|
+
//#region src/helpers/capnp.ts
|
|
29
|
+
/**
|
|
30
|
+
* Compiles a Cap'n Proto schema into TypeScript definitions.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The context containing the project and workspace information.
|
|
33
|
+
* @param options - The options for compiling the schema.
|
|
34
|
+
* @returns A promise that resolves to the compiled schema.
|
|
35
|
+
*/
|
|
36
|
+
async function compile(context, options = {}) {
|
|
37
|
+
const opts = (0, defu.default)(options, {
|
|
38
|
+
ts: true,
|
|
39
|
+
js: false,
|
|
40
|
+
dts: false,
|
|
41
|
+
schemas: (0, _stryke_path_join.joinPaths)(context.artifactsPath, "schemas"),
|
|
42
|
+
tsconfig: context.tsconfig,
|
|
43
|
+
projectRoot: context.config.root,
|
|
44
|
+
workspaceRoot: context.workspaceConfig.workspaceRoot,
|
|
45
|
+
tty: true
|
|
46
|
+
});
|
|
47
|
+
const resolvedOptions = await (0, _stryke_capnp_helpers.resolveOptions)(opts);
|
|
48
|
+
if (!resolvedOptions) throw new Error(`✖ No Cap'n Proto schema files found in the specified source paths: ${(0, _stryke_convert_to_array.toArray)(opts.schemas).join(", ")}.`);
|
|
49
|
+
return (0, _stryke_capnp_compile.capnpc)(resolvedOptions);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
53
|
+
*
|
|
54
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
55
|
+
* @param value - The value to stringify.
|
|
56
|
+
* @returns A string representation of the value.
|
|
57
|
+
*/
|
|
58
|
+
function stringifyCapnpDefaultValue(property, value) {
|
|
59
|
+
return stringifyCapnpValue(property.type, value ?? property.getDefaultValue());
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
63
|
+
*
|
|
64
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
65
|
+
* @param value - The value to stringify.
|
|
66
|
+
* @returns A string representation of the value.
|
|
67
|
+
*/
|
|
68
|
+
function stringifyCapnpValue(type, value) {
|
|
69
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && (0, _stryke_type_checks_is_string.isString)(type.literal) ? `"${String(value)}"` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum ? `${(0, _stryke_string_format_camel_case.camelCase)(String(value))}` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array ? _stryke_json.StormJSON.stringify(value) : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.object || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral ? _stryke_json.StormJSON.stringify(value).replaceAll("{", "(").replaceAll("}", ")") : String(value);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
73
|
+
*
|
|
74
|
+
* @param type - The TypeEnum to evaluate.
|
|
75
|
+
* @returns A string representation of the property.
|
|
76
|
+
*/
|
|
77
|
+
function getCapnpEnumTypes(type) {
|
|
78
|
+
if (type.kind !== _powerlines_deepkit_vendor_type.ReflectionKind.enum) return null;
|
|
79
|
+
const unique = (0, _stryke_helpers_get_unique.getUniqueBy)(type.values.filter((value) => !(0, _stryke_type_checks_is_undefined.isUndefined)(value) && !(0, _stryke_type_checks_is_null.isNull)(value)), (enumMember) => (0, _stryke_type_checks_is_string.isString)(enumMember) ? "Text" : "Float32");
|
|
80
|
+
if (unique.length === 0) return null;
|
|
81
|
+
return unique[0] && (0, _stryke_type_checks_is_string.isString)(unique[0]) ? "Text" : "Float32";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Determines if a Type is a `Void` type in a Cap'n Proto schema.
|
|
85
|
+
*
|
|
86
|
+
* @param type - The Type to check.
|
|
87
|
+
* @returns True if the Type is a `Void` type, false otherwise.
|
|
88
|
+
*/
|
|
89
|
+
function isVoidType(type) {
|
|
90
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
94
|
+
*
|
|
95
|
+
* @param type - The {@link TypeUnion} to convert.
|
|
96
|
+
* @returns A string representation of the Cap'n Proto primitive type.
|
|
97
|
+
*/
|
|
98
|
+
function getCapnpUnionTypes(type) {
|
|
99
|
+
return (0, _powerlines_deepkit_utilities.getUnionTypes)(type);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
103
|
+
*
|
|
104
|
+
* @param type - The {@link TypeUnion} to convert.
|
|
105
|
+
* @returns An array of Cap'n Proto primitive types.
|
|
106
|
+
*/
|
|
107
|
+
function isCapnpStringUnion(type) {
|
|
108
|
+
return getCapnpUnionTypes(type).some((member) => member.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string);
|
|
109
|
+
}
|
|
110
|
+
const LARGE_BUFFER = 1024 * 1e6;
|
|
111
|
+
const execAsync = (0, node_util.promisify)(node_child_process.exec);
|
|
112
|
+
async function generateCapnpId() {
|
|
113
|
+
const { stdout } = await execAsync("capnp id", {
|
|
114
|
+
windowsHide: true,
|
|
115
|
+
maxBuffer: LARGE_BUFFER,
|
|
116
|
+
killSignal: "SIGTERM"
|
|
117
|
+
});
|
|
118
|
+
return stdout;
|
|
119
|
+
}
|
|
120
|
+
async function generateCapnp(context, reflection, options) {
|
|
121
|
+
return `${(await generateCapnpId()).trim()};
|
|
122
|
+
${(0, powerlines_utils.getFileHeader)(context).replace(/^\r*\n*/g, "").replaceAll("//", "#")}
|
|
123
|
+
${reflection.getMethods().length === 0 ? generateCapnpStruct(reflection, options) : generateCapnpInterface(reflection, options)}
|
|
124
|
+
`.trim();
|
|
125
|
+
}
|
|
126
|
+
function generateCapnpStruct(reflection, options = {}) {
|
|
127
|
+
const structName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
|
|
128
|
+
return `${generateCapnpEnums(reflection)}struct ${(0, _stryke_string_format_pascal_case.pascalCase)(structName)} {
|
|
129
|
+
# Struct definition for ${(0, _stryke_string_format_title_case.titleCase)(structName)}.
|
|
130
|
+
|
|
131
|
+
${generateCapnpSchema(reflection, options)}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
function generateCapnpInterface(reflection, options = {}) {
|
|
136
|
+
const interfaceName = options?.name || reflection.getTitle() || reflection.getClassName() || reflection.getName();
|
|
137
|
+
return `${generateCapnpEnums(reflection)}interface ${(0, _stryke_string_format_pascal_case.pascalCase)(interfaceName)} {
|
|
138
|
+
# Interface definition for ${(0, _stryke_string_format_title_case.titleCase)(interfaceName)}.
|
|
139
|
+
|
|
140
|
+
${generateCapnpSchema(reflection, options)}
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
function formatEnumName(name) {
|
|
145
|
+
return (0, _stryke_string_format_pascal_case.pascalCase)(`${name}_Type`);
|
|
146
|
+
}
|
|
147
|
+
function generateCapnpEnums(reflection) {
|
|
148
|
+
const enums = reflection.getProperties().filter((prop) => !prop.isIgnored() && (prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum || prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union && getCapnpUnionTypes(prop.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1)).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1);
|
|
149
|
+
if (enums.length === 0) return "";
|
|
150
|
+
return `${enums.map((enumeration) => generateCapnpEnumSchema(enumeration.type, formatEnumName(enumeration.getNameAsString()))).join("\n\n")}
|
|
151
|
+
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
function generateCapnpSchema(reflection, options = {}) {
|
|
155
|
+
let index = 0;
|
|
156
|
+
const indexCounter = options?.indexCounter ?? (() => index++);
|
|
157
|
+
return `${reflection.getProperties().filter((prop) => !prop.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? b.getNameAsString().localeCompare(a.getNameAsString()) : a.isReadonly() ? 1 : -1).map((prop) => generateCapnpPropertySchema(prop, indexCounter)).join(" \n\n ")}${reflection.getMethods().filter((methods) => !methods.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? String(b.getName()).localeCompare(String(a.getName())) : a.isReadonly() ? 1 : -1).map((methods) => generateCapnpMethodSchema(methods, indexCounter)).join(" \n\n ")}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Map) ? `
|
|
158
|
+
struct Map(Key, Value) {
|
|
159
|
+
entries @0 :List(Entry);
|
|
160
|
+
|
|
161
|
+
struct Entry {
|
|
162
|
+
key @0 :Key;
|
|
163
|
+
value @1 :Value;
|
|
164
|
+
}
|
|
165
|
+
}` : ""}${reflection.getProperties().some((prop) => prop.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && prop.type.classType === Date) ? `
|
|
166
|
+
struct Date {
|
|
167
|
+
# A standard Gregorian calendar date.
|
|
168
|
+
|
|
169
|
+
year @0 :Int16;
|
|
170
|
+
# The year - Must include the century.
|
|
171
|
+
# Negative value indicates BC.
|
|
172
|
+
|
|
173
|
+
month @1 :UInt8; # The month, 1-12
|
|
174
|
+
|
|
175
|
+
day @2 :UInt8; # The day of the month, 1-30
|
|
176
|
+
|
|
177
|
+
hour @3 :UInt8; # The hour of the day, 0-23
|
|
178
|
+
|
|
179
|
+
minute @4 :UInt8; # The minute of the hour, 0-59
|
|
180
|
+
|
|
181
|
+
second @5 :UInt8; # The second of the minute, 0-59
|
|
182
|
+
|
|
183
|
+
millisecond @6 :UInt16; # Milliseconds of the second, 0-999
|
|
184
|
+
}` : ""}`;
|
|
185
|
+
}
|
|
186
|
+
function generateCapnpMethodSchema(reflection, indexCounter) {
|
|
187
|
+
const methodName = reflection.getTitle() || typeof reflection.getName() === "string" ? String(reflection.getName()) : "";
|
|
188
|
+
if (!methodName) throw new Error(`Cannot generate Cap'n Proto schema for method without a name - Parent interface: ${reflection.reflectionClass.getName()}`);
|
|
189
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(methodName)} @${indexCounter()} (${reflection.getParameters().map((param) => {
|
|
190
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(param.getName())} :${generateCapnpPrimitive(param.getType())}${param.hasDefault() ? ` = ${stringifyCapnpDefaultValue(param)}` : ""}`;
|
|
191
|
+
}).join(", ")})${isVoidType(reflection.getReturnType()) ? "" : ` -> (${(0, _powerlines_deepkit_utilities.kindToName)(reflection.getReturnType().kind)}: ${generateCapnpPrimitive(reflection.getReturnType())})`}; # ${(reflection.getDescription() || `The ${(0, _stryke_string_format_title_case.titleCase)(reflection.reflectionClass.getTitle() || reflection.reflectionClass.getName())} interface ${(0, _stryke_string_format_title_case.titleCase)(methodName)} method.`).replaceAll("\n", ". ")}`;
|
|
192
|
+
}
|
|
193
|
+
function generateCapnpPropertyComment(reflection) {
|
|
194
|
+
const result = (0, _stryke_string_format_get_words.getWords)(reflection.getDescription() || `A schema property for ${(0, _stryke_string_format_title_case.titleCase)(reflection.getTitle() || reflection.getNameAsString())} field.`, { relaxed: true }).reduce((ret, word) => {
|
|
195
|
+
let length = ret.length;
|
|
196
|
+
if (ret.includes("\n")) length = ret.substring(ret.lastIndexOf("\n") + 1).length;
|
|
197
|
+
const current = word.trim();
|
|
198
|
+
if (length + current.length > 60) ret += `\n\t# ${current}`;
|
|
199
|
+
else ret += ` ${current}`;
|
|
200
|
+
return ret;
|
|
201
|
+
}, "").trim();
|
|
202
|
+
if (result.length > 0) return `\t# ${result}`;
|
|
203
|
+
return "";
|
|
204
|
+
}
|
|
205
|
+
function generateCapnpPropertySchema(reflection, indexCounter) {
|
|
206
|
+
if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) if (getCapnpUnionTypes(reflection.type).length === 0) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Void;
|
|
207
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
208
|
+
else if (getCapnpUnionTypes(reflection.type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).length === 1) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${formatEnumName(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
209
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
210
|
+
else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} :union {
|
|
211
|
+
${getCapnpUnionTypes(reflection.type).map((type) => ` ${(0, _powerlines_deepkit_utilities.kindToName)(type.kind)} @${indexCounter()} :${generateCapnpPrimitive(type)};`).join("\n")}
|
|
212
|
+
}
|
|
213
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
214
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.array) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :List(${generateCapnpPrimitive(reflection.getSubType())})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
215
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
216
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class) if (reflection.type.classType === Map) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Map(${!reflection.type.typeArguments || reflection.type.typeArguments.length === 0 || !reflection.type.typeArguments[0] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[0])}, ${!reflection.type.typeArguments || reflection.type.typeArguments.length < 2 || !reflection.type.typeArguments[1] ? "Data" : generateCapnpPrimitive(reflection.type.typeArguments[1])})${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
217
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
218
|
+
else if (reflection.type.classType === Date) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
219
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
220
|
+
else if (reflection.type.classType === node_buffer.Buffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
221
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
222
|
+
else if (reflection.type.classType === ArrayBuffer) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :Data${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
223
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
224
|
+
else return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_core.getClassName)(reflection.type.classType)) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
225
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
226
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString()))}${generateCapnpStruct(reflection.reflectionClass, { name: (0, _stryke_string_format_pascal_case.pascalCase)(reflection.type.typeName || (0, _powerlines_deepkit_vendor_type.memberNameToString)(reflection.getNameAsString())) })}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
227
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
228
|
+
else if (reflection.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.enum) return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${(0, _stryke_string_format_pascal_case.pascalCase)(reflection.getNameAsString())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
229
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
230
|
+
return `${(0, _stryke_string_format_camel_case.camelCase)(reflection.getNameAsString())} @${indexCounter()} :${generateCapnpPrimitive(reflection.getType())}${reflection.hasDefault() ? ` = ${stringifyCapnpDefaultValue(reflection)}` : ""};
|
|
231
|
+
${generateCapnpPropertyComment(reflection)}`;
|
|
232
|
+
}
|
|
233
|
+
function generateCapnpEnumSchema(type, name) {
|
|
234
|
+
if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) return generateCapnpEnumSchema({
|
|
235
|
+
kind: _powerlines_deepkit_vendor_type.ReflectionKind.enum,
|
|
236
|
+
indexType: type,
|
|
237
|
+
enum: type.types.reduce((ret, type) => {
|
|
238
|
+
if ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal)) ret[(0, _stryke_string_format_camel_case.camelCase)(String(type.literal))] = type.literal;
|
|
239
|
+
return ret;
|
|
240
|
+
}, {}),
|
|
241
|
+
values: getCapnpUnionTypes(type).filter((type) => type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_string.isString)(type.literal) || (0, _stryke_type_checks_is_number.isNumber)(type.literal))).map((type) => type.literal)
|
|
242
|
+
}, name);
|
|
243
|
+
let index = 0;
|
|
244
|
+
const indexCounter = () => index++;
|
|
245
|
+
const enumType = getCapnpEnumTypes(type);
|
|
246
|
+
if (!enumType) return "";
|
|
247
|
+
return `enum ${(0, _stryke_string_format_pascal_case.pascalCase)(name)} {
|
|
248
|
+
${type.enum && Object.entries(type.enum).length > 0 ? Object.entries(type.enum).filter(([, value]) => value !== null && value !== void 0).map(([key]) => ` ${(0, _stryke_string_format_camel_case.camelCase)(key)} @${indexCounter()};`).join("\n") : type.values.filter((value) => value !== null && value !== void 0).map((value) => `${enumType === "Text" && value ? (0, _stryke_string_format_camel_case.camelCase)(String(value)) : `${type.typeName ? `${(0, _stryke_string_format_camel_case.camelCase)(type.typeName)}_` : ""}${value || ""}`} @${indexCounter()};`).join("\n")}
|
|
249
|
+
}`;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
|
|
253
|
+
*
|
|
254
|
+
* @param type - The Deepkit Type to convert.
|
|
255
|
+
* @returns A string representation of the Cap'n Proto primitive type.
|
|
256
|
+
*/
|
|
257
|
+
function generateCapnpPrimitive(type) {
|
|
258
|
+
return type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.never || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.void || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.null || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.undefined || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.symbol ? "Void" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Date ? "Date" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.class && type.classType === Set ? `List(${type.typeArguments && type.typeArguments[0] ? generateCapnpPrimitive(type.typeArguments[0]) : "Data"})` : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.bigint ? "UInt64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number ? "Float64" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.regexp ? "Text" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.boolean ? "Bool" : type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal ? (0, _stryke_type_checks_is_number.isNumber)(type.literal) ? "Float64" : (0, _stryke_type_checks_is_bigint.isBigInt)(type.literal) ? "UInt64" : (0, _stryke_type_checks_is_string.isString)(type.literal) ? "Text" : typeof type.literal === "boolean" ? "Bool" : "Data" : "Data";
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
exports.LARGE_BUFFER = LARGE_BUFFER;
|
|
263
|
+
exports.compile = compile;
|
|
264
|
+
exports.generateCapnp = generateCapnp;
|
|
265
|
+
exports.generateCapnpEnumSchema = generateCapnpEnumSchema;
|
|
266
|
+
exports.generateCapnpId = generateCapnpId;
|
|
267
|
+
exports.generateCapnpInterface = generateCapnpInterface;
|
|
268
|
+
exports.generateCapnpMethodSchema = generateCapnpMethodSchema;
|
|
269
|
+
exports.generateCapnpPrimitive = generateCapnpPrimitive;
|
|
270
|
+
exports.generateCapnpSchema = generateCapnpSchema;
|
|
271
|
+
exports.generateCapnpStruct = generateCapnpStruct;
|
|
272
|
+
exports.getCapnpEnumTypes = getCapnpEnumTypes;
|
|
273
|
+
exports.getCapnpUnionTypes = getCapnpUnionTypes;
|
|
274
|
+
exports.isCapnpStringUnion = isCapnpStringUnion;
|
|
275
|
+
exports.isVoidType = isVoidType;
|
|
276
|
+
exports.stringifyCapnpDefaultValue = stringifyCapnpDefaultValue;
|
|
277
|
+
exports.stringifyCapnpValue = stringifyCapnpValue;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Context, PluginContext } from "powerlines";
|
|
2
|
+
import { ReflectionClass, ReflectionMethod, ReflectionParameter, ReflectionProperty, Type, TypeEnum, TypeUnion } from "@powerlines/deepkit/vendor/type";
|
|
3
|
+
import { CapnpcOptions, CapnpcResult } from "@stryke/capnp/types";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/capnp.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Compiles a Cap'n Proto schema into TypeScript definitions.
|
|
8
|
+
*
|
|
9
|
+
* @param context - The context containing the project and workspace information.
|
|
10
|
+
* @param options - The options for compiling the schema.
|
|
11
|
+
* @returns A promise that resolves to the compiled schema.
|
|
12
|
+
*/
|
|
13
|
+
declare function compile(context: Context, options?: Partial<CapnpcOptions>): Promise<CapnpcResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Converts any {@link ReflectionProperty} or {@link ReflectionParameter}'s value to string representation.
|
|
16
|
+
*
|
|
17
|
+
* @param property - The {@link ReflectionProperty} or {@link ReflectionParameter} containing the value to stringify.
|
|
18
|
+
* @param value - The value to stringify.
|
|
19
|
+
* @returns A string representation of the value.
|
|
20
|
+
*/
|
|
21
|
+
declare function stringifyCapnpDefaultValue(property: ReflectionProperty | ReflectionParameter, value?: any): string;
|
|
22
|
+
/**
|
|
23
|
+
* Converts any {@link Type}'s actual value to string representation.
|
|
24
|
+
*
|
|
25
|
+
* @param type - The {@link Type} of the value to stringify.
|
|
26
|
+
* @param value - The value to stringify.
|
|
27
|
+
* @returns A string representation of the value.
|
|
28
|
+
*/
|
|
29
|
+
declare function stringifyCapnpValue(type: Type, value: any): string;
|
|
30
|
+
/**
|
|
31
|
+
* Converts a ReflectionProperty's default value to a Cap'n Proto schema string representation.
|
|
32
|
+
*
|
|
33
|
+
* @param type - The TypeEnum to evaluate.
|
|
34
|
+
* @returns A string representation of the property.
|
|
35
|
+
*/
|
|
36
|
+
declare function getCapnpEnumTypes(type: Type): "Text" | "Float32" | null;
|
|
37
|
+
/**
|
|
38
|
+
* Determines if a Type is a `Void` type in a Cap'n Proto schema.
|
|
39
|
+
*
|
|
40
|
+
* @param type - The Type to check.
|
|
41
|
+
* @returns True if the Type is a `Void` type, false otherwise.
|
|
42
|
+
*/
|
|
43
|
+
declare function isVoidType(type: Type): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
46
|
+
*
|
|
47
|
+
* @param type - The {@link TypeUnion} to convert.
|
|
48
|
+
* @returns A string representation of the Cap'n Proto primitive type.
|
|
49
|
+
*/
|
|
50
|
+
declare function getCapnpUnionTypes(type: Type): Type[];
|
|
51
|
+
/**
|
|
52
|
+
* Converts a {@link TypeUnion} to an array of its underlying Cap'n Proto primitive type representation.
|
|
53
|
+
*
|
|
54
|
+
* @param type - The {@link TypeUnion} to convert.
|
|
55
|
+
* @returns An array of Cap'n Proto primitive types.
|
|
56
|
+
*/
|
|
57
|
+
declare function isCapnpStringUnion(type: Type): boolean;
|
|
58
|
+
declare const LARGE_BUFFER: number;
|
|
59
|
+
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
60
|
+
type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
|
|
61
|
+
declare function generateCapnpId(): Promise<string>;
|
|
62
|
+
interface GenerateCapnpOptions {
|
|
63
|
+
name?: string;
|
|
64
|
+
}
|
|
65
|
+
declare function generateCapnp(context: PluginContext, reflection: ReflectionClass<any>, options: GenerateCapnpOptions): Promise<string>;
|
|
66
|
+
interface GenerateCapnpStructOptions extends GenerateCapnpOptions {
|
|
67
|
+
indexCounter?: () => number;
|
|
68
|
+
}
|
|
69
|
+
declare function generateCapnpStruct(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
70
|
+
declare function generateCapnpInterface(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
71
|
+
declare function generateCapnpSchema(reflection: ReflectionClass<any>, options?: GenerateCapnpStructOptions): string;
|
|
72
|
+
declare function generateCapnpMethodSchema(reflection: ReflectionMethod, indexCounter: () => number): string;
|
|
73
|
+
declare function generateCapnpEnumSchema(type: TypeEnum | TypeUnion, name: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Generates a string representation of Cap'n Proto primitive types from a Deepkit Type.
|
|
76
|
+
*
|
|
77
|
+
* @param type - The Deepkit Type to convert.
|
|
78
|
+
* @returns A string representation of the Cap'n Proto primitive type.
|
|
79
|
+
*/
|
|
80
|
+
declare function generateCapnpPrimitive(type: Type): string;
|
|
81
|
+
declare type __ΩIOType = any[];
|
|
82
|
+
declare type __ΩStdioOptions = any[];
|
|
83
|
+
declare type __ΩGenerateCapnpOptions = any[];
|
|
84
|
+
declare type __ΩGenerateCapnpStructOptions = any[];
|
|
85
|
+
//#endregion
|
|
86
|
+
export { GenerateCapnpOptions, GenerateCapnpStructOptions, IOType, LARGE_BUFFER, StdioOptions, __ΩGenerateCapnpOptions, __ΩGenerateCapnpStructOptions, __ΩIOType, __ΩStdioOptions, compile, generateCapnp, generateCapnpEnumSchema, generateCapnpId, generateCapnpInterface, generateCapnpMethodSchema, generateCapnpPrimitive, generateCapnpSchema, generateCapnpStruct, getCapnpEnumTypes, getCapnpUnionTypes, isCapnpStringUnion, isVoidType, stringifyCapnpDefaultValue, stringifyCapnpValue };
|
|
87
|
+
//# sourceMappingURL=capnp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capnp.d.cts","names":[],"sources":["../../src/helpers/capnp.ts"],"mappings":";;;;;;;AA8DA;;;;;iBAAsB,OAAA,CACpB,OAAA,EAAS,OAAA,EACT,OAAA,GAAS,OAAA,CAAQ,aAAA,IAChB,OAAA,CAAQ,YAAA;;;;;;;;iBA+BK,0BAAA,CACd,QAAA,EAAU,kBAAA,GAAqB,mBAAA,EAC/B,KAAA;;;;;;AAFF;;iBAiBgB,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,KAAA;;;;;;;iBAoBhC,iBAAA,CAAkB,IAAA,EAAM,IAAA;AApBxC;;;;;;AAAA,iBA0CgB,UAAA,CAAW,IAAA,EAAM,IAAA;;;AAtBjC;;;;iBAsCgB,kBAAA,CAAmB,IAAA,EAAM,IAAA,GAAO,IAAA;AAhBhD;;;;;AAgBA;AAhBA,iBA0BgB,kBAAA,CAAmB,IAAA,EAAM,IAAA;AAAA,cAM5B,YAAA;AAAA,KACD,MAAA;AAAA,KACA,YAAA,GACR,MAAA,GACA,KAAA,CAAM,MAAA;AAAA,iBAIY,eAAA,CAAA,GAAe,OAAA;AAAA,UAUpB,oBAAA;EACf,IAAA;AAAA;AAAA,iBAGoB,aAAA,CACpB,OAAA,EAAS,aAAA,EACT,UAAA,EAAY,eAAA,OACZ,OAAA,EAAS,oBAAA,GAAoB,OAAA;AAAA,UAgBd,0BAAA,SAAmC,oBAAA;EAClD,YAAA;AAAA;AAAA,iBAGc,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAgBK,sBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBAyDK,mBAAA,CACd,UAAA,EAAY,eAAA,OACZ,OAAA,GAAS,0BAAA;AAAA,iBA4EK,yBAAA,CACd,UAAA,EAAY,gBAAA,EACZ,YAAA;AAAA,iBA0Mc,uBAAA,CACd,IAAA,EAAM,QAAA,GAAW,SAAA,EACjB,IAAA;;AArZF;;;;;iBAudgB,sBAAA,CAAuB,IAAA,EAAM,IAAA;AAAA"}
|