@powerlines/plugin-alloy 0.26.237 → 0.26.238
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/components/index.cjs +1 -9
- package/dist/core/components/index.d.cts +1 -5
- package/dist/core/components/index.d.mts +1 -5
- package/dist/core/components/index.mjs +1 -5
- package/dist/core/components/infrastructure-file.cjs +6 -3
- package/dist/core/components/infrastructure-file.d.cts +1 -1
- package/dist/core/components/infrastructure-file.d.cts.map +1 -1
- package/dist/core/components/infrastructure-file.d.mts +1 -1
- package/dist/core/components/infrastructure-file.mjs +5 -2
- package/dist/core/contexts/index.cjs +1 -11
- package/dist/core/contexts/index.d.cts +1 -3
- package/dist/core/contexts/index.d.mts +1 -3
- package/dist/core/contexts/index.mjs +1 -3
- package/dist/core/index.cjs +2 -23
- package/dist/core/index.d.cts +2 -10
- package/dist/core/index.d.mts +2 -10
- package/dist/core/index.mjs +2 -10
- package/dist/helpers/capnp.cjs +2 -2
- package/dist/helpers/capnp.mjs +2 -2
- package/dist/index.cjs +10 -2
- package/dist/index.d.cts +10 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +10 -4
- package/dist/index.mjs +10 -2
- package/dist/render.cjs +67 -48
- package/dist/render.d.cts +33 -2
- package/dist/render.d.cts.map +1 -1
- package/dist/render.d.mts +33 -2
- package/dist/render.mjs +68 -49
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.mts +2 -3
- package/dist/types/plugin.d.cts +7 -4
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +7 -4
- package/dist/typescript/components/builtin-file.cjs +6 -6
- package/dist/typescript/components/builtin-file.d.cts +2 -2
- package/dist/typescript/components/builtin-file.d.cts.map +1 -1
- package/dist/typescript/components/builtin-file.d.mts +2 -2
- package/dist/typescript/components/builtin-file.mjs +2 -2
- package/dist/typescript/components/entry-file.cjs +2 -2
- package/dist/typescript/components/entry-file.d.cts +1 -1
- package/dist/typescript/components/entry-file.d.cts.map +1 -1
- package/dist/typescript/components/entry-file.d.mts +1 -1
- package/dist/typescript/components/entry-file.mjs +1 -1
- package/dist/typescript/components/index.cjs +1 -56
- package/dist/typescript/components/index.d.cts +1 -12
- package/dist/typescript/components/index.d.mts +1 -12
- package/dist/typescript/components/index.mjs +1 -12
- package/dist/typescript/index.cjs +1 -64
- package/dist/typescript/index.d.cts +1 -17
- package/dist/typescript/index.d.mts +1 -17
- package/dist/typescript/index.mjs +1 -17
- package/package.json +18 -639
- package/dist/core/components/output.cjs +0 -40
- package/dist/core/components/output.d.cts +0 -22
- package/dist/core/components/output.d.cts.map +0 -1
- package/dist/core/components/output.d.mts +0 -22
- package/dist/core/components/output.d.mts.map +0 -1
- package/dist/core/components/output.mjs +0 -40
- package/dist/core/components/output.mjs.map +0 -1
- package/dist/core/components/single-line-comment.cjs +0 -22
- package/dist/core/components/single-line-comment.d.cts +0 -19
- package/dist/core/components/single-line-comment.d.cts.map +0 -1
- package/dist/core/components/single-line-comment.d.mts +0 -19
- package/dist/core/components/single-line-comment.d.mts.map +0 -1
- package/dist/core/components/single-line-comment.mjs +0 -22
- package/dist/core/components/single-line-comment.mjs.map +0 -1
- package/dist/core/components/source-file.cjs +0 -64
- package/dist/core/components/source-file.d.cts +0 -30
- package/dist/core/components/source-file.d.cts.map +0 -1
- package/dist/core/components/source-file.d.mts +0 -30
- package/dist/core/components/source-file.d.mts.map +0 -1
- package/dist/core/components/source-file.mjs +0 -62
- package/dist/core/components/source-file.mjs.map +0 -1
- package/dist/core/components/spacing.cjs +0 -19
- package/dist/core/components/spacing.d.cts +0 -19
- package/dist/core/components/spacing.d.cts.map +0 -1
- package/dist/core/components/spacing.d.mts +0 -19
- package/dist/core/components/spacing.d.mts.map +0 -1
- package/dist/core/components/spacing.mjs +0 -19
- package/dist/core/components/spacing.mjs.map +0 -1
- package/dist/core/contexts/meta.cjs +0 -40
- package/dist/core/contexts/meta.d.cts +0 -46
- package/dist/core/contexts/meta.d.cts.map +0 -1
- package/dist/core/contexts/meta.d.mts +0 -46
- package/dist/core/contexts/meta.d.mts.map +0 -1
- package/dist/core/contexts/meta.mjs +0 -37
- package/dist/core/contexts/meta.mjs.map +0 -1
- package/dist/core/contexts/schema.cjs +0 -38
- package/dist/core/contexts/schema.d.cts +0 -26
- package/dist/core/contexts/schema.d.cts.map +0 -1
- package/dist/core/contexts/schema.d.mts +0 -26
- package/dist/core/contexts/schema.d.mts.map +0 -1
- package/dist/core/contexts/schema.mjs +0 -35
- package/dist/core/contexts/schema.mjs.map +0 -1
- package/dist/core/helpers/code.cjs +0 -33
- package/dist/core/helpers/code.d.cts +0 -28
- package/dist/core/helpers/code.d.cts.map +0 -1
- package/dist/core/helpers/code.d.mts +0 -28
- package/dist/core/helpers/code.d.mts.map +0 -1
- package/dist/core/helpers/code.mjs +0 -33
- package/dist/core/helpers/code.mjs.map +0 -1
- package/dist/core/helpers/index.cjs +0 -4
- package/dist/core/helpers/index.d.cts +0 -2
- package/dist/core/helpers/index.d.mts +0 -2
- package/dist/core/helpers/index.mjs +0 -3
- package/dist/hcl/components/block-declaration.cjs +0 -33
- package/dist/hcl/components/block-declaration.d.cts +0 -19
- package/dist/hcl/components/block-declaration.d.cts.map +0 -1
- package/dist/hcl/components/block-declaration.d.mts +0 -19
- package/dist/hcl/components/block-declaration.d.mts.map +0 -1
- package/dist/hcl/components/block-declaration.mjs +0 -33
- package/dist/hcl/components/block-declaration.mjs.map +0 -1
- package/dist/hcl/components/hcl-file.cjs +0 -82
- package/dist/hcl/components/hcl-file.d.cts +0 -25
- package/dist/hcl/components/hcl-file.d.cts.map +0 -1
- package/dist/hcl/components/hcl-file.d.mts +0 -25
- package/dist/hcl/components/hcl-file.d.mts.map +0 -1
- package/dist/hcl/components/hcl-file.mjs +0 -81
- package/dist/hcl/components/hcl-file.mjs.map +0 -1
- package/dist/hcl/components/index.cjs +0 -11
- package/dist/hcl/components/index.d.cts +0 -5
- package/dist/hcl/components/index.d.mts +0 -5
- package/dist/hcl/components/index.mjs +0 -6
- package/dist/hcl/components/packer-file.cjs +0 -28
- package/dist/hcl/components/packer-file.d.cts +0 -16
- package/dist/hcl/components/packer-file.d.cts.map +0 -1
- package/dist/hcl/components/packer-file.d.mts +0 -16
- package/dist/hcl/components/packer-file.d.mts.map +0 -1
- package/dist/hcl/components/packer-file.mjs +0 -28
- package/dist/hcl/components/packer-file.mjs.map +0 -1
- package/dist/hcl/components/terraform-file.cjs +0 -29
- package/dist/hcl/components/terraform-file.d.cts +0 -17
- package/dist/hcl/components/terraform-file.d.cts.map +0 -1
- package/dist/hcl/components/terraform-file.d.mts +0 -17
- package/dist/hcl/components/terraform-file.d.mts.map +0 -1
- package/dist/hcl/components/terraform-file.mjs +0 -29
- package/dist/hcl/components/terraform-file.mjs.map +0 -1
- package/dist/hcl/index.cjs +0 -12
- package/dist/hcl/index.d.cts +0 -6
- package/dist/hcl/index.d.mts +0 -6
- package/dist/hcl/index.mjs +0 -7
- package/dist/markdown/components/alert.cjs +0 -74
- package/dist/markdown/components/alert.d.cts +0 -52
- package/dist/markdown/components/alert.d.cts.map +0 -1
- package/dist/markdown/components/alert.d.mts +0 -52
- package/dist/markdown/components/alert.d.mts.map +0 -1
- package/dist/markdown/components/alert.mjs +0 -69
- package/dist/markdown/components/alert.mjs.map +0 -1
- package/dist/markdown/components/front-matter.cjs +0 -30
- package/dist/markdown/components/front-matter.d.cts +0 -13
- package/dist/markdown/components/front-matter.d.cts.map +0 -1
- package/dist/markdown/components/front-matter.d.mts +0 -13
- package/dist/markdown/components/front-matter.d.mts.map +0 -1
- package/dist/markdown/components/front-matter.mjs +0 -30
- package/dist/markdown/components/front-matter.mjs.map +0 -1
- package/dist/markdown/components/heading.cjs +0 -23
- package/dist/markdown/components/heading.d.cts +0 -17
- package/dist/markdown/components/heading.d.cts.map +0 -1
- package/dist/markdown/components/heading.d.mts +0 -17
- package/dist/markdown/components/heading.d.mts.map +0 -1
- package/dist/markdown/components/heading.mjs +0 -23
- package/dist/markdown/components/heading.mjs.map +0 -1
- package/dist/markdown/components/index.cjs +0 -20
- package/dist/markdown/components/index.d.cts +0 -6
- package/dist/markdown/components/index.d.mts +0 -6
- package/dist/markdown/components/index.mjs +0 -7
- package/dist/markdown/components/markdown-file.cjs +0 -146
- package/dist/markdown/components/markdown-file.d.cts +0 -25
- package/dist/markdown/components/markdown-file.d.cts.map +0 -1
- package/dist/markdown/components/markdown-file.d.mts +0 -25
- package/dist/markdown/components/markdown-file.d.mts.map +0 -1
- package/dist/markdown/components/markdown-file.mjs +0 -145
- package/dist/markdown/components/markdown-file.mjs.map +0 -1
- package/dist/markdown/components/markdown-table.cjs +0 -106
- package/dist/markdown/components/markdown-table.d.cts +0 -37
- package/dist/markdown/components/markdown-table.d.cts.map +0 -1
- package/dist/markdown/components/markdown-table.d.mts +0 -37
- package/dist/markdown/components/markdown-table.d.mts.map +0 -1
- package/dist/markdown/components/markdown-table.mjs +0 -104
- package/dist/markdown/components/markdown-table.mjs.map +0 -1
- package/dist/markdown/contexts/index.cjs +0 -7
- package/dist/markdown/contexts/index.d.cts +0 -2
- package/dist/markdown/contexts/index.d.mts +0 -2
- package/dist/markdown/contexts/index.mjs +0 -3
- package/dist/markdown/contexts/markdown-table.cjs +0 -37
- package/dist/markdown/contexts/markdown-table.d.cts +0 -35
- package/dist/markdown/contexts/markdown-table.d.cts.map +0 -1
- package/dist/markdown/contexts/markdown-table.d.mts +0 -35
- package/dist/markdown/contexts/markdown-table.d.mts.map +0 -1
- package/dist/markdown/contexts/markdown-table.mjs +0 -34
- package/dist/markdown/contexts/markdown-table.mjs.map +0 -1
- package/dist/markdown/index.cjs +0 -27
- package/dist/markdown/index.d.cts +0 -9
- package/dist/markdown/index.d.mts +0 -9
- package/dist/markdown/index.mjs +0 -10
- package/dist/types/components.cjs +0 -9
- package/dist/types/components.d.cts +0 -137
- package/dist/types/components.d.cts.map +0 -1
- package/dist/types/components.d.mts +0 -137
- package/dist/types/components.d.mts.map +0 -1
- package/dist/types/components.mjs +0 -10
- package/dist/types/components.mjs.map +0 -1
- package/dist/typescript/components/class-declaration.cjs +0 -305
- package/dist/typescript/components/class-declaration.d.cts +0 -139
- package/dist/typescript/components/class-declaration.d.cts.map +0 -1
- package/dist/typescript/components/class-declaration.d.mts +0 -139
- package/dist/typescript/components/class-declaration.d.mts.map +0 -1
- package/dist/typescript/components/class-declaration.mjs +0 -300
- package/dist/typescript/components/class-declaration.mjs.map +0 -1
- package/dist/typescript/components/dynamic-import-statement.cjs +0 -25
- package/dist/typescript/components/dynamic-import-statement.d.cts +0 -30
- package/dist/typescript/components/dynamic-import-statement.d.cts.map +0 -1
- package/dist/typescript/components/dynamic-import-statement.d.mts +0 -30
- package/dist/typescript/components/dynamic-import-statement.d.mts.map +0 -1
- package/dist/typescript/components/dynamic-import-statement.mjs +0 -25
- package/dist/typescript/components/dynamic-import-statement.mjs.map +0 -1
- package/dist/typescript/components/interface-declaration.cjs +0 -257
- package/dist/typescript/components/interface-declaration.d.cts +0 -78
- package/dist/typescript/components/interface-declaration.d.cts.map +0 -1
- package/dist/typescript/components/interface-declaration.d.mts +0 -78
- package/dist/typescript/components/interface-declaration.d.mts.map +0 -1
- package/dist/typescript/components/interface-declaration.mjs +0 -254
- package/dist/typescript/components/interface-declaration.mjs.map +0 -1
- package/dist/typescript/components/object-declaration.cjs +0 -131
- package/dist/typescript/components/object-declaration.d.cts +0 -24
- package/dist/typescript/components/object-declaration.d.cts.map +0 -1
- package/dist/typescript/components/object-declaration.d.mts +0 -24
- package/dist/typescript/components/object-declaration.d.mts.map +0 -1
- package/dist/typescript/components/object-declaration.mjs +0 -130
- package/dist/typescript/components/object-declaration.mjs.map +0 -1
- package/dist/typescript/components/property-name.cjs +0 -31
- package/dist/typescript/components/property-name.d.cts +0 -21
- package/dist/typescript/components/property-name.d.cts.map +0 -1
- package/dist/typescript/components/property-name.d.mts +0 -21
- package/dist/typescript/components/property-name.d.mts.map +0 -1
- package/dist/typescript/components/property-name.mjs +0 -31
- package/dist/typescript/components/property-name.mjs.map +0 -1
- package/dist/typescript/components/record-expression.cjs +0 -12
- package/dist/typescript/components/record-expression.d.cts +0 -9
- package/dist/typescript/components/record-expression.d.cts.map +0 -1
- package/dist/typescript/components/record-expression.d.mts +0 -9
- package/dist/typescript/components/record-expression.d.mts.map +0 -1
- package/dist/typescript/components/record-expression.mjs +0 -12
- package/dist/typescript/components/record-expression.mjs.map +0 -1
- package/dist/typescript/components/tsdoc-schema.cjs +0 -166
- package/dist/typescript/components/tsdoc-schema.d.cts +0 -21
- package/dist/typescript/components/tsdoc-schema.d.cts.map +0 -1
- package/dist/typescript/components/tsdoc-schema.d.mts +0 -21
- package/dist/typescript/components/tsdoc-schema.d.mts.map +0 -1
- package/dist/typescript/components/tsdoc-schema.mjs +0 -165
- package/dist/typescript/components/tsdoc-schema.mjs.map +0 -1
- package/dist/typescript/components/tsdoc.cjs +0 -486
- package/dist/typescript/components/tsdoc.d.cts +0 -163
- package/dist/typescript/components/tsdoc.d.cts.map +0 -1
- package/dist/typescript/components/tsdoc.d.mts +0 -163
- package/dist/typescript/components/tsdoc.d.mts.map +0 -1
- package/dist/typescript/components/tsdoc.mjs +0 -465
- package/dist/typescript/components/tsdoc.mjs.map +0 -1
- package/dist/typescript/components/type-declaration.cjs +0 -38
- package/dist/typescript/components/type-declaration.d.cts +0 -15
- package/dist/typescript/components/type-declaration.d.cts.map +0 -1
- package/dist/typescript/components/type-declaration.d.mts +0 -15
- package/dist/typescript/components/type-declaration.d.mts.map +0 -1
- package/dist/typescript/components/type-declaration.mjs +0 -38
- package/dist/typescript/components/type-declaration.mjs.map +0 -1
- package/dist/typescript/components/type-parameters.cjs +0 -82
- package/dist/typescript/components/type-parameters.d.cts +0 -22
- package/dist/typescript/components/type-parameters.d.cts.map +0 -1
- package/dist/typescript/components/type-parameters.d.mts +0 -22
- package/dist/typescript/components/type-parameters.d.mts.map +0 -1
- package/dist/typescript/components/type-parameters.mjs +0 -82
- package/dist/typescript/components/type-parameters.mjs.map +0 -1
- package/dist/typescript/components/typescript-file.cjs +0 -231
- package/dist/typescript/components/typescript-file.d.cts +0 -46
- package/dist/typescript/components/typescript-file.d.cts.map +0 -1
- package/dist/typescript/components/typescript-file.d.mts +0 -46
- package/dist/typescript/components/typescript-file.d.mts.map +0 -1
- package/dist/typescript/components/typescript-file.mjs +0 -229
- package/dist/typescript/components/typescript-file.mjs.map +0 -1
- package/dist/typescript/contexts/index.cjs +0 -4
- package/dist/typescript/contexts/index.d.cts +0 -2
- package/dist/typescript/contexts/index.d.mts +0 -2
- package/dist/typescript/contexts/index.mjs +0 -3
- package/dist/typescript/contexts/lexical-scope.cjs +0 -25
- package/dist/typescript/contexts/lexical-scope.d.cts +0 -12
- package/dist/typescript/contexts/lexical-scope.d.cts.map +0 -1
- package/dist/typescript/contexts/lexical-scope.d.mts +0 -12
- package/dist/typescript/contexts/lexical-scope.d.mts.map +0 -1
- package/dist/typescript/contexts/lexical-scope.mjs +0 -25
- package/dist/typescript/contexts/lexical-scope.mjs.map +0 -1
- package/dist/typescript/contexts/member-scope.cjs +0 -23
- package/dist/typescript/contexts/member-scope.d.cts +0 -18
- package/dist/typescript/contexts/member-scope.d.cts.map +0 -1
- package/dist/typescript/contexts/member-scope.d.mts +0 -18
- package/dist/typescript/contexts/member-scope.d.mts.map +0 -1
- package/dist/typescript/contexts/member-scope.mjs +0 -23
- package/dist/typescript/contexts/member-scope.mjs.map +0 -1
- package/dist/typescript/helpers/get-call-signature-props.cjs +0 -25
- package/dist/typescript/helpers/get-call-signature-props.d.cts +0 -13
- package/dist/typescript/helpers/get-call-signature-props.d.cts.map +0 -1
- package/dist/typescript/helpers/get-call-signature-props.d.mts +0 -13
- package/dist/typescript/helpers/get-call-signature-props.d.mts.map +0 -1
- package/dist/typescript/helpers/get-call-signature-props.mjs +0 -25
- package/dist/typescript/helpers/get-call-signature-props.mjs.map +0 -1
- package/dist/typescript/helpers/index.cjs +0 -6
- package/dist/typescript/helpers/index.d.cts +0 -3
- package/dist/typescript/helpers/index.d.mts +0 -3
- package/dist/typescript/helpers/index.mjs +0 -4
- package/dist/typescript/helpers/utilities.cjs +0 -15
- package/dist/typescript/helpers/utilities.d.cts +0 -11
- package/dist/typescript/helpers/utilities.d.cts.map +0 -1
- package/dist/typescript/helpers/utilities.d.mts +0 -11
- package/dist/typescript/helpers/utilities.d.mts.map +0 -1
- package/dist/typescript/helpers/utilities.mjs +0 -14
- package/dist/typescript/helpers/utilities.mjs.map +0 -1
- package/dist/yaml/components/index.cjs +0 -5
- package/dist/yaml/components/index.d.cts +0 -2
- package/dist/yaml/components/index.d.mts +0 -2
- package/dist/yaml/components/index.mjs +0 -3
- package/dist/yaml/components/yaml-file.cjs +0 -148
- package/dist/yaml/components/yaml-file.d.cts +0 -31
- package/dist/yaml/components/yaml-file.d.cts.map +0 -1
- package/dist/yaml/components/yaml-file.d.mts +0 -31
- package/dist/yaml/components/yaml-file.d.mts.map +0 -1
- package/dist/yaml/components/yaml-file.mjs +0 -147
- package/dist/yaml/components/yaml-file.mjs.map +0 -1
- package/dist/yaml/index.cjs +0 -6
- package/dist/yaml/index.d.cts +0 -3
- package/dist/yaml/index.d.mts +0 -3
- package/dist/yaml/index.mjs +0 -4
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { SchemaContext, SchemaPropertyContext } from "../../core/contexts/schema.mjs";
|
|
2
|
-
import { TSDoc } from "./tsdoc.mjs";
|
|
3
|
-
import { MemberScope as MemberScope$1 } from "../contexts/member-scope.mjs";
|
|
4
|
-
import { PropertyName } from "./property-name.mjs";
|
|
5
|
-
import { TypeParameters } from "./type-parameters.mjs";
|
|
6
|
-
import { TSDocObjectSchema, TSDocSchemaProperty } from "./tsdoc-schema.mjs";
|
|
7
|
-
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
8
|
-
import { Block, For, MemberDeclaration, Name, Show, childrenArray, computed, createSymbol, createSymbolSlot, effect, emitSymbol, findUnkeyedChildren, splitProps, takeSymbols } from "@alloy-js/core";
|
|
9
|
-
import { getPrimarySchemaType, getPropertiesList, isSchemaNullable, stringifyType } from "@powerlines/schema";
|
|
10
|
-
import { pascalCase } from "@stryke/string-format/pascal-case";
|
|
11
|
-
import { Declaration as Declaration$1, TSOutputSymbol, TSSymbolFlags, ensureTypeRefContext, useTSLexicalScope, useTSMemberScope, useTSNamePolicy } from "@alloy-js/typescript";
|
|
12
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
13
|
-
import { uuid } from "@stryke/unique-id/uuid";
|
|
14
|
-
|
|
15
|
-
//#region src/typescript/components/interface-declaration.tsx
|
|
16
|
-
const InterfaceExpression = ensureTypeRefContext(function InterfaceExpression(props) {
|
|
17
|
-
const symbol = createSymbol(TSOutputSymbol, "", void 0, {
|
|
18
|
-
transient: true,
|
|
19
|
-
binder: useTSLexicalScope()?.binder
|
|
20
|
-
});
|
|
21
|
-
emitSymbol(symbol);
|
|
22
|
-
return createIntrinsic("group", { get children() {
|
|
23
|
-
return createComponent(MemberScope$1, {
|
|
24
|
-
ownerSymbol: symbol,
|
|
25
|
-
get children() {
|
|
26
|
-
return createComponent(Block, { get children() {
|
|
27
|
-
return props.children;
|
|
28
|
-
} });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} });
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Create a TypeScript interface member.
|
|
35
|
-
*
|
|
36
|
-
* An interface member can either provide a `name` prop to create a named
|
|
37
|
-
* property, or an `indexer` prop to define an indexer for the interface.
|
|
38
|
-
*
|
|
39
|
-
* The type of the member can be provided either as the `type` prop or as the
|
|
40
|
-
* children of the component.
|
|
41
|
-
*/
|
|
42
|
-
function InterfaceMember(props) {
|
|
43
|
-
const type = props.schema ? stringifyType(props.schema) : props.type ?? props.children;
|
|
44
|
-
const readonly = props.schema && props.schema?.readOnly || !props.schema && props.readOnly ? "readonly " : "";
|
|
45
|
-
if ("indexer" in props) return [
|
|
46
|
-
createComponent(Show, {
|
|
47
|
-
get when() {
|
|
48
|
-
return Boolean(props.doc);
|
|
49
|
-
},
|
|
50
|
-
get children() {
|
|
51
|
-
return createComponent(TSDoc, { get heading() {
|
|
52
|
-
return props.doc;
|
|
53
|
-
} });
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
56
|
-
readonly,
|
|
57
|
-
"[",
|
|
58
|
-
memo(() => props.indexer),
|
|
59
|
-
"]: ",
|
|
60
|
-
type
|
|
61
|
-
];
|
|
62
|
-
const scope = useTSMemberScope();
|
|
63
|
-
const sym = createSymbol(TSOutputSymbol, ((props.schema ? props.schema?.name : void 0) || isSetString(props.name) ? props.name : props.name.toString()) || uuid().replace(/-/g, ""), scope.ownerSymbol.staticMembers, {
|
|
64
|
-
refkeys: props.refkey,
|
|
65
|
-
tsFlags: TSSymbolFlags.TypeSymbol | (!!(props.schema && isSchemaNullable(props.schema)) || !!props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None),
|
|
66
|
-
namePolicy: useTSNamePolicy().for("interface-member"),
|
|
67
|
-
binder: scope.binder
|
|
68
|
-
});
|
|
69
|
-
const taken = takeSymbols();
|
|
70
|
-
effect(() => {
|
|
71
|
-
if (taken.size > 1) return;
|
|
72
|
-
const symbol = Array.from(taken)[0];
|
|
73
|
-
if (symbol?.isTransient) symbol.moveMembersTo(sym);
|
|
74
|
-
});
|
|
75
|
-
return createComponent(MemberDeclaration, {
|
|
76
|
-
symbol: sym,
|
|
77
|
-
get children() {
|
|
78
|
-
return [
|
|
79
|
-
createComponent(Show, {
|
|
80
|
-
get when() {
|
|
81
|
-
return Boolean(props.doc);
|
|
82
|
-
},
|
|
83
|
-
get children() {
|
|
84
|
-
return createComponent(TSDoc, { get heading() {
|
|
85
|
-
return props.doc;
|
|
86
|
-
} });
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
readonly,
|
|
90
|
-
createComponent(PropertyName, {}),
|
|
91
|
-
memo(() => !props.required ? "?" : ""),
|
|
92
|
-
": ",
|
|
93
|
-
type
|
|
94
|
-
];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
const BaseInterfaceDeclaration = ensureTypeRefContext(function InterfaceDeclaration(props) {
|
|
99
|
-
const ExprSlot = createSymbolSlot();
|
|
100
|
-
const children = childrenArray(() => props.children);
|
|
101
|
-
const extendsPart = props.extends ? [" extends ", memo(() => props.extends)] : "";
|
|
102
|
-
const filteredChildren = findUnkeyedChildren(children);
|
|
103
|
-
const currentScope = useTSLexicalScope();
|
|
104
|
-
const binder = currentScope?.binder;
|
|
105
|
-
const sym = createSymbol(TSOutputSymbol, (isSetString(props.name) ? props.name : props.name?.toString()) || uuid().replace(/-/g, ""), currentScope.types, {
|
|
106
|
-
refkeys: props.refkey,
|
|
107
|
-
default: props.default,
|
|
108
|
-
export: props.export,
|
|
109
|
-
metadata: props.metadata,
|
|
110
|
-
tsFlags: TSSymbolFlags.TypeSymbol,
|
|
111
|
-
namePolicy: useTSNamePolicy().for("interface"),
|
|
112
|
-
binder
|
|
113
|
-
});
|
|
114
|
-
effect(() => {
|
|
115
|
-
if (ExprSlot.ref.value) {
|
|
116
|
-
const takenSymbols = ExprSlot.ref.value;
|
|
117
|
-
for (const symbol of takenSymbols) if (symbol.isTransient) symbol.moveMembersTo(sym);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
return [createComponent(Show, {
|
|
121
|
-
get when() {
|
|
122
|
-
return Boolean(props.doc);
|
|
123
|
-
},
|
|
124
|
-
get children() {
|
|
125
|
-
return createComponent(TSDoc, { get heading() {
|
|
126
|
-
return props.doc;
|
|
127
|
-
} });
|
|
128
|
-
}
|
|
129
|
-
}), createComponent(Declaration$1, mergeProps(props, {
|
|
130
|
-
nameKind: "interface",
|
|
131
|
-
kind: "type",
|
|
132
|
-
symbol: sym,
|
|
133
|
-
get children() {
|
|
134
|
-
return [
|
|
135
|
-
"interface ",
|
|
136
|
-
createComponent(Name, {}),
|
|
137
|
-
memo(() => memo(() => !!props.typeParameters)() && createComponent(TypeParameters, { get parameters() {
|
|
138
|
-
return props.typeParameters;
|
|
139
|
-
} })),
|
|
140
|
-
extendsPart,
|
|
141
|
-
" ",
|
|
142
|
-
createComponent(ExprSlot, { get children() {
|
|
143
|
-
return createComponent(InterfaceExpression, { children: filteredChildren });
|
|
144
|
-
} })
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
}))];
|
|
148
|
-
});
|
|
149
|
-
/**
|
|
150
|
-
* Generates a TypeScript interface for the given schema.
|
|
151
|
-
*/
|
|
152
|
-
function InterfaceDeclaration(props) {
|
|
153
|
-
const [{ name, schema, doc }, rest] = splitProps(props, [
|
|
154
|
-
"name",
|
|
155
|
-
"schema",
|
|
156
|
-
"doc"
|
|
157
|
-
]);
|
|
158
|
-
const interfaceName = computed(() => pascalCase(isSetString(name) ? name : schema?.name || schema?.title || ""));
|
|
159
|
-
const properties = computed(() => schema ? getPropertiesList(schema).filter((property) => !property?.ignore).sort((a, b) => a?.readOnly && b?.readOnly || !a?.readOnly && !b?.readOnly ? !a.name && !b.name ? 0 : !a.name ? -1 : !b.name ? 1 : a.name.localeCompare(b.name) : a?.readOnly ? 1 : -1) : []);
|
|
160
|
-
return createComponent(Show, {
|
|
161
|
-
get when() {
|
|
162
|
-
return schema && properties.value.length > 0;
|
|
163
|
-
},
|
|
164
|
-
get fallback() {
|
|
165
|
-
return createComponent(BaseInterfaceDeclaration, mergeProps(props, {
|
|
166
|
-
get schema() {
|
|
167
|
-
return {
|
|
168
|
-
type: "object",
|
|
169
|
-
name: interfaceName.value,
|
|
170
|
-
properties: {}
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
get name() {
|
|
174
|
-
return interfaceName.value;
|
|
175
|
-
}
|
|
176
|
-
}));
|
|
177
|
-
},
|
|
178
|
-
get children() {
|
|
179
|
-
return createComponent(SchemaContext.Provider, {
|
|
180
|
-
value: schema,
|
|
181
|
-
get children() {
|
|
182
|
-
return [createComponent(TSDocObjectSchema, {
|
|
183
|
-
heading: doc,
|
|
184
|
-
schema
|
|
185
|
-
}), createComponent(BaseInterfaceDeclaration, mergeProps({
|
|
186
|
-
"export": true,
|
|
187
|
-
get name() {
|
|
188
|
-
return interfaceName.value;
|
|
189
|
-
}
|
|
190
|
-
}, rest, { get children() {
|
|
191
|
-
return createComponent(For, {
|
|
192
|
-
each: properties,
|
|
193
|
-
doubleHardline: true,
|
|
194
|
-
semicolon: true,
|
|
195
|
-
children: (property) => createComponent(InterfaceDeclarationProperty, {
|
|
196
|
-
get name() {
|
|
197
|
-
return property.name;
|
|
198
|
-
},
|
|
199
|
-
schema: property,
|
|
200
|
-
get required() {
|
|
201
|
-
return !!property?.required;
|
|
202
|
-
}
|
|
203
|
-
})
|
|
204
|
-
});
|
|
205
|
-
} }))];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Generates a TypeScript interface property for the given reflection class.
|
|
213
|
-
*/
|
|
214
|
-
function InterfaceDeclarationProperty(props) {
|
|
215
|
-
const [{ schema, name, required, defaultValue }, rest] = splitProps(props, [
|
|
216
|
-
"schema",
|
|
217
|
-
"name",
|
|
218
|
-
"required",
|
|
219
|
-
"defaultValue"
|
|
220
|
-
]);
|
|
221
|
-
return createComponent(Show, {
|
|
222
|
-
get when() {
|
|
223
|
-
return isSetString(name);
|
|
224
|
-
},
|
|
225
|
-
get children() {
|
|
226
|
-
return createComponent(SchemaPropertyContext.Provider, {
|
|
227
|
-
value: schema,
|
|
228
|
-
get children() {
|
|
229
|
-
return [createComponent(TSDocSchemaProperty, {
|
|
230
|
-
schema,
|
|
231
|
-
defaultValue
|
|
232
|
-
}), createComponent(InterfaceMember, mergeProps({
|
|
233
|
-
name,
|
|
234
|
-
schema,
|
|
235
|
-
required,
|
|
236
|
-
get readOnly() {
|
|
237
|
-
return schema?.readOnly;
|
|
238
|
-
},
|
|
239
|
-
get nullish() {
|
|
240
|
-
return isSchemaNullable(schema);
|
|
241
|
-
},
|
|
242
|
-
get type() {
|
|
243
|
-
return getPrimarySchemaType(schema);
|
|
244
|
-
}
|
|
245
|
-
}, rest))];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
//#endregion
|
|
253
|
-
export { InterfaceDeclaration, InterfaceDeclarationProperty, InterfaceExpression, InterfaceMember };
|
|
254
|
-
//# sourceMappingURL=interface-declaration.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interface-declaration.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_core_contexts_schema = require('../../core/contexts/schema.cjs');
|
|
3
|
-
const require_typescript_components_tsdoc_schema = require('./tsdoc-schema.cjs');
|
|
4
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
6
|
-
let _powerlines_schema = require("@powerlines/schema");
|
|
7
|
-
let _stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
8
|
-
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
9
|
-
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
10
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
11
|
-
|
|
12
|
-
//#region src/typescript/components/object-declaration.tsx
|
|
13
|
-
/**
|
|
14
|
-
* Generates a TypeScript object for the given reflection class.
|
|
15
|
-
*/
|
|
16
|
-
function ObjectDeclaration(props) {
|
|
17
|
-
const { schema } = props;
|
|
18
|
-
if (!schema) return null;
|
|
19
|
-
const name = (0, _alloy_js_core.computed)(() => (0, _stryke_string_format_camel_case.camelCase)((0, _stryke_type_checks_is_set_string.isSetString)(props.name) ? props.name : schema?.name));
|
|
20
|
-
const defaultValues = (0, _alloy_js_core.computed)(() => Object.fromEntries((0, _powerlines_schema.getPropertiesList)(schema).map((property) => [property.name, property.default]) || {}));
|
|
21
|
-
const properties = (0, _alloy_js_core.computed)(() => (0, _powerlines_schema.getPropertiesList)(schema).filter((property) => !property?.ignore && !property?.runtime && !(0, _stryke_type_checks_is_undefined.isUndefined)(defaultValues.value[property.name] ?? property?.alias?.reduce((ret, alias) => {
|
|
22
|
-
if ((0, _stryke_type_checks_is_undefined.isUndefined)(ret) && !(0, _stryke_type_checks_is_undefined.isUndefined)(defaultValues.value[alias])) return defaultValues.value[alias];
|
|
23
|
-
return ret;
|
|
24
|
-
}, void 0) ?? property?.default)).sort((a, b) => a?.readOnly && b?.readOnly || !a?.readOnly && !b?.readOnly ? a.name.localeCompare(b.name) : a?.readOnly ? 1 : -1));
|
|
25
|
-
const TypeSymbolSlot = (0, _alloy_js_core.createSymbolSlot)();
|
|
26
|
-
const ValueTypeSymbolSlot = (0, _alloy_js_core.createSymbolSlot)();
|
|
27
|
-
const sym = (0, _alloy_js_typescript.createValueSymbol)(name.value || "schema", {
|
|
28
|
-
refkeys: props.refkey,
|
|
29
|
-
default: props.default,
|
|
30
|
-
export: props.export,
|
|
31
|
-
metadata: props.metadata,
|
|
32
|
-
tsFlags: props.nullish ? _alloy_js_typescript.TSSymbolFlags.Nullish : _alloy_js_typescript.TSSymbolFlags.None,
|
|
33
|
-
type: props.type ? TypeSymbolSlot.firstSymbol : void 0,
|
|
34
|
-
namePolicy: (0, _alloy_js_typescript.useTSNamePolicy)().for("variable")
|
|
35
|
-
});
|
|
36
|
-
if (!props.type) ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
37
|
-
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
38
|
-
const type = props.type ? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeRefContext, { get children() {
|
|
39
|
-
return [": ", (0, _alloy_js_core_jsx_runtime.createComponent)(TypeSymbolSlot, { get children() {
|
|
40
|
-
return props.type;
|
|
41
|
-
} })];
|
|
42
|
-
} }) : void 0;
|
|
43
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
44
|
-
when: !!schema,
|
|
45
|
-
get children() {
|
|
46
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaContext.Provider, {
|
|
47
|
-
value: schema,
|
|
48
|
-
get children() {
|
|
49
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
50
|
-
get when() {
|
|
51
|
-
return !!name.value && !!type;
|
|
52
|
-
},
|
|
53
|
-
get children() {
|
|
54
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocObjectSchema, { schema }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Declaration, {
|
|
55
|
-
symbol: sym,
|
|
56
|
-
get children() {
|
|
57
|
-
return [
|
|
58
|
-
(0, _alloy_js_core_jsx_runtime.memo)(() => props.export ? "export " : ""),
|
|
59
|
-
(0, _alloy_js_core_jsx_runtime.memo)(() => props.default ? "default " : ""),
|
|
60
|
-
keyword,
|
|
61
|
-
" ",
|
|
62
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Name, {}),
|
|
63
|
-
type,
|
|
64
|
-
" =",
|
|
65
|
-
" ",
|
|
66
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(ValueTypeSymbolSlot, { get children() {
|
|
67
|
-
return props.initializer ?? props.children ?? (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ObjectExpression, { get children() {
|
|
68
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
69
|
-
get each() {
|
|
70
|
-
return properties.value ?? [];
|
|
71
|
-
},
|
|
72
|
-
comma: true,
|
|
73
|
-
doubleHardline: true,
|
|
74
|
-
children: (property) => (0, _alloy_js_core_jsx_runtime.createComponent)(ObjectDeclarationProperty, {
|
|
75
|
-
get name() {
|
|
76
|
-
return property.name;
|
|
77
|
-
},
|
|
78
|
-
schema: property
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
} });
|
|
82
|
-
} })
|
|
83
|
-
];
|
|
84
|
-
}
|
|
85
|
-
})];
|
|
86
|
-
}
|
|
87
|
-
}), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
95
|
-
*/
|
|
96
|
-
function ObjectDeclarationProperty(props) {
|
|
97
|
-
const [{ schema, name, value }, rest] = (0, _alloy_js_core.splitProps)(props, [
|
|
98
|
-
"schema",
|
|
99
|
-
"name",
|
|
100
|
-
"value"
|
|
101
|
-
]);
|
|
102
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
103
|
-
get when() {
|
|
104
|
-
return (0, _stryke_type_checks_is_set_string.isSetString)(name);
|
|
105
|
-
},
|
|
106
|
-
get children() {
|
|
107
|
-
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_core_contexts_schema.SchemaPropertyContext.Provider, {
|
|
108
|
-
value: schema,
|
|
109
|
-
get children() {
|
|
110
|
-
return [
|
|
111
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(require_typescript_components_tsdoc_schema.TSDocSchemaProperty, {
|
|
112
|
-
schema,
|
|
113
|
-
defaultValue: value
|
|
114
|
-
}),
|
|
115
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ObjectProperty, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
116
|
-
name,
|
|
117
|
-
get value() {
|
|
118
|
-
return (0, _powerlines_schema.stringifyValue)(value, schema.type);
|
|
119
|
-
}
|
|
120
|
-
}, rest)),
|
|
121
|
-
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
//#endregion
|
|
130
|
-
exports.ObjectDeclaration = ObjectDeclaration;
|
|
131
|
-
exports.ObjectDeclarationProperty = ObjectDeclarationProperty;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from "../../types/components.cjs";
|
|
2
|
-
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
|
-
import { JsonSchema, JsonSchemaObject } from "@powerlines/schema";
|
|
4
|
-
//#region src/typescript/components/object-declaration.d.ts
|
|
5
|
-
interface ObjectDeclarationProps extends VarDeclarationProps {
|
|
6
|
-
schema?: JsonSchemaObject;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Generates a TypeScript object for the given reflection class.
|
|
10
|
-
*/
|
|
11
|
-
declare function ObjectDeclaration(props: ObjectDeclarationProps): import("@alloy-js/core").Children;
|
|
12
|
-
interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
13
|
-
name: string;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
value?: unknown;
|
|
16
|
-
schema: JsonSchema;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
20
|
-
*/
|
|
21
|
-
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): import("@alloy-js/core").Children;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ObjectDeclaration, ObjectDeclarationProperty, ObjectDeclarationPropertyProps, ObjectDeclarationProps };
|
|
24
|
-
//# sourceMappingURL=object-declaration.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.d.cts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":";;;;UAqDiB,+BAA+B;EAC9C,SAAS;;;;;iBAMK,kBAAkB,OAAO,kDAAsB;UA0G9C,uCAAuC;EACtD;EACA;EACA;EACA,QAAQ;;;;;iBAMM,0BACd,OAAO,0DAA8B"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentProps } from "../../types/components.mjs";
|
|
2
|
-
import { JsonSchema, JsonSchemaObject } from "@powerlines/schema";
|
|
3
|
-
import { VarDeclarationProps } from "@alloy-js/typescript";
|
|
4
|
-
//#region src/typescript/components/object-declaration.d.ts
|
|
5
|
-
interface ObjectDeclarationProps extends VarDeclarationProps {
|
|
6
|
-
schema?: JsonSchemaObject;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Generates a TypeScript object for the given reflection class.
|
|
10
|
-
*/
|
|
11
|
-
declare function ObjectDeclaration(props: ObjectDeclarationProps): import("@alloy-js/core").Children;
|
|
12
|
-
interface ObjectDeclarationPropertyProps extends ComponentProps {
|
|
13
|
-
name: string;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
value?: unknown;
|
|
16
|
-
schema: JsonSchema;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
20
|
-
*/
|
|
21
|
-
declare function ObjectDeclarationProperty(props: ObjectDeclarationPropertyProps): import("@alloy-js/core").Children;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ObjectDeclaration, ObjectDeclarationProperty, ObjectDeclarationPropertyProps, ObjectDeclarationProps };
|
|
24
|
-
//# sourceMappingURL=object-declaration.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.d.mts","names":[],"sources":["../../../src/typescript/components/object-declaration.tsx"],"mappings":""}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { SchemaContext, SchemaPropertyContext } from "../../core/contexts/schema.mjs";
|
|
2
|
-
import { TSDocObjectSchema, TSDocSchemaProperty } from "./tsdoc-schema.mjs";
|
|
3
|
-
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
|
-
import { Declaration, For, Name, Show, computed, createSymbolSlot, splitProps } from "@alloy-js/core";
|
|
5
|
-
import { getPropertiesList, stringifyValue } from "@powerlines/schema";
|
|
6
|
-
import { camelCase } from "@stryke/string-format/camel-case";
|
|
7
|
-
import { ObjectExpression, ObjectProperty, TSSymbolFlags, TypeRefContext, createValueSymbol, useTSNamePolicy } from "@alloy-js/typescript";
|
|
8
|
-
import { isUndefined } from "@stryke/type-checks/is-undefined";
|
|
9
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
10
|
-
|
|
11
|
-
//#region src/typescript/components/object-declaration.tsx
|
|
12
|
-
/**
|
|
13
|
-
* Generates a TypeScript object for the given reflection class.
|
|
14
|
-
*/
|
|
15
|
-
function ObjectDeclaration(props) {
|
|
16
|
-
const { schema } = props;
|
|
17
|
-
if (!schema) return null;
|
|
18
|
-
const name = computed(() => camelCase(isSetString(props.name) ? props.name : schema?.name));
|
|
19
|
-
const defaultValues = computed(() => Object.fromEntries(getPropertiesList(schema).map((property) => [property.name, property.default]) || {}));
|
|
20
|
-
const properties = computed(() => getPropertiesList(schema).filter((property) => !property?.ignore && !property?.runtime && !isUndefined(defaultValues.value[property.name] ?? property?.alias?.reduce((ret, alias) => {
|
|
21
|
-
if (isUndefined(ret) && !isUndefined(defaultValues.value[alias])) return defaultValues.value[alias];
|
|
22
|
-
return ret;
|
|
23
|
-
}, void 0) ?? property?.default)).sort((a, b) => a?.readOnly && b?.readOnly || !a?.readOnly && !b?.readOnly ? a.name.localeCompare(b.name) : a?.readOnly ? 1 : -1));
|
|
24
|
-
const TypeSymbolSlot = createSymbolSlot();
|
|
25
|
-
const ValueTypeSymbolSlot = createSymbolSlot();
|
|
26
|
-
const sym = createValueSymbol(name.value || "schema", {
|
|
27
|
-
refkeys: props.refkey,
|
|
28
|
-
default: props.default,
|
|
29
|
-
export: props.export,
|
|
30
|
-
metadata: props.metadata,
|
|
31
|
-
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,
|
|
32
|
-
type: props.type ? TypeSymbolSlot.firstSymbol : void 0,
|
|
33
|
-
namePolicy: useTSNamePolicy().for("variable")
|
|
34
|
-
});
|
|
35
|
-
if (!props.type) ValueTypeSymbolSlot.moveMembersTo(sym);
|
|
36
|
-
const keyword = props.var ? "var" : props.let ? "let" : "const";
|
|
37
|
-
const type = props.type ? createComponent(TypeRefContext, { get children() {
|
|
38
|
-
return [": ", createComponent(TypeSymbolSlot, { get children() {
|
|
39
|
-
return props.type;
|
|
40
|
-
} })];
|
|
41
|
-
} }) : void 0;
|
|
42
|
-
return createComponent(Show, {
|
|
43
|
-
when: !!schema,
|
|
44
|
-
get children() {
|
|
45
|
-
return createComponent(SchemaContext.Provider, {
|
|
46
|
-
value: schema,
|
|
47
|
-
get children() {
|
|
48
|
-
return [createComponent(Show, {
|
|
49
|
-
get when() {
|
|
50
|
-
return !!name.value && !!type;
|
|
51
|
-
},
|
|
52
|
-
get children() {
|
|
53
|
-
return [createComponent(TSDocObjectSchema, { schema }), createComponent(Declaration, {
|
|
54
|
-
symbol: sym,
|
|
55
|
-
get children() {
|
|
56
|
-
return [
|
|
57
|
-
memo(() => props.export ? "export " : ""),
|
|
58
|
-
memo(() => props.default ? "default " : ""),
|
|
59
|
-
keyword,
|
|
60
|
-
" ",
|
|
61
|
-
createComponent(Name, {}),
|
|
62
|
-
type,
|
|
63
|
-
" =",
|
|
64
|
-
" ",
|
|
65
|
-
createComponent(ValueTypeSymbolSlot, { get children() {
|
|
66
|
-
return props.initializer ?? props.children ?? createComponent(ObjectExpression, { get children() {
|
|
67
|
-
return createComponent(For, {
|
|
68
|
-
get each() {
|
|
69
|
-
return properties.value ?? [];
|
|
70
|
-
},
|
|
71
|
-
comma: true,
|
|
72
|
-
doubleHardline: true,
|
|
73
|
-
children: (property) => createComponent(ObjectDeclarationProperty, {
|
|
74
|
-
get name() {
|
|
75
|
-
return property.name;
|
|
76
|
-
},
|
|
77
|
-
schema: property
|
|
78
|
-
})
|
|
79
|
-
});
|
|
80
|
-
} });
|
|
81
|
-
} })
|
|
82
|
-
];
|
|
83
|
-
}
|
|
84
|
-
})];
|
|
85
|
-
}
|
|
86
|
-
}), createIntrinsic("hbr", {})];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Generates a TypeScript object property for the given reflection class.
|
|
94
|
-
*/
|
|
95
|
-
function ObjectDeclarationProperty(props) {
|
|
96
|
-
const [{ schema, name, value }, rest] = splitProps(props, [
|
|
97
|
-
"schema",
|
|
98
|
-
"name",
|
|
99
|
-
"value"
|
|
100
|
-
]);
|
|
101
|
-
return createComponent(Show, {
|
|
102
|
-
get when() {
|
|
103
|
-
return isSetString(name);
|
|
104
|
-
},
|
|
105
|
-
get children() {
|
|
106
|
-
return createComponent(SchemaPropertyContext.Provider, {
|
|
107
|
-
value: schema,
|
|
108
|
-
get children() {
|
|
109
|
-
return [
|
|
110
|
-
createComponent(TSDocSchemaProperty, {
|
|
111
|
-
schema,
|
|
112
|
-
defaultValue: value
|
|
113
|
-
}),
|
|
114
|
-
createComponent(ObjectProperty, mergeProps({
|
|
115
|
-
name,
|
|
116
|
-
get value() {
|
|
117
|
-
return stringifyValue(value, schema.type);
|
|
118
|
-
}
|
|
119
|
-
}, rest)),
|
|
120
|
-
createIntrinsic("hbr", {})
|
|
121
|
-
];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
export { ObjectDeclaration, ObjectDeclarationProperty };
|
|
130
|
-
//# sourceMappingURL=object-declaration.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-declaration.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_typescript_helpers_utilities = require('../helpers/utilities.cjs');
|
|
3
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
-
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
-
|
|
6
|
-
//#region src/typescript/components/property-name.tsx
|
|
7
|
-
/**
|
|
8
|
-
* A TypeScript property name for an interface, class, or object member.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* If the name is not a valid JavaScript identifier, it will be quoted. If a `name` prop is provided, it will be used as the property name. Otherwise, the name will be taken from the {@link (MemberDeclarationContext:variable)}.
|
|
12
|
-
*/
|
|
13
|
-
function PropertyName(props) {
|
|
14
|
-
if (props.name) return (0, _alloy_js_core.memo)(() => {
|
|
15
|
-
if (props.private) return `#${props.name}`;
|
|
16
|
-
return quoteIfNeeded(props.name);
|
|
17
|
-
});
|
|
18
|
-
else {
|
|
19
|
-
const declSymbol = (0, _alloy_js_core.useContext)(_alloy_js_core.MemberDeclarationContext);
|
|
20
|
-
if (!declSymbol) return "(no member declaration context)";
|
|
21
|
-
if (declSymbol.isPrivateMemberSymbol) return ["#", (0, _alloy_js_core_jsx_runtime.memo)(() => declSymbol.name)];
|
|
22
|
-
else return [(0, _alloy_js_core_jsx_runtime.memo)(() => quoteIfNeeded(declSymbol.name))];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function quoteIfNeeded(name) {
|
|
26
|
-
if (require_typescript_helpers_utilities.isValidJSIdentifier(name)) return name;
|
|
27
|
-
else return `"${name.replace(/"/g, "\\\"")}"`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.PropertyName = PropertyName;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/typescript/components/property-name.d.ts
|
|
2
|
-
interface PropertyNameProps {
|
|
3
|
-
/**
|
|
4
|
-
* The name of the property.
|
|
5
|
-
*/
|
|
6
|
-
name?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Whether the property is a private property. If `true`, the property will be prefixed with `#`.
|
|
9
|
-
*/
|
|
10
|
-
private?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A TypeScript property name for an interface, class, or object member.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* If the name is not a valid JavaScript identifier, it will be quoted. If a `name` prop is provided, it will be used as the property name. Otherwise, the name will be taken from the {@link (MemberDeclarationContext:variable)}.
|
|
17
|
-
*/
|
|
18
|
-
declare function PropertyName(props: PropertyNameProps): import("@alloy-js/core").Children;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { PropertyName, PropertyNameProps };
|
|
21
|
-
//# sourceMappingURL=property-name.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property-name.d.cts","names":[],"sources":["../../../src/typescript/components/property-name.tsx"],"mappings":";UAsBiB;;;;EAIf;;;;EAKA;;;;;;;;iBASc,aAAa,OAAO,6CAAiB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/typescript/components/property-name.d.ts
|
|
2
|
-
interface PropertyNameProps {
|
|
3
|
-
/**
|
|
4
|
-
* The name of the property.
|
|
5
|
-
*/
|
|
6
|
-
name?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Whether the property is a private property. If `true`, the property will be prefixed with `#`.
|
|
9
|
-
*/
|
|
10
|
-
private?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A TypeScript property name for an interface, class, or object member.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* If the name is not a valid JavaScript identifier, it will be quoted. If a `name` prop is provided, it will be used as the property name. Otherwise, the name will be taken from the {@link (MemberDeclarationContext:variable)}.
|
|
17
|
-
*/
|
|
18
|
-
declare function PropertyName(props: PropertyNameProps): import("@alloy-js/core").Children;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { PropertyName, PropertyNameProps };
|
|
21
|
-
//# sourceMappingURL=property-name.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property-name.d.mts","names":[],"sources":["../../../src/typescript/components/property-name.tsx"],"mappings":""}
|