@alloy-js/python 0.5.0-dev.0 → 0.5.0-dev.2
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/dev/src/builtins/python.js +46 -0
- package/dist/dev/src/builtins/python.js.map +1 -1
- package/dist/dev/src/components/ClassDeclaration.js +19 -10
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -1
- package/dist/dev/src/components/ClassMethodDeclaration.js +20 -5
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/DataclassDeclaration.js +14 -12
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/dev/src/components/DecoratorList.js +55 -0
- package/dist/dev/src/components/DecoratorList.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +21 -12
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -1
- package/dist/dev/src/components/FunctionBase.js +21 -10
- package/dist/dev/src/components/FunctionBase.js.map +1 -1
- package/dist/dev/src/components/FutureStatement.js +1 -1
- package/dist/dev/src/components/MethodBase.js +16 -4
- package/dist/dev/src/components/MethodBase.js.map +1 -1
- package/dist/dev/src/components/PropertyDeclaration.js +68 -17
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/dev/src/components/PydanticClassDeclaration.js +136 -0
- package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/src/components/StaticMethodDeclaration.js +19 -5
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/dev/src/components/index.js +1 -0
- package/dist/dev/src/components/index.js.map +1 -1
- package/dist/dev/test/callsignatures.test.js +471 -297
- package/dist/dev/test/callsignatures.test.js.map +1 -1
- package/dist/dev/test/class-method-declaration.test.js +21 -10
- package/dist/dev/test/class-method-declaration.test.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +480 -381
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/classinstantiations.test.js +201 -168
- package/dist/dev/test/classinstantiations.test.js.map +1 -1
- package/dist/dev/test/constructordeclaration.test.js +22 -11
- package/dist/dev/test/constructordeclaration.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +345 -358
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +131 -0
- package/dist/dev/test/decoratorlist.test.js.map +1 -0
- package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/enums.test.js +231 -166
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/externals.test.js +57 -45
- package/dist/dev/test/externals.test.js.map +1 -1
- package/dist/dev/test/factories.test.js +124 -50
- package/dist/dev/test/factories.test.js.map +1 -1
- package/dist/dev/test/functioncallexpressions.test.js +199 -164
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +452 -265
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/imports.test.js +273 -221
- package/dist/dev/test/imports.test.js.map +1 -1
- package/dist/dev/test/memberexpressions.test.js +1237 -972
- package/dist/dev/test/memberexpressions.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +200 -45
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/namepolicies.test.js +130 -94
- package/dist/dev/test/namepolicies.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +177 -46
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +1089 -0
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/dev/test/pydocs.test.js +888 -715
- package/dist/dev/test/pydocs.test.js.map +1 -1
- package/dist/dev/test/references.test.js +42 -35
- package/dist/dev/test/references.test.js.map +1 -1
- package/dist/dev/test/sourcefiles.test.js +1109 -841
- package/dist/dev/test/sourcefiles.test.js.map +1 -1
- package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/type-checking-imports.test.js +408 -359
- package/dist/dev/test/type-checking-imports.test.js.map +1 -1
- package/dist/dev/test/typereference.test.js +55 -40
- package/dist/dev/test/typereference.test.js.map +1 -1
- package/dist/dev/test/uniontypeexpression.test.js +222 -146
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
- package/dist/dev/test/utils.js +39 -77
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/values.test.js +237 -101
- package/dist/dev/test/values.test.js.map +1 -1
- package/dist/dev/test/variables.test.js +321 -203
- package/dist/dev/test/variables.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/src/builtins/python.d.ts +30 -0
- package/dist/src/builtins/python.d.ts.map +1 -1
- package/dist/src/builtins/python.js +46 -0
- package/dist/src/builtins/python.js.map +1 -1
- package/dist/src/components/ClassDeclaration.d.ts +21 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -1
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts +5 -1
- package/dist/src/components/ClassMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassMethodDeclaration.js +14 -3
- package/dist/src/components/ClassMethodDeclaration.js.map +1 -1
- package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
- package/dist/src/components/DataclassDeclaration.js +10 -4
- package/dist/src/components/DataclassDeclaration.js.map +1 -1
- package/dist/src/components/DecoratorList.d.ts +43 -0
- package/dist/src/components/DecoratorList.d.ts.map +1 -0
- package/dist/src/components/DecoratorList.js +47 -0
- package/dist/src/components/DecoratorList.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts +9 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +6 -1
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts +31 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +9 -2
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FutureStatement.d.ts +1 -1
- package/dist/src/components/FutureStatement.js +1 -1
- package/dist/src/components/MethodBase.d.ts.map +1 -1
- package/dist/src/components/MethodBase.js +10 -2
- package/dist/src/components/MethodBase.js.map +1 -1
- package/dist/src/components/PropertyDeclaration.d.ts +29 -0
- package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
- package/dist/src/components/PropertyDeclaration.js +48 -1
- package/dist/src/components/PropertyDeclaration.js.map +1 -1
- package/dist/src/components/PydanticClassDeclaration.d.ts +120 -0
- package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/PydanticClassDeclaration.js +116 -0
- package/dist/src/components/PydanticClassDeclaration.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +2 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +12 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.d.ts +3 -0
- package/dist/src/components/StaticMethodDeclaration.d.ts.map +1 -1
- package/dist/src/components/StaticMethodDeclaration.js +13 -3
- package/dist/src/components/StaticMethodDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/test/callsignatures.test.js +346 -272
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.js +7 -4
- package/dist/test/class-method-declaration.test.js.map +1 -1
- package/dist/test/classdeclarations.test.js +316 -277
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/classinstantiations.test.js +112 -103
- package/dist/test/classinstantiations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.js +7 -4
- package/dist/test/constructordeclaration.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +153 -178
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.d.ts +2 -0
- package/dist/test/decoratorlist.test.d.ts.map +1 -0
- package/dist/test/decoratorlist.test.js +83 -0
- package/dist/test/decoratorlist.test.js.map +1 -0
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +172 -143
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +24 -24
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.js +75 -33
- package/dist/test/factories.test.js.map +1 -1
- package/dist/test/functioncallexpressions.test.js +117 -106
- package/dist/test/functioncallexpressions.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +256 -173
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +171 -143
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +582 -453
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +106 -19
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/namepolicies.test.js +90 -78
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +90 -15
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.d.ts +2 -0
- package/dist/test/pydanticclassdeclarations.test.d.ts.map +1 -0
- package/dist/test/pydanticclassdeclarations.test.js +773 -0
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -0
- package/dist/test/pydocs.test.js +573 -532
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +31 -28
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +700 -580
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.js +7 -4
- package/dist/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.js +297 -284
- package/dist/test/type-checking-imports.test.js.map +1 -1
- package/dist/test/typereference.test.js +29 -22
- package/dist/test/typereference.test.js.map +1 -1
- package/dist/test/uniontypeexpression.test.js +124 -88
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/utils.d.ts +10 -17
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +32 -74
- package/dist/test/utils.js.map +1 -1
- package/dist/test/values.test.js +135 -67
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +201 -151
- package/dist/test/variables.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/ClassDeclaration.md +10 -7
- package/docs/api/components/ClassEnumDeclaration.md +9 -6
- package/docs/api/components/ClassMethodDeclaration.md +7 -5
- package/docs/api/components/DataclassDeclaration.md +9 -5
- package/docs/api/components/DunderMethodDeclaration.md +7 -5
- package/docs/api/components/FunctionDeclaration.md +9 -5
- package/docs/api/components/FutureStatement.md +1 -1
- package/docs/api/components/MethodDeclaration.md +11 -6
- package/docs/api/components/PropertyDeclaration.md +11 -8
- package/docs/api/components/PydanticClassDeclaration.md +146 -0
- package/docs/api/components/SourceFile.md +20 -8
- package/docs/api/components/StaticMethodDeclaration.md +7 -5
- package/docs/api/components/index.md +1 -0
- package/docs/api/index.md +3 -3
- package/docs/api/types/CommonFunctionProps.md +4 -3
- package/docs/api/types/PydanticModelConfigDictProps.md +32 -0
- package/docs/api/types/index.md +1 -0
- package/docs/api/variables/index.md +3 -0
- package/docs/api/variables/pydanticModule.md +27 -0
- package/docs/api/variables/pydanticSettingsModule.md +7 -0
- package/docs/api/variables/typingModule.md +9 -0
- package/package.json +4 -4
- package/src/builtins/python.ts +539 -1
- package/src/components/ClassDeclaration.tsx +23 -0
- package/src/components/ClassMethodDeclaration.tsx +9 -1
- package/src/components/DataclassDeclaration.tsx +18 -11
- package/src/components/DecoratorList.tsx +50 -0
- package/src/components/EnumDeclaration.tsx +11 -0
- package/src/components/FunctionBase.tsx +34 -3
- package/src/components/FutureStatement.tsx +1 -1
- package/src/components/MethodBase.tsx +6 -2
- package/src/components/PropertyDeclaration.tsx +48 -1
- package/src/components/PydanticClassDeclaration.tsx +222 -0
- package/src/components/SourceFile.tsx +6 -1
- package/src/components/StaticMethodDeclaration.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/temp/api.json +1158 -86
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +277 -235
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +256 -349
- package/test/decoratorlist.test.tsx +114 -0
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +84 -71
- package/test/externals.test.tsx +25 -25
- package/test/factories.test.tsx +64 -22
- package/test/functioncallexpressions.test.tsx +123 -109
- package/test/functiondeclaration.test.tsx +218 -140
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +115 -24
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +71 -7
- package/test/pydanticclassdeclarations.test.tsx +704 -0
- package/test/pydocs.test.tsx +531 -579
- package/test/references.test.tsx +24 -23
- package/test/sourcefiles.test.tsx +527 -492
- package/test/staticmethoddeclaration.test.tsx +3 -4
- package/test/type-checking-imports.test.tsx +206 -218
- package/test/typereference.test.tsx +15 -12
- package/test/uniontypeexpression.test.tsx +74 -61
- package/test/utils.tsx +26 -110
- package/test/values.test.tsx +82 -32
- package/test/variables.test.tsx +162 -142
- package/test/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { code, refkey } from "@alloy-js/core";
|
|
3
|
-
import { d } from "@alloy-js/core/testing";
|
|
4
3
|
import { expect, it } from "vitest";
|
|
5
4
|
import * as py from "../src/index.js";
|
|
6
5
|
import { createModule } from "../src/index.js";
|
|
7
|
-
import {
|
|
6
|
+
import { TestOutput } from "./utils.js";
|
|
8
7
|
it("uses import from external library", () => {
|
|
9
8
|
const requestsLib = createModule({
|
|
10
9
|
name: "requests",
|
|
@@ -14,14 +13,16 @@ it("uses import from external library", () => {
|
|
|
14
13
|
"models.anothermodule": ["something"]
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
|
-
|
|
16
|
+
expect(_$createComponent(TestOutput, {
|
|
17
|
+
externals: [requestsLib],
|
|
18
18
|
get children() {
|
|
19
|
-
return
|
|
19
|
+
return _$createComponent(py.StatementList, {
|
|
20
|
+
get children() {
|
|
21
|
+
return [_$memo(() => requestsLib["."].get), _$memo(() => requestsLib["."].post), _$memo(() => requestsLib["models"].Request), _$memo(() => requestsLib["models"].Response), _$memo(() => requestsLib["models.anothermodule"].something)];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
|
-
})
|
|
22
|
-
externals: [requestsLib]
|
|
23
|
-
});
|
|
24
|
-
const expected = d`
|
|
25
|
+
})).toRenderTo(`
|
|
25
26
|
from requests import get
|
|
26
27
|
from requests import post
|
|
27
28
|
from requests.models import Request
|
|
@@ -33,8 +34,7 @@ it("uses import from external library", () => {
|
|
|
33
34
|
Request
|
|
34
35
|
Response
|
|
35
36
|
something
|
|
36
|
-
|
|
37
|
-
expect(result).toRenderTo(expected);
|
|
37
|
+
`);
|
|
38
38
|
});
|
|
39
39
|
it("uses import from external library in multiple functions", () => {
|
|
40
40
|
const functionDeclarations = [_$createComponent(py.FunctionDeclaration, {
|
|
@@ -94,10 +94,12 @@ it("uses import from external library in multiple functions", () => {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
})];
|
|
97
|
-
|
|
98
|
-
externals
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
expect(_$createComponent(TestOutput, {
|
|
98
|
+
get externals() {
|
|
99
|
+
return [py.requestsModule];
|
|
100
|
+
},
|
|
101
|
+
children: functionDeclarations
|
|
102
|
+
})).toRenderTo(`
|
|
101
103
|
from requests import get
|
|
102
104
|
from requests import post
|
|
103
105
|
from typing import TYPE_CHECKING
|
|
@@ -115,9 +117,7 @@ it("uses import from external library in multiple functions", () => {
|
|
|
115
117
|
response = post(1)
|
|
116
118
|
return response.json()
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
`;
|
|
120
|
-
expect(result).toRenderTo(expected);
|
|
120
|
+
`);
|
|
121
121
|
});
|
|
122
122
|
it("uses import from external library in multiple class methods", () => {
|
|
123
123
|
const functionDeclarations = [_$createComponent(py.ClassDeclaration, {
|
|
@@ -197,10 +197,12 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
})];
|
|
200
|
-
|
|
201
|
-
externals
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
expect(_$createComponent(TestOutput, {
|
|
201
|
+
get externals() {
|
|
202
|
+
return [py.requestsModule];
|
|
203
|
+
},
|
|
204
|
+
children: functionDeclarations
|
|
205
|
+
})).toRenderTo(`
|
|
204
206
|
from requests import get
|
|
205
207
|
from requests import post
|
|
206
208
|
from typing import TYPE_CHECKING
|
|
@@ -220,8 +222,6 @@ it("uses import from external library in multiple class methods", () => {
|
|
|
220
222
|
return response.json()
|
|
221
223
|
|
|
222
224
|
|
|
223
|
-
|
|
224
|
-
`;
|
|
225
|
-
expect(result).toRenderTo(expected);
|
|
225
|
+
`);
|
|
226
226
|
});
|
|
227
227
|
//# sourceMappingURL=externals.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["code","refkey","
|
|
1
|
+
{"version":3,"names":["code","refkey","expect","it","py","createModule","TestOutput","requestsLib","name","descriptor","models","_$createComponent","externals","children","StatementList","_$memo","get","post","Request","Response","something","toRenderTo","functionDeclarations","FunctionDeclaration","parameters","type","returnType","requestsModule","VariableDeclaration","initializer","FunctionCallExpression","target","args","ClassDeclaration","instanceVariable","MethodDeclaration"],"sources":["../../test/externals.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,EAAEC,MAAM,QAAQ,gBAAgB;AAC7C,SAASC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACnC,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,UAAU,QAAQ,YAAY;AAEvCH,EAAE,CAAC,mCAAmC,EAAE,MAAM;EAC5C,MAAMI,WAAW,GAAGF,YAAY,CAAC;IAC/BG,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAE;MACV,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;MACpBC,MAAM,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC;MAC/B,sBAAsB,EAAE,CAAC,WAAW;IACtC;EACF,CAAC,CAAC;EACFR,MAAM,CAAAS,iBAAA,CACHL,UAAU;IAACM,SAAS,EAAE,CAACL,WAAW,CAAC;IAAA,IAAAM,SAAA;MAAA,OAAAF,iBAAA,CACjCP,EAAE,CAACU,aAAa;QAAA,IAAAD,SAAA;UAAA,QAAAE,MAAA,OACdR,WAAW,CAAC,GAAG,CAAC,CAACS,GAAG,GAAAD,MAAA,OACpBR,WAAW,CAAC,GAAG,CAAC,CAACU,IAAI,GAAAF,MAAA,OACrBR,WAAW,CAAC,QAAQ,CAAC,CAACW,OAAO,GAAAH,MAAA,OAC7BR,WAAW,CAAC,QAAQ,C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Ac,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;wBAAA;wBAAA,IACtCK,IAAIA,CAAA;0BAAA,OAAE,CAAC/B,MAAM,CAAC,UAAU,CAAC,CAAC;wBAAA;sBAAA;oBAAA;kBAAA,IAI/BD,IAAI;AACjB;AACA,aAAa;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,GAKV;EAEDE,MAAM,CAAAS,iBAAA,CACHL,UAAU;IAAA,IAACM,SAASA,CAAA;MAAA,OAAE,CAACR,EAAE,CAACuB,cAAc,CAAC;IAAA;IAAAd,QAAA,EACvCS;EAAoB,EAEzB,CAAC,CAACD,UAAU,CACV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACE,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,77 +1,119 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { render } from "@alloy-js/core";
|
|
2
3
|
import { describe, expect, it } from "vitest";
|
|
3
4
|
import * as py from "../src/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { TestOutput } from "./utils.js";
|
|
5
6
|
describe("Symbol factories", () => {
|
|
6
7
|
it("createMethodSymbol throws outside class", () => {
|
|
7
8
|
expect(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
render(_$createComponent(TestOutput, {
|
|
10
|
+
get children() {
|
|
11
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
12
|
+
name: "m"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
11
16
|
}).toThrow('Method "m" must be declared inside a class (member scope)');
|
|
12
17
|
});
|
|
13
18
|
it("createMethodSymbol succeeds inside class", () => {
|
|
14
|
-
|
|
15
|
-
name: "C",
|
|
19
|
+
expect(_$createComponent(TestOutput, {
|
|
16
20
|
get children() {
|
|
17
|
-
return _$createComponent(py.
|
|
18
|
-
name: "
|
|
21
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
22
|
+
name: "C",
|
|
23
|
+
get children() {
|
|
24
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
25
|
+
name: "m"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
19
28
|
});
|
|
20
29
|
}
|
|
21
|
-
})
|
|
22
|
-
|
|
30
|
+
})).toRenderTo(`
|
|
31
|
+
class C:
|
|
32
|
+
def m(self):
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
`);
|
|
23
37
|
});
|
|
24
38
|
it("createFunctionSymbol usable in member scope (top-level function component still works nested)", () => {
|
|
25
|
-
|
|
26
|
-
name: "C",
|
|
39
|
+
expect(_$createComponent(TestOutput, {
|
|
27
40
|
get children() {
|
|
28
|
-
return _$createComponent(py.
|
|
41
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
42
|
+
name: "C",
|
|
29
43
|
get children() {
|
|
30
|
-
return _$createComponent(py.
|
|
31
|
-
|
|
44
|
+
return _$createComponent(py.StatementList, {
|
|
45
|
+
get children() {
|
|
46
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
47
|
+
name: "f"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
32
50
|
});
|
|
33
51
|
}
|
|
34
52
|
});
|
|
35
53
|
}
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
})).toRenderTo(`
|
|
55
|
+
class C:
|
|
56
|
+
def f():
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
`);
|
|
39
61
|
});
|
|
40
62
|
});
|
|
41
63
|
describe("Validation Errors", () => {
|
|
42
64
|
it("throws error when PropertyDeclaration is used outside of a class", () => {
|
|
43
65
|
expect(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
render(_$createComponent(TestOutput, {
|
|
67
|
+
get children() {
|
|
68
|
+
return _$createComponent(py.PropertyDeclaration, {
|
|
69
|
+
name: "x"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
47
73
|
}).toThrow('Method "x" must be declared inside a class (member scope)');
|
|
48
74
|
});
|
|
49
75
|
it("throws error when MethodDeclaration is used outside of a class", () => {
|
|
50
76
|
expect(() => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
render(_$createComponent(TestOutput, {
|
|
78
|
+
get children() {
|
|
79
|
+
return _$createComponent(py.MethodDeclaration, {
|
|
80
|
+
name: "my_method"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
54
84
|
}).toThrow('Method "my_method" must be declared inside a class (member scope)');
|
|
55
85
|
});
|
|
56
86
|
it("throws error when ClassMethodDeclaration is used outside of a class", () => {
|
|
57
87
|
expect(() => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
render(_$createComponent(TestOutput, {
|
|
89
|
+
get children() {
|
|
90
|
+
return _$createComponent(py.ClassMethodDeclaration, {
|
|
91
|
+
name: "my_class_method"
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
61
95
|
}).toThrow('Method "my_class_method" must be declared inside a class (member scope)');
|
|
62
96
|
});
|
|
63
97
|
it("throws error when StaticMethodDeclaration is used outside of a class", () => {
|
|
64
98
|
expect(() => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
render(_$createComponent(TestOutput, {
|
|
100
|
+
get children() {
|
|
101
|
+
return _$createComponent(py.StaticMethodDeclaration, {
|
|
102
|
+
name: "my_static_method"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
68
106
|
}).toThrow('Method "my_static_method" must be declared inside a class (member scope)');
|
|
69
107
|
});
|
|
70
108
|
it("throws error when DunderMethodDeclaration is used outside of a class", () => {
|
|
71
109
|
expect(() => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
110
|
+
render(_$createComponent(TestOutput, {
|
|
111
|
+
get children() {
|
|
112
|
+
return _$createComponent(py.DunderMethodDeclaration, {
|
|
113
|
+
name: "__init__"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
75
117
|
}).toThrow('Method "__init__" must be declared inside a class (member scope)');
|
|
76
118
|
});
|
|
77
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["describe","expect","it","py","
|
|
1
|
+
{"version":3,"names":["render","describe","expect","it","py","TestOutput","_$createComponent","children","MethodDeclaration","name","toThrow","ClassDeclaration","toRenderTo","StatementList","FunctionDeclaration","PropertyDeclaration","ClassMethodDeclaration","StaticMethodDeclaration","DunderMethodDeclaration"],"sources":["../../test/factories.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,UAAU,QAAQ,YAAY;AAEvCJ,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCE,EAAE,CAAC,yCAAyC,EAAE,MAAM;IAClDD,MAAM,CAAC,MAAM;MACXF,MAAM,CAAAM,iBAAA,CACHD,UAAU;QAAA,IAAAE,SAAA;UAAA,OAAAD,iBAAA,CACRF,EAAE,CAACI,iBAAiB;YAACC,IAAI;UAAA;QAAA;MAAA,EAE9B,CAAC;IACH,CAAC,CAAC,CAACC,OAAO,CAAC,2DAA2D,CAAC;EACzE,CAAC,CAAC;EAEFP,EAAE,CAAC,0CAA0C,EAAE,MAAM;IACnDD,MAAM,CAAAI,iBAAA,CACHD,UAAU;MAAA,IAAAE,SAAA;QAAA,OAAAD,iBAAA,CACRF,EAAE,CAACO,gBAAgB;UAACF,IAAI;UAAA,IAAAF,SAAA;YAAA,OAAAD,iBAAA,CACtBF,EAAE,CAACI,iBAAiB;cAACC,IAAI;YAAA;UAAA;QAAA;MA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AAA,CACHD,UAAU;QAAA,IAAAE,SAAA;UAAA,OAAAD,iBAAA,CACRF,EAAE,CAACY,sBAAsB;YAACP,IAAI;UAAA;QAAA;MAAA,EAEnC,CAAC;IACH,CAAC,CAAC,CAACC,OAAO,CACR,yEACF,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC/ED,MAAM,CAAC,MAAM;MACXF,MAAM,CAAAM,iBAAA,CACHD,UAAU;QAAA,IAAAE,SAAA;UAAA,OAAAD,iBAAA,CACRF,EAAE,CAACa,uBAAuB;YAACR,IAAI;UAAA;QAAA;MAAA,EAEpC,CAAC;IACH,CAAC,CAAC,CAACC,OAAO,CACR,0EACF,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,sEAAsE,EAAE,MAAM;IAC/ED,MAAM,CAAC,MAAM;MACXF,MAAM,CAAAM,iBAAA,CACHD,UAAU;QAAA,IAAAE,SAAA;UAAA,OAAAD,iBAAA,CACRF,EAAE,CAACc,uBAAuB;YAACT,IAAI;UAAA;QAAA;MAAA,EAEpC,CAAC;IACH,CAAC,CAAC,CAACC,OAAO,CACR,kEACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,157 +1,168 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { refkey } from "@alloy-js/core";
|
|
3
|
-
import { d } from "@alloy-js/core/testing";
|
|
4
3
|
import { describe, expect, it } from "vitest";
|
|
5
4
|
import * as py from "../src/index.js";
|
|
6
|
-
import {
|
|
5
|
+
import { TestOutput } from "./utils.js";
|
|
7
6
|
describe("FunctionCallExpression", () => {
|
|
8
7
|
it("renders", () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
expect(_$createComponent(TestOutput, {
|
|
9
|
+
get children() {
|
|
10
|
+
return _$createComponent(py.FunctionCallExpression, {
|
|
11
|
+
target: "foo"
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
})).toRenderTo(`
|
|
13
15
|
foo()
|
|
14
16
|
`);
|
|
15
17
|
});
|
|
16
18
|
it("renders with args", () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
expect(_$createComponent(TestOutput, {
|
|
20
|
+
get children() {
|
|
21
|
+
return _$createComponent(py.FunctionCallExpression, {
|
|
22
|
+
target: "foo",
|
|
23
|
+
args: ["a", "b"]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
})).toRenderTo(`
|
|
22
27
|
foo(a, b)
|
|
23
28
|
`);
|
|
24
29
|
});
|
|
25
30
|
it("function call with variables", () => {
|
|
26
|
-
// Creating the reference separately so the naming policy doesn't interfere
|
|
27
31
|
const methodRef = refkey();
|
|
28
|
-
|
|
32
|
+
expect(_$createComponent(TestOutput, {
|
|
29
33
|
get children() {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
return _$createComponent(py.StatementList, {
|
|
35
|
+
get children() {
|
|
36
|
+
return [_$createComponent(py.FunctionDeclaration, {
|
|
37
|
+
name: "runFunc",
|
|
38
|
+
refkey: methodRef
|
|
39
|
+
}), _$createComponent(py.FunctionCallExpression, {
|
|
40
|
+
target: methodRef,
|
|
41
|
+
get args() {
|
|
42
|
+
return [_$createComponent(py.Atom, {
|
|
43
|
+
jsValue: "A name"
|
|
44
|
+
}), _$createComponent(py.Atom, {
|
|
45
|
+
jsValue: 42
|
|
46
|
+
}), _$createComponent(py.Atom, {
|
|
47
|
+
jsValue: true
|
|
48
|
+
})];
|
|
49
|
+
}
|
|
42
50
|
})];
|
|
43
51
|
}
|
|
44
|
-
})
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
|
-
})
|
|
47
|
-
const expected = d`
|
|
54
|
+
})).toRenderTo(`
|
|
48
55
|
def run_func():
|
|
49
56
|
pass
|
|
50
57
|
|
|
51
58
|
run_func("A name", 42, True)
|
|
52
|
-
|
|
53
|
-
expect(result).toRenderTo(expected);
|
|
59
|
+
`);
|
|
54
60
|
});
|
|
55
61
|
it("function call with variables and assignment", () => {
|
|
56
|
-
// Creating the reference separately so the naming policy doesn't interfere
|
|
57
62
|
const methodRef = refkey();
|
|
58
|
-
|
|
63
|
+
expect(_$createComponent(TestOutput, {
|
|
59
64
|
get children() {
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
65
|
+
return _$createComponent(py.StatementList, {
|
|
66
|
+
get children() {
|
|
67
|
+
return [_$createComponent(py.FunctionDeclaration, {
|
|
68
|
+
name: "runFunc",
|
|
69
|
+
returnType: "str",
|
|
70
|
+
refkey: methodRef,
|
|
71
|
+
parameters: [{
|
|
72
|
+
name: "name",
|
|
73
|
+
type: "str"
|
|
74
|
+
}, {
|
|
75
|
+
name: "number",
|
|
76
|
+
type: "int"
|
|
77
|
+
}, {
|
|
78
|
+
name: "flag",
|
|
79
|
+
type: "bool"
|
|
80
|
+
}]
|
|
81
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
82
|
+
name: "result",
|
|
83
|
+
type: "str",
|
|
84
|
+
get initializer() {
|
|
85
|
+
return _$createComponent(py.FunctionCallExpression, {
|
|
86
|
+
target: methodRef,
|
|
87
|
+
get args() {
|
|
88
|
+
return [_$createComponent(py.Atom, {
|
|
89
|
+
jsValue: "A name"
|
|
90
|
+
}), _$createComponent(py.Atom, {
|
|
91
|
+
jsValue: 42
|
|
92
|
+
}), _$createComponent(py.Atom, {
|
|
93
|
+
jsValue: true
|
|
94
|
+
})];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
88
97
|
}
|
|
89
|
-
});
|
|
98
|
+
})];
|
|
90
99
|
}
|
|
91
|
-
})
|
|
100
|
+
});
|
|
92
101
|
}
|
|
93
|
-
})
|
|
94
|
-
const expected = d`
|
|
102
|
+
})).toRenderTo(`
|
|
95
103
|
def run_func(name: str, number: int, flag: bool) -> str:
|
|
96
104
|
pass
|
|
97
105
|
|
|
98
106
|
result: str = run_func("A name", 42, True)
|
|
99
|
-
|
|
100
|
-
expect(result).toRenderTo(expected);
|
|
107
|
+
`);
|
|
101
108
|
});
|
|
102
109
|
it("Method call without a reference and with call statement vars", () => {
|
|
103
|
-
|
|
110
|
+
expect(_$createComponent(TestOutput, {
|
|
104
111
|
get children() {
|
|
105
|
-
return _$createComponent(py.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
return _$createComponent(py.StatementList, {
|
|
113
|
+
get children() {
|
|
114
|
+
return _$createComponent(py.FunctionCallExpression, {
|
|
115
|
+
target: "example_method",
|
|
116
|
+
get args() {
|
|
117
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
118
|
+
name: "name",
|
|
119
|
+
initializer: "A name",
|
|
120
|
+
callStatementVar: true
|
|
121
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
122
|
+
name: "number",
|
|
123
|
+
initializer: 42,
|
|
124
|
+
callStatementVar: true
|
|
125
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
126
|
+
name: "flag",
|
|
127
|
+
initializer: true,
|
|
128
|
+
callStatementVar: true
|
|
129
|
+
})];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
121
132
|
}
|
|
122
133
|
});
|
|
123
134
|
}
|
|
124
|
-
})
|
|
125
|
-
const expected = d`
|
|
135
|
+
})).toRenderTo(`
|
|
126
136
|
example_method(name="A name", number=42, flag=True)
|
|
127
|
-
|
|
128
|
-
expect(result).toRenderTo(expected);
|
|
137
|
+
`);
|
|
129
138
|
});
|
|
130
139
|
it("Method call without a reference mixing unnamed and named vars", () => {
|
|
131
|
-
|
|
140
|
+
expect(_$createComponent(TestOutput, {
|
|
132
141
|
get children() {
|
|
133
|
-
return _$createComponent(py.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
return _$createComponent(py.StatementList, {
|
|
143
|
+
get children() {
|
|
144
|
+
return _$createComponent(py.FunctionCallExpression, {
|
|
145
|
+
target: "example_method",
|
|
146
|
+
get args() {
|
|
147
|
+
return [_$createComponent(py.Atom, {
|
|
148
|
+
jsValue: "A name"
|
|
149
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
150
|
+
name: "number",
|
|
151
|
+
initializer: 42,
|
|
152
|
+
callStatementVar: true
|
|
153
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
154
|
+
name: "flag",
|
|
155
|
+
initializer: true,
|
|
156
|
+
callStatementVar: true
|
|
157
|
+
})];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
147
160
|
}
|
|
148
161
|
});
|
|
149
162
|
}
|
|
150
|
-
})
|
|
151
|
-
const expected = d`
|
|
163
|
+
})).toRenderTo(`
|
|
152
164
|
example_method("A name", number=42, flag=True)
|
|
153
|
-
|
|
154
|
-
expect(result).toRenderTo(expected);
|
|
165
|
+
`);
|
|
155
166
|
});
|
|
156
167
|
});
|
|
157
168
|
//# sourceMappingURL=functioncallexpressions.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["refkey","
|
|
1
|
+
{"version":3,"names":["refkey","describe","expect","it","py","TestOutput","_$createComponent","children","FunctionCallExpression","target","toRenderTo","args","methodRef","StatementList","FunctionDeclaration","name","Atom","jsValue","returnType","parameters","type","VariableDeclaration","initializer","callStatementVar"],"sources":["../../test/functioncallexpressions.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,UAAU,QAAQ,YAAY;AAEvCJ,QAAQ,CAAC,wBAAwB,EAAE,MAAM;EACvCE,EAAE,CAAC,SAAS,EAAE,MAAM;IAClBD,MAAM,CAAAI,iBAAA,CACHD,UAAU;MAAA,IAAAE,SAAA;QAAA,OAAAD,iBAAA,CACRF,EAAE,CAACI,sBAAsB;UAACC,MAAM;QAAA;MAAA;IAAA,EAErC,CAAC,CAACC,UAAU,CACV;AACN;AACA,KACI,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,mBAAmB,EAAE,MAAM;IAC5BD,MAAM,CAAAI,iBAAA,CACHD,UAAU;MAAA,IAAAE,SAAA;QAAA,OAAAD,iBAAA,CACRF,EAAE,CAACI,sBAAsB;UAACC,MAAM;UAAOE,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG;QAAC;MAAA;IAAA,EAE5D,CAAC,CAACD,UAAU,CACV;AACN;AACA,KACI,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,8BAA8B,EAAE,MAAM;IACvC,MAAMS,SAAS,GAAGZ,MAAM,CAAC,CAAC;IAC1BE,MAAM,CAAAI,iBAAA,CACHD,UAAU;MAAA,IAAAE,SAAA;QAAA,OAAAD,iBAAA,CACRF,EA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