crankscript 0.10.7 → 0.11.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/assets/ImportMap/ImportMap.d.ts +8 -0
- package/assets/ImportMap/ImportMap.js +83 -0
- package/assets/ImportMap/ImportMap.js.map +1 -0
- package/assets/ImportMap/index.d.ts +1 -0
- package/assets/ImportMap/index.js +8 -0
- package/assets/ImportMap/index.js.map +1 -0
- package/assets/beforeEmit/getBeforeEmit.d.ts +2 -0
- package/assets/beforeEmit/getBeforeEmit.js +22 -0
- package/assets/beforeEmit/getBeforeEmit.js.map +1 -0
- package/assets/beforeEmit/index.d.ts +1 -0
- package/assets/beforeEmit/index.js +8 -0
- package/assets/beforeEmit/index.js.map +1 -0
- package/assets/beforeEmit/withAutomaticImportWarning.d.ts +1 -0
- package/assets/beforeEmit/withAutomaticImportWarning.js +15 -0
- package/assets/beforeEmit/withAutomaticImportWarning.js.map +1 -0
- package/assets/index.d.ts +14 -0
- package/assets/index.js +32 -0
- package/assets/index.js.map +1 -0
- package/assets/transformCallExpression/getTransformCallExpression.d.ts +4 -0
- package/assets/transformCallExpression/getTransformCallExpression.js +29 -0
- package/assets/transformCallExpression/getTransformCallExpression.js.map +1 -0
- package/assets/transformCallExpression/index.d.ts +1 -0
- package/assets/transformCallExpression/index.js +8 -0
- package/assets/transformCallExpression/index.js.map +1 -0
- package/assets/transformClassDeclaration/createClasCall.d.ts +3 -0
- package/assets/transformClassDeclaration/createClasCall.js +32 -0
- package/assets/transformClassDeclaration/createClasCall.js.map +1 -0
- package/assets/transformClassDeclaration/getExportedClassDeclarationStatements.d.ts +3 -0
- package/assets/transformClassDeclaration/getExportedClassDeclarationStatements.js +23 -0
- package/assets/transformClassDeclaration/getExportedClassDeclarationStatements.js.map +1 -0
- package/assets/transformClassDeclaration/getTransformClassDeclaration.d.ts +5 -0
- package/assets/transformClassDeclaration/getTransformClassDeclaration.js +72 -0
- package/assets/transformClassDeclaration/getTransformClassDeclaration.js.map +1 -0
- package/assets/transformClassDeclaration/index.d.ts +1 -0
- package/assets/transformClassDeclaration/index.js +8 -0
- package/assets/transformClassDeclaration/index.js.map +1 -0
- package/assets/transformClassDeclaration/transformConstructor.d.ts +4 -0
- package/assets/transformClassDeclaration/transformConstructor.js +51 -0
- package/assets/transformClassDeclaration/transformConstructor.js.map +1 -0
- package/assets/transformClassDeclaration/transformMethodDeclaration.d.ts +4 -0
- package/assets/transformClassDeclaration/transformMethodDeclaration.js +20 -0
- package/assets/transformClassDeclaration/transformMethodDeclaration.js.map +1 -0
- package/assets/transformClassDeclaration/transformPropertyName.d.ts +3 -0
- package/assets/transformClassDeclaration/transformPropertyName.js +26 -0
- package/assets/transformClassDeclaration/transformPropertyName.js.map +1 -0
- package/assets/transformNewExpression/index.d.ts +1 -0
- package/assets/transformNewExpression/index.js +8 -0
- package/assets/transformNewExpression/index.js.map +1 -0
- package/assets/transformNewExpression/transformNewExpression.d.ts +3 -0
- package/assets/transformNewExpression/transformNewExpression.js +24 -0
- package/assets/transformNewExpression/transformNewExpression.js.map +1 -0
- package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.d.ts +3 -0
- package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js +22 -0
- package/assets/transformPropertyAccessExpression/getTransformPropertyAccessExpression.js.map +1 -0
- package/assets/transformPropertyAccessExpression/index.d.ts +1 -0
- package/assets/transformPropertyAccessExpression/index.js +8 -0
- package/assets/transformPropertyAccessExpression/index.js.map +1 -0
- package/assets/transformSuperExpression/index.d.ts +1 -0
- package/assets/transformSuperExpression/index.js +8 -0
- package/assets/transformSuperExpression/index.js.map +1 -0
- package/assets/transformSuperExpression/transformSuperExpression.d.ts +7 -0
- package/assets/transformSuperExpression/transformSuperExpression.js +24 -0
- package/assets/transformSuperExpression/transformSuperExpression.js.map +1 -0
- package/assets/types.d.ts +6 -0
- package/assets/types.js +6 -0
- package/assets/types.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js +10 -1
- package/src/commands/GenerateTypes/hooks/useGenerateTypeFile.js.map +1 -1
- package/src/commands/GenerateTypes/hooks/useGetVersion.d.ts +5 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.d.ts +5 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.js +13 -0
- package/src/commands/GenerateTypes/utils/createTypeProvider.js.map +1 -1
- package/src/commands/TranspileCommand/fn/_tests/test-automatic-imports/src/index.js +3 -0
- package/src/commands/TranspileCommand/fn/_tests/test-automatic-imports/src/index.js.map +1 -0
- package/src/types.d.ts +5 -0
- package/src/types.js.map +1 -1
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "ImportMap", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return ImportMap;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
let ImportMap = class ImportMap {
|
12
|
+
toArray() {
|
13
|
+
return Array.from(this.imports);
|
14
|
+
}
|
15
|
+
map(callback) {
|
16
|
+
return this.toArray().map(callback);
|
17
|
+
}
|
18
|
+
add(importName) {
|
19
|
+
this.imports.add(importName);
|
20
|
+
}
|
21
|
+
processName(name) {
|
22
|
+
for (const [key, value] of Object.entries(ImportMap.map)){
|
23
|
+
if (value.has(name)) {
|
24
|
+
this.add(key);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
constructor(){
|
29
|
+
this.imports = new Set();
|
30
|
+
}
|
31
|
+
};
|
32
|
+
ImportMap.map = {
|
33
|
+
graphics: new Set([
|
34
|
+
'graphics'
|
35
|
+
]),
|
36
|
+
sprites: new Set([
|
37
|
+
'sprite'
|
38
|
+
]),
|
39
|
+
crank: new Set([
|
40
|
+
'getCrankTicks'
|
41
|
+
]),
|
42
|
+
object: new Set([
|
43
|
+
'printTable'
|
44
|
+
]),
|
45
|
+
'utilities/where': new Set([
|
46
|
+
'where'
|
47
|
+
]),
|
48
|
+
easing: new Set([
|
49
|
+
'easingFunctions'
|
50
|
+
]),
|
51
|
+
nineSlice: new Set([
|
52
|
+
'nineSlice'
|
53
|
+
]),
|
54
|
+
qrcode: new Set([
|
55
|
+
'generateQRCode'
|
56
|
+
]),
|
57
|
+
animation: new Set([
|
58
|
+
'animation'
|
59
|
+
]),
|
60
|
+
animator: new Set([
|
61
|
+
'animator'
|
62
|
+
]),
|
63
|
+
keyboard: new Set([
|
64
|
+
'keyboard'
|
65
|
+
]),
|
66
|
+
math: new Set([
|
67
|
+
'math'
|
68
|
+
]),
|
69
|
+
string: new Set([
|
70
|
+
'string'
|
71
|
+
]),
|
72
|
+
timer: new Set([
|
73
|
+
'timer'
|
74
|
+
]),
|
75
|
+
frameTimer: new Set([
|
76
|
+
'frameTimer'
|
77
|
+
]),
|
78
|
+
ui: new Set([
|
79
|
+
'ui'
|
80
|
+
])
|
81
|
+
};
|
82
|
+
|
83
|
+
//# sourceMappingURL=ImportMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/ImportMap/ImportMap.ts"],"sourcesContent":["export class ImportMap {\n private imports = new Set<string>();\n\n toArray() {\n return Array.from(this.imports);\n }\n\n map(callback: Parameters<ReturnType<typeof this.toArray>['map']>[0]) {\n return this.toArray().map(callback);\n }\n\n add(importName: string) {\n this.imports.add(importName);\n }\n\n processName(name: string) {\n for (const [key, value] of Object.entries(ImportMap.map)) {\n if (value.has(name)) {\n this.add(key);\n }\n }\n }\n\n private static map = {\n graphics: new Set(['graphics']),\n sprites: new Set(['sprite']),\n crank: new Set(['getCrankTicks']),\n object: new Set(['printTable']),\n 'utilities/where': new Set(['where']),\n easing: new Set(['easingFunctions']),\n nineSlice: new Set(['nineSlice']),\n qrcode: new Set(['generateQRCode']),\n animation: new Set(['animation']),\n animator: new Set(['animator']),\n keyboard: new Set(['keyboard']),\n math: new Set(['math']),\n string: new Set(['string']),\n timer: new Set(['timer']),\n frameTimer: new Set(['frameTimer']),\n ui: new Set(['ui']),\n };\n}\n"],"names":["ImportMap","toArray","Array","from","imports","map","callback","add","importName","processName","name","key","value","Object","entries","has","Set","graphics","sprites","crank","object","easing","nineSlice","qrcode","animation","animator","keyboard","math","string","timer","frameTimer","ui"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,IAAA,AAAMA,YAAN,MAAMA;IAGTC,UAAU;QACN,OAAOC,MAAMC,IAAI,CAAC,IAAI,CAACC,OAAO;IAClC;IAEAC,IAAIC,QAA+D,EAAE;QACjE,OAAO,IAAI,CAACL,OAAO,GAAGI,GAAG,CAACC;IAC9B;IAEAC,IAAIC,UAAkB,EAAE;QACpB,IAAI,CAACJ,OAAO,CAACG,GAAG,CAACC;IACrB;IAEAC,YAAYC,IAAY,EAAE;QACtB,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACd,UAAUK,GAAG,EAAG;YACtD,IAAIO,MAAMG,GAAG,CAACL,OAAO;gBACjB,IAAI,CAACH,GAAG,CAACI;YACb;QACJ;IACJ;;aApBQP,UAAU,IAAIY;;AAwC1B;AAzCahB,UAuBMK,MAAM;IACjBY,UAAU,IAAID,IAAI;QAAC;KAAW;IAC9BE,SAAS,IAAIF,IAAI;QAAC;KAAS;IAC3BG,OAAO,IAAIH,IAAI;QAAC;KAAgB;IAChCI,QAAQ,IAAIJ,IAAI;QAAC;KAAa;IAC9B,mBAAmB,IAAIA,IAAI;QAAC;KAAQ;IACpCK,QAAQ,IAAIL,IAAI;QAAC;KAAkB;IACnCM,WAAW,IAAIN,IAAI;QAAC;KAAY;IAChCO,QAAQ,IAAIP,IAAI;QAAC;KAAiB;IAClCQ,WAAW,IAAIR,IAAI;QAAC;KAAY;IAChCS,UAAU,IAAIT,IAAI;QAAC;KAAW;IAC9BU,UAAU,IAAIV,IAAI;QAAC;KAAW;IAC9BW,MAAM,IAAIX,IAAI;QAAC;KAAO;IACtBY,QAAQ,IAAIZ,IAAI;QAAC;KAAS;IAC1Ba,OAAO,IAAIb,IAAI;QAAC;KAAQ;IACxBc,YAAY,IAAId,IAAI;QAAC;KAAa;IAClCe,IAAI,IAAIf,IAAI;QAAC;KAAK;AACtB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './ImportMap';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/ImportMap/index.ts"],"sourcesContent":["export * from './ImportMap';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { ImportMap } from '../ImportMap';
|
2
|
+
export declare const getBeforeEmit: (importMap: ImportMap) => (_: import("typescript").Program, __: import("typescript-to-lua").CompilerOptions, ___: import("typescript-to-lua").EmitHost, result: import("typescript-to-lua").EmitFile[]) => void;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getBeforeEmit", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getBeforeEmit;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _withAutomaticImportWarning = require("./withAutomaticImportWarning");
|
12
|
+
const getBeforeEmit = (importMap)=>{
|
13
|
+
return (_, __, ___, result)=>{
|
14
|
+
const importsString = importMap.map((importString)=>`import "CoreLibs/${importString}"`).join('\n');
|
15
|
+
if (importsString.trim() === '') {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
result[0].code = (0, _withAutomaticImportWarning.withAutomaticImportWarning)(importsString, result[0].code);
|
19
|
+
};
|
20
|
+
};
|
21
|
+
|
22
|
+
//# sourceMappingURL=getBeforeEmit.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/beforeEmit/getBeforeEmit.ts"],"sourcesContent":["import { Plugin } from 'typescript-to-lua';\nimport { withAutomaticImportWarning } from './withAutomaticImportWarning';\nimport { ImportMap } from '../ImportMap';\n\nexport const getBeforeEmit = (importMap: ImportMap) => {\n return ((_, __, ___, result) => {\n const importsString = importMap\n .map((importString) => `import \"CoreLibs/${importString}\"`)\n .join('\\n');\n\n if (importsString.trim() === '') {\n return;\n }\n\n result[0].code = withAutomaticImportWarning(\n importsString,\n result[0].code\n );\n }) satisfies Plugin['beforeEmit'];\n};\n"],"names":["getBeforeEmit","importMap","_","__","___","result","importsString","map","importString","join","trim","code","withAutomaticImportWarning"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;4CAH8B;AAGpC,MAAMA,gBAAgB,CAACC;IAC1B,OAAQ,CAACC,GAAGC,IAAIC,KAAKC;QACjB,MAAMC,gBAAgBL,UACjBM,GAAG,CAAC,CAACC,eAAiB,CAAC,iBAAiB,EAAEA,aAAa,CAAC,CAAC,EACzDC,IAAI,CAAC;QAEV,IAAIH,cAAcI,IAAI,OAAO,IAAI;YAC7B;QACJ;QAEAL,MAAM,CAAC,EAAE,CAACM,IAAI,GAAGC,IAAAA,sDAA0B,EACvCN,eACAD,MAAM,CAAC,EAAE,CAACM,IAAI;IAEtB;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './getBeforeEmit';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/beforeEmit/index.ts"],"sourcesContent":["export * from './getBeforeEmit';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const withAutomaticImportWarning: (importsString: string, code: string) => string;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "withAutomaticImportWarning", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return withAutomaticImportWarning;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const withAutomaticImportWarning = (importsString, code)=>{
|
12
|
+
return `-- These imports were added automatically\n\n${importsString}\n\n-- End of automatic imports\n\n${code}`;
|
13
|
+
};
|
14
|
+
|
15
|
+
//# sourceMappingURL=withAutomaticImportWarning.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/beforeEmit/withAutomaticImportWarning.ts"],"sourcesContent":["export const withAutomaticImportWarning = (\n importsString: string,\n code: string\n) => {\n return `-- These imports were added automatically\\n\\n${importsString}\\n\\n-- End of automatic imports\\n\\n${code}`;\n};\n"],"names":["withAutomaticImportWarning","importsString","code"],"rangeMappings":";;;;;;;;;;;;","mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,6BAA6B,CACtCC,eACAC;IAEA,OAAO,CAAC,6CAA6C,EAAED,cAAc,mCAAmC,EAAEC,KAAK,CAAC;AACpH"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
declare const _default: {
|
3
|
+
beforeEmit: (_: ts.Program, __: import("typescript-to-lua").CompilerOptions, ___: import("typescript-to-lua").EmitHost, result: import("typescript-to-lua").EmitFile[]) => void;
|
4
|
+
visitors: {
|
5
|
+
263: (declaration: ts.ClassLikeDeclaration, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Statement[];
|
6
|
+
108: (expression: ts.SuperExpression, context: import("typescript-to-lua").TransformationContext & {
|
7
|
+
classSuperInfos?: import("./types").ClassSuperInfo[];
|
8
|
+
}) => import("typescript-to-lua").Identifier | import("typescript-to-lua").TableIndexExpression;
|
9
|
+
214: (node: ts.NewExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").CallExpression;
|
10
|
+
211: (node: ts.PropertyAccessExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
11
|
+
213: (node: ts.CallExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
export default _default;
|
package/assets/index.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "default", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return _default;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const _beforeEmit = require("./beforeEmit");
|
14
|
+
const _ImportMap = require("./ImportMap");
|
15
|
+
const _transformCallExpression = require("./transformCallExpression");
|
16
|
+
const _transformClassDeclaration = require("./transformClassDeclaration");
|
17
|
+
const _transformNewExpression = require("./transformNewExpression");
|
18
|
+
const _transformPropertyAccessExpression = require("./transformPropertyAccessExpression");
|
19
|
+
const _transformSuperExpression = require("./transformSuperExpression");
|
20
|
+
const importMap = new _ImportMap.ImportMap();
|
21
|
+
const _default = {
|
22
|
+
beforeEmit: (0, _beforeEmit.getBeforeEmit)(importMap),
|
23
|
+
visitors: {
|
24
|
+
[_typescript.SyntaxKind.ClassDeclaration]: (0, _transformClassDeclaration.getTransformClassDeclaration)(importMap),
|
25
|
+
[_typescript.SyntaxKind.SuperKeyword]: _transformSuperExpression.transformSuperExpression,
|
26
|
+
[_typescript.SyntaxKind.NewExpression]: _transformNewExpression.transformNewExpression,
|
27
|
+
[_typescript.SyntaxKind.PropertyAccessExpression]: (0, _transformPropertyAccessExpression.getTransformPropertyAccessExpression)(importMap),
|
28
|
+
[_typescript.SyntaxKind.CallExpression]: (0, _transformCallExpression.getTransformCallExpression)(importMap)
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../libs/tstl-plugin/src/index.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { Plugin } from 'typescript-to-lua';\nimport { getBeforeEmit } from './beforeEmit';\nimport { ImportMap } from './ImportMap';\nimport { getTransformCallExpression } from './transformCallExpression';\nimport { getTransformClassDeclaration } from './transformClassDeclaration';\nimport { transformNewExpression } from './transformNewExpression';\nimport { getTransformPropertyAccessExpression } from './transformPropertyAccessExpression';\nimport { transformSuperExpression } from './transformSuperExpression';\n\nconst importMap = new ImportMap();\n\nexport default {\n beforeEmit: getBeforeEmit(importMap),\n visitors: {\n [ts.SyntaxKind.ClassDeclaration]:\n getTransformClassDeclaration(importMap),\n [ts.SyntaxKind.SuperKeyword]: transformSuperExpression,\n [ts.SyntaxKind.NewExpression]: transformNewExpression,\n [ts.SyntaxKind.PropertyAccessExpression]:\n getTransformPropertyAccessExpression(importMap),\n [ts.SyntaxKind.CallExpression]: getTransformCallExpression(importMap),\n },\n} satisfies Plugin;\n"],"names":["importMap","ImportMap","beforeEmit","getBeforeEmit","visitors","ts","SyntaxKind","ClassDeclaration","getTransformClassDeclaration","SuperKeyword","transformSuperExpression","NewExpression","transformNewExpression","PropertyAccessExpression","getTransformPropertyAccessExpression","CallExpression","getTransformCallExpression"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAYA;;;eAAA;;;;sEAZoB;4BAEU;2BACJ;yCACiB;2CACE;wCACN;mDACc;0CACZ;AAEzC,MAAMA,YAAY,IAAIC,oBAAS;MAE/B,WAAe;IACXC,YAAYC,IAAAA,yBAAa,EAACH;IAC1BI,UAAU;QACN,CAACC,YAAGC,UAAU,CAACC,gBAAgB,CAAC,EAC5BC,IAAAA,uDAA4B,EAACR;QACjC,CAACK,YAAGC,UAAU,CAACG,YAAY,CAAC,EAAEC,kDAAwB;QACtD,CAACL,YAAGC,UAAU,CAACK,aAAa,CAAC,EAAEC,8CAAsB;QACrD,CAACP,YAAGC,UAAU,CAACO,wBAAwB,CAAC,EACpCC,IAAAA,uEAAoC,EAACd;QACzC,CAACK,YAAGC,UAAU,CAACS,cAAc,CAAC,EAAEC,IAAAA,mDAA0B,EAAChB;IAC/D;AACJ"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { Expression } from 'typescript-to-lua';
|
3
|
+
import { ImportMap } from '../ImportMap';
|
4
|
+
export declare const getTransformCallExpression: (importMap: ImportMap) => (node: ts.CallExpression, context: import("typescript-to-lua").TransformationContext) => Expression;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getTransformCallExpression", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getTransformCallExpression;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const getTransformCallExpression = (importMap)=>{
|
14
|
+
return (node, context)=>{
|
15
|
+
if (_typescript.isIdentifier(node.expression)) {
|
16
|
+
importMap.processName(node.expression.escapedText.toString());
|
17
|
+
}
|
18
|
+
if (_typescript.isIdentifier(node.expression) && node.expression.escapedText === 'require') {
|
19
|
+
const normalNode = context.superTransformExpression(node);
|
20
|
+
normalNode.expression.text = 'import';
|
21
|
+
normalNode.expression.originalName = 'import';
|
22
|
+
return normalNode;
|
23
|
+
} else {
|
24
|
+
return context.superTransformExpression(node);
|
25
|
+
}
|
26
|
+
};
|
27
|
+
};
|
28
|
+
|
29
|
+
//# sourceMappingURL=getTransformCallExpression.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformCallExpression/getTransformCallExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { Expression, FunctionVisitor } from 'typescript-to-lua';\nimport { ImportMap } from '../ImportMap';\n\nexport const getTransformCallExpression = (importMap: ImportMap) => {\n return ((node, context) => {\n if (ts.isIdentifier(node.expression)) {\n importMap.processName(node.expression.escapedText.toString());\n }\n\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 Expression;\n } else {\n return context.superTransformExpression(node);\n }\n }) satisfies FunctionVisitor<ts.CallExpression>;\n};\n"],"names":["getTransformCallExpression","importMap","node","context","ts","isIdentifier","expression","processName","escapedText","toString","normalNode","superTransformExpression","text","originalName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;;sEAJO;AAIb,MAAMA,6BAA6B,CAACC;IACvC,OAAQ,CAACC,MAAMC;QACX,IAAIC,YAAGC,YAAY,CAACH,KAAKI,UAAU,GAAG;YAClCL,UAAUM,WAAW,CAACL,KAAKI,UAAU,CAACE,WAAW,CAACC,QAAQ;QAC9D;QAEA,IACIL,YAAGC,YAAY,CAACH,KAAKI,UAAU,KAC/BJ,KAAKI,UAAU,CAACE,WAAW,KAAK,WAClC;YACE,MAAME,aAAaP,QAAQQ,wBAAwB,CAC/CT;YAKJQ,WAAWJ,UAAU,CAACM,IAAI,GAAG;YAC7BF,WAAWJ,UAAU,CAACO,YAAY,GAAG;YAErC,OAAOH;QACX,OAAO;YACH,OAAOP,QAAQQ,wBAAwB,CAACT;QAC5C;IACJ;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './getTransformCallExpression';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformCallExpression/index.ts"],"sourcesContent":["export * from './getTransformCallExpression';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "createClassCall", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return createClassCall;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
13
|
+
const createClassCall = (context, className, extendsNode)=>{
|
14
|
+
// class('X')
|
15
|
+
const classCall = _typescripttolua.createCallExpression(_typescripttolua.createIdentifier('class'), [
|
16
|
+
_typescripttolua.createStringLiteral(className.text)
|
17
|
+
]);
|
18
|
+
let classCreationExpression;
|
19
|
+
if (extendsNode) {
|
20
|
+
// class('X').extends(Blah)
|
21
|
+
classCreationExpression = _typescripttolua.createCallExpression(_typescripttolua.createTableIndexExpression(classCall, _typescripttolua.createStringLiteral('extends')), [
|
22
|
+
context.transformExpression(extendsNode.expression)
|
23
|
+
]);
|
24
|
+
} else {
|
25
|
+
classCreationExpression = _typescripttolua.createCallExpression(_typescripttolua.createTableIndexExpression(classCall, _typescripttolua.createStringLiteral('extends')), [
|
26
|
+
_typescripttolua.createIdentifier('Object')
|
27
|
+
]);
|
28
|
+
}
|
29
|
+
return _typescripttolua.createExpressionStatement(classCreationExpression);
|
30
|
+
};
|
31
|
+
|
32
|
+
//# sourceMappingURL=createClasCall.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/createClasCall.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as tstl from 'typescript-to-lua';\n\nexport const 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"],"names":["createClassCall","context","className","extendsNode","classCall","tstl","createCallExpression","createIdentifier","createStringLiteral","text","classCreationExpression","createTableIndexExpression","transformExpression","expression","createExpressionStatement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAGaA;;;eAAAA;;;;2EAFS;AAEf,MAAMA,kBAAkB,CAC3BC,SACAC,WACAC;IAEA,aAAa;IACb,MAAMC,YAAYC,iBAAKC,oBAAoB,CACvCD,iBAAKE,gBAAgB,CAAC,UACtB;QAACF,iBAAKG,mBAAmB,CAACN,UAAUO,IAAI;KAAE;IAE9C,IAAIC;IACJ,IAAIP,aAAa;QACb,2BAA2B;QAC3BO,0BAA0BL,iBAAKC,oBAAoB,CAC/CD,iBAAKM,0BAA0B,CAC3BP,WACAC,iBAAKG,mBAAmB,CAAC,aAE7B;YAACP,QAAQW,mBAAmB,CAACT,YAAYU,UAAU;SAAE;IAE7D,OAAO;QACHH,0BAA0BL,iBAAKC,oBAAoB,CAC/CD,iBAAKM,0BAA0B,CAC3BP,WACAC,iBAAKG,mBAAmB,CAAC,aAE7B;YAACH,iBAAKE,gBAAgB,CAAC;SAAU;IAEzC;IACA,OAAOF,iBAAKS,yBAAyB,CAACJ;AAC1C"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getExportedClassDeclarationStatements", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getExportedClassDeclarationStatements;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
13
|
+
const getExportedClassDeclarationStatements = (className, declaration)=>{
|
14
|
+
if ('localSymbol' in declaration && declaration.localSymbol && typeof declaration.localSymbol === 'object' && 'exportSymbol' in declaration.localSymbol && declaration.localSymbol.exportSymbol && typeof declaration.localSymbol.exportSymbol === 'object' && 'escapedName' in declaration.localSymbol.exportSymbol && typeof declaration.localSymbol.exportSymbol.escapedName === 'string') {
|
15
|
+
const escapedName = declaration.localSymbol.exportSymbol.escapedName;
|
16
|
+
return [
|
17
|
+
_typescripttolua.createAssignmentStatement(_typescripttolua.createTableIndexExpression(_typescripttolua.createIdentifier('____exports'), _typescripttolua.createStringLiteral(escapedName)), className)
|
18
|
+
];
|
19
|
+
}
|
20
|
+
return [];
|
21
|
+
};
|
22
|
+
|
23
|
+
//# sourceMappingURL=getExportedClassDeclarationStatements.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/getExportedClassDeclarationStatements.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as tstl from 'typescript-to-lua';\n\nexport const getExportedClassDeclarationStatements = (\n className: tstl.Identifier,\n declaration: ts.ClassLikeDeclaration\n) => {\n if (\n 'localSymbol' in declaration &&\n declaration.localSymbol &&\n typeof declaration.localSymbol === 'object' &&\n 'exportSymbol' in declaration.localSymbol &&\n declaration.localSymbol.exportSymbol &&\n typeof declaration.localSymbol.exportSymbol === 'object' &&\n 'escapedName' in declaration.localSymbol.exportSymbol &&\n typeof declaration.localSymbol.exportSymbol.escapedName === 'string'\n ) {\n const escapedName = declaration.localSymbol.exportSymbol.escapedName;\n\n return [\n tstl.createAssignmentStatement(\n tstl.createTableIndexExpression(\n tstl.createIdentifier('____exports'),\n tstl.createStringLiteral(escapedName)\n ),\n className\n ),\n ];\n }\n\n return [];\n};\n"],"names":["getExportedClassDeclarationStatements","className","declaration","localSymbol","exportSymbol","escapedName","tstl","createAssignmentStatement","createTableIndexExpression","createIdentifier","createStringLiteral"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAGaA;;;eAAAA;;;;2EAFS;AAEf,MAAMA,wCAAwC,CACjDC,WACAC;IAEA,IACI,iBAAiBA,eACjBA,YAAYC,WAAW,IACvB,OAAOD,YAAYC,WAAW,KAAK,YACnC,kBAAkBD,YAAYC,WAAW,IACzCD,YAAYC,WAAW,CAACC,YAAY,IACpC,OAAOF,YAAYC,WAAW,CAACC,YAAY,KAAK,YAChD,iBAAiBF,YAAYC,WAAW,CAACC,YAAY,IACrD,OAAOF,YAAYC,WAAW,CAACC,YAAY,CAACC,WAAW,KAAK,UAC9D;QACE,MAAMA,cAAcH,YAAYC,WAAW,CAACC,YAAY,CAACC,WAAW;QAEpE,OAAO;YACHC,iBAAKC,yBAAyB,CAC1BD,iBAAKE,0BAA0B,CAC3BF,iBAAKG,gBAAgB,CAAC,gBACtBH,iBAAKI,mBAAmB,CAACL,eAE7BJ;SAEP;IACL;IAEA,OAAO,EAAE;AACb"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { TransformationContext } from 'typescript-to-lua';
|
3
|
+
import * as tstl from 'typescript-to-lua';
|
4
|
+
import { ImportMap } from '../ImportMap';
|
5
|
+
export declare const getTransformClassDeclaration: (importMap: ImportMap) => (declaration: ts.ClassLikeDeclaration, context: TransformationContext) => tstl.Statement[];
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getTransformClassDeclaration", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getTransformClassDeclaration;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
14
|
+
const _utils = require("typescript-to-lua/dist/transformation/visitors/class/utils");
|
15
|
+
const _getExportedClassDeclarationStatements = require("./getExportedClassDeclarationStatements");
|
16
|
+
const _createClasCall = require("./createClasCall");
|
17
|
+
const _transformConstructor = require("./transformConstructor");
|
18
|
+
const _transformMethodDeclaration = require("./transformMethodDeclaration");
|
19
|
+
const hasSuperInfos = (context)=>{
|
20
|
+
return 'classSuperInfos' in context;
|
21
|
+
};
|
22
|
+
const getTransformClassDeclaration = (importMap)=>{
|
23
|
+
return (declaration, context)=>{
|
24
|
+
importMap.add('object');
|
25
|
+
let className;
|
26
|
+
if (declaration.name) {
|
27
|
+
className = _typescripttolua.createIdentifier(declaration.name.text);
|
28
|
+
} else {
|
29
|
+
className = _typescripttolua.createIdentifier(context.createTempName('class'), declaration);
|
30
|
+
}
|
31
|
+
const extension = (0, _utils.getExtendedNode)(declaration);
|
32
|
+
if (hasSuperInfos(context)) {
|
33
|
+
if (context.classSuperInfos) {
|
34
|
+
context.classSuperInfos.push({
|
35
|
+
className,
|
36
|
+
extendedTypeNode: extension
|
37
|
+
});
|
38
|
+
} else {
|
39
|
+
context.classSuperInfos = [
|
40
|
+
{
|
41
|
+
className,
|
42
|
+
extendedTypeNode: extension
|
43
|
+
}
|
44
|
+
];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
// Get all properties with value
|
48
|
+
const properties = declaration.members.filter(_typescript.isPropertyDeclaration).filter((member)=>member.initializer);
|
49
|
+
// Divide properties into static and non-static
|
50
|
+
const instanceFields = properties.filter((prop)=>!(0, _utils.isStaticNode)(prop));
|
51
|
+
const statements = [];
|
52
|
+
// class('X')
|
53
|
+
statements.push((0, _createClasCall.createClassCall)(context, className, extension));
|
54
|
+
// function X:init()
|
55
|
+
// X.super.init(self)
|
56
|
+
// end
|
57
|
+
const constructor = declaration.members.find((n)=>_typescript.isConstructorDeclaration(n) && n.body !== undefined);
|
58
|
+
if (!constructor) {
|
59
|
+
return [];
|
60
|
+
}
|
61
|
+
const transformedConstructor = (0, _transformConstructor.transformConstructor)(context, className, instanceFields, constructor);
|
62
|
+
if (transformedConstructor) {
|
63
|
+
statements.push(transformedConstructor);
|
64
|
+
}
|
65
|
+
const methods = declaration.members.filter(_typescript.isMethodDeclaration).map((method)=>(0, _transformMethodDeclaration.transformMethodDeclaration)(context, method, className)).filter((method)=>method !== undefined);
|
66
|
+
statements.push(...methods);
|
67
|
+
statements.push(...(0, _getExportedClassDeclarationStatements.getExportedClassDeclarationStatements)(className, declaration));
|
68
|
+
return statements;
|
69
|
+
};
|
70
|
+
};
|
71
|
+
|
72
|
+
//# sourceMappingURL=getTransformClassDeclaration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/getTransformClassDeclaration.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor, TransformationContext } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport {\n getExtendedNode,\n isStaticNode,\n} from 'typescript-to-lua/dist/transformation/visitors/class/utils';\nimport { getExportedClassDeclarationStatements } from './getExportedClassDeclarationStatements';\nimport { ImportMap } from '../ImportMap';\nimport { ClassSuperInfo } from '../types';\nimport { createClassCall } from './createClasCall';\nimport { transformConstructor } from './transformConstructor';\nimport { transformMethodDeclaration } from './transformMethodDeclaration';\n\nconst hasSuperInfos = (\n context: TransformationContext\n): context is TransformationContext & {\n classSuperInfos?: [ClassSuperInfo];\n} => {\n return 'classSuperInfos' in context;\n};\n\nexport const getTransformClassDeclaration = (importMap: ImportMap) => {\n return ((declaration, context: TransformationContext) => {\n importMap.add('object');\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\n if (hasSuperInfos(context)) {\n if (context.classSuperInfos) {\n context.classSuperInfos.push({\n className,\n extendedTypeNode: extension,\n });\n } else {\n context.classSuperInfos = [\n { className, extendedTypeNode: extension },\n ];\n }\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\n if (!constructor) {\n return [];\n }\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) =>\n transformMethodDeclaration(context, method, className)\n )\n .filter((method): method is tstl.Statement => method !== undefined);\n statements.push(...methods);\n\n statements.push(\n ...getExportedClassDeclarationStatements(className, declaration)\n );\n\n return statements;\n }) satisfies FunctionVisitor<ts.ClassLikeDeclaration>;\n};\n"],"names":["getTransformClassDeclaration","hasSuperInfos","context","importMap","declaration","add","className","name","tstl","createIdentifier","text","createTempName","extension","getExtendedNode","classSuperInfos","push","extendedTypeNode","properties","members","filter","ts","isPropertyDeclaration","member","initializer","instanceFields","prop","isStaticNode","statements","createClassCall","constructor","find","n","isConstructorDeclaration","body","undefined","transformedConstructor","transformConstructor","methods","isMethodDeclaration","map","method","transformMethodDeclaration","getExportedClassDeclarationStatements"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsBaA;;;eAAAA;;;;sEAtBO;2EAEE;uBAIf;uDAC+C;gCAGtB;sCACK;4CACM;AAE3C,MAAMC,gBAAgB,CAClBC;IAIA,OAAO,qBAAqBA;AAChC;AAEO,MAAMF,+BAA+B,CAACG;IACzC,OAAQ,CAACC,aAAaF;QAClBC,UAAUE,GAAG,CAAC;QAEd,IAAIC;QACJ,IAAIF,YAAYG,IAAI,EAAE;YAClBD,YAAYE,iBAAKC,gBAAgB,CAACL,YAAYG,IAAI,CAACG,IAAI;QAC3D,OAAO;YACHJ,YAAYE,iBAAKC,gBAAgB,CAC7BP,QAAQS,cAAc,CAAC,UACvBP;QAER;QAEA,MAAMQ,YAAYC,IAAAA,sBAAe,EAACT;QAElC,IAAIH,cAAcC,UAAU;YACxB,IAAIA,QAAQY,eAAe,EAAE;gBACzBZ,QAAQY,eAAe,CAACC,IAAI,CAAC;oBACzBT;oBACAU,kBAAkBJ;gBACtB;YACJ,OAAO;gBACHV,QAAQY,eAAe,GAAG;oBACtB;wBAAER;wBAAWU,kBAAkBJ;oBAAU;iBAC5C;YACL;QACJ;QAEA,gCAAgC;QAChC,MAAMK,aAAab,YAAYc,OAAO,CACjCC,MAAM,CAACC,YAAGC,qBAAqB,EAC/BF,MAAM,CAAC,CAACG,SAAWA,OAAOC,WAAW;QAE1C,+CAA+C;QAC/C,MAAMC,iBAAiBP,WAAWE,MAAM,CAAC,CAACM,OAAS,CAACC,IAAAA,mBAAY,EAACD;QAEjE,MAAME,aAA+B,EAAE;QAEvC,aAAa;QACbA,WAAWZ,IAAI,CAACa,IAAAA,+BAAe,EAAC1B,SAASI,WAAWM;QAEpD,oBAAoB;QACpB,uBAAuB;QACvB,MAAM;QACN,MAAMiB,cAAczB,YAAYc,OAAO,CAACY,IAAI,CACxC,CAACC,IACGX,YAAGY,wBAAwB,CAACD,MAAMA,EAAEE,IAAI,KAAKC;QAGrD,IAAI,CAACL,aAAa;YACd,OAAO,EAAE;QACb;QAEA,MAAMM,yBAAyBC,IAAAA,0CAAoB,EAC/ClC,SACAI,WACAkB,gBACAK;QAEJ,IAAIM,wBAAwB;YACxBR,WAAWZ,IAAI,CAACoB;QACpB;QAEA,MAAME,UAAUjC,YAAYc,OAAO,CAC9BC,MAAM,CAACC,YAAGkB,mBAAmB,EAC7BC,GAAG,CAAC,CAACC,SACFC,IAAAA,sDAA0B,EAACvC,SAASsC,QAAQlC,YAE/Ca,MAAM,CAAC,CAACqB,SAAqCA,WAAWN;QAC7DP,WAAWZ,IAAI,IAAIsB;QAEnBV,WAAWZ,IAAI,IACR2B,IAAAA,4EAAqC,EAACpC,WAAWF;QAGxD,OAAOuB;IACX;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './getTransformClassDeclaration';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/index.ts"],"sourcesContent":["export * from './getTransformClassDeclaration';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { TransformationContext } from 'typescript-to-lua';
|
3
|
+
import * as tstl from 'typescript-to-lua';
|
4
|
+
export declare const transformConstructor: (context: TransformationContext, className: tstl.Identifier, instanceFields: ts.PropertyDeclaration[], constructor: ts.ConstructorDeclaration) => tstl.Statement | undefined;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "transformConstructor", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return transformConstructor;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _extends = require("@swc/helpers/_/_extends");
|
12
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
13
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
14
|
+
const _scope = require("typescript-to-lua/dist/transformation/utils/scope");
|
15
|
+
const _fields = require("typescript-to-lua/dist/transformation/visitors/class/members/fields");
|
16
|
+
const _function = require("typescript-to-lua/dist/transformation/visitors/function");
|
17
|
+
const transformConstructor = (context, className, instanceFields, constructor)=>{
|
18
|
+
const methodName = 'init';
|
19
|
+
context.pushScope(_scope.ScopeType.Function);
|
20
|
+
let bodyStatements = [];
|
21
|
+
const params = (0, _function.transformParameters)(context, constructor == null ? void 0 : constructor.parameters, _typescripttolua.createIdentifier('self'))[0];
|
22
|
+
const classInstanceFields = (0, _fields.transformClassInstanceFields)(context, instanceFields);
|
23
|
+
bodyStatements.push(...classInstanceFields);
|
24
|
+
if (constructor == null ? void 0 : constructor.body) {
|
25
|
+
const body = (0, _function.transformFunctionBodyContent)(context, constructor.body);
|
26
|
+
bodyStatements.push(...body);
|
27
|
+
bodyStatements = bodyStatements.reduce((previous, current)=>{
|
28
|
+
if (_typescripttolua.isExpressionStatement(current) && _typescripttolua.isCallExpression(current.expression) && _typescripttolua.isTableIndexExpression(current.expression.expression) && _typescripttolua.isStringLiteral(current.expression.expression.index) && current.expression.expression.index.value === '____constructor') {
|
29
|
+
return [
|
30
|
+
_extends._({}, current, {
|
31
|
+
expression: _extends._({}, current.expression, {
|
32
|
+
expression: _extends._({}, current.expression.expression, {
|
33
|
+
index: _typescripttolua.createStringLiteral('init')
|
34
|
+
}),
|
35
|
+
params: current.expression.params.slice(1)
|
36
|
+
})
|
37
|
+
}),
|
38
|
+
...previous
|
39
|
+
];
|
40
|
+
}
|
41
|
+
return [
|
42
|
+
...previous,
|
43
|
+
current
|
44
|
+
];
|
45
|
+
}, []);
|
46
|
+
}
|
47
|
+
context.popScope();
|
48
|
+
return _typescripttolua.createAssignmentStatement(_typescripttolua.createTableIndexExpression(className, _typescripttolua.createStringLiteral(methodName)), _typescripttolua.createFunctionExpression(_typescripttolua.createBlock(bodyStatements), params));
|
49
|
+
};
|
50
|
+
|
51
|
+
//# sourceMappingURL=transformConstructor.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/transformConstructor.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { TransformationContext } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport { ScopeType } from 'typescript-to-lua/dist/transformation/utils/scope';\nimport { transformClassInstanceFields } from 'typescript-to-lua/dist/transformation/visitors/class/members/fields';\nimport {\n transformFunctionBodyContent,\n transformParameters,\n} from 'typescript-to-lua/dist/transformation/visitors/function';\n\nexport const 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 let bodyStatements: tstl.Statement[] = [];\n const params = transformParameters(\n context,\n constructor?.parameters,\n tstl.createIdentifier('self')\n )[0];\n const classInstanceFields = transformClassInstanceFields(\n context,\n instanceFields\n );\n\n bodyStatements.push(...classInstanceFields);\n\n if (constructor?.body) {\n const body = transformFunctionBodyContent(context, constructor.body);\n\n bodyStatements.push(...body);\n bodyStatements = bodyStatements.reduce((previous, current) => {\n if (\n tstl.isExpressionStatement(current) &&\n tstl.isCallExpression(current.expression) &&\n tstl.isTableIndexExpression(current.expression.expression) &&\n tstl.isStringLiteral(current.expression.expression.index) &&\n current.expression.expression.index.value === '____constructor'\n ) {\n return [\n {\n ...current,\n expression: {\n ...current.expression,\n expression: {\n ...current.expression.expression,\n index: tstl.createStringLiteral('init'),\n },\n params: current.expression.params.slice(1),\n },\n },\n ...previous,\n ];\n }\n\n return [...previous, current];\n }, [] as tstl.Statement[]);\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"],"names":["transformConstructor","context","className","instanceFields","constructor","methodName","pushScope","ScopeType","Function","bodyStatements","params","transformParameters","parameters","tstl","createIdentifier","classInstanceFields","transformClassInstanceFields","push","body","transformFunctionBodyContent","reduce","previous","current","isExpressionStatement","isCallExpression","expression","isTableIndexExpression","isStringLiteral","index","value","createStringLiteral","slice","popScope","createAssignmentStatement","createTableIndexExpression","createFunctionExpression","createBlock"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAUaA;;;eAAAA;;;;;2EARS;uBACI;wBACmB;0BAItC;AAEA,MAAMA,uBAAuB,CAChCC,SACAC,WACAC,gBACAC;IAEA,MAAMC,aAAa;IACnBJ,QAAQK,SAAS,CAACC,gBAAS,CAACC,QAAQ;IACpC,IAAIC,iBAAmC,EAAE;IACzC,MAAMC,SAASC,IAAAA,6BAAmB,EAC9BV,SACAG,+BAAAA,YAAaQ,UAAU,EACvBC,iBAAKC,gBAAgB,CAAC,QACzB,CAAC,EAAE;IACJ,MAAMC,sBAAsBC,IAAAA,oCAA4B,EACpDf,SACAE;IAGJM,eAAeQ,IAAI,IAAIF;IAEvB,IAAIX,+BAAAA,YAAac,IAAI,EAAE;QACnB,MAAMA,OAAOC,IAAAA,sCAA4B,EAAClB,SAASG,YAAYc,IAAI;QAEnET,eAAeQ,IAAI,IAAIC;QACvBT,iBAAiBA,eAAeW,MAAM,CAAC,CAACC,UAAUC;YAC9C,IACIT,iBAAKU,qBAAqB,CAACD,YAC3BT,iBAAKW,gBAAgB,CAACF,QAAQG,UAAU,KACxCZ,iBAAKa,sBAAsB,CAACJ,QAAQG,UAAU,CAACA,UAAU,KACzDZ,iBAAKc,eAAe,CAACL,QAAQG,UAAU,CAACA,UAAU,CAACG,KAAK,KACxDN,QAAQG,UAAU,CAACA,UAAU,CAACG,KAAK,CAACC,KAAK,KAAK,mBAChD;gBACE,OAAO;oBACH,eACOP;wBACHG,YAAY,eACLH,QAAQG,UAAU;4BACrBA,YAAY,eACLH,QAAQG,UAAU,CAACA,UAAU;gCAChCG,OAAOf,iBAAKiB,mBAAmB,CAAC;;4BAEpCpB,QAAQY,QAAQG,UAAU,CAACf,MAAM,CAACqB,KAAK,CAAC;;;uBAG7CV;iBACN;YACL;YAEA,OAAO;mBAAIA;gBAAUC;aAAQ;QACjC,GAAG,EAAE;IACT;IACArB,QAAQ+B,QAAQ;IAChB,OAAOnB,iBAAKoB,yBAAyB,CACjCpB,iBAAKqB,0BAA0B,CAC3BhC,WACAW,iBAAKiB,mBAAmB,CAACzB,cAE7BQ,iBAAKsB,wBAAwB,CAACtB,iBAAKuB,WAAW,CAAC3B,iBAAiBC;AAExE"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { TransformationContext } from 'typescript-to-lua';
|
3
|
+
import * as tstl from 'typescript-to-lua';
|
4
|
+
export declare const transformMethodDeclaration: (context: TransformationContext, node: ts.MethodDeclaration, className: tstl.Identifier) => tstl.Statement | undefined;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "transformMethodDeclaration", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return transformMethodDeclaration;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
13
|
+
const _function = require("typescript-to-lua/dist/transformation/visitors/function");
|
14
|
+
const _transformPropertyName = require("./transformPropertyName");
|
15
|
+
const transformMethodDeclaration = (context, node, className)=>{
|
16
|
+
const [functionExpression] = (0, _function.transformFunctionToExpression)(context, node);
|
17
|
+
return _typescripttolua.createAssignmentStatement(_typescripttolua.createTableIndexExpression(className, (0, _transformPropertyName.transformPropertyName)(context, node.name)), functionExpression);
|
18
|
+
};
|
19
|
+
|
20
|
+
//# sourceMappingURL=transformMethodDeclaration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/transformMethodDeclaration.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { TransformationContext } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport { transformFunctionToExpression } from 'typescript-to-lua/dist/transformation/visitors/function';\nimport { transformPropertyName } from './transformPropertyName';\n\nexport const 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};\n"],"names":["transformMethodDeclaration","context","node","className","functionExpression","transformFunctionToExpression","tstl","createAssignmentStatement","createTableIndexExpression","transformPropertyName","name"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BAMaA;;;eAAAA;;;;2EAJS;0BACwB;uCACR;AAE/B,MAAMA,6BAA6B,CACtCC,SACAC,MACAC;IAEA,MAAM,CAACC,mBAAmB,GAAGC,IAAAA,uCAA6B,EAACJ,SAASC;IACpE,OAAOI,iBAAKC,yBAAyB,CACjCD,iBAAKE,0BAA0B,CAC3BL,WACAM,IAAAA,4CAAqB,EAACR,SAASC,KAAKQ,IAAI,IAE5CN;AAER"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "transformPropertyName", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return transformPropertyName;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const _typescripttolua = require("typescript-to-lua");
|
14
|
+
const transformPropertyName = (context, node)=>{
|
15
|
+
if (_typescript.isComputedPropertyName(node)) {
|
16
|
+
return context.transformExpression(node.expression);
|
17
|
+
} else if (_typescript.isIdentifier(node)) {
|
18
|
+
return (0, _typescripttolua.createStringLiteral)(node.text);
|
19
|
+
} else if (_typescript.isPrivateIdentifier(node)) {
|
20
|
+
throw new Error('PrivateIdentifier is not supported');
|
21
|
+
} else {
|
22
|
+
return context.transformExpression(node);
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
//# sourceMappingURL=transformPropertyName.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformClassDeclaration/transformPropertyName.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { createStringLiteral } from 'typescript-to-lua';\nimport { TransformationContext } from 'typescript-to-lua';\n\nexport const transformPropertyName = (\n context: TransformationContext,\n node: ts.PropertyName\n) => {\n if (ts.isComputedPropertyName(node)) {\n return context.transformExpression(node.expression);\n } else if (ts.isIdentifier(node)) {\n return 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"],"names":["transformPropertyName","context","node","ts","isComputedPropertyName","transformExpression","expression","isIdentifier","createStringLiteral","text","isPrivateIdentifier","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;;sEAJO;iCACgB;AAG7B,MAAMA,wBAAwB,CACjCC,SACAC;IAEA,IAAIC,YAAGC,sBAAsB,CAACF,OAAO;QACjC,OAAOD,QAAQI,mBAAmB,CAACH,KAAKI,UAAU;IACtD,OAAO,IAAIH,YAAGI,YAAY,CAACL,OAAO;QAC9B,OAAOM,IAAAA,oCAAmB,EAACN,KAAKO,IAAI;IACxC,OAAO,IAAIN,YAAGO,mBAAmB,CAACR,OAAO;QACrC,MAAM,IAAIS,MAAM;IACpB,OAAO;QACH,OAAOV,QAAQI,mBAAmB,CAACH;IACvC;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './transformNewExpression';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformNewExpression/index.ts"],"sourcesContent":["export * from './transformNewExpression';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "transformNewExpression", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return transformNewExpression;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const _typescripttolua = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua"));
|
14
|
+
const _call = require("typescript-to-lua/dist/transformation/visitors/call");
|
15
|
+
const transformNewExpression = (node, context)=>{
|
16
|
+
const signature = context.checker.getResolvedSignature(node);
|
17
|
+
var _node_arguments;
|
18
|
+
const [name, params] = (0, _call.transformCallAndArguments)(context, node.expression, (_node_arguments = node.arguments) != null ? _node_arguments : [
|
19
|
+
_typescript.factory.createTrue()
|
20
|
+
], signature);
|
21
|
+
return _typescripttolua.createCallExpression(name, params);
|
22
|
+
};
|
23
|
+
|
24
|
+
//# sourceMappingURL=transformNewExpression.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformNewExpression/transformNewExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport * as tstl from 'typescript-to-lua';\nimport { transformCallAndArguments } from 'typescript-to-lua/dist/transformation/visitors/call';\n\nexport const transformNewExpression = ((node, context) => {\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}) satisfies FunctionVisitor<ts.NewExpression>;\n"],"names":["transformNewExpression","node","context","signature","checker","getResolvedSignature","name","params","transformCallAndArguments","expression","arguments","ts","factory","createTrue","tstl","createCallExpression"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAKaA;;;eAAAA;;;;sEALO;2EAEE;sBACoB;AAEnC,MAAMA,yBAA0B,CAACC,MAAMC;IAC1C,MAAMC,YAAYD,QAAQE,OAAO,CAACC,oBAAoB,CAACJ;QAInDA;IAHJ,MAAM,CAACK,MAAMC,OAAO,GAAGC,IAAAA,+BAAyB,EAC5CN,SACAD,KAAKQ,UAAU,EACfR,CAAAA,kBAAAA,KAAKS,SAAS,YAAdT,kBAAkB;QAACU,YAAGC,OAAO,CAACC,UAAU;KAAG,EAC3CV;IAEJ,OAAOW,iBAAKC,oBAAoB,CAACT,MAAMC;AAC3C"}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { ImportMap } from '../ImportMap';
|
3
|
+
export declare const getTransformPropertyAccessExpression: (importMap: ImportMap) => (node: ts.PropertyAccessExpression, context: import("typescript-to-lua").TransformationContext) => import("typescript-to-lua").Expression;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "getTransformPropertyAccessExpression", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return getTransformPropertyAccessExpression;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_wildcard._(require("typescript"));
|
13
|
+
const getTransformPropertyAccessExpression = (importMap)=>{
|
14
|
+
return (node, context)=>{
|
15
|
+
if (_typescript.isIdentifier(node.expression)) {
|
16
|
+
importMap.processName(node.name.text);
|
17
|
+
}
|
18
|
+
return context.superTransformExpression(node);
|
19
|
+
};
|
20
|
+
};
|
21
|
+
|
22
|
+
//# sourceMappingURL=getTransformPropertyAccessExpression.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformPropertyAccessExpression/getTransformPropertyAccessExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor } from 'typescript-to-lua';\nimport { ImportMap } from '../ImportMap';\n\nexport const getTransformPropertyAccessExpression = (importMap: ImportMap) => {\n return ((node, context) => {\n if (ts.isIdentifier(node.expression)) {\n importMap.processName(node.name.text);\n }\n\n return context.superTransformExpression(node);\n }) satisfies FunctionVisitor<ts.PropertyAccessExpression>;\n};\n"],"names":["getTransformPropertyAccessExpression","importMap","node","context","ts","isIdentifier","expression","processName","name","text","superTransformExpression"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAIaA;;;eAAAA;;;;sEAJO;AAIb,MAAMA,uCAAuC,CAACC;IACjD,OAAQ,CAACC,MAAMC;QACX,IAAIC,YAAGC,YAAY,CAACH,KAAKI,UAAU,GAAG;YAClCL,UAAUM,WAAW,CAACL,KAAKM,IAAI,CAACC,IAAI;QACxC;QAEA,OAAON,QAAQO,wBAAwB,CAACR;IAC5C;AACJ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './getTransformPropertyAccessExpression';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformPropertyAccessExpression/index.ts"],"sourcesContent":["export * from './getTransformPropertyAccessExpression';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './transformSuperExpression';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformSuperExpression/index.ts"],"sourcesContent":["export * from './transformSuperExpression';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import * as ts from 'typescript';
|
2
|
+
import { TransformationContext } from 'typescript-to-lua';
|
3
|
+
import * as lua from 'typescript-to-lua/dist/LuaAST';
|
4
|
+
import { ClassSuperInfo } from '../types';
|
5
|
+
export declare const transformSuperExpression: (expression: ts.SuperExpression, context: TransformationContext & {
|
6
|
+
classSuperInfos?: ClassSuperInfo[];
|
7
|
+
}) => lua.Identifier | lua.TableIndexExpression;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "transformSuperExpression", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return transformSuperExpression;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _LuaAST = /*#__PURE__*/ _interop_require_wildcard._(require("typescript-to-lua/dist/LuaAST"));
|
13
|
+
const transformSuperExpression = (expression, context)=>{
|
14
|
+
const superInfos = context.classSuperInfos;
|
15
|
+
let superInfo = undefined;
|
16
|
+
if (superInfos) {
|
17
|
+
superInfo = superInfos[superInfos.length - 1];
|
18
|
+
}
|
19
|
+
if (!superInfo) return _LuaAST.createAnonymousIdentifier(expression);
|
20
|
+
const { className } = superInfo;
|
21
|
+
return _LuaAST.createTableIndexExpression(className, _LuaAST.createStringLiteral('super'));
|
22
|
+
};
|
23
|
+
|
24
|
+
//# sourceMappingURL=transformSuperExpression.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/tstl-plugin/src/transformSuperExpression/transformSuperExpression.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport { FunctionVisitor, TransformationContext } from 'typescript-to-lua';\nimport * as lua from 'typescript-to-lua/dist/LuaAST';\nimport { ClassSuperInfo } from '../types';\n\nexport const transformSuperExpression = ((\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 return lua.createTableIndexExpression(\n className,\n lua.createStringLiteral('super')\n );\n}) satisfies FunctionVisitor<ts.SuperExpression>;\n"],"names":["transformSuperExpression","expression","context","superInfos","classSuperInfos","superInfo","undefined","length","lua","createAnonymousIdentifier","className","createTableIndexExpression","createStringLiteral"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAKaA;;;eAAAA;;;;kEAHQ;AAGd,MAAMA,2BAA4B,CACrCC,YACAC;IAEA,MAAMC,aAAaD,QAAQE,eAAe;IAC1C,IAAIC,YAAwCC;IAC5C,IAAIH,YAAY;QACZE,YAAYF,UAAU,CAACA,WAAWI,MAAM,GAAG,EAAE;IACjD;IACA,IAAI,CAACF,WAAW,OAAOG,QAAIC,yBAAyB,CAACR;IACrD,MAAM,EAAES,SAAS,EAAE,GAAGL;IAEtB,OAAOG,QAAIG,0BAA0B,CACjCD,WACAF,QAAII,mBAAmB,CAAC;AAEhC"}
|
package/assets/types.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../libs/tstl-plugin/src/types.ts"],"names":[],"rangeMappings":"","mappings":""}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
2
2
|
import { writeFileSync } from 'node:fs';
|
3
3
|
import { useMemo } from 'react';
|
4
|
-
import { Project } from 'ts-morph';
|
4
|
+
import { Project, VariableDeclarationKind } from 'ts-morph';
|
5
5
|
import { TypescriptReservedNamed } from '../../../constants.js';
|
6
6
|
export const useGenerateTypeFile = (path, definitions, typeProvider)=>{
|
7
7
|
const generateTypeFile = useMemo(()=>{
|
@@ -50,6 +50,15 @@ const generateNamespace = (apiObject, incomingSubject, typeProvider, namespace,
|
|
50
50
|
if (name === 'playdate') {
|
51
51
|
subject.addStatements(typeProvider.getStatements());
|
52
52
|
}
|
53
|
+
for (const constant of typeProvider.getConstants(fullNamespaceName)){
|
54
|
+
subject.addVariableStatement({
|
55
|
+
declarations: [
|
56
|
+
constant
|
57
|
+
],
|
58
|
+
isExported: true,
|
59
|
+
declarationKind: VariableDeclarationKind.Const
|
60
|
+
});
|
61
|
+
}
|
53
62
|
for (const func of apiObject.functions){
|
54
63
|
const isFunctionNameReserved = TypescriptReservedNamed.includes(func.name);
|
55
64
|
const resolvedName = `_${func.name}`;
|
@@ -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 ClassDeclaration,\n FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n Project,\n SourceFile,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { ApiDefinitions, ApiObject, 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\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n generateNamespace(globalNamespace, typeFile, typeProvider, '');\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\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n namespace: string,\n name?: string\n) => {\n let subject = incomingSubject;\n const fullNamespaceName = [namespace, name].filter(Boolean).join('.');\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n isExported: !!name,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n ...typeProvider.getClassOptions(fullNamespaceName),\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n for (const property of apiObject.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadOnly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const eachNamespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(\n eachNamespace[1],\n subject,\n typeProvider,\n fullNamespaceName,\n eachNamespace[0]\n );\n }\n};\n"],"names":["writeFileSync","useMemo","Project","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","namespace","name","subject","fullNamespaceName","filter","Boolean","join","addModule","getStatements","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","
|
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 FunctionDeclarationStructure,\n MethodDeclarationStructure,\n ModuleDeclaration,\n Project,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph';\nimport { createTypeProvider } from '@/cli/commands/GenerateTypes/utils/createTypeProvider.js';\nimport { TypescriptReservedNamed } from '@/cli/constants.js';\nimport { ApiDefinitions, ApiObject, 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\n const globalNamespace = definitions.global;\n\n typeFile.addStatements(typeProvider.getGlobalStatements());\n\n generateNamespace(globalNamespace, typeFile, typeProvider, '');\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\nconst generateNamespace = (\n apiObject: ApiObject,\n incomingSubject: SourceFile | ModuleDeclaration,\n typeProvider: ReturnType<typeof createTypeProvider>,\n namespace: string,\n name?: string\n) => {\n let subject = incomingSubject;\n const fullNamespaceName = [namespace, name].filter(Boolean).join('.');\n\n if (name) {\n subject = incomingSubject.addModule({\n name,\n });\n }\n\n if (name === 'playdate') {\n subject.addStatements(typeProvider.getStatements());\n }\n\n for (const constant of typeProvider.getConstants(fullNamespaceName)) {\n subject.addVariableStatement({\n declarations: [constant],\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n });\n }\n\n for (const func of apiObject.functions) {\n const isFunctionNameReserved = TypescriptReservedNamed.includes(\n func.name\n );\n const resolvedName = `_${func.name}`;\n const parameters = typeProvider.getParameters(func);\n\n subject.addFunction({\n name: isFunctionNameReserved ? resolvedName : func.name,\n docs: [func.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(func),\n isExported: !!name,\n ...(typeProvider.getFunctionOverrideOptions(\n func\n ) as FunctionDeclarationStructure),\n });\n\n if (isFunctionNameReserved) {\n subject.addExportDeclaration({\n namedExports: [\n {\n name: resolvedName,\n alias: func.name,\n },\n ],\n });\n }\n }\n\n let propertiesSubject: ClassDeclaration | null = null;\n\n if (name && apiObject.methods.length > 0) {\n const typeClass = incomingSubject.addClass({\n name,\n ...typeProvider.getClassOptions(fullNamespaceName),\n });\n propertiesSubject = typeClass;\n\n for (const method of apiObject.methods) {\n const parameters = typeProvider.getParameters(method);\n\n typeClass.addMethod({\n name: method.name,\n docs: [method.docs],\n parameters,\n returnType: typeProvider.getFunctionReturnType(method),\n ...(typeProvider.getFunctionOverrideOptions(\n method\n ) as Partial<MethodDeclarationStructure>),\n });\n }\n }\n\n for (const property of apiObject.properties) {\n const propertyDetails = typeProvider.getPropertyDetails(property);\n\n if (propertiesSubject) {\n propertiesSubject.addProperty({\n name: property.name,\n docs: [property.docs],\n type: propertyDetails.type,\n isStatic: propertyDetails.isStatic,\n isReadonly: propertyDetails.isReadOnly,\n });\n } else {\n subject.addVariableStatement({\n docs: [property.docs],\n declarations: [\n {\n name: property.name,\n type: propertyDetails.type,\n },\n ],\n });\n }\n }\n\n for (const eachNamespace of Object.entries(apiObject.namespaces)) {\n generateNamespace(\n eachNamespace[1],\n subject,\n typeProvider,\n fullNamespaceName,\n eachNamespace[0]\n );\n }\n};\n"],"names":["writeFileSync","useMemo","Project","VariableDeclarationKind","TypescriptReservedNamed","useGenerateTypeFile","path","definitions","typeProvider","generateTypeFile","waitingDescription","errorDescription","finishedDescription","runningDescription","runner","Error","project","typeFile","createSourceFile","overwrite","globalNamespace","global","addStatements","getGlobalStatements","generateNamespace","getFullText","replace","ready","apiObject","incomingSubject","namespace","name","subject","fullNamespaceName","filter","Boolean","join","addModule","getStatements","constant","getConstants","addVariableStatement","declarations","isExported","declarationKind","Const","func","functions","isFunctionNameReserved","includes","resolvedName","parameters","getParameters","addFunction","docs","returnType","getFunctionReturnType","getFunctionOverrideOptions","addExportDeclaration","namedExports","alias","propertiesSubject","methods","length","typeClass","addClass","getClassOptions","method","addMethod","property","properties","propertyDetails","getPropertyDetails","addProperty","type","isStatic","isReadonly","isReadOnly","eachNamespace","Object","entries","namespaces"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,aAAa,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAKIC,OAAO,EAEPC,uBAAuB,QACpB,WAAW;AAElB,SAASC,uBAAuB,QAAQ,qBAAqB;AAG7D,OAAO,MAAMC,sBAAsB,CAC/BC,MACAC,aACAC;IAEA,MAAMC,mBAAmBR,QAAQ;QAC7B,OAAO;YACHS,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,IAAId;gBACpB,MAAMe,WAAWD,QAAQE,gBAAgB,CAACZ,MAAM,IAAI;oBAChDa,WAAW;gBACf;gBAEA,MAAMC,kBAAkBb,YAAYc,MAAM;gBAE1CJ,SAASK,aAAa,CAACd,aAAae,mBAAmB;gBAEvDC,kBAAkBJ,iBAAiBH,UAAUT,cAAc;gBAE3DR,cACIM,MACAW,SAASQ,WAAW,GAAGC,OAAO,CAAC,MAAM;YAE7C;YACAC,OAAOpB,gBAAgB,QAAQC,iBAAiB;QACpD;IACJ,GAAG;QAACD;QAAaC;KAAa;IAE9B,OAAO;QACHC;IACJ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e,CAACjC;QAEpC4B,oBAAoBG;QAEpB,KAAK,MAAMG,UAAUvC,UAAUkC,OAAO,CAAE;YACpC,MAAMX,aAAa3C,aAAa4C,aAAa,CAACe;YAE9CH,UAAUI,SAAS,CAAC;gBAChBrC,MAAMoC,OAAOpC,IAAI;gBACjBuB,MAAM;oBAACa,OAAOb,IAAI;iBAAC;gBACnBH;gBACAI,YAAY/C,aAAagD,qBAAqB,CAACW;eAC3C3D,aAAaiD,0BAA0B,CACvCU;QAGZ;IACJ;IAEA,KAAK,MAAME,YAAYzC,UAAU0C,UAAU,CAAE;QACzC,MAAMC,kBAAkB/D,aAAagE,kBAAkB,CAACH;QAExD,IAAIR,mBAAmB;YACnBA,kBAAkBY,WAAW,CAAC;gBAC1B1C,MAAMsC,SAAStC,IAAI;gBACnBuB,MAAM;oBAACe,SAASf,IAAI;iBAAC;gBACrBoB,MAAMH,gBAAgBG,IAAI;gBAC1BC,UAAUJ,gBAAgBI,QAAQ;gBAClCC,YAAYL,gBAAgBM,UAAU;YAC1C;QACJ,OAAO;YACH7C,QAAQS,oBAAoB,CAAC;gBACzBa,MAAM;oBAACe,SAASf,IAAI;iBAAC;gBACrBZ,cAAc;oBACV;wBACIX,MAAMsC,SAAStC,IAAI;wBACnB2C,MAAMH,gBAAgBG,IAAI;oBAC9B;iBACH;YACL;QACJ;IACJ;IAEA,KAAK,MAAMI,iBAAiBC,OAAOC,OAAO,CAACpD,UAAUqD,UAAU,EAAG;QAC9DzD,kBACIsD,aAAa,CAAC,EAAE,EAChB9C,SACAxB,cACAyB,mBACA6C,aAAa,CAAC,EAAE;IAExB;AACJ"}
|
@@ -48,6 +48,11 @@ export declare const useGetVersion: (version: PlaydateSdkVersion) => {
|
|
48
48
|
kind?: import("ts-morph").StructureKind.FunctionOverload | undefined;
|
49
49
|
})[];
|
50
50
|
};
|
51
|
+
getConstants: (fullNamespace: string) => {
|
52
|
+
kind: import("ts-morph").StructureKind.VariableDeclaration;
|
53
|
+
name: string;
|
54
|
+
type: string;
|
55
|
+
}[];
|
51
56
|
save: () => void;
|
52
57
|
} | null;
|
53
58
|
};
|
@@ -39,5 +39,10 @@ export declare const createTypeProvider: (version: string) => {
|
|
39
39
|
kind?: StructureKind.FunctionOverload | undefined;
|
40
40
|
})[];
|
41
41
|
};
|
42
|
+
getConstants: (fullNamespace: string) => {
|
43
|
+
kind: StructureKind.VariableDeclaration;
|
44
|
+
name: string;
|
45
|
+
type: string;
|
46
|
+
}[];
|
42
47
|
save: () => void;
|
43
48
|
};
|
@@ -11,6 +11,7 @@ export const createTypeProvider = (version)=>{
|
|
11
11
|
const path = join(DataFolder, `${version}.json`);
|
12
12
|
const fallbackProvider = existsSync(path) ? JSON.parse(readFileSync(path, 'utf-8')) : {
|
13
13
|
globalStatements: [],
|
14
|
+
constants: {},
|
14
15
|
statements: [],
|
15
16
|
classes: {},
|
16
17
|
properties: {},
|
@@ -18,6 +19,7 @@ export const createTypeProvider = (version)=>{
|
|
18
19
|
};
|
19
20
|
const provider = {
|
20
21
|
globalStatements: fallbackProvider.globalStatements,
|
22
|
+
constants: fallbackProvider.constants,
|
21
23
|
statements: fallbackProvider.statements,
|
22
24
|
classes: fallbackProvider.classes,
|
23
25
|
properties: {},
|
@@ -136,6 +138,16 @@ export const createTypeProvider = (version)=>{
|
|
136
138
|
}
|
137
139
|
return options;
|
138
140
|
};
|
141
|
+
const getConstants = (fullNamespace)=>{
|
142
|
+
var _provider_constants_fullNamespace;
|
143
|
+
return ((_provider_constants_fullNamespace = provider.constants[fullNamespace]) != null ? _provider_constants_fullNamespace : []).map((constant)=>{
|
144
|
+
return {
|
145
|
+
kind: StructureKind.VariableDeclaration,
|
146
|
+
name: typeof constant === 'string' ? constant : constant.name,
|
147
|
+
type: typeof constant === 'string' ? 'number' : constant.type
|
148
|
+
};
|
149
|
+
});
|
150
|
+
};
|
139
151
|
const save = ()=>{
|
140
152
|
const contents = JSON.stringify(provider, null, 4) + '\n';
|
141
153
|
writeFileSync(path, contents, 'utf-8');
|
@@ -149,6 +161,7 @@ export const createTypeProvider = (version)=>{
|
|
149
161
|
getParameterDetails,
|
150
162
|
getParameters,
|
151
163
|
getFunctionOverrideOptions,
|
164
|
+
getConstants,
|
152
165
|
save
|
153
166
|
};
|
154
167
|
};
|
@@ -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 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,SAAW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K,EAAEb,UAAU,EAAE,GAC5CH,mBAAmBC;QACvB,MAAMgB,0BAA0B,CAACL;gBAKrBA;YAJR,OAAO;gBACHM,MAAMrD,cAAcsD,SAAS;gBAC7Bb,MAAMvC,iBAAiB6C,UAAUN,IAAI;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"}
|
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 VariableDeclarationStructure,\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 constants: {},\n statements: [],\n classes: {},\n properties: {},\n functions: {},\n } satisfies TypeProviderData);\n const provider = {\n globalStatements: fallbackProvider.globalStatements,\n constants: fallbackProvider.constants,\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 getConstants = (fullNamespace: string) => {\n return (provider.constants[fullNamespace] ?? []).map((constant) => {\n return {\n kind: StructureKind.VariableDeclaration,\n name: typeof constant === 'string' ? constant : constant.name,\n type: typeof constant === 'string' ? 'number' : constant.type,\n } satisfies VariableDeclarationStructure;\n });\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 getConstants,\n save,\n };\n};\n"],"names":["readFileSync","existsSync","writeFileSync","join","StructureKind","DataFolder","kebabToCamelCase","str","replace","_","letter","toUpperCase","createTypeProvider","version","path","fallbackProvider","JSON","parse","globalStatements","constants","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","getConstants","fullNamespace","constant","VariableDeclaration","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,QAEV,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,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IAEA,MAAMoC,OAAO;QACT,MAAMC,WAAW3D,KAAK4D,SAAS,CAACpD,UAAU,MAAM,KAAK;QAErDtB,cAAcY,MAAM6D,UAAU;IAClC;IAEA,OAAO;QACH3B;QACAC;QACArB;QACAE;QACAoB;QACAC;QACAI;QACAQ;QACAO;QACAI;IACJ;AACJ,EAAE"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../libs/cli/src/commands/TranspileCommand/fn/_tests/test-automatic-imports/src/index.ts"],"sourcesContent":["printTable(playdate.graphics);\n"],"names":["printTable","playdate","graphics"],"rangeMappings":"","mappings":"AAAAA,WAAWC,SAASC,QAAQ"}
|
package/src/types.d.ts
CHANGED
@@ -81,9 +81,14 @@ export interface FunctionDetails {
|
|
81
81
|
overrideParameters?: boolean;
|
82
82
|
overrideOptions?: Partial<FunctionDeclarationStructure | MethodDeclarationStructure>;
|
83
83
|
}
|
84
|
+
export interface ConstantDefinition {
|
85
|
+
name: string;
|
86
|
+
type: string;
|
87
|
+
}
|
84
88
|
export type TypeProviderData = {
|
85
89
|
globalStatements: string[];
|
86
90
|
statements: string[];
|
91
|
+
constants: Record<string, (ConstantDefinition | string)[]>;
|
87
92
|
classes: Record<string, Partial<ClassDeclarationStructure>>;
|
88
93
|
properties: Record<string, PropertyDetails>;
|
89
94
|
functions: Record<string, FunctionDetails>;
|
package/src/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\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 ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\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 classes: Record<string, Partial<ClassDeclarationStructure>>;\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n\nexport type FunctionTypeOverrideMap = Record<string, { isMethod: boolean }>;\n\nexport enum TemplateName {\n Blank = 'blank',\n}\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType","TemplateName"],"rangeMappings":";;;;;;;;;;;;;","mappings":";UASYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA;;
|
1
|
+
{"version":3,"sources":["../../../../libs/cli/src/types.ts"],"sourcesContent":["import {\n ClassDeclarationStructure,\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 ApiObject {\n functions: FunctionDescription[];\n methods: FunctionDescription[];\n properties: PropertyDescription[];\n namespaces: Record<string, ApiObject>;\n}\n\nexport interface ApiDefinitions {\n global: ApiObject;\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 interface ConstantDefinition {\n name: string;\n type: string;\n}\n\nexport type TypeProviderData = {\n globalStatements: string[];\n statements: string[];\n constants: Record<string, (ConstantDefinition | string)[]>;\n classes: Record<string, Partial<ClassDeclarationStructure>>;\n properties: Record<string, PropertyDetails>;\n functions: Record<string, FunctionDetails>;\n};\n\nexport type FunctionTypeOverrideMap = Record<string, { isMethod: boolean }>;\n\nexport enum TemplateName {\n Blank = 'blank',\n}\n"],"names":["PlaydateSdkVersionIdentifier","HealthCheckStatusType","TemplateName"],"rangeMappings":";;;;;;;;;;;;;","mappings":";UASYA;;GAAAA,iCAAAA;;UAiBAC;;;;GAAAA,0BAAAA;;UAwGAC;;GAAAA,iBAAAA"}
|