@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.
Files changed (212) hide show
  1. package/dist/src/core/components/index.d.ts +2 -0
  2. package/dist/src/core/components/index.d.ts.map +1 -1
  3. package/dist/src/core/components/index.js +4 -1
  4. package/dist/src/core/components/index.js.map +1 -0
  5. package/dist/src/core/components/output.js +2 -1
  6. package/dist/src/core/components/output.js.map +1 -0
  7. package/dist/src/core/components/overrides/component-overrides.d.ts +64 -0
  8. package/dist/src/core/components/overrides/component-overrides.d.ts.map +1 -0
  9. package/dist/src/core/components/overrides/component-overrides.js +41 -0
  10. package/dist/src/core/components/overrides/component-overrides.js.map +1 -0
  11. package/dist/src/core/components/overrides/config.d.ts +28 -0
  12. package/dist/src/core/components/overrides/config.d.ts.map +1 -0
  13. package/dist/src/core/components/overrides/config.js +55 -0
  14. package/dist/src/core/components/overrides/config.js.map +1 -0
  15. package/dist/src/core/components/overrides/context.d.ts +11 -0
  16. package/dist/src/core/components/overrides/context.d.ts.map +1 -0
  17. package/dist/src/core/components/overrides/context.js +9 -0
  18. package/dist/src/core/components/overrides/context.js.map +1 -0
  19. package/dist/src/core/context/index.js +2 -1
  20. package/dist/src/core/context/index.js.map +1 -0
  21. package/dist/src/core/context/name-policy-context.js +2 -1
  22. package/dist/src/core/context/name-policy-context.js.map +1 -0
  23. package/dist/src/core/context/tsp-context.js +2 -1
  24. package/dist/src/core/context/tsp-context.js.map +1 -0
  25. package/dist/src/core/index.js +2 -1
  26. package/dist/src/core/index.js.map +1 -0
  27. package/dist/src/core/transport-name-policy.js +2 -1
  28. package/dist/src/core/transport-name-policy.js.map +1 -0
  29. package/dist/src/core/write-output.d.ts.map +1 -1
  30. package/dist/src/core/write-output.js +4 -3
  31. package/dist/src/core/write-output.js.map +1 -0
  32. package/dist/src/csharp/components/class/declaration.d.ts +1 -1
  33. package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
  34. package/dist/src/csharp/components/class/declaration.js +14 -5
  35. package/dist/src/csharp/components/class/declaration.js.map +1 -0
  36. package/dist/src/csharp/components/class/declaration.test.js +125 -92
  37. package/dist/src/csharp/components/class/declaration.test.js.map +1 -0
  38. package/dist/src/csharp/components/enum/declaration.js +2 -1
  39. package/dist/src/csharp/components/enum/declaration.js.map +1 -0
  40. package/dist/src/csharp/components/enum/declaration.test.js +52 -88
  41. package/dist/src/csharp/components/enum/declaration.test.js.map +1 -0
  42. package/dist/src/csharp/components/index.js +2 -1
  43. package/dist/src/csharp/components/index.js.map +1 -0
  44. package/dist/src/csharp/components/property/property.d.ts.map +1 -1
  45. package/dist/src/csharp/components/property/property.js +40 -14
  46. package/dist/src/csharp/components/property/property.js.map +1 -0
  47. package/dist/src/csharp/components/property/property.test.js +129 -29
  48. package/dist/src/csharp/components/property/property.test.js.map +1 -0
  49. package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
  50. package/dist/src/csharp/components/type-expression.js +34 -6
  51. package/dist/src/csharp/components/type-expression.js.map +1 -0
  52. package/dist/src/csharp/components/type-expression.test.js +87 -54
  53. package/dist/src/csharp/components/type-expression.test.js.map +1 -0
  54. package/dist/src/csharp/components/utils/doc-comments.js +2 -1
  55. package/dist/src/csharp/components/utils/doc-comments.js.map +1 -0
  56. package/dist/src/csharp/components/utils/nullable-util.d.ts +4 -0
  57. package/dist/src/csharp/components/utils/nullable-util.d.ts.map +1 -0
  58. package/dist/src/csharp/components/utils/nullable-util.js +27 -0
  59. package/dist/src/csharp/components/utils/nullable-util.js.map +1 -0
  60. package/dist/src/csharp/components/utils/refkey.js +2 -1
  61. package/dist/src/csharp/components/utils/refkey.js.map +1 -0
  62. package/dist/src/csharp/index.js +2 -1
  63. package/dist/src/csharp/index.js.map +1 -0
  64. package/dist/src/lib.js +2 -1
  65. package/dist/src/lib.js.map +1 -0
  66. package/dist/src/testing/index.js +2 -1
  67. package/dist/src/testing/index.js.map +1 -0
  68. package/dist/src/testing/scenario-test/code-block-expectation.js +2 -1
  69. package/dist/src/testing/scenario-test/code-block-expectation.js.map +1 -0
  70. package/dist/src/testing/scenario-test/code-block-expectation.test.js +2 -1
  71. package/dist/src/testing/scenario-test/code-block-expectation.test.js.map +1 -0
  72. package/dist/src/testing/scenario-test/harness.js +8 -2
  73. package/dist/src/testing/scenario-test/harness.js.map +1 -0
  74. package/dist/src/testing/scenario-test/index.js +2 -1
  75. package/dist/src/testing/scenario-test/index.js.map +1 -0
  76. package/dist/src/testing/scenario-test/snippet-extractor.js +2 -1
  77. package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
  78. package/dist/src/typescript/components/array-expression.js +2 -1
  79. package/dist/src/typescript/components/array-expression.js.map +1 -0
  80. package/dist/src/typescript/components/arrow-function.js +2 -1
  81. package/dist/src/typescript/components/arrow-function.js.map +1 -0
  82. package/dist/src/typescript/components/class-method.js +2 -1
  83. package/dist/src/typescript/components/class-method.js.map +1 -0
  84. package/dist/src/typescript/components/enum-declaration.js +2 -1
  85. package/dist/src/typescript/components/enum-declaration.js.map +1 -0
  86. package/dist/src/typescript/components/function-declaration.js +2 -1
  87. package/dist/src/typescript/components/function-declaration.js.map +1 -0
  88. package/dist/src/typescript/components/function-expression.js +2 -1
  89. package/dist/src/typescript/components/function-expression.js.map +1 -0
  90. package/dist/src/typescript/components/function-type.js +2 -1
  91. package/dist/src/typescript/components/function-type.js.map +1 -0
  92. package/dist/src/typescript/components/index.js +2 -1
  93. package/dist/src/typescript/components/index.js.map +1 -0
  94. package/dist/src/typescript/components/interface-declaration.js +2 -1
  95. package/dist/src/typescript/components/interface-declaration.js.map +1 -0
  96. package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
  97. package/dist/src/typescript/components/interface-member.js +13 -20
  98. package/dist/src/typescript/components/interface-member.js.map +1 -0
  99. package/dist/src/typescript/components/interface-method.js +2 -1
  100. package/dist/src/typescript/components/interface-method.js.map +1 -0
  101. package/dist/src/typescript/components/record-expression.js +2 -1
  102. package/dist/src/typescript/components/record-expression.js.map +1 -0
  103. package/dist/src/typescript/components/static-serializers.js +2 -1
  104. package/dist/src/typescript/components/static-serializers.js.map +1 -0
  105. package/dist/src/typescript/components/type-alias-declaration.js +2 -1
  106. package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
  107. package/dist/src/typescript/components/type-declaration.js +2 -1
  108. package/dist/src/typescript/components/type-declaration.js.map +1 -0
  109. package/dist/src/typescript/components/type-expression.d.ts +0 -1
  110. package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
  111. package/dist/src/typescript/components/type-expression.js +13 -12
  112. package/dist/src/typescript/components/type-expression.js.map +1 -0
  113. package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
  114. package/dist/src/typescript/components/type-transform.js +5 -4
  115. package/dist/src/typescript/components/type-transform.js.map +1 -0
  116. package/dist/src/typescript/components/union/declaration.js +2 -1
  117. package/dist/src/typescript/components/union/declaration.js.map +1 -0
  118. package/dist/src/typescript/components/union/declaration.test.js +2 -1
  119. package/dist/src/typescript/components/union/declaration.test.js.map +1 -0
  120. package/dist/src/typescript/components/union/expression.js +2 -1
  121. package/dist/src/typescript/components/union/expression.js.map +1 -0
  122. package/dist/src/typescript/components/union/expression.test.js +2 -1
  123. package/dist/src/typescript/components/union/expression.test.js.map +1 -0
  124. package/dist/src/typescript/components/value-expression.js +2 -1
  125. package/dist/src/typescript/components/value-expression.js.map +1 -0
  126. package/dist/src/typescript/index.js +2 -1
  127. package/dist/src/typescript/index.js.map +1 -0
  128. package/dist/src/typescript/lib.js +2 -1
  129. package/dist/src/typescript/lib.js.map +1 -0
  130. package/dist/src/typescript/utils/index.js +2 -1
  131. package/dist/src/typescript/utils/index.js.map +1 -0
  132. package/dist/src/typescript/utils/operation.js +2 -1
  133. package/dist/src/typescript/utils/operation.js.map +1 -0
  134. package/dist/src/typescript/utils/refkey.js +2 -1
  135. package/dist/src/typescript/utils/refkey.js.map +1 -0
  136. package/dist/test/test-host.js +2 -1
  137. package/dist/test/test-host.js.map +1 -0
  138. package/dist/test/testing/snippet-extractor-csharp.test.js +2 -1
  139. package/dist/test/testing/snippet-extractor-csharp.test.js.map +1 -0
  140. package/dist/test/testing/snippet-extractor-java.test.js +2 -1
  141. package/dist/test/testing/snippet-extractor-java.test.js.map +1 -0
  142. package/dist/test/testing/snippet-extractor-python.test.js +2 -1
  143. package/dist/test/testing/snippet-extractor-python.test.js.map +1 -0
  144. package/dist/test/testing/snippet-extractor-typescript.test.js +2 -1
  145. package/dist/test/testing/snippet-extractor-typescript.test.js.map +1 -0
  146. package/dist/test/typescript/components/arrow-function.test.js +18 -22
  147. package/dist/test/typescript/components/arrow-function.test.js.map +1 -0
  148. package/dist/test/typescript/components/component-override.test.d.ts +2 -0
  149. package/dist/test/typescript/components/component-override.test.d.ts.map +1 -0
  150. package/dist/test/typescript/components/component-override.test.js +78 -0
  151. package/dist/test/typescript/components/component-override.test.js.map +1 -0
  152. package/dist/test/typescript/components/enum-declaration.test.js +2 -1
  153. package/dist/test/typescript/components/enum-declaration.test.js.map +1 -0
  154. package/dist/test/typescript/components/function-declaration.test.js +3 -2
  155. package/dist/test/typescript/components/function-declaration.test.js.map +1 -0
  156. package/dist/test/typescript/components/function-expression.test.js +18 -22
  157. package/dist/test/typescript/components/function-expression.test.js.map +1 -0
  158. package/dist/test/typescript/components/function-type.test.js +18 -22
  159. package/dist/test/typescript/components/function-type.test.js.map +1 -0
  160. package/dist/test/typescript/components/interface-declaration.test.js +3 -2
  161. package/dist/test/typescript/components/interface-declaration.test.js.map +1 -0
  162. package/dist/test/typescript/components/interface-method.test.js +37 -45
  163. package/dist/test/typescript/components/interface-method.test.js.map +1 -0
  164. package/dist/test/typescript/components/member-expression.test.js +2 -1
  165. package/dist/test/typescript/components/member-expression.test.js.map +1 -0
  166. package/dist/test/typescript/components/type-alias-declaration.test.js +8 -5
  167. package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -0
  168. package/dist/test/typescript/components/type-transform.test.js +29 -27
  169. package/dist/test/typescript/components/type-transform.test.js.map +1 -0
  170. package/dist/test/typescript/components/value-expression.test.js +3 -2
  171. package/dist/test/typescript/components/value-expression.test.js.map +1 -0
  172. package/dist/test/typescript/utils.js +2 -1
  173. package/dist/test/typescript/utils.js.map +1 -0
  174. package/dist/test/utils.d.ts +1 -0
  175. package/dist/test/utils.d.ts.map +1 -1
  176. package/dist/test/utils.js +13 -3
  177. package/dist/test/utils.js.map +1 -0
  178. package/dist/test/vitest.setup.js +2 -1
  179. package/dist/test/vitest.setup.js.map +1 -0
  180. package/package.json +9 -13
  181. package/src/core/components/index.tsx +2 -0
  182. package/src/core/components/overrides/component-overrides.tsx +134 -0
  183. package/src/core/components/overrides/config.ts +85 -0
  184. package/src/core/components/overrides/context.ts +14 -0
  185. package/src/core/write-output.ts +2 -2
  186. package/src/csharp/components/class/declaration.test.tsx +114 -88
  187. package/src/csharp/components/class/declaration.tsx +13 -3
  188. package/src/csharp/components/enum/declaration.test.tsx +47 -78
  189. package/src/csharp/components/property/property.test.tsx +108 -25
  190. package/src/csharp/components/property/property.tsx +43 -11
  191. package/src/csharp/components/type-expression.test.tsx +84 -69
  192. package/src/csharp/components/type-expression.tsx +31 -5
  193. package/src/csharp/components/utils/nullable-util.ts +25 -0
  194. package/src/testing/scenario-test/harness.ts +6 -1
  195. package/src/typescript/components/interface-member.tsx +8 -14
  196. package/src/typescript/components/type-expression.tsx +7 -8
  197. package/src/typescript/components/type-transform.tsx +3 -7
  198. package/test/typescript/components/arrow-function.test.tsx +23 -42
  199. package/test/typescript/components/component-override.test.tsx +71 -0
  200. package/test/typescript/components/function-declaration.test.tsx +2 -1
  201. package/test/typescript/components/function-expression.test.tsx +23 -42
  202. package/test/typescript/components/function-type.test.tsx +22 -40
  203. package/test/typescript/components/interface-declaration.test.tsx +1 -1
  204. package/test/typescript/components/interface-method.test.tsx +50 -92
  205. package/test/typescript/components/type-alias-declaration.test.tsx +8 -6
  206. package/test/typescript/components/type-transform.test.tsx +37 -37
  207. package/test/typescript/components/value-expression.test.tsx +1 -1
  208. package/test/utils.ts +10 -3
  209. package/dist/test/typescript/test-host.d.ts +0 -16
  210. package/dist/test/typescript/test-host.d.ts.map +0 -1
  211. package/dist/test/typescript/test-host.js +0 -40
  212. package/test/typescript/test-host.ts +0 -49
