@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.
- package/dist/dev/src/builtins/python.js +30 -0
- package/dist/dev/src/builtins/python.js.map +1 -0
- package/dist/dev/src/components/Atom.js +122 -0
- package/dist/dev/src/components/Atom.js.map +1 -0
- package/dist/dev/src/components/CallSignature.js +195 -0
- package/dist/dev/src/components/CallSignature.js.map +1 -0
- package/dist/dev/src/components/ClassDeclaration.js +112 -0
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/ClassInstantiation.js +40 -0
- package/dist/dev/src/components/ClassInstantiation.js.map +1 -0
- package/dist/dev/src/components/ClassMethodDeclaration.js +40 -0
- package/dist/dev/src/components/ClassMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/ConstructorDeclaration.js +39 -0
- package/dist/dev/src/components/ConstructorDeclaration.js.map +1 -0
- package/dist/dev/src/components/DataclassDeclaration.js +177 -0
- package/dist/dev/src/components/DataclassDeclaration.js.map +1 -0
- package/dist/dev/src/components/Declaration.js +31 -0
- package/dist/dev/src/components/Declaration.js.map +1 -0
- package/dist/dev/src/components/DunderMethodDeclaration.js +33 -0
- package/dist/dev/src/components/DunderMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +259 -0
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -0
- package/dist/dev/src/components/EnumMember.js +95 -0
- package/dist/dev/src/components/EnumMember.js.map +1 -0
- package/dist/dev/src/components/FunctionBase.js +130 -0
- package/dist/dev/src/components/FunctionBase.js.map +1 -0
- package/dist/dev/src/components/FunctionCallExpression.js +53 -0
- package/dist/dev/src/components/FunctionCallExpression.js.map +1 -0
- package/dist/dev/src/components/FunctionDeclaration.js +45 -0
- package/dist/dev/src/components/FunctionDeclaration.js.map +1 -0
- package/dist/dev/src/components/FutureStatement.js +31 -0
- package/dist/dev/src/components/FutureStatement.js.map +1 -0
- package/dist/dev/src/components/ImportStatement.js +167 -0
- package/dist/dev/src/components/ImportStatement.js.map +1 -0
- package/dist/dev/src/components/LexicalScope.js +26 -0
- package/dist/dev/src/components/LexicalScope.js.map +1 -0
- package/dist/dev/src/components/MemberExpression.js +290 -0
- package/dist/dev/src/components/MemberExpression.js.map +1 -0
- package/dist/dev/src/components/MemberScope.js +23 -0
- package/dist/dev/src/components/MemberScope.js.map +1 -0
- package/dist/dev/src/components/MethodBase.js +40 -0
- package/dist/dev/src/components/MethodBase.js.map +1 -0
- package/dist/dev/src/components/MethodDeclaration.js +38 -0
- package/dist/dev/src/components/MethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/PropertyDeclaration.js +287 -0
- package/dist/dev/src/components/PropertyDeclaration.js.map +1 -0
- package/dist/dev/src/components/PyDoc.js +1478 -0
- package/dist/dev/src/components/PyDoc.js.map +1 -0
- package/dist/dev/src/components/PythonBlock.js +35 -0
- package/dist/dev/src/components/PythonBlock.js.map +1 -0
- package/dist/dev/src/components/Reference.js +23 -0
- package/dist/dev/src/components/Reference.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +385 -0
- package/dist/dev/src/components/SourceFile.js.map +1 -0
- package/dist/dev/src/components/StatementList.js +34 -0
- package/dist/dev/src/components/StatementList.js.map +1 -0
- package/dist/dev/src/components/StaticMethodDeclaration.js +40 -0
- package/dist/dev/src/components/StaticMethodDeclaration.js.map +1 -0
- package/dist/dev/src/components/TypeArguments.js +22 -0
- package/dist/dev/src/components/TypeArguments.js.map +1 -0
- package/dist/dev/src/components/TypeRefContext.js +33 -0
- package/dist/dev/src/components/TypeRefContext.js.map +1 -0
- package/dist/dev/src/components/TypeReference.js +67 -0
- package/dist/dev/src/components/TypeReference.js.map +1 -0
- package/dist/dev/src/components/UnionTypeExpression.js +57 -0
- package/dist/dev/src/components/UnionTypeExpression.js.map +1 -0
- package/dist/dev/src/components/VariableDeclaration.js +150 -0
- package/dist/dev/src/components/VariableDeclaration.js.map +1 -0
- package/dist/dev/src/components/index.js +32 -0
- package/dist/dev/src/components/index.js.map +1 -0
- package/dist/dev/src/context/index.js +2 -0
- package/dist/dev/src/context/index.js.map +1 -0
- package/dist/dev/src/context/type-ref-context.js +17 -0
- package/dist/dev/src/context/type-ref-context.js.map +1 -0
- package/dist/dev/src/create-module.js +64 -0
- package/dist/dev/src/create-module.js.map +1 -0
- package/dist/dev/src/index.js +8 -0
- package/dist/dev/src/index.js.map +1 -0
- package/dist/dev/src/name-conflict-resolver.js +8 -0
- package/dist/dev/src/name-conflict-resolver.js.map +1 -0
- package/dist/dev/src/name-policy.js +48 -0
- package/dist/dev/src/name-policy.js.map +1 -0
- package/dist/dev/src/parameter-descriptor.js +8 -0
- package/dist/dev/src/parameter-descriptor.js.map +1 -0
- package/dist/dev/src/symbol-creation.js +58 -0
- package/dist/dev/src/symbol-creation.js.map +1 -0
- package/dist/dev/src/symbols/factories.js +28 -0
- package/dist/dev/src/symbols/factories.js.map +1 -0
- package/dist/dev/src/symbols/index.js +8 -0
- package/dist/dev/src/symbols/index.js.map +1 -0
- package/dist/dev/src/symbols/python-lexical-scope.js +15 -0
- package/dist/dev/src/symbols/python-lexical-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-member-scope.js +7 -0
- package/dist/dev/src/symbols/python-member-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-module-scope.js +86 -0
- package/dist/dev/src/symbols/python-module-scope.js.map +1 -0
- package/dist/dev/src/symbols/python-output-symbol.js +73 -0
- package/dist/dev/src/symbols/python-output-symbol.js.map +1 -0
- package/dist/dev/src/symbols/reference.js +87 -0
- package/dist/dev/src/symbols/reference.js.map +1 -0
- package/dist/dev/src/symbols/scopes.js +13 -0
- package/dist/dev/src/symbols/scopes.js.map +1 -0
- package/dist/dev/src/utils.js +13 -0
- package/dist/dev/src/utils.js.map +1 -0
- package/dist/dev/test/callsignatures.test.js +482 -0
- package/dist/dev/test/callsignatures.test.js.map +1 -0
- package/dist/dev/test/class-method-declaration.test.js +85 -0
- package/dist/dev/test/class-method-declaration.test.js.map +1 -0
- package/dist/dev/test/classdeclarations.test.js +654 -0
- package/dist/dev/test/classdeclarations.test.js.map +1 -0
- package/dist/dev/test/classinstantiations.test.js +281 -0
- package/dist/dev/test/classinstantiations.test.js.map +1 -0
- package/dist/dev/test/constructordeclaration.test.js +86 -0
- package/dist/dev/test/constructordeclaration.test.js.map +1 -0
- package/dist/dev/test/dataclassdeclarations.test.js +1068 -0
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -0
- package/dist/dev/test/dundermethoddeclaration.test.js +93 -0
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -0
- package/dist/dev/test/enums.test.js +263 -0
- package/dist/dev/test/enums.test.js.map +1 -0
- package/dist/dev/test/externals.test.js +307 -0
- package/dist/dev/test/externals.test.js.map +1 -0
- package/dist/dev/test/factories.test.js +122 -0
- package/dist/dev/test/factories.test.js.map +1 -0
- package/dist/dev/test/functioncallexpressions.test.js +257 -0
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -0
- package/dist/dev/test/functiondeclaration.test.js +817 -0
- package/dist/dev/test/functiondeclaration.test.js.map +1 -0
- package/dist/dev/test/imports.test.js +372 -0
- package/dist/dev/test/imports.test.js.map +1 -0
- package/dist/dev/test/memberexpressions.test.js +1668 -0
- package/dist/dev/test/memberexpressions.test.js.map +1 -0
- package/dist/dev/test/methoddeclaration.test.js +344 -0
- package/dist/dev/test/methoddeclaration.test.js.map +1 -0
- package/dist/dev/test/namepolicies.test.js +154 -0
- package/dist/dev/test/namepolicies.test.js.map +1 -0
- package/dist/dev/test/propertydeclaration.test.js +354 -0
- package/dist/dev/test/propertydeclaration.test.js.map +1 -0
- package/dist/dev/test/pydocs.test.js +1675 -0
- package/dist/dev/test/pydocs.test.js.map +1 -0
- package/dist/dev/test/references.test.js +66 -0
- package/dist/dev/test/references.test.js.map +1 -0
- package/dist/dev/test/sourcefiles.test.js +1802 -0
- package/dist/dev/test/sourcefiles.test.js.map +1 -0
- package/dist/dev/test/staticmethoddeclaration.test.js +85 -0
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -0
- package/dist/dev/test/type-checking-imports.test.js +617 -0
- package/dist/dev/test/type-checking-imports.test.js.map +1 -0
- package/dist/dev/test/typereference.test.js +79 -0
- package/dist/dev/test/typereference.test.js.map +1 -0
- package/dist/dev/test/uniontypeexpression.test.js +307 -0
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -0
- package/dist/dev/test/utils.js +100 -0
- package/dist/dev/test/utils.js.map +1 -0
- package/dist/dev/test/values.test.js +182 -0
- package/dist/dev/test/values.test.js.map +1 -0
- package/dist/dev/test/variables.test.js +363 -0
- package/dist/dev/test/variables.test.js.map +1 -0
- package/dist/src/components/CallSignature.d.ts.map +1 -1
- package/dist/src/components/CallSignature.js +12 -3
- package/dist/src/components/CallSignature.js.map +1 -1
- package/dist/src/components/ImportStatement.d.ts +12 -0
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +47 -5
- package/dist/src/components/ImportStatement.js.map +1 -1
- package/dist/src/components/MemberExpression.d.ts +1 -1
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +98 -180
- package/dist/src/components/MemberExpression.js.map +1 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +5 -1
- package/dist/src/components/Reference.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +46 -7
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/TypeRefContext.d.ts +26 -0
- package/dist/src/components/TypeRefContext.d.ts.map +1 -0
- package/dist/src/components/TypeRefContext.js +29 -0
- package/dist/src/components/TypeRefContext.js.map +1 -0
- package/dist/src/components/TypeReference.d.ts +5 -0
- package/dist/src/components/TypeReference.d.ts.map +1 -1
- package/dist/src/components/TypeReference.js +19 -9
- package/dist/src/components/TypeReference.js.map +1 -1
- package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
- package/dist/src/components/VariableDeclaration.js +7 -2
- package/dist/src/components/VariableDeclaration.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +2 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/type-ref-context.d.ts +13 -0
- package/dist/src/context/type-ref-context.d.ts.map +1 -0
- package/dist/src/context/type-ref-context.js +17 -0
- package/dist/src/context/type-ref-context.js.map +1 -0
- package/dist/src/symbols/python-module-scope.d.ts +13 -1
- package/dist/src/symbols/python-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/python-module-scope.js +36 -2
- package/dist/src/symbols/python-module-scope.js.map +1 -1
- package/dist/src/symbols/python-output-symbol.d.ts +11 -0
- package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/python-output-symbol.js +26 -2
- package/dist/src/symbols/python-output-symbol.js.map +1 -1
- package/dist/src/symbols/reference.d.ts +8 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +4 -2
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +5 -2
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/externals.test.js +8 -2
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +6 -3
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +3 -3
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/references.test.js +1 -1
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +26 -26
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.d.ts +2 -0
- package/dist/test/type-checking-imports.test.d.ts.map +1 -0
- package/dist/test/type-checking-imports.test.js +437 -0
- package/dist/test/type-checking-imports.test.js.map +1 -0
- package/dist/test/uniontypeexpression.test.js +4 -1
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/variables.test.js +4 -1
- package/dist/test/variables.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/components/CallSignature.tsx +6 -2
- package/src/components/ImportStatement.tsx +52 -5
- package/src/components/MemberExpression.tsx +174 -298
- package/src/components/Reference.tsx +3 -1
- package/src/components/SourceFile.tsx +44 -8
- package/src/components/TypeRefContext.tsx +36 -0
- package/src/components/TypeReference.tsx +15 -7
- package/src/components/VariableDeclaration.tsx +5 -1
- package/src/components/index.ts +1 -1
- package/src/context/index.ts +1 -0
- package/src/context/type-ref-context.tsx +16 -0
- package/src/symbols/python-module-scope.ts +55 -2
- package/src/symbols/python-output-symbol.ts +32 -1
- package/src/symbols/reference.tsx +10 -0
- package/temp/api.json +443 -338
- package/test/dataclassdeclarations.test.tsx +8 -2
- package/test/externals.test.tsx +8 -2
- package/test/functiondeclaration.test.tsx +6 -3
- package/test/imports.test.tsx +6 -6
- package/test/references.test.tsx +1 -1
- package/test/sourcefiles.test.tsx +13 -13
- package/test/type-checking-imports.test.tsx +363 -0
- package/test/uniontypeexpression.test.tsx +4 -1
- package/test/variables.test.tsx +4 -1
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createContentSlot, Name, Show } from "@alloy-js/core";
|
|
3
|
+
import { getCallSignatureProps } from "../utils.js";
|
|
4
|
+
import { CallSignature } from "./CallSignature.js";
|
|
5
|
+
import { Declaration } from "./Declaration.js";
|
|
6
|
+
import { LexicalScope } from "./LexicalScope.js";
|
|
7
|
+
import { PythonBlock } from "./PythonBlock.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shared base interface for function-like components.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This interface is consumed by public components like `FunctionDeclaration`,
|
|
14
|
+
* `MethodDeclaration`, and property method helpers. It combines declaration
|
|
15
|
+
* metadata with call signature shape.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Props for `BaseFunctionDeclaration`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This low-level component powers function/method-like declarations by
|
|
23
|
+
* handling symbol creation, parameter injection for instance/class methods,
|
|
24
|
+
* and common rendering concerns. Intended primarily for internal reuse.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Base function declaration that handles instance/class/static parameter injection
|
|
29
|
+
* and symbol creation. Exported for internal reuse by method-like components.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* // Not typically used directly. Prefer higher-level components.
|
|
34
|
+
* <BaseFunctionDeclaration name="helper" parameters={[{ name: "x" }]}>
|
|
35
|
+
* return x
|
|
36
|
+
* </BaseFunctionDeclaration>
|
|
37
|
+
* ```
|
|
38
|
+
* Generates:
|
|
39
|
+
* ```python
|
|
40
|
+
* def helper(x):
|
|
41
|
+
* return x
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function BaseFunctionDeclaration(props) {
|
|
45
|
+
const asyncKwd = props.async ? "async " : "";
|
|
46
|
+
let parameters;
|
|
47
|
+
switch (props.functionType) {
|
|
48
|
+
case "instance":
|
|
49
|
+
parameters = [{
|
|
50
|
+
name: "self"
|
|
51
|
+
}, ...(props.parameters || [])];
|
|
52
|
+
break;
|
|
53
|
+
case "class":
|
|
54
|
+
parameters = [{
|
|
55
|
+
name: "cls"
|
|
56
|
+
}, ...(props.parameters || [])];
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
parameters = props.parameters;
|
|
60
|
+
}
|
|
61
|
+
const sym = props.sym;
|
|
62
|
+
const ContentSlot = createContentSlot();
|
|
63
|
+
return [_$createComponent(Declaration, _$mergeProps(props, {
|
|
64
|
+
nameKind: "function",
|
|
65
|
+
symbol: sym,
|
|
66
|
+
get children() {
|
|
67
|
+
return [asyncKwd, "def ", _$createComponent(Name, {}, {
|
|
68
|
+
fileName: import.meta.url,
|
|
69
|
+
lineNumber: 74,
|
|
70
|
+
columnNumber: 23
|
|
71
|
+
}), _$createComponent(LexicalScope, {
|
|
72
|
+
get name() {
|
|
73
|
+
return sym.name;
|
|
74
|
+
},
|
|
75
|
+
get children() {
|
|
76
|
+
return [_$createComponent(CallSignature, _$mergeProps(() => getCallSignatureProps(props, {}), {
|
|
77
|
+
parameters: parameters
|
|
78
|
+
}), {
|
|
79
|
+
fileName: import.meta.url,
|
|
80
|
+
lineNumber: 76,
|
|
81
|
+
columnNumber: 11
|
|
82
|
+
}), _$createComponent(PythonBlock, {
|
|
83
|
+
opener: ":",
|
|
84
|
+
get children() {
|
|
85
|
+
return [_$createComponent(Show, {
|
|
86
|
+
get when() {
|
|
87
|
+
return Boolean(props.doc);
|
|
88
|
+
},
|
|
89
|
+
get children() {
|
|
90
|
+
return props.doc;
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
fileName: import.meta.url,
|
|
94
|
+
lineNumber: 81,
|
|
95
|
+
columnNumber: 13
|
|
96
|
+
}), _$createComponent(ContentSlot.WhenEmpty, {
|
|
97
|
+
children: "pass"
|
|
98
|
+
}, {
|
|
99
|
+
fileName: import.meta.url,
|
|
100
|
+
lineNumber: 82,
|
|
101
|
+
columnNumber: 13
|
|
102
|
+
}), _$createComponent(ContentSlot, {
|
|
103
|
+
get children() {
|
|
104
|
+
return props.children;
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
fileName: import.meta.url,
|
|
108
|
+
lineNumber: 83,
|
|
109
|
+
columnNumber: 13
|
|
110
|
+
})];
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
fileName: import.meta.url,
|
|
114
|
+
lineNumber: 80,
|
|
115
|
+
columnNumber: 11
|
|
116
|
+
})];
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
fileName: import.meta.url,
|
|
120
|
+
lineNumber: 75,
|
|
121
|
+
columnNumber: 9
|
|
122
|
+
})];
|
|
123
|
+
}
|
|
124
|
+
}), {
|
|
125
|
+
fileName: import.meta.url,
|
|
126
|
+
lineNumber: 73,
|
|
127
|
+
columnNumber: 7
|
|
128
|
+
})];
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=FunctionBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContentSlot","Name","Show","getCallSignatureProps","CallSignature","Declaration","LexicalScope","PythonBlock","BaseFunctionDeclaration","props","asyncKwd","async","parameters","functionType","name","sym","ContentSlot","_$createComponent","_$mergeProps","nameKind","symbol","children","fileName","import","meta","url","lineNumber","columnNumber","opener","when","Boolean","doc","WhenEmpty"],"sources":["../../../../src/components/FunctionBase.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,iBAAiB,EAAEC,IAAI,EAAEC,IAAI,QAAQ,gBAAgB;AAE9D,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAASC,aAAa;AACtB,SAA+BC,WAAW,QAAQ,kBAAkB;AACpE,SAASC,YAAY;AACrB,SAASC,WAAW;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,KAAmC,EAAE;EAC3E,MAAMC,QAAQ,GAAGD,KAAK,CAACE,KAAK,GAAG,QAAQ,GAAG,EAAE;EAC5C,IAAIC,UAAU;EACd,QAAQH,KAAK,CAACI,YAAY;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gBAAA;cAAA;gBAAAT,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;gBAAAC,UAAA;gBAAAC,YAAA;cAAA,IAAAV,iBAAA,CACzCD,WAAW,CAACgB,SAAS;gBAAAX,QAAA;cAAA;gBAAAC,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;gBAAAC,UAAA;gBAAAC,YAAA;cAAA,IAAAV,iBAAA,CACrBD,WAAW;gBAAA,IAAAK,SAAA;kBAAA,OAAEZ,KAAK,CAACY,QAAQ;gBAAA;cAAA;gBAAAC,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;AAMxC","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { For, Indent, Wrap } from "@alloy-js/core";
|
|
3
|
+
/**
|
|
4
|
+
* A Python function call expression.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <FunctionCallExpression target="foo" args={["arg1", "arg2"]} />
|
|
9
|
+
* ```
|
|
10
|
+
* This will generate:
|
|
11
|
+
* ```python
|
|
12
|
+
* foo(arg1, arg2)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function FunctionCallExpression(props) {
|
|
16
|
+
return _$createIntrinsic("group", {
|
|
17
|
+
get children() {
|
|
18
|
+
return [_$memo(() => props.target, false, "props.target"), "(", _$createComponent(Wrap, {
|
|
19
|
+
get when() {
|
|
20
|
+
return !!props.args && props.args.length > 1;
|
|
21
|
+
},
|
|
22
|
+
"with": Indent,
|
|
23
|
+
props: {
|
|
24
|
+
softline: true,
|
|
25
|
+
trailingBreak: true
|
|
26
|
+
},
|
|
27
|
+
get children() {
|
|
28
|
+
return _$createComponent(For, {
|
|
29
|
+
get each() {
|
|
30
|
+
return props.args ?? [];
|
|
31
|
+
},
|
|
32
|
+
comma: true,
|
|
33
|
+
line: true,
|
|
34
|
+
children: arg => arg
|
|
35
|
+
}, {
|
|
36
|
+
fileName: import.meta.url,
|
|
37
|
+
lineNumber: 29,
|
|
38
|
+
columnNumber: 9
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
fileName: import.meta.url,
|
|
43
|
+
lineNumber: 24,
|
|
44
|
+
columnNumber: 7
|
|
45
|
+
}), ")"];
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
fileName: import.meta.url,
|
|
49
|
+
lineNumber: 22,
|
|
50
|
+
columnNumber: 5
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=FunctionCallExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["For","Indent","Wrap","FunctionCallExpression","props","_$createIntrinsic","children","_$memo","target","_$createComponent","when","args","length","softline","trailingBreak","each","comma","line","arg","fileName","import","meta","url","lineNumber","columnNumber"],"sources":["../../../../src/components/FunctionCallExpression.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAmBA,GAAG,EAAEC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;AAO5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAACC,KAAkC,EAAE;EACzE,OAAAC,iBAAA;IAAA,IAAAC,SAAA;MAAA,QAAAC,MAAA,OAEKH,KAAK,CAACI,MAAM,+BAAAC,iBAAA,CACZP,IAAI;QAAA,IACHQ,IAAIA,CAAA;UAAA,OAAE,CAAC,CAACN,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACO,IAAI,CAACC,MAAM,GAAG,CAAC;QAAA;QAAA,QACrCX,MAAM;QACZG,KAAK,EAAE;UAAES,QAAQ,EAAE,IAAI;UAAEC,aAAa,EAAE;QAAK,CAAC;QAAA,IAAAR,SAAA;UAAA,OAAAG,iBAAA,CAE7CT,GAAG;YAAA,IAACe,IAAIA,CAAA;cAAA,OAAEX,KAAK,CAACO,IAAI,IAAI,EAAE;YAAA;YAAEK,KAAK;YAACC,IAAI;YAAAX,QAAA,EACnCY,GAAG,IAAKA;UAAG;YAAAC,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;AAMvB","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createFunctionSymbol } from "../symbols/factories.js";
|
|
3
|
+
import { BaseFunctionDeclaration } from "./FunctionBase.js";
|
|
4
|
+
|
|
5
|
+
// Types are sourced from FunctionBase to avoid duplicate exports
|
|
6
|
+
|
|
7
|
+
// Clean public interface extending common properties
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A Python function declaration.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <FunctionDeclaration
|
|
15
|
+
* name="my_function"
|
|
16
|
+
* returnType="int"
|
|
17
|
+
* parameters={[{ name: "a", type: { children: "int" } }, { name: "b", type: { children: "str" } }]}
|
|
18
|
+
* >
|
|
19
|
+
* return a + b
|
|
20
|
+
* </FunctionDeclaration>
|
|
21
|
+
* ```
|
|
22
|
+
* This will generate:
|
|
23
|
+
* ```python
|
|
24
|
+
* def my_function(a: int, b: str) -> int:
|
|
25
|
+
* return a + b
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This component creates a Python function declaration with optional type annotations,
|
|
30
|
+
* parameters, and return types. It supports async functions and automatically
|
|
31
|
+
* handles symbol creation and emission.
|
|
32
|
+
*/
|
|
33
|
+
export function FunctionDeclaration(props) {
|
|
34
|
+
const sym = createFunctionSymbol(props.name, {
|
|
35
|
+
refkeys: props.refkey
|
|
36
|
+
});
|
|
37
|
+
return _$createComponent(BaseFunctionDeclaration, _$mergeProps(props, {
|
|
38
|
+
sym: sym
|
|
39
|
+
}), {
|
|
40
|
+
fileName: import.meta.url,
|
|
41
|
+
lineNumber: 36,
|
|
42
|
+
columnNumber: 10
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=FunctionDeclaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFunctionSymbol","BaseFunctionDeclaration","FunctionDeclaration","props","sym","name","refkeys","refkey","_$createComponent","_$mergeProps","fileName","import","meta","url","lineNumber","columnNumber"],"sources":["../../../../src/components/FunctionDeclaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,oBAAoB,QAAQ,yBAAyB;AAE9D,SAASC,uBAAuB,QAAQ,mBAAmB;;AAE3D;;AAEA;;AAGA;AACA;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,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAMC,GAAG,GAAGJ,oBAAoB,CAACG,KAAK,CAACE,IAAI,EAAE;IAAEC,OAAO,EAAEH,KAAK,CAACI;EAAO,CAAC,CAAC;EACvE,OAAAC,iBAAA,CAAQP,uBAAuB,EAAAQ,YAAA,CAAKN,KAAK;IAAEC,GAAG,EAAEA;EAAG;IAAAM,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AACrD","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A future statement that imports features from __future__.
|
|
4
|
+
*
|
|
5
|
+
* Future statements are directives to the compiler that a particular module
|
|
6
|
+
* should be compiled using syntax or semantics from a future Python release.
|
|
7
|
+
* They must appear near the top of the module, after the module docstring (if any).
|
|
8
|
+
*
|
|
9
|
+
* Use this in the `futureImports` prop of SourceFile to ensure proper placement.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <SourceFile path="models.py" futureImports={<FutureStatement feature="annotations" />}>
|
|
14
|
+
* <ClassDeclaration name="User">
|
|
15
|
+
* <PropertyDeclaration name="manager" type="User" />
|
|
16
|
+
* </ClassDeclaration>
|
|
17
|
+
* </SourceFile>
|
|
18
|
+
* ```
|
|
19
|
+
* renders to
|
|
20
|
+
* ```py
|
|
21
|
+
* from __future__ import annotations
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* class User:
|
|
25
|
+
* manager: User
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function FutureStatement(props) {
|
|
29
|
+
return ["from __future__ import ", _$memo(() => props.feature, false, "props.feature")];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=FutureStatement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FutureStatement","props","_$memo","feature"],"sources":["../../../../src/components/FutureStatement.tsx"],"sourcesContent":[null],"mappings":";AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAACC,KAA2B,EAAY;EACrE,mCAAAC,MAAA,OAAiCD,KAAK,CAACE,OAAO;AAChD","ignoreList":[]}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { computed, mapJoin, memo } from "@alloy-js/core";
|
|
3
|
+
/**
|
|
4
|
+
* Categorize import records into type-only and value imports.
|
|
5
|
+
* Type-only imports are those used only in type annotation contexts.
|
|
6
|
+
* Value imports are regular imports used at runtime.
|
|
7
|
+
*/
|
|
8
|
+
export function categorizeImportRecords(records) {
|
|
9
|
+
const typeImports = new Map();
|
|
10
|
+
const valueImports = new Map();
|
|
11
|
+
for (const [module, properties] of records) {
|
|
12
|
+
if (!properties.symbols || properties.symbols.size === 0) {
|
|
13
|
+
// Module-level imports without symbols go to value imports
|
|
14
|
+
valueImports.set(module, properties);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const typeSymbols = new Set();
|
|
18
|
+
const valueSymbols = new Set();
|
|
19
|
+
for (const sym of properties.symbols) {
|
|
20
|
+
if (sym.local.isTypeOnly) {
|
|
21
|
+
typeSymbols.add(sym);
|
|
22
|
+
} else {
|
|
23
|
+
valueSymbols.add(sym);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (typeSymbols.size > 0) {
|
|
27
|
+
typeImports.set(module, {
|
|
28
|
+
symbols: typeSymbols
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (valueSymbols.size > 0) {
|
|
32
|
+
valueImports.set(module, {
|
|
33
|
+
symbols: valueSymbols
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
typeImports,
|
|
39
|
+
valueImports
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A component that renders import statements based on the provided import records.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This component will render import statements for each module and its symbols.
|
|
48
|
+
* If `joinImportsFromSameModule` is true, it will group imports from the same module
|
|
49
|
+
* into a single statement.
|
|
50
|
+
*/
|
|
51
|
+
export function ImportStatements(props) {
|
|
52
|
+
// Sort the import records by module name
|
|
53
|
+
const imports = computed(() => {
|
|
54
|
+
return [...props.records].sort(([a], [b]) => {
|
|
55
|
+
return a.name.localeCompare(b.name);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return mapJoin(() => imports.value, ([module, properties]) => {
|
|
59
|
+
// Only handling absolute imports for now
|
|
60
|
+
const targetPath = module.name;
|
|
61
|
+
if (properties.symbols && properties.symbols.size > 0) {
|
|
62
|
+
// Sort the symbols in a module by the imported name
|
|
63
|
+
const sortedSymbols = Array.from(properties.symbols).sort((a, b) => a.local.name.localeCompare(b.local.name));
|
|
64
|
+
if (props.joinImportsFromSameModule) {
|
|
65
|
+
// If joinImportsFromSameModule is true, we will group imports from the same module
|
|
66
|
+
return _$createComponent(ImportStatement, {
|
|
67
|
+
path: targetPath,
|
|
68
|
+
symbols: new Set(sortedSymbols)
|
|
69
|
+
}, {
|
|
70
|
+
fileName: import.meta.url,
|
|
71
|
+
lineNumber: 86,
|
|
72
|
+
columnNumber: 13
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
return sortedSymbols.map((symbol, idx, arr) => [_$createComponent(ImportStatement, {
|
|
76
|
+
path: targetPath,
|
|
77
|
+
symbols: new Set([symbol])
|
|
78
|
+
}, {
|
|
79
|
+
fileName: import.meta.url,
|
|
80
|
+
lineNumber: 94,
|
|
81
|
+
columnNumber: 15
|
|
82
|
+
}), idx < arr.length - 1 && _$createIntrinsic("hbr", {}, {
|
|
83
|
+
fileName: import.meta.url,
|
|
84
|
+
lineNumber: 95,
|
|
85
|
+
columnNumber: 50
|
|
86
|
+
})]);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// If no symbols are specified, it's either a wildcard import or a module import
|
|
90
|
+
return _$createComponent(ImportStatement, {
|
|
91
|
+
path: targetPath,
|
|
92
|
+
get symbols() {
|
|
93
|
+
return properties.symbols;
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
fileName: import.meta.url,
|
|
97
|
+
lineNumber: 102,
|
|
98
|
+
columnNumber: 11
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A Python import statement.
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* This component renders an import statement for a given path and symbols.
|
|
108
|
+
* If no symbols are provided, it will render a simple import statement.
|
|
109
|
+
* If symbols are provided, it will render an import statement with the specified symbols.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* <ImportStatement path="os" />
|
|
114
|
+
* <ImportStatement path="math" symbols={new Set([new ImportedSymbol("sqrt", "sqrt")])} />
|
|
115
|
+
* ```
|
|
116
|
+
* This will generate:
|
|
117
|
+
* ```python
|
|
118
|
+
* import os
|
|
119
|
+
* from math import sqrt
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function ImportStatement(props) {
|
|
123
|
+
return memo(() => {
|
|
124
|
+
const {
|
|
125
|
+
path,
|
|
126
|
+
symbols
|
|
127
|
+
} = props;
|
|
128
|
+
const importSymbols = [];
|
|
129
|
+
if (symbols && symbols.size > 0) {
|
|
130
|
+
for (const sym of symbols) {
|
|
131
|
+
importSymbols.push(sym);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const parts = [];
|
|
135
|
+
if (!symbols || symbols.size === 0) {
|
|
136
|
+
parts.push(`import ${path}`);
|
|
137
|
+
} else {
|
|
138
|
+
importSymbols.sort((a, b) => {
|
|
139
|
+
return a.target.name.localeCompare(b.target.name);
|
|
140
|
+
});
|
|
141
|
+
parts.push(`from ${path} import `);
|
|
142
|
+
parts.push(mapJoin(() => importSymbols, nis => _$createComponent(ImportBinding, {
|
|
143
|
+
importedSymbol: nis
|
|
144
|
+
}, {
|
|
145
|
+
fileName: import.meta.url,
|
|
146
|
+
lineNumber: 156,
|
|
147
|
+
columnNumber: 20
|
|
148
|
+
}), {
|
|
149
|
+
joiner: ", "
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
return parts;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function ImportBinding(props) {
|
|
156
|
+
const text = memo(() => {
|
|
157
|
+
const localName = props.importedSymbol.local.name;
|
|
158
|
+
const targetName = props.importedSymbol.target.name;
|
|
159
|
+
if (localName === targetName) {
|
|
160
|
+
return targetName;
|
|
161
|
+
} else {
|
|
162
|
+
return `${targetName} as ${localName}`;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return [_$memo(text, false, "text")];
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=ImportStatement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["computed","mapJoin","memo","categorizeImportRecords","records","typeImports","Map","valueImports","module","properties","symbols","size","set","typeSymbols","Set","valueSymbols","sym","local","isTypeOnly","add","ImportStatements","props","imports","sort","a","b","name","localeCompare","value","targetPath","sortedSymbols","Array","from","joinImportsFromSameModule","_$createComponent","ImportStatement","path","fileName","import","meta","url","lineNumber","columnNumber","map","symbol","idx","arr","length","_$createIntrinsic","importSymbols","push","parts","target","nis","ImportBinding","importedSymbol","joiner","text","localName","targetName","_$memo"],"sources":["../../../../src/components/ImportStatement.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,IAAI,QAAQ,gBAAgB;AAexD;AACA;AACA;AACA;AACA;AACA,OAAO,SA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AAU,CAAC;MAClCe,KAAK,CAACD,IAAI,CACRjD,OAAO,CACL,MAAMgD,aAAa,EAClBI,GAAG,IAAAnB,iBAAA,CAAMoB,aAAa;QAACC,cAAc,EAAEF;MAAG;QAAAhB,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;QAAAC,UAAA;QAAAC,YAAA;MAAA,EAAI,EAC/C;QAAEc,MAAM,EAAE;MAAK,CACjB,CACF,CAAC;IACH;IACA,OAAOL,KAAK;EACd,CAAC,CAAC;AACJ;AAMA,SAASG,aAAaA,CAACjC,KAAmC,EAAE;EAC1D,MAAMoC,IAAI,GAAGvD,IAAI,CAAC,MAAM;IACtB,MAAMwD,SAAS,GAAGrC,KAAK,CAACkC,cAAc,CAACtC,KAAK,CAACS,IAAI;IACjD,MAAMiC,UAAU,GAAGtC,KAAK,CAACkC,cAAc,CAACH,MAAM,CAAC1B,IAAI;IACnD,IAAIgC,SAAS,KAAKC,UAAU,EAAE;MAC5B,OAAOA,UAAU;IACnB,CAAC,MAAM;MACL,OAAO,GAAGA,UAAU,OAAOD,SAAS,EAAE;IACxC;EACF,CAAC,CAAC;EAEF,QAAAE,MAAA,CAAUH,IAAI;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Scope } from "@alloy-js/core";
|
|
3
|
+
import { createLexicalScope } from "../symbol-creation.js";
|
|
4
|
+
import { PythonLexicalScope } from "../symbols/python-lexical-scope.js";
|
|
5
|
+
export function LexicalScope(props) {
|
|
6
|
+
let scope;
|
|
7
|
+
if ("value" in props) {
|
|
8
|
+
if (!(props.value instanceof PythonLexicalScope)) {
|
|
9
|
+
throw new Error("LexicalScope value must be a TSLexicalScope instance");
|
|
10
|
+
}
|
|
11
|
+
scope = props.value;
|
|
12
|
+
} else {
|
|
13
|
+
scope = createLexicalScope(props.name ?? "Lexical scope", props);
|
|
14
|
+
}
|
|
15
|
+
return _$createComponent(Scope, {
|
|
16
|
+
value: scope,
|
|
17
|
+
get children() {
|
|
18
|
+
return props.children;
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
fileName: import.meta.url,
|
|
22
|
+
lineNumber: 23,
|
|
23
|
+
columnNumber: 10
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=LexicalScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Scope","createLexicalScope","PythonLexicalScope","LexicalScope","props","scope","value","Error","name","_$createComponent","children","fileName","import","meta","url","lineNumber","columnNumber"],"sources":["../../../../src/components/LexicalScope.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,KAAK,QAAiD,gBAAgB;AAC/E,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,kBAAkB,QAAQ,oCAAoC;AASvE,OAAO,SAASC,YAAYA,CAACC,KAAwB,EAAE;EACrD,IAAIC,KAAK;EACT,IAAI,OAAO,IAAID,KAAK,EAAE;IACpB,IAAI,EAAEA,KAAK,CAACE,KAAK,YAAYJ,kBAAkB,CAAC,EAAE;MAChD,MAAM,IAAIK,KAAK,CAAC,sDAAsD,CAAC;IACzE;IACAF,KAAK,GAAGD,KAAK,CAACE,KAAK;EACrB,CAAC,MAAM;IACLD,KAAK,GAAGJ,kBAAkB,CAACG,KAAK,CAACI,IAAI,IAAI,eAAe,EAAEJ,KAAK,CAAC;EAClE;EAEA,OAAAK,iBAAA,CAAQT,KAAK;IAACM,KAAK,EAAED,KAAK;IAAA,IAAAK,SAAA;MAAA,OAAGN,KAAK,CAACM,QAAQ;IAAA;EAAA;IAAAC,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;IAAAC,UAAA;IAAAC,YAAA;EAAA;AAC7C","ignoreList":[]}
|