@powerlines/plugin-alloy 0.25.33 → 0.25.35
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/README.md +1 -1
- package/dist/core/components/output.cjs +17 -10
- package/dist/core/components/output.mjs +17 -10
- package/dist/core/components/output.mjs.map +1 -1
- package/dist/core/components/single-line-comment.cjs +6 -4
- package/dist/core/components/single-line-comment.mjs +6 -4
- package/dist/core/components/single-line-comment.mjs.map +1 -1
- package/dist/core/components/source-file.cjs +10 -6
- package/dist/core/components/source-file.mjs +10 -6
- package/dist/core/components/source-file.mjs.map +1 -1
- package/dist/core/components/spacing.cjs +6 -4
- package/dist/core/components/spacing.mjs +6 -4
- package/dist/core/components/spacing.mjs.map +1 -1
- package/dist/index.cjs +13 -18
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +12 -17
- package/dist/index.mjs.map +1 -1
- package/dist/markdown/components/front-matter.cjs +9 -7
- package/dist/markdown/components/front-matter.mjs +9 -7
- package/dist/markdown/components/front-matter.mjs.map +1 -1
- package/dist/markdown/components/markdown-file.cjs +76 -44
- package/dist/markdown/components/markdown-file.mjs +76 -44
- package/dist/markdown/components/markdown-file.mjs.map +1 -1
- package/dist/markdown/components/markdown-table.cjs +49 -28
- package/dist/markdown/components/markdown-table.mjs +49 -28
- package/dist/markdown/components/markdown-table.mjs.map +1 -1
- package/dist/render.cjs +3 -3
- package/dist/render.mjs +4 -4
- package/dist/render.mjs.map +1 -1
- package/dist/typescript/components/builtin-file.cjs +29 -19
- package/dist/typescript/components/builtin-file.mjs +30 -20
- package/dist/typescript/components/builtin-file.mjs.map +1 -1
- package/dist/typescript/components/class-declaration.cjs +165 -100
- package/dist/typescript/components/class-declaration.mjs +165 -100
- package/dist/typescript/components/class-declaration.mjs.map +1 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +2 -6
- package/dist/typescript/components/dynamic-import-statement.mjs +2 -6
- package/dist/typescript/components/dynamic-import-statement.mjs.map +1 -1
- package/dist/typescript/components/entry-file.cjs +9 -6
- package/dist/typescript/components/entry-file.mjs +10 -7
- package/dist/typescript/components/entry-file.mjs.map +1 -1
- package/dist/typescript/components/infrastructure-file.cjs +9 -6
- package/dist/typescript/components/infrastructure-file.mjs +10 -7
- package/dist/typescript/components/infrastructure-file.mjs.map +1 -1
- package/dist/typescript/components/interface-declaration.cjs +121 -70
- package/dist/typescript/components/interface-declaration.mjs +121 -70
- package/dist/typescript/components/interface-declaration.mjs.map +1 -1
- package/dist/typescript/components/object-declaration.cjs +76 -44
- package/dist/typescript/components/object-declaration.mjs +76 -44
- package/dist/typescript/components/object-declaration.mjs.map +1 -1
- package/dist/typescript/components/property-name.cjs +3 -3
- package/dist/typescript/components/property-name.mjs +3 -3
- package/dist/typescript/components/property-name.mjs.map +1 -1
- package/dist/typescript/components/record-expression.mjs.map +1 -1
- package/dist/typescript/components/tsdoc-reflection.cjs +225 -104
- package/dist/typescript/components/tsdoc-reflection.mjs +225 -104
- package/dist/typescript/components/tsdoc-reflection.mjs.map +1 -1
- package/dist/typescript/components/tsdoc.cjs +255 -160
- package/dist/typescript/components/tsdoc.mjs +255 -160
- package/dist/typescript/components/tsdoc.mjs.map +1 -1
- package/dist/typescript/components/type-declaration.cjs +20 -15
- package/dist/typescript/components/type-declaration.mjs +20 -15
- package/dist/typescript/components/type-declaration.mjs.map +1 -1
- package/dist/typescript/components/type-parameters.cjs +55 -29
- package/dist/typescript/components/type-parameters.mjs +55 -29
- package/dist/typescript/components/type-parameters.mjs.map +1 -1
- package/dist/typescript/components/typescript-file.cjs +145 -80
- package/dist/typescript/components/typescript-file.mjs +145 -80
- package/dist/typescript/components/typescript-file.mjs.map +1 -1
- package/dist/typescript/contexts/lexical-scope.cjs +5 -3
- package/dist/typescript/contexts/lexical-scope.mjs +5 -3
- package/dist/typescript/contexts/lexical-scope.mjs.map +1 -1
- package/dist/typescript/contexts/member-scope.cjs +5 -3
- package/dist/typescript/contexts/member-scope.mjs +5 -3
- package/dist/typescript/contexts/member-scope.mjs.map +1 -1
- package/dist/yaml/components/yaml-file.cjs +92 -47
- package/dist/yaml/components/yaml-file.mjs +92 -47
- package/dist/yaml/components/yaml-file.mjs.map +1 -1
- package/package.json +16 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdoc.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n childrenArray,\n computed,\n For,\n List,\n Prose,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport { JSDocExampleProps, ParameterDescriptor } from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport {\n ReflectionKind,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport interface TSDocProps extends ComponentProps {\n heading?: Children;\n}\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function TSDoc(props: TSDocProps) {\n const [{ children, heading }] = splitProps(props, [\"children\", \"heading\"]);\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={!isUndefined(heading)}>{heading}</Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={!isUndefined(heading)}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </align>\n <hbr />\n {`*/`}\n <hbr />\n </>\n );\n}\n\nexport interface TSDocTagProps extends ComponentProps {\n tag: string;\n}\n\n/**\n * Create a TSDoc `@<props.tag>` tag.\n */\nexport function TSDocTag(props: TSDocTagProps) {\n const [{ children, tag }] = splitProps(props, [\"children\", \"tag\"]);\n\n return (\n <>\n {`@${tag} `}\n <Show when={Boolean(children)}>\n <align width={2}>\n <Prose>{children}</Prose>\n </align>\n </Show>\n <sbr />\n </>\n );\n}\n\nexport interface TSDocParamsProps {\n parameters: ParameterDescriptor[] | string[];\n}\n\n/**\n * A component that creates a TSDoc block with `@param` tags for each parameter.\n */\nexport function TSDocParams(props: TSDocParamsProps) {\n const parameters = normalizeParametersForDoc(props.parameters);\n\n return (\n <For each={parameters}>\n {param => (\n <TSDocParam name={param.name} optional={param.optional}>\n {param.doc}\n </TSDocParam>\n )}\n </For>\n );\n}\n\nfunction normalizeParametersForDoc(\n parameters: ParameterDescriptor[] | string[]\n): ParameterDescriptor[] {\n if (parameters.some(p => typeof p === \"string\")) {\n return [];\n }\n\n return parameters as ParameterDescriptor[];\n}\n\n/**\n * Create a TSDoc `@title` tag.\n */\nexport function TSDocTitle(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"title\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@domain` tag.\n */\nexport function TSDocDomain(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"domain\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@alias` tag.\n */\nexport function TSDocAlias(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"alias\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@permission` tag.\n */\nexport function TSDocPermission(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"permission\">\n {children}\n </TSDocTag>\n );\n}\n\nexport interface TSDocDefaultValueProps extends ComponentProps {\n type: ReflectionKind | ReflectionProperty | ReflectionParameter;\n defaultValue: any;\n}\n\n/**\n * Create a TSDoc `@defaultValue` tag.\n */\nexport function TSDocDefaultValue(props: TSDocDefaultValueProps) {\n const [{ type, defaultValue }] = splitProps(props, [\"type\", \"defaultValue\"]);\n\n return (\n <>\n {\"@defaultValue \"}\n <Show when={!isUndefined(defaultValue)}>\n <align width={2}>\n <Prose>{stringifyDefaultValue(type, defaultValue)}</Prose>\n </align>\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@remarks` tag.\n */\nexport function TSDocRemarks(props: ComponentProps) {\n return (\n <>\n {\"@remarks \"}\n <hbr />\n <List hardline={true}>{childrenArray(() => props.children)}</List>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@see` tag.\n */\nexport function TSDocLink(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"see\" />;\n}\n\nexport interface TSDocExampleProps extends JSDocExampleProps {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n}\n\n/**\n * Create a TSDoc `@example` tag.\n */\nexport function TSDocExample(props: TSDocExampleProps) {\n const [{ tsx, fenced = true, language, children }] = splitProps(props, [\n \"tsx\",\n \"fenced\",\n \"language\",\n \"children\"\n ]);\n\n return (\n <>\n {\"@example \"}\n <hbr />\n <Show when={fenced}>\n ```{language || (tsx ? \"tsx\" : \"ts\")}\n <hbr />\n </Show>\n {children}\n <Show when={fenced}>\n <hbr />\n ```\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@readonly` tag.\n */\nexport function TSDocReadonly() {\n return <TSDocTag tag=\"readonly\" />;\n}\n\n/**\n * Create a TSDoc `@internal` tag.\n */\nexport function TSDocInternal() {\n return <TSDocTag tag=\"internal\" />;\n}\n\n/**\n * Create a TSDoc `@ignore` tag.\n */\nexport function TSDocIgnore() {\n return <TSDocTag tag=\"ignore\" />;\n}\n\n/**\n * Create a TSDoc `@hidden` tag.\n */\nexport function TSDocHidden() {\n return <TSDocTag tag=\"hidden\" />;\n}\n\nexport interface TSDocAttributesTagsProps {\n type?: ReflectionKind | ReflectionProperty | ReflectionParameter;\n title?: string;\n alias?: string[];\n permission?: string[];\n domain?: string;\n readonly?: boolean;\n internal?: boolean;\n ignore?: boolean;\n hidden?: boolean;\n defaultValue?: any;\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function TSDocAttributesTags(props: TSDocAttributesTagsProps) {\n const [\n {\n type,\n alias,\n permission,\n readonly,\n internal,\n ignore,\n hidden,\n defaultValue\n }\n ] = splitProps(props, [\n \"type\",\n \"alias\",\n \"permission\",\n \"readonly\",\n \"internal\",\n \"ignore\",\n \"hidden\",\n \"defaultValue\"\n ]);\n\n const title = computed(() => props.title?.trim() || \"\");\n const domain = computed(() => props.domain?.trim() || \"\");\n\n return (\n <>\n <Show when={isSetString(title.value)}>\n <TSDocTitle>{title.value}</TSDocTitle>\n </Show>\n <Show\n when={\n !isUndefined(alias) &&\n alias.length > 0 &&\n alias.some(a => isSetString(a?.trim()))\n }>\n <For each={alias?.filter(a => isSetString(a?.trim())) ?? []}>\n {alias => <TSDocAlias>{alias}</TSDocAlias>}\n </For>\n </Show>\n <Show when={isSetString(domain.value)}>\n <TSDocDomain>{domain.value}</TSDocDomain>\n </Show>\n <Show\n when={\n !isUndefined(permission) &&\n permission.length > 0 &&\n permission.some(p => isSetString(p?.trim()))\n }>\n <For each={permission?.filter(p => isSetString(p?.trim())) ?? []}>\n {permission => <TSDocPermission>{permission}</TSDocPermission>}\n </For>\n </Show>\n <Show when={readonly === true}>\n <TSDocReadonly />\n </Show>\n <Show when={internal === true}>\n <TSDocInternal />\n </Show>\n <Show when={ignore === true}>\n <TSDocIgnore />\n </Show>\n <Show when={hidden === true}>\n <TSDocHidden />\n </Show>\n <Show when={!isUndefined(type) && !isUndefined(defaultValue)}>\n <TSDocDefaultValue\n type={\n type as ReflectionKind | ReflectionProperty | ReflectionParameter\n }\n defaultValue={defaultValue}\n />\n </Show>\n </>\n );\n}\n\nexport interface TSDocParamProps {\n name: Children;\n children?: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\n/**\n * Create a TSDoc parameter set off with `@param`.\n */\nexport function TSDocParam(props: TSDocParamProps) {\n return (\n <>\n {\"@param \"}\n <TSDocParamName\n name={props.name}\n optional={props.optional}\n defaultValue={props.defaultValue}\n />\n <TSDocParamDescription children={props.children} />\n </>\n );\n}\n\ninterface TSDocParamNameProps {\n name: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\nfunction TSDocParamName(props: TSDocParamNameProps) {\n return (\n <>\n <Show when={props.optional}>{\"[\"}</Show>\n {props.name}\n <Show when={Boolean(props.defaultValue)}>={props.defaultValue}</Show>\n <Show when={props.optional}>{\"]\"}</Show>\n </>\n );\n}\n\ninterface TSDocParamDescriptionProps {\n children?: Children;\n}\n\nfunction TSDocParamDescription(props: TSDocParamDescriptionProps) {\n return (\n <Show when={Boolean(props.children)}>\n {\" - \"}\n <align width={2}>\n <Prose>{props.children}</Prose>\n </align>\n </Show>\n );\n}\n\n/**\n * Create a TSDoc `@returns` tag.\n */\nexport function TSDocReturns(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"returns\" />;\n}\n\n/**\n * Create a TSDoc `@throws` tag.\n */\nexport function TSDocThrows(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"throws\" />;\n}\n\nexport interface TSDocModuleProps extends ComponentProps {\n /**\n * The prefix for the builtin module name\n *\n * @remarks\n * This value is populated from the Powerlines configuration output builtin prefix by default.\n *\n * @example\n * ```ts\n * /**\n * @module powerlines:my-module\n * \\/\n * ```\n */\n prefix?: string;\n\n /**\n * The name of the module\n *\n * @remarks\n * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.\n *\n * @example\n * ```ts\n * import { MyModule } from \"powerlines:my-module\";\n * ```\n */\n name: Children;\n}\n\n/**\n * Generates a TSDoc `@module` tag for the given module name.\n */\nexport function TSDocModule(props: TSDocModuleProps) {\n const [{ children, name, prefix }] = splitProps(props, [\n \"children\",\n \"name\",\n \"prefix\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={Boolean(children)}>\n <List hardline={true}>{childrenArray(() => children)}</List>\n <Spacing />\n </Show>\n {\"@module \"}\n {prefix || context?.config?.framework || \"powerlines\"}:{name}\n </align>\n <hbr />\n {` */`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAgDA,SAAgB,MAAM,OAAmB;CACvC,MAAM,CAAC,EAAE,UAAU,aAAa,WAAW,OAAO,CAAC,YAAY,UAAU,CAAC;AAE1E,QACE;EAAE;EAEA,qBAAC,SAAD;GAAO,QAAO;aAAd;IACE,oBAAC,OAAD,EAAO;IACP,oBAAC,MAAD;KAAM,MAAM,CAAC,YAAY,QAAQ;eAAG;KAAe;IACnD,qBAAC,MAAD;KACE,MACE,CAAC,YAAY,SAAS,IACtB,oBAAoB,SAAS,CAAC,OAAO,QAAQ,CAAC,SAAS;eAH3D,CAKE,oBAAC,MAAD;MAAM,MAAM,CAAC,YAAY,QAAQ;gBAC/B,oBAAC,SAAD,EAAW;MACN,GACP,oBAAC,MAAD,YAAO,oBAAoB,SAAS,EAAQ,EACvC;;IACD;;EACR,oBAAC,OAAD,EAAO;EACN;EACD,oBAAC,OAAD,EAAO;EACN;;;;;AAWP,SAAgB,SAAS,OAAsB;CAC7C,MAAM,CAAC,EAAE,UAAU,SAAS,WAAW,OAAO,CAAC,YAAY,MAAM,CAAC;AAElE,QACE;EACG,IAAI,IAAI;EACT,oBAAC,MAAD;GAAM,MAAM,QAAQ,SAAS;aAC3B,o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AU,MAAM,UAAY;EAClD;;AAUP,SAAS,eAAe,OAA4B;AAClD,QACE;EACE,oBAAC,MAAD;GAAM,MAAM,MAAM;aAAW;GAAW;EACvC,MAAM;EACP,qBAAC,MAAD;GAAM,MAAM,QAAQ,MAAM,aAAa;aAAvC,CAAyC,KAAE,MAAM,aAAoB;;EACrE,oBAAC,MAAD;GAAM,MAAM,MAAM;aAAW;GAAW;EACvC;;AAQP,SAAS,sBAAsB,OAAmC;AAChE,QACE,qBAAC,MAAD;EAAM,MAAM,QAAQ,MAAM,SAAS;YAAnC,CACG,OACD,oBAAC,SAAD;GAAO,OAAO;aACZ,oBAAC,OAAD,YAAQ,MAAM,UAAiB;GACzB,EACH;;;;;;AAOX,SAAgB,aAAa,OAAuB;AAClD,QAAO,oBAAC,UAAD;EAAU,GAAI;EAAO,KAAI;EAAY;;;;;AAM9C,SAAgB,YAAY,OAAuB;AACjD,QAAO,oBAAC,UAAD;EAAU,GAAI;EAAO,KAAI;EAAW;;;;;AAoC7C,SAAgB,YAAY,OAAyB;CACnD,MAAM,CAAC,EAAE,UAAU,MAAM,YAAY,WAAW,OAAO;EACrD;EACA;EACA;EACD,CAAC;CAEF,MAAM,UAAU,mBAAmB;AAEnC,QACE;EAAE;EAEA,qBAAC,SAAD;GAAO,QAAO;aAAd;IACE,oBAAC,OAAD,EAAO;IACP,qBAAC,MAAD;KAAM,MAAM,QAAQ,SAAS;eAA7B,CACE,oBAAC,MAAD;MAAM,UAAU;gBAAO,oBAAoB,SAAS;MAAQ,GAC5D,oBAAC,SAAD,EAAW,EACN;;IACN;IACA,UAAU,SAAS,QAAQ,aAAa;IAAa;IAAE;IAClD;;EACR,oBAAC,OAAD,EAAO;EACN;EACA"}
|
|
1
|
+
{"version":3,"file":"tsdoc.mjs","names":[],"sources":["../../../src/typescript/components/tsdoc.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n Children,\n childrenArray,\n computed,\n For,\n List,\n Prose,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport { JSDocExampleProps, ParameterDescriptor } from \"@alloy-js/typescript\";\nimport { stringifyDefaultValue } from \"@powerlines/deepkit/utilities\";\nimport {\n ReflectionKind,\n ReflectionParameter,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport { Spacing } from \"../../core/components/spacing\";\nimport { usePowerlinesSafe } from \"../../core/contexts/context\";\nimport { ComponentProps } from \"../../types/components\";\n\nexport interface TSDocProps extends ComponentProps {\n heading?: Children;\n}\n\n/**\n * Generates a TypeScript interface for the given reflection class.\n */\nexport function TSDoc(props: TSDocProps) {\n const [{ children, heading }] = splitProps(props, [\"children\", \"heading\"]);\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={!isUndefined(heading)}>{heading}</Show>\n <Show\n when={\n !isUndefined(children) &&\n childrenArray(() => children).filter(Boolean).length > 0\n }>\n <Show when={!isUndefined(heading)}>\n <Spacing />\n </Show>\n <List>{childrenArray(() => children)}</List>\n </Show>\n </align>\n <hbr />\n {`*/`}\n <hbr />\n </>\n );\n}\n\nexport interface TSDocTagProps extends ComponentProps {\n tag: string;\n}\n\n/**\n * Create a TSDoc `@<props.tag>` tag.\n */\nexport function TSDocTag(props: TSDocTagProps) {\n const [{ children, tag }] = splitProps(props, [\"children\", \"tag\"]);\n\n return (\n <>\n {`@${tag} `}\n <Show when={Boolean(children)}>\n <align width={2}>\n <Prose>{children}</Prose>\n </align>\n </Show>\n <sbr />\n </>\n );\n}\n\nexport interface TSDocParamsProps {\n parameters: ParameterDescriptor[] | string[];\n}\n\n/**\n * A component that creates a TSDoc block with `@param` tags for each parameter.\n */\nexport function TSDocParams(props: TSDocParamsProps) {\n const parameters = normalizeParametersForDoc(props.parameters);\n\n return (\n <For each={parameters}>\n {param => (\n <TSDocParam name={param.name} optional={param.optional}>\n {param.doc}\n </TSDocParam>\n )}\n </For>\n );\n}\n\nfunction normalizeParametersForDoc(\n parameters: ParameterDescriptor[] | string[]\n): ParameterDescriptor[] {\n if (parameters.some(p => typeof p === \"string\")) {\n return [];\n }\n\n return parameters as ParameterDescriptor[];\n}\n\n/**\n * Create a TSDoc `@title` tag.\n */\nexport function TSDocTitle(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"title\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@domain` tag.\n */\nexport function TSDocDomain(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"domain\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@alias` tag.\n */\nexport function TSDocAlias(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"alias\">\n {children}\n </TSDocTag>\n );\n}\n\n/**\n * Create a TSDoc `@permission` tag.\n */\nexport function TSDocPermission(props: ComponentProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <TSDocTag {...rest} tag=\"permission\">\n {children}\n </TSDocTag>\n );\n}\n\nexport interface TSDocDefaultValueProps extends ComponentProps {\n type: ReflectionKind | ReflectionProperty | ReflectionParameter;\n defaultValue: any;\n}\n\n/**\n * Create a TSDoc `@defaultValue` tag.\n */\nexport function TSDocDefaultValue(props: TSDocDefaultValueProps) {\n const [{ type, defaultValue }] = splitProps(props, [\"type\", \"defaultValue\"]);\n\n return (\n <>\n {\"@defaultValue \"}\n <Show when={!isUndefined(defaultValue)}>\n <align width={2}>\n <Prose>{stringifyDefaultValue(type, defaultValue)}</Prose>\n </align>\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@remarks` tag.\n */\nexport function TSDocRemarks(props: ComponentProps) {\n return (\n <>\n {\"@remarks \"}\n <hbr />\n <List hardline={true}>{childrenArray(() => props.children)}</List>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@see` tag.\n */\nexport function TSDocLink(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"see\" />;\n}\n\nexport interface TSDocExampleProps extends JSDocExampleProps {\n /**\n * Whether the file is a TSX file.\n *\n * @defaultValue false\n */\n tsx?: boolean;\n}\n\n/**\n * Create a TSDoc `@example` tag.\n */\nexport function TSDocExample(props: TSDocExampleProps) {\n const [{ tsx, fenced = true, language, children }] = splitProps(props, [\n \"tsx\",\n \"fenced\",\n \"language\",\n \"children\"\n ]);\n\n return (\n <>\n {\"@example \"}\n <hbr />\n <Show when={fenced}>\n ```{language || (tsx ? \"tsx\" : \"ts\")}\n <hbr />\n </Show>\n {children}\n <Show when={fenced}>\n <hbr />\n ```\n </Show>\n </>\n );\n}\n\n/**\n * Create a TSDoc `@readonly` tag.\n */\nexport function TSDocReadonly() {\n return <TSDocTag tag=\"readonly\" />;\n}\n\n/**\n * Create a TSDoc `@internal` tag.\n */\nexport function TSDocInternal() {\n return <TSDocTag tag=\"internal\" />;\n}\n\n/**\n * Create a TSDoc `@ignore` tag.\n */\nexport function TSDocIgnore() {\n return <TSDocTag tag=\"ignore\" />;\n}\n\n/**\n * Create a TSDoc `@hidden` tag.\n */\nexport function TSDocHidden() {\n return <TSDocTag tag=\"hidden\" />;\n}\n\nexport interface TSDocAttributesTagsProps {\n type?: ReflectionKind | ReflectionProperty | ReflectionParameter;\n title?: string;\n alias?: string[];\n permission?: string[];\n domain?: string;\n readonly?: boolean;\n internal?: boolean;\n ignore?: boolean;\n hidden?: boolean;\n defaultValue?: any;\n}\n\n/**\n * Generates a TypeScript interface property for the given reflection class.\n */\nexport function TSDocAttributesTags(props: TSDocAttributesTagsProps) {\n const [\n {\n type,\n alias,\n permission,\n readonly,\n internal,\n ignore,\n hidden,\n defaultValue\n }\n ] = splitProps(props, [\n \"type\",\n \"alias\",\n \"permission\",\n \"readonly\",\n \"internal\",\n \"ignore\",\n \"hidden\",\n \"defaultValue\"\n ]);\n\n const title = computed(() => props.title?.trim() || \"\");\n const domain = computed(() => props.domain?.trim() || \"\");\n\n return (\n <>\n <Show when={isSetString(title.value)}>\n <TSDocTitle>{title.value}</TSDocTitle>\n </Show>\n <Show\n when={\n !isUndefined(alias) &&\n alias.length > 0 &&\n alias.some(a => isSetString(a?.trim()))\n }>\n <For each={alias?.filter(a => isSetString(a?.trim())) ?? []}>\n {alias => <TSDocAlias>{alias}</TSDocAlias>}\n </For>\n </Show>\n <Show when={isSetString(domain.value)}>\n <TSDocDomain>{domain.value}</TSDocDomain>\n </Show>\n <Show\n when={\n !isUndefined(permission) &&\n permission.length > 0 &&\n permission.some(p => isSetString(p?.trim()))\n }>\n <For each={permission?.filter(p => isSetString(p?.trim())) ?? []}>\n {permission => <TSDocPermission>{permission}</TSDocPermission>}\n </For>\n </Show>\n <Show when={readonly === true}>\n <TSDocReadonly />\n </Show>\n <Show when={internal === true}>\n <TSDocInternal />\n </Show>\n <Show when={ignore === true}>\n <TSDocIgnore />\n </Show>\n <Show when={hidden === true}>\n <TSDocHidden />\n </Show>\n <Show when={!isUndefined(type) && !isUndefined(defaultValue)}>\n <TSDocDefaultValue\n type={\n type as ReflectionKind | ReflectionProperty | ReflectionParameter\n }\n defaultValue={defaultValue}\n />\n </Show>\n </>\n );\n}\n\nexport interface TSDocParamProps {\n name: Children;\n children?: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\n/**\n * Create a TSDoc parameter set off with `@param`.\n */\nexport function TSDocParam(props: TSDocParamProps) {\n return (\n <>\n {\"@param \"}\n <TSDocParamName\n name={props.name}\n optional={props.optional}\n defaultValue={props.defaultValue}\n />\n <TSDocParamDescription children={props.children} />\n </>\n );\n}\n\ninterface TSDocParamNameProps {\n name: Children;\n optional?: boolean;\n defaultValue?: Children;\n}\n\nfunction TSDocParamName(props: TSDocParamNameProps) {\n return (\n <>\n <Show when={props.optional}>{\"[\"}</Show>\n {props.name}\n <Show when={Boolean(props.defaultValue)}>={props.defaultValue}</Show>\n <Show when={props.optional}>{\"]\"}</Show>\n </>\n );\n}\n\ninterface TSDocParamDescriptionProps {\n children?: Children;\n}\n\nfunction TSDocParamDescription(props: TSDocParamDescriptionProps) {\n return (\n <Show when={Boolean(props.children)}>\n {\" - \"}\n <align width={2}>\n <Prose>{props.children}</Prose>\n </align>\n </Show>\n );\n}\n\n/**\n * Create a TSDoc `@returns` tag.\n */\nexport function TSDocReturns(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"returns\" />;\n}\n\n/**\n * Create a TSDoc `@throws` tag.\n */\nexport function TSDocThrows(props: ComponentProps) {\n return <TSDocTag {...props} tag=\"throws\" />;\n}\n\nexport interface TSDocModuleProps extends ComponentProps {\n /**\n * The prefix for the builtin module name\n *\n * @remarks\n * This value is populated from the Powerlines configuration output builtin prefix by default.\n *\n * @example\n * ```ts\n * /**\n * @module powerlines:my-module\n * \\/\n * ```\n */\n prefix?: string;\n\n /**\n * The name of the module\n *\n * @remarks\n * This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.\n *\n * @example\n * ```ts\n * import { MyModule } from \"powerlines:my-module\";\n * ```\n */\n name: Children;\n}\n\n/**\n * Generates a TSDoc `@module` tag for the given module name.\n */\nexport function TSDocModule(props: TSDocModuleProps) {\n const [{ children, name, prefix }] = splitProps(props, [\n \"children\",\n \"name\",\n \"prefix\"\n ]);\n\n const context = usePowerlinesSafe();\n\n return (\n <>\n /**\n <align string=\" * \">\n <hbr />\n <Show when={Boolean(children)}>\n <List hardline={true}>{childrenArray(() => children)}</List>\n <Spacing />\n </Show>\n {\"@module \"}\n {prefix || context?.config?.framework || \"powerlines\"}:{name}\n </align>\n <hbr />\n {` */`}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmCA,SAAS,MAAa,OAAmB;CACzC,MAAQ,CAAC,EACT,UACA,aACO,WAAE,OAAgB,CAAC,YAAY,UAAM,CAAA;;;;GAE5C,QAAO;GACL,IAAA,WAAU;AACZ,WAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,MAAA;;AAEE,cAAA,CAAA,YAAA,QAAA;;MAEA,UAAA;MACK,CAAA;KAAA,gBAAqB,MAAC;MACrB,IAAG,OAAQ;;;MAGd,IAAA,WAAA;AACG,cAAA,CAAA,gBAAA,MAAA;QACI,IAAC,OAAU;AACT,gBAAA,CAAA,YAAA,QAAA;;QAEL,IAAA,WAAA;AACK,gBAAC,gBAAA,SAAA,EAAA,CAAA;;QAEJ,CAAC,EAAA,gBAAoB,MAAA,EACrB,IAAA,WAAA;AACA,eAAU,oBAAc,SAAS;UAEjC,CAAC,CAAA;;MAEL,CAAC;KAAC;;GAEN,CAAC;EAAE,gBAAM,OAAA,EAAA,CAAA;EAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AASZ,SAAA,SAAA,OAAA;UAEE,UACC,SACD,WAAA,OAAA,CAAA,YAAA,MAAA,CAAA;AACF,QAAO;EAAA,IAAA,IAAS;EAAA,gBAAgB,MAAc;GAC5C,IAAM,OAAG;;;GAGP,IAAC,WAAA;AACC,WAAK,gBAAM,SAAA;KACV,OAAK;KACJ,IAAC,WAAc;AACb,aAAO,gBAAiB,OAAA,EACnB,UACP,CAAI;;KAEN,CAAA;;GAEN,CAAA;EAAA,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AASA,SAAgB,YAAY,OAAyB;;EAGnD,MAFmB,0BAA0B,MAAM,WAAW;EAG5D,WAAU,UAAC,gBAAW,YAAA;GACpB,IAAC,OAAS;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OAAA,EACN,KAAC,WACF,CAAC,CAAA;;;;;AAMJ,SAAQ,YAAA,OAAA;AACN,QAAK,gBAAkB,UAAA,WAAA,OAAA,EACrB,KAAK,UACN,CAAC,CAAC"}
|
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_typescript_components_tsdoc = require('./tsdoc.cjs');
|
|
4
4
|
const require_typescript_components_type_parameters = require('./type-parameters.cjs');
|
|
5
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
6
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
7
7
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
8
|
|
|
9
9
|
//#region src/typescript/components/type-declaration.tsx
|
|
@@ -12,22 +12,27 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
12
12
|
*/
|
|
13
13
|
const TypeDeclaration = (0, _alloy_js_typescript.ensureTypeRefContext)(function TypeDeclaration(props) {
|
|
14
14
|
const { children, doc, typeParameters, ...rest } = props;
|
|
15
|
-
return
|
|
16
|
-
when
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
16
|
+
get when() {
|
|
17
|
+
return Boolean(doc);
|
|
18
|
+
},
|
|
19
|
+
get children() {
|
|
20
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc.TSDoc, { heading: doc });
|
|
21
|
+
}
|
|
22
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.Declaration, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
20
23
|
kind: "type",
|
|
21
24
|
nameKind: "type",
|
|
22
|
-
children
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
get children() {
|
|
26
|
+
return [
|
|
27
|
+
"type ",
|
|
28
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Name, {}),
|
|
29
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => typeParameters && (0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_type_parameters.TypeParameters, { parameters: typeParameters })),
|
|
30
|
+
" = ",
|
|
31
|
+
children,
|
|
32
|
+
";"
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
}))];
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TSDoc } from "./tsdoc.mjs";
|
|
2
2
|
import { TypeParameters } from "./type-parameters.mjs";
|
|
3
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
4
|
import { Name, Show } from "@alloy-js/core";
|
|
4
|
-
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
5
5
|
import { Declaration as Declaration$1, ensureTypeRefContext } from "@alloy-js/typescript";
|
|
6
6
|
|
|
7
7
|
//#region src/typescript/components/type-declaration.tsx
|
|
@@ -10,22 +10,27 @@ import { Declaration as Declaration$1, ensureTypeRefContext } from "@alloy-js/ty
|
|
|
10
10
|
*/
|
|
11
11
|
const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(props) {
|
|
12
12
|
const { children, doc, typeParameters, ...rest } = props;
|
|
13
|
-
return
|
|
14
|
-
when
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return [createComponent(Show, {
|
|
14
|
+
get when() {
|
|
15
|
+
return Boolean(doc);
|
|
16
|
+
},
|
|
17
|
+
get children() {
|
|
18
|
+
return createComponent(TSDoc, { heading: doc });
|
|
19
|
+
}
|
|
20
|
+
}), createComponent(Declaration$1, mergeProps(rest, {
|
|
18
21
|
kind: "type",
|
|
19
22
|
nameKind: "type",
|
|
20
|
-
children
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
get children() {
|
|
24
|
+
return [
|
|
25
|
+
"type ",
|
|
26
|
+
createComponent(Name, {}),
|
|
27
|
+
memo(() => typeParameters && createComponent(TypeParameters, { parameters: typeParameters })),
|
|
28
|
+
" = ",
|
|
29
|
+
children,
|
|
30
|
+
";"
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
}))];
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-declaration.mjs","names":[
|
|
1
|
+
{"version":3,"file":"type-declaration.mjs","names":[],"sources":["../../../src/typescript/components/type-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 { Name, Show } from \"@alloy-js/core\";\nimport {\n CommonDeclarationProps,\n Declaration,\n ensureTypeRefContext,\n TypeParameterDescriptor\n} from \"@alloy-js/typescript\";\nimport { TSDoc } from \"./tsdoc\";\nimport { TypeParameters } from \"./type-parameters\";\n\nexport interface TypeDeclarationProps extends CommonDeclarationProps {\n /**\n * The generic type parameters of the interface.\n */\n typeParameters?: TypeParameterDescriptor[] | string[];\n}\n\n/**\n * Renders a TypeScript type declaration, including its name, optional TSDoc comment, and generic type parameters.\n */\nexport const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(\n props: TypeDeclarationProps\n) {\n const { children, doc, typeParameters, ...rest } = props;\n\n return (\n <>\n <Show when={Boolean(doc)}>\n <TSDoc heading={doc} />\n </Show>\n <Declaration {...rest} kind=\"type\" nameKind=\"type\">\n type <Name />\n {typeParameters && (\n <TypeParameters parameters={typeParameters} />\n )} = {children};\n </Declaration>\n </>\n );\n});\n"],"mappings":";;;;;;;;;;AAiCA,MAAA,kBAAA,qBAAA,SAAA,gBAAA,OAAA;SAEE,UACC,KACD,gBACF,GAAO,SACL;AACA,QAAA,CAAA,gBAAA,MAAA;EACA,IAAM,OAAE;;;EAGN,IAAC,WAAA;AACC,UAAM,gBAAmB,OAAA,EACvB,SAAO,KACR,CAAC;;EAEL,CAAC,EAAE,gBAAc,eAAA,WAAA,MAAA;EAChB,MAAK;EACL,UAAO;EACP,IAAI,WAAM;AACR,UAAE;IAAA;IAAW,gBAAA,MAAA,EAAA,CAAA;IAAA,WAAA,kBAAA,gBAAA,gBAAA,EACb,YAAA,gBACH,CAAA,CAAA;IAAA;IAAA;IAAA;IAAA"}
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
4
3
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
6
|
|
|
7
7
|
//#region src/typescript/components/type-parameters.tsx
|
|
8
8
|
function typeParameter(param) {
|
|
9
|
-
return
|
|
9
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
10
10
|
when: typeof param === "object",
|
|
11
|
-
fallback
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
get fallback() {
|
|
12
|
+
return [param];
|
|
13
|
+
},
|
|
14
|
+
get children() {
|
|
15
|
+
return [(0, _alloy_js_core_jsx_runtime.createIntrinsic)("group", { get children() {
|
|
16
|
+
return [
|
|
17
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => param.name),
|
|
18
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
19
|
+
get when() {
|
|
20
|
+
return !!param.extends;
|
|
21
|
+
},
|
|
22
|
+
get children() {
|
|
23
|
+
return [
|
|
24
|
+
" ",
|
|
25
|
+
"extends",
|
|
26
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("indent", { get children() {
|
|
27
|
+
return [" ", (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeRefContext, { get children() {
|
|
28
|
+
return param.extends;
|
|
29
|
+
} })];
|
|
30
|
+
} })
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
35
|
+
get when() {
|
|
36
|
+
return !!param.default;
|
|
37
|
+
},
|
|
38
|
+
get children() {
|
|
39
|
+
return [" = ", (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeRefContext, { get children() {
|
|
40
|
+
return param.default;
|
|
41
|
+
} })];
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
];
|
|
45
|
+
} }), " "];
|
|
46
|
+
}
|
|
27
47
|
});
|
|
28
48
|
}
|
|
29
49
|
/**
|
|
@@ -37,19 +57,25 @@ function typeParameter(param) {
|
|
|
37
57
|
function TypeParameters(props) {
|
|
38
58
|
if (props.children) return props.children;
|
|
39
59
|
if (!props.parameters) return;
|
|
40
|
-
return
|
|
60
|
+
return [
|
|
41
61
|
"<",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("group", { get children() {
|
|
63
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Indent, {
|
|
64
|
+
softline: true,
|
|
65
|
+
get children() {
|
|
66
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
67
|
+
get each() {
|
|
68
|
+
return props.parameters;
|
|
69
|
+
},
|
|
70
|
+
comma: true,
|
|
71
|
+
line: true,
|
|
72
|
+
children: (param) => typeParameter(param)
|
|
73
|
+
}), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("ifBreak", { children: "," })];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
} }),
|
|
51
77
|
">"
|
|
52
|
-
]
|
|
78
|
+
];
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
//#endregion
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
+
import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
|
|
1
2
|
import { For, Indent, Show } from "@alloy-js/core";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
3
3
|
import { TypeRefContext } from "@alloy-js/typescript";
|
|
4
4
|
|
|
5
5
|
//#region src/typescript/components/type-parameters.tsx
|
|
6
6
|
function typeParameter(param) {
|
|
7
|
-
return
|
|
7
|
+
return createComponent(Show, {
|
|
8
8
|
when: typeof param === "object",
|
|
9
|
-
fallback
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
get fallback() {
|
|
10
|
+
return [param];
|
|
11
|
+
},
|
|
12
|
+
get children() {
|
|
13
|
+
return [createIntrinsic("group", { get children() {
|
|
14
|
+
return [
|
|
15
|
+
memo(() => param.name),
|
|
16
|
+
createComponent(Show, {
|
|
17
|
+
get when() {
|
|
18
|
+
return !!param.extends;
|
|
19
|
+
},
|
|
20
|
+
get children() {
|
|
21
|
+
return [
|
|
22
|
+
" ",
|
|
23
|
+
"extends",
|
|
24
|
+
createIntrinsic("indent", { get children() {
|
|
25
|
+
return [" ", createComponent(TypeRefContext, { get children() {
|
|
26
|
+
return param.extends;
|
|
27
|
+
} })];
|
|
28
|
+
} })
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
createComponent(Show, {
|
|
33
|
+
get when() {
|
|
34
|
+
return !!param.default;
|
|
35
|
+
},
|
|
36
|
+
get children() {
|
|
37
|
+
return [" = ", createComponent(TypeRefContext, { get children() {
|
|
38
|
+
return param.default;
|
|
39
|
+
} })];
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
];
|
|
43
|
+
} }), " "];
|
|
44
|
+
}
|
|
25
45
|
});
|
|
26
46
|
}
|
|
27
47
|
/**
|
|
@@ -35,19 +55,25 @@ function typeParameter(param) {
|
|
|
35
55
|
function TypeParameters(props) {
|
|
36
56
|
if (props.children) return props.children;
|
|
37
57
|
if (!props.parameters) return;
|
|
38
|
-
return
|
|
58
|
+
return [
|
|
39
59
|
"<",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
createIntrinsic("group", { get children() {
|
|
61
|
+
return createComponent(Indent, {
|
|
62
|
+
softline: true,
|
|
63
|
+
get children() {
|
|
64
|
+
return [createComponent(For, {
|
|
65
|
+
get each() {
|
|
66
|
+
return props.parameters;
|
|
67
|
+
},
|
|
68
|
+
comma: true,
|
|
69
|
+
line: true,
|
|
70
|
+
children: (param) => typeParameter(param)
|
|
71
|
+
}), createIntrinsic("ifBreak", { children: "," })];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
} }),
|
|
49
75
|
">"
|
|
50
|
-
]
|
|
76
|
+
];
|
|
51
77
|
}
|
|
52
78
|
|
|
53
79
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-parameters.mjs","names":[],"sources":["../../../src/typescript/components/type-parameters.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 { Children, For, Indent, Show } from \"@alloy-js/core\";\nimport { TypeParameterDescriptor, TypeRefContext } from \"@alloy-js/typescript\";\n\n/** Props for type parameters */\nexport interface TypeParametersProps {\n /** Parameters */\n parameters?: TypeParameterDescriptor[] | string[];\n /** Jsx Children */\n children?: Children;\n}\n\nfunction typeParameter(param: TypeParameterDescriptor | string) {\n return (\n <Show when={typeof param === \"object\"} fallback={<>{param}</>}>\n <group>\n {(param as TypeParameterDescriptor).name}\n <Show when={!!(param as TypeParameterDescriptor).extends}>\n {\" \"}\n extends\n <indent>\n {\" \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).extends}\n </TypeRefContext>\n </indent>\n </Show>\n <Show when={!!(param as TypeParameterDescriptor).default}>\n {\" = \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).default}\n </TypeRefContext>\n </Show>\n </group>{\" \"}\n </Show>\n );\n}\n\n/**\n * Represent type parameters\n *\n * @example\n * ```ts\n * <A, B extends string>\n * ```\n */\nexport function TypeParameters(props: TypeParametersProps) {\n if (props.children) {\n return props.children;\n }\n\n if (!props.parameters) {\n return undefined;\n }\n\n return (\n <>\n {\"<\"}\n <group>\n <Indent softline>\n <For each={props.parameters} comma line>\n {param => typeParameter(param)}\n </For>\n <ifBreak>,</ifBreak>\n </Indent>\n </group>\n {\">\"}\n </>\n );\n}\n"],"mappings":";;;;;AA6BA,SAAS,cAAc,OAAyC;AAC9D,
|
|
1
|
+
{"version":3,"file":"type-parameters.mjs","names":[],"sources":["../../../src/typescript/components/type-parameters.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 { Children, For, Indent, Show } from \"@alloy-js/core\";\nimport { TypeParameterDescriptor, TypeRefContext } from \"@alloy-js/typescript\";\n\n/** Props for type parameters */\nexport interface TypeParametersProps {\n /** Parameters */\n parameters?: TypeParameterDescriptor[] | string[];\n /** Jsx Children */\n children?: Children;\n}\n\nfunction typeParameter(param: TypeParameterDescriptor | string) {\n return (\n <Show when={typeof param === \"object\"} fallback={<>{param}</>}>\n <group>\n {(param as TypeParameterDescriptor).name}\n <Show when={!!(param as TypeParameterDescriptor).extends}>\n {\" \"}\n extends\n <indent>\n {\" \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).extends}\n </TypeRefContext>\n </indent>\n </Show>\n <Show when={!!(param as TypeParameterDescriptor).default}>\n {\" = \"}\n <TypeRefContext>\n {(param as TypeParameterDescriptor).default}\n </TypeRefContext>\n </Show>\n </group>{\" \"}\n </Show>\n );\n}\n\n/**\n * Represent type parameters\n *\n * @example\n * ```ts\n * <A, B extends string>\n * ```\n */\nexport function TypeParameters(props: TypeParametersProps) {\n if (props.children) {\n return props.children;\n }\n\n if (!props.parameters) {\n return undefined;\n }\n\n return (\n <>\n {\"<\"}\n <group>\n <Indent softline>\n <For each={props.parameters} comma line>\n {param => typeParameter(param)}\n </For>\n <ifBreak>,</ifBreak>\n </Indent>\n </group>\n {\">\"}\n </>\n );\n}\n"],"mappings":";;;;;AA6BA,SAAS,cAAc,OAAyC;AAC9D,QAAO,gBAAA,MAAA;EACL,MAAM,OAAM,UAAO;EACnB,IAAG,WAAK;AACN,UAAI,CAAA,MAAS;;EAEf,IAAI,WAAM;AACR,UAAI,CAAA,gBAAA,SAAA,EACF,IAAG,WAAM;AACP,WAAM;KAAA,WAAA,MAAA,KAAA;KAAA,gBAAA,MAAA;MACJ,IAAC,OAAA;AACC,cAAO,CAAC,CAAE,MAAiC;;MAE7C,IAAA,WAAM;AACJ,cAAA;QAAA;QAAA;QAAA,gBAAA,UAAA,EACA,IAAM,WAAW;AACf,gBAAA,CAAA,KAAA,gBAAA,gBAAA,EACL,IAAA,WAAc;AACH,iBAAC,MAAgC;YAEzC,CAAA,CAAA;WAEJ,CAAA;QAAA;;MAEV,CAAA;KAAA,gBAAA,MAAA;;AAEE,cAAA,CAAA,CAAA,MAAA;;MAED,IAAA,WAAA;AACG,cAAA,CAAA,OAAA,gBAAA,gBAAA,EACE,IAAA,WAAA;AACW,eAAM,MAAA;UAErB,CAAA,CAAA;;MAES,CAAC;KAAA;MAEV,CAAA,EAAA,IAAA;;EAEA,CAAE;;;;;;;;;;AAWJ,SAAe,eAAA,OAAA;AACb,KAAI,MAAK,SACP,QAAM,MAAM;AAEd,KAAI,CAAC,MAAG,WACN;AAEJ,QAAA;EAAA;EAAA,gBAAA,SAAA"}
|