@powerlines/plugin-alloy 0.26.76 → 0.26.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/core/components/index.cjs +12 -1
- package/dist/core/components/index.mjs +7 -1
- package/dist/core/components/infrastructure-file.cjs +48 -1
- package/dist/core/components/infrastructure-file.mjs +45 -1
- package/dist/core/components/infrastructure-file.mjs.map +1 -1
- package/dist/core/components/output.cjs +41 -1
- package/dist/core/components/output.mjs +39 -1
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +23 -1
- package/dist/core/components/single-line-comment.mjs +21 -1
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +64 -1
- package/dist/core/components/source-file.mjs +61 -1
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +20 -1
- package/dist/core/components/spacing.mjs +18 -1
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/core/contexts/context.cjs +41 -1
- package/dist/core/contexts/context.mjs +36 -1
- package/dist/core/contexts/context.mjs.map +1 -1
- package/dist/core/contexts/index.cjs +22 -1
- package/dist/core/contexts/index.mjs +5 -1
- package/dist/core/contexts/meta.cjs +41 -1
- package/dist/core/contexts/meta.mjs +36 -1
- package/dist/core/contexts/meta.mjs.map +1 -1
- package/dist/core/contexts/reflection.cjs +80 -1
- package/dist/core/contexts/reflection.mjs +70 -1
- package/dist/core/contexts/reflection.mjs.map +1 -1
- package/dist/core/helpers/code.cjs +34 -1
- package/dist/core/helpers/code.mjs +32 -1
- package/dist/core/helpers/code.mjs.map +1 -1
- package/dist/core/helpers/index.cjs +4 -1
- package/dist/core/helpers/index.mjs +3 -1
- package/dist/core/index.cjs +37 -1
- package/dist/core/index.mjs +14 -1
- package/dist/hcl/components/block-declaration.cjs +34 -1
- package/dist/hcl/components/block-declaration.mjs +32 -1
- package/dist/hcl/components/block-declaration.mjs.map +1 -1
- package/dist/hcl/components/hcl-file.cjs +83 -1
- package/dist/hcl/components/hcl-file.mjs +80 -1
- package/dist/hcl/components/hcl-file.mjs.map +1 -1
- package/dist/hcl/components/index.cjs +11 -1
- package/dist/hcl/components/index.mjs +6 -1
- package/dist/hcl/components/packer-file.cjs +29 -1
- package/dist/hcl/components/packer-file.mjs +27 -1
- package/dist/hcl/components/packer-file.mjs.map +1 -1
- package/dist/hcl/components/terraform-file.cjs +30 -1
- package/dist/hcl/components/terraform-file.mjs +28 -1
- package/dist/hcl/components/terraform-file.mjs.map +1 -1
- package/dist/hcl/index.cjs +12 -1
- package/dist/hcl/index.mjs +7 -1
- package/dist/helpers/capnp.cjs +245 -37
- package/dist/helpers/capnp.mjs +227 -37
- package/dist/helpers/capnp.mjs.map +1 -1
- package/dist/helpers/create-builtin.cjs +20 -1
- package/dist/helpers/create-builtin.mjs +18 -1
- package/dist/helpers/create-builtin.mjs.map +1 -1
- package/dist/helpers/index.cjs +25 -1
- package/dist/helpers/index.mjs +6 -1
- package/dist/helpers/refkey.cjs +17 -1
- package/dist/helpers/refkey.mjs +15 -1
- package/dist/helpers/refkey.mjs.map +1 -1
- package/dist/helpers/typescript.cjs +43 -19
- package/dist/helpers/typescript.mjs +41 -19
- package/dist/helpers/typescript.mjs.map +1 -1
- package/dist/index.cjs +55 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +29 -1
- package/dist/markdown/components/front-matter.mjs +27 -1
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/heading.cjs +24 -1
- package/dist/markdown/components/heading.mjs +22 -1
- package/dist/markdown/components/heading.mjs.map +1 -1
- package/dist/markdown/components/index.cjs +13 -1
- package/dist/markdown/components/index.mjs +6 -1
- package/dist/markdown/components/markdown-file.cjs +135 -1
- package/dist/markdown/components/markdown-file.mjs +132 -1
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +102 -1
- package/dist/markdown/components/markdown-table.mjs +98 -1
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/markdown/contexts/index.cjs +7 -1
- package/dist/markdown/contexts/index.mjs +3 -1
- package/dist/markdown/contexts/markdown-table.cjs +38 -1
- package/dist/markdown/contexts/markdown-table.mjs +33 -1
- package/dist/markdown/contexts/markdown-table.mjs.map +1 -1
- package/dist/markdown/index.cjs +20 -1
- package/dist/markdown/index.mjs +9 -1
- package/dist/render.cjs +91 -1
- package/dist/render.mjs +88 -1
- package/dist/render.mjs.map +1 -1
- package/dist/types/components.cjs +9 -0
- package/dist/types/components.mjs +9 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/typescript/components/builtin-file.cjs +63 -1
- package/dist/typescript/components/builtin-file.mjs +61 -1
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +306 -1
- package/dist/typescript/components/class-declaration.mjs +299 -1
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +26 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +24 -1
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +43 -1
- package/dist/typescript/components/entry-file.mjs +40 -1
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/index.cjs +64 -1
- package/dist/typescript/components/index.mjs +15 -1
- package/dist/typescript/components/interface-declaration.cjs +239 -1
- package/dist/typescript/components/interface-declaration.mjs +234 -1
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +139 -1
- package/dist/typescript/components/object-declaration.mjs +136 -1
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +32 -1
- package/dist/typescript/components/property-name.mjs +30 -1
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.cjs +13 -3
- package/dist/typescript/components/record-expression.mjs +11 -3
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +331 -1
- package/dist/typescript/components/tsdoc-reflection.mjs +324 -1
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +497 -1
- package/dist/typescript/components/tsdoc.mjs +475 -1
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +39 -1
- package/dist/typescript/components/type-declaration.mjs +37 -1
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +83 -1
- package/dist/typescript/components/type-parameters.mjs +81 -1
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +221 -1
- package/dist/typescript/components/typescript-file.mjs +217 -1
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/index.cjs +4 -1
- package/dist/typescript/contexts/index.mjs +3 -1
- package/dist/typescript/contexts/lexical-scope.cjs +26 -1
- package/dist/typescript/contexts/lexical-scope.mjs +24 -1
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +24 -1
- package/dist/typescript/contexts/member-scope.mjs +22 -1
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/typescript/helpers/get-call-signature-props.cjs +26 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs +24 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +1 -1
- package/dist/typescript/helpers/index.cjs +6 -1
- package/dist/typescript/helpers/index.mjs +4 -1
- package/dist/typescript/helpers/utilities.cjs +15 -1
- package/dist/typescript/helpers/utilities.mjs +13 -1
- package/dist/typescript/helpers/utilities.mjs.map +1 -1
- package/dist/typescript/index.cjs +73 -1
- package/dist/typescript/index.mjs +21 -1
- package/dist/yaml/components/index.cjs +5 -1
- package/dist/yaml/components/index.mjs +3 -1
- package/dist/yaml/components/yaml-file.cjs +149 -1
- package/dist/yaml/components/yaml-file.mjs +146 -1
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/dist/yaml/index.cjs +6 -1
- package/dist/yaml/index.mjs +4 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-declaration.mjs","names":[],"sources":["../../../src/typescript/components/class-declaration.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 Block,\n Children,\n code,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n CallSignature,\n CallSignatureProps,\n CommonDeclarationProps,\n createMemberSymbol,\n createTypeAndValueSymbol,\n Declaration,\n TSSymbolFlags,\n TypeParameterDescriptor,\n TypeRefContext,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport { LexicalScope } from \"../contexts\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { getCallSignatureProps } from \"../helpers\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc, TSDocParams } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\n/**\n * Props for the ClassDeclaration component, which represents a TypeScript class declaration\n */\nexport interface ClassDeclarationProps extends CommonDeclarationProps {\n /**\n * An indication of whether this class is abstract\n */\n abstract?: boolean;\n\n /**\n * An optional class that this class extends. This will be rendered as an `extends` clause in the class declaration\n */\n extends?: Children;\n\n /**\n * Optional interfaces that this class implements. This will be rendered as an `implements` clause in the class declaration\n */\n implements?: Children[];\n\n /**\n * The generic type parameters of the class.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Create a TypeScript class declaration.\n *\n * @example\n * ```tsx\n * const myPetRefkey = refkey();\n * const Animal = refkey();\n * const staticMember = refkey();\n * const instanceMember = refkey();\n *\n * <ClassDeclaration name=\"Animal\" refkey={Animal}>\n * <ClassMember public static name=\"something\" type=\"string\" refkey={staticMember}>\n * \"hello\"\n * </ClassMember>\n * <ClassMember public name=\"kind\" type=\"string\" />\n * <ClassMember public name=\"name\" type=\"string\" refkey={instanceMember} />\n * <ClassConstructor parameters=\"name: string\">\n * this.name = name;\n * </ClassConstructor>\n * </ClassDeclaration>\n *\n * <VarDeclaration const name=\"myPet\" refkey={myPetRefkey}>\n * new {Animal}();\n * </VarDeclaration>\n *\n * {staticMember}; // Animal.something\n * <MemberReference path={[myPetRefkey, instanceMember]} /> // myPet.name\n * {memberRefkey(myPetRefkey, instanceMember)}\n * ```\n */\nexport function ClassDeclaration(props: ClassDeclarationProps) {\n const extendsPart = props.extends && <> extends {props.extends}</>;\n const implementsPart = props.implements && props.implements.length > 0 && (\n <>\n {\" \"}\n implements{\" \"}\n <For each={props.implements} comma space>\n {implement => implement}\n </For>\n </>\n );\n const sym = createTypeAndValueSymbol(props.name, {\n refkeys: props.refkey,\n export: props.export,\n default: props.default,\n metadata: props.metadata,\n hasInstanceMembers: true,\n namePolicy: useTSNamePolicy().for(\"class\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration symbol={sym} export={props.export} default={props.default}>\n <MemberScope ownerSymbol={sym}>\n {props.abstract && code`abstract `} class <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}\n {implementsPart} <Block>{props.children}</Block>\n </MemberScope>\n </Declaration>\n </>\n );\n}\n\nClassDeclaration.TypeParameters = TypeParameters;\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n */\nexport interface ClassMemberProps {\n name: string | Namekey;\n refkey?: Refkey;\n public?: boolean;\n private?: boolean;\n protected?: boolean;\n jsPrivate?: boolean;\n static?: boolean;\n abstract?: boolean;\n children?: Children;\n doc?: Children;\n nullish?: boolean;\n override?: boolean;\n}\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n *\n * @param props - The properties of the class member, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class member declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMember(props: ClassMemberProps) {\n let tsFlags = TSSymbolFlags.None;\n if (props.nullish) {\n tsFlags |= TSSymbolFlags.Nullish;\n }\n\n const sym = createMemberSymbol(props.name, props, {\n refkeys: props.refkey,\n tsFlags,\n namePolicy: useTSNamePolicy().for(\"class-member-data\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <MemberDeclaration symbol={sym}>\n {props.public && \"public \"}\n {props.private && \"private \"}\n {props.protected && \"protected \"}\n {props.abstract && \"abstract \"}\n {props.override && \"override \"}\n {props.static && \"static \"}\n {props.children}\n </MemberDeclaration>\n </>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassFieldProps extends ClassMemberProps {\n name: string;\n type?: Children;\n optional?: boolean;\n children?: Children;\n isPrivateMember?: boolean;\n}\n\n/**\n * Generates a TypeScript class field declaration for the given reflection class.\n *\n * @param props - The properties of the class field, including its name, type, optionality, and other modifiers.\n * @returns A JSX element representing the class field declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassField(props: ClassFieldProps) {\n const optionality = props.optional ? \"?\" : \"\";\n const typeSection = props.type && (\n <>\n {optionality}: <TypeRefContext>{props.type}</TypeRefContext>\n </>\n );\n const initializerSection = props.children && <> = {props.children}</>;\n const nullish = props.nullish ?? props.optional;\n\n return (\n <ClassMember {...props} nullish={nullish}>\n <PropertyName\n private={props.isPrivateMember}\n name={props.isPrivateMember ? props.name : undefined}\n />\n {typeSection}\n {initializerSection}\n </ClassMember>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassPropertyProps extends ClassMemberProps {\n name: string;\n type?: Children;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class property setter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertySet(props: ClassPropertyProps) {\n return (\n <>\n <ClassMember {...props}>\n {\"set \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n parameters={[\n {\n name: \"value\",\n type: <TypeRefContext>{props.type}</TypeRefContext>\n }\n ]}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n\n/**\n * Generates a TypeScript class property getter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertyGet(props: ClassPropertyProps) {\n return (\n <ClassMember {...props}>\n {\"get \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n returnType={<TypeRefContext>{props.type}</TypeRefContext>}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n );\n}\n\n/**\n * Props for a class method, which is a specific type of class member that represents a function defined within the class.\n */\nexport interface ClassMethodProps extends ClassMemberProps, CallSignatureProps {\n async?: boolean;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class method declaration for the given reflection class.\n *\n * @param props - The properties of the class method, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class method declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMethod(props: ClassMethodProps) {\n const callProps = getCallSignatureProps(props);\n const [_, rest] = splitProps(props, [\"doc\"]);\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc}>\n {Array.isArray(rest.parameters) && (\n <TSDocParams parameters={rest.parameters} />\n )}\n </TSDoc>\n </Show>\n <ClassMember {...rest}>\n {props.async && \"async \"}\n <PropertyName />\n <LexicalScope>\n <CallSignature {...callProps} /> <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n"],"mappings":"ozBA+DE,IAAE,EAAA,EAAA,SAAA,CAAA,YAAA,MAAA,EAAA,QAAA,CAAA,CACC,EAAoB,EAAK,YAAW,EAAU,WAAW,OAAI,GAAS,CAAE,IAAK,aAAY,IAAO,EAAa,EAAA,CAC9G,IAAA,MAAA,CACF,OAAW,EAAE,YAEX,MAAA,GACA,MAAK,GACL,SAAA,GAAA,EACF,CAAA,CAAA,CACF,EAAA,EAAA,EAAA,KAAA,kBAEE,OAAA,EAAA,OACC,QAAS,EAAA,QACX,SAAA,EAAA,SACG,mBAAA,GACA,WAAE,GAAA,CAAA,IAAA,QAAA,CACH,CAAA,CACD,MAAO,CAAA,EAAiB,EAAA,CACvB,IAAK,MAAC,CACN,MAAM,EAAA,EAAiB,KAEtB,IAAA,UAAA,CACE,OAAA,EAAyB,EAAO,CAC9B,IAAA,SAAK,CACN,OAAA,EAAW,KAEZ,CAAA,EAEH,CAAC,CAAE,EAAiB,EAAA,CACnB,OAAG,EACH,IAAC,QAAgB,CACpB,OAAA,EAAA,QAEG,IAAK,SAAU,CACd,OAAA,EAAc,SAEf,IAAA,UAAe,CACf,OAAA,EAAuB,EAAa,CACpC,YAAa,EACZ,IAAA,UAAA,CACH,MAAA,CAAA,MAAA,EAAA,UAAA,CAAA,YAAA,CAAA,UAAA,EAAA,EAAA,EAAA,CAAA,CAAA,MAAA,MAAA,CAAA,CAAA,EAAA,eAAA,EAAA,EAAA,EAAA,EAAA,CACK,IAAS,YAAA,CACR,OAAa,EAAM,gBAEtB,CAAA,CAAA,CAAA,EAAA,EAAA,IAAA,EAAA,EAAA,CACK,IAAA,U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EE,CAAA,EAEA,CAAA,CAAA,EAAA,EAAA,EAAA,EAAA,CACF,IAAO,UAAU,CACf,MAAQ,CAAA,MAAO,EAAA,OAAA,SAAA,CAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACf,IAAU,UAAS,CACrB,MAAA,CAAA,EAAA,EAAA,EAAA,CAAA,IAAA,EAAA,EAAA,CAAA,IAAA,UAAA,CAEE,OAAA,EAAA,UAED,CAAA,CAAA,EAEG,CAAA,CAAA,EAEJ,CAAA,CAAA,CAAM"}
|
|
1
|
+
{"version":3,"file":"class-declaration.mjs","names":[],"sources":["../../../src/typescript/components/class-declaration.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 Block,\n Children,\n code,\n For,\n MemberDeclaration,\n Name,\n Namekey,\n Refkey,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n CallSignature,\n CallSignatureProps,\n CommonDeclarationProps,\n createMemberSymbol,\n createTypeAndValueSymbol,\n Declaration,\n TSSymbolFlags,\n TypeParameterDescriptor,\n TypeRefContext,\n useTSNamePolicy\n} from \"@alloy-js/typescript\";\nimport { LexicalScope } from \"../contexts\";\nimport { MemberScope } from \"../contexts/member-scope\";\nimport { getCallSignatureProps } from \"../helpers\";\nimport { PropertyName } from \"./property-name\";\nimport { TSDoc, TSDocParams } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\n/**\n * Props for the ClassDeclaration component, which represents a TypeScript class declaration\n */\nexport interface ClassDeclarationProps extends CommonDeclarationProps {\n /**\n * An indication of whether this class is abstract\n */\n abstract?: boolean;\n\n /**\n * An optional class that this class extends. This will be rendered as an `extends` clause in the class declaration\n */\n extends?: Children;\n\n /**\n * Optional interfaces that this class implements. This will be rendered as an `implements` clause in the class declaration\n */\n implements?: Children[];\n\n /**\n * The generic type parameters of the class.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Create a TypeScript class declaration.\n *\n * @example\n * ```tsx\n * const myPetRefkey = refkey();\n * const Animal = refkey();\n * const staticMember = refkey();\n * const instanceMember = refkey();\n *\n * <ClassDeclaration name=\"Animal\" refkey={Animal}>\n * <ClassMember public static name=\"something\" type=\"string\" refkey={staticMember}>\n * \"hello\"\n * </ClassMember>\n * <ClassMember public name=\"kind\" type=\"string\" />\n * <ClassMember public name=\"name\" type=\"string\" refkey={instanceMember} />\n * <ClassConstructor parameters=\"name: string\">\n * this.name = name;\n * </ClassConstructor>\n * </ClassDeclaration>\n *\n * <VarDeclaration const name=\"myPet\" refkey={myPetRefkey}>\n * new {Animal}();\n * </VarDeclaration>\n *\n * {staticMember}; // Animal.something\n * <MemberReference path={[myPetRefkey, instanceMember]} /> // myPet.name\n * {memberRefkey(myPetRefkey, instanceMember)}\n * ```\n */\nexport function ClassDeclaration(props: ClassDeclarationProps) {\n const extendsPart = props.extends && <> extends {props.extends}</>;\n const implementsPart = props.implements && props.implements.length > 0 && (\n <>\n {\" \"}\n implements{\" \"}\n <For each={props.implements} comma space>\n {implement => implement}\n </For>\n </>\n );\n const sym = createTypeAndValueSymbol(props.name, {\n refkeys: props.refkey,\n export: props.export,\n default: props.default,\n metadata: props.metadata,\n hasInstanceMembers: true,\n namePolicy: useTSNamePolicy().for(\"class\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <Declaration symbol={sym} export={props.export} default={props.default}>\n <MemberScope ownerSymbol={sym}>\n {props.abstract && code`abstract `} class <Name />\n {props.typeParameters && (\n <TypeParameters parameters={props.typeParameters} />\n )}\n {extendsPart}\n {implementsPart} <Block>{props.children}</Block>\n </MemberScope>\n </Declaration>\n </>\n );\n}\n\nClassDeclaration.TypeParameters = TypeParameters;\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n */\nexport interface ClassMemberProps {\n name: string | Namekey;\n refkey?: Refkey;\n public?: boolean;\n private?: boolean;\n protected?: boolean;\n jsPrivate?: boolean;\n static?: boolean;\n abstract?: boolean;\n children?: Children;\n doc?: Children;\n nullish?: boolean;\n override?: boolean;\n}\n\n/**\n * Generates a TypeScript class member declaration for the given reflection class.\n *\n * @param props - The properties of the class member, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class member declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMember(props: ClassMemberProps) {\n let tsFlags = TSSymbolFlags.None;\n if (props.nullish) {\n tsFlags |= TSSymbolFlags.Nullish;\n }\n\n const sym = createMemberSymbol(props.name, props, {\n refkeys: props.refkey,\n tsFlags,\n namePolicy: useTSNamePolicy().for(\"class-member-data\")\n });\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc} />\n </Show>\n <MemberDeclaration symbol={sym}>\n {props.public && \"public \"}\n {props.private && \"private \"}\n {props.protected && \"protected \"}\n {props.abstract && \"abstract \"}\n {props.override && \"override \"}\n {props.static && \"static \"}\n {props.children}\n </MemberDeclaration>\n </>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassFieldProps extends ClassMemberProps {\n name: string;\n type?: Children;\n optional?: boolean;\n children?: Children;\n isPrivateMember?: boolean;\n}\n\n/**\n * Generates a TypeScript class field declaration for the given reflection class.\n *\n * @param props - The properties of the class field, including its name, type, optionality, and other modifiers.\n * @returns A JSX element representing the class field declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassField(props: ClassFieldProps) {\n const optionality = props.optional ? \"?\" : \"\";\n const typeSection = props.type && (\n <>\n {optionality}: <TypeRefContext>{props.type}</TypeRefContext>\n </>\n );\n const initializerSection = props.children && <> = {props.children}</>;\n const nullish = props.nullish ?? props.optional;\n\n return (\n <ClassMember {...props} nullish={nullish}>\n <PropertyName\n private={props.isPrivateMember}\n name={props.isPrivateMember ? props.name : undefined}\n />\n {typeSection}\n {initializerSection}\n </ClassMember>\n );\n}\n\n/**\n * Props for a class field, which is a specific type of class member that represents a property of the class.\n */\nexport interface ClassPropertyProps extends ClassMemberProps {\n name: string;\n type?: Children;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class property setter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property setter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertySet(props: ClassPropertyProps) {\n return (\n <>\n <ClassMember {...props}>\n {\"set \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n parameters={[\n {\n name: \"value\",\n type: <TypeRefContext>{props.type}</TypeRefContext>\n }\n ]}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n\n/**\n * Generates a TypeScript class property getter declaration for the given reflection class.\n *\n * @param props - The properties of the class property, including its name, type, and other modifiers.\n * @returns A JSX element representing the class property getter declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassPropertyGet(props: ClassPropertyProps) {\n return (\n <ClassMember {...props}>\n {\"get \"}\n <PropertyName name={props.name} />\n <LexicalScope>\n <CallSignature\n returnType={<TypeRefContext>{props.type}</TypeRefContext>}\n />{\" \"}\n <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n );\n}\n\n/**\n * Props for a class method, which is a specific type of class member that represents a function defined within the class.\n */\nexport interface ClassMethodProps extends ClassMemberProps, CallSignatureProps {\n async?: boolean;\n children?: Children;\n}\n\n/**\n * Generates a TypeScript class method declaration for the given reflection class.\n *\n * @param props - The properties of the class method, including its name, visibility, and other modifiers.\n * @returns A JSX element representing the class method declaration, which can be used within a ClassDeclaration component.\n */\nexport function ClassMethod(props: ClassMethodProps) {\n const callProps = getCallSignatureProps(props);\n const [_, rest] = splitProps(props, [\"doc\"]);\n\n return (\n <>\n <Show when={Boolean(props.doc)}>\n <TSDoc heading={props.doc}>\n {Array.isArray(rest.parameters) && (\n <TSDocParams parameters={rest.parameters} />\n )}\n </TSDoc>\n </Show>\n <ClassMember {...rest}>\n {props.async && \"async \"}\n <PropertyName />\n <LexicalScope>\n <CallSignature {...callProps} /> <Block>{props.children}</Block>\n </LexicalScope>\n </ClassMember>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DE,MAAE,cAAA,MAAA,WAAA,CAAA,aAAA,WAAA,MAAA,QAAA,CAAA;CACF,MAAG,iBAAoB,MAAK,cAAW,MAAU,WAAW,SAAI,KAAS;EAAE;EAAK;EAAY;EAAO,gBAAa,KAAA;GAC9G,IAAA,OAAA;AACF,WAAW,MAAE;;GAEX,OAAA;GACA,OAAK;GACL,WAAA,cAAA;GACF,CAAA;EAAA;CACF,MAAA,MAAA,yBAAA,MAAA,MAAA;;EAEE,QAAA,MAAA;EACC,SAAS,MAAA;EACX,UAAA,MAAA;EACG,oBAAA;EACA,YAAE,iBAAA,CAAA,IAAA,QAAA;EACH,CAAA;AACD,QAAO,CAAA,gBAAiB,MAAA;EACvB,IAAK,OAAC;AACN,UAAM,QAAA,MAAiB,IAAA;;EAEtB,IAAA,WAAA;AACE,UAAA,gBAAyB,OAAO,EAC9B,IAAA,UAAK;AACN,WAAA,MAAW;MAEZ,CAAA;;EAEH,CAAC,EAAE,gBAAiB,eAAA;EACnB,QAAG;EACH,KAAC,YAAgB;AACpB,UAAA,MAAA;;EAEG,KAAK,aAAU;AACd,UAAA,MAAc;;EAEf,IAAA,WAAe;AACf,UAAA,gBAAuB,eAAa;IACpC,aAAa;IACZ,IAAA,WAAA;AACH,YAAA;MAAA,WAAA,MAAA,YAAA,IAAA,YAAA;MAAA;M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WAAQ,OAAY,CAAC,MAAI,CAAA;AACzC,QAAA,CAAA,gBAAA,MAAA;EACF,IAAO,OAAQ;AACb,UAAO,QAAA,MAAA,IAAA;;EAEL,IAAI,WAAK;AACP,UAAC,gBAAwB,OAAO;IAC/B,IAAA,UAAY;AACV,YAAA,MAAA;;IAED,IAAI,WAAE;AACL,YAAO,WAAc,CAAC,CAAC,MAAM,QAAA,KAAA,WAAA,CAAA,EAAA,IAAA,gBAAA,aAAA,EAC9B,IAAA,aAAY;AACd,aAAW,KAAA;QAEjB,CAAA;;IAEE,CAAA;;EAEA,CAAA,EAAA,gBAAA,aAAA,WAAA,MAAA,EACF,IAAO,WAAU;AACf,SAAQ;GAAA,WAAO,MAAA,SAAA,SAAA;GAAA,gBAAA,cAAA,EAAA,CAAA;GAAA,gBAAA,cAAA,EACf,IAAU,WAAS;AACrB,WAAA;KAAA,gBAAA,eAAA,UAAA;KAAA;KAAA,gBAAA,OAAA;AAEE,aAAA,MAAA;QAED,CAAA;KAAA;MAEG,CAAA;GAAA;IAEJ,CAAA,CAAA,CAAM"}
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
|
|
7
|
+
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Generates a dynamic import statement for a given module path and export name.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <DynamicImportStatement importPath="./my-module" exportName="myExport" const={true} name="myVar" />
|
|
14
|
+
* // const myVar = await import("./my-module").then(m => m.myExport);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param props - The properties for the dynamic import statement.
|
|
18
|
+
* @returns A `VarDeclaration` component representing the dynamic import statement.
|
|
19
|
+
*/
|
|
20
|
+
function DynamicImportStatement(props) {
|
|
21
|
+
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
22
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)({ "const": isConst }, rest, { initializer: _alloy_js_core.code`await import("${importPath}").then(m => m.${exportName});` }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.DynamicImportStatement = DynamicImportStatement;
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import{createComponent
|
|
1
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
|
+
import { VarDeclaration } from "@alloy-js/typescript";
|
|
4
|
+
|
|
5
|
+
//#region src/typescript/components/dynamic-import-statement.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Generates a dynamic import statement for a given module path and export name.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <DynamicImportStatement importPath="./my-module" exportName="myExport" const={true} name="myVar" />
|
|
12
|
+
* // const myVar = await import("./my-module").then(m => m.myExport);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param props - The properties for the dynamic import statement.
|
|
16
|
+
* @returns A `VarDeclaration` component representing the dynamic import statement.
|
|
17
|
+
*/
|
|
18
|
+
function DynamicImportStatement(props) {
|
|
19
|
+
const { importPath, exportName = "default", const: isConst = true, ...rest } = props;
|
|
20
|
+
return createComponent(VarDeclaration, mergeProps({ "const": isConst }, rest, { initializer: code`await import("${importPath}").then(m => m.${exportName});` }));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { DynamicImportStatement };
|
|
2
25
|
//# sourceMappingURL=dynamic-import-statement.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-import-statement.mjs","names":[],"sources":["../../../src/typescript/components/dynamic-import-statement.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { VarDeclaration, VarDeclarationProps } from \"@alloy-js/typescript\";\n\nexport interface DynamicImportStatementProps extends Omit<\n VarDeclarationProps,\n \"initializer\"\n> {\n /**\n * The path of the module to import.\n */\n importPath: string;\n\n /**\n * The name of the export to import from the module.\n *\n * @defaultValue \"default\"\n */\n exportName?: string;\n}\n\n/**\n * Generates a dynamic import statement for a given module path and export name.\n *\n * @example\n * ```tsx\n * <DynamicImportStatement importPath=\"./my-module\" exportName=\"myExport\" const={true} name=\"myVar\" />\n * // const myVar = await import(\"./my-module\").then(m => m.myExport);\n * ```\n *\n * @param props - The properties for the dynamic import statement.\n * @returns A `VarDeclaration` component representing the dynamic import statement.\n */\nexport function DynamicImportStatement(props: DynamicImportStatementProps) {\n const {\n importPath,\n exportName = \"default\",\n const: isConst = true,\n ...rest\n } = props;\n\n return (\n <VarDeclaration\n const={isConst}\n {...rest}\n initializer={code`await import(\"${importPath}\").then(m => m.${exportName});`}></VarDeclaration>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic-import-statement.mjs","names":[],"sources":["../../../src/typescript/components/dynamic-import-statement.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { VarDeclaration, VarDeclarationProps } from \"@alloy-js/typescript\";\n\nexport interface DynamicImportStatementProps extends Omit<\n VarDeclarationProps,\n \"initializer\"\n> {\n /**\n * The path of the module to import.\n */\n importPath: string;\n\n /**\n * The name of the export to import from the module.\n *\n * @defaultValue \"default\"\n */\n exportName?: string;\n}\n\n/**\n * Generates a dynamic import statement for a given module path and export name.\n *\n * @example\n * ```tsx\n * <DynamicImportStatement importPath=\"./my-module\" exportName=\"myExport\" const={true} name=\"myVar\" />\n * // const myVar = await import(\"./my-module\").then(m => m.myExport);\n * ```\n *\n * @param props - The properties for the dynamic import statement.\n * @returns A `VarDeclaration` component representing the dynamic import statement.\n */\nexport function DynamicImportStatement(props: DynamicImportStatementProps) {\n const {\n importPath,\n exportName = \"default\",\n const: isConst = true,\n ...rest\n } = props;\n\n return (\n <VarDeclaration\n const={isConst}\n {...rest}\n initializer={code`await import(\"${importPath}\").then(m => m.${exportName});`}></VarDeclaration>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,SAAM,uBAAqB,OAAA;CACzB,MAAE,EACF,YACF,aAAA,kCAEE,GAAA,SACC;AACF,QAAA,gBAAA,gBAAA,WAAA,EACG,SAAA,SACD,EAAE,MAAC,EACF,aAAA,IAAA,iBAAkC,WAAM,iBAAoB,WAAU,KACvE,CAAC,CAAC"}
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_core_contexts_context = require('../../core/contexts/context.cjs');
|
|
4
|
+
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
5
|
+
let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
6
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
7
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
8
|
+
let _stryke_path_append = require("@stryke/path/append");
|
|
9
|
+
let _stryke_path_replace = require("@stryke/path/replace");
|
|
10
|
+
let defu = require("defu");
|
|
11
|
+
defu = require_runtime.__toESM(defu);
|
|
12
|
+
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
13
|
+
|
|
14
|
+
//#region src/typescript/components/entry-file.tsx
|
|
15
|
+
/**
|
|
16
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
17
|
+
*
|
|
18
|
+
* @param props - The properties for the source file.
|
|
19
|
+
* @returns The rendered source file component.
|
|
20
|
+
*/
|
|
21
|
+
function EntryFile(props) {
|
|
22
|
+
const [{ children, meta, tsx, path, typeDefinition }, rest] = (0, _alloy_js_core.splitProps)(props, [
|
|
23
|
+
"children",
|
|
24
|
+
"meta",
|
|
25
|
+
"tsx",
|
|
26
|
+
"path",
|
|
27
|
+
"typeDefinition"
|
|
28
|
+
]);
|
|
29
|
+
const context = require_core_contexts_context.usePowerlinesSafe();
|
|
30
|
+
const fullPath = (0, _alloy_js_core.computed)(() => context ? (0, _stryke_path_append.appendPath)(`${!(0, _stryke_type_checks_is_set.isSet)(tsx) ? path : (0, _stryke_path_replace.replaceExtension)(path)}${tsx ? ".tsx" : (0, _stryke_path_file_path_fns.hasFileExtension)(path) ? "" : ".ts"}`, (0, _stryke_path_replace.replacePath)(context.entryPath, context.config.cwd)) : path);
|
|
31
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_typescript_file.TypescriptFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
32
|
+
get path() {
|
|
33
|
+
return fullPath.value;
|
|
34
|
+
},
|
|
35
|
+
get meta() {
|
|
36
|
+
return (0, defu.default)({ kind: "entry" }, meta ?? {}, { typeDefinition });
|
|
37
|
+
},
|
|
38
|
+
children
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.EntryFile = EntryFile;
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
import{usePowerlinesSafe
|
|
1
|
+
import { usePowerlinesSafe } from "../../core/contexts/context.mjs";
|
|
2
|
+
import { TypescriptFile } from "./typescript-file.mjs";
|
|
3
|
+
import { hasFileExtension } from "@stryke/path/file-path-fns";
|
|
4
|
+
import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
5
|
+
import { computed, splitProps } from "@alloy-js/core";
|
|
6
|
+
import { appendPath } from "@stryke/path/append";
|
|
7
|
+
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
8
|
+
import defu from "defu";
|
|
9
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
10
|
+
|
|
11
|
+
//#region src/typescript/components/entry-file.tsx
|
|
12
|
+
/**
|
|
13
|
+
* A base component representing a Powerlines generated Typescript source file.
|
|
14
|
+
*
|
|
15
|
+
* @param props - The properties for the source file.
|
|
16
|
+
* @returns The rendered source file component.
|
|
17
|
+
*/
|
|
18
|
+
function EntryFile(props) {
|
|
19
|
+
const [{ children, meta, tsx, path, typeDefinition }, rest] = splitProps(props, [
|
|
20
|
+
"children",
|
|
21
|
+
"meta",
|
|
22
|
+
"tsx",
|
|
23
|
+
"path",
|
|
24
|
+
"typeDefinition"
|
|
25
|
+
]);
|
|
26
|
+
const context = usePowerlinesSafe();
|
|
27
|
+
const fullPath = computed(() => context ? appendPath(`${!isSet(tsx) ? path : replaceExtension(path)}${tsx ? ".tsx" : hasFileExtension(path) ? "" : ".ts"}`, replacePath(context.entryPath, context.config.cwd)) : path);
|
|
28
|
+
return createComponent(TypescriptFile, mergeProps(rest, {
|
|
29
|
+
get path() {
|
|
30
|
+
return fullPath.value;
|
|
31
|
+
},
|
|
32
|
+
get meta() {
|
|
33
|
+
return defu({ kind: "entry" }, meta ?? {}, { typeDefinition });
|
|
34
|
+
},
|
|
35
|
+
children
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { EntryFile };
|
|
2
41
|
//# sourceMappingURL=entry-file.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-file.mjs","names":[],"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.config.cwd)\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
|
+
{"version":3,"file":"entry-file.mjs","names":[],"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.config.cwd)\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":";;;;;;;;;;;;;;;;;AAkCA,SAAe,UAAA,OAAA;UAEX,UACA,MACA,KACF,MACD;;;;;;;CAEC,MAAA,UAAA,mBAAA;CACA,MAAG,WAAc,eAAe,UAAC,WAAoB,GAAC,CAAA,MAAA,IAAW,GAAA,OAAW,iBAAA,KAAA,GAAA,MAAA,SAAA,iBAAA,KAAA,GAAA,KAAA,SAAA,YAAA,QAAA,WAAA,QAAA,OAAA,IAAA,CAAA,GAAA,KAAA;AAC7E,QAAA,gBAAA,gBAAA,WAAA,MAAA;EACG,IAAA,OAAW;AACX,UAAQ,SAAI;;EAEhB,IAAO,OAAQ;AACb,UAAS,KAAA,EACP,MAAK,SACH,EAAA,QAAW,EAAC,EAAA,EACf;;EAGK;EACL,CAAC,CAAA"}
|
|
@@ -1 +1,64 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
3
|
+
const require_typescript_components_typescript_file = require('./typescript-file.cjs');
|
|
4
|
+
const require_typescript_components_builtin_file = require('./builtin-file.cjs');
|
|
5
|
+
const require_typescript_components_property_name = require('./property-name.cjs');
|
|
6
|
+
const require_typescript_components_type_parameters = require('./type-parameters.cjs');
|
|
7
|
+
const require_typescript_components_class_declaration = require('./class-declaration.cjs');
|
|
8
|
+
const require_typescript_components_dynamic_import_statement = require('./dynamic-import-statement.cjs');
|
|
9
|
+
const require_typescript_components_entry_file = require('./entry-file.cjs');
|
|
10
|
+
const require_typescript_components_tsdoc_reflection = require('./tsdoc-reflection.cjs');
|
|
11
|
+
const require_typescript_components_interface_declaration = require('./interface-declaration.cjs');
|
|
12
|
+
const require_typescript_components_object_declaration = require('./object-declaration.cjs');
|
|
13
|
+
const require_typescript_components_record_expression = require('./record-expression.cjs');
|
|
14
|
+
const require_typescript_components_type_declaration = require('./type-declaration.cjs');
|
|
15
|
+
|
|
16
|
+
exports.BuiltinFile = require_typescript_components_builtin_file.BuiltinFile;
|
|
17
|
+
exports.ClassDeclaration = require_typescript_components_class_declaration.ClassDeclaration;
|
|
18
|
+
exports.ClassField = require_typescript_components_class_declaration.ClassField;
|
|
19
|
+
exports.ClassMember = require_typescript_components_class_declaration.ClassMember;
|
|
20
|
+
exports.ClassMethod = require_typescript_components_class_declaration.ClassMethod;
|
|
21
|
+
exports.ClassPropertyGet = require_typescript_components_class_declaration.ClassPropertyGet;
|
|
22
|
+
exports.ClassPropertySet = require_typescript_components_class_declaration.ClassPropertySet;
|
|
23
|
+
exports.DynamicImportStatement = require_typescript_components_dynamic_import_statement.DynamicImportStatement;
|
|
24
|
+
exports.EntryFile = require_typescript_components_entry_file.EntryFile;
|
|
25
|
+
exports.InterfaceDeclaration = require_typescript_components_interface_declaration.InterfaceDeclaration;
|
|
26
|
+
exports.InterfaceDeclarationProperty = require_typescript_components_interface_declaration.InterfaceDeclarationProperty;
|
|
27
|
+
exports.InterfaceExpression = require_typescript_components_interface_declaration.InterfaceExpression;
|
|
28
|
+
exports.InterfaceMember = require_typescript_components_interface_declaration.InterfaceMember;
|
|
29
|
+
exports.ObjectDeclaration = require_typescript_components_object_declaration.ObjectDeclaration;
|
|
30
|
+
exports.ObjectDeclarationProperty = require_typescript_components_object_declaration.ObjectDeclarationProperty;
|
|
31
|
+
exports.PropertyName = require_typescript_components_property_name.PropertyName;
|
|
32
|
+
exports.RecordExpression = require_typescript_components_record_expression.RecordExpression;
|
|
33
|
+
exports.TSDoc = require_typescript_components_tsdoc.TSDoc;
|
|
34
|
+
exports.TSDocAlias = require_typescript_components_tsdoc.TSDocAlias;
|
|
35
|
+
exports.TSDocAttributesTags = require_typescript_components_tsdoc.TSDocAttributesTags;
|
|
36
|
+
exports.TSDocContextClass = require_typescript_components_tsdoc_reflection.TSDocContextClass;
|
|
37
|
+
exports.TSDocContextMethod = require_typescript_components_tsdoc_reflection.TSDocContextMethod;
|
|
38
|
+
exports.TSDocContextProperty = require_typescript_components_tsdoc_reflection.TSDocContextProperty;
|
|
39
|
+
exports.TSDocDefaultValue = require_typescript_components_tsdoc.TSDocDefaultValue;
|
|
40
|
+
exports.TSDocDomain = require_typescript_components_tsdoc.TSDocDomain;
|
|
41
|
+
exports.TSDocExample = require_typescript_components_tsdoc.TSDocExample;
|
|
42
|
+
exports.TSDocHidden = require_typescript_components_tsdoc.TSDocHidden;
|
|
43
|
+
exports.TSDocIgnore = require_typescript_components_tsdoc.TSDocIgnore;
|
|
44
|
+
exports.TSDocInternal = require_typescript_components_tsdoc.TSDocInternal;
|
|
45
|
+
exports.TSDocLink = require_typescript_components_tsdoc.TSDocLink;
|
|
46
|
+
exports.TSDocModule = require_typescript_components_tsdoc.TSDocModule;
|
|
47
|
+
exports.TSDocParam = require_typescript_components_tsdoc.TSDocParam;
|
|
48
|
+
exports.TSDocParams = require_typescript_components_tsdoc.TSDocParams;
|
|
49
|
+
exports.TSDocPermission = require_typescript_components_tsdoc.TSDocPermission;
|
|
50
|
+
exports.TSDocReadonly = require_typescript_components_tsdoc.TSDocReadonly;
|
|
51
|
+
exports.TSDocReflectionClass = require_typescript_components_tsdoc_reflection.TSDocReflectionClass;
|
|
52
|
+
exports.TSDocReflectionMethod = require_typescript_components_tsdoc_reflection.TSDocReflectionMethod;
|
|
53
|
+
exports.TSDocReflectionProperty = require_typescript_components_tsdoc_reflection.TSDocReflectionProperty;
|
|
54
|
+
exports.TSDocRemarks = require_typescript_components_tsdoc.TSDocRemarks;
|
|
55
|
+
exports.TSDocReturns = require_typescript_components_tsdoc.TSDocReturns;
|
|
56
|
+
exports.TSDocRuntime = require_typescript_components_tsdoc.TSDocRuntime;
|
|
57
|
+
exports.TSDocTag = require_typescript_components_tsdoc.TSDocTag;
|
|
58
|
+
exports.TSDocThrows = require_typescript_components_tsdoc.TSDocThrows;
|
|
59
|
+
exports.TSDocTitle = require_typescript_components_tsdoc.TSDocTitle;
|
|
60
|
+
exports.TypeDeclaration = require_typescript_components_type_declaration.TypeDeclaration;
|
|
61
|
+
exports.TypeParameters = require_typescript_components_type_parameters.TypeParameters;
|
|
62
|
+
exports.TypescriptFile = require_typescript_components_typescript_file.TypescriptFile;
|
|
63
|
+
exports.TypescriptFileHeader = require_typescript_components_typescript_file.TypescriptFileHeader;
|
|
64
|
+
exports.TypescriptFileHeaderImports = require_typescript_components_typescript_file.TypescriptFileHeaderImports;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TSDoc, TSDocAlias, TSDocAttributesTags, TSDocDefaultValue, TSDocDomain, TSDocExample, TSDocHidden, TSDocIgnore, TSDocInternal, TSDocLink, TSDocModule, TSDocParam, TSDocParams, TSDocPermission, TSDocReadonly, TSDocRemarks, TSDocReturns, TSDocRuntime, TSDocTag, TSDocThrows, TSDocTitle } from "./tsdoc.mjs";
|
|
2
|
+
import { TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports } from "./typescript-file.mjs";
|
|
3
|
+
import { BuiltinFile } from "./builtin-file.mjs";
|
|
4
|
+
import { PropertyName } from "./property-name.mjs";
|
|
5
|
+
import { TypeParameters } from "./type-parameters.mjs";
|
|
6
|
+
import { ClassDeclaration, ClassField, ClassMember, ClassMethod, ClassPropertyGet, ClassPropertySet } from "./class-declaration.mjs";
|
|
7
|
+
import { DynamicImportStatement } from "./dynamic-import-statement.mjs";
|
|
8
|
+
import { EntryFile } from "./entry-file.mjs";
|
|
9
|
+
import { TSDocContextClass, TSDocContextMethod, TSDocContextProperty, TSDocReflectionClass, TSDocReflectionMethod, TSDocReflectionProperty } from "./tsdoc-reflection.mjs";
|
|
10
|
+
import { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceExpression, InterfaceMember } from "./interface-declaration.mjs";
|
|
11
|
+
import { ObjectDeclaration, ObjectDeclarationProperty } from "./object-declaration.mjs";
|
|
12
|
+
import { RecordExpression } from "./record-expression.mjs";
|
|
13
|
+
import { TypeDeclaration } from "./type-declaration.mjs";
|
|
14
|
+
|
|
15
|
+
export { BuiltinFile, ClassDeclaration, ClassField, ClassMember, ClassMethod, ClassPropertyGet, ClassPropertySet, DynamicImportStatement, EntryFile, InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceExpression, InterfaceMember, ObjectDeclaration, ObjectDeclarationProperty, PropertyName, RecordExpression, TSDoc, TSDocAlias, TSDocAttributesTags, TSDocContextClass, TSDocContextMethod, TSDocContextProperty, TSDocDefaultValue, TSDocDomain, TSDocExample, TSDocHidden, TSDocIgnore, TSDocInternal, TSDocLink, TSDocModule, TSDocParam, TSDocParams, TSDocPermission, TSDocReadonly, TSDocReflectionClass, TSDocReflectionMethod, TSDocReflectionProperty, TSDocRemarks, TSDocReturns, TSDocRuntime, TSDocTag, TSDocThrows, TSDocTitle, TypeDeclaration, TypeParameters, TypescriptFile, TypescriptFileHeader, TypescriptFileHeaderImports };
|
|
@@ -1 +1,239 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_core_contexts_reflection = require('../../core/contexts/reflection.cjs');
|
|
4
|
+
const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
5
|
+
const require_typescript_contexts_member_scope = require('../contexts/member-scope.cjs');
|
|
6
|
+
const require_typescript_components_property_name = require('./property-name.cjs');
|
|
7
|
+
const require_typescript_components_type_parameters = require('./type-parameters.cjs');
|
|
8
|
+
const require_typescript_components_tsdoc_reflection = require('./tsdoc-reflection.cjs');
|
|
9
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
10
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
11
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
12
|
+
let _stryke_string_format_pascal_case = require("@stryke/string-format/pascal-case");
|
|
13
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
14
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
15
|
+
|
|
16
|
+
//#region src/typescript/components/interface-declaration.tsx
|
|
17
|
+
const InterfaceExpression = (0, _alloy_js_typescript.ensureTypeRefContext)(function InterfaceExpression(props) {
|
|
18
|
+
const symbol = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, "", void 0, {
|
|
19
|
+
transient: true,
|
|
20
|
+
binder: (0, _alloy_js_typescript.useTSLexicalScope)()?.binder
|
|
21
|
+
});
|
|
22
|
+
(0, _alloy_js_core.emitSymbol)(symbol);
|
|
23
|
+
return (0, _alloy_js_core_jsx_runtime.createIntrinsic)("group", { get children() {
|
|
24
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_contexts_member_scope.MemberScope, {
|
|
25
|
+
ownerSymbol: symbol,
|
|
26
|
+
get children() {
|
|
27
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Block, { get children() {
|
|
28
|
+
return props.children;
|
|
29
|
+
} });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
} });
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Create a TypeScript interface member.
|
|
36
|
+
*
|
|
37
|
+
* An interface member can either provide a `name` prop to create a named
|
|
38
|
+
* property, or an `indexer` prop to define an indexer for the interface.
|
|
39
|
+
*
|
|
40
|
+
* The type of the member can be provided either as the `type` prop or as the
|
|
41
|
+
* children of the component.
|
|
42
|
+
*/
|
|
43
|
+
function InterfaceMember(props) {
|
|
44
|
+
const type = props.type ?? props.children;
|
|
45
|
+
const readonly = props.readonly ? "readonly " : "";
|
|
46
|
+
if ("indexer" in props) return [
|
|
47
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
48
|
+
get when() {
|
|
49
|
+
return Boolean(props.doc);
|
|
50
|
+
},
|
|
51
|
+
get children() {
|
|
52
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, { get heading() {
|
|
53
|
+
return props.doc;
|
|
54
|
+
} });
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
readonly,
|
|
58
|
+
"[",
|
|
59
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => props.indexer),
|
|
60
|
+
"]: ",
|
|
61
|
+
type
|
|
62
|
+
];
|
|
63
|
+
const optionality = props.optional ? "?" : "";
|
|
64
|
+
const scope = (0, _alloy_js_typescript.useTSMemberScope)();
|
|
65
|
+
const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, props.name, scope.ownerSymbol.staticMembers, {
|
|
66
|
+
refkeys: props.refkey,
|
|
67
|
+
tsFlags: _alloy_js_typescript.TSSymbolFlags.TypeSymbol | (props.nullish ?? props.optional ? _alloy_js_typescript.TSSymbolFlags.Nullish : _alloy_js_typescript.TSSymbolFlags.None),
|
|
68
|
+
namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("interface-member"),
|
|
69
|
+
binder: scope.binder
|
|
70
|
+
});
|
|
71
|
+
const taken = (0, _alloy_js_core.takeSymbols)();
|
|
72
|
+
(0, _alloy_js_core.effect)(() => {
|
|
73
|
+
if (taken.size > 1) return;
|
|
74
|
+
const symbol = Array.from(taken)[0];
|
|
75
|
+
if (symbol?.isTransient) symbol.moveMembersTo(sym);
|
|
76
|
+
});
|
|
77
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.MemberDeclaration, {
|
|
78
|
+
symbol: sym,
|
|
79
|
+
get children() {
|
|
80
|
+
return [
|
|
81
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
82
|
+
get when() {
|
|
83
|
+
return Boolean(props.doc);
|
|
84
|
+
},
|
|
85
|
+
get children() {
|
|
86
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, { get heading() {
|
|
87
|
+
return props.doc;
|
|
88
|
+
} });
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
readonly,
|
|
92
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_property_name.PropertyName, {}),
|
|
93
|
+
optionality,
|
|
94
|
+
": ",
|
|
95
|
+
type
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const BaseInterfaceDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(function InterfaceDeclaration(props) {
|
|
101
|
+
const ExprSlot = (0, _alloy_js_core.createSymbolSlot)();
|
|
102
|
+
const children = (0, _alloy_js_core.childrenArray)(() => props.children);
|
|
103
|
+
const extendsPart = props.extends ? [" extends ", (0, _alloy_js_core_jsx_runtime.memo)(() => props.extends)] : "";
|
|
104
|
+
const filteredChildren = (0, _alloy_js_core.findUnkeyedChildren)(children);
|
|
105
|
+
const currentScope = (0, _alloy_js_typescript.useTSLexicalScope)();
|
|
106
|
+
const binder = currentScope?.binder;
|
|
107
|
+
const sym = (0, _alloy_js_core.createSymbol)(_alloy_js_typescript.TSOutputSymbol, props.name, currentScope.types, {
|
|
108
|
+
refkeys: props.refkey,
|
|
109
|
+
default: props.default,
|
|
110
|
+
export: props.export,
|
|
111
|
+
metadata: props.metadata,
|
|
112
|
+
tsFlags: _alloy_js_typescript.TSSymbolFlags.TypeSymbol,
|
|
113
|
+
namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("interface"),
|
|
114
|
+
binder
|
|
115
|
+
});
|
|
116
|
+
(0, _alloy_js_core.effect)(() => {
|
|
117
|
+
if (ExprSlot.ref.value) {
|
|
118
|
+
const takenSymbols = ExprSlot.ref.value;
|
|
119
|
+
for (const symbol of takenSymbols) if (symbol.isTransient) symbol.moveMembersTo(sym);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
123
|
+
get when() {
|
|
124
|
+
return Boolean(props.doc);
|
|
125
|
+
},
|
|
126
|
+
get children() {
|
|
127
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, { get heading() {
|
|
128
|
+
return props.doc;
|
|
129
|
+
} });
|
|
130
|
+
}
|
|
131
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.Declaration, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, {
|
|
132
|
+
nameKind: "interface",
|
|
133
|
+
kind: "type",
|
|
134
|
+
symbol: sym,
|
|
135
|
+
get children() {
|
|
136
|
+
return [
|
|
137
|
+
"interface ",
|
|
138
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Name, {}),
|
|
139
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => (0, _alloy_js_core_jsx_runtime.memo)(() => !!props.typeParameters)() && (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_type_parameters.TypeParameters, { get parameters() {
|
|
140
|
+
return props.typeParameters;
|
|
141
|
+
} })),
|
|
142
|
+
extendsPart,
|
|
143
|
+
" ",
|
|
144
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ExprSlot, { get children() {
|
|
145
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceExpression, { children: filteredChildren });
|
|
146
|
+
} })
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
}))];
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* Generates a TypeScript interface for the given reflection class.
|
|
153
|
+
*/
|
|
154
|
+
function InterfaceDeclaration(props) {
|
|
155
|
+
const [{ name, reflection, doc, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, [
|
|
156
|
+
"name",
|
|
157
|
+
"reflection",
|
|
158
|
+
"doc",
|
|
159
|
+
"defaultValue"
|
|
160
|
+
]);
|
|
161
|
+
const interfaceName = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_pascal_case.pascalCase)(((0, _stryke_type_checks_is_string.isString)(name) ? name : name.toString()) || reflection?.getName()));
|
|
162
|
+
const properties = (0, _alloy_js_core.computed)(() => reflection ? reflection.getProperties().filter((item) => !item.isIgnored()).sort((a, b) => a.isReadonly() && b.isReadonly() || !a.isReadonly() && !b.isReadonly() ? a.getNameAsString().localeCompare(b.getNameAsString()) : a.isReadonly() ? 1 : -1) : []);
|
|
163
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
164
|
+
get when() {
|
|
165
|
+
return reflection && properties.value.length > 0;
|
|
166
|
+
},
|
|
167
|
+
get fallback() {
|
|
168
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(BaseInterfaceDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)(props, { get name() {
|
|
169
|
+
return interfaceName.value;
|
|
170
|
+
} }));
|
|
171
|
+
},
|
|
172
|
+
get children() {
|
|
173
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionClassContext.Provider, {
|
|
174
|
+
value: { reflection },
|
|
175
|
+
get children() {
|
|
176
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocReflectionClass, {
|
|
177
|
+
heading: doc,
|
|
178
|
+
reflection
|
|
179
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(BaseInterfaceDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
180
|
+
"export": true,
|
|
181
|
+
get name() {
|
|
182
|
+
return interfaceName.value;
|
|
183
|
+
},
|
|
184
|
+
defaultValue
|
|
185
|
+
}, rest, { get children() {
|
|
186
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
187
|
+
each: properties,
|
|
188
|
+
doubleHardline: true,
|
|
189
|
+
semicolon: true,
|
|
190
|
+
children: (prop) => (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceDeclarationProperty, {
|
|
191
|
+
property: prop,
|
|
192
|
+
get defaultValue() {
|
|
193
|
+
return defaultValue?.value?.[prop.getNameAsString()];
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
});
|
|
197
|
+
} }))];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Generates a TypeScript interface property for the given reflection class.
|
|
205
|
+
*/
|
|
206
|
+
function InterfaceDeclarationProperty(props) {
|
|
207
|
+
const [{ property, defaultValue }, rest] = (0, _alloy_js_core.splitProps)(props, ["property", "defaultValue"]);
|
|
208
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_reflection.ReflectionPropertyContext.Provider, {
|
|
209
|
+
value: {
|
|
210
|
+
property,
|
|
211
|
+
defaultValue
|
|
212
|
+
},
|
|
213
|
+
get children() {
|
|
214
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_reflection.TSDocContextProperty, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(InterfaceMember, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
215
|
+
get name() {
|
|
216
|
+
return property.getNameAsString();
|
|
217
|
+
},
|
|
218
|
+
get readonly() {
|
|
219
|
+
return property.isReadonly();
|
|
220
|
+
},
|
|
221
|
+
get optional() {
|
|
222
|
+
return property.isOptional();
|
|
223
|
+
},
|
|
224
|
+
get nullish() {
|
|
225
|
+
return property.isNullable();
|
|
226
|
+
},
|
|
227
|
+
get type() {
|
|
228
|
+
return (0, _powerlines_deepkit_vendor_type.stringifyType)(property.getType());
|
|
229
|
+
}
|
|
230
|
+
}, rest))];
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
exports.InterfaceDeclaration = InterfaceDeclaration;
|
|
237
|
+
exports.InterfaceDeclarationProperty = InterfaceDeclarationProperty;
|
|
238
|
+
exports.InterfaceExpression = InterfaceExpression;
|
|
239
|
+
exports.InterfaceMember = InterfaceMember;
|