typescript-to-lua 1.4.2 → 1.5.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/dist/CompilerOptions.d.ts +5 -1
- package/dist/LuaAST.d.ts +9 -7
- package/dist/LuaAST.js +19 -13
- package/dist/LuaLib.d.ts +1 -2
- package/dist/LuaLib.js +1 -2
- package/dist/LuaPrinter.js +1 -2
- package/dist/cli/parse.js +10 -0
- 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 +2 -5
- 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/Await.lua +21 -34
- 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/SourceMapTraceBack.lua +14 -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 +393 -423
- package/dist/lualib/lualib_module_info.json +13 -23
- package/dist/transformation/builtins/array.d.ts +2 -3
- package/dist/transformation/builtins/array.js +43 -12
- package/dist/transformation/builtins/console.d.ts +2 -2
- package/dist/transformation/builtins/console.js +8 -9
- package/dist/transformation/builtins/function.d.ts +1 -2
- package/dist/transformation/builtins/function.js +5 -6
- package/dist/transformation/builtins/index.js +22 -23
- package/dist/transformation/builtins/math.d.ts +1 -2
- package/dist/transformation/builtins/math.js +3 -4
- package/dist/transformation/builtins/number.d.ts +3 -3
- package/dist/transformation/builtins/number.js +10 -12
- package/dist/transformation/builtins/object.d.ts +2 -3
- package/dist/transformation/builtins/object.js +16 -17
- package/dist/transformation/builtins/promise.d.ts +2 -2
- package/dist/transformation/builtins/promise.js +7 -7
- package/dist/transformation/builtins/string.d.ts +2 -3
- package/dist/transformation/builtins/string.js +8 -10
- package/dist/transformation/builtins/symbol.d.ts +2 -2
- package/dist/transformation/builtins/symbol.js +6 -7
- 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 +89 -3
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +9 -1
- package/dist/transformation/visitors/async-await.d.ts +1 -1
- package/dist/transformation/visitors/async-await.js +7 -14
- package/dist/transformation/visitors/call.d.ts +1 -3
- package/dist/transformation/visitors/call.js +26 -13
- 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 +52 -9
- package/dist/transformation/visitors/function.js +5 -5
- package/dist/transformation/visitors/modules/import.d.ts +1 -0
- package/dist/transformation/visitors/modules/import.js +9 -1
- package/dist/transformation/visitors/return.js +5 -4
- package/dist/transformation/visitors/spread.js +1 -7
- package/package.json +1 -1
- package/dist/lualib/ArrayShift.lua +0 -3
- package/dist/lualib/StringConcat.lua +0 -8
|
@@ -1,35 +1,42 @@
|
|
|
1
|
-
local
|
|
2
|
-
|
|
3
|
-
if type(replaceValue) == "string" then
|
|
4
|
-
replacer = function() return replaceValue end
|
|
5
|
-
else
|
|
6
|
-
replacer = replaceValue
|
|
7
|
-
end
|
|
8
|
-
local parts = {}
|
|
9
|
-
local partsIndex = 1
|
|
1
|
+
local __TS__StringReplaceAll
|
|
2
|
+
do
|
|
10
3
|
local sub = string.sub
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
local find = string.find
|
|
5
|
+
function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
6
|
+
if type(replaceValue) == "string" then
|
|
7
|
+
local concat = table.concat(
|
|
8
|
+
__TS__StringSplit(source, searchValue),
|
|
9
|
+
replaceValue
|
|
10
|
+
)
|
|
11
|
+
if #searchValue == 0 then
|
|
12
|
+
return (replaceValue .. concat) .. replaceValue
|
|
13
|
+
end
|
|
14
|
+
return concat
|
|
18
15
|
end
|
|
19
|
-
|
|
20
|
-
local
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
local parts = {}
|
|
17
|
+
local partsIndex = 1
|
|
18
|
+
if #searchValue == 0 then
|
|
19
|
+
parts[1] = replaceValue(nil, "", 0, source)
|
|
20
|
+
partsIndex = 2
|
|
21
|
+
for i = 1, #source do
|
|
22
|
+
parts[partsIndex] = sub(source, i, i)
|
|
23
|
+
parts[partsIndex + 1] = replaceValue(nil, "", i, source)
|
|
24
|
+
partsIndex = partsIndex + 2
|
|
25
|
+
end
|
|
26
|
+
else
|
|
27
|
+
local currentPos = 1
|
|
28
|
+
while true do
|
|
29
|
+
local startPos, endPos = find(source, searchValue, currentPos, true)
|
|
30
|
+
if not startPos then
|
|
31
|
+
break
|
|
32
|
+
end
|
|
33
|
+
parts[partsIndex] = sub(source, currentPos, startPos - 1)
|
|
34
|
+
parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source)
|
|
35
|
+
partsIndex = partsIndex + 2
|
|
36
|
+
currentPos = endPos + 1
|
|
26
37
|
end
|
|
27
|
-
parts[partsIndex] = sub(source, currentPos
|
|
28
|
-
parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
|
|
29
|
-
partsIndex = partsIndex + 2
|
|
30
|
-
currentPos = endPos + 1
|
|
38
|
+
parts[partsIndex] = sub(source, currentPos)
|
|
31
39
|
end
|
|
32
|
-
|
|
40
|
+
return table.concat(parts)
|
|
33
41
|
end
|
|
34
|
-
return table.concat(parts)
|
|
35
42
|
end
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
local
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
local out = {}
|
|
9
|
-
local index = 0
|
|
10
|
-
local count = 0
|
|
11
|
-
if separator == nil or separator == "" then
|
|
12
|
-
while index < #source - 1 and count < limit do
|
|
13
|
-
out[count + 1] = __TS__StringAccess(source, index)
|
|
14
|
-
count = count + 1
|
|
15
|
-
index = index + 1
|
|
1
|
+
local __TS__StringSplit
|
|
2
|
+
do
|
|
3
|
+
local sub = string.sub
|
|
4
|
+
local find = string.find
|
|
5
|
+
function __TS__StringSplit(source, separator, limit)
|
|
6
|
+
if limit == nil then
|
|
7
|
+
limit = 4294967295
|
|
16
8
|
end
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
|
|
20
|
-
while nextIndex >= 0 and count < limit do
|
|
21
|
-
out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
|
|
22
|
-
count = count + 1
|
|
23
|
-
index = nextIndex + separatorLength
|
|
24
|
-
nextIndex = (string.find(
|
|
25
|
-
source,
|
|
26
|
-
separator,
|
|
27
|
-
math.max(index + 1, 1),
|
|
28
|
-
true
|
|
29
|
-
) or 0) - 1
|
|
9
|
+
if limit == 0 then
|
|
10
|
+
return {}
|
|
30
11
|
end
|
|
12
|
+
local result = {}
|
|
13
|
+
local resultIndex = 1
|
|
14
|
+
if separator == nil or separator == "" then
|
|
15
|
+
for i = 1, #source do
|
|
16
|
+
result[resultIndex] = sub(source, i, i)
|
|
17
|
+
resultIndex = resultIndex + 1
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
local currentPos = 1
|
|
21
|
+
while resultIndex <= limit do
|
|
22
|
+
local startPos, endPos = find(source, separator, currentPos, true)
|
|
23
|
+
if not startPos then
|
|
24
|
+
break
|
|
25
|
+
end
|
|
26
|
+
result[resultIndex] = sub(source, currentPos, startPos - 1)
|
|
27
|
+
resultIndex = resultIndex + 1
|
|
28
|
+
currentPos = endPos + 1
|
|
29
|
+
end
|
|
30
|
+
if resultIndex <= limit then
|
|
31
|
+
result[resultIndex] = sub(source, currentPos)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
return result
|
|
31
35
|
end
|
|
32
|
-
if count < limit then
|
|
33
|
-
out[count + 1] = __TS__StringSubstring(source, index)
|
|
34
|
-
end
|
|
35
|
-
return out
|
|
36
36
|
end
|