@typespec/emitter-framework 0.11.0-dev.0 → 0.11.0-dev.10
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/src/core/components/index.d.ts +2 -0
- package/dist/src/core/components/index.d.ts.map +1 -1
- package/dist/src/core/components/index.js +4 -1
- package/dist/src/core/components/index.js.map +1 -0
- package/dist/src/core/components/output.js +2 -1
- package/dist/src/core/components/output.js.map +1 -0
- package/dist/src/core/components/overrides/component-overrides.d.ts +64 -0
- package/dist/src/core/components/overrides/component-overrides.d.ts.map +1 -0
- package/dist/src/core/components/overrides/component-overrides.js +41 -0
- package/dist/src/core/components/overrides/component-overrides.js.map +1 -0
- package/dist/src/core/components/overrides/config.d.ts +28 -0
- package/dist/src/core/components/overrides/config.d.ts.map +1 -0
- package/dist/src/core/components/overrides/config.js +55 -0
- package/dist/src/core/components/overrides/config.js.map +1 -0
- package/dist/src/core/components/overrides/context.d.ts +11 -0
- package/dist/src/core/components/overrides/context.d.ts.map +1 -0
- package/dist/src/core/components/overrides/context.js +9 -0
- package/dist/src/core/components/overrides/context.js.map +1 -0
- package/dist/src/core/context/index.js +2 -1
- package/dist/src/core/context/index.js.map +1 -0
- package/dist/src/core/context/name-policy-context.js +2 -1
- package/dist/src/core/context/name-policy-context.js.map +1 -0
- package/dist/src/core/context/tsp-context.js +2 -1
- package/dist/src/core/context/tsp-context.js.map +1 -0
- package/dist/src/core/index.js +2 -1
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/transport-name-policy.js +2 -1
- package/dist/src/core/transport-name-policy.js.map +1 -0
- package/dist/src/core/write-output.d.ts.map +1 -1
- package/dist/src/core/write-output.js +4 -3
- package/dist/src/core/write-output.js.map +1 -0
- package/dist/src/csharp/components/class/declaration.d.ts +1 -1
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.js +14 -5
- package/dist/src/csharp/components/class/declaration.js.map +1 -0
- package/dist/src/csharp/components/class/declaration.test.js +125 -92
- package/dist/src/csharp/components/class/declaration.test.js.map +1 -0
- package/dist/src/csharp/components/enum/declaration.js +2 -1
- package/dist/src/csharp/components/enum/declaration.js.map +1 -0
- package/dist/src/csharp/components/enum/declaration.test.js +52 -88
- package/dist/src/csharp/components/enum/declaration.test.js.map +1 -0
- package/dist/src/csharp/components/index.js +2 -1
- package/dist/src/csharp/components/index.js.map +1 -0
- package/dist/src/csharp/components/property/property.d.ts.map +1 -1
- package/dist/src/csharp/components/property/property.js +40 -14
- package/dist/src/csharp/components/property/property.js.map +1 -0
- package/dist/src/csharp/components/property/property.test.js +129 -29
- package/dist/src/csharp/components/property/property.test.js.map +1 -0
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
- package/dist/src/csharp/components/type-expression.js +34 -6
- package/dist/src/csharp/components/type-expression.js.map +1 -0
- package/dist/src/csharp/components/type-expression.test.js +87 -54
- package/dist/src/csharp/components/type-expression.test.js.map +1 -0
- package/dist/src/csharp/components/utils/doc-comments.js +2 -1
- package/dist/src/csharp/components/utils/doc-comments.js.map +1 -0
- package/dist/src/csharp/components/utils/nullable-util.d.ts +4 -0
- package/dist/src/csharp/components/utils/nullable-util.d.ts.map +1 -0
- package/dist/src/csharp/components/utils/nullable-util.js +27 -0
- package/dist/src/csharp/components/utils/nullable-util.js.map +1 -0
- package/dist/src/csharp/components/utils/refkey.js +2 -1
- package/dist/src/csharp/components/utils/refkey.js.map +1 -0
- package/dist/src/csharp/index.js +2 -1
- package/dist/src/csharp/index.js.map +1 -0
- package/dist/src/lib.js +2 -1
- package/dist/src/lib.js.map +1 -0
- package/dist/src/testing/index.js +2 -1
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.js +2 -1
- package/dist/src/testing/scenario-test/code-block-expectation.js.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.test.js +2 -1
- package/dist/src/testing/scenario-test/code-block-expectation.test.js.map +1 -0
- package/dist/src/testing/scenario-test/harness.js +8 -2
- package/dist/src/testing/scenario-test/harness.js.map +1 -0
- package/dist/src/testing/scenario-test/index.js +2 -1
- package/dist/src/testing/scenario-test/index.js.map +1 -0
- package/dist/src/testing/scenario-test/snippet-extractor.js +2 -1
- package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
- package/dist/src/typescript/components/array-expression.js +2 -1
- package/dist/src/typescript/components/array-expression.js.map +1 -0
- package/dist/src/typescript/components/arrow-function.js +2 -1
- package/dist/src/typescript/components/arrow-function.js.map +1 -0
- package/dist/src/typescript/components/class-method.js +2 -1
- package/dist/src/typescript/components/class-method.js.map +1 -0
- package/dist/src/typescript/components/enum-declaration.js +2 -1
- package/dist/src/typescript/components/enum-declaration.js.map +1 -0
- package/dist/src/typescript/components/function-declaration.js +2 -1
- package/dist/src/typescript/components/function-declaration.js.map +1 -0
- package/dist/src/typescript/components/function-expression.js +2 -1
- package/dist/src/typescript/components/function-expression.js.map +1 -0
- package/dist/src/typescript/components/function-type.js +2 -1
- package/dist/src/typescript/components/function-type.js.map +1 -0
- package/dist/src/typescript/components/index.js +2 -1
- package/dist/src/typescript/components/index.js.map +1 -0
- package/dist/src/typescript/components/interface-declaration.js +2 -1
- package/dist/src/typescript/components/interface-declaration.js.map +1 -0
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-member.js +13 -20
- package/dist/src/typescript/components/interface-member.js.map +1 -0
- package/dist/src/typescript/components/interface-method.js +2 -1
- package/dist/src/typescript/components/interface-method.js.map +1 -0
- package/dist/src/typescript/components/record-expression.js +2 -1
- package/dist/src/typescript/components/record-expression.js.map +1 -0
- package/dist/src/typescript/components/static-serializers.js +2 -1
- package/dist/src/typescript/components/static-serializers.js.map +1 -0
- package/dist/src/typescript/components/type-alias-declaration.js +2 -1
- package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-declaration.js +2 -1
- package/dist/src/typescript/components/type-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-expression.d.ts +0 -1
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.js +13 -12
- package/dist/src/typescript/components/type-expression.js.map +1 -0
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
- package/dist/src/typescript/components/type-transform.js +5 -4
- package/dist/src/typescript/components/type-transform.js.map +1 -0
- package/dist/src/typescript/components/union/declaration.js +2 -1
- package/dist/src/typescript/components/union/declaration.js.map +1 -0
- package/dist/src/typescript/components/union/declaration.test.js +2 -1
- package/dist/src/typescript/components/union/declaration.test.js.map +1 -0
- package/dist/src/typescript/components/union/expression.js +2 -1
- package/dist/src/typescript/components/union/expression.js.map +1 -0
- package/dist/src/typescript/components/union/expression.test.js +2 -1
- package/dist/src/typescript/components/union/expression.test.js.map +1 -0
- package/dist/src/typescript/components/value-expression.js +2 -1
- package/dist/src/typescript/components/value-expression.js.map +1 -0
- package/dist/src/typescript/index.js +2 -1
- package/dist/src/typescript/index.js.map +1 -0
- package/dist/src/typescript/lib.js +2 -1
- package/dist/src/typescript/lib.js.map +1 -0
- package/dist/src/typescript/utils/index.js +2 -1
- package/dist/src/typescript/utils/index.js.map +1 -0
- package/dist/src/typescript/utils/operation.js +2 -1
- package/dist/src/typescript/utils/operation.js.map +1 -0
- package/dist/src/typescript/utils/refkey.js +2 -1
- package/dist/src/typescript/utils/refkey.js.map +1 -0
- package/dist/test/test-host.js +2 -1
- package/dist/test/test-host.js.map +1 -0
- package/dist/test/testing/snippet-extractor-csharp.test.js +2 -1
- package/dist/test/testing/snippet-extractor-csharp.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-java.test.js +2 -1
- package/dist/test/testing/snippet-extractor-java.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-python.test.js +2 -1
- package/dist/test/testing/snippet-extractor-python.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-typescript.test.js +2 -1
- package/dist/test/testing/snippet-extractor-typescript.test.js.map +1 -0
- package/dist/test/typescript/components/arrow-function.test.js +18 -22
- package/dist/test/typescript/components/arrow-function.test.js.map +1 -0
- package/dist/test/typescript/components/component-override.test.d.ts +2 -0
- package/dist/test/typescript/components/component-override.test.d.ts.map +1 -0
- package/dist/test/typescript/components/component-override.test.js +78 -0
- package/dist/test/typescript/components/component-override.test.js.map +1 -0
- package/dist/test/typescript/components/enum-declaration.test.js +2 -1
- package/dist/test/typescript/components/enum-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/function-declaration.test.js +3 -2
- package/dist/test/typescript/components/function-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/function-expression.test.js +18 -22
- package/dist/test/typescript/components/function-expression.test.js.map +1 -0
- package/dist/test/typescript/components/function-type.test.js +18 -22
- package/dist/test/typescript/components/function-type.test.js.map +1 -0
- package/dist/test/typescript/components/interface-declaration.test.js +3 -2
- package/dist/test/typescript/components/interface-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/interface-method.test.js +37 -45
- package/dist/test/typescript/components/interface-method.test.js.map +1 -0
- package/dist/test/typescript/components/member-expression.test.js +2 -1
- package/dist/test/typescript/components/member-expression.test.js.map +1 -0
- package/dist/test/typescript/components/type-alias-declaration.test.js +8 -5
- package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/type-transform.test.js +29 -27
- package/dist/test/typescript/components/type-transform.test.js.map +1 -0
- package/dist/test/typescript/components/value-expression.test.js +3 -2
- package/dist/test/typescript/components/value-expression.test.js.map +1 -0
- package/dist/test/typescript/utils.js +2 -1
- package/dist/test/typescript/utils.js.map +1 -0
- package/dist/test/utils.d.ts +1 -0
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +13 -3
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/package.json +9 -13
- package/src/core/components/index.tsx +2 -0
- package/src/core/components/overrides/component-overrides.tsx +134 -0
- package/src/core/components/overrides/config.ts +85 -0
- package/src/core/components/overrides/context.ts +14 -0
- package/src/core/write-output.ts +2 -2
- package/src/csharp/components/class/declaration.test.tsx +114 -88
- package/src/csharp/components/class/declaration.tsx +13 -3
- package/src/csharp/components/enum/declaration.test.tsx +47 -78
- package/src/csharp/components/property/property.test.tsx +108 -25
- package/src/csharp/components/property/property.tsx +43 -11
- package/src/csharp/components/type-expression.test.tsx +84 -69
- package/src/csharp/components/type-expression.tsx +31 -5
- package/src/csharp/components/utils/nullable-util.ts +25 -0
- package/src/testing/scenario-test/harness.ts +6 -1
- package/src/typescript/components/interface-member.tsx +8 -14
- package/src/typescript/components/type-expression.tsx +7 -8
- package/src/typescript/components/type-transform.tsx +3 -7
- package/test/typescript/components/arrow-function.test.tsx +23 -42
- package/test/typescript/components/component-override.test.tsx +71 -0
- package/test/typescript/components/function-declaration.test.tsx +2 -1
- package/test/typescript/components/function-expression.test.tsx +23 -42
- package/test/typescript/components/function-type.test.tsx +22 -40
- package/test/typescript/components/interface-declaration.test.tsx +1 -1
- package/test/typescript/components/interface-method.test.tsx +50 -92
- package/test/typescript/components/type-alias-declaration.test.tsx +8 -6
- package/test/typescript/components/type-transform.test.tsx +37 -37
- package/test/typescript/components/value-expression.test.tsx +1 -1
- package/test/utils.ts +10 -3
- package/dist/test/typescript/test-host.d.ts +0 -16
- package/dist/test/typescript/test-host.d.ts.map +0 -1
- package/dist/test/typescript/test-host.js +0 -40
- package/test/typescript/test-host.ts +0 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qCAAqC,CAAC;AACpD,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/core/components/index.tsx"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA,cAAc,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Output","CoreOutput","splitProps","TspContext","props","program","rest","_$createComponent","Provider","value","children"],"sources":["../../../../src/core/components/output.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,MAAM,IAAIC,UAAU,EACpBC,UAAU,QAEL,gBAAgB;AAEvB,SAASC,UAAU,QAAQ,2BAA2B;AAStD,OAAO,SAASH,MAAMA,CAACI,KAAkB,EAAE;EACzC,MAAM,CAAC;IAAEC;EAAQ,CAAC,EAAEC,IAAI,CAAC,GAAGJ,UAAU,CAACE,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC;EAC1D,OAAAG,iBAAA,CACGJ,UAAU,CAACK,QAAQ;IAACC,KAAK,EAAE;MAAEJ;IAAQ,CAAC;IAAA,IAAAK,SAAA;MAAA,OAAAH,iBAAA,CACpCN,UAAU,EAAKK,IAAI;IAAA;EAAA;AAG1B","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Children, type ComponentDefinition } from "@alloy-js/core";
|
|
2
|
+
import type { ObjectPropertyProps, VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
|
+
import type { Enum, EnumMember, Model, ModelProperty, Scalar, Type, Union, UnionVariant } from "@typespec/compiler";
|
|
4
|
+
import { type Experimental_ComponentOverridesConfig } from "./config.js";
|
|
5
|
+
export interface Experimental_OverrideEmitPropsBase<TCustomType extends Type> {
|
|
6
|
+
/**
|
|
7
|
+
* The TypeSpec type to render.
|
|
8
|
+
*/
|
|
9
|
+
type: TCustomType;
|
|
10
|
+
/**
|
|
11
|
+
* The default emitted output for this type.
|
|
12
|
+
*/
|
|
13
|
+
default: Children;
|
|
14
|
+
}
|
|
15
|
+
export type Experimental_CustomTypeToProps<TCustomType extends Type> = TCustomType extends ModelProperty ? ObjectPropertyProps : TCustomType extends EnumMember ? {} : TCustomType extends UnionVariant ? {} : TCustomType extends Model | Scalar | Union | Enum ? VarDeclarationProps : VarDeclarationProps | ObjectPropertyProps;
|
|
16
|
+
export interface Experimental_OverrideReferenceProps<TCustomType extends Type> extends Experimental_OverrideEmitPropsBase<TCustomType> {
|
|
17
|
+
/**
|
|
18
|
+
* The member this type is referenced from, if any. This member may contain
|
|
19
|
+
* additional metadata that should be represented in the emitted output.
|
|
20
|
+
*/
|
|
21
|
+
member?: ModelProperty;
|
|
22
|
+
}
|
|
23
|
+
export interface Experimental_OverrideDeclareProps<TCustomType extends Type> extends Experimental_OverrideEmitPropsBase<TCustomType> {
|
|
24
|
+
Declaration: ComponentDefinition<Experimental_CustomTypeToProps<TCustomType>>;
|
|
25
|
+
declarationProps: Experimental_CustomTypeToProps<TCustomType>;
|
|
26
|
+
}
|
|
27
|
+
export type Experimental_OverrideDeclarationComponent<TCustomType extends Type> = ComponentDefinition<Experimental_OverrideDeclareProps<TCustomType>>;
|
|
28
|
+
export type Experimental_OverrideReferenceComponent<TCustomType extends Type> = ComponentDefinition<Experimental_OverrideReferenceProps<TCustomType>>;
|
|
29
|
+
export interface Experimental_ComponentOverridesConfigBase<TCustomType extends Type> {
|
|
30
|
+
/**
|
|
31
|
+
* Override when this type is referenced.
|
|
32
|
+
* e.g. When used in <TypeExpression type={type} />
|
|
33
|
+
*/
|
|
34
|
+
reference?: Experimental_OverrideReferenceComponent<TCustomType>;
|
|
35
|
+
}
|
|
36
|
+
export interface Experimental_ComponentOverridesProps {
|
|
37
|
+
overrides: Experimental_ComponentOverridesConfig;
|
|
38
|
+
children?: Children;
|
|
39
|
+
}
|
|
40
|
+
export declare function Experimental_ComponentOverrides(props: Experimental_ComponentOverridesProps): Children;
|
|
41
|
+
export interface Experimental_OverrideTypeComponentCommonProps<T extends Type> {
|
|
42
|
+
/**
|
|
43
|
+
* The TypeSpec type to render.
|
|
44
|
+
*/
|
|
45
|
+
type: T;
|
|
46
|
+
/**
|
|
47
|
+
* The default rendering.
|
|
48
|
+
*/
|
|
49
|
+
children: Children;
|
|
50
|
+
}
|
|
51
|
+
export interface Experimental_OverridableComponentReferenceProps<T extends Type> extends Experimental_OverrideTypeComponentCommonProps<T> {
|
|
52
|
+
/**
|
|
53
|
+
* Pass when rendering a reference to the provided type or type kind.
|
|
54
|
+
*/
|
|
55
|
+
reference: true;
|
|
56
|
+
/**
|
|
57
|
+
* The member this type is referenced from, if any. This member may contain
|
|
58
|
+
* additional metadata that should be represented in the emitted output.
|
|
59
|
+
*/
|
|
60
|
+
member?: ModelProperty;
|
|
61
|
+
}
|
|
62
|
+
export type Experimental_OverridableComponentProps<T extends Type> = Experimental_OverridableComponentReferenceProps<T>;
|
|
63
|
+
export declare function Experimental_OverridableComponent<T extends Type>(props: Experimental_OverridableComponentProps<T>): Children;
|
|
64
|
+
//# sourceMappingURL=component-overrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-overrides.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/overrides/component-overrides.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EACV,IAAI,EACJ,UAAU,EACV,KAAK,EACL,aAAa,EACb,MAAM,EACN,IAAI,EACJ,KAAK,EACL,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,qCAAqC,EAG3C,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,kCAAkC,CAAC,WAAW,SAAS,IAAI;IAC1E;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,MAAM,8BAA8B,CAAC,WAAW,SAAS,IAAI,IACjE,WAAW,S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AM,WAAW,+CAA+C,CAAC,CAAC,SAAS,IAAI,CAC7E,SAAQ,6CAA6C,CAAC,CAAC,CAAC;IACxD;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,MAAM,sCAAsC,CAAC,CAAC,SAAS,IAAI,IAC/D,+CAA+C,CAAC,CAAC,CAAC,CAAC;AAErD,wBAAgB,iCAAiC,CAAC,CAAC,SAAS,IAAI,EAC9D,KAAK,EAAE,sCAAsC,CAAC,CAAC,CAAC,YAkBjD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { useTsp } from "../../context/index.js";
|
|
3
|
+
import { getOverrideForType, getOverridesForTypeKind } from "./config.js";
|
|
4
|
+
import { OverridesContext, useOverrides } from "./context.js";
|
|
5
|
+
export function Experimental_ComponentOverrides(props) {
|
|
6
|
+
const context = {
|
|
7
|
+
overrides: props.overrides
|
|
8
|
+
};
|
|
9
|
+
return _$createComponent(OverridesContext.Provider, {
|
|
10
|
+
value: context,
|
|
11
|
+
get children() {
|
|
12
|
+
return props.children;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function Experimental_OverridableComponent(props) {
|
|
17
|
+
const options = useOverrides();
|
|
18
|
+
const {
|
|
19
|
+
$
|
|
20
|
+
} = useTsp();
|
|
21
|
+
const descriptor = getOverrideForType($.program, props.type, options.overrides) ?? getOverridesForTypeKind($.program, props.type.kind, options.overrides);
|
|
22
|
+
if (!descriptor) {
|
|
23
|
+
return [_$memo(() => props.children)];
|
|
24
|
+
}
|
|
25
|
+
if ("reference" in props && props.reference && descriptor.reference) {
|
|
26
|
+
const CustomComponent = descriptor.reference;
|
|
27
|
+
return _$createComponent(CustomComponent, {
|
|
28
|
+
get type() {
|
|
29
|
+
return props.type;
|
|
30
|
+
},
|
|
31
|
+
get member() {
|
|
32
|
+
return props.member;
|
|
33
|
+
},
|
|
34
|
+
get ["default"]() {
|
|
35
|
+
return props.children;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return [_$memo(() => props.children)];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=component-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useTsp","getOverrideForType","getOverridesForTypeKind","OverridesContext","useOverrides","Experimental_ComponentOverrides","props","context","overrides","_$createComponent","Provider","value","children","Experimental_OverridableComponent","options","$","descriptor","program","type","kind","_$memo","reference","CustomComponent","member","default"],"sources":["../../../../../src/core/components/overrides/component-overrides.tsx"],"sourcesContent":[null],"mappings":";AAYA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAEEC,kBAAkB,EAClBC,uBAAuB,QAClB,aAAa;AACpB,SAAyCC,gBAAgB,EAAEC,YAAY,QAAQ,cAAc;AA2D7F,OAAO,SAASC,+BAA+BA,CAACC,KAA2C,EAAE;EAC3F,MAAMC,OAAkC,GAAG;IACzCC,SAAS,EAAEF,KAAK,CAACE;EACnB,CAAC;EAED,OAAAC,iBAAA,CAAQN,gBAAgB,CAACO,QAAQ;IAACC,KAAK,EAAEJ,OAAO;IAAA,IAAAK,SAAA;MAAA,OAAGN,KAAK,CAACM,QAAQ;IAAA;EAAA;AACnE;AA+BA,OAAO,SAASC,iCAAiCA,CAC/CP,KAAgD,EAChD;EACA,MAAMQ,OAAO,GAAGV,YAAY,CAAC,CAAC;EAC9B,MAAM;IAAEW;EAAE,CAAC,GAAGf,MAAM,CAAC,CAAC;EACtB,MAAMgB,UAAU,GACdf,kBAAkB,CAACc,CAAC,CAACE,OAAO,EAAEX,KAAK,CAACY,IAAI,EAAEJ,OAAO,CAACN,SAAS,CAAC,IAC5DN,uBAAuB,CAACa,CAAC,CAACE,OAAO,EAAEX,KAAK,CAACY,IAAI,CAACC,IAAI,EAAEL,OAAO,CAACN,SAAS,CAAC;EAExE,IAAI,CAACQ,UAAU,EAAE;IACf,QAAAI,MAAA,OAAUd,KAAK,CAACM,QAAQ;EAC1B;EAEA,IAAI,WAAW,IAAIN,KAAK,IAAIA,KAAK,CAACe,SAAS,IAAIL,UAAU,CAACK,SAAS,EAAE;IACnE,MAAMC,eAAe,GAAGN,UAAU,CAACK,SAAS;IAC5C,OAAAZ,iBAAA,CAAQa,eAAe;MAAA,IAACJ,IAAIA,CAAA;QAAA,OAAEZ,KAAK,CAACY,IAAI;MAAA;MAAA,IAAEK,MAAMA,CAAA;QAAA,OAAEjB,KAAK,CAACiB,MAAM;MAAA;MAAA,eAAAC,CAAA;QAAA,OAAWlB,KAAK,CAACM,QAAQ;MAAA;IAAA;EACzF;EAEA,QAAAQ,MAAA,OAAUd,KAAK,CAACM,QAAQ;AAC1B","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Program, Type } from "@typespec/compiler";
|
|
2
|
+
import type { Experimental_ComponentOverridesConfigBase } from "./component-overrides.jsx";
|
|
3
|
+
declare const getOverrideForTypeSym: unique symbol;
|
|
4
|
+
declare const getOverrideForTypeKindSym: unique symbol;
|
|
5
|
+
export type Experimental_ComponentOverridesConfig = Experimental_ComponentOverridesClass;
|
|
6
|
+
export declare const Experimental_ComponentOverridesConfig: {
|
|
7
|
+
new (): Experimental_ComponentOverridesClass;
|
|
8
|
+
(): Experimental_ComponentOverridesClass;
|
|
9
|
+
};
|
|
10
|
+
export declare class Experimental_ComponentOverridesClass {
|
|
11
|
+
#private;
|
|
12
|
+
forType<const T extends Type>(type: T, options: Experimental_ComponentOverridesConfigBase<T>): this;
|
|
13
|
+
forTypeKind<const TKind extends Type["kind"]>(typeKind: TKind, options: Experimental_ComponentOverridesConfigBase<Extract<Type, {
|
|
14
|
+
kind: TKind;
|
|
15
|
+
}>>): this;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
[getOverrideForTypeSym](program: Program, type: Type): Experimental_ComponentOverridesConfigBase<any> | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
[getOverrideForTypeKindSym](program: Program, typeKind: Type["kind"]): Experimental_ComponentOverridesConfigBase<any> | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare function getOverrideForType(program: Program, type: Type, options?: Experimental_ComponentOverridesConfig): Experimental_ComponentOverridesConfigBase<any> | undefined;
|
|
26
|
+
export declare function getOverridesForTypeKind(program: Program, typeKind: Type["kind"], options?: Experimental_ComponentOverridesConfig): Experimental_ComponentOverridesConfigBase<any> | undefined;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/overrides/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAU,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,2BAA2B,CAAC;AAE3F,QAAA,MAAM,qBAAqB,EAAE,OAAO,MAA+C,CAAC;AACpF,QAAA,MAAM,yBAAyB,EAAE,OAAO,MAAmD,CAAC;AAE5F,MAAM,MAAM,qCAAqC,GAAG,oCAAoC,CAAC;AACzF,eAAO,MAAM,qCAAqC,EAE7C;IACH,QAAQ,oCAAoC,CAAC;IAC7C,IAAI,oCAAoC,CAAC;CAC1C,CAAC;AAEF,qBAAa,oCAAoC;;IAK/C,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,yCAAyC,CAAC,CAAC,CAAC;IAM5F,WAAW,CAAC,KAAK,CAAC,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,EAC1C,QAAQ,EAAE,KAAK,EACf,OAAO,EAAE,yCAAyC,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;IAOpF;;OAEG;IACH,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;IAwBpD;;OAEG;IACH,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;CAGrE;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,qCAAqC,8DAGhD;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EACtB,OAAO,CAAC,EAAE,qCAAqC,8DAGhD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { $ } from "@typespec/compiler/typekit";
|
|
2
|
+
const getOverrideForTypeSym = Symbol.for("ef-ts:getOverrideForType");
|
|
3
|
+
const getOverrideForTypeKindSym = Symbol.for("ef-ts:getOverrideForTypeKind");
|
|
4
|
+
export const Experimental_ComponentOverridesConfig = function () {
|
|
5
|
+
return new Experimental_ComponentOverridesClass();
|
|
6
|
+
};
|
|
7
|
+
export class Experimental_ComponentOverridesClass {
|
|
8
|
+
#typeEmitOptions = new Map();
|
|
9
|
+
#typeKindEmitOptions = new Map();
|
|
10
|
+
forType(type, options) {
|
|
11
|
+
this.#typeEmitOptions.set(type, options);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
forTypeKind(typeKind, options) {
|
|
15
|
+
this.#typeKindEmitOptions.set(typeKind, options);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
[getOverrideForTypeSym](program, type) {
|
|
23
|
+
const options = this.#typeEmitOptions.get(type);
|
|
24
|
+
if (options || !$(program).scalar.is(type) /** || isBuiltIn(program, type) */) {
|
|
25
|
+
return options;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// have a scalar, it's not a built-in scalar, and didn't find options, so
|
|
29
|
+
// see if we have options for a base scalar.
|
|
30
|
+
let currentScalar = type;
|
|
31
|
+
while (currentScalar &&
|
|
32
|
+
// !isBuiltIn(program, currentScalar) &&
|
|
33
|
+
!this.#typeEmitOptions.has(currentScalar)) {
|
|
34
|
+
currentScalar = currentScalar?.baseScalar;
|
|
35
|
+
}
|
|
36
|
+
if (!currentScalar) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return this.#typeEmitOptions.get(currentScalar);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
[getOverrideForTypeKindSym](program, typeKind) {
|
|
46
|
+
return this.#typeKindEmitOptions.get(typeKind);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function getOverrideForType(program, type, options) {
|
|
50
|
+
return options?.[getOverrideForTypeSym](program, type);
|
|
51
|
+
}
|
|
52
|
+
export function getOverridesForTypeKind(program, typeKind, options) {
|
|
53
|
+
return options?.[getOverrideForTypeKindSym](program, typeKind);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["$","getOverrideForTypeSym","Symbol","for","getOverrideForTypeKindSym","Experimental_ComponentOverridesConfig","Experimental_ComponentOverridesClass","typeEmitOptions","Map","typeKindEmitOptions","forType","type","options","set","forTypeKind","typeKind","program","get","scalar","is","currentScalar","has","baseScalar","undefined","getOverrideForType","getOverridesForTypeKind"],"sources":["../../../../../src/core/components/overrides/config.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,CAAC,QAAQ,4BAA4B;AAG9C,MAAMC,qBAAoC,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;AACnF,MAAMC,yBAAwC,GA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EAAED,QAAsB,EAAE;IACpE,OAAO,IAAI,CAAC,CAACN,mBAAmB,CAACQ,GAAG,CAACF,QAAQ,CAAC;EAChD;AACF;AAEA,OAAO,SAASS,kBAAkBA,CAChCR,OAAgB,EAChBL,IAAU,EACVC,OAA+C,EAC/C;EACA,OAAOA,OAAO,GAAGX,qBAAqB,CAAC,CAACe,OAAO,EAAEL,IAAI,CAAC;AACxD;AAEA,OAAO,SAASc,uBAAuBA,CACrCT,OAAgB,EAChBD,QAAsB,EACtBH,OAA+C,EAC/C;EACA,OAAOA,OAAO,GAAGR,yBAAyB,CAAC,CAACY,OAAO,EAAED,QAAQ,CAAC;AAChE","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import type { Experimental_ComponentOverridesConfig } from "./config.js";
|
|
3
|
+
export interface ComponentOverridesContext {
|
|
4
|
+
overrides?: Experimental_ComponentOverridesConfig;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Context for setting overrides for components
|
|
8
|
+
*/
|
|
9
|
+
export declare const OverridesContext: ComponentContext<ComponentOverridesContext>;
|
|
10
|
+
export declare function useOverrides(): ComponentOverridesContext;
|
|
11
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/overrides/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,aAAa,CAAC;AAEzE,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,EAAE,qCAAqC,CAAC;CACnD;AACD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,CAAC,yBAAyB,CAAqB,CAAC;AAE/F,wBAAgB,YAAY,IAAI,yBAAyB,CAExD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Context for setting overrides for components
|
|
4
|
+
*/
|
|
5
|
+
export const OverridesContext = createContext({});
|
|
6
|
+
export function useOverrides() {
|
|
7
|
+
return useContext(OverridesContext);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","OverridesContext","useOverrides"],"sources":["../../../../../src/core/components/overrides/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAA+B,gBAAgB;AAMjF;AACA;AACA;AACA,OAAO,MAAMC,gBAA6D,GAAGF,aAAa,CAAC,CAAC,CAAC,CAAC;AAE9F,OAAO,SAASG,YAAYA,CAAA,EAA8B;EACxD,OAAOF,UAAU,CAACC,gBAAgB,CAAC;AACrC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/core/context/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createNamedContext","useContext","TransformNamePolicyContext","getApplicationName","type","name","getTransportName","useTransformNamePolicy"],"sources":["../../../../src/core/context/name-policy-context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAgCA,kBAAkB,EAAEC,UAAU,QAAQ,gBAAgB;AAGtF,OAAO,MAAMC,0BAAiE,GAC5EF,kBAAkB,CAAsB,qBAAqB,EAAE;EAC7DG,kBAAkBA,CAACC,IAAI,EAAE;IACvB,OAAO,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,GAAGD,IAAI,CAACC,IAAI,GAAG,EAAE;EACvD,CAAC;EACDC,gBAAgBA,CAACF,IAAI,EAAE;IACrB,OAAO,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,GAAGD,IAAI,CAACC,IAAI,GAAG,EAAE;EACvD;AACF,CAAC,CAAC;AAEJ,OAAO,SAASE,sBAAsBA,CAAA,EAAG;EACvC,OAAON,UAAU,CAACC,0BAA0B,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createNamedContext","useContext","$","TspContext","useTsp","context","Error","program"],"sources":["../../../../src/core/context/tsp-context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAgCA,kBAAkB,EAAEC,UAAU,QAAQ,gBAAgB;AAEtF,SAASC,CAAC,QAAsB,4BAA4B;AAO5D,OAAO,MAAMC,UAA+D,GAAGH,kBAAkB,CAG9F,YAAY,CAAC;AAEhB,OAAO,SAASI,MAAMA,CAAA,EAAG;EACvB,MAAMC,OAAO,GAAGJ,UAAU,CAACE,UAAU,CAAE;EAEvC,IAAI,CAACE,OAAO,EAAE;IACZ,MAAM,IAAIC,KAAK,CACb,6HACF,CAAC;EACH;EAEA,IAAI,CAACD,OAAO,CAACH,CAAC,EAAE;IACdG,OAAO,CAACH,CAAC,GAAGA,CAAC,CAACG,OAAO,CAACE,OAAO,CAAC;EAChC;EAEA,OAAOF,OAAO;AAChB","ignoreList":[]}
|
package/dist/src/core/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/core/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTransformNamePolicy","namer","getTransportName","type","transportNamer","getApplicationName","applicationNamer"],"sources":["../../../src/core/transport-name-policy.ts"],"sourcesContent":[null],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,yBAAyBA,CAACC,KAGzC,EAAuB;EACtB,OAAO;IACL;AACJ;AACA;AACA;AACA;AACA;IACIC,gBAAgBA,CAACC,IAAI,EAAE;MACrB,OAAOF,KAAK,CAACG,cAAc,CAACD,IAAI,CAAC;IACnC,CAAC;IAED;AACJ;AACA;AACA;AACA;AACA;IACIE,kBAAkBA,CAACF,IAAI,EAAE;MACvB,OAAOF,KAAK,CAACK,gBAAgB,CAACH,IAAI,CAAC;IACrC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAwB,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,MAAM,iBAIzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { renderAsync } from "@alloy-js/core";
|
|
2
2
|
import { emitFile, joinPaths } from "@typespec/compiler";
|
|
3
3
|
export async function writeOutput(program, rootComponent, emitterOutputDir) {
|
|
4
|
-
const tree =
|
|
4
|
+
const tree = await renderAsync(rootComponent);
|
|
5
5
|
await writeOutputDirectory(program, tree, emitterOutputDir);
|
|
6
6
|
}
|
|
7
7
|
async function writeOutputDirectory(program, dir, emitterOutputDir) {
|
|
@@ -19,4 +19,5 @@ async function writeOutputDirectory(program, dir, emitterOutputDir) {
|
|
|
19
19
|
// TODO: support copy file
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=write-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["renderAsync","emitFile","joinPaths","writeOutput","program","rootComponent","emitterOutputDir","tree","writeOutputDirectory","dir","sub","contents","Array","isArray","content","path"],"sources":["../../../src/core/write-output.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAA6C,gBAAgB;AACjF,SAASC,QAAQ,EAAEC,SAAS,QAAsB,oBAAoB;AAEtE,OAAO,eAAeC,WAAWA,CAC/BC,OAAgB,EAChBC,aAAuB,EACvBC,gBAAwB,EACxB;EACA,MAAMC,IAAI,GAAG,MAAMP,WAAW,CAACK,aAAa,CAAC;EAC7C,MAAMG,oBAAoB,CAACJ,OAAO,EAAEG,IAAI,EAAED,gBAAgB,CAAC;AAC7D;AAEA,eAAeE,oBAAoBA,CACjCJ,OAAgB,EAChBK,GAAoB,EACpBH,gBAAwB,EACxB;EACA,KAAK,MAAMI,GAAG,IAAID,GAAG,CAACE,QAAQ,EAAE;IAC9B,IAAI,UAAU,IAAID,GAAG,EAAE;MACrB,IAAIE,KAAK,CAACC,OAAO,CAACH,GAAG,CAACC,QAAQ,CAAC,EAAE;QAC/B,MAAMH,oBAAoB,CAACJ,OAAO,EAAEM,GAAG,EAAqBJ,gBAAgB,CAAC;MAC/E,CAAC,MAAM;QACL,MAAML,QAAQ,CAACG,OAAO,EAAE;UACtBU,OAAO,EAAEJ,GAAG,CAACC,QAAkB;UAC/BI,IAAI,EAAEb,SAAS,CAACI,gBAAgB,EAAEI,GAAG,CAACK,IAAI;QAC5C,CAAC,CAAC;MACJ;IACF,CAAC,MAAM;MACL;IAAA;EAEJ;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import * as cs from "@alloy-js/csharp";
|
|
3
|
-
import type
|
|
3
|
+
import { type Interface, type Model } from "@typespec/compiler";
|
|
4
4
|
export interface ClassDeclarationProps extends Omit<cs.ClassDeclarationProps, "name"> {
|
|
5
5
|
/** Set an alternative name for the class. Otherwise default to the type name. */
|
|
6
6
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO5E,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACnF,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAYD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CA6BvE"}
|
|
@@ -2,6 +2,7 @@ import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$create
|
|
|
2
2
|
import { For } from "@alloy-js/core";
|
|
3
3
|
import * as cs from "@alloy-js/csharp";
|
|
4
4
|
import { Method } from "@alloy-js/csharp";
|
|
5
|
+
import { isVoidType } from "@typespec/compiler";
|
|
5
6
|
import { useTsp } from "../../../core/index.js";
|
|
6
7
|
import { Property } from "../property/property.js";
|
|
7
8
|
import { TypeExpression } from "../type-expression.js";
|
|
@@ -18,6 +19,13 @@ export function ClassDeclaration(props) {
|
|
|
18
19
|
return [_$createComponent(cs.ClassDeclaration, _$mergeProps(props, {
|
|
19
20
|
name: className,
|
|
20
21
|
refkey: refkeys,
|
|
22
|
+
get baseType() {
|
|
23
|
+
return props.baseType ?? (props.type.kind === "Model" && props.type.baseModel ? _$createComponent(TypeExpression, {
|
|
24
|
+
get type() {
|
|
25
|
+
return props.type.baseModel;
|
|
26
|
+
}
|
|
27
|
+
}) : undefined);
|
|
28
|
+
},
|
|
21
29
|
get doc() {
|
|
22
30
|
return getDocComments($, props.type);
|
|
23
31
|
},
|
|
@@ -38,11 +46,11 @@ export function ClassDeclaration(props) {
|
|
|
38
46
|
}))];
|
|
39
47
|
}
|
|
40
48
|
function ClassProperties(props) {
|
|
49
|
+
// Ignore 'void' type properties which is not valid in csharp
|
|
50
|
+
const properties = Array.from(props.type.properties.entries()).filter(([_, p]) => !isVoidType(p.type));
|
|
41
51
|
return _$createComponent(For, {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
hardline: true,
|
|
52
|
+
each: properties,
|
|
53
|
+
doubleHardline: true,
|
|
46
54
|
children: ([name, property]) => _$createComponent(Property, {
|
|
47
55
|
type: property,
|
|
48
56
|
get jsonAttributes() {
|
|
@@ -89,4 +97,5 @@ function ClassMethods(props) {
|
|
|
89
97
|
}));
|
|
90
98
|
}
|
|
91
99
|
return [abstractMethods];
|
|
92
|
-
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["For","cs","Method","isVoidType","useTsp","Property","TypeExpression","getDocComments","declarationRefkeys","ClassDeclaration","props","$","namePolicy","useCSharpNamePolicy","className","name","getName","type","refkeys","refkey","_$createComponent","_$mergeProps","baseType","kind","baseModel","undefined","doc","children","_$memo","ClassProperties","jsonAttributes","ClassMethods","properties","Array","from","entries","filter","_","p","each","doubleHardline","property","abstractMethods","method","operations","push","abstract","parameters","map","prop","returns","returnType"],"sources":["../../../../../src/csharp/components/class/declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,QAAuB,gBAAgB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