crankscript 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/plugin.js +2 -1
- package/package.json +2 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +4 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +31 -1
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +32 -2
- package/src/commands/GenerateTypes/utils/createTypeProvider.js +11 -1
- package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +1 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +4 -1
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -1
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
package/assets/plugin.js
CHANGED
@@ -162,7 +162,8 @@ var transformClassDeclaration = function (declaration, context) {
|
|
162
162
|
.map(function (method) { return transformMethodDeclaration(context, method, className); })
|
163
163
|
.filter(function (method) { return method !== undefined; });
|
164
164
|
statements.push.apply(statements, methods);
|
165
|
-
// export
|
165
|
+
// export the class if needed
|
166
|
+
// todo: check if there is a cleaner way to do this
|
166
167
|
if ('localSymbol' in declaration &&
|
167
168
|
typeof declaration.localSymbol === 'object' &&
|
168
169
|
'exportSymbol' in declaration.localSymbol &&
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "crankscript",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.2",
|
4
4
|
"scripts": {
|
5
5
|
"dev": "tsx src/index.ts",
|
6
6
|
"post-build": "tsc-alias --project tsconfig.json",
|
@@ -19,6 +19,7 @@
|
|
19
19
|
"react": "^18.3.1",
|
20
20
|
"tiged": "^3.0.0-rc.0",
|
21
21
|
"ts-morph": "^23.0.0",
|
22
|
+
"turndown": "^7.2.0",
|
22
23
|
"typanion": "^3.14.0",
|
23
24
|
"typescript-to-lua": "^1.27.0"
|
24
25
|
},
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
2
2
|
import { load } from 'cheerio';
|
3
|
+
import Turndown from 'turndown';
|
3
4
|
import { PlaydateSdkUrl } from '../../../commands/GenerateTypes/constants.js';
|
4
5
|
import { parseFunctionSignature } from '../../../commands/GenerateTypes/fn/parseFunctionSignature.js';
|
5
6
|
const extractFunctionCalls = (input)=>{
|
@@ -21,6 +22,7 @@ export const getDescriptionsFromHtml = (html, version)=>{
|
|
21
22
|
const functions = [];
|
22
23
|
const properties = [];
|
23
24
|
const visitedSignatures = [];
|
25
|
+
const turndown = new Turndown();
|
24
26
|
for (const element of functionSignatures){
|
25
27
|
var _$_attr;
|
26
28
|
const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
|
@@ -39,7 +41,8 @@ export const getDescriptionsFromHtml = (html, version)=>{
|
|
39
41
|
docsString = docsString.slice(0, docsString.length - '</div>'.length);
|
40
42
|
}
|
41
43
|
docsString = docsString.replace(/<a href="#/g, '<a href="' + PlaydateSdkUrl + version + '#');
|
42
|
-
|
44
|
+
docsString = turndown.turndown(docsString);
|
45
|
+
const baseDocs = id ? `${docsString}\n\n[Read more](${PlaydateSdkUrl}${version}#${id})` : docsString;
|
43
46
|
for (const title of titles){
|
44
47
|
const signature = normalizeSignature(title);
|
45
48
|
if (visitedSignatures.includes(signature)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('> .title').text();\n\n if (\n titleText.indexOf('#') !== -1 ||\n /[a-zA-Z]\\[/.test(titleText) ||\n /^-[a-zA-Z]/.test(titleText) ||\n /[+*/]/.test(titleText) ||\n titleText.indexOf(' - ') !== -1 ||\n titleText.indexOf(' .. ') !== -1\n ) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n const baseDocs = id\n ? `${docsString}\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.ts"],"sourcesContent":["import { load } from 'cheerio';\nimport Turndown from 'turndown';\nimport { PlaydateSdkUrl } from '@/cli/commands/GenerateTypes/constants.js';\nimport { parseFunctionSignature } from '@/cli/commands/GenerateTypes/fn/parseFunctionSignature.js';\nimport { FunctionDescription, PropertyDescription } from '@/cli/types.js';\n\nconst extractFunctionCalls = (input: string) => {\n const functionCallRegex =\n /([a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*(?::[a-zA-Z_]\\w*)?)\\s*(\\([^)]*\\))?/g;\n const matches: string[] = [];\n let match;\n\n while ((match = functionCallRegex.exec(input)) !== null) {\n matches.push(match[0].trim());\n }\n\n return matches;\n};\n\nconst normalizeSignature = (signature: string) => {\n const closingParenIndex = signature.indexOf(')');\n return closingParenIndex !== -1\n ? signature.slice(0, closingParenIndex + 1)\n : signature;\n};\n\nexport const getDescriptionsFromHtml = (html: string, version: string) => {\n const $ = load(html);\n\n const functionSignatures = $(\n '[id^=\"m-\"], [id^=\"f-\"], [id^=\"c-\"], [id^=\"v-\"]'\n ).toArray();\n const functions: FunctionDescription[] = [];\n const properties: PropertyDescription[] = [];\n const visitedSignatures: string[] = [];\n const turndown = new Turndown();\n\n for (const element of functionSignatures) {\n const id = $(element).attr('id') ?? '';\n const isProperty = id.startsWith('v-');\n const titleText = $(element).find('> .title').text();\n\n if (\n titleText.indexOf('#') !== -1 ||\n /[a-zA-Z]\\[/.test(titleText) ||\n /^-[a-zA-Z]/.test(titleText) ||\n /[+*/]/.test(titleText) ||\n titleText.indexOf(' - ') !== -1 ||\n titleText.indexOf(' .. ') !== -1\n ) {\n continue;\n }\n\n const titles = isProperty\n ? titleText.split(' ')\n : extractFunctionCalls(titleText);\n\n let docsString = ($(element).find('.content').html() ?? '').trim();\n\n if (docsString.startsWith('<div class=\"paragraph\">')) {\n docsString = docsString.slice('<div class=\"paragraph\">'.length);\n }\n\n if (docsString.endsWith('</div>')) {\n docsString = docsString.slice(\n 0,\n docsString.length - '</div>'.length\n );\n }\n\n docsString = docsString.replace(\n /<a href=\"#/g,\n '<a href=\"' + PlaydateSdkUrl + version + '#'\n );\n\n docsString = turndown.turndown(docsString);\n\n const baseDocs = id\n ? `${docsString}\\n\\n[Read more](${PlaydateSdkUrl}${version}#${id})`\n : docsString;\n\n for (const title of titles) {\n const signature = normalizeSignature(title);\n\n if (visitedSignatures.includes(signature)) {\n continue;\n }\n\n visitedSignatures.push(signature);\n\n if (isProperty) {\n properties.push({\n name: title.split('.').slice(-1)[0],\n namespaces: signature.split('.').slice(0, -1),\n signature,\n docs: baseDocs,\n });\n } else {\n try {\n const description = parseFunctionSignature(signature);\n\n const docs = description.hasSelf\n ? baseDocs\n : `${baseDocs}\\n\\n@noSelf`;\n\n functions.push({\n ...description,\n docs,\n });\n } catch (e) {\n // Ignore\n }\n }\n }\n }\n\n return { functions, properties };\n};\n"],"names":["load","Turndown","PlaydateSdkUrl","parseFunctionSignature","extractFunctionCalls","input","functionCallRegex","matches","match","exec","push","trim","normalizeSignature","signature","closingParenIndex","indexOf","slice","getDescriptionsFromHtml","html","version","$","functionSignatures","toArray","functions","properties","visitedSignatures","turndown","element","id","attr","isProperty","startsWith","titleText","find","text","test","titles","split","docsString","length","endsWith","replace","baseDocs","title","includes","name","namespaces","docs","description","hasSelf","e"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,OAAOC,cAAc,WAAW;AAChC,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,sBAAsB,QAAQ,4DAA4D;AAGnG,MAAMC,uBAAuB,CAACC;IAC1B,MAAMC,oBACF;IACJ,MAAMC,UAAoB,EAAE;IAC5B,IAAIC;IAEJ,MAAO,AAACA,CAAAA,QAAQF,kBAAkBG,IAAI,CAACJ,MAAK,MAAO,KAAM;QACrDE,QAAQG,IAAI,CAACF,KAAK,CAAC,EAAE,CAACG,IAAI;IAC9B;IAEA,OAAOJ;AACX;AAEA,MAAMK,qBAAqB,CAACC;IACxB,MAAMC,oBAAoBD,UAAUE,OAAO,CAAC;IAC5C,OAAOD,sBAAsB,CAAC,IACxBD,UAAUG,KAAK,CAAC,GAAGF,oBAAoB,KACvCD;AACV;AAEA,OAAO,MAAMI,0BAA0B,CAACC,MAAcC;IAClD,MAAMC,IAAIpB,KAAKkB;IAEf,MAAMG,qBAAqBD,EACvB,kDACFE,OAAO;IACT,MAAMC,YAAmC,EAAE;IAC3C,MAAMC,aAAoC,EAAE;IAC5C,MAAMC,oBAA8B,EAAE;IACtC,MAAMC,WAAW,IAAIzB;IAErB,KAAK,MAAM0B,WAAWN,mBAAoB;YAC3BD;QAAX,MAAMQ,KAAKR,CAAAA,UAAAA,EAAEO,SAASE,IAAI,CAAC,iBAAhBT,UAAyB;QACpC,MAAMU,aAAaF,GAAGG,UAAU,CAAC;QACjC,MAAMC,YAAYZ,EAAEO,SAASM,IAAI,CAAC,YAAYC,IA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kC,MAAML;gBACV;YACJ,OAAO;gBACH,IAAI;oBACA,MAAMM,cAAc7C,uBAAuBU;oBAE3C,MAAMkC,OAAOC,YAAYC,OAAO,GAC1BP,WACA,CAAC,EAAEA,SAAS,WAAW,CAAC;oBAE9BnB,UAAUb,IAAI,CAAC,aACRsC;wBACHD;;gBAER,EAAE,OAAOG,GAAG;gBACR,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,OAAO;QAAE3B;QAAWC;IAAW;AACnC,EAAE"}
|
@@ -17,7 +17,37 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
|
|
17
17
|
getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
|
18
18
|
getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
|
19
19
|
getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
|
20
|
-
getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure
|
20
|
+
getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
|
21
|
+
overloads: ({
|
22
|
+
docs: string[];
|
23
|
+
leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
24
|
+
trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
25
|
+
hasQuestionToken?: boolean | undefined;
|
26
|
+
scope?: import("ts-morph").Scope | undefined;
|
27
|
+
hasOverrideKeyword?: boolean | undefined;
|
28
|
+
parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
|
29
|
+
typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
|
30
|
+
isAbstract?: boolean | undefined;
|
31
|
+
returnType?: (string | import("ts-morph").WriterFunction) | undefined;
|
32
|
+
isAsync?: boolean | undefined;
|
33
|
+
isGenerator?: boolean | undefined;
|
34
|
+
isStatic?: boolean | undefined;
|
35
|
+
kind?: import("ts-morph").StructureKind.MethodOverload | undefined;
|
36
|
+
} | {
|
37
|
+
docs: string[];
|
38
|
+
leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
39
|
+
trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
40
|
+
parameters?: import("ts-morph").OptionalKind<import("ts-morph").ParameterDeclarationStructure>[] | undefined;
|
41
|
+
typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
|
42
|
+
hasDeclareKeyword?: boolean | undefined;
|
43
|
+
isExported?: boolean | undefined;
|
44
|
+
isDefaultExport?: boolean | undefined;
|
45
|
+
returnType?: (string | import("ts-morph").WriterFunction) | undefined;
|
46
|
+
isAsync?: boolean | undefined;
|
47
|
+
isGenerator?: boolean | undefined;
|
48
|
+
kind?: import("ts-morph").StructureKind.FunctionOverload | undefined;
|
49
|
+
})[];
|
50
|
+
};
|
21
51
|
save: () => void;
|
22
52
|
} | null;
|
23
53
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FunctionDeclarationStructure } from 'ts-morph';
|
1
|
+
import { FunctionDeclarationStructure, ParameterDeclarationStructure, StructureKind } from 'ts-morph';
|
2
2
|
import { FunctionDescription, ParameterDetails, PropertyDescription, PropertyDetails } from '../../../types.js';
|
3
3
|
export declare const createTypeProvider: (version: string) => {
|
4
4
|
getGlobalStatements: () => string[];
|
@@ -8,6 +8,36 @@ export declare const createTypeProvider: (version: string) => {
|
|
8
8
|
getFunctionReturnType: (func: FunctionDescription) => string;
|
9
9
|
getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
|
10
10
|
getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
|
11
|
-
getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure
|
11
|
+
getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure> | Partial<import("ts-morph").MethodDeclarationStructure> | {
|
12
|
+
overloads: ({
|
13
|
+
docs: string[];
|
14
|
+
leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
15
|
+
trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
16
|
+
hasQuestionToken?: boolean | undefined;
|
17
|
+
scope?: import("ts-morph").Scope | undefined;
|
18
|
+
hasOverrideKeyword?: boolean | undefined;
|
19
|
+
parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
|
20
|
+
typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
|
21
|
+
isAbstract?: boolean | undefined;
|
22
|
+
returnType?: (string | import("ts-morph").WriterFunction) | undefined;
|
23
|
+
isAsync?: boolean | undefined;
|
24
|
+
isGenerator?: boolean | undefined;
|
25
|
+
isStatic?: boolean | undefined;
|
26
|
+
kind?: StructureKind.MethodOverload | undefined;
|
27
|
+
} | {
|
28
|
+
docs: string[];
|
29
|
+
leadingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
30
|
+
trailingTrivia?: (string | import("ts-morph").WriterFunction | (string | import("ts-morph").WriterFunction)[]) | undefined;
|
31
|
+
parameters?: import("ts-morph").OptionalKind<ParameterDeclarationStructure>[] | undefined;
|
32
|
+
typeParameters?: (import("ts-morph").OptionalKind<import("ts-morph").TypeParameterDeclarationStructure> | string)[] | undefined;
|
33
|
+
hasDeclareKeyword?: boolean | undefined;
|
34
|
+
isExported?: boolean | undefined;
|
35
|
+
isDefaultExport?: boolean | undefined;
|
36
|
+
returnType?: (string | import("ts-morph").WriterFunction) | undefined;
|
37
|
+
isAsync?: boolean | undefined;
|
38
|
+
isGenerator?: boolean | undefined;
|
39
|
+
kind?: StructureKind.FunctionOverload | undefined;
|
40
|
+
})[];
|
41
|
+
};
|
12
42
|
save: () => void;
|
13
43
|
};
|
@@ -124,7 +124,17 @@ export const createTypeProvider = (version)=>{
|
|
124
124
|
};
|
125
125
|
const getFunctionOverrideOptions = (func)=>{
|
126
126
|
var _getFunctionDetails_overrideOptions;
|
127
|
-
|
127
|
+
const options = (_getFunctionDetails_overrideOptions = getFunctionDetails(func).overrideOptions) != null ? _getFunctionDetails_overrideOptions : {};
|
128
|
+
if ('overloads' in options && Array.isArray(options.overloads)) {
|
129
|
+
return {
|
130
|
+
overloads: options.overloads.map((overload)=>_extends({}, overload, {
|
131
|
+
docs: [
|
132
|
+
func.docs
|
133
|
+
]
|
134
|
+
}))
|
135
|
+
};
|
136
|
+
}
|
137
|
+
return options;
|
128
138
|
};
|
129
139
|
const save = ()=>{
|
130
140
|
const contents = JSON.stringify(provider, null, 4) + '\n';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map((p) => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find((p) => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map((details) => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map((parameter) => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n return getFunctionDetails(func).overrideOptions ?? {};\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","classes","properties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;IACJ;AACJ,EAAE"}
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/utils/createTypeProvider.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { existsSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport {\n FunctionDeclarationStructure,\n ParameterDeclarationStructure,\n StructureKind,\n} from 'ts-morph';\nimport { DataFolder } from '@/cli/constants.js';\nimport {\n FunctionDescription,\n FunctionDetails,\n ParameterDetails,\n PropertyDescription,\n PropertyDetails,\n TypeProviderData,\n} from '@/cli/types.js';\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());\n}\n\nexport const createTypeProvider = (version: string) => {\n const path = join(DataFolder, `${version}.json`);\n const fallbackProvider = existsSync(path)\n ? (JSON.parse(readFileSync(path, 'utf-8')) as TypeProviderData)\n : ({\n globalStatements: [],\n statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n statements: fallbackProvider.statements,\n classes: fallbackProvider.classes,\n properties: {},\n functions: {},\n } as TypeProviderData;\n const visitedProperties = new Map<string, PropertyDetails>();\n const visitedFunctions = new Map<string, FunctionDetails>();\n\n const getClassOptions = (className: string) => {\n return provider.classes[className] ?? {};\n };\n\n const getPropertyDetails = (property: PropertyDescription) => {\n if (visitedProperties.has(property.signature)) {\n return visitedProperties.get(property.signature) as PropertyDetails;\n }\n\n let result: PropertyDetails;\n let prop = provider.properties[property.signature];\n\n if (!prop) {\n prop = fallbackProvider.properties[property.signature];\n }\n\n if (!prop) {\n const details = {\n signature: property.signature,\n type: 'any',\n } satisfies PropertyDetails;\n\n provider.properties[property.signature] = details;\n\n result = details;\n } else {\n provider.properties[property.signature] = prop;\n\n result = prop;\n }\n\n visitedProperties.set(property.signature, result);\n\n return result;\n };\n\n const getFunctionDetails = (func: FunctionDescription): FunctionDetails => {\n if (visitedFunctions.has(func.signature)) {\n return visitedFunctions.get(func.signature) as FunctionDetails;\n }\n\n let result: FunctionDetails;\n let fn = provider.functions[func.signature];\n\n if (!fn) {\n fn = fallbackProvider.functions[func.signature];\n }\n\n if (!fn) {\n const details = {\n signature: func.signature,\n parameters: func.parameters.map((p) => ({\n name: p.name,\n type: 'any',\n })),\n returnType: 'any',\n } satisfies FunctionDetails;\n\n provider.functions[func.signature] = details;\n\n result = details;\n } else {\n provider.functions[func.signature] = fn;\n\n result = fn;\n }\n\n visitedFunctions.set(func.signature, result);\n\n return result;\n };\n\n const getGlobalStatements = () => {\n return provider.globalStatements;\n };\n\n const getStatements = () => {\n return provider.statements;\n };\n\n const getFunctionReturnType = (func: FunctionDescription) => {\n const { returnType } = getFunctionDetails(func);\n\n return returnType;\n };\n\n const getParameterDetails = (\n func: FunctionDescription,\n parameter: string\n ) => {\n const { parameters } = getFunctionDetails(func);\n const param = parameters.find((p) => p.name === parameter);\n\n if (!param) {\n return {\n name: parameter,\n type: 'any',\n } satisfies ParameterDetails;\n }\n\n return param;\n };\n\n const getParameters = (\n func: FunctionDescription\n ): FunctionDeclarationStructure['parameters'] => {\n const { overrideParameters = false, parameters } =\n getFunctionDetails(func);\n const getParameterFromDetails = (parameter: ParameterDetails) => {\n return {\n kind: StructureKind.Parameter,\n name: kebabToCamelCase(parameter.name),\n type: parameter.type,\n ...(parameter.overrideOptions ?? {}),\n } satisfies ParameterDeclarationStructure;\n };\n\n if (overrideParameters) {\n return parameters.map((details) => {\n return getParameterFromDetails(details);\n });\n }\n\n return func.parameters.map((parameter) => {\n const details = getParameterDetails(func, parameter.name);\n\n return {\n hasQuestionToken: !parameter.required,\n ...getParameterFromDetails(details),\n } satisfies ParameterDeclarationStructure;\n });\n };\n\n const getFunctionOverrideOptions = (func: FunctionDescription) => {\n const options = getFunctionDetails(func).overrideOptions ?? {};\n\n if ('overloads' in options && Array.isArray(options.overloads)) {\n return {\n overloads: options.overloads.map((overload) => ({\n ...overload,\n docs: [func.docs],\n })),\n };\n }\n\n return options;\n };\n\n const save = () => {\n const contents = JSON.stringify(provider, null, 4) + '\\n';\n\n writeFileSync(path, contents, 'utf-8');\n };\n\n return {\n getGlobalStatements,\n getStatements,\n getClassOptions,\n getPropertyDetails,\n getFunctionReturnType,\n getParameterDetails,\n getParameters,\n getFunctionOverrideOptions,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","statements","classes","properties","functions","provider","visitedProperties","Map","visitedFunctions","getClassOptions","className","getPropertyDetails","property","has","signature","get","result","prop","details","type","set","getFunctionDetails","func","fn","parameters","map","p","name","returnType","getGlobalStatements","getStatements","getFunctionReturnType","getParameterDetails","parameter","param","find","getParameters","overrideParameters","getParameterFromDetails","kind","Parameter","overrideOptions","hasQuestionToken","required","getFunctionOverrideOptions","options","Array","isArray","overloads","overload","docs","save","contents","stringify"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,UAAU,EAAEC,aAAa,QAAQ,UAAU;AACpD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAGIC,aAAa,QACV,WAAW;AAClB,SAASC,UAAU,QAAQ,qBAAqB;AAUhD,SAASC,iBAAiBC,GAAW;IACjC,OAAOA,IAAIC,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAWA,OAAOC,WAAW;AACrE;AAEA,OAAO,MAAMC,qBAAqB,CAACC;IAC/B,MAAMC,OAAOX,KAAKE,YAAY,CAAC,EAAEQ,QAAQ,KAAK,CAAC;IAC/C,MAAME,mBAAmBd,WAAWa,QAC7BE,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;gBACrCR,MAAMc,UAAUd,IAAI;eAChBc,CAAAA,6BAAAA,UAAUQ,eAAe,YAAzBR,6BAA6B,CAAC;QAE1C;QAEA,IAAII,oBAAoB;YACpB,OAAOb,WAAWC,GAAG,CAAC,CAACP;gBACnB,OAAOoB,wBAAwBpB;YACnC;QACJ;QAEA,OAAOI,KAAKE,UAAU,CAACC,GAAG,CAAC,CAACQ;YACxB,MAAMf,UAAUc,oBAAoBV,MAAMW,UAAUN,IAAI;YAExD,OAAO;gBACHe,kBAAkB,CAACT,UAAUU,QAAQ;eAClCL,wBAAwBpB;QAEnC;IACJ;IAEA,MAAM0B,6BAA6B,CAACtB;YAChBD;QAAhB,MAAMwB,UAAUxB,CAAAA,sCAAAA,mBAAmBC,MAAMmB,eAAe,YAAxCpB,sCAA4C,CAAC;QAE7D,IAAI,eAAewB,WAAWC,MAAMC,OAAO,CAACF,QAAQG,SAAS,GAAG;YAC5D,OAAO;gBACHA,WAAWH,QAAQG,SAAS,CAACvB,GAAG,CAAC,CAACwB,WAAc,aACzCA;wBACHC,MAAM;4BAAC5B,KAAK4B,IAAI;yBAAC;;YAEzB;QACJ;QAEA,OAAOL;IACX;IAEA,MAAMM,OAAO;QACT,MAAMC,WAAWtD,KAAKuD,SAAS,CAAChD,UAAU,MAAM,KAAK;QAErDrB,cAAcY,MAAMwD,UAAU;IAClC;IAEA,OAAO;QACHvB;QACAC;QACArB;QACAE;QACAoB;QACAC;QACAI;QACAQ;QACAO;IACJ;AACJ,EAAE"}
|
@@ -3,6 +3,7 @@ import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
|
3
3
|
export declare const projectPathOption: string;
|
4
4
|
export declare class TranspileCommand extends RenderableCommand {
|
5
5
|
static paths: string[][];
|
6
|
+
static usage: import("clipanion").Usage;
|
6
7
|
projectPath: string;
|
7
8
|
render(): React.JSX.Element;
|
8
9
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import process from 'node:process';
|
2
|
-
import { Option } from 'clipanion';
|
2
|
+
import { Command, Option } from 'clipanion';
|
3
3
|
import React from 'react';
|
4
4
|
import * as t from 'typanion';
|
5
5
|
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
@@ -24,5 +24,8 @@ TranspileCommand.paths = [
|
|
24
24
|
'transpile'
|
25
25
|
]
|
26
26
|
];
|
27
|
+
TranspileCommand.usage = Command.Usage({
|
28
|
+
description: 'Transpile TypeScript files to Lua'
|
29
|
+
});
|
27
30
|
|
28
31
|
//# sourceMappingURL=TranspileCommand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n projectPath = projectPathOption;\n\n override render() {\n return <Transpile path={this.projectPath} />;\n }\n}\n"],"names":["process","Option","React","t","RenderableCommand","Transpile","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","path","projectPath","paths"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/TranspileCommand.tsx"],"sourcesContent":["import process from 'node:process';\nimport { Command, Option } from 'clipanion';\nimport React from 'react';\nimport * as t from 'typanion';\nimport { RenderableCommand } from '@/cli/commands/RenderableCommand.js';\nimport { Transpile } from '@/cli/commands/TranspileCommand/components/Transpile.js';\n\nexport const projectPathOption = Option.String('-p,--path', process.cwd(), {\n description: `Where to find the project. Defaults to the current working directory (\"${process.cwd()}\")`,\n validator: t.isString(),\n});\n\nexport class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n static override usage = Command.Usage({\n description: 'Transpile TypeScript files to Lua',\n });\n\n projectPath = projectPathOption;\n\n override render() {\n return <Transpile path={this.projectPath} />;\n }\n}\n"],"names":["process","Command","Option","React","t","RenderableCommand","Transpile","projectPathOption","String","cwd","description","validator","isString","TranspileCommand","render","path","projectPath","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,SAASC,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,SAAS,QAAQ,0DAA0D;AAEpF,OAAO,MAAMC,oBAAoBL,OAAOM,MAAM,CAAC,aAAaR,QAAQS,GAAG,IAAI;IACvEC,aAAa,CAAC,uEAAuE,EAAEV,QAAQS,GAAG,GAAG,EAAE,CAAC;IACxGE,WAAWP,EAAEQ,QAAQ;AACzB,GAAG;AAEH,OAAO,MAAMC,yBAAyBR;IASzBS,SAAS;QACd,qBAAO,oBAACR;YAAUS,MAAM,IAAI,CAACC,WAAW;;IAC5C;;;aAJAA,cAAcT;;AAKlB;AAZaM,iBACOI,QAAQ;IAAC;QAAC;KAAY;CAAC;AAD9BJ,iBAGOK,QAAQjB,QAAQkB,KAAK,CAAC;IAClCT,aAAa;AACjB"}
|
package/src/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
2
2
|
import { readFileSync } from 'fs';
|
3
3
|
import { join } from 'node:path';
|
4
|
-
import { Cli } from 'clipanion';
|
4
|
+
import { Builtins, Cli } from 'clipanion';
|
5
5
|
import { CompileCommand } from './commands/CompileCommand/index.js';
|
6
6
|
import { DoctorCommand } from './commands/DoctorCommand.js';
|
7
7
|
import { GenerateTypesCommand } from './commands/GenerateTypes/index.js';
|
@@ -20,6 +20,8 @@ const cli = new Cli({
|
|
20
20
|
process.on('SIGINT', function() {
|
21
21
|
process.exit();
|
22
22
|
});
|
23
|
+
cli.register(Builtins.HelpCommand);
|
24
|
+
cli.register(Builtins.VersionCommand);
|
23
25
|
cli.register(DoctorCommand);
|
24
26
|
cli.register(NewCommand);
|
25
27
|
cli.register(TranspileCommand);
|
package/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Cli } from 'clipanion';\nimport { CompileCommand } from '@/cli/commands/CompileCommand/index.js';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/index.js';\nimport { NewCommand } from '@/cli/commands/NewCommand/NewCommand.js';\nimport { SimulatorCommand } from '@/cli/commands/SimulatorCommand/index.js';\nimport { TranspileCommand } from '@/cli/commands/TranspileCommand/index.js';\nimport { RootFolder } from '@/cli/constants.js';\n\nconst packageJsonContents = readFileSync(\n join(RootFolder, 'package.json'),\n 'utf-8'\n);\nconst packageJson = JSON.parse(packageJsonContents);\n\nconst args = process.argv.slice(2);\n\nconst cli = new Cli({\n binaryLabel: 'crankscript',\n binaryName: 'crankscript',\n binaryVersion: packageJson.version,\n});\n\nprocess.on('SIGINT', function () {\n process.exit();\n});\n\ncli.register(DoctorCommand);\ncli.register(NewCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","NewCommand","SimulatorCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","on","exit","register","runExit"],"rangeMappings":"
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/index.ts"],"sourcesContent":["#!/usr/bin/env node --no-warnings=ExperimentalWarning\n\nimport { readFileSync } from 'fs';\nimport { join } from 'node:path';\nimport { Builtins, Cli } from 'clipanion';\nimport { CompileCommand } from '@/cli/commands/CompileCommand/index.js';\nimport { DoctorCommand } from '@/cli/commands/DoctorCommand.js';\nimport { GenerateTypesCommand } from '@/cli/commands/GenerateTypes/index.js';\nimport { NewCommand } from '@/cli/commands/NewCommand/NewCommand.js';\nimport { SimulatorCommand } from '@/cli/commands/SimulatorCommand/index.js';\nimport { TranspileCommand } from '@/cli/commands/TranspileCommand/index.js';\nimport { RootFolder } from '@/cli/constants.js';\n\nconst packageJsonContents = readFileSync(\n join(RootFolder, 'package.json'),\n 'utf-8'\n);\nconst packageJson = JSON.parse(packageJsonContents);\n\nconst args = process.argv.slice(2);\n\nconst cli = new Cli({\n binaryLabel: 'crankscript',\n binaryName: 'crankscript',\n binaryVersion: packageJson.version,\n});\n\nprocess.on('SIGINT', function () {\n process.exit();\n});\n\ncli.register(Builtins.HelpCommand);\ncli.register(Builtins.VersionCommand);\ncli.register(DoctorCommand);\ncli.register(NewCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.register(SimulatorCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Builtins","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","NewCommand","SimulatorCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","on","exit","register","HelpCommand","VersionCommand","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,QAAQ,EAAEC,GAAG,QAAQ,YAAY;AAC1C,SAASC,cAAc,QAAQ,yCAAyC;AACxE,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,UAAU,QAAQ,0CAA0C;AACrE,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBX,aACxBC,KAAKS,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAIhB,IAAI;IAChBiB,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAP,QAAQQ,EAAE,CAAC,UAAU;IACjBR,QAAQS,IAAI;AAChB;AAEAN,IAAIO,QAAQ,CAACxB,SAASyB,WAAW;AACjCR,IAAIO,QAAQ,CAACxB,SAAS0B,cAAc;AACpCT,IAAIO,QAAQ,CAACrB;AACbc,IAAIO,QAAQ,CAACnB;AACbY,IAAIO,QAAQ,CAACjB;AACbU,IAAIO,QAAQ,CAACtB;AACbe,IAAIO,QAAQ,CAACpB;AACba,IAAIO,QAAQ,CAAClB;AACbW,IAAIU,OAAO,CAACd"}
|