@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,28 @@
|
|
|
1
|
+
import { createPythonSymbol } from "../symbol-creation.js";
|
|
2
|
+
import { usePythonScope } from "./scopes.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a function symbol in the current scope.
|
|
6
|
+
*/
|
|
7
|
+
export function createFunctionSymbol(name, options = {}) {
|
|
8
|
+
return createPythonSymbol(name, {
|
|
9
|
+
instance: false,
|
|
10
|
+
refkeys: options.refkeys
|
|
11
|
+
}, "function");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates a method symbol in a class. Validates that the current scope is a member scope.
|
|
16
|
+
*/
|
|
17
|
+
export function createMethodSymbol(name, options = {}) {
|
|
18
|
+
const scope = usePythonScope();
|
|
19
|
+
if (!scope?.isMemberScope) {
|
|
20
|
+
const displayName = typeof name === "string" ? name : name.name;
|
|
21
|
+
throw new Error(`Method "${displayName}" must be declared inside a class (member scope)`);
|
|
22
|
+
}
|
|
23
|
+
return createPythonSymbol(name, {
|
|
24
|
+
instance: true,
|
|
25
|
+
refkeys: options.refkeys
|
|
26
|
+
}, "function");
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=factories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPythonSymbol","usePythonScope","createFunctionSymbol","name","options","instance","refkeys","createMethodSymbol","scope","isMemberScope","displayName","Error"],"sources":["../../../../src/symbols/factories.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,kBAAkB,QAAQ,uBAAuB;AAE1D,SAASC,cAAc,QAAQ,aAAa;;AAE5C;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,IAAsB,EACtBC,OAA0B,GAAG,CAAC,CAAC,EACX;EACpB,OAAOJ,kBAAkB,CACvBG,IAAI,EACJ;IAAEE,QAAQ,EAAE,KAAK;IAAEC,OAAO,EAAEF,OAAO,CAACE;EAAQ,CAAC,EAC7C,UACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCJ,IAAsB,EACtBC,OAA0B,GAAG,CAAC,CAAC,EACX;EACpB,MAAMI,KAAK,GAAGP,cAAc,CAAC,CAAC;EAC9B,IAAI,CAACO,KAAK,EAAEC,aAAa,EAAE;IACzB,MAAMC,WAAW,GAAG,OAAOP,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACA,IAAI;IAC/D,MAAM,IAAIQ,KAAK,CACb,WAAWD,WAAW,kDACxB,CAAC;EACH;EACA,OAAOV,kBAAkB,CACvBG,IAAI,EACJ;IAAEE,QAAQ,EAAE,IAAI;IAAEC,OAAO,EAAEF,OAAO,CAACE;EAAQ,CAAC,EAC5C,UACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./factories.js";
|
|
2
|
+
export * from "./python-lexical-scope.js";
|
|
3
|
+
export * from "./python-member-scope.js";
|
|
4
|
+
export * from "./python-module-scope.js";
|
|
5
|
+
export * from "./python-output-symbol.js";
|
|
6
|
+
export * from "./reference.js";
|
|
7
|
+
export * from "./scopes.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/symbols/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,2BAA2B;AACzC,cAAc,0BAA0B;AACxC,cAAc,0BAA0B;AACxC,cAAc,2BAA2B;AACzC,cAAc,gBAAgB;AAC9B,cAAc,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OutputScope } from "@alloy-js/core";
|
|
2
|
+
export class PythonLexicalScope extends OutputScope {
|
|
3
|
+
static declarationSpaces = ["symbols"];
|
|
4
|
+
get symbols() {
|
|
5
|
+
return this.spaceFor("symbols");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Lexical scopes do not have an owner symbol. This ensures that we get the
|
|
9
|
+
// correct type when using `usePythonScope` (i.e. we don't get the
|
|
10
|
+
// OutputScope's `OutputSymbol | undefined` type).
|
|
11
|
+
get ownerSymbol() {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=python-lexical-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OutputScope","PythonLexicalScope","declarationSpaces","symbols","spaceFor","ownerSymbol","undefined"],"sources":["../../../../src/symbols/python-lexical-scope.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAE5C,OAAO,MAAMC,kBAAkB,SAASD,WAAW,CAAC;EAClD,OAAuBE,iBAAiB,GAAsB,CAAC,SAAS,CAAC;EAEzE,IAAIC,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,QAAQ,CAAC,SAAS,CAAC;EACjC;;EAEA;EACA;EACA;EACA,IAAIC,WAAWA,CAAA,EAAc;IAC3B,OAAOC,SAAS;EAClB;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OutputScope","PythonMemberScope","ownerSymbol"],"sources":["../../../../src/symbols/python-member-scope.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAG5C,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EACjD,IAAIE,WAAWA,CAAA,EAAG;IAChB,OAAO,KAAK,CAACA,WAAW;EAC1B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createSymbol, reactive, shallowReactive } from "@alloy-js/core";
|
|
2
|
+
import { PythonLexicalScope } from "./python-lexical-scope.js";
|
|
3
|
+
import { PythonOutputSymbol } from "./python-output-symbol.js";
|
|
4
|
+
|
|
5
|
+
// Internal typing module for TYPE_CHECKING imports
|
|
6
|
+
let _typingModuleScope;
|
|
7
|
+
let _typeCheckingSymbol;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the internal typing module scope and TYPE_CHECKING symbol.
|
|
11
|
+
* Used by addTypeImport() to add TYPE_CHECKING imports without
|
|
12
|
+
* going through the binder's refkey resolution.
|
|
13
|
+
*/
|
|
14
|
+
function getTypingModuleInternal() {
|
|
15
|
+
if (!_typingModuleScope) {
|
|
16
|
+
_typingModuleScope = new PythonModuleScope("typing", undefined);
|
|
17
|
+
_typeCheckingSymbol = new PythonOutputSymbol("TYPE_CHECKING", _typingModuleScope.symbols, {});
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
scope: _typingModuleScope,
|
|
21
|
+
TYPE_CHECKING: _typeCheckingSymbol
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export class ImportedSymbol {
|
|
25
|
+
constructor(target, local) {
|
|
26
|
+
this.target = target;
|
|
27
|
+
this.local = local;
|
|
28
|
+
}
|
|
29
|
+
static from(target, local) {
|
|
30
|
+
return new ImportedSymbol(target, local);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class ImportRecords extends Map {}
|
|
34
|
+
export class PythonModuleScope extends PythonLexicalScope {
|
|
35
|
+
#importedSymbols = shallowReactive(new Map());
|
|
36
|
+
get importedSymbols() {
|
|
37
|
+
return this.#importedSymbols;
|
|
38
|
+
}
|
|
39
|
+
#importedModules = reactive(new Map());
|
|
40
|
+
get importedModules() {
|
|
41
|
+
return this.#importedModules;
|
|
42
|
+
}
|
|
43
|
+
addImport(targetSymbol, targetModule, options) {
|
|
44
|
+
const existing = this.importedSymbols.get(targetSymbol);
|
|
45
|
+
if (existing) {
|
|
46
|
+
// If existing is type-only but now used as value, upgrade it
|
|
47
|
+
if (!options?.type && existing.isTypeOnly) {
|
|
48
|
+
existing.markAsValue();
|
|
49
|
+
}
|
|
50
|
+
return existing;
|
|
51
|
+
}
|
|
52
|
+
if (!this.importedModules.has(targetModule)) {
|
|
53
|
+
this.importedModules.set(targetModule, {
|
|
54
|
+
symbols: new Set()
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const localSymbol = createSymbol(PythonOutputSymbol, targetSymbol.name, this.symbols, {
|
|
58
|
+
binder: this.binder,
|
|
59
|
+
aliasTarget: targetSymbol,
|
|
60
|
+
typeOnly: options?.type
|
|
61
|
+
});
|
|
62
|
+
this.importedSymbols.set(targetSymbol, localSymbol);
|
|
63
|
+
this.importedModules.get(targetModule).symbols?.add({
|
|
64
|
+
local: localSymbol,
|
|
65
|
+
target: targetSymbol
|
|
66
|
+
});
|
|
67
|
+
return localSymbol;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Add TYPE_CHECKING import from the typing module.
|
|
72
|
+
* Returns the local symbol for use in the if block opener.
|
|
73
|
+
*/
|
|
74
|
+
addTypeImport() {
|
|
75
|
+
const typing = getTypingModuleInternal();
|
|
76
|
+
return this.addImport(typing.TYPE_CHECKING, typing.scope);
|
|
77
|
+
}
|
|
78
|
+
get debugInfo() {
|
|
79
|
+
return {
|
|
80
|
+
...super.debugInfo,
|
|
81
|
+
importedSymbolCount: this.#importedSymbols.size,
|
|
82
|
+
importedModuleCount: this.#importedModules.size
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=python-module-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSymbol","reactive","shallowReactive","PythonLexicalScope","PythonOutputSymbol","_typingModuleScope","_typeCheckingSymbol","getTypingModuleInternal","PythonModuleScope","undefined","symbols","scope","TYPE_CHECKING","ImportedSymbol","constructor","target","local","from","ImportRecords","Map","importedSymbols","importedModules","addImport","targetSymbol","targetModule","options","existing","get","type","isTypeOnly","markAsValue","has","set","Set","localSymbol","name","binder","aliasTarget","typeOnly","add","addTypeImport","typing","debugInfo","importedSymbolCount","size","importedModuleCount"],"sources":["../../../../src/symbols/python-module-scope.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,gBAAgB;AACxE,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,SAASC,kBAAkB,QAAQ,2BAA2B;;AAE9D;AACA,IAAIC,kBAAiD;AACrD,IAAIC,mBAAmD;;AAEvD;AACA;AACA;AACA;AACA;AACA,SAASC,uBAAuBA,CAAA,EAG9B;EACA,IAAI,CAACF,kBAAkB,EAAE;IACvBA,kBAAkB,GAAG,IAAIG,iBAAiB,CAAC,QAAQ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ACU,GAAG,CAACP,YAAY,CAAC,EAAE;MAC3C,IAAI,CAACH,eAAe,CAACW,GAAG,CAACR,YAAY,EAAE;QACrCd,OAAO,EAAE,IAAIuB,GAAG,CAAiB;MACnC,CAAC,CAAC;IACJ;IAEA,MAAMC,WAAW,GAAGlC,YAAY,CAC9BI,kBAAkB,EAClBmB,YAAY,CAACY,IAAI,EACjB,IAAI,CAACzB,OAAO,EACZ;MACE0B,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,WAAW,EAAEd,YAAY;MACzBe,QAAQ,EAAEb,OAAO,EAAEG;IACrB,CACF,CAAC;IAED,IAAI,CAACR,eAAe,CAACY,GAAG,CAACT,YAAY,EAAEW,WAAW,CAAC;IACnD,IAAI,CAACb,eAAe,CAACM,GAAG,CAACH,YAAY,CAAC,CAAEd,OAAO,EAAE6B,GAAG,CAAC;MACnDvB,KAAK,EAAEkB,WAAW;MAClBnB,MAAM,EAAEQ;IACV,CAAC,CAAC;IAEF,OAAOW,WAAW;EACpB;;EAEA;AACF;AACA;AACA;EACEM,aAAaA,CAAA,EAAuB;IAClC,MAAMC,MAAM,GAAGlC,uBAAuB,CAAC,CAAC;IACxC,OAAO,IAAI,CAACe,SAAS,CAACmB,MAAM,CAAC7B,aAAa,EAAE6B,MAAM,CAAC9B,KAAK,CAAC;EAC3D;EAEA,IAAa+B,SAASA,CAAA,EAA4B;IAChD,OAAO;MACL,GAAG,KAAK,CAACA,SAAS;MAClBC,mBAAmB,EAAE,IAAI,CAAC,CAACvB,eAAe,CAACwB,IAAI;MAC/CC,mBAAmB,EAAE,IAAI,CAAC,CAACxB,eAAe,CAACuB;IAC7C,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createSymbol, OutputSymbol, track, TrackOpTypes, trigger, TriggerOpTypes } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an 'exported' symbol from a .py file. Class, enum, interface etc.
|
|
4
|
+
*/
|
|
5
|
+
export class PythonOutputSymbol extends OutputSymbol {
|
|
6
|
+
static memberSpaces = ["static", "instance"];
|
|
7
|
+
constructor(name, spaces, options) {
|
|
8
|
+
super(name, spaces, options);
|
|
9
|
+
this.#module = options.module ?? undefined;
|
|
10
|
+
this.#typeOnly = options.typeOnly ?? false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// The module in which the symbol is defined
|
|
14
|
+
#module;
|
|
15
|
+
get module() {
|
|
16
|
+
return this.#module;
|
|
17
|
+
}
|
|
18
|
+
#typeOnly;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if this symbol is only used in type annotation contexts.
|
|
22
|
+
* Such symbols can be imported inside a TYPE_CHECKING block.
|
|
23
|
+
*/
|
|
24
|
+
get isTypeOnly() {
|
|
25
|
+
track(this, TrackOpTypes.GET, "typeOnly");
|
|
26
|
+
return this.#typeOnly;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Mark this symbol as also being used as a value (not just a type).
|
|
31
|
+
*/
|
|
32
|
+
markAsValue() {
|
|
33
|
+
if (!this.#typeOnly) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const oldValue = this.#typeOnly;
|
|
37
|
+
this.#typeOnly = false;
|
|
38
|
+
trigger(this, TriggerOpTypes.SET, "typeOnly", false, oldValue);
|
|
39
|
+
}
|
|
40
|
+
get staticMembers() {
|
|
41
|
+
return this.memberSpaceFor("static");
|
|
42
|
+
}
|
|
43
|
+
get instanceMembers() {
|
|
44
|
+
return this.memberSpaceFor("instance");
|
|
45
|
+
}
|
|
46
|
+
get isStaticMemberSymbol() {
|
|
47
|
+
return !this.isInstanceMemberSymbol;
|
|
48
|
+
}
|
|
49
|
+
get isInstanceMemberSymbol() {
|
|
50
|
+
return this.spaces.some(s => s.key === "instance");
|
|
51
|
+
}
|
|
52
|
+
get debugInfo() {
|
|
53
|
+
return {
|
|
54
|
+
...super.debugInfo,
|
|
55
|
+
module: this.#module,
|
|
56
|
+
isStaticMemberSymbol: this.isStaticMemberSymbol,
|
|
57
|
+
isInstanceMemberSymbol: this.isInstanceMemberSymbol
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
copy() {
|
|
61
|
+
const binder = this.binder;
|
|
62
|
+
const copy = createSymbol(PythonOutputSymbol, this.name, undefined, {
|
|
63
|
+
binder,
|
|
64
|
+
aliasTarget: this.aliasTarget,
|
|
65
|
+
module: this.module,
|
|
66
|
+
metadata: this.metadata,
|
|
67
|
+
typeOnly: this.isTypeOnly
|
|
68
|
+
});
|
|
69
|
+
this.initializeCopy(copy);
|
|
70
|
+
return copy;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=python-output-symbol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSymbol","OutputSymbol","track","TrackOpTypes","trigger","TriggerOpTypes","PythonOutputSymbol","memberSpaces","constructor","name","spaces","options","module","undefined","typeOnly","isTypeOnly","GET","markAsValue","oldValue","SET","staticMembers","memberSpaceFor","instanceMembers","isStaticMemberSymbol","isInstanceMemberSymbol","some","s","key","debugInfo","copy","binder","aliasTarget","metadata","initializeCopy"],"sources":["../../../../src/symbols/python-output-symbol.ts"],"sourcesContent":[null],"mappings":"AAAA,SACEA,YAAY,EAGZC,YAAY,EAEZC,KAAK,EACLC,YAAY,EACZC,OAAO,EACPC,cAAc,QACT,gBAAgB;AAavB;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASL,YAAY,CAAC;EACnD,OAAgBM,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC;EAErDC,WAAWA,CACTC,IAAsB,EACtBC,MAA+C,EAC/CC,OAAkC,EAClC;IACA,KAAK,CAACF,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;IAC5B,IAAI,CAAC,CAACC,MAAM,GAAGD,OAAO,CAACC,MAAM,IAAIC,SAAS;IAC1C,IAAI,CAAC,CAACC,Q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EACH;EAEAK,IAAIA,CAAA,EAAG;IACL,MAAMC,MAAM,GAAG,IAAI,CAACA,MAAM;IAC1B,MAAMD,IAAI,GAAG7B,YAAY,CAACM,kBAAkB,EAAE,IAAI,CAACG,IAAI,EAAEI,SAAS,EAAE;MAClEiB,MAAM;MACNC,WAAW,EAAE,IAAI,CAACA,WAAW;MAC7BnB,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBoB,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBlB,QAAQ,EAAE,IAAI,CAACC;IACjB,CAAC,CAAC;IAEF,IAAI,CAACkB,cAAc,CAACJ,IAAI,CAAC;IAEzB,OAAOA,IAAI;EACb;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { memo, resolve, unresolvedRefkey, untrack, useContext } from "@alloy-js/core";
|
|
3
|
+
import { MemberExpression } from "../components/MemberExpression.js";
|
|
4
|
+
import { PythonSourceFileContext } from "../components/SourceFile.js";
|
|
5
|
+
import { PythonModuleScope } from "./python-module-scope.js";
|
|
6
|
+
export function ref(refkey, options) {
|
|
7
|
+
const sourceFile = useContext(PythonSourceFileContext);
|
|
8
|
+
const resolveResult = resolve(refkey);
|
|
9
|
+
return memo(() => {
|
|
10
|
+
if (resolveResult.value === undefined) {
|
|
11
|
+
return [unresolvedRefkey(refkey), undefined];
|
|
12
|
+
}
|
|
13
|
+
const {
|
|
14
|
+
commonScope,
|
|
15
|
+
lexicalDeclaration,
|
|
16
|
+
symbol,
|
|
17
|
+
pathDown,
|
|
18
|
+
memberPath
|
|
19
|
+
} = resolveResult.value;
|
|
20
|
+
|
|
21
|
+
// Where the target declaration is relative to the referencing scope.
|
|
22
|
+
// * module: target symbol is in a different module
|
|
23
|
+
// * local: target symbol is within the current module
|
|
24
|
+
const targetLocation = pathDown[0] instanceof PythonModuleScope ? "module" : "local";
|
|
25
|
+
let localSymbol;
|
|
26
|
+
if (targetLocation === "module") {
|
|
27
|
+
localSymbol = untrack(() => sourceFile.scope.addImport(lexicalDeclaration, pathDown[0], {
|
|
28
|
+
type: options?.type
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
const parts = [];
|
|
32
|
+
if (commonScope && commonScope.isMemberScope) {
|
|
33
|
+
// we are referencing a member of a type we are inside
|
|
34
|
+
if (lexicalDeclaration.isInstanceMemberSymbol) {
|
|
35
|
+
parts.push(_$createComponent(MemberExpression.Part, {
|
|
36
|
+
id: "self"
|
|
37
|
+
}, {
|
|
38
|
+
fileName: import.meta.url,
|
|
39
|
+
lineNumber: 63,
|
|
40
|
+
columnNumber: 20
|
|
41
|
+
}));
|
|
42
|
+
} else {
|
|
43
|
+
parts.push(_$createComponent(MemberExpression.Part, {
|
|
44
|
+
get symbol() {
|
|
45
|
+
return commonScope.ownerSymbol;
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
fileName: import.meta.url,
|
|
49
|
+
lineNumber: 65,
|
|
50
|
+
columnNumber: 20
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
parts.push(_$createComponent(MemberExpression.Part, {
|
|
54
|
+
symbol: lexicalDeclaration
|
|
55
|
+
}, {
|
|
56
|
+
fileName: import.meta.url,
|
|
57
|
+
lineNumber: 67,
|
|
58
|
+
columnNumber: 18
|
|
59
|
+
}));
|
|
60
|
+
} else {
|
|
61
|
+
parts.push(_$createComponent(MemberExpression.Part, {
|
|
62
|
+
symbol: localSymbol ?? lexicalDeclaration
|
|
63
|
+
}, {
|
|
64
|
+
fileName: import.meta.url,
|
|
65
|
+
lineNumber: 70,
|
|
66
|
+
columnNumber: 9
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
for (const part of memberPath) {
|
|
70
|
+
parts.push(_$createComponent(MemberExpression.Part, {
|
|
71
|
+
symbol: part
|
|
72
|
+
}, {
|
|
73
|
+
fileName: import.meta.url,
|
|
74
|
+
lineNumber: 74,
|
|
75
|
+
columnNumber: 18
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return [_$createComponent(MemberExpression, {
|
|
79
|
+
children: parts
|
|
80
|
+
}, {
|
|
81
|
+
fileName: import.meta.url,
|
|
82
|
+
lineNumber: 77,
|
|
83
|
+
columnNumber: 13
|
|
84
|
+
}), localSymbol ?? symbol];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memo","resolve","unresolvedRefkey","untrack","useContext","MemberExpression","PythonSourceFileContext","PythonModuleScope","ref","refkey","options","sourceFile","resolveResult","value","undefined","commonScope","lexicalDeclaration","symbol","pathDown","memberPath","targetLocation","localSymbol","scope","addImport","type","parts","isMemberScope","isInstanceMemberSymbol","push","_$createComponent","Part","id","fileName","import","meta","url","lineNumber","columnNumber","ownerSymbol","part","children"],"sources":["../../../../src/symbols/reference.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,IAAI,EAEJC,OAAO,EACPC,gBAAgB,EAChBC,OAAO,EACPC,UAAU,QACL,gBAAgB;AACvB,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAChC,SAASC,iBAAiB,QAAQ,0BAA0B;AAY5D,OAAO,SAASC,GAAGA,CACjBC,MAAc,EACdC,OAAoB,EAC8B;EAClD,MAAMC,UAAU,GAAGP,UAAU,CAACE,uBAAuB,CAAC;EACtD,MAAMM,aAAa,GAAGX,OAAO,CAC3BQ,MACF,CAAC;EAED,OAAOT,IAAI,CAAC,MAAM;IAChB,IAAIY,aAAa,CAACC,KAAK,KAAKC,SAAS,EAAE;MACrC,OAAO,CAACZ,gBAAgB,CAACO,MAAM,CAAC,EAAEK,SAAS,CAAC;IAC9C;IAEA,MAAM;MAAEC,WAAW;MAAEC,kBAAkB;MAAEC,MAAM;MAAEC,QAAQ;MAAEC;IAAW,CAAC,GACrEP,aAAa,CAACC,KAAK;;IAErB;IACA;IACA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AkB;QAAAgB,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;QAAAC,UAAA;QAAAC,YAAA;MAAA,EAClE,CAAC;IACH;IACA,KAAK,MAAME,IAAI,IAAIpB,UAAU,EAAE;MAC7BM,KAAK,CAACG,IAAI,CAAAC,iBAAA,CAAExB,gBAAgB,CAACyB,IAAI;QAACb,MAAM,EAAEsB;MAAI;QAAAP,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;QAAAC,UAAA;QAAAC,YAAA;MAAA,EAAI,CAAC;IACrD;IAEA,OAAO,CAAAR,iBAAA,CAAExB,gBAAgB;MAACmC,QAAQ,EAAEf;IAAK;MAAAO,QAAA,EAAAC,MAAA,CAAAC,IAAA,CAAAC,GAAA;MAAAC,UAAA;MAAAC,YAAA;IAAA,IAAMhB,WAAW,IAAIJ,MAAM,CAAC;EACvE,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useScope } from "@alloy-js/core";
|
|
2
|
+
import { PythonLexicalScope } from "./python-lexical-scope.js";
|
|
3
|
+
export function usePythonScope() {
|
|
4
|
+
return useScope();
|
|
5
|
+
}
|
|
6
|
+
export function usePythonLexicalScope() {
|
|
7
|
+
const scope = usePythonScope();
|
|
8
|
+
if (!(scope instanceof PythonLexicalScope)) {
|
|
9
|
+
throw new Error("Expected a PythonLexicalScope, but got " + scope.constructor.name);
|
|
10
|
+
}
|
|
11
|
+
return scope;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useScope","PythonLexicalScope","usePythonScope","usePythonLexicalScope","scope","Error","constructor","name"],"sources":["../../../../src/symbols/scopes.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,kBAAkB,QAAQ,2BAA2B;AAS9D,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/B,OAAOF,QAAQ,CAAC,CAAC;AACnB;AAEA,OAAO,SAASG,qBAAqBA,CAAA,EAAG;EACtC,MAAMC,KAAK,GAAGF,cAAc,CAAC,CAAC;EAC9B,IAAI,EAAEE,KAAK,YAAYH,kBAAkB,CAAC,EAAE;IAC1C,MAAM,IAAII,KAAK,CACb,yCAAyC,GAAGD,KAAK,CAACE,WAAW,CAACC,IAChE,CAAC;EACH;EACA,OAAOH,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defaultProps, splitProps } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Extract only the call signature props from a props object which extends
|
|
4
|
+
* `CallSignatureProps`. You can provide default values for the props.
|
|
5
|
+
*/
|
|
6
|
+
export function getCallSignatureProps(props, defaults) {
|
|
7
|
+
const [callSignatureProps] = splitProps(props, ["parameters", "typeParameters", "args", "kwargs", "returnType"]);
|
|
8
|
+
if (!defaults) {
|
|
9
|
+
return callSignatureProps;
|
|
10
|
+
}
|
|
11
|
+
return defaultProps(callSignatureProps, defaults);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["defaultProps","splitProps","getCallSignatureProps","props","defaults","callSignatureProps"],"sources":["../../../src/utils.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AAGzD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,KAAyB,EACzBC,QAAsC,EACtC;EACA,MAAM,CAACC,kBAAkB,CAAC,GAAGJ,UAAU,CAACE,KAAK,EAAE,CAC7C,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,YAAY,CACb,CAAC;EAEF,IAAI,CAACC,QAAQ,EAAE;IACb,OAAOC,kBAAkB;EAC3B;EAEA,OAAOL,YAAY,CAACK,kBAAkB,EAAED,QAAQ,CAAC;AACnD","ignoreList":[]}
|