typescript-to-lua 1.3.2 → 1.4.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 +1 -1
- package/dist/CompilerOptions.js +0 -1
- package/dist/LuaLib.d.ts +12 -1
- package/dist/LuaLib.js +61 -65
- package/dist/LuaPrinter.js +9 -8
- package/dist/cli/parse.js +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/lualib/ArrayConcat.lua +1 -1
- package/dist/lualib/ArrayEntries.lua +1 -1
- package/dist/lualib/ArrayEvery.lua +2 -2
- package/dist/lualib/ArrayFilter.lua +2 -2
- package/dist/lualib/ArrayFind.lua +2 -2
- package/dist/lualib/ArrayFindIndex.lua +2 -2
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +2 -2
- package/dist/lualib/ArrayForEach.lua +2 -2
- package/dist/lualib/ArrayIncludes.lua +1 -1
- package/dist/lualib/ArrayIndexOf.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayJoin.lua +1 -1
- package/dist/lualib/ArrayMap.lua +2 -2
- package/dist/lualib/ArrayPush.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +2 -2
- package/dist/lualib/ArrayReduceRight.lua +2 -2
- package/dist/lualib/ArrayReverse.lua +1 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArrayShift.lua +1 -1
- package/dist/lualib/ArraySlice.lua +1 -1
- package/dist/lualib/ArraySome.lua +2 -2
- package/dist/lualib/ArraySort.lua +2 -2
- package/dist/lualib/ArraySplice.lua +1 -1
- package/dist/lualib/ArrayToObject.lua +1 -1
- package/dist/lualib/ArrayUnshift.lua +1 -1
- package/dist/lualib/Await.lua +13 -13
- package/dist/lualib/Class.lua +1 -1
- package/dist/lualib/ClassExtends.lua +1 -1
- package/dist/lualib/CloneDescriptor.lua +1 -1
- package/dist/lualib/Decorate.lua +5 -5
- package/dist/lualib/DecorateParam.lua +2 -2
- package/dist/lualib/DelegatedYield.lua +1 -1
- package/dist/lualib/Delete.lua +1 -1
- package/dist/lualib/Error.lua +68 -69
- package/dist/lualib/FunctionBind.lua +1 -1
- package/dist/lualib/Generator.lua +26 -23
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Iterator.lua +35 -32
- package/dist/lualib/Map.lua +131 -129
- package/dist/lualib/MathAtan2.lua +1 -1
- package/dist/lualib/MathSign.lua +1 -1
- package/dist/lualib/New.lua +1 -1
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberIsNaN.lua +1 -1
- package/dist/lualib/NumberToString.lua +42 -39
- package/dist/lualib/ObjectAssign.lua +1 -1
- package/dist/lualib/ObjectDefineProperty.lua +1 -1
- package/dist/lualib/ObjectEntries.lua +1 -1
- package/dist/lualib/ObjectFromEntries.lua +1 -1
- package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +1 -1
- package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +1 -1
- package/dist/lualib/ObjectKeys.lua +1 -1
- package/dist/lualib/ObjectRest.lua +1 -1
- package/dist/lualib/ObjectValues.lua +1 -1
- package/dist/lualib/ParseFloat.lua +1 -1
- package/dist/lualib/ParseInt.lua +39 -36
- package/dist/lualib/Promise.lua +148 -152
- package/dist/lualib/PromiseAll.lua +5 -5
- package/dist/lualib/PromiseAllSettled.lua +5 -5
- package/dist/lualib/PromiseAny.lua +5 -5
- package/dist/lualib/PromiseRace.lua +5 -5
- package/dist/lualib/Set.lua +120 -118
- package/dist/lualib/SetDescriptor.lua +67 -64
- package/dist/lualib/SourceMapTraceBack.lua +7 -6
- package/dist/lualib/SparseArrayNew.lua +1 -1
- package/dist/lualib/SparseArrayPush.lua +1 -1
- package/dist/lualib/SparseArraySpread.lua +1 -1
- package/dist/lualib/Spread.lua +1 -1
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharAt.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringConcat.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +1 -1
- package/dist/lualib/StringIncludes.lua +1 -1
- package/dist/lualib/StringPadEnd.lua +1 -1
- package/dist/lualib/StringPadStart.lua +1 -1
- package/dist/lualib/StringReplace.lua +2 -2
- package/dist/lualib/StringReplaceAll.lua +4 -4
- package/dist/lualib/StringSlice.lua +1 -1
- package/dist/lualib/StringSplit.lua +1 -1
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +1 -1
- package/dist/lualib/StringTrim.lua +1 -1
- package/dist/lualib/StringTrimEnd.lua +1 -1
- package/dist/lualib/StringTrimStart.lua +1 -1
- package/dist/lualib/Symbol.lua +14 -11
- package/dist/lualib/SymbolRegistry.lua +13 -10
- package/dist/lualib/TypeOf.lua +1 -1
- package/dist/lualib/Unpack.lua +1 -1
- package/dist/lualib/WeakMap.lua +41 -39
- package/dist/lualib/WeakSet.lua +37 -35
- package/dist/lualib/lualib_bundle.lua +1054 -924
- package/dist/lualib/lualib_module_info.json +619 -0
- package/dist/lualib-build/plugin.d.ts +23 -0
- package/dist/lualib-build/plugin.js +138 -0
- package/dist/lualib-build/util.d.ts +19 -0
- package/dist/lualib-build/util.js +43 -0
- package/dist/transformation/builtins/function.js +2 -1
- package/dist/transformation/builtins/index.d.ts +1 -0
- package/dist/transformation/builtins/index.js +63 -16
- package/dist/transformation/context/index.js +5 -1
- package/dist/transformation/utils/diagnostics.d.ts +3 -0
- package/dist/transformation/utils/diagnostics.js +2 -1
- package/dist/transformation/utils/typescript/index.js +5 -1
- package/dist/transformation/utils/typescript/types.d.ts +2 -0
- package/dist/transformation/utils/typescript/types.js +10 -1
- package/dist/transformation/visitors/class/index.js +1 -5
- package/dist/transformation/visitors/class/members/constructor.js +1 -3
- package/dist/transformation/visitors/class/members/fields.js +12 -8
- package/dist/transformation/visitors/class/new.d.ts +1 -2
- package/dist/transformation/visitors/class/new.js +1 -40
- package/dist/transformation/visitors/conditional.js +15 -14
- package/dist/transformation/visitors/identifier.js +5 -0
- package/dist/transformation/visitors/literal.js +22 -0
- package/dist/transformation/visitors/modules/import.js +4 -14
- package/dist/transpilation/bundle.js +1 -1
- package/dist/transpilation/index.js +5 -1
- package/dist/transpilation/plugins.d.ts +11 -0
- package/dist/transpilation/resolve.js +2 -2
- package/dist/transpilation/transpile.js +13 -0
- package/dist/transpilation/transpiler.js +6 -2
- package/package.json +12 -11
- package/CHANGELOG.md +0 -703
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
function __TS__PromiseAny(iterable)
|
|
1
|
+
local function __TS__PromiseAny(iterable)
|
|
2
2
|
local rejections = {}
|
|
3
3
|
local pending = {}
|
|
4
4
|
for ____, item in __TS__Iterator(iterable) do
|
|
5
5
|
if __TS__InstanceOf(item, __TS__Promise) then
|
|
6
|
-
if item.state ==
|
|
6
|
+
if item.state == 1 then
|
|
7
7
|
return __TS__Promise.resolve(item.value)
|
|
8
|
-
elseif item.state ==
|
|
8
|
+
elseif item.state == 2 then
|
|
9
9
|
__TS__ArrayPush(rejections, item.rejectionReason)
|
|
10
10
|
else
|
|
11
11
|
__TS__ArrayPush(pending, item)
|
|
@@ -25,13 +25,13 @@ function __TS__PromiseAny(iterable)
|
|
|
25
25
|
promise["then"](
|
|
26
26
|
promise,
|
|
27
27
|
function(____, data)
|
|
28
|
-
resolve(
|
|
28
|
+
resolve(nil, data)
|
|
29
29
|
end,
|
|
30
30
|
function(____, reason)
|
|
31
31
|
__TS__ArrayPush(rejections, reason)
|
|
32
32
|
numResolved = numResolved + 1
|
|
33
33
|
if numResolved == #pending then
|
|
34
|
-
reject(
|
|
34
|
+
reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function __TS__PromiseRace(iterable)
|
|
1
|
+
local function __TS__PromiseRace(iterable)
|
|
2
2
|
local pending = {}
|
|
3
3
|
for ____, item in __TS__Iterator(iterable) do
|
|
4
4
|
if __TS__InstanceOf(item, __TS__Promise) then
|
|
5
|
-
if item.state ==
|
|
5
|
+
if item.state == 1 then
|
|
6
6
|
return __TS__Promise.resolve(item.value)
|
|
7
|
-
elseif item.state ==
|
|
7
|
+
elseif item.state == 2 then
|
|
8
8
|
return __TS__Promise.reject(item.rejectionReason)
|
|
9
9
|
else
|
|
10
10
|
__TS__ArrayPush(pending, item)
|
|
@@ -19,8 +19,8 @@ function __TS__PromiseRace(iterable)
|
|
|
19
19
|
for ____, promise in ipairs(pending) do
|
|
20
20
|
promise["then"](
|
|
21
21
|
promise,
|
|
22
|
-
function(____, value) return resolve(
|
|
23
|
-
function(____, reason) return reject(
|
|
22
|
+
function(____, value) return resolve(nil, value) end,
|
|
23
|
+
function(____, reason) return reject(nil, reason) end
|
|
24
24
|
)
|
|
25
25
|
end
|
|
26
26
|
end
|
package/dist/lualib/Set.lua
CHANGED
|
@@ -1,128 +1,130 @@
|
|
|
1
|
-
Set
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
self
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
local
|
|
14
|
-
|
|
15
|
-
local
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
local Set
|
|
2
|
+
do
|
|
3
|
+
Set = __TS__Class()
|
|
4
|
+
Set.name = "Set"
|
|
5
|
+
function Set.prototype.____constructor(self, values)
|
|
6
|
+
self[Symbol.toStringTag] = "Set"
|
|
7
|
+
self.size = 0
|
|
8
|
+
self.nextKey = {}
|
|
9
|
+
self.previousKey = {}
|
|
10
|
+
if values == nil then
|
|
11
|
+
return
|
|
12
|
+
end
|
|
13
|
+
local iterable = values
|
|
14
|
+
if iterable[Symbol.iterator] then
|
|
15
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
16
|
+
while true do
|
|
17
|
+
local result = iterator:next()
|
|
18
|
+
if result.done then
|
|
19
|
+
break
|
|
20
|
+
end
|
|
21
|
+
self:add(result.value)
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
local array = values
|
|
25
|
+
for ____, value in ipairs(array) do
|
|
26
|
+
self:add(value)
|
|
18
27
|
end
|
|
19
|
-
self:add(result.value)
|
|
20
28
|
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
end
|
|
30
|
+
function Set.prototype.add(self, value)
|
|
31
|
+
local isNewValue = not self:has(value)
|
|
32
|
+
if isNewValue then
|
|
33
|
+
self.size = self.size + 1
|
|
34
|
+
end
|
|
35
|
+
if self.firstKey == nil then
|
|
36
|
+
self.firstKey = value
|
|
37
|
+
self.lastKey = value
|
|
38
|
+
elseif isNewValue then
|
|
39
|
+
self.nextKey[self.lastKey] = value
|
|
40
|
+
self.previousKey[value] = self.lastKey
|
|
41
|
+
self.lastKey = value
|
|
25
42
|
end
|
|
43
|
+
return self
|
|
26
44
|
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
self.
|
|
45
|
+
function Set.prototype.clear(self)
|
|
46
|
+
self.nextKey = {}
|
|
47
|
+
self.previousKey = {}
|
|
48
|
+
self.firstKey = nil
|
|
49
|
+
self.lastKey = nil
|
|
50
|
+
self.size = 0
|
|
32
51
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
function Set.prototype.delete(self, value)
|
|
53
|
+
local contains = self:has(value)
|
|
54
|
+
if contains then
|
|
55
|
+
self.size = self.size - 1
|
|
56
|
+
local next = self.nextKey[value]
|
|
57
|
+
local previous = self.previousKey[value]
|
|
58
|
+
if next and previous then
|
|
59
|
+
self.nextKey[previous] = next
|
|
60
|
+
self.previousKey[next] = previous
|
|
61
|
+
elseif next then
|
|
62
|
+
self.firstKey = next
|
|
63
|
+
self.previousKey[next] = nil
|
|
64
|
+
elseif previous then
|
|
65
|
+
self.lastKey = previous
|
|
66
|
+
self.nextKey[previous] = nil
|
|
67
|
+
else
|
|
68
|
+
self.firstKey = nil
|
|
69
|
+
self.lastKey = nil
|
|
70
|
+
end
|
|
71
|
+
self.nextKey[value] = nil
|
|
72
|
+
self.previousKey[value] = nil
|
|
73
|
+
end
|
|
74
|
+
return contains
|
|
40
75
|
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
self.nextKey = {}
|
|
45
|
-
self.previousKey = {}
|
|
46
|
-
self.firstKey = nil
|
|
47
|
-
self.lastKey = nil
|
|
48
|
-
self.size = 0
|
|
49
|
-
end
|
|
50
|
-
function Set.prototype.delete(self, value)
|
|
51
|
-
local contains = self:has(value)
|
|
52
|
-
if contains then
|
|
53
|
-
self.size = self.size - 1
|
|
54
|
-
local next = self.nextKey[value]
|
|
55
|
-
local previous = self.previousKey[value]
|
|
56
|
-
if next and previous then
|
|
57
|
-
self.nextKey[previous] = next
|
|
58
|
-
self.previousKey[next] = previous
|
|
59
|
-
elseif next then
|
|
60
|
-
self.firstKey = next
|
|
61
|
-
self.previousKey[next] = nil
|
|
62
|
-
elseif previous then
|
|
63
|
-
self.lastKey = previous
|
|
64
|
-
self.nextKey[previous] = nil
|
|
65
|
-
else
|
|
66
|
-
self.firstKey = nil
|
|
67
|
-
self.lastKey = nil
|
|
76
|
+
function Set.prototype.forEach(self, callback)
|
|
77
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
78
|
+
callback(nil, key, key, self)
|
|
68
79
|
end
|
|
69
|
-
self.nextKey[value] = nil
|
|
70
|
-
self.previousKey[value] = nil
|
|
71
80
|
end
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
function Set.prototype.forEach(self, callback)
|
|
75
|
-
for ____, key in __TS__Iterator(self:keys()) do
|
|
76
|
-
callback(_G, key, key, self)
|
|
81
|
+
function Set.prototype.has(self, value)
|
|
82
|
+
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
77
83
|
end
|
|
84
|
+
Set.prototype[Symbol.iterator] = function(self)
|
|
85
|
+
return self:values()
|
|
86
|
+
end
|
|
87
|
+
function Set.prototype.entries(self)
|
|
88
|
+
local nextKey = self.nextKey
|
|
89
|
+
local key = self.firstKey
|
|
90
|
+
return {
|
|
91
|
+
[Symbol.iterator] = function(self)
|
|
92
|
+
return self
|
|
93
|
+
end,
|
|
94
|
+
next = function(self)
|
|
95
|
+
local result = {done = not key, value = {key, key}}
|
|
96
|
+
key = nextKey[key]
|
|
97
|
+
return result
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
function Set.prototype.keys(self)
|
|
102
|
+
local nextKey = self.nextKey
|
|
103
|
+
local key = self.firstKey
|
|
104
|
+
return {
|
|
105
|
+
[Symbol.iterator] = function(self)
|
|
106
|
+
return self
|
|
107
|
+
end,
|
|
108
|
+
next = function(self)
|
|
109
|
+
local result = {done = not key, value = key}
|
|
110
|
+
key = nextKey[key]
|
|
111
|
+
return result
|
|
112
|
+
end
|
|
113
|
+
}
|
|
114
|
+
end
|
|
115
|
+
function Set.prototype.values(self)
|
|
116
|
+
local nextKey = self.nextKey
|
|
117
|
+
local key = self.firstKey
|
|
118
|
+
return {
|
|
119
|
+
[Symbol.iterator] = function(self)
|
|
120
|
+
return self
|
|
121
|
+
end,
|
|
122
|
+
next = function(self)
|
|
123
|
+
local result = {done = not key, value = key}
|
|
124
|
+
key = nextKey[key]
|
|
125
|
+
return result
|
|
126
|
+
end
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
Set[Symbol.species] = Set
|
|
78
130
|
end
|
|
79
|
-
function Set.prototype.has(self, value)
|
|
80
|
-
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
81
|
-
end
|
|
82
|
-
Set.prototype[Symbol.iterator] = function(self)
|
|
83
|
-
return self:values()
|
|
84
|
-
end
|
|
85
|
-
function Set.prototype.entries(self)
|
|
86
|
-
local nextKey = self.nextKey
|
|
87
|
-
local key = self.firstKey
|
|
88
|
-
return {
|
|
89
|
-
[Symbol.iterator] = function(self)
|
|
90
|
-
return self
|
|
91
|
-
end,
|
|
92
|
-
next = function(self)
|
|
93
|
-
local result = {done = not key, value = {key, key}}
|
|
94
|
-
key = nextKey[key]
|
|
95
|
-
return result
|
|
96
|
-
end
|
|
97
|
-
}
|
|
98
|
-
end
|
|
99
|
-
function Set.prototype.keys(self)
|
|
100
|
-
local nextKey = self.nextKey
|
|
101
|
-
local key = self.firstKey
|
|
102
|
-
return {
|
|
103
|
-
[Symbol.iterator] = function(self)
|
|
104
|
-
return self
|
|
105
|
-
end,
|
|
106
|
-
next = function(self)
|
|
107
|
-
local result = {done = not key, value = key}
|
|
108
|
-
key = nextKey[key]
|
|
109
|
-
return result
|
|
110
|
-
end
|
|
111
|
-
}
|
|
112
|
-
end
|
|
113
|
-
function Set.prototype.values(self)
|
|
114
|
-
local nextKey = self.nextKey
|
|
115
|
-
local key = self.firstKey
|
|
116
|
-
return {
|
|
117
|
-
[Symbol.iterator] = function(self)
|
|
118
|
-
return self
|
|
119
|
-
end,
|
|
120
|
-
next = function(self)
|
|
121
|
-
local result = {done = not key, value = key}
|
|
122
|
-
key = nextKey[key]
|
|
123
|
-
return result
|
|
124
|
-
end
|
|
125
|
-
}
|
|
126
|
-
end
|
|
127
|
-
Set[Symbol.species] = Set
|
|
128
|
-
Set = Set
|
|
@@ -1,76 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
while metatable do
|
|
8
|
-
local rawResult = rawget(metatable, key)
|
|
9
|
-
if rawResult ~= nil then
|
|
10
|
-
return rawResult
|
|
1
|
+
local __TS__SetDescriptor
|
|
2
|
+
do
|
|
3
|
+
local function descriptorIndex(self, key)
|
|
4
|
+
local value = rawget(self, key)
|
|
5
|
+
if value ~= nil then
|
|
6
|
+
return value
|
|
11
7
|
end
|
|
12
|
-
local
|
|
13
|
-
|
|
14
|
-
local
|
|
15
|
-
if
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
local metatable = getmetatable(self)
|
|
9
|
+
while metatable do
|
|
10
|
+
local rawResult = rawget(metatable, key)
|
|
11
|
+
if rawResult ~= nil then
|
|
12
|
+
return rawResult
|
|
13
|
+
end
|
|
14
|
+
local descriptors = rawget(metatable, "_descriptors")
|
|
15
|
+
if descriptors then
|
|
16
|
+
local descriptor = descriptors[key]
|
|
17
|
+
if descriptor then
|
|
18
|
+
if descriptor.get then
|
|
19
|
+
return descriptor.get(self)
|
|
20
|
+
end
|
|
21
|
+
return descriptor.value
|
|
18
22
|
end
|
|
19
|
-
return descriptor.value
|
|
20
23
|
end
|
|
24
|
+
metatable = getmetatable(metatable)
|
|
21
25
|
end
|
|
22
|
-
metatable = getmetatable(metatable)
|
|
23
26
|
end
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
local function descriptorNewIndex(self, key, value)
|
|
28
|
+
local metatable = getmetatable(self)
|
|
29
|
+
while metatable do
|
|
30
|
+
local descriptors = rawget(metatable, "_descriptors")
|
|
31
|
+
if descriptors then
|
|
32
|
+
local descriptor = descriptors[key]
|
|
33
|
+
if descriptor then
|
|
34
|
+
if descriptor.set then
|
|
35
|
+
descriptor.set(self, value)
|
|
36
|
+
else
|
|
37
|
+
if descriptor.writable == false then
|
|
38
|
+
error(
|
|
39
|
+
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
40
|
+
0
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
descriptor.value = value
|
|
40
44
|
end
|
|
41
|
-
|
|
45
|
+
return
|
|
42
46
|
end
|
|
43
|
-
return
|
|
44
47
|
end
|
|
48
|
+
metatable = getmetatable(metatable)
|
|
45
49
|
end
|
|
46
|
-
|
|
47
|
-
end
|
|
48
|
-
rawset(self, key, value)
|
|
49
|
-
end
|
|
50
|
-
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
51
|
-
if isPrototype == nil then
|
|
52
|
-
isPrototype = false
|
|
53
|
-
end
|
|
54
|
-
local ____isPrototype_0
|
|
55
|
-
if isPrototype then
|
|
56
|
-
____isPrototype_0 = target
|
|
57
|
-
else
|
|
58
|
-
____isPrototype_0 = getmetatable(target)
|
|
50
|
+
rawset(self, key, value)
|
|
59
51
|
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
metatable
|
|
52
|
+
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
53
|
+
if isPrototype == nil then
|
|
54
|
+
isPrototype = false
|
|
55
|
+
end
|
|
56
|
+
local ____isPrototype_0
|
|
57
|
+
if isPrototype then
|
|
58
|
+
____isPrototype_0 = target
|
|
59
|
+
else
|
|
60
|
+
____isPrototype_0 = getmetatable(target)
|
|
61
|
+
end
|
|
62
|
+
local metatable = ____isPrototype_0
|
|
63
|
+
if not metatable then
|
|
64
|
+
metatable = {}
|
|
65
|
+
setmetatable(target, metatable)
|
|
66
|
+
end
|
|
67
|
+
local value = rawget(target, key)
|
|
68
|
+
if value ~= nil then
|
|
69
|
+
rawset(target, key, nil)
|
|
70
|
+
end
|
|
71
|
+
if not rawget(metatable, "_descriptors") then
|
|
72
|
+
metatable._descriptors = {}
|
|
73
|
+
end
|
|
74
|
+
local descriptor = __TS__CloneDescriptor(desc)
|
|
75
|
+
metatable._descriptors[key] = descriptor
|
|
76
|
+
metatable.__index = descriptorIndex
|
|
77
|
+
metatable.__newindex = descriptorNewIndex
|
|
71
78
|
end
|
|
72
|
-
local descriptor = __TS__CloneDescriptor(desc)
|
|
73
|
-
metatable._descriptors[key] = descriptor
|
|
74
|
-
metatable.__index = ____descriptorIndex
|
|
75
|
-
metatable.__newindex = ____descriptorNewindex
|
|
76
79
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
1
|
+
local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
2
2
|
_G.__TS__sourcemap = _G.__TS__sourcemap or ({})
|
|
3
3
|
_G.__TS__sourcemap[fileName] = sourceMap
|
|
4
4
|
if _G.__TS__originalTraceback == nil then
|
|
5
|
-
|
|
5
|
+
local originalTraceback = debug.traceback
|
|
6
|
+
_G.__TS__originalTraceback = originalTraceback
|
|
6
7
|
debug.traceback = function(thread, message, level)
|
|
7
8
|
local trace
|
|
8
9
|
if thread == nil and message == nil and level == nil then
|
|
9
|
-
trace =
|
|
10
|
+
trace = originalTraceback()
|
|
10
11
|
else
|
|
11
|
-
trace =
|
|
12
|
+
trace = originalTraceback(thread, message, level)
|
|
12
13
|
end
|
|
13
14
|
if type(trace) ~= "string" then
|
|
14
15
|
return trace
|
|
@@ -27,12 +28,12 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
27
28
|
local result = string.gsub(
|
|
28
29
|
trace,
|
|
29
30
|
"(%S+)%.lua:(%d+)",
|
|
30
|
-
function(file, line) return replacer(
|
|
31
|
+
function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
|
|
31
32
|
)
|
|
32
33
|
result = string.gsub(
|
|
33
34
|
result,
|
|
34
35
|
"(%[string \"[^\"]+\"%]):(%d+)",
|
|
35
|
-
function(file, line) return replacer(
|
|
36
|
+
function(file, line) return replacer(nil, file, "unknown", line) end
|
|
36
37
|
)
|
|
37
38
|
return result
|
|
38
39
|
end
|
package/dist/lualib/Spread.lua
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function __TS__StringReplace(source, searchValue, replaceValue)
|
|
1
|
+
local function __TS__StringReplace(source, searchValue, replaceValue)
|
|
2
2
|
local startPos, endPos = string.find(source, searchValue, nil, true)
|
|
3
3
|
if not startPos then
|
|
4
4
|
return source
|
|
@@ -9,7 +9,7 @@ function __TS__StringReplace(source, searchValue, replaceValue)
|
|
|
9
9
|
if type(replaceValue) == "string" then
|
|
10
10
|
____temp_0 = replaceValue
|
|
11
11
|
else
|
|
12
|
-
____temp_0 = replaceValue(
|
|
12
|
+
____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
|
|
13
13
|
end
|
|
14
14
|
local replacement = ____temp_0
|
|
15
15
|
local after = sub(source, endPos + 1)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
1
|
+
local function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
2
2
|
local replacer
|
|
3
3
|
if type(replaceValue) == "string" then
|
|
4
4
|
replacer = function() return replaceValue end
|
|
@@ -9,11 +9,11 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
|
9
9
|
local partsIndex = 1
|
|
10
10
|
local sub = string.sub
|
|
11
11
|
if #searchValue == 0 then
|
|
12
|
-
parts[1] = replacer(
|
|
12
|
+
parts[1] = replacer(nil, "", 0, source)
|
|
13
13
|
partsIndex = 2
|
|
14
14
|
for i = 1, #source do
|
|
15
15
|
parts[partsIndex] = sub(source, i, i)
|
|
16
|
-
parts[partsIndex + 1] = replacer(
|
|
16
|
+
parts[partsIndex + 1] = replacer(nil, "", i, source)
|
|
17
17
|
partsIndex = partsIndex + 2
|
|
18
18
|
end
|
|
19
19
|
else
|
|
@@ -25,7 +25,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
|
25
25
|
break
|
|
26
26
|
end
|
|
27
27
|
parts[partsIndex] = sub(source, currentPos, startPos - 1)
|
|
28
|
-
parts[partsIndex + 1] = replacer(
|
|
28
|
+
parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
|
|
29
29
|
partsIndex = partsIndex + 2
|
|
30
30
|
currentPos = endPos + 1
|
|
31
31
|
end
|