typescript-to-lua 1.4.0 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CompilerOptions.d.ts +4 -1
- package/dist/LuaAST.d.ts +9 -7
- package/dist/LuaAST.js +19 -13
- package/dist/LuaLib.d.ts +2 -2
- package/dist/LuaLib.js +2 -2
- package/dist/LuaPrinter.js +10 -11
- package/dist/cli/parse.js +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/lualib/ArrayConcat.lua +16 -12
- package/dist/lualib/ArrayEvery.lua +4 -8
- package/dist/lualib/ArrayFilter.lua +6 -8
- package/dist/lualib/ArrayFind.lua +4 -7
- package/dist/lualib/ArrayFindIndex.lua +4 -9
- package/dist/lualib/ArrayFlat.lua +17 -7
- package/dist/lualib/ArrayFlatMap.lua +11 -10
- package/dist/lualib/ArrayForEach.lua +3 -7
- package/dist/lualib/ArrayFrom.lua +29 -0
- package/dist/lualib/ArrayIncludes.lua +2 -2
- package/dist/lualib/ArrayIndexOf.lua +13 -21
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayJoin.lua +4 -7
- package/dist/lualib/ArrayMap.lua +5 -9
- package/dist/lualib/ArrayPush.lua +6 -4
- package/dist/lualib/ArrayPushArray.lua +8 -0
- package/dist/lualib/ArrayReduce.lua +8 -8
- package/dist/lualib/ArrayReduceRight.lua +8 -8
- package/dist/lualib/ArrayReverse.lua +7 -7
- package/dist/lualib/ArraySetLength.lua +3 -7
- package/dist/lualib/ArraySlice.lua +26 -19
- package/dist/lualib/ArraySome.lua +4 -8
- package/dist/lualib/ArraySort.lua +4 -4
- package/dist/lualib/ArraySplice.lua +47 -58
- package/dist/lualib/ArrayToObject.lua +3 -7
- package/dist/lualib/ArrayUnshift.lua +11 -8
- package/dist/lualib/FunctionBind.lua +5 -11
- package/dist/lualib/ObjectAssign.lua +5 -7
- package/dist/lualib/ObjectEntries.lua +3 -1
- package/dist/lualib/ObjectKeys.lua +3 -1
- package/dist/lualib/ObjectValues.lua +3 -1
- package/dist/lualib/Promise.lua +8 -7
- package/dist/lualib/PromiseAny.lua +3 -3
- package/dist/lualib/PromiseRace.lua +1 -1
- package/dist/lualib/Spread.lua +5 -7
- package/dist/lualib/StringReplace.lua +17 -14
- package/dist/lualib/StringReplaceAll.lua +36 -29
- package/dist/lualib/StringSplit.lua +32 -32
- package/dist/lualib/lualib_bundle.lua +425 -421
- package/dist/lualib/lualib_module_info.json +21 -22
- package/dist/transformation/builtins/array.d.ts +2 -2
- package/dist/transformation/builtins/array.js +40 -2
- package/dist/transformation/builtins/promise.d.ts +1 -0
- package/dist/transformation/builtins/promise.js +2 -1
- package/dist/transformation/builtins/string.js +1 -1
- package/dist/transformation/utils/diagnostics.d.ts +7 -2
- package/dist/transformation/utils/diagnostics.js +4 -1
- package/dist/transformation/utils/lua-ast.d.ts +1 -0
- package/dist/transformation/utils/lua-ast.js +6 -2
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +9 -1
- package/dist/transformation/visitors/call.js +4 -0
- package/dist/transformation/visitors/class/index.js +1 -1
- package/dist/transformation/visitors/class/members/accessors.js +1 -1
- package/dist/transformation/visitors/class/members/constructor.js +1 -1
- package/dist/transformation/visitors/errors.js +4 -2
- package/dist/transformation/visitors/function.js +4 -4
- package/dist/transformation/visitors/modules/import.d.ts +1 -0
- package/dist/transformation/visitors/modules/import.js +9 -1
- package/dist/transformation/visitors/spread.js +1 -7
- package/dist/transpilation/plugins.d.ts +10 -3
- package/dist/transpilation/plugins.js +6 -2
- package/dist/transpilation/resolve.js +1 -0
- package/dist/transpilation/transpile.d.ts +1 -1
- package/dist/transpilation/transpile.js +1 -6
- package/dist/transpilation/transpiler.js +19 -9
- package/dist/transpilation/utils.d.ts +2 -0
- package/package.json +1 -1
- package/dist/lualib/ArrayShift.lua +0 -3
- package/dist/lualib/StringConcat.lua +0 -8
|
@@ -7,6 +7,7 @@ const CompilerOptions_1 = require("../CompilerOptions");
|
|
|
7
7
|
const LuaLib_1 = require("../LuaLib");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const bundle_1 = require("./bundle");
|
|
10
|
+
const plugins_1 = require("./plugins");
|
|
10
11
|
const resolve_1 = require("./resolve");
|
|
11
12
|
const transpile_1 = require("./transpile");
|
|
12
13
|
class Transpiler {
|
|
@@ -14,18 +15,27 @@ class Transpiler {
|
|
|
14
15
|
this.emitHost = emitHost;
|
|
15
16
|
}
|
|
16
17
|
emit(emitOptions) {
|
|
17
|
-
var _a;
|
|
18
|
+
var _a, _b;
|
|
18
19
|
const { program, writeFile = this.emitHost.writeFile } = emitOptions;
|
|
19
|
-
const
|
|
20
|
-
const { diagnostics,
|
|
20
|
+
const options = program.getCompilerOptions();
|
|
21
|
+
const { diagnostics: getPluginsDiagnostics, plugins } = (0, plugins_1.getPlugins)(program);
|
|
22
|
+
const { diagnostics, transpiledFiles: freshFiles } = (0, transpile_1.getProgramTranspileResult)(this.emitHost, writeFile, {
|
|
23
|
+
...emitOptions,
|
|
24
|
+
plugins,
|
|
25
|
+
});
|
|
21
26
|
const { emitPlan } = this.getEmitPlan(program, diagnostics, freshFiles);
|
|
22
|
-
if (
|
|
27
|
+
if (options.tstlVerbose) {
|
|
23
28
|
console.log("Emitting output");
|
|
24
29
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
30
|
+
for (const plugin of plugins) {
|
|
31
|
+
if (plugin.beforeEmit) {
|
|
32
|
+
const beforeEmitPluginDiagnostics = (_a = plugin.beforeEmit(program, options, this.emitHost, emitPlan)) !== null && _a !== void 0 ? _a : [];
|
|
33
|
+
diagnostics.push(...beforeEmitPluginDiagnostics);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const emitBOM = (_b = options.emitBOM) !== null && _b !== void 0 ? _b : false;
|
|
27
37
|
for (const { outputPath, code, sourceMap, sourceFiles } of emitPlan) {
|
|
28
|
-
if (
|
|
38
|
+
if (options.tstlVerbose) {
|
|
29
39
|
console.log(`Emitting ${(0, utils_1.normalizeSlashes)(outputPath)}`);
|
|
30
40
|
}
|
|
31
41
|
writeFile(outputPath, code, emitBOM, undefined, sourceFiles);
|
|
@@ -33,10 +43,10 @@ class Transpiler {
|
|
|
33
43
|
writeFile(outputPath + ".map", sourceMap, emitBOM, undefined, sourceFiles);
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
|
-
if (
|
|
46
|
+
if (options.tstlVerbose) {
|
|
37
47
|
console.log("Emit finished!");
|
|
38
48
|
}
|
|
39
|
-
return { diagnostics, emitSkipped: emitPlan.length === 0 };
|
|
49
|
+
return { diagnostics: getPluginsDiagnostics.concat(diagnostics), emitSkipped: emitPlan.length === 0 };
|
|
40
50
|
}
|
|
41
51
|
getEmitPlan(program, diagnostics, files) {
|
|
42
52
|
const options = program.getCompilerOptions();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SourceNode } from "source-map";
|
|
1
2
|
import * as ts from "typescript";
|
|
2
3
|
import * as lua from "../LuaAST";
|
|
3
4
|
export interface EmitHost {
|
|
@@ -15,6 +16,7 @@ interface BaseFile {
|
|
|
15
16
|
export interface ProcessedFile extends BaseFile {
|
|
16
17
|
fileName: string;
|
|
17
18
|
luaAst?: lua.File;
|
|
19
|
+
sourceMapNode?: SourceNode;
|
|
18
20
|
}
|
|
19
21
|
export interface EmitFile extends BaseFile {
|
|
20
22
|
outputPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
|
|
5
5
|
"repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
|
|
6
6
|
"homepage": "https://typescripttolua.github.io/",
|