typescript-to-lua 1.12.1 → 1.13.1
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/lualib/5.0/Await.lua +5 -11
- package/dist/lualib/5.0/Decorate.lua +1 -1
- package/dist/lualib/5.0/Error.lua +12 -18
- package/dist/lualib/5.0/Map.lua +3 -3
- package/dist/lualib/5.0/MathModf.lua +1 -7
- package/dist/lualib/5.0/ObjectDefineProperty.lua +21 -27
- package/dist/lualib/5.0/ParseFloat.lua +2 -8
- package/dist/lualib/5.0/ParseInt.lua +9 -21
- package/dist/lualib/5.0/Set.lua +3 -3
- package/dist/lualib/5.0/SetDescriptor.lua +2 -2
- package/dist/lualib/5.0/SourceMapTraceBack.lua +4 -4
- package/dist/lualib/5.0/StringReplace.lua +1 -7
- package/dist/lualib/5.0/SymbolRegistry.lua +1 -0
- package/dist/lualib/5.0/lualib_bundle.lua +65 -112
- package/dist/lualib/universal/Await.lua +5 -11
- package/dist/lualib/universal/Decorate.lua +1 -1
- package/dist/lualib/universal/Error.lua +12 -18
- package/dist/lualib/universal/Map.lua +3 -3
- package/dist/lualib/universal/ObjectDefineProperty.lua +21 -27
- package/dist/lualib/universal/ParseFloat.lua +2 -8
- package/dist/lualib/universal/ParseInt.lua +3 -15
- package/dist/lualib/universal/Set.lua +3 -3
- package/dist/lualib/universal/SetDescriptor.lua +2 -2
- package/dist/lualib/universal/SourceMapTraceBack.lua +5 -5
- package/dist/lualib/universal/StringReplace.lua +1 -7
- package/dist/lualib/universal/SymbolRegistry.lua +1 -0
- package/dist/lualib/universal/lualib_bundle.lua +59 -100
- package/dist/transformation/utils/preceding-statements.d.ts +5 -1
- package/dist/transformation/utils/preceding-statements.js +1 -1
- package/dist/transformation/visitors/binary-expression/assignments.js +3 -3
- package/dist/transformation/visitors/binary-expression/compound.d.ts +0 -7
- package/dist/transformation/visitors/binary-expression/compound.js +40 -22
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +5 -5
- package/dist/transformation/visitors/binary-expression/index.d.ts +3 -2
- package/dist/transformation/visitors/binary-expression/index.js +12 -13
- package/dist/transformation/visitors/call.js +2 -2
- package/dist/transformation/visitors/class/index.js +1 -1
- package/dist/transformation/visitors/class/members/fields.js +1 -1
- package/dist/transformation/visitors/conditional.js +10 -10
- package/dist/transformation/visitors/expression-list.js +1 -1
- package/dist/transformation/visitors/function.js +2 -2
- package/dist/transformation/visitors/loops/do-while.js +2 -2
- package/dist/transformation/visitors/loops/for.js +2 -2
- package/dist/transformation/visitors/loops/utils.js +1 -1
- package/dist/transformation/visitors/optional-chaining.js +2 -2
- package/dist/transformation/visitors/sourceFile.js +1 -1
- package/dist/transformation/visitors/switch.js +15 -6
- package/dist/transformation/visitors/typeof.js +1 -1
- package/dist/transformation/visitors/variable-declaration.js +3 -3
- package/dist/transpilation/output-collector.d.ts +1 -1
- package/dist/transpilation/output-collector.js +3 -3
- package/dist/transpilation/resolve.js +22 -10
- package/package.json +7 -7
|
@@ -4,13 +4,7 @@ local function __TS__AsyncAwaiter(generator)
|
|
|
4
4
|
function(____, resolve, reject)
|
|
5
5
|
local adopt, fulfilled, step, resolved, asyncCoroutine
|
|
6
6
|
function adopt(self, value)
|
|
7
|
-
|
|
8
|
-
if __TS__InstanceOf(value, __TS__Promise) then
|
|
9
|
-
____temp_0 = value
|
|
10
|
-
else
|
|
11
|
-
____temp_0 = __TS__Promise.resolve(value)
|
|
12
|
-
end
|
|
13
|
-
return ____temp_0
|
|
7
|
+
return __TS__InstanceOf(value, __TS__Promise) and value or __TS__Promise.resolve(value)
|
|
14
8
|
end
|
|
15
9
|
function fulfilled(self, value)
|
|
16
10
|
local success, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
@@ -27,8 +21,8 @@ local function __TS__AsyncAwaiter(generator)
|
|
|
27
21
|
if coroutine.status(asyncCoroutine) == "dead" then
|
|
28
22
|
resolve(nil, result)
|
|
29
23
|
else
|
|
30
|
-
local
|
|
31
|
-
|
|
24
|
+
local ____self_0 = adopt(nil, result)
|
|
25
|
+
____self_0["then"](____self_0, fulfilled, reject)
|
|
32
26
|
end
|
|
33
27
|
end
|
|
34
28
|
resolved = false
|
|
@@ -37,8 +31,8 @@ local function __TS__AsyncAwaiter(generator)
|
|
|
37
31
|
asyncCoroutine,
|
|
38
32
|
function(____, v)
|
|
39
33
|
resolved = true
|
|
40
|
-
local
|
|
41
|
-
|
|
34
|
+
local ____self_1 = adopt(nil, v)
|
|
35
|
+
____self_1["then"](____self_1, resolve, reject)
|
|
42
36
|
end
|
|
43
37
|
)
|
|
44
38
|
if success then
|
|
@@ -4,7 +4,7 @@ local function __TS__Decorate(decorators, target, key, desc)
|
|
|
4
4
|
local i = table.getn(decorators)
|
|
5
5
|
while i >= 0 do
|
|
6
6
|
local decorator = decorators[i + 1]
|
|
7
|
-
if decorator then
|
|
7
|
+
if decorator ~= nil then
|
|
8
8
|
local oldResult = result
|
|
9
9
|
if key == nil then
|
|
10
10
|
result = decorator(nil, result)
|
|
@@ -26,7 +26,7 @@ do
|
|
|
26
26
|
if isClassicLua or caller and caller.func ~= error then
|
|
27
27
|
return description
|
|
28
28
|
else
|
|
29
|
-
return (
|
|
29
|
+
return (description .. "\n") .. tostring(self.stack)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -37,7 +37,7 @@ do
|
|
|
37
37
|
{__call = function(____, _self, message) return __TS__New(Type, message) end}
|
|
38
38
|
)
|
|
39
39
|
end
|
|
40
|
-
local
|
|
40
|
+
local ____initErrorClass_1 = initErrorClass
|
|
41
41
|
local ____class_0 = __TS__Class()
|
|
42
42
|
____class_0.name = ""
|
|
43
43
|
function ____class_0.prototype.____constructor(self, message)
|
|
@@ -48,34 +48,28 @@ do
|
|
|
48
48
|
self.name = "Error"
|
|
49
49
|
self.stack = getErrorStack(nil, self.constructor.new)
|
|
50
50
|
local metatable = getmetatable(self)
|
|
51
|
-
if not metatable.__errorToStringPatched then
|
|
51
|
+
if metatable and not metatable.__errorToStringPatched then
|
|
52
52
|
metatable.__errorToStringPatched = true
|
|
53
53
|
metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
function ____class_0.prototype.__tostring(self)
|
|
57
|
-
|
|
58
|
-
if self.message ~= "" then
|
|
59
|
-
____temp_1 = (self.name .. ": ") .. self.message
|
|
60
|
-
else
|
|
61
|
-
____temp_1 = self.name
|
|
62
|
-
end
|
|
63
|
-
return ____temp_1
|
|
57
|
+
return self.message ~= "" and (self.name .. ": ") .. self.message or self.name
|
|
64
58
|
end
|
|
65
|
-
Error =
|
|
59
|
+
Error = ____initErrorClass_1(nil, ____class_0, "Error")
|
|
66
60
|
local function createErrorClass(self, name)
|
|
67
|
-
local
|
|
68
|
-
local
|
|
69
|
-
|
|
70
|
-
__TS__ClassExtends(
|
|
71
|
-
function
|
|
72
|
-
|
|
61
|
+
local ____initErrorClass_3 = initErrorClass
|
|
62
|
+
local ____class_2 = __TS__Class()
|
|
63
|
+
____class_2.name = ____class_2.name
|
|
64
|
+
__TS__ClassExtends(____class_2, Error)
|
|
65
|
+
function ____class_2.prototype.____constructor(self, ...)
|
|
66
|
+
____class_2.____super.prototype.____constructor(
|
|
73
67
|
self,
|
|
74
68
|
unpack(arg)
|
|
75
69
|
)
|
|
76
70
|
self.name = name
|
|
77
71
|
end
|
|
78
|
-
return
|
|
72
|
+
return ____initErrorClass_3(nil, ____class_2, name)
|
|
79
73
|
end
|
|
80
74
|
RangeError = createErrorClass(nil, "RangeError")
|
|
81
75
|
ReferenceError = createErrorClass(nil, "ReferenceError")
|
package/dist/lualib/5.0/Map.lua
CHANGED
|
@@ -43,13 +43,13 @@ do
|
|
|
43
43
|
self.size = self.size - 1
|
|
44
44
|
local next = self.nextKey[key]
|
|
45
45
|
local previous = self.previousKey[key]
|
|
46
|
-
if next and previous then
|
|
46
|
+
if next ~= nil and previous ~= nil then
|
|
47
47
|
self.nextKey[previous] = next
|
|
48
48
|
self.previousKey[next] = previous
|
|
49
|
-
elseif next then
|
|
49
|
+
elseif next ~= nil then
|
|
50
50
|
self.firstKey = next
|
|
51
51
|
self.previousKey[next] = nil
|
|
52
|
-
elseif previous then
|
|
52
|
+
elseif previous ~= nil then
|
|
53
53
|
self.lastKey = previous
|
|
54
54
|
self.nextKey[previous] = nil
|
|
55
55
|
else
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
local function __TS__MathModf(x)
|
|
2
|
-
local
|
|
3
|
-
if x > 0 then
|
|
4
|
-
____temp_0 = math.floor(x)
|
|
5
|
-
else
|
|
6
|
-
____temp_0 = math.ceil(x)
|
|
7
|
-
end
|
|
8
|
-
local integral = ____temp_0
|
|
2
|
+
local integral = x > 0 and math.floor(x) or math.ceil(x)
|
|
9
3
|
return integral, x - integral
|
|
10
4
|
end
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
local function __TS__ObjectDefineProperty(target, key, desc)
|
|
2
|
-
local
|
|
3
|
-
if type(key) == "number" then
|
|
4
|
-
____temp_0 = key + 1
|
|
5
|
-
else
|
|
6
|
-
____temp_0 = key
|
|
7
|
-
end
|
|
8
|
-
local luaKey = ____temp_0
|
|
2
|
+
local luaKey = type(key) == "number" and key + 1 or key
|
|
9
3
|
local value = rawget(target, luaKey)
|
|
10
4
|
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
|
|
11
5
|
local descriptor
|
|
@@ -19,39 +13,39 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
19
13
|
descriptor = desc
|
|
20
14
|
else
|
|
21
15
|
local valueExists = value ~= nil
|
|
22
|
-
local
|
|
23
|
-
local
|
|
24
|
-
local
|
|
16
|
+
local ____desc_set_4 = desc.set
|
|
17
|
+
local ____desc_get_5 = desc.get
|
|
18
|
+
local ____temp_0
|
|
25
19
|
if desc.configurable ~= nil then
|
|
26
|
-
|
|
20
|
+
____temp_0 = desc.configurable
|
|
27
21
|
else
|
|
28
|
-
|
|
22
|
+
____temp_0 = valueExists
|
|
29
23
|
end
|
|
30
|
-
local
|
|
24
|
+
local ____temp_1
|
|
31
25
|
if desc.enumerable ~= nil then
|
|
32
|
-
|
|
26
|
+
____temp_1 = desc.enumerable
|
|
33
27
|
else
|
|
34
|
-
|
|
28
|
+
____temp_1 = valueExists
|
|
35
29
|
end
|
|
36
|
-
local
|
|
30
|
+
local ____temp_2
|
|
37
31
|
if desc.writable ~= nil then
|
|
38
|
-
|
|
32
|
+
____temp_2 = desc.writable
|
|
39
33
|
else
|
|
40
|
-
|
|
34
|
+
____temp_2 = valueExists
|
|
41
35
|
end
|
|
42
|
-
local
|
|
36
|
+
local ____temp_3
|
|
43
37
|
if desc.value ~= nil then
|
|
44
|
-
|
|
38
|
+
____temp_3 = desc.value
|
|
45
39
|
else
|
|
46
|
-
|
|
40
|
+
____temp_3 = value
|
|
47
41
|
end
|
|
48
42
|
descriptor = {
|
|
49
|
-
set =
|
|
50
|
-
get =
|
|
51
|
-
configurable =
|
|
52
|
-
enumerable =
|
|
53
|
-
writable =
|
|
54
|
-
value =
|
|
43
|
+
set = ____desc_set_4,
|
|
44
|
+
get = ____desc_get_5,
|
|
45
|
+
configurable = ____temp_0,
|
|
46
|
+
enumerable = ____temp_1,
|
|
47
|
+
writable = ____temp_2,
|
|
48
|
+
value = ____temp_3
|
|
55
49
|
}
|
|
56
50
|
end
|
|
57
51
|
__TS__SetDescriptor(target, luaKey, descriptor)
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
local function __TS__ParseFloat(numberString)
|
|
2
2
|
local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
|
|
3
|
-
if infinityMatch then
|
|
4
|
-
|
|
5
|
-
if __TS__StringAccess(infinityMatch, 0) == "-" then
|
|
6
|
-
____temp_0 = -(1 / 0)
|
|
7
|
-
else
|
|
8
|
-
____temp_0 = 1 / 0
|
|
9
|
-
end
|
|
10
|
-
return ____temp_0
|
|
3
|
+
if infinityMatch ~= nil then
|
|
4
|
+
return __TS__StringAccess(infinityMatch, 0) == "-" and -(1 / 0) or 1 / 0
|
|
11
5
|
end
|
|
12
6
|
local number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))
|
|
13
7
|
return number or 0 / 0
|
|
@@ -5,33 +5,21 @@ do
|
|
|
5
5
|
if base == nil then
|
|
6
6
|
base = 10
|
|
7
7
|
local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
|
|
8
|
-
if hexMatch then
|
|
8
|
+
if hexMatch ~= nil then
|
|
9
9
|
base = 16
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
____TS__Match_result__0_0 = __TS__StringSubstring(
|
|
18
|
-
numberString,
|
|
19
|
-
string.len(hexMatch)
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
numberString = ____TS__Match_result__0_0
|
|
10
|
+
numberString = __TS__Match(hexMatch, "-") and "-" .. __TS__StringSubstring(
|
|
11
|
+
numberString,
|
|
12
|
+
string.len(hexMatch)
|
|
13
|
+
) or __TS__StringSubstring(
|
|
14
|
+
numberString,
|
|
15
|
+
string.len(hexMatch)
|
|
16
|
+
)
|
|
23
17
|
end
|
|
24
18
|
end
|
|
25
19
|
if base < 2 or base > 36 then
|
|
26
20
|
return 0 / 0
|
|
27
21
|
end
|
|
28
|
-
local
|
|
29
|
-
if base <= 10 then
|
|
30
|
-
____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
|
|
31
|
-
else
|
|
32
|
-
____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
|
|
33
|
-
end
|
|
34
|
-
local allowedDigits = ____temp_1
|
|
22
|
+
local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
|
|
35
23
|
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
36
24
|
local number = tonumber(
|
|
37
25
|
__TS__Match(numberString, pattern),
|
package/dist/lualib/5.0/Set.lua
CHANGED
|
@@ -55,13 +55,13 @@ do
|
|
|
55
55
|
self.size = self.size - 1
|
|
56
56
|
local next = self.nextKey[value]
|
|
57
57
|
local previous = self.previousKey[value]
|
|
58
|
-
if next and previous then
|
|
58
|
+
if next ~= nil and previous ~= nil then
|
|
59
59
|
self.nextKey[previous] = next
|
|
60
60
|
self.previousKey[next] = previous
|
|
61
|
-
elseif next then
|
|
61
|
+
elseif next ~= nil then
|
|
62
62
|
self.firstKey = next
|
|
63
63
|
self.previousKey[next] = nil
|
|
64
|
-
elseif previous then
|
|
64
|
+
elseif previous ~= nil then
|
|
65
65
|
self.lastKey = previous
|
|
66
66
|
self.nextKey[previous] = nil
|
|
67
67
|
else
|
|
@@ -14,7 +14,7 @@ do
|
|
|
14
14
|
local descriptors = rawget(metatable, "_descriptors")
|
|
15
15
|
if descriptors then
|
|
16
16
|
local descriptor = descriptors[key]
|
|
17
|
-
if descriptor then
|
|
17
|
+
if descriptor ~= nil then
|
|
18
18
|
if descriptor.get then
|
|
19
19
|
return descriptor.get(self)
|
|
20
20
|
end
|
|
@@ -30,7 +30,7 @@ do
|
|
|
30
30
|
local descriptors = rawget(metatable, "_descriptors")
|
|
31
31
|
if descriptors then
|
|
32
32
|
local descriptor = descriptors[key]
|
|
33
|
-
if descriptor then
|
|
33
|
+
if descriptor ~= nil then
|
|
34
34
|
if descriptor.set then
|
|
35
35
|
descriptor.set(self, value)
|
|
36
36
|
else
|
|
@@ -18,12 +18,12 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
18
18
|
end
|
|
19
19
|
local function replacer(____, file, srcFile, line)
|
|
20
20
|
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
21
|
-
if fileSourceMap and fileSourceMap[line] then
|
|
21
|
+
if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then
|
|
22
22
|
local data = fileSourceMap[line]
|
|
23
23
|
if type(data) == "number" then
|
|
24
24
|
return (srcFile .. ":") .. tostring(data)
|
|
25
25
|
end
|
|
26
|
-
return (
|
|
26
|
+
return (data.file .. ":") .. tostring(data.line)
|
|
27
27
|
end
|
|
28
28
|
return (file .. ":") .. line
|
|
29
29
|
end
|
|
@@ -34,14 +34,14 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
34
34
|
)
|
|
35
35
|
local function stringReplacer(____, file, line)
|
|
36
36
|
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
37
|
-
if fileSourceMap and fileSourceMap[line] then
|
|
37
|
+
if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then
|
|
38
38
|
local chunkName = __TS__Match(file, "%[string \"([^\"]+)\"%]")
|
|
39
39
|
local sourceName = string.gsub(chunkName, ".lua$", ".ts")
|
|
40
40
|
local data = fileSourceMap[line]
|
|
41
41
|
if type(data) == "number" then
|
|
42
42
|
return (sourceName .. ":") .. tostring(data)
|
|
43
43
|
end
|
|
44
|
-
return (
|
|
44
|
+
return (data.file .. ":") .. tostring(data.line)
|
|
45
45
|
end
|
|
46
46
|
return (file .. ":") .. line
|
|
47
47
|
end
|
|
@@ -7,13 +7,7 @@ do
|
|
|
7
7
|
return source
|
|
8
8
|
end
|
|
9
9
|
local before = sub(source, 1, startPos - 1)
|
|
10
|
-
local
|
|
11
|
-
if type(replaceValue) == "string" then
|
|
12
|
-
____temp_0 = replaceValue
|
|
13
|
-
else
|
|
14
|
-
____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
|
|
15
|
-
end
|
|
16
|
-
local replacement = ____temp_0
|
|
10
|
+
local replacement = type(replaceValue) == "string" and replaceValue or replaceValue(nil, searchValue, startPos - 1, source)
|
|
17
11
|
local after = sub(source, endPos + 1)
|
|
18
12
|
return (before .. replacement) .. after
|
|
19
13
|
end
|