@alloy-js/python 0.4.0-dev.2 → 0.4.0-dev.5

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 (258) hide show
  1. package/dist/dev/src/builtins/python.js +30 -0
  2. package/dist/dev/src/builtins/python.js.map +1 -0
  3. package/dist/dev/src/components/Atom.js +122 -0
  4. package/dist/dev/src/components/Atom.js.map +1 -0
  5. package/dist/dev/src/components/CallSignature.js +195 -0
  6. package/dist/dev/src/components/CallSignature.js.map +1 -0
  7. package/dist/dev/src/components/ClassDeclaration.js +112 -0
  8. package/dist/dev/src/components/ClassDeclaration.js.map +1 -0
  9. package/dist/dev/src/components/ClassInstantiation.js +40 -0
  10. package/dist/dev/src/components/ClassInstantiation.js.map +1 -0
  11. package/dist/dev/src/components/ClassMethodDeclaration.js +40 -0
  12. package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -0
  13. package/dist/dev/src/components/ConstructorDeclaration.js +39 -0
  14. package/dist/dev/src/components/ConstructorDeclaration.js.map +1 -0
  15. package/dist/dev/src/components/DataclassDeclaration.js +177 -0
  16. package/dist/dev/src/components/DataclassDeclaration.js.map +1 -0
  17. package/dist/dev/src/components/Declaration.js +31 -0
  18. package/dist/dev/src/components/Declaration.js.map +1 -0
  19. package/dist/dev/src/components/DunderMethodDeclaration.js +33 -0
  20. package/dist/dev/src/components/DunderMethodDeclaration.js.map +1 -0
  21. package/dist/dev/src/components/EnumDeclaration.js +259 -0
  22. package/dist/dev/src/components/EnumDeclaration.js.map +1 -0
  23. package/dist/dev/src/components/EnumMember.js +95 -0
  24. package/dist/dev/src/components/EnumMember.js.map +1 -0
  25. package/dist/dev/src/components/FunctionBase.js +130 -0
  26. package/dist/dev/src/components/FunctionBase.js.map +1 -0
  27. package/dist/dev/src/components/FunctionCallExpression.js +53 -0
  28. package/dist/dev/src/components/FunctionCallExpression.js.map +1 -0
  29. package/dist/dev/src/components/FunctionDeclaration.js +45 -0
  30. package/dist/dev/src/components/FunctionDeclaration.js.map +1 -0
  31. package/dist/dev/src/components/FutureStatement.js +31 -0
  32. package/dist/dev/src/components/FutureStatement.js.map +1 -0
  33. package/dist/dev/src/components/ImportStatement.js +167 -0
  34. package/dist/dev/src/components/ImportStatement.js.map +1 -0
  35. package/dist/dev/src/components/LexicalScope.js +26 -0
  36. package/dist/dev/src/components/LexicalScope.js.map +1 -0
  37. package/dist/dev/src/components/MemberExpression.js +290 -0
  38. package/dist/dev/src/components/MemberExpression.js.map +1 -0
  39. package/dist/dev/src/components/MemberScope.js +23 -0
  40. package/dist/dev/src/components/MemberScope.js.map +1 -0
  41. package/dist/dev/src/components/MethodBase.js +40 -0
  42. package/dist/dev/src/components/MethodBase.js.map +1 -0
  43. package/dist/dev/src/components/MethodDeclaration.js +38 -0
  44. package/dist/dev/src/components/MethodDeclaration.js.map +1 -0
  45. package/dist/dev/src/components/PropertyDeclaration.js +287 -0
  46. package/dist/dev/src/components/PropertyDeclaration.js.map +1 -0
  47. package/dist/dev/src/components/PyDoc.js +1478 -0
  48. package/dist/dev/src/components/PyDoc.js.map +1 -0
  49. package/dist/dev/src/components/PythonBlock.js +35 -0
  50. package/dist/dev/src/components/PythonBlock.js.map +1 -0
  51. package/dist/dev/src/components/Reference.js +23 -0
  52. package/dist/dev/src/components/Reference.js.map +1 -0
  53. package/dist/dev/src/components/SourceFile.js +385 -0
  54. package/dist/dev/src/components/SourceFile.js.map +1 -0
  55. package/dist/dev/src/components/StatementList.js +34 -0
  56. package/dist/dev/src/components/StatementList.js.map +1 -0
  57. package/dist/dev/src/components/StaticMethodDeclaration.js +40 -0
  58. package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -0
  59. package/dist/dev/src/components/TypeArguments.js +22 -0
  60. package/dist/dev/src/components/TypeArguments.js.map +1 -0
  61. package/dist/dev/src/components/TypeRefContext.js +33 -0
  62. package/dist/dev/src/components/TypeRefContext.js.map +1 -0
  63. package/dist/dev/src/components/TypeReference.js +67 -0
  64. package/dist/dev/src/components/TypeReference.js.map +1 -0
  65. package/dist/dev/src/components/UnionTypeExpression.js +57 -0
  66. package/dist/dev/src/components/UnionTypeExpression.js.map +1 -0
  67. package/dist/dev/src/components/VariableDeclaration.js +150 -0
  68. package/dist/dev/src/components/VariableDeclaration.js.map +1 -0
  69. package/dist/dev/src/components/index.js +32 -0
  70. package/dist/dev/src/components/index.js.map +1 -0
  71. package/dist/dev/src/context/index.js +2 -0
  72. package/dist/dev/src/context/index.js.map +1 -0
  73. package/dist/dev/src/context/type-ref-context.js +17 -0
  74. package/dist/dev/src/context/type-ref-context.js.map +1 -0
  75. package/dist/dev/src/create-module.js +64 -0
  76. package/dist/dev/src/create-module.js.map +1 -0
  77. package/dist/dev/src/index.js +8 -0
  78. package/dist/dev/src/index.js.map +1 -0
  79. package/dist/dev/src/name-conflict-resolver.js +8 -0
  80. package/dist/dev/src/name-conflict-resolver.js.map +1 -0
  81. package/dist/dev/src/name-policy.js +48 -0
  82. package/dist/dev/src/name-policy.js.map +1 -0
  83. package/dist/dev/src/parameter-descriptor.js +8 -0
  84. package/dist/dev/src/parameter-descriptor.js.map +1 -0
  85. package/dist/dev/src/symbol-creation.js +58 -0
  86. package/dist/dev/src/symbol-creation.js.map +1 -0
  87. package/dist/dev/src/symbols/factories.js +28 -0
  88. package/dist/dev/src/symbols/factories.js.map +1 -0
  89. package/dist/dev/src/symbols/index.js +8 -0
  90. package/dist/dev/src/symbols/index.js.map +1 -0
  91. package/dist/dev/src/symbols/python-lexical-scope.js +15 -0
  92. package/dist/dev/src/symbols/python-lexical-scope.js.map +1 -0
  93. package/dist/dev/src/symbols/python-member-scope.js +7 -0
  94. package/dist/dev/src/symbols/python-member-scope.js.map +1 -0
  95. package/dist/dev/src/symbols/python-module-scope.js +86 -0
  96. package/dist/dev/src/symbols/python-module-scope.js.map +1 -0
  97. package/dist/dev/src/symbols/python-output-symbol.js +73 -0
  98. package/dist/dev/src/symbols/python-output-symbol.js.map +1 -0
  99. package/dist/dev/src/symbols/reference.js +87 -0
  100. package/dist/dev/src/symbols/reference.js.map +1 -0
  101. package/dist/dev/src/symbols/scopes.js +13 -0
  102. package/dist/dev/src/symbols/scopes.js.map +1 -0
  103. package/dist/dev/src/utils.js +13 -0
  104. package/dist/dev/src/utils.js.map +1 -0
  105. package/dist/dev/test/callsignatures.test.js +482 -0
  106. package/dist/dev/test/callsignatures.test.js.map +1 -0
  107. package/dist/dev/test/class-method-declaration.test.js +85 -0
  108. package/dist/dev/test/class-method-declaration.test.js.map +1 -0
  109. package/dist/dev/test/classdeclarations.test.js +654 -0
  110. package/dist/dev/test/classdeclarations.test.js.map +1 -0
  111. package/dist/dev/test/classinstantiations.test.js +281 -0
  112. package/dist/dev/test/classinstantiations.test.js.map +1 -0
  113. package/dist/dev/test/constructordeclaration.test.js +86 -0
  114. package/dist/dev/test/constructordeclaration.test.js.map +1 -0
  115. package/dist/dev/test/dataclassdeclarations.test.js +1068 -0
  116. package/dist/dev/test/dataclassdeclarations.test.js.map +1 -0
  117. package/dist/dev/test/dundermethoddeclaration.test.js +93 -0
  118. package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -0
  119. package/dist/dev/test/enums.test.js +263 -0
  120. package/dist/dev/test/enums.test.js.map +1 -0
  121. package/dist/dev/test/externals.test.js +307 -0
  122. package/dist/dev/test/externals.test.js.map +1 -0
  123. package/dist/dev/test/factories.test.js +122 -0
  124. package/dist/dev/test/factories.test.js.map +1 -0
  125. package/dist/dev/test/functioncallexpressions.test.js +257 -0
  126. package/dist/dev/test/functioncallexpressions.test.js.map +1 -0
  127. package/dist/dev/test/functiondeclaration.test.js +817 -0
  128. package/dist/dev/test/functiondeclaration.test.js.map +1 -0
  129. package/dist/dev/test/imports.test.js +372 -0
  130. package/dist/dev/test/imports.test.js.map +1 -0
  131. package/dist/dev/test/memberexpressions.test.js +1668 -0
  132. package/dist/dev/test/memberexpressions.test.js.map +1 -0
  133. package/dist/dev/test/methoddeclaration.test.js +344 -0
  134. package/dist/dev/test/methoddeclaration.test.js.map +1 -0
  135. package/dist/dev/test/namepolicies.test.js +154 -0
  136. package/dist/dev/test/namepolicies.test.js.map +1 -0
  137. package/dist/dev/test/propertydeclaration.test.js +354 -0
  138. package/dist/dev/test/propertydeclaration.test.js.map +1 -0
  139. package/dist/dev/test/pydocs.test.js +1675 -0
  140. package/dist/dev/test/pydocs.test.js.map +1 -0
  141. package/dist/dev/test/references.test.js +66 -0
  142. package/dist/dev/test/references.test.js.map +1 -0
  143. package/dist/dev/test/sourcefiles.test.js +1802 -0
  144. package/dist/dev/test/sourcefiles.test.js.map +1 -0
  145. package/dist/dev/test/staticmethoddeclaration.test.js +85 -0
  146. package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -0
  147. package/dist/dev/test/type-checking-imports.test.js +617 -0
  148. package/dist/dev/test/type-checking-imports.test.js.map +1 -0
  149. package/dist/dev/test/typereference.test.js +79 -0
  150. package/dist/dev/test/typereference.test.js.map +1 -0
  151. package/dist/dev/test/uniontypeexpression.test.js +307 -0
  152. package/dist/dev/test/uniontypeexpression.test.js.map +1 -0
  153. package/dist/dev/test/utils.js +100 -0
  154. package/dist/dev/test/utils.js.map +1 -0
  155. package/dist/dev/test/values.test.js +182 -0
  156. package/dist/dev/test/values.test.js.map +1 -0
  157. package/dist/dev/test/variables.test.js +363 -0
  158. package/dist/dev/test/variables.test.js.map +1 -0
  159. package/dist/src/components/CallSignature.d.ts.map +1 -1
  160. package/dist/src/components/CallSignature.js +12 -3
  161. package/dist/src/components/CallSignature.js.map +1 -1
  162. package/dist/src/components/ImportStatement.d.ts +12 -0
  163. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  164. package/dist/src/components/ImportStatement.js +47 -5
  165. package/dist/src/components/ImportStatement.js.map +1 -1
  166. package/dist/src/components/MemberExpression.d.ts +1 -1
  167. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  168. package/dist/src/components/MemberExpression.js +98 -180
  169. package/dist/src/components/MemberExpression.js.map +1 -1
  170. package/dist/src/components/Reference.d.ts.map +1 -1
  171. package/dist/src/components/Reference.js +5 -1
  172. package/dist/src/components/Reference.js.map +1 -1
  173. package/dist/src/components/SourceFile.d.ts +1 -1
  174. package/dist/src/components/SourceFile.d.ts.map +1 -1
  175. package/dist/src/components/SourceFile.js +46 -7
  176. package/dist/src/components/SourceFile.js.map +1 -1
  177. package/dist/src/components/TypeRefContext.d.ts +26 -0
  178. package/dist/src/components/TypeRefContext.d.ts.map +1 -0
  179. package/dist/src/components/TypeRefContext.js +29 -0
  180. package/dist/src/components/TypeRefContext.js.map +1 -0
  181. package/dist/src/components/TypeReference.d.ts +5 -0
  182. package/dist/src/components/TypeReference.d.ts.map +1 -1
  183. package/dist/src/components/TypeReference.js +19 -9
  184. package/dist/src/components/TypeReference.js.map +1 -1
  185. package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
  186. package/dist/src/components/VariableDeclaration.js +7 -2
  187. package/dist/src/components/VariableDeclaration.js.map +1 -1
  188. package/dist/src/components/index.d.ts +1 -1
  189. package/dist/src/components/index.d.ts.map +1 -1
  190. package/dist/src/components/index.js +1 -1
  191. package/dist/src/components/index.js.map +1 -1
  192. package/dist/src/context/index.d.ts +2 -0
  193. package/dist/src/context/index.d.ts.map +1 -0
  194. package/dist/src/context/index.js +2 -0
  195. package/dist/src/context/index.js.map +1 -0
  196. package/dist/src/context/type-ref-context.d.ts +13 -0
  197. package/dist/src/context/type-ref-context.d.ts.map +1 -0
  198. package/dist/src/context/type-ref-context.js +17 -0
  199. package/dist/src/context/type-ref-context.js.map +1 -0
  200. package/dist/src/symbols/python-module-scope.d.ts +13 -1
  201. package/dist/src/symbols/python-module-scope.d.ts.map +1 -1
  202. package/dist/src/symbols/python-module-scope.js +36 -2
  203. package/dist/src/symbols/python-module-scope.js.map +1 -1
  204. package/dist/src/symbols/python-output-symbol.d.ts +11 -0
  205. package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
  206. package/dist/src/symbols/python-output-symbol.js +26 -2
  207. package/dist/src/symbols/python-output-symbol.js.map +1 -1
  208. package/dist/src/symbols/reference.d.ts +8 -1
  209. package/dist/src/symbols/reference.d.ts.map +1 -1
  210. package/dist/src/symbols/reference.js +4 -2
  211. package/dist/src/symbols/reference.js.map +1 -1
  212. package/dist/test/dataclassdeclarations.test.js +5 -2
  213. package/dist/test/dataclassdeclarations.test.js.map +1 -1
  214. package/dist/test/externals.test.js +8 -2
  215. package/dist/test/externals.test.js.map +1 -1
  216. package/dist/test/functiondeclaration.test.js +6 -3
  217. package/dist/test/functiondeclaration.test.js.map +1 -1
  218. package/dist/test/imports.test.js +3 -3
  219. package/dist/test/imports.test.js.map +1 -1
  220. package/dist/test/references.test.js +1 -1
  221. package/dist/test/references.test.js.map +1 -1
  222. package/dist/test/sourcefiles.test.js +26 -26
  223. package/dist/test/sourcefiles.test.js.map +1 -1
  224. package/dist/test/type-checking-imports.test.d.ts +2 -0
  225. package/dist/test/type-checking-imports.test.d.ts.map +1 -0
  226. package/dist/test/type-checking-imports.test.js +437 -0
  227. package/dist/test/type-checking-imports.test.js.map +1 -0
  228. package/dist/test/uniontypeexpression.test.js +4 -1
  229. package/dist/test/uniontypeexpression.test.js.map +1 -1
  230. package/dist/test/variables.test.js +4 -1
  231. package/dist/test/variables.test.js.map +1 -1
  232. package/dist/tsconfig.tsbuildinfo +1 -1
  233. package/package.json +6 -4
  234. package/src/components/CallSignature.tsx +6 -2
  235. package/src/components/ImportStatement.tsx +52 -5
  236. package/src/components/MemberExpression.tsx +174 -298
  237. package/src/components/Reference.tsx +3 -1
  238. package/src/components/SourceFile.tsx +44 -8
  239. package/src/components/TypeRefContext.tsx +36 -0
  240. package/src/components/TypeReference.tsx +15 -7
  241. package/src/components/VariableDeclaration.tsx +5 -1
  242. package/src/components/index.ts +1 -1
  243. package/src/context/index.ts +1 -0
  244. package/src/context/type-ref-context.tsx +16 -0
  245. package/src/symbols/python-module-scope.ts +55 -2
  246. package/src/symbols/python-output-symbol.ts +32 -1
  247. package/src/symbols/reference.tsx +10 -0
  248. package/temp/api.json +443 -338
  249. package/test/dataclassdeclarations.test.tsx +8 -2
  250. package/test/externals.test.tsx +8 -2
  251. package/test/functiondeclaration.test.tsx +6 -3
  252. package/test/imports.test.tsx +6 -6
  253. package/test/references.test.tsx +1 -1
  254. package/test/sourcefiles.test.tsx +13 -13
  255. package/test/type-checking-imports.test.tsx +363 -0
  256. package/test/uniontypeexpression.test.tsx +4 -1
  257. package/test/variables.test.tsx +4 -1
  258. package/vitest.config.ts +8 -0
