crankscript 0.7.0 → 0.9.0
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/package.json +1 -1
- package/src/commands/CompileCommand/CompileCommand.d.ts +6 -4
- package/src/commands/CompileCommand/CompileCommand.js +13 -34
- package/src/commands/CompileCommand/CompileCommand.js.map +1 -1
- package/src/commands/CompileCommand/components/Compile.d.ts +8 -0
- package/src/commands/CompileCommand/components/Compile.js +41 -0
- package/src/commands/CompileCommand/components/Compile.js.map +1 -0
- package/src/commands/GenerateTypes/fn/generateFunction.js +0 -1
- package/src/commands/GenerateTypes/fn/generateFunction.js.map +1 -1
- package/src/commands/GenerateTypes/fn/generateNamespace.d.ts +2 -2
- package/src/commands/GenerateTypes/fn/generateNamespace.js +10 -9
- package/src/commands/GenerateTypes/fn/generateNamespace.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getApiDefinitions.d.ts +1 -0
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js +14 -0
- package/src/commands/GenerateTypes/fn/getApiDefinitions.js.map +1 -1
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js +2 -2
- package/src/commands/GenerateTypes/fn/getDescriptionsFromHtml.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +2 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +1 -1
- package/src/commands/GenerateTypes/hooks/useParseDocumentation.d.ts +1 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +1 -1
- package/src/commands/TranspileCommand/TranspileCommand.d.ts +7 -0
- package/src/commands/TranspileCommand/TranspileCommand.js +27 -0
- package/src/commands/TranspileCommand/TranspileCommand.js.map +1 -0
- package/src/commands/TranspileCommand/components/Transpile.d.ts +4 -0
- package/src/commands/TranspileCommand/components/Transpile.js +40 -0
- package/src/commands/TranspileCommand/components/Transpile.js.map +1 -0
- package/src/commands/TranspileCommand/index.d.ts +1 -0
- package/src/commands/TranspileCommand/index.js +3 -0
- package/src/commands/TranspileCommand/index.js.map +1 -0
- package/src/commands/TranspileCommand/plugin.js.map +1 -0
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/types.d.ts +3 -2
- package/src/types.js.map +1 -1
- package/src/commands/CompileCommand/plugin.js.map +0 -1
- /package/src/commands/{CompileCommand → TranspileCommand}/plugin.js +0 -0
package/package.json
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
|
2
|
+
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
3
|
+
import { Environment } from '../../environment/dto/Environment.js';
|
4
|
+
export declare class CompileCommand extends EnvironmentAwareCommand {
|
4
5
|
static paths: string[][];
|
5
|
-
|
6
|
-
|
6
|
+
static usage: import("clipanion").Usage;
|
7
|
+
watch: boolean;
|
8
|
+
renderWithEnvironment(environment: Environment): React.JSX.Element;
|
7
9
|
}
|
@@ -1,42 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import
|
5
|
-
|
6
|
-
|
7
|
-
import { LuaTarget } from 'typescript-to-lua';
|
8
|
-
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
9
|
-
import { RootFolder } from '../../constants.js';
|
10
|
-
const compile = (path)=>{
|
11
|
-
const result = tstl.transpileProject(join(path, 'tsconfig.json'), {
|
12
|
-
luaTarget: LuaTarget.Lua54,
|
13
|
-
outDir: join(path, 'Source'),
|
14
|
-
luaBundle: 'game.lua',
|
15
|
-
luaBundleEntry: join(path, 'src', 'index.ts'),
|
16
|
-
luaPlugins: [
|
17
|
-
{
|
18
|
-
name: join(RootFolder, 'src', 'commands', 'CompileCommand', 'plugin.cts')
|
19
|
-
}
|
20
|
-
]
|
21
|
-
});
|
22
|
-
};
|
23
|
-
const Compile = ({ path })=>{
|
24
|
-
useEffect(()=>{
|
25
|
-
compile(path);
|
26
|
-
}, []);
|
27
|
-
return null;
|
28
|
-
};
|
29
|
-
export class CompileCommand extends RenderableCommand {
|
30
|
-
render() {
|
1
|
+
import { Command, Option } from 'clipanion';
|
2
|
+
import React from 'react';
|
3
|
+
import { Compile } from '../../commands/CompileCommand/components/Compile.js';
|
4
|
+
import { EnvironmentAwareCommand } from '../../commands/EnvironmentAwareCommand/index.js';
|
5
|
+
export class CompileCommand extends EnvironmentAwareCommand {
|
6
|
+
renderWithEnvironment(environment) {
|
31
7
|
return /*#__PURE__*/ React.createElement(Compile, {
|
32
|
-
|
8
|
+
environment: environment,
|
9
|
+
watch: this.watch
|
33
10
|
});
|
34
11
|
}
|
35
12
|
constructor(...args){
|
36
13
|
super(...args);
|
37
|
-
this.
|
38
|
-
description:
|
39
|
-
validator: t.isString()
|
14
|
+
this.watch = Option.Boolean('-w,--watch', false, {
|
15
|
+
description: 'Watch for changes'
|
40
16
|
});
|
41
17
|
}
|
42
18
|
}
|
@@ -45,5 +21,8 @@ CompileCommand.paths = [
|
|
45
21
|
'compile'
|
46
22
|
]
|
47
23
|
];
|
24
|
+
CompileCommand.usage = Command.Usage({
|
25
|
+
description: 'Compiles the code and runs the simulator'
|
26
|
+
});
|
48
27
|
|
49
28
|
//# sourceMappingURL=CompileCommand.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/CompileCommand/CompileCommand.tsx"],"sourcesContent":["import {
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/CompileCommand/CompileCommand.tsx"],"sourcesContent":["import { Command, Option } from 'clipanion';\nimport React from 'react';\nimport { Compile } from '@/cli/commands/CompileCommand/components/Compile.js';\nimport { EnvironmentAwareCommand } from '@/cli/commands/EnvironmentAwareCommand/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\n\nexport class CompileCommand extends EnvironmentAwareCommand {\n static override paths = [['compile']];\n\n static override usage = Command.Usage({\n description: 'Compiles the code and runs the simulator',\n });\n\n watch = Option.Boolean('-w,--watch', false, {\n description: 'Watch for changes',\n });\n\n override renderWithEnvironment(environment: Environment) {\n return <Compile environment={environment} watch={this.watch} />;\n }\n}\n"],"names":["Command","Option","React","Compile","EnvironmentAwareCommand","CompileCommand","renderWithEnvironment","environment","watch","Boolean","description","paths","usage","Usage"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,YAAY;AAC5C,OAAOC,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,sDAAsD;AAC9E,SAASC,uBAAuB,QAAQ,kDAAkD;AAG1F,OAAO,MAAMC,uBAAuBD;IAWvBE,sBAAsBC,WAAwB,EAAE;QACrD,qBAAO,oBAACJ;YAAQI,aAAaA;YAAaC,OAAO,IAAI,CAACA,KAAK;;IAC/D;;;aANAA,QAAQP,OAAOQ,OAAO,CAAC,cAAc,OAAO;YACxCC,aAAa;QACjB;;AAKJ;AAdaL,eACOM,QAAQ;IAAC;QAAC;KAAU;CAAC;AAD5BN,eAGOO,QAAQZ,QAAQa,KAAK,CAAC;IAClCH,aAAa;AACjB"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Environment } from '../../../environment/dto/Environment.js';
|
3
|
+
interface Props {
|
4
|
+
environment: Environment;
|
5
|
+
watch?: boolean;
|
6
|
+
}
|
7
|
+
export declare const Compile: ({ environment, watch }: Props) => React.JSX.Element;
|
8
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { exec } from 'node:child_process';
|
2
|
+
import { existsSync } from 'node:fs';
|
3
|
+
import { join } from 'node:path';
|
4
|
+
import React, { useMemo } from 'react';
|
5
|
+
import { CheckList } from '../../../components/CheckList/index.js';
|
6
|
+
import { useQuitOnCtrlC } from '../../../hooks/useQuitOnCtrlC.js';
|
7
|
+
export const Compile = ({ environment, watch = false })=>{
|
8
|
+
useQuitOnCtrlC();
|
9
|
+
const path = join(environment.sdkPath.path, 'bin', 'pdc');
|
10
|
+
const items = useMemo(()=>[
|
11
|
+
{
|
12
|
+
waitingDescription: 'Waiting to check for pdc binary...',
|
13
|
+
errorDescription: 'Could not find pdc binary',
|
14
|
+
runningDescription: 'Checking for pdc binary...',
|
15
|
+
finishedDescription: (result)=>`Found pdc binary at "${result}"`,
|
16
|
+
runner: async ()=>{
|
17
|
+
if (!existsSync(path)) {
|
18
|
+
throw new Error('Could not find pdc binary');
|
19
|
+
}
|
20
|
+
return path;
|
21
|
+
},
|
22
|
+
ready: true
|
23
|
+
},
|
24
|
+
{
|
25
|
+
waitingDescription: 'Waiting for pdc binary path...',
|
26
|
+
errorDescription: 'Could not compile lua code',
|
27
|
+
runningDescription: 'Compiling lua code...',
|
28
|
+
finishedDescription: ()=>'Lua code compiled',
|
29
|
+
runner: async ()=>{
|
30
|
+
exec(`${path} Source`);
|
31
|
+
},
|
32
|
+
ready: true
|
33
|
+
}
|
34
|
+
], []);
|
35
|
+
return /*#__PURE__*/ React.createElement(CheckList, {
|
36
|
+
items: items,
|
37
|
+
onFinish: process.exit
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
//# sourceMappingURL=Compile.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/CompileCommand/components/Compile.tsx"],"sourcesContent":["import { exec } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport React, { useMemo } from 'react';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { useQuitOnCtrlC } from '@/cli/hooks/useQuitOnCtrlC.js';\nimport { CheckListItem } from '@/cli/types.js';\n\ninterface Props {\n environment: Environment;\n watch?: boolean;\n}\n\nexport const Compile = ({ environment, watch = false }: Props) => {\n useQuitOnCtrlC();\n\n const path = join(environment.sdkPath.path, 'bin', 'pdc');\n const items = useMemo(\n () => [\n {\n waitingDescription: 'Waiting to check for pdc binary...',\n errorDescription: 'Could not find pdc binary',\n runningDescription: 'Checking for pdc binary...',\n finishedDescription: (result) =>\n `Found pdc binary at \"${result}\"`,\n runner: async () => {\n if (!existsSync(path)) {\n throw new Error('Could not find pdc binary');\n }\n\n return path;\n },\n ready: true,\n } satisfies CheckListItem<string>,\n {\n waitingDescription: 'Waiting for pdc binary path...',\n errorDescription: 'Could not compile lua code',\n runningDescription: 'Compiling lua code...',\n finishedDescription: () => 'Lua code compiled',\n runner: async () => {\n exec(`${path} Source`);\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["exec","existsSync","join","React","useMemo","CheckList","useQuitOnCtrlC","Compile","environment","watch","path","sdkPath","items","waitingDescription","errorDescription","runningDescription","finishedDescription","result","runner","Error","ready","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,qBAAqB;AAC1C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,IAAI,QAAQ,YAAY;AACjC,OAAOC,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,SAAS,QAAQ,sCAAsC;AAEhE,SAASC,cAAc,QAAQ,gCAAgC;AAQ/D,OAAO,MAAMC,UAAU,CAAC,EAAEC,WAAW,EAAEC,QAAQ,KAAK,EAAS;IACzDH;IAEA,MAAMI,OAAOR,KAAKM,YAAYG,OAAO,CAACD,IAAI,EAAE,OAAO;IACnD,MAAME,QAAQR,QACV,IAAM;YACF;gBACIS,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,CAACC,SAClB,CAAC,qBAAqB,EAAEA,OAAO,CAAC,CAAC;gBACrCC,QAAQ;oBACJ,IAAI,CAACjB,WAAWS,OAAO;wBACnB,MAAM,IAAIS,MAAM;oBACpB;oBAEA,OAAOT;gBACX;gBACAU,OAAO;YACX;YACA;gBACIP,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BE,QAAQ;oBACJlB,KAAK,CAAC,EAAEU,KAAK,OAAO,CAAC;gBACzB;gBACAU,OAAO;YACX;SACH,EACD,EAAE;IAGN,qBAAO,oBAACf;QAAUO,OAAOA;QAAOS,UAAUC,QAAQC,IAAI;;AAC1D,EAAE"}
|
@@ -9,7 +9,6 @@ export const generateFunction = (func, subject, typeProvider)=>{
|
|
9
9
|
docs: [
|
10
10
|
func.docs
|
11
11
|
],
|
12
|
-
isExported: !isReserved,
|
13
12
|
returnType: typeProvider.getFunctionReturnType(func),
|
14
13
|
parameters: typeProvider.getParameters(func)
|
15
14
|
}, (_typeProvider_getFunctionOverrideOptions = typeProvider.getFunctionOverrideOptions(func)) != null ? _typeProvider_getFunctionOverrideOptions : {}));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateFunction.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n ModuleDeclaration,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { FunctionDescription } from '@/cli/types.js';\n\nexport const generateFunction = (\n func: FunctionDescription,\n subject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>\n) => {\n const isReserved = TypescriptReservedNamed.includes(func.name);\n\n const name = isReserved ? `_${func.name}` : func.name;\n\n subject.addFunction({\n name,\n docs: [func.docs],\n
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateFunction.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n ModuleDeclaration,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { FunctionDescription } from '@/cli/types.js';\n\nexport const generateFunction = (\n func: FunctionDescription,\n subject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>\n) => {\n const isReserved = TypescriptReservedNamed.includes(func.name);\n\n const name = isReserved ? `_${func.name}` : func.name;\n\n subject.addFunction({\n name,\n docs: [func.docs],\n returnType: typeProvider.getFunctionReturnType(func),\n parameters: typeProvider.getParameters(func),\n ...((typeProvider.getFunctionOverrideOptions(\n func\n ) as Partial<FunctionDeclarationStructure>) ?? {}),\n });\n\n if (isReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name,\n alias: func.name,\n },\n ],\n });\n }\n};\n"],"names":["TypescriptReservedNamed","generateFunction","func","subject","typeProvider","isReserved","includes","name","addFunction","docs","returnType","getFunctionReturnType","parameters","getParameters","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAMA,SAASA,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,mBAAmB,CAC5BC,MACAC,SACAC;IAEA,MAAMC,aAAaL,wBAAwBM,QAAQ,CAACJ,KAAKK,IAAI;IAE7D,MAAMA,OAAOF,aAAa,CAAC,CAAC,EAAEH,KAAKK,IAAI,CAAC,CAAC,GAAGL,KAAKK,IAAI;QAO5CH;IALTD,QAAQK,WAAW,CAAC;QAChBD;QACAE,MAAM;YAACP,KAAKO,IAAI;SAAC;QACjBC,YAAYN,aAAaO,qBAAqB,CAACT;QAC/CU,YAAYR,aAAaS,aAAa,CAACX;OACnC,CAACE,2CAAAA,aAAaU,0BAA0B,CACxCZ,iBADCE,2CAE0C,CAAC;IAGpD,IAAIC,YAAY;QACZF,QAAQY,oBAAoB,CAAC;YACzBC,cAAc;gBACV;oBACIT;oBACAU,OAAOf,KAAKK,IAAI;gBACpB;aACH;QACL;IACJ;AACJ,EAAE"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ClassDeclaration, ModuleDeclaration, SourceFile } from 'ts-morph';
|
2
2
|
import { createTypeProvider } from '../../../commands/GenerateTypes/utils/createTypeProvider.js';
|
3
3
|
import { PlaydateNamespace, PlaydateType } from '../../../types.js';
|
4
|
-
export declare const generateNamespace: (namespaceDescription: PlaydateNamespace, namespaces: string[], subjects: Map<string, SourceFile | ModuleDeclaration>, typeSubjects: Map<string,
|
4
|
+
export declare const generateNamespace: (namespaceDescription: PlaydateNamespace, namespaces: string[], subjects: Map<string, SourceFile | ModuleDeclaration>, typeSubjects: Map<string, ClassDeclaration>, typeProvider: ReturnType<typeof createTypeProvider>, types: Record<string, PlaydateType>) => void;
|
@@ -5,22 +5,22 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
|
|
5
5
|
const subjectName = namespaces.slice(0, -1).join('.');
|
6
6
|
const namespaceName = namespaces[namespaces.length - 1];
|
7
7
|
const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';
|
8
|
-
const subject = namespaces.length
|
8
|
+
const subject = namespaces.length <= 1 ? subjects.get('root') : subjects.get(subjectName);
|
9
9
|
if (!subject) {
|
10
10
|
return;
|
11
11
|
}
|
12
|
-
const module = subject.addModule({
|
12
|
+
const module = namespaces.length > 0 ? subject.addModule({
|
13
13
|
name: namespaceName
|
14
|
-
});
|
14
|
+
}) : subject;
|
15
15
|
const addMethods = (typeName, subj, methods)=>{
|
16
16
|
const interfaceName = typeName.split('.').map((name)=>name[0].toUpperCase() + name.slice(1)).join('');
|
17
|
-
const
|
17
|
+
const typeClass = subj.addClass({
|
18
18
|
name: interfaceName
|
19
19
|
});
|
20
|
-
typeSubjects.set(typeName,
|
20
|
+
typeSubjects.set(typeName, typeClass);
|
21
21
|
for (const func of methods){
|
22
22
|
const parameters = typeProvider.getParameters(func);
|
23
|
-
|
23
|
+
typeClass.addMethod(_extends({
|
24
24
|
name: func.name,
|
25
25
|
docs: [
|
26
26
|
func.docs
|
@@ -30,7 +30,7 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
|
|
30
30
|
}, typeProvider.getFunctionOverrideOptions(func)));
|
31
31
|
}
|
32
32
|
};
|
33
|
-
if (isRoot) {
|
33
|
+
if (isRoot && 'addJsDoc' in module) {
|
34
34
|
module.addJsDoc({
|
35
35
|
description: 'Playdate SDK'
|
36
36
|
});
|
@@ -39,7 +39,9 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
|
|
39
39
|
addMethods(eachType, module, types[eachType].methods);
|
40
40
|
});
|
41
41
|
}
|
42
|
-
|
42
|
+
if (namespaces.length > 0) {
|
43
|
+
subjects.set(namespaces.join('.'), module);
|
44
|
+
}
|
43
45
|
if (namespaceDescription.methods.length > 0) {
|
44
46
|
addMethods(namespaces.join('.'), subjects.get('playdate'), namespaceDescription.methods);
|
45
47
|
}
|
@@ -62,7 +64,6 @@ export const generateNamespace = (namespaceDescription, namespaces, subjects, ty
|
|
62
64
|
}
|
63
65
|
const propertyType = propertyDetails.type;
|
64
66
|
module.addVariableStatement({
|
65
|
-
isExported: true,
|
66
67
|
declarationKind: VariableDeclarationKind.Const,
|
67
68
|
declarations: [
|
68
69
|
{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateNamespace.ts"],"sourcesContent":["import {\n
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/generateNamespace.ts"],"sourcesContent":["import {\n ClassDeclaration,\n MethodDeclarationStructure,\n ModuleDeclaration,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { generateFunction } from '@/cli/commands/GenerateTypes/fn/generateFunction.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport {\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n} from '@/cli/types.js';\n\nexport const generateNamespace = (\n namespaceDescription: PlaydateNamespace,\n namespaces: string[],\n subjects: Map<string, SourceFile | ModuleDeclaration>,\n typeSubjects: Map<string, ClassDeclaration>,\n typeProvider: ReturnType<typeof createTypeProvider>,\n types: Record<string, PlaydateType>\n) => {\n const subjectName = namespaces.slice(0, -1).join('.');\n const namespaceName = namespaces[namespaces.length - 1];\n const isRoot = namespaces.length === 1 && namespaces[0] === 'playdate';\n const subject =\n namespaces.length <= 1\n ? subjects.get('root')\n : subjects.get(subjectName);\n\n if (!subject) {\n return;\n }\n\n const module =\n namespaces.length > 0\n ? subject.addModule({\n name: namespaceName,\n })\n : subject;\n\n const addMethods = (\n typeName: string,\n subj: ModuleDeclaration,\n methods: FunctionDescription[]\n ) => {\n const interfaceName = typeName\n .split('.')\n .map((name) => name[0].toUpperCase() + name.slice(1))\n .join('');\n const typeClass = subj.addClass({\n name: interfaceName,\n });\n typeSubjects.set(typeName, typeClass);\n\n for (const func of methods) {\n const parameters = typeProvider.getParameters(func);\n\n typeClass.addMethod({\n name: func.name,\n docs: [func.docs],\n returnType: typeProvider.getFunctionReturnType(func),\n parameters,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n };\n\n if (isRoot && 'addJsDoc' in module) {\n module.addJsDoc({\n description: 'Playdate SDK',\n });\n module.addStatements(typeProvider.getStatements());\n\n Object.keys(types).forEach((eachType) => {\n addMethods(eachType, module, types[eachType].methods);\n });\n }\n\n if (namespaces.length > 0) {\n subjects.set(namespaces.join('.'), module);\n }\n\n if (namespaceDescription.methods.length > 0) {\n addMethods(\n namespaces.join('.'),\n subjects.get('playdate') as ModuleDeclaration,\n namespaceDescription.methods\n );\n }\n\n for (const property of namespaceDescription.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n if (!propertyDetails.isStatic) {\n const typeName = namespaces.join('.');\n\n if (typeSubjects.has(typeName)) {\n const typeInterface = typeSubjects.get(\n typeName\n ) as ClassDeclaration;\n\n typeInterface.addProperty({\n name: property.name,\n type: propertyDetails.type,\n docs: [property.docs],\n isReadonly: propertyDetails.isReadOnly,\n });\n }\n\n continue;\n }\n\n const propertyType = propertyDetails.type;\n\n module.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: property.name,\n type: propertyType,\n },\n ],\n });\n }\n\n for (const func of namespaceDescription.functions) {\n generateFunction(func, module, typeProvider);\n }\n};\n"],"names":["VariableDeclarationKind","generateFunction","generateNamespace","namespaceDescription","namespaces","subjects","typeSubjects","typeProvider","types","subjectName","slice","join","namespaceName","length","isRoot","subject","get","module","addModule","name","addMethods","typeName","subj","methods","interfaceName","split","map","toUpperCase","typeClass","addClass","set","func","parameters","getParameters","addMethod","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addJsDoc","description","addStatements","getStatements","Object","keys","forEach","eachType","property","properties","propertyDetails","getPropertyDetails","isStatic","has","typeInterface","addProperty","type","isReadonly","isReadOnly","propertyType","addVariableStatement","declarationKind","Const","declarations","functions"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAKIA,uBAAuB,QACpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,sDAAsD;AAQvF,OAAO,MAAMC,oBAAoB,CAC7BC,sBACAC,YACAC,UACAC,cACAC,cACAC;IAEA,MAAMC,cAAcL,WAAWM,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;IACjD,MAAMC,gBAAgBR,UAAU,CAACA,WAAWS,MAAM,GAAG,EAAE;IACvD,MAAMC,SAASV,WAAWS,MAAM,KAAK,KAAKT,UAAU,CAAC,EAAE,KAAK;IAC5D,MAAMW,UACFX,WAAWS,MAAM,IAAI,IACfR,SAASW,GAAG,CAAC,UACbX,SAASW,GAAG,CAACP;IAEvB,IAAI,CAACM,SAAS;QACV;IACJ;IAEA,MAAME,SACFb,WAAWS,MAAM,GAAG,IACdE,QAAQG,SAAS,CAAC;QACdC,MAAMP;IACV,KAC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AC;YAEjC,IAAIL,aAAa8C,GAAG,CAAC/B,WAAW;gBAC5B,MAAMgC,gBAAgB/C,aAAaU,GAAG,CAClCK;gBAGJgC,cAAcC,WAAW,CAAC;oBACtBnC,MAAM4B,SAAS5B,IAAI;oBACnBoC,MAAMN,gBAAgBM,IAAI;oBAC1BpB,MAAM;wBAACY,SAASZ,IAAI;qBAAC;oBACrBqB,YAAYP,gBAAgBQ,UAAU;gBAC1C;YACJ;YAEA;QACJ;QAEA,MAAMC,eAAeT,gBAAgBM,IAAI;QAEzCtC,OAAO0C,oBAAoB,CAAC;YACxBC,iBAAiB5D,wBAAwB6D,KAAK;YAC9CC,cAAc;gBACV;oBACI3C,MAAM4B,SAAS5B,IAAI;oBACnBoC,MAAMG;gBACV;aACH;QACL;IACJ;IAEA,KAAK,MAAM3B,QAAQ5B,qBAAqB4D,SAAS,CAAE;QAC/C9D,iBAAiB8B,MAAMd,QAAQV;IACnC;AACJ,EAAE"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { FunctionDescription, PlaydateNamespace, PlaydateType, PropertyDescription } from '../../../types.js';
|
2
2
|
export declare const getApiDefinitions: (functions: FunctionDescription[], properties: PropertyDescription[]) => {
|
3
|
+
rootNamespace: PlaydateNamespace;
|
3
4
|
namespaces: Record<string, PlaydateNamespace>;
|
4
5
|
types: Record<string, PlaydateType>;
|
5
6
|
};
|
@@ -1,4 +1,9 @@
|
|
1
1
|
export const getApiDefinitions = (functions, properties)=>{
|
2
|
+
const rootNamespace = {
|
3
|
+
functions: [],
|
4
|
+
methods: [],
|
5
|
+
properties: []
|
6
|
+
};
|
2
7
|
const namespaces = {};
|
3
8
|
const types = {};
|
4
9
|
const realNamespaces = new Set();
|
@@ -58,15 +63,24 @@ export const getApiDefinitions = (functions, properties)=>{
|
|
58
63
|
};
|
59
64
|
}
|
60
65
|
types[fullNamespacePath].methods.push(func);
|
66
|
+
} else if (fullNamespacePath === '') {
|
67
|
+
if (func.hasSelf) {
|
68
|
+
rootNamespace.methods.push(func);
|
69
|
+
} else {
|
70
|
+
rootNamespace.functions.push(func);
|
71
|
+
}
|
61
72
|
}
|
62
73
|
});
|
63
74
|
properties.forEach((prop)=>{
|
64
75
|
const fullNamespacePath = prop.namespaces.join('.');
|
65
76
|
if (realNamespaces.has(fullNamespacePath)) {
|
66
77
|
namespaces[fullNamespacePath].properties.push(prop);
|
78
|
+
} else if (fullNamespacePath === '') {
|
79
|
+
rootNamespace.properties.push(prop);
|
67
80
|
}
|
68
81
|
});
|
69
82
|
return {
|
83
|
+
rootNamespace,
|
70
84
|
namespaces,
|
71
85
|
types
|
72
86
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[]\n) => {\n const namespaces: Record<string, PlaydateNamespace> = {};\n const types: Record<string, PlaydateType> = {};\n const realNamespaces = new Set<string>();\n const potentialNamespaces = new Set<string>();\n\n functions.forEach((func) => {\n if (!func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n }\n });\n\n properties.forEach((prop) => {\n let currentNamespace = '';\n prop.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n });\n\n functions.forEach((func) => {\n if (func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n if (!potentialNamespaces.has(currentNamespace)) {\n potentialNamespaces.add(currentNamespace);\n }\n });\n }\n });\n\n realNamespaces.forEach((ns) => {\n namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n };\n });\n\n functions.forEach((func) => {\n const fullNamespacePath = func.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n if (func.hasSelf) {\n namespaces[fullNamespacePath].methods.push(func);\n } else {\n namespaces[fullNamespacePath].functions.push(func);\n }\n } else if (potentialNamespaces.has(fullNamespacePath)) {\n if (!types[fullNamespacePath]) {\n types[fullNamespacePath] = { methods: [] };\n }\n types[fullNamespacePath].methods.push(func);\n }\n });\n\n properties.forEach((prop) => {\n const fullNamespacePath = prop.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n namespaces[fullNamespacePath].properties.push(prop);\n }\n });\n\n return {\n namespaces,\n types,\n } satisfies ApiDefinitions;\n};\n"],"names":["getApiDefinitions","functions","properties","namespaces","types","realNamespaces","Set","potentialNamespaces","forEach","func","hasSelf","currentNamespace","ns","realNamespaceName","trim","has","add","prop","
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/fn/getApiDefinitions.ts"],"sourcesContent":["import {\n ApiDefinitions,\n FunctionDescription,\n PlaydateNamespace,\n PlaydateType,\n PropertyDescription,\n} from '@/cli/types.js';\n\nexport const getApiDefinitions = (\n functions: FunctionDescription[],\n properties: PropertyDescription[]\n) => {\n const rootNamespace: PlaydateNamespace = {\n functions: [],\n methods: [],\n properties: [],\n };\n const namespaces: Record<string, PlaydateNamespace> = {};\n const types: Record<string, PlaydateType> = {};\n const realNamespaces = new Set<string>();\n const potentialNamespaces = new Set<string>();\n\n functions.forEach((func) => {\n if (!func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n }\n });\n\n properties.forEach((prop) => {\n let currentNamespace = '';\n prop.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n const realNamespaceName = currentNamespace.trim();\n\n if (!realNamespaces.has(realNamespaceName)) {\n realNamespaces.add(realNamespaceName);\n }\n });\n });\n\n functions.forEach((func) => {\n if (func.hasSelf) {\n let currentNamespace = '';\n func.namespaces.forEach((ns) => {\n currentNamespace = currentNamespace\n ? `${currentNamespace}.${ns}`\n : ns;\n\n if (!potentialNamespaces.has(currentNamespace)) {\n potentialNamespaces.add(currentNamespace);\n }\n });\n }\n });\n\n realNamespaces.forEach((ns) => {\n namespaces[ns] = {\n functions: [],\n methods: [],\n properties: [],\n };\n });\n\n functions.forEach((func) => {\n const fullNamespacePath = func.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n if (func.hasSelf) {\n namespaces[fullNamespacePath].methods.push(func);\n } else {\n namespaces[fullNamespacePath].functions.push(func);\n }\n } else if (potentialNamespaces.has(fullNamespacePath)) {\n if (!types[fullNamespacePath]) {\n types[fullNamespacePath] = { methods: [] };\n }\n types[fullNamespacePath].methods.push(func);\n } else if (fullNamespacePath === '') {\n if (func.hasSelf) {\n rootNamespace.methods.push(func);\n } else {\n rootNamespace.functions.push(func);\n }\n }\n });\n\n properties.forEach((prop) => {\n const fullNamespacePath = prop.namespaces.join('.');\n\n if (realNamespaces.has(fullNamespacePath)) {\n namespaces[fullNamespacePath].properties.push(prop);\n } else if (fullNamespacePath === '') {\n rootNamespace.properties.push(prop);\n }\n });\n\n return {\n rootNamespace,\n namespaces,\n types,\n } satisfies ApiDefinitions;\n};\n"],"names":["getApiDefinitions","functions","properties","rootNamespace","methods","namespaces","types","realNamespaces","Set","potentialNamespaces","forEach","func","hasSelf","currentNamespace","ns","realNamespaceName","trim","has","add","prop","fullNamespacePath","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AAO;QACHhB;QACAE;QACAC;IACJ;AACJ,EAAE"}
|
@@ -25,8 +25,8 @@ export const getDescriptionsFromHtml = (html, version)=>{
|
|
25
25
|
var _$_attr;
|
26
26
|
const id = (_$_attr = $(element).attr('id')) != null ? _$_attr : '';
|
27
27
|
const isProperty = id.startsWith('v-');
|
28
|
-
const titleText = $(element).find('.title').text();
|
29
|
-
if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\[/.test(titleText)) {
|
28
|
+
const titleText = $(element).find('> .title').text();
|
29
|
+
if (titleText.indexOf('#') !== -1 || /[a-zA-Z]\[/.test(titleText) || /^-[a-zA-Z]/.test(titleText) || /[+*/]/.test(titleText) || titleText.indexOf(' - ') !== -1 || titleText.indexOf(' .. ') !== -1) {
|
30
30
|
continue;
|
31
31
|
}
|
32
32
|
const titles = isProperty ? titleText.split(' ') : extractFunctionCalls(titleText);
|
@@ -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 (titleText.indexOf('#') !== -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B,SAASC,cAAc,QAAQ,4CAA4C;AAC3E,SAASC,sBAAsB,QAAQ,4DAA4D;AAGnG,MAAMC,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AWP,UAAU,CAAC,4BAA4B;YAClDO,aAAaA,WAAWrB,KAAK,CAAC,0BAA0BsB,MAAM;QAClE;QAEA,IAAID,WAAWE,QAAQ,CAAC,WAAW;YAC/BF,aAAaA,WAAWrB,KAAK,CACzB,GACAqB,WAAWC,MAAM,GAAG,SAASA,MAAM;QAE3C;QAEAD,aAAaA,WAAWG,OAAO,CAC3B,eACA,cAActC,iBAAiBiB,UAAU;QAG7C,MAAMsB,WAAWd,KACX,CAAC,EAAEU,WAAW,cAAc,EAAEnC,eAAe,EAAEiB,QAAQ,CAAC,EAAEQ,GAAG,CAAC,CAAC,GAC/DU;QAEN,KAAK,MAAMK,SAASP,OAAQ;YACxB,MAAMtB,YAAYD,mBAAmB8B;YAErC,IAAIjB,kBAAkBkB,QAAQ,CAAC9B,YAAY;gBACvC;YACJ;YAEAY,kBAAkBf,IAAI,CAACG;YAEvB,IAAIgB,YAAY;gBACZL,WAAWd,IAAI,CAAC;oBACZkC,MAAMF,MAAMN,KAAK,CAAC,KAAKpB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;oBACnC6B,YAAYhC,UAAUuB,KAAK,CAAC,KAAKpB,KAAK,CAAC,GAAG,CAAC;oBAC3CH;oBACAiC,MAAML;gBACV;YACJ,OAAO;gBACH,IAAI;oBACA,MAAMM,cAAc5C,uBAAuBU;oBAE3C,MAAMiC,OAAOC,YAAYC,OAAO,GAC1BP,WACA,CAAC,EAAEA,SAAS,WAAW,CAAC;oBAE9BlB,UAAUb,IAAI,CAAC,aACRqC;wBACHD;;gBAER,EAAE,OAAOG,GAAG;gBACR,SAAS;gBACb;YACJ;QACJ;IACJ;IAEA,OAAO;QAAE1B;QAAWC;IAAW;AACnC,EAAE"}
|
@@ -24,12 +24,13 @@ export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
|
|
24
24
|
const subjects = new Map();
|
25
25
|
const typeSubjects = new Map();
|
26
26
|
subjects.set('root', typeFile);
|
27
|
+
generateNamespace(definitions.rootNamespace, [], subjects, typeSubjects, typeProvider, definitions.types);
|
27
28
|
Object.keys(definitions.namespaces).forEach((namespace)=>{
|
28
29
|
const namespaceDescription = definitions.namespaces[namespace];
|
29
30
|
const namespaces = namespace.split('.');
|
30
31
|
generateNamespace(namespaceDescription, namespaces, subjects, typeSubjects, typeProvider, definitions.types);
|
31
32
|
});
|
32
|
-
writeFileSync(path, typeFile.getFullText().replace('/**
|
33
|
+
writeFileSync(path, typeFile.getFullText().replace('/**', '\n/**'));
|
33
34
|
},
|
34
35
|
ready: definitions !== null && typeProvider !== null
|
35
36
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/GenerateTypes/hooks/useGenerateTypeFile.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { useMemo } from 'react';\nimport {\n ClassDeclaration,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { generateNamespace } from '@/cli/commands/GenerateTypes/fn/generateNamespace.js';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { ApiDefinitions, CheckListItem } from '@/cli/types.js';\n\nexport const useGenerateTypeFile = (\n path: string,\n definitions: ApiDefinitions | null,\n typeProvider: ReturnType<typeof createTypeProvider> | null\n) => {\n const generateTypeFile = useMemo(() => {\n return {\n waitingDescription: 'Waiting to generate the type file...',\n errorDescription: 'Failed to generate the type file',\n finishedDescription: () => 'Type file generated',\n runningDescription: 'Generating the type file...',\n runner: async () => {\n if (!definitions) {\n throw new Error('Definitions are not set');\n }\n\n if (!typeProvider) {\n throw new Error('Type provider is not set');\n }\n\n const project = new Project();\n const typeFile = project.createSourceFile(path, '', {\n overwrite: true,\n });\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n const subjects = new Map<\n string,\n SourceFile | ModuleDeclaration\n >();\n const typeSubjects = new Map<string, ClassDeclaration>();\n subjects.set('root', typeFile);\n\n generateNamespace(\n definitions.rootNamespace,\n [],\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\n );\n\n Object.keys(definitions.namespaces).forEach((namespace) => {\n const namespaceDescription =\n definitions.namespaces[namespace];\n const namespaces = namespace.split('.');\n generateNamespace(\n namespaceDescription,\n namespaces,\n subjects,\n typeSubjects,\n typeProvider,\n definitions.types\n );\n });\n\n writeFileSync(\n path,\n typeFile.getFullText().replace('/**', '\\n/**')\n );\n },\n ready: definitions !== null && typeProvider !== null,\n } satisfies CheckListItem<void>;\n }, [definitions, typeProvider]);\n\n return {\n generateTypeFile,\n };\n};\n"],"names":["writeFileSync","useMemo","Project","generateNamespace","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","addStatements","getGlobalStatements","subjects","Map","typeSubjects","set","rootNamespace","types","Object","keys","namespaces","forEach","namespace","namespaceDescription","split","getFullText","replace","ready"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAGIC,OAAO,QAEJ,WAAW;AAClB,SAASC,iBAAiB,QAAQ,uDAAuD;AAIzF,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBP,QAAQ;QAC7B,OAAO;YACHQ,oBAAoB;YACpBC,kBAAkB;YAClBC,qBAAqB,IAAM;YAC3BC,oBAAoB;YACpBC,QAAQ;gBACJ,IAAI,CAACP,aAAa;oBACd,MAAM,IAAIQ,MAAM;gBACpB;gBAEA,IAAI,CAACP,cAAc;oBACf,MAAM,IAAIO,MAAM;gBACpB;gBAEA,MAAMC,UAAU,IAAIb;gBACpB,MAAMc,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBACAF,SAASG,aAAa,CAACZ,aAAaa,mBAAmB;gBAEvD,MAAMC,WAAW,IAAIC;gBAIrB,MAAMC,eAAe,IAAID;gBACzBD,SAASG,GAAG,CAAC,QAAQR;gBAErBb,kBACIG,YAAYmB,aAAa,EACzB,EAAE,EACFJ,UACAE,cACAhB,cACAD,YAAYoB,KAAK;gBAGrBC,OAAOC,IAAI,CAACtB,YAAYuB,UAAU,EAAEC,OAAO,CAAC,CAACC;oBACzC,MAAMC,uBACF1B,YAAYuB,UAAU,CAACE,UAAU;oBACrC,MAAMF,aAAaE,UAAUE,KAAK,CAAC;oBACnC9B,kBACI6B,sBACAH,YACAR,UACAE,cACAhB,cACAD,YAAYoB,KAAK;gBAEzB;gBAEA1B,cACIK,MACAW,SAASkB,WAAW,GAAGC,OAAO,CAAC,OAAO;YAE9C;YACAC,OAAO9B,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ;AACJ,EAAE"}
|
@@ -16,7 +16,7 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
|
|
16
16
|
getFunctionReturnType: (func: import("../../../types.js").FunctionDescription) => string;
|
17
17
|
getParameterDetails: (func: import("../../../types.js").FunctionDescription, parameter: string) => import("../../../types.js").ParameterDetails;
|
18
18
|
getParameters: (func: import("../../../types.js").FunctionDescription) => import("ts-morph").FunctionDeclarationStructure["parameters"];
|
19
|
-
getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").
|
19
|
+
getFunctionOverrideOptions: (func: import("../../../types.js").FunctionDescription) => Partial<import("ts-morph").FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
|
20
20
|
save: () => void;
|
21
21
|
} | null;
|
22
22
|
};
|
@@ -7,6 +7,7 @@ export declare const useParseDocumentation: (html: string | null, version: strin
|
|
7
7
|
finishedDescription: () => string;
|
8
8
|
runningDescription: string;
|
9
9
|
runner: () => Promise<{
|
10
|
+
rootNamespace: import("../../../types.js").PlaydateNamespace;
|
10
11
|
namespaces: Record<string, import("../../../types.js").PlaydateNamespace>;
|
11
12
|
types: Record<string, import("../../../types.js").PlaydateType>;
|
12
13
|
}>;
|
@@ -7,6 +7,6 @@ export declare const createTypeProvider: (version: string) => {
|
|
7
7
|
getFunctionReturnType: (func: FunctionDescription) => string;
|
8
8
|
getParameterDetails: (func: FunctionDescription, parameter: string) => ParameterDetails;
|
9
9
|
getParameters: (func: FunctionDescription) => FunctionDeclarationStructure["parameters"];
|
10
|
-
getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").
|
10
|
+
getFunctionOverrideOptions: (func: FunctionDescription) => Partial<FunctionDeclarationStructure | import("ts-morph").MethodDeclarationStructure>;
|
11
11
|
save: () => void;
|
12
12
|
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import process from 'node:process';
|
2
|
+
import { Option } from 'clipanion';
|
3
|
+
import React from 'react';
|
4
|
+
import * as t from 'typanion';
|
5
|
+
import { RenderableCommand } from '../../commands/RenderableCommand.js';
|
6
|
+
import { Transpile } from '../../commands/TranspileCommand/components/Transpile.js';
|
7
|
+
export class TranspileCommand extends RenderableCommand {
|
8
|
+
render() {
|
9
|
+
return /*#__PURE__*/ React.createElement(Transpile, {
|
10
|
+
path: this.projectPath
|
11
|
+
});
|
12
|
+
}
|
13
|
+
constructor(...args){
|
14
|
+
super(...args);
|
15
|
+
this.projectPath = Option.String('-p,--path', process.cwd(), {
|
16
|
+
description: `Where to find the project. Defaults to the current working directory ("${process.cwd()}")`,
|
17
|
+
validator: t.isString()
|
18
|
+
});
|
19
|
+
}
|
20
|
+
}
|
21
|
+
TranspileCommand.paths = [
|
22
|
+
[
|
23
|
+
'transpile'
|
24
|
+
]
|
25
|
+
];
|
26
|
+
|
27
|
+
//# sourceMappingURL=TranspileCommand.js.map
|
@@ -0,0 +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 class TranspileCommand extends RenderableCommand {\n static override paths = [['transpile']];\n\n projectPath = 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\n override render() {\n return <Transpile path={this.projectPath} />;\n }\n}\n"],"names":["process","Option","React","t","RenderableCommand","Transpile","TranspileCommand","render","path","projectPath","String","cwd","description","validator","isString","paths"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,aAAa,eAAe;AACnC,SAASC,MAAM,QAAQ,YAAY;AACnC,OAAOC,WAAW,QAAQ;AAC1B,YAAYC,OAAO,WAAW;AAC9B,SAASC,iBAAiB,QAAQ,sCAAsC;AACxE,SAASC,SAAS,QAAQ,0DAA0D;AAEpF,OAAO,MAAMC,yBAAyBF;IAQzBG,SAAS;QACd,qBAAO,oBAACF;YAAUG,MAAM,IAAI,CAACC,WAAW;;IAC5C;;;aAPAA,cAAcR,OAAOS,MAAM,CAAC,aAAaV,QAAQW,GAAG,IAAI;YACpDC,aAAa,CAAC,uEAAuE,EAAEZ,QAAQW,GAAG,GAAG,EAAE,CAAC;YACxGE,WAAWV,EAAEW,QAAQ;QACzB;;AAKJ;AAXaR,iBACOS,QAAQ;IAAC;QAAC;KAAY;CAAC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { join } from 'node:path';
|
2
|
+
import React from 'react';
|
3
|
+
import { useMemo } from 'react';
|
4
|
+
import * as tstl from 'typescript-to-lua';
|
5
|
+
import { LuaTarget } from 'typescript-to-lua';
|
6
|
+
import { CheckList } from '../../../components/CheckList/index.js';
|
7
|
+
import { RootFolder } from '../../../constants.js';
|
8
|
+
const transpile = (path)=>{
|
9
|
+
tstl.transpileProject(join(path, 'tsconfig.json'), {
|
10
|
+
luaTarget: LuaTarget.Lua54,
|
11
|
+
outDir: join(path, 'Source'),
|
12
|
+
luaBundle: 'game.lua',
|
13
|
+
luaBundleEntry: join(path, 'src', 'index.ts'),
|
14
|
+
luaPlugins: [
|
15
|
+
{
|
16
|
+
name: join(RootFolder, 'src', 'commands', 'CompileCommand', 'plugin.cts')
|
17
|
+
}
|
18
|
+
]
|
19
|
+
});
|
20
|
+
};
|
21
|
+
export const Transpile = ({ path })=>{
|
22
|
+
const items = useMemo(()=>[
|
23
|
+
{
|
24
|
+
waitingDescription: 'Waiting to transpile code...',
|
25
|
+
errorDescription: 'Could not transpile code',
|
26
|
+
runningDescription: 'Transpiling code...',
|
27
|
+
finishedDescription: ()=>'Code transpiled',
|
28
|
+
runner: async ()=>{
|
29
|
+
transpile(path);
|
30
|
+
},
|
31
|
+
ready: true
|
32
|
+
}
|
33
|
+
], []);
|
34
|
+
return /*#__PURE__*/ React.createElement(CheckList, {
|
35
|
+
items: items,
|
36
|
+
onFinish: process.exit
|
37
|
+
});
|
38
|
+
};
|
39
|
+
|
40
|
+
//# sourceMappingURL=Transpile.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/cli/src/commands/TranspileCommand/components/Transpile.tsx"],"sourcesContent":["import { join } from 'node:path';\nimport React from 'react';\nimport { useMemo } from 'react';\nimport * as tstl from 'typescript-to-lua';\nimport { LuaTarget } from 'typescript-to-lua';\nimport { CheckList } from '@/cli/components/CheckList/index.js';\nimport { RootFolder } from '@/cli/constants.js';\nimport { CheckListItem } from '@/cli/types.js';\n\nconst transpile = (path: string) => {\n tstl.transpileProject(join(path, 'tsconfig.json'), {\n luaTarget: LuaTarget.Lua54,\n outDir: join(path, 'Source'),\n luaBundle: 'game.lua',\n luaBundleEntry: join(path, 'src', 'index.ts'),\n luaPlugins: [\n {\n name: join(\n RootFolder,\n 'src',\n 'commands',\n 'CompileCommand',\n 'plugin.cts'\n ),\n },\n ],\n });\n};\n\nexport const Transpile = ({ path }: { path: string }) => {\n const items = useMemo(\n () => [\n {\n waitingDescription: 'Waiting to transpile code...',\n errorDescription: 'Could not transpile code',\n runningDescription: 'Transpiling code...',\n finishedDescription: () => 'Code transpiled',\n runner: async () => {\n transpile(path);\n },\n ready: true,\n },\n ],\n []\n ) as CheckListItem<unknown>[];\n\n return <CheckList items={items} onFinish={process.exit} />;\n};\n"],"names":["join","React","useMemo","tstl","LuaTarget","CheckList","RootFolder","transpile","path","transpileProject","luaTarget","Lua54","outDir","luaBundle","luaBundleEntry","luaPlugins","name","Transpile","items","waitingDescription","errorDescription","runningDescription","finishedDescription","runner","ready","onFinish","process","exit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AACjC,OAAOC,WAAW,QAAQ;AAC1B,SAASC,OAAO,QAAQ,QAAQ;AAChC,YAAYC,UAAU,oBAAoB;AAC1C,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAQ,sCAAsC;AAChE,SAASC,UAAU,QAAQ,qBAAqB;AAGhD,MAAMC,YAAY,CAACC;IACfL,KAAKM,gBAAgB,CAACT,KAAKQ,MAAM,kBAAkB;QAC/CE,WAAWN,UAAUO,KAAK;QAC1BC,QAAQZ,KAAKQ,MAAM;QACnBK,WAAW;QACXC,gBAAgBd,KAAKQ,MAAM,OAAO;QAClCO,YAAY;YACR;gBACIC,MAAMhB,KACFM,YACA,OACA,YACA,kBACA;YAER;SACH;IACL;AACJ;AAEA,OAAO,MAAMW,YAAY,CAAC,EAAET,IAAI,EAAoB;IAChD,MAAMU,QAAQhB,QACV,IAAM;YACF;gBACIiB,oBAAoB;gBACpBC,kBAAkB;gBAClBC,oBAAoB;gBACpBC,qBAAqB,IAAM;gBAC3BC,QAAQ;oBACJhB,UAAUC;gBACd;gBACAgB,OAAO;YACX;SACH,EACD,EAAE;IAGN,qBAAO,oBAACnB;QAAUa,OAAOA;QAAOO,UAAUC,QAAQC,IAAI;;AAC1D,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './TranspileCommand.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/index.ts"],"sourcesContent":["export * from './TranspileCommand.js';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,wBAAwB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/cli/src/commands/TranspileCommand/plugin.cts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as tstl from 'typescript-to-lua';\nimport { FunctionVisitor, TransformationContext } from 'typescript-to-lua';\nimport * as lua from 'typescript-to-lua/dist/LuaAST';\nimport { ScopeType } from 'typescript-to-lua/dist/transformation/utils/scope';\nimport { transformCallAndArguments } from 'typescript-to-lua/dist/transformation/visitors/call';\nimport { transformClassInstanceFields } from 'typescript-to-lua/dist/transformation/visitors/class/members/fields';\nimport {\n getExtendedNode,\n isStaticNode,\n} from 'typescript-to-lua/dist/transformation/visitors/class/utils';\nimport {\n transformFunctionBodyContent,\n transformFunctionToExpression,\n transformParameters,\n} from 'typescript-to-lua/dist/transformation/visitors/function';\n\nfunction createClassCall(\n context: tstl.TransformationContext,\n className: tstl.Identifier,\n extendsNode?: ts.ExpressionWithTypeArguments\n): tstl.Statement {\n // class('X')\n const classCall = tstl.createCallExpression(\n tstl.createIdentifier('class'),\n [tstl.createStringLiteral(className.text)]\n );\n let classCreationExpression: tstl.Expression;\n if (extendsNode) {\n // class('X').extends(Blah)\n classCreationExpression = tstl.createCallExpression(\n tstl.createTableIndexExpression(\n classCall,\n tstl.createStringLiteral('extends')\n ),\n [context.transformExpression(extendsNode.expression)]\n );\n } else {\n classCreationExpression = tstl.createCallExpression(\n tstl.createTableIndexExpression(\n classCall,\n tstl.createStringLiteral('extends')\n ),\n [tstl.createIdentifier('Object')]\n );\n }\n return tstl.createExpressionStatement(classCreationExpression);\n}\n\nexport function transformPropertyName(\n context: TransformationContext,\n node: ts.PropertyName\n): tstl.Expression {\n if (ts.isComputedPropertyName(node)) {\n return context.transformExpression(node.expression);\n } else if (ts.isIdentifier(node)) {\n return tstl.createStringLiteral(node.text);\n } else if (ts.isPrivateIdentifier(node)) {\n throw new Error('PrivateIdentifier is not supported');\n } else {\n return context.transformExpression(node);\n }\n}\n\nfunction transformConstructor(\n context: TransformationContext,\n className: tstl.Identifier,\n instanceFields: ts.PropertyDeclaration[],\n constructor?: ts.ConstructorDeclaration\n): tstl.Statement | undefined {\n const methodName = 'init';\n context.pushScope(ScopeType.Function);\n const bodyStatements: tstl.Statement[] = [];\n let params: tstl.Identifier[];\n if (constructor) {\n [params] = transformParameters(\n context,\n constructor?.parameters,\n tstl.createIdentifier('self')\n );\n } else {\n params = [tstl.createIdentifier('self')];\n }\n bodyStatements.push(\n tstl.createExpressionStatement(\n tstl.createCallExpression(\n tstl.createTableIndexExpression(\n tstl.createTableIndexExpression(\n className,\n tstl.createStringLiteral('super')\n ),\n tstl.createStringLiteral('init')\n ),\n params\n )\n )\n );\n const classInstanceFields = transformClassInstanceFields(\n context,\n instanceFields\n );\n // initializers have to come before any body of the constructor\n bodyStatements.push(...classInstanceFields);\n if (constructor?.body) {\n const body = transformFunctionBodyContent(context, constructor.body);\n // if the first expression in the body is a super call, ignore it, because we have\n // constructed our own super call.\n // if it's not, make sure to include the entire body.\n const firstStatement = constructor.body.statements[0];\n if (\n firstStatement &&\n ts.isExpressionStatement(firstStatement) &&\n ts.isCallExpression(firstStatement.expression) &&\n firstStatement.expression.expression.kind ===\n ts.SyntaxKind.SuperKeyword\n ) {\n bodyStatements.push(...body.slice(1));\n } else {\n bodyStatements.push(...body);\n }\n }\n context.popScope();\n return tstl.createAssignmentStatement(\n tstl.createTableIndexExpression(\n className,\n tstl.createStringLiteral(methodName)\n ),\n tstl.createFunctionExpression(tstl.createBlock(bodyStatements), params)\n );\n}\n\nfunction transformMethodDeclaration(\n context: TransformationContext,\n node: ts.MethodDeclaration,\n className: tstl.Identifier\n): tstl.Statement | undefined {\n const [functionExpression] = transformFunctionToExpression(context, node);\n return tstl.createAssignmentStatement(\n tstl.createTableIndexExpression(\n className,\n transformPropertyName(context, node.name)\n ),\n functionExpression\n );\n}\ninterface ClassSuperInfo {\n className: lua.Identifier;\n extendedTypeNode?: ts.ExpressionWithTypeArguments;\n}\n\nexport const transformClassDeclaration: FunctionVisitor<\n ts.ClassLikeDeclaration\n> = (\n declaration,\n context: TransformationContext & { classSuperInfos?: [ClassSuperInfo] }\n) => {\n let className: tstl.Identifier;\n if (declaration.name) {\n className = tstl.createIdentifier(declaration.name.text);\n } else {\n className = tstl.createIdentifier(\n context.createTempName('class'),\n declaration\n );\n }\n\n const extension = getExtendedNode(declaration);\n if (context.classSuperInfos) {\n context.classSuperInfos.push({\n className,\n extendedTypeNode: extension,\n });\n } else {\n context.classSuperInfos = [{ className, extendedTypeNode: extension }];\n }\n\n // Get all properties with value\n const properties = declaration.members\n .filter(ts.isPropertyDeclaration)\n .filter((member) => member.initializer);\n\n // Divide properties into static and non-static\n const instanceFields = properties.filter((prop) => !isStaticNode(prop));\n\n const statements: tstl.Statement[] = [];\n\n // class('X')\n statements.push(createClassCall(context, className, extension));\n\n // function X:init()\n // X.super.init(self)\n // end\n const constructor = declaration.members.find(\n (n): n is ts.ConstructorDeclaration =>\n ts.isConstructorDeclaration(n) && n.body !== undefined\n );\n const transformedConstructor = transformConstructor(\n context,\n className,\n instanceFields,\n constructor\n );\n if (transformedConstructor) {\n statements.push(transformedConstructor);\n }\n\n const methods = declaration.members\n .filter(ts.isMethodDeclaration)\n .map((method) => transformMethodDeclaration(context, method, className))\n .filter((method): method is tstl.Statement => method !== undefined);\n statements.push(...methods);\n\n return statements;\n};\n\nconst transformNewExpression: FunctionVisitor<ts.NewExpression> = (\n node,\n context\n) => {\n const signature = context.checker.getResolvedSignature(node);\n const [name, params] = transformCallAndArguments(\n context,\n node.expression,\n node.arguments ?? [ts.factory.createTrue()],\n signature\n );\n return tstl.createCallExpression(name, params);\n};\n\nexport const transformSuperExpression: FunctionVisitor<ts.SuperExpression> = (\n expression,\n context: TransformationContext & { classSuperInfos?: ClassSuperInfo[] }\n) => {\n const superInfos = context.classSuperInfos;\n let superInfo: ClassSuperInfo | undefined = undefined;\n if (superInfos) {\n superInfo = superInfos[superInfos.length - 1];\n }\n if (!superInfo) return lua.createAnonymousIdentifier(expression);\n const { className } = superInfo;\n\n // Using `super` without extended type node is a TypeScript error\n // const extendsExpression = extendedTypeNode?.expression;\n // let baseClassName: lua.AssignmentLeftHandSideExpression | undefined;\n\n // if (extendsExpression && ts.isIdentifier(extendsExpression)) {\n // const symbol = context.checker.getSymbolAtLocation(extendsExpression);\n // if (symbol && !isSymbolExported(context, symbol)) {\n // // Use \"baseClassName\" if base is a simple identifier\n // baseClassName = transformIdentifier(context, extendsExpression);\n // }\n // }\n\n // if (!baseClassName) {\n // // Use \"className.____super\" if the base is not a simple identifier\n // baseClassName = lua.createTableIndexExpression(\n // className,\n // lua.createStringLiteral('____super'),\n // expression\n // );\n // }\n\n return lua.createTableIndexExpression(\n className,\n lua.createStringLiteral('super')\n );\n};\n\nconst plugin = {\n visitors: {\n [ts.SyntaxKind.ClassDeclaration]: transformClassDeclaration,\n [ts.SyntaxKind.SuperKeyword]: transformSuperExpression,\n [ts.SyntaxKind.NewExpression]: transformNewExpression,\n [ts.SyntaxKind.CallExpression]: (node, context) => {\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.escapedText === 'require'\n ) {\n const normalNode = context.superTransformExpression(\n node\n ) as unknown as {\n expression: { text: string; originalName: string };\n };\n\n normalNode.expression.text = 'import';\n normalNode.expression.originalName = 'import';\n\n return normalNode as unknown as lua.Expression;\n } else {\n return context.superTransformExpression(node);\n }\n },\n },\n} satisfies tstl.Plugin;\n\nexport default plugin;\n"],"names":["ts","tstl","lua","ScopeType","transformCallAndArguments","transformClassInstanceFields","getExtendedNode","isStaticNode","transformFunctionBodyContent","transformFunctionToExpression","transformParameters","createClassCall","context","className","extendsNode","classCall","createCallExpression","createIdentifier","createStringLiteral","text","classCreationExpression","createTableIndexExpression","transformExpression","expression","createExpressionStatement","transformPropertyName","node","isComputedPropertyName","isIdentifier","isPrivateIdentifier","Error","transformConstructor","instanceFields","constructor","methodName","pushScope","Function","bodyStatements","params","parameters","push","classInstanceFields","body","firstStatement","statements","isExpressionStatement","isCallExpression","kind","SyntaxKind","SuperKeyword","slice","popScope","createAssignmentStatement","createFunctionExpression","createBlock","transformMethodDeclaration","functionExpression","name","transformClassDeclaration","declaration","createTempName","extension","classSuperInfos","extendedTypeNode","properties","members","filter","isPropertyDeclaration","member","initializer","prop","find","n","isConstructorDeclaration","undefined","transformedConstructor","methods","isMethodDeclaration","map","method","transformNewExpression","signature","checker","getResolvedSignature","arguments","factory","createTrue","transformSuperExpression","superInfos","superInfo","length","createAnonymousIdentifier","plugin","visitors","ClassDeclaration","NewExpression","CallExpression","escapedText","normalNode","superTransformExpression","originalName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,QAAQ,aAAa;AACjC,YAAYC,UAAU,oBAAoB;AAE1C,YAAYC,SAAS,gCAAgC;AACrD,SAASC,SAAS,QAAQ,oDAAoD;AAC9E,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,4BAA4B,QAAQ,sEAAsE;AACnH,SACIC,eAAe,EACfC,YAAY,QACT,6DAA6D;AACp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C,CAAC1D,GAAGgD,UAAU,CAACC,YAAY,CAAC,EAAEsC;QAC9B,CAACvF,GAAGgD,UAAU,CAAC+C,aAAa,CAAC,EAAEf;QAC/B,CAAChF,GAAGgD,UAAU,CAACgD,cAAc,CAAC,EAAE,CAACtE,MAAMd;YACnC,IACIZ,GAAG4B,YAAY,CAACF,KAAKH,UAAU,KAC/BG,KAAKH,UAAU,CAAC0E,WAAW,KAAK,WAClC;gBACE,MAAMC,aAAatF,QAAQuF,wBAAwB,CAC/CzE;gBAKJwE,WAAW3E,UAAU,CAACJ,IAAI,GAAG;gBAC7B+E,WAAW3E,UAAU,CAAC6E,YAAY,GAAG;gBAErC,OAAOF;YACX,OAAO;gBACH,OAAOtF,QAAQuF,wBAAwB,CAACzE;YAC5C;QACJ;IACJ;AACJ;AAEA,eAAekE,OAAO"}
|
package/src/index.js
CHANGED
@@ -5,6 +5,7 @@ import { 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';
|
8
|
+
import { TranspileCommand } from './commands/TranspileCommand/index.js';
|
8
9
|
import { RootFolder } from './constants.js';
|
9
10
|
const packageJsonContents = readFileSync(join(RootFolder, 'package.json'), 'utf-8');
|
10
11
|
const packageJson = JSON.parse(packageJsonContents);
|
@@ -15,8 +16,9 @@ const cli = new Cli({
|
|
15
16
|
binaryVersion: packageJson.version
|
16
17
|
});
|
17
18
|
cli.register(DoctorCommand);
|
18
|
-
cli.register(
|
19
|
+
cli.register(TranspileCommand);
|
19
20
|
cli.register(CompileCommand);
|
21
|
+
cli.register(GenerateTypesCommand);
|
20
22
|
cli.runExit(args);
|
21
23
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
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 { 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\ncli.register(DoctorCommand);\ncli.register(
|
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 { 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\ncli.register(DoctorCommand);\ncli.register(TranspileCommand);\ncli.register(CompileCommand);\ncli.register(GenerateTypesCommand);\ncli.runExit(args);\n"],"names":["readFileSync","join","Cli","CompileCommand","DoctorCommand","GenerateTypesCommand","TranspileCommand","RootFolder","packageJsonContents","packageJson","JSON","parse","args","process","argv","slice","cli","binaryLabel","binaryName","binaryVersion","version","register","runExit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";AAEA,SAASA,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,GAAG,QAAQ,YAAY;AAChC,SAASC,cAAc,QAAQ,yCAAyC;AACxE,SAASC,aAAa,QAAQ,kCAAkC;AAChE,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,UAAU,QAAQ,qBAAqB;AAEhD,MAAMC,sBAAsBR,aACxBC,KAAKM,YAAY,iBACjB;AAEJ,MAAME,cAAcC,KAAKC,KAAK,CAACH;AAE/B,MAAMI,OAAOC,QAAQC,IAAI,CAACC,KAAK,CAAC;AAEhC,MAAMC,MAAM,IAAId,IAAI;IAChBe,aAAa;IACbC,YAAY;IACZC,eAAeV,YAAYW,OAAO;AACtC;AAEAJ,IAAIK,QAAQ,CAACjB;AACbY,IAAIK,QAAQ,CAACf;AACbU,IAAIK,QAAQ,CAAClB;AACba,IAAIK,QAAQ,CAAChB;AACbW,IAAIM,OAAO,CAACV"}
|
package/src/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FunctionDeclarationStructure,
|
1
|
+
import { FunctionDeclarationStructure, MethodDeclarationStructure, ParameterDeclarationStructure } from 'ts-morph';
|
2
2
|
import { Environment } from './environment/dto/Environment.js';
|
3
3
|
import { PlaydateSdkPath } from './environment/path/dto/PlaydateSdkPath.js';
|
4
4
|
export declare enum PlaydateSdkVersionIdentifier {
|
@@ -72,6 +72,7 @@ export interface PlaydateType {
|
|
72
72
|
methods: FunctionDescription[];
|
73
73
|
}
|
74
74
|
export interface ApiDefinitions {
|
75
|
+
rootNamespace: PlaydateNamespace;
|
75
76
|
namespaces: Record<string, PlaydateNamespace>;
|
76
77
|
types: Record<string, PlaydateType>;
|
77
78
|
}
|
@@ -91,7 +92,7 @@ export interface FunctionDetails {
|
|
91
92
|
parameters: ParameterDetails[];
|
92
93
|
returnType: string;
|
93
94
|
overrideParameters?: boolean;
|
94
|
-
overrideOptions?: Partial<FunctionDeclarationStructure |
|
95
|
+
overrideOptions?: Partial<FunctionDeclarationStructure | MethodDeclarationStructure>;
|
95
96
|
}
|
96
97
|
export type TypeProviderData = {
|
97
98
|
globalStatements: string[];
|
package/src/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ParameterDeclarationStructure,\n} from 'ts-morph';\nimport { Environment } from '@/cli/environment/dto/Environment.js';\nimport { PlaydateSdkPath } from '@/cli/environment/path/dto/PlaydateSdkPath.js';\n\nexport enum PlaydateSdkVersionIdentifier {\n Latest = 'latest',\n}\n\nexport type PlaydateSdkVersion = PlaydateSdkVersionIdentifier.Latest | string;\n\nexport type EnvironmentHealthResult =\n | {\n isHealthy: true;\n environment: Environment;\n health: EnvironmentHealth;\n }\n | {\n isHealthy: false;\n health: EnvironmentHealth;\n };\n\nexport enum HealthCheckStatusType {\n Healthy = 'Healthy',\n Unhealthy = 'Unhealthy',\n Unknown = 'Unknown',\n}\n\nexport type HealthCheckStatus<TArgument> =\n | {\n healthStatus:\n | HealthCheckStatusType.Unknown\n | HealthCheckStatusType.Unhealthy;\n }\n | {\n healthStatus: HealthCheckStatusType.Healthy;\n argument: TArgument;\n };\n\nexport interface EnvironmentHealth {\n sdkPathKnown: HealthCheckStatus<PlaydateSdkPath>;\n}\n\nexport type CheckListItem<TResult> = {\n runningDescription: string;\n waitingDescription: string;\n errorDescription: string;\n finishedDescription: (result: TResult) => string;\n runner: () => Promise<TResult> | Promise<false>;\n onFinish?: (result: TResult) => void;\n ready?: boolean;\n};\n\nexport interface ParameterDescription {\n name: string;\n required: boolean;\n}\n\nexport interface PropertyDescription {\n signature: string;\n name: string;\n namespaces: string[];\n docs: string;\n}\n\nexport interface FunctionDescription {\n signature: string;\n name: string;\n namespaces: string[];\n parameters: ParameterDescription[];\n hasSelf: boolean;\n docs: string;\n}\n\nexport interface ConstantDescription {\n name: string;\n docs: string;\n values: {\n name: string;\n value: number;\n docs: string;\n }[];\n}\n\nexport interface PlaydateNamespace {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n}\n\nexport interface PlaydateType {\n methods: FunctionDescription[];\n}\n\nexport interface ApiDefinitions {\n rootNamespace: PlaydateNamespace;\n namespaces: Record<string, PlaydateNamespace>;\n types: Record<string, PlaydateType>;\n}\n\nexport interface ParameterDetails {\n name: string;\n type: string;\n overrideOptions?: Partial<\n Omit<ParameterDeclarationStructure, 'kind' | 'name' | 'type'>\n >;\n}\n\nexport interface PropertyDetails {\n signature: string;\n type: string;\n isStatic?: boolean;\n isReadOnly?: boolean;\n}\n\nexport interface FunctionDetails {\n signature: string;\n parameters: ParameterDetails[];\n returnType: string;\n overrideParameters?: boolean;\n overrideOptions?: Partial<\n FunctionDeclarationStructure | MethodDeclarationStructure\n >;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType"],"rangeMappings":";;;;;;;;;","mappings":";UAQYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/cli/src/commands/CompileCommand/plugin.cts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as tstl from 'typescript-to-lua';\nimport { FunctionVisitor, TransformationContext } from 'typescript-to-lua';\nimport * as lua from 'typescript-to-lua/dist/LuaAST';\nimport { ScopeType } from 'typescript-to-lua/dist/transformation/utils/scope';\nimport { transformCallAndArguments } from 'typescript-to-lua/dist/transformation/visitors/call';\nimport { transformClassInstanceFields } from 'typescript-to-lua/dist/transformation/visitors/class/members/fields';\nimport {\n getExtendedNode,\n isStaticNode,\n} from 'typescript-to-lua/dist/transformation/visitors/class/utils';\nimport {\n transformFunctionBodyContent,\n transformFunctionToExpression,\n transformParameters,\n} from 'typescript-to-lua/dist/transformation/visitors/function';\n\nfunction createClassCall(\n context: tstl.TransformationContext,\n className: tstl.Identifier,\n extendsNode?: ts.ExpressionWithTypeArguments\n): tstl.Statement {\n // class('X')\n const classCall = tstl.createCallExpression(\n tstl.createIdentifier('class'),\n [tstl.createStringLiteral(className.text)]\n );\n let classCreationExpression: tstl.Expression;\n if (extendsNode) {\n // class('X').extends(Blah)\n classCreationExpression = tstl.createCallExpression(\n tstl.createTableIndexExpression(\n classCall,\n tstl.createStringLiteral('extends')\n ),\n [context.transformExpression(extendsNode.expression)]\n );\n } else {\n classCreationExpression = tstl.createCallExpression(\n tstl.createTableIndexExpression(\n classCall,\n tstl.createStringLiteral('extends')\n ),\n [tstl.createIdentifier('Object')]\n );\n }\n return tstl.createExpressionStatement(classCreationExpression);\n}\n\nexport function transformPropertyName(\n context: TransformationContext,\n node: ts.PropertyName\n): tstl.Expression {\n if (ts.isComputedPropertyName(node)) {\n return context.transformExpression(node.expression);\n } else if (ts.isIdentifier(node)) {\n return tstl.createStringLiteral(node.text);\n } else if (ts.isPrivateIdentifier(node)) {\n throw new Error('PrivateIdentifier is not supported');\n } else {\n return context.transformExpression(node);\n }\n}\n\nfunction transformConstructor(\n context: TransformationContext,\n className: tstl.Identifier,\n instanceFields: ts.PropertyDeclaration[],\n constructor?: ts.ConstructorDeclaration\n): tstl.Statement | undefined {\n const methodName = 'init';\n context.pushScope(ScopeType.Function);\n const bodyStatements: tstl.Statement[] = [];\n let params: tstl.Identifier[];\n if (constructor) {\n [params] = transformParameters(\n context,\n constructor?.parameters,\n tstl.createIdentifier('self')\n );\n } else {\n params = [tstl.createIdentifier('self')];\n }\n bodyStatements.push(\n tstl.createExpressionStatement(\n tstl.createCallExpression(\n tstl.createTableIndexExpression(\n tstl.createTableIndexExpression(\n className,\n tstl.createStringLiteral('super')\n ),\n tstl.createStringLiteral('init')\n ),\n params\n )\n )\n );\n const classInstanceFields = transformClassInstanceFields(\n context,\n instanceFields\n );\n // initializers have to come before any body of the constructor\n bodyStatements.push(...classInstanceFields);\n if (constructor?.body) {\n const body = transformFunctionBodyContent(context, constructor.body);\n // if the first expression in the body is a super call, ignore it, because we have\n // constructed our own super call.\n // if it's not, make sure to include the entire body.\n const firstStatement = constructor.body.statements[0];\n if (\n firstStatement &&\n ts.isExpressionStatement(firstStatement) &&\n ts.isCallExpression(firstStatement.expression) &&\n firstStatement.expression.expression.kind ===\n ts.SyntaxKind.SuperKeyword\n ) {\n bodyStatements.push(...body.slice(1));\n } else {\n bodyStatements.push(...body);\n }\n }\n context.popScope();\n return tstl.createAssignmentStatement(\n tstl.createTableIndexExpression(\n className,\n tstl.createStringLiteral(methodName)\n ),\n tstl.createFunctionExpression(tstl.createBlock(bodyStatements), params)\n );\n}\n\nfunction transformMethodDeclaration(\n context: TransformationContext,\n node: ts.MethodDeclaration,\n className: tstl.Identifier\n): tstl.Statement | undefined {\n const [functionExpression] = transformFunctionToExpression(context, node);\n return tstl.createAssignmentStatement(\n tstl.createTableIndexExpression(\n className,\n transformPropertyName(context, node.name)\n ),\n functionExpression\n );\n}\ninterface ClassSuperInfo {\n className: lua.Identifier;\n extendedTypeNode?: ts.ExpressionWithTypeArguments;\n}\n\nexport const transformClassDeclaration: FunctionVisitor<\n ts.ClassLikeDeclaration\n> = (\n declaration,\n context: TransformationContext & { classSuperInfos?: [ClassSuperInfo] }\n) => {\n let className: tstl.Identifier;\n if (declaration.name) {\n className = tstl.createIdentifier(declaration.name.text);\n } else {\n className = tstl.createIdentifier(\n context.createTempName('class'),\n declaration\n );\n }\n\n const extension = getExtendedNode(declaration);\n if (context.classSuperInfos) {\n context.classSuperInfos.push({\n className,\n extendedTypeNode: extension,\n });\n } else {\n context.classSuperInfos = [{ className, extendedTypeNode: extension }];\n }\n\n // Get all properties with value\n const properties = declaration.members\n .filter(ts.isPropertyDeclaration)\n .filter((member) => member.initializer);\n\n // Divide properties into static and non-static\n const instanceFields = properties.filter((prop) => !isStaticNode(prop));\n\n const statements: tstl.Statement[] = [];\n\n // class('X')\n statements.push(createClassCall(context, className, extension));\n\n // function X:init()\n // X.super.init(self)\n // end\n const constructor = declaration.members.find(\n (n): n is ts.ConstructorDeclaration =>\n ts.isConstructorDeclaration(n) && n.body !== undefined\n );\n const transformedConstructor = transformConstructor(\n context,\n className,\n instanceFields,\n constructor\n );\n if (transformedConstructor) {\n statements.push(transformedConstructor);\n }\n\n const methods = declaration.members\n .filter(ts.isMethodDeclaration)\n .map((method) => transformMethodDeclaration(context, method, className))\n .filter((method): method is tstl.Statement => method !== undefined);\n statements.push(...methods);\n\n return statements;\n};\n\nconst transformNewExpression: FunctionVisitor<ts.NewExpression> = (\n node,\n context\n) => {\n const signature = context.checker.getResolvedSignature(node);\n const [name, params] = transformCallAndArguments(\n context,\n node.expression,\n node.arguments ?? [ts.factory.createTrue()],\n signature\n );\n return tstl.createCallExpression(name, params);\n};\n\nexport const transformSuperExpression: FunctionVisitor<ts.SuperExpression> = (\n expression,\n context: TransformationContext & { classSuperInfos?: ClassSuperInfo[] }\n) => {\n const superInfos = context.classSuperInfos;\n let superInfo: ClassSuperInfo | undefined = undefined;\n if (superInfos) {\n superInfo = superInfos[superInfos.length - 1];\n }\n if (!superInfo) return lua.createAnonymousIdentifier(expression);\n const { className } = superInfo;\n\n // Using `super` without extended type node is a TypeScript error\n // const extendsExpression = extendedTypeNode?.expression;\n // let baseClassName: lua.AssignmentLeftHandSideExpression | undefined;\n\n // if (extendsExpression && ts.isIdentifier(extendsExpression)) {\n // const symbol = context.checker.getSymbolAtLocation(extendsExpression);\n // if (symbol && !isSymbolExported(context, symbol)) {\n // // Use \"baseClassName\" if base is a simple identifier\n // baseClassName = transformIdentifier(context, extendsExpression);\n // }\n // }\n\n // if (!baseClassName) {\n // // Use \"className.____super\" if the base is not a simple identifier\n // baseClassName = lua.createTableIndexExpression(\n // className,\n // lua.createStringLiteral('____super'),\n // expression\n // );\n // }\n\n return lua.createTableIndexExpression(\n className,\n lua.createStringLiteral('super')\n );\n};\n\nconst plugin = {\n visitors: {\n [ts.SyntaxKind.ClassDeclaration]: transformClassDeclaration,\n [ts.SyntaxKind.SuperKeyword]: transformSuperExpression,\n [ts.SyntaxKind.NewExpression]: transformNewExpression,\n [ts.SyntaxKind.CallExpression]: (node, context) => {\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.escapedText === 'require'\n ) {\n const normalNode = context.superTransformExpression(\n node\n ) as unknown as {\n expression: { text: string; originalName: string };\n };\n\n normalNode.expression.text = 'import';\n normalNode.expression.originalName = 'import';\n\n return normalNode as unknown as lua.Expression;\n } else {\n return context.superTransformExpression(node);\n }\n },\n },\n} satisfies tstl.Plugin;\n\nexport default plugin;\n"],"names":["ts","tstl","lua","ScopeType","transformCallAndArguments","transformClassInstanceFields","getExtendedNode","isStaticNode","transformFunctionBodyContent","transformFunctionToExpression","transformParameters","createClassCall","context","className","extendsNode","classCall","createCallExpression","createIdentifier","createStringLiteral","text","classCreationExpression","createTableIndexExpression","transformExpression","expression","createExpressionStatement","transformPropertyName","node","isComputedPropertyName","isIdentifier","isPrivateIdentifier","Error","transformConstructor","instanceFields","constructor","methodName","pushScope","Function","bodyStatements","params","parameters","push","classInstanceFields","body","firstStatement","statements","isExpressionStatement","isCallExpression","kind","SyntaxKind","SuperKeyword","slice","popScope","createAssignmentStatement","createFunctionExpression","createBlock","transformMethodDeclaration","functionExpression","name","transformClassDeclaration","declaration","createTempName","extension","classSuperInfos","extendedTypeNode","properties","members","filter","isPropertyDeclaration","member","initializer","prop","find","n","isConstructorDeclaration","undefined","transformedConstructor","methods","isMethodDeclaration","map","method","transformNewExpression","signature","checker","getResolvedSignature","arguments","factory","createTrue","transformSuperExpression","superInfos","superInfo","length","createAnonymousIdentifier","plugin","visitors","ClassDeclaration","NewExpression","CallExpression","escapedText","normalNode","superTransformExpression","originalName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,QAAQ,aAAa;AACjC,YAAYC,UAAU,oBAAoB;AAE1C,YAAYC,SAAS,gCAAgC;AACrD,SAASC,SAAS,QAAQ,oDAAoD;AAC9E,SAASC,yBAAyB,QAAQ,sDAAsD;AAChG,SAASC,4BAA4B,QAAQ,sEAAsE;AACnH,SACIC,eAAe,EACfC,YAAY,QACT,6DAA6D;AACpE,SACIC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,mBAAmB,QAChB,0DAA0D;AAEjE,SAASC,gBACLC,OAAmC,EACnCC,SAA0B,EAC1BC,WAA4C;IAE5C,aAAa;IACb,MAAMC,YAAYd,KAAKe,oBAAoB,CACvCf,KAAKgB,gBAAgB,CAAC,UACtB;QAAChB,KAAKiB,mBAAmB,CAACL,UAAUM,IAAI;KAAE;IAE9C,IAAIC;IACJ,IAAIN,aAAa;QACb,2BAA2B;QAC3BM,0BAA0BnB,KAAKe,oBAAoB,CAC/Cf,KAAKoB,0BAA0B,CAC3BN,WACAd,KAAKiB,mBAAmB,CAAC,aAE7B;YAACN,QAAQU,mBAAmB,CAACR,YAAYS,UAAU;SAAE;IAE7D,OAAO;QACHH,0BAA0BnB,KAAKe,oBAAoB,CAC/Cf,KAAKoB,0BAA0B,CAC3BN,WACAd,KAAKiB,mBAAmB,CAAC,aAE7B;YAACjB,KAAKgB,gBAAgB,CAAC;SAAU;IAEzC;IACA,OAAOhB,KAAKuB,yBAAyB,CAACJ;AAC1C;AAEA,OAAO,SAASK,sBACZb,OAA8B,EAC9Bc,IAAqB;IAErB,IAAI1B,GAAG2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