@@ -1,2 +1,4 @@
1
1
  export * from "./output.jsx";
2
+ export * from "./overrides/component-overrides.jsx";
3
+ export * from "./overrides/config.js";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -1 +1,4 @@
1
- export * from "./output.js";
1
+ export * from "./output.js";
2
+ export * from "./overrides/component-overrides.js";
3
+ export * from "./overrides/config.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../src/core/components/index.tsx"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA,cAAc,uBAAuB","ignoreList":[]}
@@ -13,4 +13,5 @@ export function Output(props) {
13
13
  return _$createComponent(CoreOutput, rest);
14
14
  }
15
15
  });
16
- }
16
+ }
17
+ //# sourceMappingURL=output.js.map
@@ -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,aA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,CAAC,WAAW,CAAC,CAAC;CAClE;AAED,MAAM,WAAW,oCAAoC;IACnD,SAAS,EAAE,qCAAqC,CAAC;IACjD,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,YAM1F;AAED,MAAM,WAAW,6CAA6C,CAAC,CAAC,SAAS,IAAI;IAC3E;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,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,GAAGF,MAAM,CAACC,GAAG,CAAC,8BAA8B,CAAC;AAG3F,OAAO,MAAME,qCAAqC,GAAG,SAAAA,CAAA,EAAY;EAC/D,OAAO,IAAIC,oCAAoC,CAAC,CAAC;AACnD,CAGC;AAED,OAAO,MAAMA,oCAAoC,CAAC;EAChD,CAACC,eAAe,GAA8D,IAAIC,GAAG,CAAC,CAAC;EACvF,CAACC,mBAAmB,GAClB,IAAID,GAAG,CAAC,CAAC;EAEXE,OAAOA,CAAuBC,IAAO,EAAEC,OAAqD,EAAE;IAC5F,IAAI,CAAC,CAACL,eAAe,CAACM,GAAG,CAACF,IAAI,EAAEC,OAAO,CAAC;IAExC,OAAO,IAAI;EACb;EAEAE,WAAWA,CACTC,QAAe,EACfH,OAAkF,EAClF;IACA,IAAI,CAAC,CAACH,mBAAmB,CAACI,GAAG,CAACE,QAAQ,EAAEH,OAAO,CAAC;IAEhD,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,CAACX,qBAAqB,EAAEe,OAAgB,EAAEL,IAAU,EAAE;IACpD,MAAMC,OAAO,GAAG,IAAI,CAAC,CAACL,eAAe,CAACU,GAAG,CAACN,IAAI,CAAC;IAC/C,IAAIC,OAAO,IAAI,CAACZ,CAAC,CAACgB,OAAO,CAAC,CAACE,MAAM,CAACC,EAAE,CAACR,IAAI,CAAC,CAAC,oCAAoC;MAC7E,OAAOC,OAAO;IAChB;;IAEA;IACA;IACA,IAAIQ,aAAiC,GAAGT,IAAI;IAC5C,OACES,aAAa;IACb;IACA,CAAC,IAAI,CAAC,CAACb,eAAe,CAACc,GAAG,CAACD,aAAa,CAAC,EACzC;MACAA,aAAa,GAAGA,aAAa,EAAEE,UAAU;IAC3C;IAEA,IAAI,CAACF,aAAa,EAAE;MAClB,OAAOG,SAAS;IAClB;IAEA,OAAO,IAAI,CAAC,CAAChB,eAAe,CAACU,GAAG,CAACG,aAAa,CAAC;EACjD;;EAEA;AACF;AACA;EACE,CAAChB,yBAAyB,EAAEY,OAAgB,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":[]}
@@ -1,2 +1,3 @@
1
1
  export * from "./name-policy-context.js";