@@ -0,0 +1,30 @@
1
+ import { createModule } from "../create-module.js";
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+
5
+ export const abcModule = createModule({
6
+ name: "abc",
7
+ descriptor: {
8
+ ".": ["abstractmethod"]
9
+ }
10
+ });
11
+ export const dataclassesModule = createModule({
12
+ name: "dataclasses",
13
+ descriptor: {
14
+ ".": ["dataclass", "KW_ONLY"]
15
+ }
16
+ });
17
+ export const enumModule = createModule({
18
+ name: "enum",
19
+ descriptor: {
20
+ ".": ["auto", "Enum", "Flag", "IntEnum", "IntFlag", "StrEnum"]
21
+ }
22
+ });
23
+ export const requestsModule = createModule({
24
+ name: "requests",
25
+ descriptor: {
26
+ ".": ["get", "post", "put", "delete", "patch", "head", "options"],
27
+ models: ["Response", "Request"]
28
+ }
29
+ });
30
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createModule","abcModule","name","descriptor","dataclassesModule","enumModule","requestsModule","models"],"sources":["../../../../src/builtins/python.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,YAAY,QAAQ,qBAAqB;;AAElD;;AAGA,OAAO,MAAMC,SAAS,GAAGD,YAAY,CAAC;EACpCE,IAAI,EAAE,KAAK;EACXC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,gBAAgB;EACxB;AACF,CAAC,CAAC;AAEF,OAAO,MAAMC,iBAAiB,GAAGJ,YAAY,CAAC;EAC5CE,IAAI,EAAE,aAAa;EACnBC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,WAAW,EAAE,SAAS;EAC9B;AACF,CAAC,CAAC;AAEF,OAAO,MAAME,UAAU,GAAGL,YAAY,CAAC;EACrCE,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS;EAC/D;AACF,CAAC,CAAC;AAEF,OAAO,MAAMG,cAAc,GAAGN,YAAY,CAAC;EACzCE,IAAI,EAAE,UAAU;EAChBC,UAAU,EAAE;IACV,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC;IACjEI,MAAM,EAAE,CAAC,UAAU,EAAE,SAAS;EAChC;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,122 @@
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { For, Indent, memo } from "@alloy-js/core";
3
+ /**
4
+ * A component that renders a JavaScript value as a Python atom (atomic value).
5
+ * It handles various types of atomic values including numbers, booleans, strings,
6
+ * functions, arrays, and objects, converting them to Python-like syntax.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <Atom jsValue={42} /> // renders "42"
11
+ * <Atom jsValue={true} /> // renders "True"
12
+ * <Atom jsValue="Hello" /> // renders '"Hello"'
13
+ * <Atom jsValue={[1, 2, 3]} /> // renders "[1, 2, 3]"
14
+ * <Atom jsValue={{ key: "value" }} />
15
+ * ```
16
+ */
17
+ export function Atom(props) {
18
+ return memo(() => {
19
+ const jsValue = props.jsValue;
20
+ if (typeof jsValue === "undefined") {
21
+ return "None";
22
+ } else if (typeof jsValue === "number") {
23
+ if (props.asFloat && Number.isInteger(jsValue)) {
24
+ return jsValue.toFixed(1);
25
+ }
26
+ return String(jsValue);
27
+ } else if (typeof jsValue === "boolean") {
28
+ return jsValue ? "True" : "False";
29
+ } else if (typeof jsValue === "string") {
30
+ return `"${jsValue.replace(/"/g, '\\"')}"`;
31
+ } else if (typeof jsValue === "function") {
32
+ // functions are inserted as-is.
33
+ return jsValue;
34
+ } else if (typeof jsValue === "object") {
35
+ if (jsValue === null) {
36
+ return "None";
37
+ } else if (Array.isArray(jsValue)) {
38
+ // Recursively emit each element of arrays
39
+ return _$createIntrinsic("group", {
40
+ get children() {
41
+ return ["[", _$createComponent(Indent, {
42
+ softline: true,
43
+ trailingBreak: true,
44
+ get children() {
45
+ return _$createComponent(For, {
46
+ each: jsValue,
47
+ comma: true,
48
+ line: true,
49
+ children: v => _$createComponent(Atom, {
50
+ jsValue: v
51
+ }, {
52
+ fileName: import.meta.url,
53
+ lineNumber: 50,
54
+ columnNumber: 25
55
+ })
56
+ }, {
57
+ fileName: import.meta.url,
58
+ lineNumber: 49,
59
+ columnNumber: 15
60
+ });
61
+ }
62
+ }, {
63
+ fileName: import.meta.url,
64
+ lineNumber: 48,
65
+ columnNumber: 13
66
+ }), "]"];
67
+ }
68
+ }, {
69
+ fileName: import.meta.url,
70
+ lineNumber: 46,
71
+ columnNumber: 11
72
+ });
73
+ } else {
74
+ const entries = Object.entries(jsValue);
75
+ if (entries.length === 0) {
76
+ return "{}";
77
+ }
78
+ // Recursively emit each key-value pair of objects
79
+ return _$createIntrinsic("group", {
80
+ get children() {
81
+ return ["{", _$createComponent(Indent, {
82
+ softline: true,
83
+ get children() {
84
+ return _$createComponent(For, {
85
+ each: entries,
86
+ comma: true,
87
+ line: true,
88
+ children: ([k, v]) => [_$createComponent(Atom, {
89
+ jsValue: k
90
+ }, {
91
+ fileName: import.meta.url,
92
+ lineNumber: 69,
93
+ columnNumber: 21
94
+ }), ": ", _$createComponent(Atom, {
95
+ jsValue: v
96
+ }, {
97
+ fileName: import.meta.url,
98
+ lineNumber: 69,
99
+ columnNumber: 43
100
+ })]
101
+ }, {
102
+ fileName: import.meta.url,
103
+ lineNumber: 66,
104
+ columnNumber: 15
105
+ });
106
+ }
107
+ }, {
108
+ fileName: import.meta.url,
109
+ lineNumber: 65,
110
+ columnNumber: 13
111
+ }), "}"];
112
+ }
113
+ }, {
114
+ fileName: import.meta.url,
115
+ lineNumber: 63,
116
+ columnNumber: 11
117
+ });
118
+ }
119
+ }
120
+ });
121
+ }
122
+ //# sourceMappingURL=Atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["For","Indent","memo","Atom","props","jsValue","asFloat","Number","isInteger","toFixed","String","replace","Array","isArray","_$createIntrinsic","children","_$createComponent","softline","trailingBreak","each","comma","line","v","fileName","import","meta","url","lineNumber","columnNumber","entries","Object","length","k"],"sources":["../../../../src/components/Atom.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;AAOlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAACC,KAAgB,EAAO;EAC1C,OAAOF,IAAI,CAAC,MAAM;IAChB,MAAMG,OAAO,GAAGD,KAAK,CAACC,OAAO;IAE7B,IAAI,OAAOA,OAAO,KAAK,WAAW,EAAE;MAClC,OAAO,MAAM;IACf,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MACtC,IAAID,KAAK,CAACE,OAAO,IAAIC,MAAM,CAACC,SAAS,CAACH,OAAO,CAAC,EAAE;QAC9C,OAAOA,OAAO,CAACI,OAAO,CAAC,CAAC,CAAC;MAC3B;MACA,OAAOC,MAAM,CAACL,OAAO,CAAC;IACxB,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,SAAS,EAAE;MACvC,OAAOA,OAAO,GAAG,MAAM,GAAG,OAAO;IACnC,CAAC,MAAM,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MACtC,OAAO,IAAIA,OAAO,CAACM,OAAO,CAAC,IAAI,EAAE,KAAK,C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;cAAA,IAAAF,SAAA;gBAAA,OAAAC,iBAAA,CACbhB,GAAG;kBAACmB,IAAI,EAAEU,OAAO;kBAAET,KAAK;kBAACC,IAAI;kBAAAN,QAAA,EAC3BA,CAAC,CAACiB,CAAC,EAAEV,CAAC,CAAC,MAAAN,iBAAA,CAEHb,IAAI;oBAACE,OAAO,EAAE2B;kBAAC;oBAAAT,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;oBAAAC,UAAA;oBAAAC,YAAA;kBAAA,UAAAZ,iBAAA,CAAOb,IAAI;oBAACE,OAAO,EAAEiB;kBAAC;oBAAAC,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;oBAAAC,UAAA;oBAAAC,YAAA;kBAAA;gBAEzC;kBAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;kBAAAC,UAAA;kBAAAC,YAAA;gBAAA;cAAA;YAAA;cAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;cAAAC,UAAA;cAAAC,YAAA;YAAA,IAGJ,GAAG;UAAA;QAAA;UAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;UAAAC,UAAA;UAAAC,YAAA;QAAA;MAGV;IACF;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,195 @@
1
+ import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { computed, createSymbolSlot, For, Show } from "@alloy-js/core";
3
+ import { isParameterDescriptor } from "../parameter-descriptor.js";
4
+ import { createPythonSymbol } from "../symbol-creation.js";
5
+ import { Atom } from "./Atom.js";
6
+ import { TypeRefContext } from "./TypeRefContext.js";
7
+ function isParameterMarker(param) {
8
+ return typeof param === "string" && (param === "*" || param === "/");
9
+ }
10
+ /**
11
+ * A call signature parameters declaration, which can be used to define the
12
+ * parameters of a function or other callables.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <py.CallSignatureParameters parameters={[ "a", "b" ]} />
17
+ * ```
18
+ * This will generate:
19
+ * ```python
20
+ * a, b
21
+ * ```
22
+ */
23
+ export function CallSignatureParameters(props) {
24
+ const parameterList = computed(() => {
25
+ const params = (props.parameters ?? []).map(p => {
26
+ return isParameterMarker(p) ? p : parameter(normalizeAndDeclareParameter(p));
27
+ });
28
+
29
+ // Add *args if specified
30
+ if (props.args) {
31
+ params.push("*args");
32
+ }
33
+
34
+ // Add **kwargs if specified
35
+ if (props.kwargs) {
36
+ params.push("**kwargs");
37
+ }
38
+ return params;
39
+ });
40
+ return _$createComponent(For, {
41
+ each: parameterList,
42
+ comma: true,
43
+ space: true,
44
+ children: param => param
45
+ }, {
46
+ fileName: import.meta.url,
47
+ lineNumber: 67,
48
+ columnNumber: 5
49
+ });
50
+ }
51
+ function parameter(param) {
52
+ const TypeSlot = param.TypeSlot; // TypeSlot will always be present when param.type is true.
53
+ return _$createIntrinsic("group", {
54
+ get children() {
55
+ return [_$memo(() => param.symbol.name, false, "param.symbol.name"), _$createComponent(Show, {
56
+ get when() {
57
+ return !!param.type;
58
+ },
59
+ get children() {
60
+ return [":", " ", _$createComponent(TypeRefContext, {
61
+ get children() {
62
+ return _$createComponent(TypeSlot, {
63
+ get children() {
64
+ return param.type;
65
+ }
66
+ }, {
67
+ fileName: import.meta.url,
68
+ lineNumber: 81,
69
+ columnNumber: 11
70
+ });
71
+ }
72
+ }, {
73
+ fileName: import.meta.url,
74
+ lineNumber: 80,
75
+ columnNumber: 9
76
+ })];
77
+ }
78
+ }, {
79
+ fileName: import.meta.url,
80
+ lineNumber: 78,
81
+ columnNumber: 7
82
+ }), _$createComponent(Show, {
83
+ get when() {
84
+ return param.default !== undefined;
85
+ },
86
+ get children() {
87
+ return [_$createComponent(Show, {
88
+ get when() {
89
+ return !param.type;
90
+ },
91
+ children: "="
92
+ }, {
93
+ fileName: import.meta.url,
94
+ lineNumber: 85,
95
+ columnNumber: 9
96
+ }), _$createComponent(Show, {
97
+ get when() {
98
+ return !!param.type;
99
+ },
100
+ children: " = "
101
+ }, {
102
+ fileName: import.meta.url,
103
+ lineNumber: 86,
104
+ columnNumber: 9
105
+ }), [_$createComponent(Atom, {
106
+ get jsValue() {
107
+ return param.default;
108
+ }
109
+ }, {
110
+ fileName: import.meta.url,
111
+ lineNumber: 88,
112
+ columnNumber: 11
113
+ })]];
114
+ }
115
+ }, {
116
+ fileName: import.meta.url,
117
+ lineNumber: 84,
118
+ columnNumber: 7
119
+ })];
120
+ }
121
+ }, {
122
+ fileName: import.meta.url,
123
+ lineNumber: 76,
124
+ columnNumber: 5
125
+ });
126
+ }
127
+ function normalizeAndDeclareParameter(param) {
128
+ if (isParameterDescriptor(param)) {
129
+ const TypeSlot = createSymbolSlot();
130
+ const symbol = createPythonSymbol(param.name, {
131
+ refkeys: param.refkey,
132
+ type: TypeSlot.firstSymbol
133
+ }, "parameter");
134
+ return {
135
+ ...param,
136
+ symbol,
137
+ TypeSlot
138
+ };
139
+ } else {
140
+ const symbol = createPythonSymbol(param, {}, "parameter");
141
+ return {
142
+ symbol
143
+ };
144
+ }
145
+ }
146
+ /**
147
+ * A Python call signature, e.g. the part after the `def` keyword and the name in a
148
+ * function expression.
149
+ *
150
+ * @example
151
+ * ```tsx
152
+ * <CallSignature
153
+ * parameters={[{ name: "a", type: "int" }, { name: "b", type: "str" }]}
154
+ * returnType="int"
155
+ * />
156
+ * ```
157
+ * renders to
158
+ * ```py
159
+ * (a: int, b: str) -> int
160
+ * ```
161
+ * @remarks
162
+ *
163
+ * Any parameters or type parameters declared in this signature will be placed
164
+ * in the current scope. This component does not make a scope to hold its
165
+ * parameters.
166
+ */
167
+ export function CallSignature(props) {
168
+ const sParams = _$createComponent(CallSignatureParameters, {
169
+ get parameters() {
170
+ return props.parameters;
171
+ },
172
+ get args() {
173
+ return props.args;
174
+ },
175
+ get kwargs() {
176
+ return props.kwargs;
177
+ }
178
+ }, {
179
+ fileName: import.meta.url,
180
+ lineNumber: 179,
181
+ columnNumber: 5
182
+ });
183
+ const typeParams = props.typeParameters ? `[${props.typeParameters.join(", ")}]` : "";
184
+ const sReturnType = props.returnType ? [" -> ", _$createComponent(TypeRefContext, {
185
+ get children() {
186
+ return props.returnType;
187
+ }
188
+ }, {
189
+ fileName: import.meta.url,
190
+ lineNumber: 191,
191
+ columnNumber: 9
192
+ })] : undefined;
193
+ return [typeParams, "(", sParams, ")", sReturnType];
194
+ }
195
+ //# sourceMappingURL=CallSignature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["computed","createSymbolSlot","For","Show","isParameterDescriptor","createPythonSymbol","Atom","TypeRefContext","isParameterMarker","param","CallSignatureParameters","props","parameterList","params","parameters","map","p","parameter","normalizeAndDeclareParameter","args","push","kwargs","_$createComponent","each","comma","space","children","fileName","import","meta","url","lineNumber","columnNumber","TypeSlot","_$createIntrinsic","_$memo","symbol","name","when","type","default","undefined","jsValue","refkeys","refkey","firstSymbol","CallSignature","sParams","typeParams","typeParameters","join","sReturnType","returnType"],"sources":["../../../../src/components/CallSignature.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,QAAQ,EACRC,gBAAgB,EAChBC,GAAG,EACHC,IAAI,QAEC,gBAAgB;AACvB,SACEC,qBAAqB,QAEhB,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,IAAI;AACb,SAASC,cAAc;AAIvB,SAASC,iBAAiBA,CACxBC,KAA+C,EACrB;EAC1B,OAAO,OAAOA,KAAK,KAAK,QAAQ,KAAKA,KAAK,KAAK,GAAG,IAAIA,KAAK,KAAK,GAAG,CAAC;AACtE;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAMC,aAAa,GAAGZ,QAAQ,CAAC,MAAM;IACnC,MAAMa,MAAM,GAAG,CAACF,KAAK,CAACG,UAAU,IAAI,EA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AAA,MAEnCS,SAAS;EAEb,QAEKO,UAAU,OAAGD,OAAO,OAAGI,WAAW;AAGzC","ignoreList":[]}
@@ -0,0 +1,112 @@
1
+ import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { List, Name, Show, createContentSlot } from "@alloy-js/core";
3
+ import { createPythonSymbol } from "../symbol-creation.js";
4
+ import { Declaration } from "./Declaration.js";
5
+ import { MemberScope } from "./MemberScope.js";
6
+ import { PythonBlock } from "./PythonBlock.js";
7
+ /**
8
+ * Create a Python class declaration.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <ClassDeclaration name="MyClass" bases={["BaseClass"]}>
13
+ * <VariableDeclaration name="a" type="int" />
14
+ * <VariableDeclaration name="b" type="str" />
15
+ * <py.FunctionDeclaration name="my_method" parameters={[{ name: "a", type: "int" }, { name: "b", type: "str" }]} returnType="int">
16
+ * return a + b
17
+ * </py.FunctionDeclaration>
18
+ * </ClassDeclaration>
19
+ * ```
20
+ * renders to
21
+ * ```py
22
+ * class MyClass(BaseClass):
23
+ * a: int = None
24
+ * b: str = None
25
+ * def my_method(self, a: int, b: str) -> int:
26
+ * return a + b
27
+ * ```
28
+ * @remarks
29
+ *
30
+ * Any child declarations (methods, fields, nested classes) will be placed
31
+ * in the class scope. This component creates a class scope to hold its
32
+ * members.
33
+ */
34
+ export function ClassDeclaration(props) {
35
+ const basesPart = props.bases && ["(", _$createComponent(List, {
36
+ get children() {
37
+ return props.bases;
38
+ },
39
+ comma: true,
40
+ space: true
41
+ }, {
42
+ fileName: import.meta.url,
43
+ lineNumber: 44,
44
+ columnNumber: 8
45
+ }), ")"];
46
+ const sym = createPythonSymbol(props.name, {
47
+ refkeys: props.refkey
48
+ }, "class");
49
+ const ContentSlot = createContentSlot();
50
+ return _$createComponent(Declaration, {
51
+ symbol: sym,
52
+ get children() {
53
+ return ["class ", _$createComponent(Name, {}, {
54
+ fileName: import.meta.url,
55
+ lineNumber: 60,
56
+ columnNumber: 13
57
+ }), _$createComponent(MemberScope, {
58
+ ownerSymbol: sym,
59
+ get children() {
60
+ return [basesPart, _$createComponent(PythonBlock, {
61
+ opener: ":",
62
+ get children() {
63
+ return [_$createComponent(Show, {
64
+ get when() {
65
+ return Boolean(props.doc);
66
+ },
67
+ get children() {
68
+ return [_$memo(() => props.doc, false, "props.doc"), _$createIntrinsic("line", {}, {
69
+ fileName: import.meta.url,
70
+ lineNumber: 66,
71
+ columnNumber: 13
72
+ })];
73
+ }
74
+ }, {
75
+ fileName: import.meta.url,
76
+ lineNumber: 64,
77
+ columnNumber: 11
78
+ }), _$createComponent(ContentSlot.WhenEmpty, {
79
+ children: "pass"
80
+ }, {
81
+ fileName: import.meta.url,
82
+ lineNumber: 68,
83
+ columnNumber: 11
84
+ }), _$createComponent(ContentSlot, {
85
+ get children() {
86
+ return props.children;
87
+ }
88
+ }, {
89
+ fileName: import.meta.url,
90
+ lineNumber: 69,
91
+ columnNumber: 11
92
+ })];
93
+ }
94
+ }, {
95
+ fileName: import.meta.url,
96
+ lineNumber: 63,
97
+ columnNumber: 9
98
+ })];
99
+ }
100
+ }, {
101
+ fileName: import.meta.url,
102
+ lineNumber: 61,
103
+ columnNumber: 7
104
+ })];
105
+ }
106
+ }, {
107
+ fileName: import.meta.url,
108
+ lineNumber: 59,
109
+ columnNumber: 5
110
+ });
111
+ }
112
+ //# sourceMappingURL=ClassDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["List","Name","Show","createContentSlot","createPythonSymbol","Declaration","MemberScope","PythonBlock","ClassDeclaration","props","basesPart","bases","_$createComponent","children","comma","space","fileName","import","meta","url","lineNumber","columnNumber","sym","name","refkeys","refkey","ContentSlot","symbol","ownerSymbol","opener","when","Boolean","doc","_$memo","_$createIntrinsic","WhenEmpty"],"sources":["../../../../src/components/ClassDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAmBA,IAAI,EAAEC,IAAI,EAAEC,IAAI,E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AA,IAAAnB,SAAA;kBAAA,QAAAoB,MAAA,OAC3BxB,KAAK,CAACuB,GAAG,uBAAAE,iBAAA;oBAAAlB,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;oBAAAC,UAAA;oBAAAC,YAAA;kBAAA;gBAAA;cAAA;gBAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;gBAAAC,UAAA;gBAAAC,YAAA;cAAA,IAAAT,iBAAA,CAGXc,WAAW,CAACS,SAAS;gBAAAtB,QAAA;cAAA;gBAAAG,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;gBAAAC,UAAA;gBAAAC,YAAA;cAAA,IAAAT,iBAAA,CACrBc,WAAW;gBAAA,IAAAb,SAAA;kBAAA,OAAEJ,KAAK,CAACI,QAAQ;gBAAA;cAAA;gBAAAG,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;gBAAAC,UAAA;gBAAAC,YAAA;cAAA;YAAA;UAAA;YAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;YAAAC,UAAA;YAAAC,YAAA;UAAA;QAAA;MAAA;QAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;QAAAC,UAAA;QAAAC,YAAA;MAAA;IAAA;EAAA;IAAAL,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AAKtC","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { emitSymbol, instantiateTakenMembersTo, useContext } from "@alloy-js/core";
3
+ import { createPythonSymbol } from "../symbol-creation.js";
4
+ import { FunctionCallExpression } from "./FunctionCallExpression.js";
5
+ import { PythonSourceFileContext } from "./SourceFile.js";
6
+ /**
7
+ * Used to create new instances of classes in Python.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <ClassInstantiation target="MyClass" args={["arg1", "arg2"]} />
12
+ * ```
13
+ * This will generate:
14
+ * ```python
15
+ * MyClass(arg1, arg2)
16
+ * ```
17
+ * @remarks
18
+ *
19
+ * It is similar to FunctionCallExpression but specifically for class instantiation.
20
+ * Args should be a list arguments that can be either simple js values or py.Atoms, which will render as positional arguments,
21
+ * or py.VariableDeclarations, which will render as named arguments in the call statement. This component will
22
+ * not check for the correctness of the python grammar and will just work with any children you provide.
23
+ * It is up to you to ensure that the arguments you provide are valid in the context of a class instantiation.
24
+ */
25
+ export function ClassInstantiation(props) {
26
+ const sfContext = useContext(PythonSourceFileContext);
27
+ const module = sfContext?.module;
28
+ const sym = createPythonSymbol("", {
29
+ transient: true,
30
+ module: module
31
+ });
32
+ instantiateTakenMembersTo(sym, "static", "instance");
33
+ emitSymbol(sym);
34
+ return [_$createComponent(FunctionCallExpression, props, {
35
+ fileName: import.meta.url,
36
+ lineNumber: 45,
37
+ columnNumber: 7
38
+ })];
39
+ }
40
+ //# sourceMappingURL=ClassInstantiation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["emitSymbol","instantiateTakenMembersTo","useContext","createPythonSymbol","FunctionCallExpression","PythonSourceFileContext","ClassInstantiation","props","sfContext","module","sym","transient","_$createComponent","fileName","import","meta","url","lineNumber","columnNumber"],"sources":["../../../../src/components/ClassInstantiation.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,UAAU,EACVC,yBAAyB,EACzBC,UAAU,QACL,gBAAgB;AACvB,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SACEC,sBAAsB;AAGxB,SAASC,uBAAuB;AAIhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAA8B,EAAE;EACjE,MAAMC,SAAS,GAAGN,UAAU,CAACG,uBAAuB,CAAC;EACrD,MAAMI,MAAM,GAAGD,SAAS,EAAEC,MAAM;EAChC,MAAMC,GAAG,GAAGP,kBAAkB,CAAC,EAAE,EAAE;IACjCQ,SAAS,EAAE,IAAI;IACfF,MAAM,EAAEA;EACV,CAAC,CAAC;EACFR,yBAAyB,CAACS,GAAG,EAAE,QAAQ,EAAE,UAAU,CAAC;EACpDV,UAAU,CAACU,GAAG,CAAC;EACf,QAAAE,iBAAA,CAEKR,sBAAsB,EAAKG,KAAK;IAAAM,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AAGvC","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import { createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { createMethodSymbol } from "../symbols/factories.js";
3
+ import { MethodDeclarationBase } from "./MethodBase.js";
4
+
5
+ /**
6
+ * A Python class method declaration component.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <py.ClassMethodDeclaration name="create" parameters={[{ name: "value", type: "str" }]}>
11
+ * return cls(value)
12
+ * </py.ClassMethodDeclaration>
13
+ * ```
14
+ * Generates:
15
+ * ```python
16
+ * @classmethod
17
+ * def create(cls, value: str) -> None:
18
+ * return cls(value)
19
+ * ```
20
+ */
21
+
22
+ export function ClassMethodDeclaration(props) {
23
+ const sym = createMethodSymbol(props.name, {
24
+ refkeys: props.refkey
25
+ });
26
+ return ["@classmethod", _$createIntrinsic("hbr", {}, {
27
+ fileName: import.meta.url,
28
+ lineNumber: 30,
29
+ columnNumber: 7
30
+ }), _$createComponent(MethodDeclarationBase, _$mergeProps({
31
+ functionType: "class"
32
+ }, props, {
33
+ sym: sym
34
+ }), {
35
+ fileName: import.meta.url,
36
+ lineNumber: 31,
37
+ columnNumber: 7
38
+ })];
39
+ }
40
+ //# sourceMappingURL=ClassMethodDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createMethodSymbol","MethodDeclarationBase","ClassMethodDeclaration","props","sym","name","refkeys","refkey","_$createIntrinsic","fileName","import","meta","url","lineNumber","columnNumber","_$createComponent","_$mergeProps","functionType"],"sources":["../../../../src/components/ClassMethodDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,qBAAqB,QAAQ,iBAAiB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASC,sBAAsBA,CAACC,KAAkC,EAAE;EACzE,MAAMC,GAAG,GAAGJ,kBAAkB,CAACG,KAAK,CAACE,IAAI,EAAE;IAAEC,OAAO,EAAEH,KAAK,CAACI;EAAO,CAAC,CAAC;EACrE,QAEK,cAAc,EAAAC,iBAAA;IAAAC,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA,IAAAC,iBAAA,CAEdd,qBAAqB,EAAAe,YAAA;IAACC,YAAY;EAAA,GAAad,KAAK;IAAEC,GAAG,EAAEA;EAAG;IAAAK,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AAGrE","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { namekey } from "@alloy-js/core";
3
+ import { createMethodSymbol } from "../symbols/factories.js";
4
+ import { MethodDeclarationBase } from "./MethodBase.js";
5
+
6
+ /**
7
+ * A Python constructor declaration for `__new__`.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <py.ConstructorDeclaration parameters={[{ name: "value", type: "int" }]}>
12
+ * pass
13
+ * </py.ConstructorDeclaration>
14
+ * ```
15
+ * Generates:
16
+ * ```python
17
+ * def __new__(cls, value: int):
18
+ * pass
19
+ * ```
20
+ */
21
+
22
+ export function ConstructorDeclaration(props) {
23
+ const name = namekey("__new__", {
24
+ ignoreNamePolicy: true
25
+ });
26
+ const sym = createMethodSymbol(name, {
27
+ refkeys: props.refkey
28
+ });
29
+ return _$createComponent(MethodDeclarationBase, _$mergeProps(props, {
30
+ name: name,
31
+ functionType: "class",
32
+ sym: sym
33
+ }), {
34
+ fileName: import.meta.url,
35
+ lineNumber: 30,
36
+ columnNumber: 5
37
+ });
38
+ }
39
+ //# sourceMappingURL=ConstructorDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["namekey","createMethodSymbol","MethodDeclarationBase","ConstructorDeclaration","props","name","ignoreNamePolicy","sym","refkeys","refkey","_$createComponent","_$mergeProps","functionType","fileName","import","meta","url","lineNumber","columnNumber"],"sources":["../../../../src/components/ConstructorDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,OAAO,QAAQ,gBAAgB;AACxC,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,qBAAqB,QAAQ,iBAAiB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,SAASC,sBAAsBA,CAACC,KAAkC,EAAE;EACzE,MAAMC,IAAI,GAAGL,OAAO,CAAC,SAAS,EAAE;IAAEM,gBAAgB,EAAE;EAAK,CAAC,CAAC;EAC3D,MAAMC,GAAG,GAAGN,kBAAkB,CAACI,IAAI,EAAE;IAAEG,OAAO,EAAEJ,KAAK,CAACK;EAAO,CAAC,CAAC;EAC/D,OAAAC,iBAAA,CACGR,qBAAqB,EAAAS,YAAA,CAChBP,KAAK;IACTC,IAAI,EAAEA,IAAI;IACVO,YAAY;IACZL,GAAG,EAAEA;EAAG;IAAAM,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AAGd","ignoreList":[]}