@typespec/emitter-framework 0.15.0-dev.2 → 0.15.0-dev.4
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/CHANGELOG.md +1 -16
- package/dist/src/core/components/overrides/component-overrides.d.ts.map +1 -1
- package/dist/src/core/components/overrides/component-overrides.js.map +1 -1
- package/dist/src/python/builtins.d.ts +14 -0
- package/dist/src/python/builtins.d.ts.map +1 -0
- package/dist/src/python/builtins.js +29 -0
- package/dist/src/python/builtins.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts +6 -0
- package/dist/src/python/components/array-expression/array-expression.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.js +11 -0
- package/dist/src/python/components/array-expression/array-expression.js.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts +2 -0
- package/dist/src/python/components/array-expression/array-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/array-expression.test.js +19 -0
- package/dist/src/python/components/array-expression/array-expression.test.js.map +1 -0
- package/dist/src/python/components/array-expression/index.d.ts +2 -0
- package/dist/src/python/components/array-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/array-expression/index.js +2 -0
- package/dist/src/python/components/array-expression/index.js.map +1 -0
- package/dist/src/python/components/atom/atom.d.ts +33 -0
- package/dist/src/python/components/atom/atom.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.js +88 -0
- package/dist/src/python/components/atom/atom.js.map +1 -0
- package/dist/src/python/components/atom/atom.test.d.ts +2 -0
- package/dist/src/python/components/atom/atom.test.d.ts.map +1 -0
- package/dist/src/python/components/atom/atom.test.js +224 -0
- package/dist/src/python/components/atom/atom.test.js.map +1 -0
- package/dist/src/python/components/atom/index.d.ts +2 -0
- package/dist/src/python/components/atom/index.d.ts.map +1 -0
- package/dist/src/python/components/atom/index.js +2 -0
- package/dist/src/python/components/atom/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts +45 -0
- package/dist/src/python/components/class-declaration/class-bases.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-bases.js +84 -0
- package/dist/src/python/components/class-declaration/class-bases.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-body.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-body.js +52 -0
- package/dist/src/python/components/class-declaration/class-body.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts +23 -0
- package/dist/src/python/components/class-declaration/class-declaration.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.js +118 -0
- package/dist/src/python/components/class-declaration/class-declaration.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js +1527 -0
- package/dist/src/python/components/class-declaration/class-declaration.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts +16 -0
- package/dist/src/python/components/class-declaration/class-member.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.js +71 -0
- package/dist/src/python/components/class-declaration/class-member.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-member.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-member.test.js +202 -0
- package/dist/src/python/components/class-declaration/class-member.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts +22 -0
- package/dist/src/python/components/class-declaration/class-method.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.js +76 -0
- package/dist/src/python/components/class-declaration/class-method.js.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts +2 -0
- package/dist/src/python/components/class-declaration/class-method.test.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/class-method.test.js +298 -0
- package/dist/src/python/components/class-declaration/class-method.test.js.map +1 -0
- package/dist/src/python/components/class-declaration/index.d.ts +7 -0
- package/dist/src/python/components/class-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/index.js +7 -0
- package/dist/src/python/components/class-declaration/index.js.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts +22 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.d.ts.map +1 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js +67 -0
- package/dist/src/python/components/class-declaration/primitive-initializer.js.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts +46 -0
- package/dist/src/python/components/doc-element/doc-element.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/doc-element.js +59 -0
- package/dist/src/python/components/doc-element/doc-element.js.map +1 -0
- package/dist/src/python/components/doc-element/index.d.ts +2 -0
- package/dist/src/python/components/doc-element/index.d.ts.map +1 -0
- package/dist/src/python/components/doc-element/index.js +2 -0
- package/dist/src/python/components/doc-element/index.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts +8 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js +80 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts +2 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js +344 -0
- package/dist/src/python/components/enum-declaration/enum-declaration.test.js.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts +9 -0
- package/dist/src/python/components/enum-declaration/enum-member.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/enum-member.js +22 -0
- package/dist/src/python/components/enum-declaration/enum-member.js.map +1 -0
- package/dist/src/python/components/enum-declaration/index.d.ts +3 -0
- package/dist/src/python/components/enum-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/enum-declaration/index.js +3 -0
- package/dist/src/python/components/enum-declaration/index.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts +24 -0
- package/dist/src/python/components/function-declaration/function-declaration.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.js +68 -0
- package/dist/src/python/components/function-declaration/function-declaration.js.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts +2 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js +682 -0
- package/dist/src/python/components/function-declaration/function-declaration.test.js.map +1 -0
- package/dist/src/python/components/function-declaration/index.d.ts +2 -0
- package/dist/src/python/components/function-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/function-declaration/index.js +2 -0
- package/dist/src/python/components/function-declaration/index.js.map +1 -0
- package/dist/src/python/components/index.d.ts +12 -0
- package/dist/src/python/components/index.d.ts.map +1 -0
- package/dist/src/python/components/index.js +12 -0
- package/dist/src/python/components/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts +25 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js +33 -0
- package/dist/src/python/components/protocol-declaration/callable-parameters.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts +3 -0
- package/dist/src/python/components/protocol-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/index.js +3 -0
- package/dist/src/python/components/protocol-declaration/index.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts +8 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js +86 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.js.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts +2 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +117 -0
- package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js.map +1 -0
- package/dist/src/python/components/record-expression/index.d.ts +2 -0
- package/dist/src/python/components/record-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/index.js +2 -0
- package/dist/src/python/components/record-expression/index.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts +6 -0
- package/dist/src/python/components/record-expression/record-expression.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.js +13 -0
- package/dist/src/python/components/record-expression/record-expression.js.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts +2 -0
- package/dist/src/python/components/record-expression/record-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/record-expression/record-expression.test.js +19 -0
- package/dist/src/python/components/record-expression/record-expression.test.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/index.js +2 -0
- package/dist/src/python/components/type-alias-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts +16 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js +75 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +140 -0
- package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-declaration/index.d.ts +2 -0
- package/dist/src/python/components/type-declaration/index.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/index.js +2 -0
- package/dist/src/python/components/type-declaration/index.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts +11 -0
- package/dist/src/python/components/type-declaration/type-declaration.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.js +31 -0
- package/dist/src/python/components/type-declaration/type-declaration.js.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts +2 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.d.ts.map +1 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js +69 -0
- package/dist/src/python/components/type-declaration/type-declaration.test.js.map +1 -0
- package/dist/src/python/components/type-expression/index.d.ts +2 -0
- package/dist/src/python/components/type-expression/index.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/index.js +2 -0
- package/dist/src/python/components/type-expression/index.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts +12 -0
- package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.js +348 -0
- package/dist/src/python/components/type-expression/type-expression.js.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts +2 -0
- package/dist/src/python/components/type-expression/type-expression.test.d.ts.map +1 -0
- package/dist/src/python/components/type-expression/type-expression.test.js +503 -0
- package/dist/src/python/components/type-expression/type-expression.test.js.map +1 -0
- package/dist/src/python/index.d.ts +4 -0
- package/dist/src/python/index.d.ts.map +1 -0
- package/dist/src/python/index.js +4 -0
- package/dist/src/python/index.js.map +1 -0
- package/dist/src/python/lib.d.ts +68 -0
- package/dist/src/python/lib.d.ts.map +1 -0
- package/dist/src/python/lib.js +38 -0
- package/dist/src/python/lib.js.map +1 -0
- package/dist/src/python/test-utils.d.ts +8 -0
- package/dist/src/python/test-utils.d.ts.map +1 -0
- package/dist/src/python/test-utils.js +25 -0
- package/dist/src/python/test-utils.js.map +1 -0
- package/dist/src/python/utils/index.d.ts +4 -0
- package/dist/src/python/utils/index.d.ts.map +1 -0
- package/dist/src/python/utils/index.js +4 -0
- package/dist/src/python/utils/index.js.map +1 -0
- package/dist/src/python/utils/operation.d.ts +27 -0
- package/dist/src/python/utils/operation.d.ts.map +1 -0
- package/dist/src/python/utils/operation.js +139 -0
- package/dist/src/python/utils/operation.js.map +1 -0
- package/dist/src/python/utils/refkey.d.ts +23 -0
- package/dist/src/python/utils/refkey.d.ts.map +1 -0
- package/dist/src/python/utils/refkey.js +36 -0
- package/dist/src/python/utils/refkey.js.map +1 -0
- package/dist/src/python/utils/type.d.ts +19 -0
- package/dist/src/python/utils/type.d.ts.map +1 -0
- package/dist/src/python/utils/type.js +24 -0
- package/dist/src/python/utils/type.js.map +1 -0
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/function-declaration.js.map +1 -1
- package/package.json +12 -4
- package/package.json.bak +13 -4
- package/src/core/components/overrides/component-overrides.tsx +9 -6
- package/src/python/builtins.ts +43 -0
- package/src/python/components/array-expression/array-expression.test.tsx +14 -0
- package/src/python/components/array-expression/array-expression.tsx +11 -0
- package/src/python/components/array-expression/index.ts +1 -0
- package/src/python/components/atom/atom.test.tsx +244 -0
- package/src/python/components/atom/atom.tsx +95 -0
- package/src/python/components/atom/index.ts +1 -0
- package/src/python/components/class-declaration/class-bases.tsx +92 -0
- package/src/python/components/class-declaration/class-body.tsx +56 -0
- package/src/python/components/class-declaration/class-declaration.test.tsx +1414 -0
- package/src/python/components/class-declaration/class-declaration.tsx +116 -0
- package/src/python/components/class-declaration/class-member.test.tsx +194 -0
- package/src/python/components/class-declaration/class-member.tsx +67 -0
- package/src/python/components/class-declaration/class-method.test.tsx +250 -0
- package/src/python/components/class-declaration/class-method.tsx +97 -0
- package/src/python/components/class-declaration/index.ts +6 -0
- package/src/python/components/class-declaration/primitive-initializer.tsx +62 -0
- package/src/python/components/doc-element/doc-element.tsx +83 -0
- package/src/python/components/doc-element/index.ts +1 -0
- package/src/python/components/enum-declaration/enum-declaration.test.tsx +319 -0
- package/src/python/components/enum-declaration/enum-declaration.tsx +77 -0
- package/src/python/components/enum-declaration/enum-member.tsx +21 -0
- package/src/python/components/enum-declaration/index.ts +2 -0
- package/src/python/components/function-declaration/function-declaration.test.tsx +582 -0
- package/src/python/components/function-declaration/function-declaration.tsx +90 -0
- package/src/python/components/function-declaration/index.ts +1 -0
- package/src/python/components/index.ts +11 -0
- package/src/python/components/protocol-declaration/callable-parameters.tsx +44 -0
- package/src/python/components/protocol-declaration/index.ts +2 -0
- package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +106 -0
- package/src/python/components/protocol-declaration/protocol-declaration.tsx +73 -0
- package/src/python/components/record-expression/index.ts +1 -0
- package/src/python/components/record-expression/record-expression.test.tsx +14 -0
- package/src/python/components/record-expression/record-expression.tsx +13 -0
- package/src/python/components/type-alias-declaration/index.ts +1 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +117 -0
- package/src/python/components/type-alias-declaration/type-alias-declaration.tsx +67 -0
- package/src/python/components/type-declaration/index.ts +1 -0
- package/src/python/components/type-declaration/type-declaration.test.tsx +58 -0
- package/src/python/components/type-declaration/type-declaration.tsx +26 -0
- package/src/python/components/type-expression/index.ts +1 -0
- package/src/python/components/type-expression/type-expression.test.tsx +463 -0
- package/src/python/components/type-expression/type-expression.tsx +333 -0
- package/src/python/index.ts +3 -0
- package/src/python/lib.ts +40 -0
- package/src/python/test-utils.tsx +31 -0
- package/src/python/utils/index.ts +3 -0
- package/src/python/utils/operation.ts +161 -0
- package/src/python/utils/refkey.ts +36 -0
- package/src/python/utils/type.ts +31 -0
- package/src/typescript/components/function-declaration.tsx +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/atom/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../../src/python/components/atom/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import { type Interface, type Model } from "@typespec/compiler";
|
|
3
|
+
export interface ClassBasesProps {
|
|
4
|
+
/**
|
|
5
|
+
* The TypeSpec type to derive bases from. If not provided, only explicit bases are used.
|
|
6
|
+
*/
|
|
7
|
+
type?: Model | Interface;
|
|
8
|
+
/**
|
|
9
|
+
* Explicit base classes to include.
|
|
10
|
+
*/
|
|
11
|
+
bases?: Children[];
|
|
12
|
+
/**
|
|
13
|
+
* Whether the class is abstract. If true, ABC is added to the bases.
|
|
14
|
+
*/
|
|
15
|
+
abstract?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Additional bases to include (e.g., for future Generic[T] support).
|
|
18
|
+
*/
|
|
19
|
+
extraBases?: Children[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Computes the base classes for a Python class declaration.
|
|
23
|
+
*
|
|
24
|
+
* Combines:
|
|
25
|
+
* - Explicit bases from props
|
|
26
|
+
* - Type-derived bases (from TypeSpec model inheritance):
|
|
27
|
+
* - Template instances (e.g., `Response<string>` → `Response[str]`)
|
|
28
|
+
* - Regular models (e.g., `BaseWidget`) via py.Reference
|
|
29
|
+
* - Arrays via TypeExpression for `typing.Sequence[T]` rendering
|
|
30
|
+
* - Records are not supported and ignored
|
|
31
|
+
* - Extra bases (for future generics support)
|
|
32
|
+
* - ABC if abstract (always last for proper Python MRO)
|
|
33
|
+
*
|
|
34
|
+
* For interfaces, type-derived bases are empty because TypeSpec flattens interface inheritance.
|
|
35
|
+
*
|
|
36
|
+
* @returns Array of base class Children, or empty array if none.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const bases = ClassBases({ type: model, abstract: true });
|
|
41
|
+
* <py.ClassDeclaration bases={bases.length ? bases : undefined} />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function ClassBases(props: ClassBasesProps): Children[];
|
|
45
|
+
//# sourceMappingURL=class-bases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-bases.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/class-declaration/class-bases.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAmC,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAKjG,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,QAAQ,EAAE,CAsC7D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { abcModule } from "#python/builtins.js";
|
|
3
|
+
import * as py from "@alloy-js/python";
|
|
4
|
+
import { isTemplateDeclarationOrInstance } from "@typespec/compiler";
|
|
5
|
+
import { useTsp } from "../../../core/context/tsp-context.js";
|
|
6
|
+
import { efRefkey } from "../../utils/refkey.js";
|
|
7
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
8
|
+
/**
|
|
9
|
+
* Computes the base classes for a Python class declaration.
|
|
10
|
+
*
|
|
11
|
+
* Combines:
|
|
12
|
+
* - Explicit bases from props
|
|
13
|
+
* - Type-derived bases (from TypeSpec model inheritance):
|
|
14
|
+
* - Template instances (e.g., `Response<string>` → `Response[str]`)
|
|
15
|
+
* - Regular models (e.g., `BaseWidget`) via py.Reference
|
|
16
|
+
* - Arrays via TypeExpression for `typing.Sequence[T]` rendering
|
|
17
|
+
* - Records are not supported and ignored
|
|
18
|
+
* - Extra bases (for future generics support)
|
|
19
|
+
* - ABC if abstract (always last for proper Python MRO)
|
|
20
|
+
*
|
|
21
|
+
* For interfaces, type-derived bases are empty because TypeSpec flattens interface inheritance.
|
|
22
|
+
*
|
|
23
|
+
* @returns Array of base class Children, or empty array if none.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const bases = ClassBases({ type: model, abstract: true });
|
|
28
|
+
* <py.ClassDeclaration bases={bases.length ? bases : undefined} />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function ClassBases(props) {
|
|
32
|
+
const {
|
|
33
|
+
$
|
|
34
|
+
} = useTsp();
|
|
35
|
+
const extraBases = [...(props.extraBases ?? [])];
|
|
36
|
+
|
|
37
|
+
// Add extends/inheritance from the TypeSpec type if present
|
|
38
|
+
if (props.type && $.model.is(props.type)) {
|
|
39
|
+
const type = props.type;
|
|
40
|
+
if (type.baseModel) {
|
|
41
|
+
if ($.array.is(type.baseModel)) {
|
|
42
|
+
extraBases.push(_$createComponent(TypeExpression, {
|
|
43
|
+
get type() {
|
|
44
|
+
return type.baseModel;
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
} else if ($.record.is(type.baseModel)) {
|
|
48
|
+
// Record-based scenarios are not supported, do nothing here
|
|
49
|
+
} else if (isTemplateDeclarationOrInstance(type.baseModel)) {
|
|
50
|
+
// Template type (declaration or instance) - needs TypeExpression for type parameter handling
|
|
51
|
+
extraBases.push(_$createComponent(TypeExpression, {
|
|
52
|
+
get type() {
|
|
53
|
+
return type.baseModel;
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
} else {
|
|
57
|
+
// Regular model - use py.Reference for proper symbol resolution
|
|
58
|
+
extraBases.push(_$createComponent(py.Reference, {
|
|
59
|
+
get refkey() {
|
|
60
|
+
return efRefkey(type.baseModel);
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle index types: Arrays (int indexes) are supported, Records are not
|
|
67
|
+
const indexType = $.model.getIndexType(type);
|
|
68
|
+
if (indexType && !$.record.is(indexType)) {
|
|
69
|
+
extraBases.push(_$createComponent(TypeExpression, {
|
|
70
|
+
type: indexType
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Combine explicit bases from props with extraBases (Generic, extends, etc.)
|
|
76
|
+
const allBases = (props.bases ?? []).concat(extraBases);
|
|
77
|
+
|
|
78
|
+
// For abstract classes, always include ABC (last for proper MRO)
|
|
79
|
+
if (props.abstract) {
|
|
80
|
+
return [...allBases, abcModule["."]["ABC"]];
|
|
81
|
+
}
|
|
82
|
+
return allBases;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=class-bases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["abcModule","py","isTemplateDeclarationOrInstance","useTsp","efRefkey","TypeExpression","ClassBases","props","$","extraBases","type","model","is","baseModel","array","push","_$createComponent","record","Reference","refkey","indexType","getIndexType","allBases","bases","concat","abstract"],"sources":["../../../../../src/python/components/class-declaration/class-bases.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAE/C,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,SAASC,+BAA+B,QAAoC,oBAAoB;AAChG,SAASC,MAAM,QAAQ,sCAAsC;AAC7D,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,cAAc,QAAQ,uCAAuC;AAwBtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAc;EAC7D,MAAM;IAAEC;EAAE,CAAC,GAAGL,MAAM,CAAC,CAA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,IAAI,EAAEU;MAAS,EAAI,CAAC;IACtD;EACF;;EAEA;EACA,MAAME,QAAQ,GAAG,CAACf,KAAK,CAACgB,KAAK,IAAI,EAAE,EAAEC,MAAM,CAACf,UAAU,CAAC;;EAEvD;EACA,IAAIF,KAAK,CAACkB,QAAQ,EAAE;IAClB,OAAO,CAAC,GAAGH,QAAQ,EAAEtB,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;EAC7C;EAEA,OAAOsB,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import { type Interface, type Model } from "@typespec/compiler";
|
|
3
|
+
export interface ClassBodyProps {
|
|
4
|
+
type: Model | Interface;
|
|
5
|
+
abstract?: boolean;
|
|
6
|
+
methodType?: "method" | "class" | "static";
|
|
7
|
+
children?: Children;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders the body of a class declaration.
|
|
11
|
+
* For models, renders properties as dataclass fields.
|
|
12
|
+
* For interfaces, renders operations as abstract methods.
|
|
13
|
+
* Includes any additional children provided.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ClassBody(props: ClassBodyProps): Children;
|
|
16
|
+
//# sourceMappingURL=class-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-body.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/class-declaration/class-body.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAsC,MAAM,oBAAoB,CAAC;AAMpG,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC3C,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAeD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,QAAQ,CAsBzD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { For } from "@alloy-js/core";
|
|
3
|
+
import { createRekeyableMap } from "@typespec/compiler/utils";
|
|
4
|
+
import { useTsp } from "../../../core/context/tsp-context.js";
|
|
5
|
+
import { ClassMember } from "./class-member.js";
|
|
6
|
+
/**
|
|
7
|
+
* Gets type members (properties or operations) from a Model or Interface.
|
|
8
|
+
*/
|
|
9
|
+
function getTypeMembers($, type) {
|
|
10
|
+
if ($.model.is(type)) {
|
|
11
|
+
return Array.from($.model.getProperties(type).values());
|
|
12
|
+
} else if (type.kind === "Interface") {
|
|
13
|
+
return Array.from(createRekeyableMap(type.operations).values());
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error("Expected Model or Interface type");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Renders the body of a class declaration.
|
|
21
|
+
* For models, renders properties as dataclass fields.
|
|
22
|
+
* For interfaces, renders operations as abstract methods.
|
|
23
|
+
* Includes any additional children provided.
|
|
24
|
+
*/
|
|
25
|
+
export function ClassBody(props) {
|
|
26
|
+
const {
|
|
27
|
+
$
|
|
28
|
+
} = useTsp();
|
|
29
|
+
const typeMembers = getTypeMembers($, props.type);
|
|
30
|
+
|
|
31
|
+
// Throw error for models with additional properties (Record-based scenarios)
|
|
32
|
+
if ($.model.is(props.type)) {
|
|
33
|
+
const additionalPropsRecord = $.model.getAdditionalPropertiesRecord(props.type);
|
|
34
|
+
if (additionalPropsRecord) {
|
|
35
|
+
throw new Error("Models with additional properties (Record[…]) are not supported");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return [_$createComponent(For, {
|
|
39
|
+
each: typeMembers,
|
|
40
|
+
line: true,
|
|
41
|
+
children: typeMember => _$createComponent(ClassMember, {
|
|
42
|
+
type: typeMember,
|
|
43
|
+
get abstract() {
|
|
44
|
+
return props.abstract;
|
|
45
|
+
},
|
|
46
|
+
get methodType() {
|
|
47
|
+
return props.methodType;
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}), _$memo(() => props.children)];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=class-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["For","createRekeyableMap","useTsp","ClassMember","getTypeMembers","$","type","model","is","Array","from","getProperties","values","kind","operations","Error","ClassBody","props","typeMembers","additionalPropsRecord","getAdditionalPropertiesRecord","_$createComponent","each","line","children","typeMember","abstract","methodType","_$memo"],"sources":["../../../../../src/python/components/class-declaration/class-body.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,QAAuB,gBAAgB;AAGnD,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,MAAM,QAAQ,sCAAsC;AAC7D,SAASC,WAAW,QAAQ,mBAAmB;AAS/C;AACA;AACA;AACA,SAASC,cAAcA,CAACC,CAAU,EAAEC,IAAuB,EAAiC;EAC1F,IAAID,CAAC,CAACE,KAAK,CAACC,EAAE,CAACF,IAAI,CAAC,EAAE;IACpB,OAAOG,KAAK,CAACC,IAAI,CAACL,CAAC,CAACE,KAAK,CAACI,aAAa,CAACL,IAAI,CAAC,CAACM,MAAM,CAAC,CAAC,CAAC;EACzD,CAAC,MAAM,IAAIN,IAAI,CAACO,IAAI,KAAK,WAAW,EAAE;IACpC,OAAOJ,KAAK,CAACC,IAAI,CAACT,kBAAkB,CAACK,IAAI,CAACQ,UAAU,CAAC,CAACF,MAAM,CAAC,CAAC,CAAC;EACjE,CAAC,MAAM;IACL,MAAM,IAAIG,KAAK,CAAC,kCAAkC,CAAC;EACrD;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,KAAqB,EAAY;EACzD,MAAM;IAAEZ;EAAE,CAAC,GAAGH,MAAM,CAAC,CAAC;EACtB,MAAMgB,WAAW,GAAGd,cAAc,CAACC,CAAC,EAAEY,KAAK,CAACX,IAAI,CAAC;;EAEjD;EACA,IAAID,CAAC,CAACE,KAAK,CAACC,EAAE,CAACS,KAAK,CAACX,IAAI,CAAC,EAAE;IAC1B,MAAMa,qBAAqB,GAAGd,CAAC,CAACE,KAAK,CAACa,6BAA6B,CAACH,KAAK,CAACX,IAAI,CAAC;IAC/E,IAAIa,qBAAqB,EAAE;MACzB,MAAM,IAAIJ,KAAK,CAAC,iEAAiE,CAAC;IACpF;EACF;EAEA,QAAAM,iBAAA,CAEKrB,GAAG;IAACsB,IAAI,EAAEJ,WAAW;IAAEK,IAAI;IAAAC,QAAA,EACxBC,UAAU,IAAAJ,iBAAA,CACTlB,WAAW;MAACG,IAAI,EAAEmB,UAAU;MAAA,IAAEC,QAAQA,CAAA;QAAA,OAAET,KAAK,CAACS,QAAQ;MAAA;MAAA,IAAEC,UAAUA,CAAA;QAAA,OAAEV,KAAK,CAACU,UAAU;MAAA;IAAA;EACtF,IAAAC,MAAA,OAEFX,KAAK,CAACO,QAAQ;AAGrB","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as py from "@alloy-js/python";
|
|
2
|
+
import { type Interface, type Model } from "@typespec/compiler";
|
|
3
|
+
export interface ClassDeclarationPropsWithType extends Omit<py.ClassDeclarationProps, "name"> {
|
|
4
|
+
type: Model | Interface;
|
|
5
|
+
name?: string;
|
|
6
|
+
abstract?: boolean;
|
|
7
|
+
methodType?: "method" | "class" | "static";
|
|
8
|
+
}
|
|
9
|
+
export type ClassDeclarationProps = ClassDeclarationPropsWithType | py.ClassDeclarationProps;
|
|
10
|
+
/**
|
|
11
|
+
* Converts TypeSpec Models and Interfaces to Python classes.
|
|
12
|
+
*
|
|
13
|
+
* - **Models** are converted into Dataclasses with `@dataclass(kw_only=True)` + fields
|
|
14
|
+
* - **Interfaces** are converted into Abstract classes (ABC) with abstract methods
|
|
15
|
+
* - For models that extends another model, we convert that into Python class inheritance
|
|
16
|
+
* - For interfaces that extends another interface, there's no inheritance, since
|
|
17
|
+
* TypeSpec flattens the inheritance
|
|
18
|
+
*
|
|
19
|
+
* @param props - The props for the class declaration.
|
|
20
|
+
* @returns The class declaration.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ClassDeclaration(props: ClassDeclarationProps): import("@alloy-js/core").Children;
|
|
23
|
+
//# sourceMappingURL=class-declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-declaration.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/class-declaration/class-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAShE,MAAM,WAAW,6BAA8B,SAAQ,IAAI,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAC3F,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,MAAM,qBAAqB,GAAG,6BAA6B,GAAG,EAAE,CAAC,qBAAqB,CAAC;AAQ7F;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qCA8E5D"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import * as py from "@alloy-js/python";
|
|
3
|
+
import { useTsp } from "../../../core/context/tsp-context.js";
|
|
4
|
+
import { reportDiagnostic } from "../../../lib.js";
|
|
5
|
+
import { declarationRefkeys } from "../../utils/refkey.js";
|
|
6
|
+
import { DocElement } from "../doc-element/doc-element.js";
|
|
7
|
+
import { ClassBases } from "./class-bases.js";
|
|
8
|
+
import { ClassBody } from "./class-body.js";
|
|
9
|
+
import { MethodProvider } from "./class-method.js";
|
|
10
|
+
function isTypedClassDeclarationProps(props) {
|
|
11
|
+
return "type" in props;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Converts TypeSpec Models and Interfaces to Python classes.
|
|
16
|
+
*
|
|
17
|
+
* - **Models** are converted into Dataclasses with `@dataclass(kw_only=True)` + fields
|
|
18
|
+
* - **Interfaces** are converted into Abstract classes (ABC) with abstract methods
|
|
19
|
+
* - For models that extends another model, we convert that into Python class inheritance
|
|
20
|
+
* - For interfaces that extends another interface, there's no inheritance, since
|
|
21
|
+
* TypeSpec flattens the inheritance
|
|
22
|
+
*
|
|
23
|
+
* @param props - The props for the class declaration.
|
|
24
|
+
* @returns The class declaration.
|
|
25
|
+
*/
|
|
26
|
+
export function ClassDeclaration(props) {
|
|
27
|
+
const {
|
|
28
|
+
$
|
|
29
|
+
} = useTsp();
|
|
30
|
+
|
|
31
|
+
// Interfaces are rendered as abstract classes (ABC) with abstract methods
|
|
32
|
+
// Models are rendered as concrete dataclasses with fields
|
|
33
|
+
// If we are explicitly overriding the class as abstract or the type is not a model, we need to create an abstract class
|
|
34
|
+
const abstract = "abstract" in props && props.abstract || "type" in props && !$.model.is(props.type);
|
|
35
|
+
const type = "type" in props ? props.type : undefined;
|
|
36
|
+
const docSource = props.doc ?? (type ? $.type.getDoc(type) : undefined);
|
|
37
|
+
const docElement = docSource ? _$createComponent(DocElement, {
|
|
38
|
+
doc: docSource,
|
|
39
|
+
component: py.ClassDoc
|
|
40
|
+
}) : undefined;
|
|
41
|
+
|
|
42
|
+
// TODO: When TypeSpec adds true generics support, pass extraBases with Generic[T, ...] here.
|
|
43
|
+
// Currently, TypeSpec templates are macros that expand to concrete types, so we don't
|
|
44
|
+
// generate Python generics (TypeVar/Generic) for template declarations.
|
|
45
|
+
const basesType = ClassBases({
|
|
46
|
+
type: "type" in props ? props.type : undefined,
|
|
47
|
+
bases: props.bases,
|
|
48
|
+
abstract
|
|
49
|
+
});
|
|
50
|
+
if (!isTypedClassDeclarationProps(props)) {
|
|
51
|
+
return _$createComponent(py.ClassDeclaration, _$mergeProps(props, {
|
|
52
|
+
doc: docElement
|
|
53
|
+
}, () => basesType.length ? {
|
|
54
|
+
bases: basesType
|
|
55
|
+
} : {}));
|
|
56
|
+
}
|
|
57
|
+
const namePolicy = py.usePythonNamePolicy();
|
|
58
|
+
let name = props.name ?? props.type.name;
|
|
59
|
+
if (!name) {
|
|
60
|
+
reportDiagnostic($.program, {
|
|
61
|
+
code: "type-declaration-missing-name",
|
|
62
|
+
target: props.type
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
name = namePolicy.getName(name, "class");
|
|
66
|
+
const refkeys = declarationRefkeys(props.refkey, props.type);
|
|
67
|
+
|
|
68
|
+
// Check for models with additional properties (Record-based scenarios)
|
|
69
|
+
// This check must happen here (in addition to ClassBody) because models with no properties
|
|
70
|
+
// (e.g., `model Foo is Record<string>`) won't render a ClassBody, so the error would never be thrown
|
|
71
|
+
if ($.model.is(props.type)) {
|
|
72
|
+
const additionalPropsRecord = $.model.getAdditionalPropertiesRecord(props.type);
|
|
73
|
+
if (additionalPropsRecord) {
|
|
74
|
+
throw new Error("Models with additional properties (Record[…]) are not supported");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Array-based models (e.g., model Foo is Array<T>) use regular classes, not dataclasses,
|
|
79
|
+
// since Array models in TypeSpec can't have properties, so they behave more like a class
|
|
80
|
+
// that inherits from a list.
|
|
81
|
+
// Similarly, interfaces should use regular classes (ABC) not dataclasses, since interfaces
|
|
82
|
+
// only define abstract methods, not fields.
|
|
83
|
+
const isArrayModel = $.model.is(props.type) && $.array.is(props.type);
|
|
84
|
+
const isInterface = props.type.kind === "Interface";
|
|
85
|
+
const useDataclass = !isArrayModel && !isInterface;
|
|
86
|
+
const ClassComponent = useDataclass ? py.DataclassDeclaration : py.ClassDeclaration;
|
|
87
|
+
return _$createComponent(MethodProvider, {
|
|
88
|
+
get value() {
|
|
89
|
+
return props.methodType;
|
|
90
|
+
},
|
|
91
|
+
get children() {
|
|
92
|
+
return _$createComponent(ClassComponent, _$mergeProps({
|
|
93
|
+
doc: docElement,
|
|
94
|
+
name: name
|
|
95
|
+
}, () => basesType.length ? {
|
|
96
|
+
bases: basesType
|
|
97
|
+
} : {}, {
|
|
98
|
+
refkey: refkeys,
|
|
99
|
+
kwOnly: useDataclass ? true : undefined,
|
|
100
|
+
get children() {
|
|
101
|
+
return _$createComponent(ClassBody, {
|
|
102
|
+
get type() {
|
|
103
|
+
return props.type;
|
|
104
|
+
},
|
|
105
|
+
abstract: abstract,
|
|
106
|
+
get methodType() {
|
|
107
|
+
return props.methodType;
|
|
108
|
+
},
|
|
109
|
+
get children() {
|
|
110
|
+
return props.children;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=class-declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["py","useTsp","reportDiagnostic","declarationRefkeys","DocElement","ClassBases","ClassBody","MethodProvider","isTypedClassDeclarationProps","props","ClassDeclaration","$","abstract","model","is","type","undefined","docSource","doc","getDoc","docElement","_$createComponent","component","ClassDoc","basesType","bases","_$mergeProps","length","namePolicy","usePythonNamePolicy","name","program","code","target","getName","refkeys","refkey","additionalPropsRecord","getAdditionalPropertiesRecord","Error","isArrayModel","array","isInterface","kind","useDataclass","ClassComponent","DataclassDeclaration","value","methodType","children","kwOnly"],"sources":["../../../../../src/python/components/class-declaration/class-declaration.tsx"],"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AACM,IAAI,CAAC;EACrE,MAAM2B,WAAW,GAAGjC,KAAK,CAACM,IAAI,CAAC4B,IAAI,KAAK,WAAW;EACnD,MAAMC,YAAY,GAAG,CAACJ,YAAY,IAAI,CAACE,WAAW;EAElD,MAAMG,cAAc,GAAGD,YAAY,GAAG5C,EAAE,CAAC8C,oBAAoB,GAAG9C,EAAE,CAACU,gBAAgB;EAEnF,OAAAW,iBAAA,CACGd,cAAc;IAAA,IAACwC,KAAKA,CAAA;MAAA,OAAEtC,KAAK,CAACuC,UAAU;IAAA;IAAA,IAAAC,SAAA;MAAA,OAAA5B,iBAAA,CACpCwB,cAAc,EAAAnB,YAAA;QACbR,GAAG,EAAEE,UAAU;QACfU,IAAI,EAAEA;MAAI,SACLN,SAAS,CAACG,MAAM,GAAG;QAAEF,KAAK,EAAED;MAAU,CAAC,GAAG,CAAC,CAAC;QACjDY,MAAM,EAAED,OAAO;QACfe,MAAM,EAAEN,YAAY,GAAG,IAAI,GAAG5B,SAAS;QAAA,IAAAiC,SAAA;UAAA,OAAA5B,iBAAA,CAEtCf,SAAS;YAAA,IAACS,IAAIA,CAAA;cAAA,OAAEN,KAAK,CAACM,IAAI;YAAA;YAAEH,QAAQ,EAAEA,QAAQ;YAAA,IAAEoC,UAAUA,CAAA;cAAA,OAAEvC,KAAK,CAACuC,UAAU;YAAA;YAAA,IAAAC,SAAA;cAAA,OAC1ExC,KAAK,CAACwC,QAAQ;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAKzB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/class-declaration/class-declaration.test.tsx"],"names":[],"mappings":""}
|