2
- export * from "./tsp-context.js";
2
+ export * from "./tsp-context.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../src/core/context/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,kBAAkB","ignoreList":[]}
@@ -9,4 +9,5 @@ export const TransformNamePolicyContext = createNamedContext("TransfromNamePolic
9
9
  });
10
10
  export function useTransformNamePolicy() {
11
11
  return useContext(TransformNamePolicyContext);
12
- }
12
+ }
13
+ //# sourceMappingURL=name-policy-context.js.map
@@ -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":[]}
@@ -10,4 +10,5 @@ export function useTsp() {
10
10
  context.$ = $(context.program);
11
11
  }
12
12
  return context;
13
- }
13
+ }
14
+ //# sourceMappingURL=tsp-context.js.map
@@ -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":[]}
@@ -1,4 +1,5 @@
1
1
  export * from "./components/index.js";
2
2
  export * from "./context/index.js";
3
3
  export * from "./transport-name-policy.js";
4
- export * from "./write-output.js";
4
+ export * from "./write-output.js";
5
+ //# sourceMappingURL=index.js.map
@@ -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":[]}
@@ -38,4 +38,5 @@ export function createTransformNamePolicy(namer) {
38
38
  return namer.applicationNamer(type);
39
39
  }
40
40
  };
41
- }
41
+ }
42
+ //# sourceMappingURL=transport-name-policy.js.map
@@ -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,EAAE,KAAK,QAAQ,EAAgC,MAAM,gBAAgB,CAAC;AAC7E,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
+ {"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 { render } from "@alloy-js/core";
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 = render(rootComponent);
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 { Interface, Model } from "@typespec/compiler";
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,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO3D,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,CAuBvE"}
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
- get each() {
43
- return props.type.properties.entries();
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;AACnD,OAAO,KAAKC,EAAE,MAAM,kBA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