typescript-to-lua 1.8.2 → 1.10.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.
Files changed (246) hide show
  1. package/dist/CompilerOptions.d.ts +1 -0
  2. package/dist/CompilerOptions.js +1 -0
  3. package/dist/LuaAST.d.ts +43 -37
  4. package/dist/LuaAST.js +48 -38
  5. package/dist/LuaLib.d.ts +12 -6
  6. package/dist/LuaLib.js +31 -21
  7. package/dist/LuaPrinter.d.ts +1 -0
  8. package/dist/LuaPrinter.js +10 -4
  9. package/dist/lualib/5.0/ArrayConcat.lua +22 -0
  10. package/dist/lualib/{ArrayEntries.lua → 5.0/ArrayEntries.lua} +0 -0
  11. package/dist/lualib/5.0/ArrayEvery.lua +8 -0
  12. package/dist/lualib/5.0/ArrayFilter.lua +11 -0
  13. package/dist/lualib/5.0/ArrayFind.lua +9 -0
  14. package/dist/lualib/5.0/ArrayFindIndex.lua +8 -0
  15. package/dist/lualib/5.0/ArrayFlat.lua +27 -0
  16. package/dist/lualib/5.0/ArrayFlatMap.lua +17 -0
  17. package/dist/lualib/5.0/ArrayForEach.lua +5 -0
  18. package/dist/lualib/5.0/ArrayFrom.lua +29 -0
  19. package/dist/lualib/5.0/ArrayIncludes.lua +19 -0
  20. package/dist/lualib/5.0/ArrayIndexOf.lua +24 -0
  21. package/dist/lualib/{ArrayIsArray.lua → 5.0/ArrayIsArray.lua} +0 -0
  22. package/dist/lualib/5.0/ArrayJoin.lua +10 -0
  23. package/dist/lualib/5.0/ArrayMap.lua +7 -0
  24. package/dist/lualib/5.0/ArrayPush.lua +9 -0
  25. package/dist/lualib/5.0/ArrayPushArray.lua +8 -0
  26. package/dist/lualib/5.0/ArrayReduce.lua +23 -0
  27. package/dist/lualib/5.0/ArrayReduceRight.lua +23 -0
  28. package/dist/lualib/5.0/ArrayReverse.lua +12 -0
  29. package/dist/lualib/5.0/ArraySetLength.lua +12 -0
  30. package/dist/lualib/5.0/ArraySlice.lua +43 -0
  31. package/dist/lualib/5.0/ArraySome.lua +8 -0
  32. package/dist/lualib/{ArraySort.lua → 5.0/ArraySort.lua} +0 -0
  33. package/dist/lualib/5.0/ArraySplice.lua +77 -0
  34. package/dist/lualib/5.0/ArrayToObject.lua +7 -0
  35. package/dist/lualib/5.0/ArrayUnshift.lua +14 -0
  36. package/dist/lualib/{Await.lua → 5.0/Await.lua} +0 -0
  37. package/dist/lualib/{Class.lua → 5.0/Class.lua} +0 -0
  38. package/dist/lualib/{ClassExtends.lua → 5.0/ClassExtends.lua} +0 -0
  39. package/dist/lualib/{CloneDescriptor.lua → 5.0/CloneDescriptor.lua} +0 -0
  40. package/dist/lualib/5.0/CountVarargs.lua +4 -0
  41. package/dist/lualib/5.0/Decorate.lua +36 -0
  42. package/dist/lualib/{DecorateParam.lua → 5.0/DecorateParam.lua} +0 -0
  43. package/dist/lualib/5.0/DelegatedYield.lua +34 -0
  44. package/dist/lualib/{Delete.lua → 5.0/Delete.lua} +0 -0
  45. package/dist/lualib/5.0/Error.lua +85 -0
  46. package/dist/lualib/5.0/FunctionBind.lua +11 -0
  47. package/dist/lualib/5.0/Generator.lua +34 -0
  48. package/dist/lualib/{InstanceOf.lua → 5.0/InstanceOf.lua} +0 -0
  49. package/dist/lualib/{InstanceOfObject.lua → 5.0/InstanceOfObject.lua} +0 -0
  50. package/dist/lualib/5.0/Iterator.lua +40 -0
  51. package/dist/lualib/5.0/LuaIteratorSpread.lua +9 -0
  52. package/dist/lualib/{Map.lua → 5.0/Map.lua} +0 -0
  53. package/dist/lualib/5.0/Match.lua +13 -0
  54. package/dist/lualib/{MathAtan2.lua → 5.0/MathAtan2.lua} +0 -0
  55. package/dist/lualib/5.0/MathModf.lua +10 -0
  56. package/dist/lualib/{MathSign.lua → 5.0/MathSign.lua} +0 -0
  57. package/dist/lualib/5.0/Modulo50.lua +3 -0
  58. package/dist/lualib/5.0/New.lua +5 -0
  59. package/dist/lualib/5.0/Number.lua +26 -0
  60. package/dist/lualib/5.0/NumberIsFinite.lua +3 -0
  61. package/dist/lualib/{NumberIsNaN.lua → 5.0/NumberIsNaN.lua} +0 -0
  62. package/dist/lualib/5.0/NumberToString.lua +47 -0
  63. package/dist/lualib/5.0/ObjectAssign.lua +10 -0
  64. package/dist/lualib/{ObjectDefineProperty.lua → 5.0/ObjectDefineProperty.lua} +0 -0
  65. package/dist/lualib/{ObjectEntries.lua → 5.0/ObjectEntries.lua} +0 -0
  66. package/dist/lualib/{ObjectFromEntries.lua → 5.0/ObjectFromEntries.lua} +0 -0
  67. package/dist/lualib/{ObjectGetOwnPropertyDescriptor.lua → 5.0/ObjectGetOwnPropertyDescriptor.lua} +0 -0
  68. package/dist/lualib/{ObjectGetOwnPropertyDescriptors.lua → 5.0/ObjectGetOwnPropertyDescriptors.lua} +0 -0
  69. package/dist/lualib/{ObjectKeys.lua → 5.0/ObjectKeys.lua} +0 -0
  70. package/dist/lualib/{ObjectRest.lua → 5.0/ObjectRest.lua} +0 -0
  71. package/dist/lualib/{ObjectValues.lua → 5.0/ObjectValues.lua} +0 -0
  72. package/dist/lualib/5.0/ParseFloat.lua +18 -0
  73. package/dist/lualib/5.0/ParseInt.lua +49 -0
  74. package/dist/lualib/5.0/Promise.lua +176 -0
  75. package/dist/lualib/{PromiseAll.lua → 5.0/PromiseAll.lua} +0 -0
  76. package/dist/lualib/{PromiseAllSettled.lua → 5.0/PromiseAllSettled.lua} +0 -0
  77. package/dist/lualib/5.0/PromiseAny.lua +41 -0
  78. package/dist/lualib/5.0/PromiseRace.lua +28 -0
  79. package/dist/lualib/{Set.lua → 5.0/Set.lua} +0 -0
  80. package/dist/lualib/{SetDescriptor.lua → 5.0/SetDescriptor.lua} +0 -0
  81. package/dist/lualib/5.0/SourceMapTraceBack.lua +56 -0
  82. package/dist/lualib/5.0/SparseArrayNew.lua +5 -0
  83. package/dist/lualib/5.0/SparseArrayPush.lua +9 -0
  84. package/dist/lualib/5.0/SparseArraySpread.lua +3 -0
  85. package/dist/lualib/5.0/Spread.lua +15 -0
  86. package/dist/lualib/5.0/StringAccess.lua +5 -0
  87. package/dist/lualib/{StringCharAt.lua → 5.0/StringCharAt.lua} +0 -0
  88. package/dist/lualib/{StringCharCodeAt.lua → 5.0/StringCharCodeAt.lua} +0 -0
  89. package/dist/lualib/5.0/StringEndsWith.lua +10 -0
  90. package/dist/lualib/{StringIncludes.lua → 5.0/StringIncludes.lua} +0 -0
  91. package/dist/lualib/5.0/StringPadEnd.lua +26 -0
  92. package/dist/lualib/5.0/StringPadStart.lua +26 -0
  93. package/dist/lualib/{StringReplace.lua → 5.0/StringReplace.lua} +0 -0
  94. package/dist/lualib/5.0/StringReplaceAll.lua +42 -0
  95. package/dist/lualib/{StringSlice.lua → 5.0/StringSlice.lua} +0 -0
  96. package/dist/lualib/5.0/StringSplit.lua +36 -0
  97. package/dist/lualib/5.0/StringStartsWith.lua +10 -0
  98. package/dist/lualib/{StringSubstr.lua → 5.0/StringSubstr.lua} +0 -0
  99. package/dist/lualib/{StringSubstring.lua → 5.0/StringSubstring.lua} +0 -0
  100. package/dist/lualib/{StringTrim.lua → 5.0/StringTrim.lua} +0 -0
  101. package/dist/lualib/{StringTrimEnd.lua → 5.0/StringTrimEnd.lua} +0 -0
  102. package/dist/lualib/{StringTrimStart.lua → 5.0/StringTrimStart.lua} +0 -0
  103. package/dist/lualib/{Symbol.lua → 5.0/Symbol.lua} +0 -0
  104. package/dist/lualib/{SymbolRegistry.lua → 5.0/SymbolRegistry.lua} +0 -0
  105. package/dist/lualib/{TypeOf.lua → 5.0/TypeOf.lua} +0 -0
  106. package/dist/lualib/5.0/Unpack.lua +1 -0
  107. package/dist/lualib/{WeakMap.lua → 5.0/WeakMap.lua} +0 -0
  108. package/dist/lualib/{WeakSet.lua → 5.0/WeakSet.lua} +0 -0
  109. package/dist/lualib/5.0/lualib_bundle.lua +2574 -0
  110. package/dist/lualib/5.0/lualib_module_info.json +672 -0
  111. package/dist/lualib/{ArrayConcat.lua → universal/ArrayConcat.lua} +0 -0
  112. package/dist/lualib/universal/ArrayEntries.lua +13 -0
  113. package/dist/lualib/{ArrayEvery.lua → universal/ArrayEvery.lua} +0 -0
  114. package/dist/lualib/{ArrayFilter.lua → universal/ArrayFilter.lua} +0 -0
  115. package/dist/lualib/{ArrayFind.lua → universal/ArrayFind.lua} +0 -0
  116. package/dist/lualib/{ArrayFindIndex.lua → universal/ArrayFindIndex.lua} +0 -0
  117. package/dist/lualib/{ArrayFlat.lua → universal/ArrayFlat.lua} +0 -0
  118. package/dist/lualib/{ArrayFlatMap.lua → universal/ArrayFlatMap.lua} +0 -0
  119. package/dist/lualib/{ArrayForEach.lua → universal/ArrayForEach.lua} +0 -0
  120. package/dist/lualib/{ArrayFrom.lua → universal/ArrayFrom.lua} +0 -0
  121. package/dist/lualib/{ArrayIncludes.lua → universal/ArrayIncludes.lua} +0 -0
  122. package/dist/lualib/{ArrayIndexOf.lua → universal/ArrayIndexOf.lua} +0 -0
  123. package/dist/lualib/universal/ArrayIsArray.lua +3 -0
  124. package/dist/lualib/{ArrayJoin.lua → universal/ArrayJoin.lua} +0 -0
  125. package/dist/lualib/{ArrayMap.lua → universal/ArrayMap.lua} +0 -0
  126. package/dist/lualib/{ArrayPush.lua → universal/ArrayPush.lua} +0 -0
  127. package/dist/lualib/{ArrayPushArray.lua → universal/ArrayPushArray.lua} +0 -0
  128. package/dist/lualib/{ArrayReduce.lua → universal/ArrayReduce.lua} +1 -1
  129. package/dist/lualib/{ArrayReduceRight.lua → universal/ArrayReduceRight.lua} +1 -1
  130. package/dist/lualib/{ArrayReverse.lua → universal/ArrayReverse.lua} +0 -0
  131. package/dist/lualib/{ArraySetLength.lua → universal/ArraySetLength.lua} +0 -0
  132. package/dist/lualib/{ArraySlice.lua → universal/ArraySlice.lua} +0 -0
  133. package/dist/lualib/{ArraySome.lua → universal/ArraySome.lua} +0 -0
  134. package/dist/lualib/universal/ArraySort.lua +11 -0
  135. package/dist/lualib/{ArraySplice.lua → universal/ArraySplice.lua} +1 -1
  136. package/dist/lualib/{ArrayToObject.lua → universal/ArrayToObject.lua} +0 -0
  137. package/dist/lualib/{ArrayUnshift.lua → universal/ArrayUnshift.lua} +0 -0
  138. package/dist/lualib/universal/Await.lua +54 -0
  139. package/dist/lualib/universal/Class.lua +6 -0
  140. package/dist/lualib/universal/ClassExtends.lua +24 -0
  141. package/dist/lualib/universal/CloneDescriptor.lua +28 -0
  142. package/dist/lualib/universal/CountVarargs.lua +3 -0
  143. package/dist/lualib/{Decorate.lua → universal/Decorate.lua} +0 -0
  144. package/dist/lualib/universal/DecorateParam.lua +3 -0
  145. package/dist/lualib/{DelegatedYield.lua → universal/DelegatedYield.lua} +0 -0
  146. package/dist/lualib/universal/Delete.lua +19 -0
  147. package/dist/lualib/{Error.lua → universal/Error.lua} +7 -2
  148. package/dist/lualib/{FunctionBind.lua → universal/FunctionBind.lua} +0 -0
  149. package/dist/lualib/{Generator.lua → universal/Generator.lua} +2 -9
  150. package/dist/lualib/universal/InstanceOf.lua +18 -0
  151. package/dist/lualib/universal/InstanceOfObject.lua +4 -0
  152. package/dist/lualib/{Iterator.lua → universal/Iterator.lua} +0 -0
  153. package/dist/lualib/{LuaIteratorSpread.lua → universal/LuaIteratorSpread.lua} +0 -0
  154. package/dist/lualib/universal/Map.lua +140 -0
  155. package/dist/lualib/universal/Match.lua +1 -0
  156. package/dist/lualib/universal/MathAtan2.lua +1 -0
  157. package/dist/lualib/universal/MathModf.lua +1 -0
  158. package/dist/lualib/universal/MathSign.lua +8 -0
  159. package/dist/lualib/universal/Modulo50.lua +3 -0
  160. package/dist/lualib/{New.lua → universal/New.lua} +0 -0
  161. package/dist/lualib/{Number.lua → universal/Number.lua} +0 -0
  162. package/dist/lualib/{NumberIsFinite.lua → universal/NumberIsFinite.lua} +0 -0
  163. package/dist/lualib/universal/NumberIsNaN.lua +3 -0
  164. package/dist/lualib/{NumberToString.lua → universal/NumberToString.lua} +1 -1
  165. package/dist/lualib/{ObjectAssign.lua → universal/ObjectAssign.lua} +0 -0
  166. package/dist/lualib/universal/ObjectDefineProperty.lua +59 -0
  167. package/dist/lualib/universal/ObjectEntries.lua +9 -0
  168. package/dist/lualib/universal/ObjectFromEntries.lua +20 -0
  169. package/dist/lualib/universal/ObjectGetOwnPropertyDescriptor.lua +10 -0
  170. package/dist/lualib/universal/ObjectGetOwnPropertyDescriptors.lua +7 -0
  171. package/dist/lualib/universal/ObjectKeys.lua +9 -0
  172. package/dist/lualib/universal/ObjectRest.lua +9 -0
  173. package/dist/lualib/universal/ObjectValues.lua +9 -0
  174. package/dist/lualib/{ParseFloat.lua → universal/ParseFloat.lua} +2 -2
  175. package/dist/lualib/{ParseInt.lua → universal/ParseInt.lua} +7 -7
  176. package/dist/lualib/{Promise.lua → universal/Promise.lua} +0 -0
  177. package/dist/lualib/universal/PromiseAll.lua +44 -0
  178. package/dist/lualib/universal/PromiseAllSettled.lua +48 -0
  179. package/dist/lualib/{PromiseAny.lua → universal/PromiseAny.lua} +0 -0
  180. package/dist/lualib/{PromiseRace.lua → universal/PromiseRace.lua} +0 -0
  181. package/dist/lualib/universal/Set.lua +130 -0
  182. package/dist/lualib/universal/SetDescriptor.lua +79 -0
  183. package/dist/lualib/{SourceMapTraceBack.lua → universal/SourceMapTraceBack.lua} +3 -1
  184. package/dist/lualib/{SparseArrayNew.lua → universal/SparseArrayNew.lua} +1 -1
  185. package/dist/lualib/{SparseArrayPush.lua → universal/SparseArrayPush.lua} +1 -1
  186. package/dist/lualib/{SparseArraySpread.lua → universal/SparseArraySpread.lua} +0 -0
  187. package/dist/lualib/{Spread.lua → universal/Spread.lua} +0 -0
  188. package/dist/lualib/{StringAccess.lua → universal/StringAccess.lua} +0 -0
  189. package/dist/lualib/universal/StringCharAt.lua +9 -0
  190. package/dist/lualib/universal/StringCharCodeAt.lua +13 -0
  191. package/dist/lualib/{StringEndsWith.lua → universal/StringEndsWith.lua} +0 -0
  192. package/dist/lualib/universal/StringIncludes.lua +9 -0
  193. package/dist/lualib/{StringPadEnd.lua → universal/StringPadEnd.lua} +0 -0
  194. package/dist/lualib/{StringPadStart.lua → universal/StringPadStart.lua} +0 -0
  195. package/dist/lualib/universal/StringReplace.lua +20 -0
  196. package/dist/lualib/{StringReplaceAll.lua → universal/StringReplaceAll.lua} +0 -0
  197. package/dist/lualib/universal/StringSlice.lua +15 -0
  198. package/dist/lualib/{StringSplit.lua → universal/StringSplit.lua} +0 -0
  199. package/dist/lualib/{StringStartsWith.lua → universal/StringStartsWith.lua} +0 -0
  200. package/dist/lualib/universal/StringSubstr.lua +15 -0
  201. package/dist/lualib/universal/StringSubstring.lua +17 -0
  202. package/dist/lualib/universal/StringTrim.lua +4 -0
  203. package/dist/lualib/universal/StringTrimEnd.lua +4 -0
  204. package/dist/lualib/universal/StringTrimStart.lua +4 -0
  205. package/dist/lualib/universal/Symbol.lua +15 -0
  206. package/dist/lualib/universal/SymbolRegistry.lua +17 -0
  207. package/dist/lualib/universal/TypeOf.lua +10 -0
  208. package/dist/lualib/{Unpack.lua → universal/Unpack.lua} +0 -0
  209. package/dist/lualib/universal/WeakMap.lua +45 -0
  210. package/dist/lualib/universal/WeakSet.lua +41 -0
  211. package/dist/lualib/{lualib_bundle.lua → universal/lualib_bundle.lua} +53 -37
  212. package/dist/lualib/{lualib_module_info.json → universal/lualib_module_info.json} +49 -4
  213. package/dist/lualib-build/plugin.js +12 -2
  214. package/dist/transformation/builtins/array.d.ts +1 -1
  215. package/dist/transformation/builtins/array.js +12 -2
  216. package/dist/transformation/builtins/function.js +4 -2
  217. package/dist/transformation/builtins/index.js +11 -3
  218. package/dist/transformation/builtins/string.d.ts +1 -1
  219. package/dist/transformation/builtins/string.js +8 -1
  220. package/dist/transformation/utils/diagnostics.d.ts +5 -4
  221. package/dist/transformation/utils/diagnostics.js +2 -1
  222. package/dist/transformation/utils/lua-ast.js +3 -1
  223. package/dist/transformation/utils/typescript/index.js +2 -2
  224. package/dist/transformation/visitors/access.js +11 -0
  225. package/dist/transformation/visitors/binary-expression/bit.js +4 -2
  226. package/dist/transformation/visitors/binary-expression/index.js +4 -0
  227. package/dist/transformation/visitors/break-continue.js +4 -2
  228. package/dist/transformation/visitors/class/index.js +9 -4
  229. package/dist/transformation/visitors/class/members/fields.js +6 -2
  230. package/dist/transformation/visitors/class/members/method.js +4 -2
  231. package/dist/transformation/visitors/conditional.d.ts +1 -0
  232. package/dist/transformation/visitors/conditional.js +12 -1
  233. package/dist/transformation/visitors/errors.js +4 -2
  234. package/dist/transformation/visitors/function.js +2 -1
  235. package/dist/transformation/visitors/identifier.js +4 -1
  236. package/dist/transformation/visitors/language-extensions/operators.js +2 -1
  237. package/dist/transformation/visitors/literal.js +12 -4
  238. package/dist/transformation/visitors/loops/do-while.js +5 -0
  239. package/dist/transformation/visitors/modules/export.js +1 -1
  240. package/dist/transformation/visitors/spread.js +4 -1
  241. package/dist/transformation/visitors/typescript.js +1 -0
  242. package/dist/transpilation/bundle.js +15 -6
  243. package/dist/transpilation/resolve.js +3 -3
  244. package/dist/transpilation/transpiler.js +3 -1
  245. package/package.json +18 -18
  246. package/language-extensions/index.d.ts +0 -676
@@ -0,0 +1,2574 @@
1
+ local function __TS__ArrayIsArray(value)
2
+ return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
3
+ end
4
+
5
+ local function __TS__ArrayConcat(self, ...)
6
+ local items = arg
7
+ local result = {}
8
+ local len = 0
9
+ for i = 1, table.getn(self) do
10
+ len = len + 1
11
+ result[len] = self[i]
12
+ end
13
+ for i = 1, table.getn(items) do
14
+ local item = items[i]
15
+ if __TS__ArrayIsArray(item) then
16
+ for j = 1, table.getn(item) do
17
+ len = len + 1
18
+ result[len] = item[j]
19
+ end
20
+ else
21
+ len = len + 1
22
+ result[len] = item
23
+ end
24
+ end
25
+ return result
26
+ end
27
+
28
+ local __TS__Symbol, Symbol
29
+ do
30
+ local symbolMetatable = {__tostring = function(self)
31
+ return ("Symbol(" .. (self.description or "")) .. ")"
32
+ end}
33
+ function __TS__Symbol(description)
34
+ return setmetatable({description = description}, symbolMetatable)
35
+ end
36
+ Symbol = {
37
+ iterator = __TS__Symbol("Symbol.iterator"),
38
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
39
+ species = __TS__Symbol("Symbol.species"),
40
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
41
+ }
42
+ end
43
+
44
+ local function __TS__ArrayEntries(array)
45
+ local key = 0
46
+ return {
47
+ [Symbol.iterator] = function(self)
48
+ return self
49
+ end,
50
+ next = function(self)
51
+ local result = {done = array[key + 1] == nil, value = {key, array[key + 1]}}
52
+ key = key + 1
53
+ return result
54
+ end
55
+ }
56
+ end
57
+
58
+ local function __TS__ArrayEvery(self, callbackfn, thisArg)
59
+ for i = 1, table.getn(self) do
60
+ if not callbackfn(thisArg, self[i], i - 1, self) then
61
+ return false
62
+ end
63
+ end
64
+ return true
65
+ end
66
+
67
+ local function __TS__ArrayFilter(self, callbackfn, thisArg)
68
+ local result = {}
69
+ local len = 0
70
+ for i = 1, table.getn(self) do
71
+ if callbackfn(thisArg, self[i], i - 1, self) then
72
+ len = len + 1
73
+ result[len] = self[i]
74
+ end
75
+ end
76
+ return result
77
+ end
78
+
79
+ local function __TS__ArrayForEach(self, callbackFn, thisArg)
80
+ for i = 1, table.getn(self) do
81
+ callbackFn(thisArg, self[i], i - 1, self)
82
+ end
83
+ end
84
+
85
+ local function __TS__ArrayFind(self, predicate, thisArg)
86
+ for i = 1, table.getn(self) do
87
+ local elem = self[i]
88
+ if predicate(thisArg, elem, i - 1, self) then
89
+ return elem
90
+ end
91
+ end
92
+ return nil
93
+ end
94
+
95
+ local function __TS__ArrayFindIndex(self, callbackFn, thisArg)
96
+ for i = 1, table.getn(self) do
97
+ if callbackFn(thisArg, self[i], i - 1, self) then
98
+ return i - 1
99
+ end
100
+ end
101
+ return -1
102
+ end
103
+
104
+ local __TS__Iterator
105
+ do
106
+ local function iteratorGeneratorStep(self)
107
+ local co = self.____coroutine
108
+ local status, value = coroutine.resume(co)
109
+ if not status then
110
+ error(value, 0)
111
+ end
112
+ if coroutine.status(co) == "dead" then
113
+ return
114
+ end
115
+ return true, value
116
+ end
117
+ local function iteratorIteratorStep(self)
118
+ local result = self:next()
119
+ if result.done then
120
+ return
121
+ end
122
+ return true, result.value
123
+ end
124
+ local function iteratorStringStep(self, index)
125
+ index = index + 1
126
+ if index > string.len(self) then
127
+ return
128
+ end
129
+ return index, string.sub(self, index, index)
130
+ end
131
+ function __TS__Iterator(iterable)
132
+ if type(iterable) == "string" then
133
+ return iteratorStringStep, iterable, 0
134
+ elseif iterable.____coroutine ~= nil then
135
+ return iteratorGeneratorStep, iterable
136
+ elseif iterable[Symbol.iterator] then
137
+ local iterator = iterable[Symbol.iterator](iterable)
138
+ return iteratorIteratorStep, iterator
139
+ else
140
+ return ipairs(iterable)
141
+ end
142
+ end
143
+ end
144
+
145
+ local __TS__ArrayFrom
146
+ do
147
+ local function arrayLikeStep(self, index)
148
+ index = index + 1
149
+ if index > self.length then
150
+ return
151
+ end
152
+ return index, self[index]
153
+ end
154
+ local function arrayLikeIterator(arr)
155
+ if type(arr.length) == "number" then
156
+ return arrayLikeStep, arr, 0
157
+ end
158
+ return __TS__Iterator(arr)
159
+ end
160
+ function __TS__ArrayFrom(arrayLike, mapFn, thisArg)
161
+ local result = {}
162
+ if mapFn == nil then
163
+ for ____, v in arrayLikeIterator(arrayLike) do
164
+ result[table.getn(result) + 1] = v
165
+ end
166
+ else
167
+ for i, v in arrayLikeIterator(arrayLike) do
168
+ result[table.getn(result) + 1] = mapFn(thisArg, v, i - 1)
169
+ end
170
+ end
171
+ return result
172
+ end
173
+ end
174
+
175
+ local function __TS__ArrayIncludes(self, searchElement, fromIndex)
176
+ if fromIndex == nil then
177
+ fromIndex = 0
178
+ end
179
+ local len = table.getn(self)
180
+ local k = fromIndex
181
+ if fromIndex < 0 then
182
+ k = len + fromIndex
183
+ end
184
+ if k < 0 then
185
+ k = 0
186
+ end
187
+ for i = k + 1, len do
188
+ if self[i] == searchElement then
189
+ return true
190
+ end
191
+ end
192
+ return false
193
+ end
194
+
195
+ local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
196
+ if fromIndex == nil then
197
+ fromIndex = 0
198
+ end
199
+ local len = table.getn(self)
200
+ if len == 0 then
201
+ return -1
202
+ end
203
+ if fromIndex >= len then
204
+ return -1
205
+ end
206
+ if fromIndex < 0 then
207
+ fromIndex = len + fromIndex
208
+ if fromIndex < 0 then
209
+ fromIndex = 0
210
+ end
211
+ end
212
+ for i = fromIndex + 1, len do
213
+ if self[i] == searchElement then
214
+ return i - 1
215
+ end
216
+ end
217
+ return -1
218
+ end
219
+
220
+ local function __TS__ArrayJoin(self, separator)
221
+ if separator == nil then
222
+ separator = ","
223
+ end
224
+ local parts = {}
225
+ for i = 1, table.getn(self) do
226
+ parts[i] = tostring(self[i])
227
+ end
228
+ return table.concat(parts, separator)
229
+ end
230
+
231
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
232
+ local result = {}
233
+ for i = 1, table.getn(self) do
234
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
235
+ end
236
+ return result
237
+ end
238
+
239
+ local function __TS__ArrayPush(self, ...)
240
+ local items = arg
241
+ local len = table.getn(self)
242
+ for i = 1, table.getn(items) do
243
+ len = len + 1
244
+ self[len] = items[i]
245
+ end
246
+ return len
247
+ end
248
+
249
+ local function __TS__ArrayPushArray(self, items)
250
+ local len = table.getn(self)
251
+ for i = 1, table.getn(items) do
252
+ len = len + 1
253
+ self[len] = items[i]
254
+ end
255
+ return len
256
+ end
257
+
258
+ local function __TS__CountVarargs(...)
259
+ local args = arg
260
+ return table.getn(args)
261
+ end
262
+
263
+ local function __TS__ArrayReduce(self, callbackFn, ...)
264
+ local len = table.getn(self)
265
+ local k = 0
266
+ local accumulator = nil
267
+ if __TS__CountVarargs(unpack(arg)) ~= 0 then
268
+ accumulator = unpack(arg)
269
+ elseif len > 0 then
270
+ accumulator = self[1]
271
+ k = 1
272
+ else
273
+ error("Reduce of empty array with no initial value", 0)
274
+ end
275
+ for i = k + 1, len do
276
+ accumulator = callbackFn(
277
+ nil,
278
+ accumulator,
279
+ self[i],
280
+ i - 1,
281
+ self
282
+ )
283
+ end
284
+ return accumulator
285
+ end
286
+
287
+ local function __TS__ArrayReduceRight(self, callbackFn, ...)
288
+ local len = table.getn(self)
289
+ local k = len - 1
290
+ local accumulator = nil
291
+ if __TS__CountVarargs(unpack(arg)) ~= 0 then
292
+ accumulator = unpack(arg)
293
+ elseif len > 0 then
294
+ accumulator = self[k + 1]
295
+ k = k - 1
296
+ else
297
+ error("Reduce of empty array with no initial value", 0)
298
+ end
299
+ for i = k + 1, 1, -1 do
300
+ accumulator = callbackFn(
301
+ nil,
302
+ accumulator,
303
+ self[i],
304
+ i - 1,
305
+ self
306
+ )
307
+ end
308
+ return accumulator
309
+ end
310
+
311
+ local function __TS__ArrayReverse(self)
312
+ local i = 1
313
+ local j = table.getn(self)
314
+ while i < j do
315
+ local temp = self[j]
316
+ self[j] = self[i]
317
+ self[i] = temp
318
+ i = i + 1
319
+ j = j - 1
320
+ end
321
+ return self
322
+ end
323
+
324
+ local function __TS__ArrayUnshift(self, ...)
325
+ local items = arg
326
+ local numItemsToInsert = table.getn(items)
327
+ if numItemsToInsert == 0 then
328
+ return table.getn(self)
329
+ end
330
+ for i = table.getn(self), 1, -1 do
331
+ self[i + numItemsToInsert] = self[i]
332
+ end
333
+ for i = 1, numItemsToInsert do
334
+ self[i] = items[i]
335
+ end
336
+ return table.getn(self)
337
+ end
338
+
339
+ local function __TS__ArraySort(self, compareFn)
340
+ if compareFn ~= nil then
341
+ table.sort(
342
+ self,
343
+ function(a, b) return compareFn(nil, a, b) < 0 end
344
+ )
345
+ else
346
+ table.sort(self)
347
+ end
348
+ return self
349
+ end
350
+
351
+ local function __TS__ArraySlice(self, first, last)
352
+ local len = table.getn(self)
353
+ local ____first_0 = first
354
+ if ____first_0 == nil then
355
+ ____first_0 = 0
356
+ end
357
+ first = ____first_0
358
+ if first < 0 then
359
+ first = len + first
360
+ if first < 0 then
361
+ first = 0
362
+ end
363
+ else
364
+ if first > len then
365
+ first = len
366
+ end
367
+ end
368
+ local ____last_1 = last
369
+ if ____last_1 == nil then
370
+ ____last_1 = len
371
+ end
372
+ last = ____last_1
373
+ if last < 0 then
374
+ last = len + last
375
+ if last < 0 then
376
+ last = 0
377
+ end
378
+ else
379
+ if last > len then
380
+ last = len
381
+ end
382
+ end
383
+ local out = {}
384
+ first = first + 1
385
+ last = last + 1
386
+ local n = 1
387
+ while first < last do
388
+ out[n] = self[first]
389
+ first = first + 1
390
+ n = n + 1
391
+ end
392
+ return out
393
+ end
394
+
395
+ local function __TS__ArraySome(self, callbackfn, thisArg)
396
+ for i = 1, table.getn(self) do
397
+ if callbackfn(thisArg, self[i], i - 1, self) then
398
+ return true
399
+ end
400
+ end
401
+ return false
402
+ end
403
+
404
+ local function __TS__ArraySplice(self, ...)
405
+ local args = arg
406
+ local len = table.getn(self)
407
+ local actualArgumentCount = __TS__CountVarargs(unpack(arg))
408
+ local start = args[1]
409
+ local deleteCount = args[2]
410
+ if start < 0 then
411
+ start = len + start
412
+ if start < 0 then
413
+ start = 0
414
+ end
415
+ elseif start > len then
416
+ start = len
417
+ end
418
+ local itemCount = actualArgumentCount - 2
419
+ if itemCount < 0 then
420
+ itemCount = 0
421
+ end
422
+ local actualDeleteCount
423
+ if actualArgumentCount == 0 then
424
+ actualDeleteCount = 0
425
+ elseif actualArgumentCount == 1 then
426
+ actualDeleteCount = len - start
427
+ else
428
+ local ____deleteCount_0 = deleteCount
429
+ if ____deleteCount_0 == nil then
430
+ ____deleteCount_0 = 0
431
+ end
432
+ actualDeleteCount = ____deleteCount_0
433
+ if actualDeleteCount < 0 then
434
+ actualDeleteCount = 0
435
+ end
436
+ if actualDeleteCount > len - start then
437
+ actualDeleteCount = len - start
438
+ end
439
+ end
440
+ local out = {}
441
+ for k = 1, actualDeleteCount do
442
+ local from = start + k
443
+ if self[from] ~= nil then
444
+ out[k] = self[from]
445
+ end
446
+ end
447
+ if itemCount < actualDeleteCount then
448
+ for k = start + 1, len - actualDeleteCount do
449
+ local from = k + actualDeleteCount
450
+ local to = k + itemCount
451
+ if self[from] then
452
+ self[to] = self[from]
453
+ else
454
+ self[to] = nil
455
+ end
456
+ end
457
+ for k = len - actualDeleteCount + itemCount + 1, len do
458
+ self[k] = nil
459
+ end
460
+ elseif itemCount > actualDeleteCount then
461
+ for k = len - actualDeleteCount, start + 1, -1 do
462
+ local from = k + actualDeleteCount
463
+ local to = k + itemCount
464
+ if self[from] then
465
+ self[to] = self[from]
466
+ else
467
+ self[to] = nil
468
+ end
469
+ end
470
+ end
471
+ local j = start + 1
472
+ for i = 3, actualArgumentCount do
473
+ self[j] = args[i]
474
+ j = j + 1
475
+ end
476
+ for k = table.getn(self), len - actualDeleteCount + itemCount + 1, -1 do
477
+ self[k] = nil
478
+ end
479
+ return out
480
+ end
481
+
482
+ local function __TS__ArrayToObject(self)
483
+ local object = {}
484
+ for i = 1, table.getn(self) do
485
+ object[i - 1] = self[i]
486
+ end
487
+ return object
488
+ end
489
+
490
+ local function __TS__ArrayFlat(self, depth)
491
+ if depth == nil then
492
+ depth = 1
493
+ end
494
+ local result = {}
495
+ local len = 0
496
+ for i = 1, table.getn(self) do
497
+ local value = self[i]
498
+ if depth > 0 and __TS__ArrayIsArray(value) then
499
+ local toAdd
500
+ if depth == 1 then
501
+ toAdd = value
502
+ else
503
+ toAdd = __TS__ArrayFlat(value, depth - 1)
504
+ end
505
+ for j = 1, table.getn(toAdd) do
506
+ local val = toAdd[j]
507
+ len = len + 1
508
+ result[len] = val
509
+ end
510
+ else
511
+ len = len + 1
512
+ result[len] = value
513
+ end
514
+ end
515
+ return result
516
+ end
517
+
518
+ local function __TS__ArrayFlatMap(self, callback, thisArg)
519
+ local result = {}
520
+ local len = 0
521
+ for i = 1, table.getn(self) do
522
+ local value = callback(thisArg, self[i], i - 1, self)
523
+ if __TS__ArrayIsArray(value) then
524
+ for j = 1, table.getn(value) do
525
+ len = len + 1
526
+ result[len] = value[j]
527
+ end
528
+ else
529
+ len = len + 1
530
+ result[len] = value
531
+ end
532
+ end
533
+ return result
534
+ end
535
+
536
+ local function __TS__ArraySetLength(self, length)
537
+ if length < 0 or length ~= length or length == 1 / 0 or math.floor(length) ~= length then
538
+ error(
539
+ "invalid array length: " .. tostring(length),
540
+ 0
541
+ )
542
+ end
543
+ for i = length + 1, table.getn(self) do
544
+ self[i] = nil
545
+ end
546
+ return length
547
+ end
548
+
549
+ local function __TS__InstanceOf(obj, classTbl)
550
+ if type(classTbl) ~= "table" then
551
+ error("Right-hand side of 'instanceof' is not an object", 0)
552
+ end
553
+ if classTbl[Symbol.hasInstance] ~= nil then
554
+ return not not classTbl[Symbol.hasInstance](classTbl, obj)
555
+ end
556
+ if type(obj) == "table" then
557
+ local luaClass = obj.constructor
558
+ while luaClass ~= nil do
559
+ if luaClass == classTbl then
560
+ return true
561
+ end
562
+ luaClass = luaClass.____super
563
+ end
564
+ end
565
+ return false
566
+ end
567
+
568
+ local function __TS__New(target, ...)
569
+ local instance = setmetatable({}, target.prototype)
570
+ instance:____constructor(unpack(arg))
571
+ return instance
572
+ end
573
+
574
+ local function __TS__Class(self)
575
+ local c = {prototype = {}}
576
+ c.prototype.__index = c.prototype
577
+ c.prototype.constructor = c
578
+ return c
579
+ end
580
+
581
+ local function __TS__FunctionBind(fn, ...)
582
+ local boundArgs = arg
583
+ return function(____, ...)
584
+ local args = arg
585
+ __TS__ArrayUnshift(
586
+ args,
587
+ unpack(boundArgs)
588
+ )
589
+ return fn(unpack(args))
590
+ end
591
+ end
592
+
593
+ local __TS__Promise
594
+ do
595
+ local function promiseDeferred(self)
596
+ local resolve
597
+ local reject
598
+ local promise = __TS__New(
599
+ __TS__Promise,
600
+ function(____, res, rej)
601
+ resolve = res
602
+ reject = rej
603
+ end
604
+ )
605
+ return {promise = promise, resolve = resolve, reject = reject}
606
+ end
607
+ local function isPromiseLike(self, thing)
608
+ return __TS__InstanceOf(thing, __TS__Promise)
609
+ end
610
+ __TS__Promise = __TS__Class()
611
+ __TS__Promise.name = "__TS__Promise"
612
+ function __TS__Promise.prototype.____constructor(self, executor)
613
+ self.state = 0
614
+ self.fulfilledCallbacks = {}
615
+ self.rejectedCallbacks = {}
616
+ self.finallyCallbacks = {}
617
+ do
618
+ local function ____catch(e)
619
+ self:reject(e)
620
+ end
621
+ local ____try, ____hasReturned = pcall(function()
622
+ executor(
623
+ nil,
624
+ __TS__FunctionBind(self.resolve, self),
625
+ __TS__FunctionBind(self.reject, self)
626
+ )
627
+ end)
628
+ if not ____try then
629
+ ____catch(____hasReturned)
630
+ end
631
+ end
632
+ end
633
+ function __TS__Promise.resolve(data)
634
+ local promise = __TS__New(
635
+ __TS__Promise,
636
+ function()
637
+ end
638
+ )
639
+ promise.state = 1
640
+ promise.value = data
641
+ return promise
642
+ end
643
+ function __TS__Promise.reject(reason)
644
+ local promise = __TS__New(
645
+ __TS__Promise,
646
+ function()
647
+ end
648
+ )
649
+ promise.state = 2
650
+ promise.rejectionReason = reason
651
+ return promise
652
+ end
653
+ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
654
+ local ____promiseDeferred_result_0 = promiseDeferred(nil)
655
+ local promise = ____promiseDeferred_result_0.promise
656
+ local resolve = ____promiseDeferred_result_0.resolve
657
+ local reject = ____promiseDeferred_result_0.reject
658
+ local isFulfilled = self.state == 1
659
+ local isRejected = self.state == 2
660
+ if onFulfilled then
661
+ local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
662
+ local ____self_fulfilledCallbacks_1 = self.fulfilledCallbacks
663
+ ____self_fulfilledCallbacks_1[table.getn(____self_fulfilledCallbacks_1) + 1] = internalCallback
664
+ if isFulfilled then
665
+ internalCallback(nil, self.value)
666
+ end
667
+ else
668
+ local ____self_fulfilledCallbacks_2 = self.fulfilledCallbacks
669
+ ____self_fulfilledCallbacks_2[table.getn(____self_fulfilledCallbacks_2) + 1] = function(____, v) return resolve(nil, v) end
670
+ end
671
+ if onRejected then
672
+ local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
673
+ local ____self_rejectedCallbacks_3 = self.rejectedCallbacks
674
+ ____self_rejectedCallbacks_3[table.getn(____self_rejectedCallbacks_3) + 1] = internalCallback
675
+ if isRejected then
676
+ internalCallback(nil, self.rejectionReason)
677
+ end
678
+ else
679
+ local ____self_rejectedCallbacks_4 = self.rejectedCallbacks
680
+ ____self_rejectedCallbacks_4[table.getn(____self_rejectedCallbacks_4) + 1] = function(____, err) return reject(nil, err) end
681
+ end
682
+ if isFulfilled then
683
+ resolve(nil, self.value)
684
+ end
685
+ if isRejected then
686
+ reject(nil, self.rejectionReason)
687
+ end
688
+ return promise
689
+ end
690
+ function __TS__Promise.prototype.catch(self, onRejected)
691
+ return self["then"](self, nil, onRejected)
692
+ end
693
+ function __TS__Promise.prototype.finally(self, onFinally)
694
+ if onFinally then
695
+ local ____self_finallyCallbacks_5 = self.finallyCallbacks
696
+ ____self_finallyCallbacks_5[table.getn(____self_finallyCallbacks_5) + 1] = onFinally
697
+ if self.state ~= 0 then
698
+ onFinally(nil)
699
+ end
700
+ end
701
+ return self
702
+ end
703
+ function __TS__Promise.prototype.resolve(self, data)
704
+ if __TS__InstanceOf(data, __TS__Promise) then
705
+ data["then"](
706
+ data,
707
+ function(____, v) return self:resolve(v) end,
708
+ function(____, err) return self:reject(err) end
709
+ )
710
+ return
711
+ end
712
+ if self.state == 0 then
713
+ self.state = 1
714
+ self.value = data
715
+ for ____, callback in ipairs(self.fulfilledCallbacks) do
716
+ callback(nil, data)
717
+ end
718
+ for ____, callback in ipairs(self.finallyCallbacks) do
719
+ callback(nil)
720
+ end
721
+ end
722
+ end
723
+ function __TS__Promise.prototype.reject(self, reason)
724
+ if self.state == 0 then
725
+ self.state = 2
726
+ self.rejectionReason = reason
727
+ for ____, callback in ipairs(self.rejectedCallbacks) do
728
+ callback(nil, reason)
729
+ end
730
+ for ____, callback in ipairs(self.finallyCallbacks) do
731
+ callback(nil)
732
+ end
733
+ end
734
+ end
735
+ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
736
+ return function(____, value)
737
+ do
738
+ local function ____catch(e)
739
+ reject(nil, e)
740
+ end
741
+ local ____try, ____hasReturned = pcall(function()
742
+ self:handleCallbackData(
743
+ f(nil, value),
744
+ resolve,
745
+ reject
746
+ )
747
+ end)
748
+ if not ____try then
749
+ ____catch(____hasReturned)
750
+ end
751
+ end
752
+ end
753
+ end
754
+ function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
755
+ if isPromiseLike(nil, data) then
756
+ local nextpromise = data
757
+ if nextpromise.state == 1 then
758
+ resolve(nil, nextpromise.value)
759
+ elseif nextpromise.state == 2 then
760
+ reject(nil, nextpromise.rejectionReason)
761
+ else
762
+ data["then"](data, resolve, reject)
763
+ end
764
+ else
765
+ resolve(nil, data)
766
+ end
767
+ end
768
+ end
769
+
770
+ local function __TS__AsyncAwaiter(generator)
771
+ return __TS__New(
772
+ __TS__Promise,
773
+ function(____, resolve, reject)
774
+ local adopt, fulfilled, step, resolved, asyncCoroutine
775
+ function adopt(self, value)
776
+ local ____temp_0
777
+ if __TS__InstanceOf(value, __TS__Promise) then
778
+ ____temp_0 = value
779
+ else
780
+ ____temp_0 = __TS__Promise.resolve(value)
781
+ end
782
+ return ____temp_0
783
+ end
784
+ function fulfilled(self, value)
785
+ local success, resultOrError = coroutine.resume(asyncCoroutine, value)
786
+ if success then
787
+ step(nil, resultOrError)
788
+ else
789
+ reject(nil, resultOrError)
790
+ end
791
+ end
792
+ function step(self, result)
793
+ if resolved then
794
+ return
795
+ end
796
+ if coroutine.status(asyncCoroutine) == "dead" then
797
+ resolve(nil, result)
798
+ else
799
+ local ____self_1 = adopt(nil, result)
800
+ ____self_1["then"](____self_1, fulfilled, reject)
801
+ end
802
+ end
803
+ resolved = false
804
+ asyncCoroutine = coroutine.create(generator)
805
+ local success, resultOrError = coroutine.resume(
806
+ asyncCoroutine,
807
+ function(____, v)
808
+ resolved = true
809
+ local ____self_2 = adopt(nil, v)
810
+ ____self_2["then"](____self_2, resolve, reject)
811
+ end
812
+ )
813
+ if success then
814
+ step(nil, resultOrError)
815
+ else
816
+ reject(nil, resultOrError)
817
+ end
818
+ end
819
+ )
820
+ end
821
+ local function __TS__Await(thing)
822
+ return coroutine.yield(thing)
823
+ end
824
+
825
+ local function __TS__ClassExtends(target, base)
826
+ target.____super = base
827
+ local staticMetatable = setmetatable({__index = base}, base)
828
+ setmetatable(target, staticMetatable)
829
+ local baseMetatable = getmetatable(base)
830
+ if baseMetatable then
831
+ if type(baseMetatable.__index) == "function" then
832
+ staticMetatable.__index = baseMetatable.__index
833
+ end
834
+ if type(baseMetatable.__newindex) == "function" then
835
+ staticMetatable.__newindex = baseMetatable.__newindex
836
+ end
837
+ end
838
+ setmetatable(target.prototype, base.prototype)
839
+ if type(base.prototype.__index) == "function" then
840
+ target.prototype.__index = base.prototype.__index
841
+ end
842
+ if type(base.prototype.__newindex) == "function" then
843
+ target.prototype.__newindex = base.prototype.__newindex
844
+ end
845
+ if type(base.prototype.__tostring) == "function" then
846
+ target.prototype.__tostring = base.prototype.__tostring
847
+ end
848
+ end
849
+
850
+ local function __TS__CloneDescriptor(____bindingPattern0)
851
+ local value
852
+ local writable
853
+ local set
854
+ local get
855
+ local configurable
856
+ local enumerable
857
+ enumerable = ____bindingPattern0.enumerable
858
+ configurable = ____bindingPattern0.configurable
859
+ get = ____bindingPattern0.get
860
+ set = ____bindingPattern0.set
861
+ writable = ____bindingPattern0.writable
862
+ value = ____bindingPattern0.value
863
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
864
+ local hasGetterOrSetter = get ~= nil or set ~= nil
865
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
866
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
867
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
868
+ end
869
+ if get or set then
870
+ descriptor.get = get
871
+ descriptor.set = set
872
+ else
873
+ descriptor.value = value
874
+ descriptor.writable = writable == true
875
+ end
876
+ return descriptor
877
+ end
878
+
879
+ local function __TS__ObjectAssign(target, ...)
880
+ local sources = arg
881
+ for i = 1, table.getn(sources) do
882
+ local source = sources[i]
883
+ for key in pairs(source) do
884
+ target[key] = source[key]
885
+ end
886
+ end
887
+ return target
888
+ end
889
+
890
+ local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
891
+ local metatable = getmetatable(object)
892
+ if not metatable then
893
+ return
894
+ end
895
+ if not rawget(metatable, "_descriptors") then
896
+ return
897
+ end
898
+ return rawget(metatable, "_descriptors")[key]
899
+ end
900
+
901
+ local __TS__SetDescriptor
902
+ do
903
+ local function descriptorIndex(self, key)
904
+ local value = rawget(self, key)
905
+ if value ~= nil then
906
+ return value
907
+ end
908
+ local metatable = getmetatable(self)
909
+ while metatable do
910
+ local rawResult = rawget(metatable, key)
911
+ if rawResult ~= nil then
912
+ return rawResult
913
+ end
914
+ local descriptors = rawget(metatable, "_descriptors")
915
+ if descriptors then
916
+ local descriptor = descriptors[key]
917
+ if descriptor then
918
+ if descriptor.get then
919
+ return descriptor.get(self)
920
+ end
921
+ return descriptor.value
922
+ end
923
+ end
924
+ metatable = getmetatable(metatable)
925
+ end
926
+ end
927
+ local function descriptorNewIndex(self, key, value)
928
+ local metatable = getmetatable(self)
929
+ while metatable do
930
+ local descriptors = rawget(metatable, "_descriptors")
931
+ if descriptors then
932
+ local descriptor = descriptors[key]
933
+ if descriptor then
934
+ if descriptor.set then
935
+ descriptor.set(self, value)
936
+ else
937
+ if descriptor.writable == false then
938
+ error(
939
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
940
+ 0
941
+ )
942
+ end
943
+ descriptor.value = value
944
+ end
945
+ return
946
+ end
947
+ end
948
+ metatable = getmetatable(metatable)
949
+ end
950
+ rawset(self, key, value)
951
+ end
952
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
953
+ if isPrototype == nil then
954
+ isPrototype = false
955
+ end
956
+ local ____isPrototype_0
957
+ if isPrototype then
958
+ ____isPrototype_0 = target
959
+ else
960
+ ____isPrototype_0 = getmetatable(target)
961
+ end
962
+ local metatable = ____isPrototype_0
963
+ if not metatable then
964
+ metatable = {}
965
+ setmetatable(target, metatable)
966
+ end
967
+ local value = rawget(target, key)
968
+ if value ~= nil then
969
+ rawset(target, key, nil)
970
+ end
971
+ if not rawget(metatable, "_descriptors") then
972
+ metatable._descriptors = {}
973
+ end
974
+ local descriptor = __TS__CloneDescriptor(desc)
975
+ metatable._descriptors[key] = descriptor
976
+ metatable.__index = descriptorIndex
977
+ metatable.__newindex = descriptorNewIndex
978
+ end
979
+ end
980
+
981
+ local function __TS__Decorate(decorators, target, key, desc)
982
+ local result = target
983
+ do
984
+ local i = table.getn(decorators)
985
+ while i >= 0 do
986
+ local decorator = decorators[i + 1]
987
+ if decorator then
988
+ local oldResult = result
989
+ if key == nil then
990
+ result = decorator(nil, result)
991
+ elseif desc == true then
992
+ local value = rawget(target, key)
993
+ local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
994
+ local desc = decorator(nil, target, key, descriptor) or descriptor
995
+ local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
996
+ if isSimpleValue then
997
+ rawset(target, key, desc.value)
998
+ else
999
+ __TS__SetDescriptor(
1000
+ target,
1001
+ key,
1002
+ __TS__ObjectAssign({}, descriptor, desc)
1003
+ )
1004
+ end
1005
+ elseif desc == false then
1006
+ result = decorator(nil, target, key, desc)
1007
+ else
1008
+ result = decorator(nil, target, key)
1009
+ end
1010
+ result = result or oldResult
1011
+ end
1012
+ i = i - 1
1013
+ end
1014
+ end
1015
+ return result
1016
+ end
1017
+
1018
+ local function __TS__DecorateParam(paramIndex, decorator)
1019
+ return function(____, target, key) return decorator(nil, target, key, paramIndex) end
1020
+ end
1021
+
1022
+ local function __TS__StringIncludes(self, searchString, position)
1023
+ if not position then
1024
+ position = 1
1025
+ else
1026
+ position = position + 1
1027
+ end
1028
+ local index = string.find(self, searchString, position, true)
1029
+ return index ~= nil
1030
+ end
1031
+
1032
+ local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
1033
+ do
1034
+ local function getErrorStack(self, constructor)
1035
+ local level = 1
1036
+ while true do
1037
+ local info = debug.getinfo(level, "f")
1038
+ level = level + 1
1039
+ if not info then
1040
+ level = 1
1041
+ break
1042
+ elseif info.func == constructor then
1043
+ break
1044
+ end
1045
+ end
1046
+ if __TS__StringIncludes(_VERSION, "Lua 5.0") then
1047
+ return debug.traceback(("[Level " .. tostring(level)) .. "]")
1048
+ else
1049
+ return debug.traceback(nil, level)
1050
+ end
1051
+ end
1052
+ local function wrapErrorToString(self, getDescription)
1053
+ return function(self)
1054
+ local description = getDescription(self)
1055
+ local caller = debug.getinfo(3, "f")
1056
+ local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1"
1057
+ if isClassicLua or caller and caller.func ~= error then
1058
+ return description
1059
+ else
1060
+ return (tostring(description) .. "\n") .. self.stack
1061
+ end
1062
+ end
1063
+ end
1064
+ local function initErrorClass(self, Type, name)
1065
+ Type.name = name
1066
+ return setmetatable(
1067
+ Type,
1068
+ {__call = function(____, _self, message) return __TS__New(Type, message) end}
1069
+ )
1070
+ end
1071
+ local ____initErrorClass_2 = initErrorClass
1072
+ local ____class_0 = __TS__Class()
1073
+ ____class_0.name = ""
1074
+ function ____class_0.prototype.____constructor(self, message)
1075
+ if message == nil then
1076
+ message = ""
1077
+ end
1078
+ self.message = message
1079
+ self.name = "Error"
1080
+ self.stack = getErrorStack(nil, self.constructor.new)
1081
+ local metatable = getmetatable(self)
1082
+ if not metatable.__errorToStringPatched then
1083
+ metatable.__errorToStringPatched = true
1084
+ metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
1085
+ end
1086
+ end
1087
+ function ____class_0.prototype.__tostring(self)
1088
+ local ____temp_1
1089
+ if self.message ~= "" then
1090
+ ____temp_1 = (self.name .. ": ") .. self.message
1091
+ else
1092
+ ____temp_1 = self.name
1093
+ end
1094
+ return ____temp_1
1095
+ end
1096
+ Error = ____initErrorClass_2(nil, ____class_0, "Error")
1097
+ local function createErrorClass(self, name)
1098
+ local ____initErrorClass_4 = initErrorClass
1099
+ local ____class_3 = __TS__Class()
1100
+ ____class_3.name = ____class_3.name
1101
+ __TS__ClassExtends(____class_3, Error)
1102
+ function ____class_3.prototype.____constructor(self, ...)
1103
+ ____class_3.____super.prototype.____constructor(
1104
+ self,
1105
+ unpack(arg)
1106
+ )
1107
+ self.name = name
1108
+ end
1109
+ return ____initErrorClass_4(nil, ____class_3, name)
1110
+ end
1111
+ RangeError = createErrorClass(nil, "RangeError")
1112
+ ReferenceError = createErrorClass(nil, "ReferenceError")
1113
+ SyntaxError = createErrorClass(nil, "SyntaxError")
1114
+ TypeError = createErrorClass(nil, "TypeError")
1115
+ URIError = createErrorClass(nil, "URIError")
1116
+ end
1117
+
1118
+ local function __TS__ObjectGetOwnPropertyDescriptors(object)
1119
+ local metatable = getmetatable(object)
1120
+ if not metatable then
1121
+ return {}
1122
+ end
1123
+ return rawget(metatable, "_descriptors") or ({})
1124
+ end
1125
+
1126
+ local function __TS__Delete(target, key)
1127
+ local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
1128
+ local descriptor = descriptors[key]
1129
+ if descriptor then
1130
+ if not descriptor.configurable then
1131
+ error(
1132
+ __TS__New(
1133
+ TypeError,
1134
+ ((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
1135
+ ),
1136
+ 0
1137
+ )
1138
+ end
1139
+ descriptors[key] = nil
1140
+ return true
1141
+ end
1142
+ target[key] = nil
1143
+ return true
1144
+ end
1145
+
1146
+ local function __TS__StringAccess(self, index)
1147
+ if index >= 0 and index < string.len(self) then
1148
+ return string.sub(self, index + 1, index + 1)
1149
+ end
1150
+ end
1151
+
1152
+ local function __TS__DelegatedYield(iterable)
1153
+ if type(iterable) == "string" then
1154
+ for index = 0, string.len(iterable) - 1 do
1155
+ coroutine.yield(__TS__StringAccess(iterable, index))
1156
+ end
1157
+ elseif iterable.____coroutine ~= nil then
1158
+ local co = iterable.____coroutine
1159
+ while true do
1160
+ local status, value = coroutine.resume(co)
1161
+ if not status then
1162
+ error(value, 0)
1163
+ end
1164
+ if coroutine.status(co) == "dead" then
1165
+ return value
1166
+ else
1167
+ coroutine.yield(value)
1168
+ end
1169
+ end
1170
+ elseif iterable[Symbol.iterator] then
1171
+ local iterator = iterable[Symbol.iterator](iterable)
1172
+ while true do
1173
+ local result = iterator:next()
1174
+ if result.done then
1175
+ return result.value
1176
+ else
1177
+ coroutine.yield(result.value)
1178
+ end
1179
+ end
1180
+ else
1181
+ for ____, value in ipairs(iterable) do
1182
+ coroutine.yield(value)
1183
+ end
1184
+ end
1185
+ end
1186
+
1187
+ local function __TS__Spread(iterable)
1188
+ local arr = {}
1189
+ if type(iterable) == "string" then
1190
+ for i = 0, string.len(iterable) - 1 do
1191
+ arr[i + 1] = __TS__StringAccess(iterable, i)
1192
+ end
1193
+ else
1194
+ local len = 0
1195
+ for ____, item in __TS__Iterator(iterable) do
1196
+ len = len + 1
1197
+ arr[len] = item
1198
+ end
1199
+ end
1200
+ return unpack(arr)
1201
+ end
1202
+
1203
+ local __TS__Unpack = unpack
1204
+
1205
+ local __TS__Generator
1206
+ do
1207
+ local function generatorIterator(self)
1208
+ return self
1209
+ end
1210
+ local function generatorNext(self, ...)
1211
+ local co = self.____coroutine
1212
+ if coroutine.status(co) == "dead" then
1213
+ return {done = true}
1214
+ end
1215
+ local status, value = coroutine.resume(
1216
+ co,
1217
+ unpack(arg)
1218
+ )
1219
+ if not status then
1220
+ error(value, 0)
1221
+ end
1222
+ return {
1223
+ value = value,
1224
+ done = coroutine.status(co) == "dead"
1225
+ }
1226
+ end
1227
+ function __TS__Generator(fn)
1228
+ return function(...)
1229
+ local args = arg
1230
+ local argsLength = __TS__CountVarargs(unpack(arg))
1231
+ return {
1232
+ ____coroutine = coroutine.create(function() return fn(__TS__Spread(__TS__Unpack(nil, args, 1, argsLength))) end),
1233
+ [Symbol.iterator] = generatorIterator,
1234
+ next = generatorNext
1235
+ }
1236
+ end
1237
+ end
1238
+ end
1239
+
1240
+ local function __TS__InstanceOfObject(value)
1241
+ local valueType = type(value)
1242
+ return valueType == "table" or valueType == "function"
1243
+ end
1244
+
1245
+ local function __TS__LuaIteratorSpread(self, state, firstKey)
1246
+ local results = {}
1247
+ local key, value = self(state, firstKey)
1248
+ while key do
1249
+ results[table.getn(results) + 1] = {key, value}
1250
+ key, value = self(state, key)
1251
+ end
1252
+ return unpack(results)
1253
+ end
1254
+
1255
+ local Map
1256
+ do
1257
+ Map = __TS__Class()
1258
+ Map.name = "Map"
1259
+ function Map.prototype.____constructor(self, entries)
1260
+ self[Symbol.toStringTag] = "Map"
1261
+ self.items = {}
1262
+ self.size = 0
1263
+ self.nextKey = {}
1264
+ self.previousKey = {}
1265
+ if entries == nil then
1266
+ return
1267
+ end
1268
+ local iterable = entries
1269
+ if iterable[Symbol.iterator] then
1270
+ local iterator = iterable[Symbol.iterator](iterable)
1271
+ while true do
1272
+ local result = iterator:next()
1273
+ if result.done then
1274
+ break
1275
+ end
1276
+ local value = result.value
1277
+ self:set(value[1], value[2])
1278
+ end
1279
+ else
1280
+ local array = entries
1281
+ for ____, kvp in ipairs(array) do
1282
+ self:set(kvp[1], kvp[2])
1283
+ end
1284
+ end
1285
+ end
1286
+ function Map.prototype.clear(self)
1287
+ self.items = {}
1288
+ self.nextKey = {}
1289
+ self.previousKey = {}
1290
+ self.firstKey = nil
1291
+ self.lastKey = nil
1292
+ self.size = 0
1293
+ end
1294
+ function Map.prototype.delete(self, key)
1295
+ local contains = self:has(key)
1296
+ if contains then
1297
+ self.size = self.size - 1
1298
+ local next = self.nextKey[key]
1299
+ local previous = self.previousKey[key]
1300
+ if next and previous then
1301
+ self.nextKey[previous] = next
1302
+ self.previousKey[next] = previous
1303
+ elseif next then
1304
+ self.firstKey = next
1305
+ self.previousKey[next] = nil
1306
+ elseif previous then
1307
+ self.lastKey = previous
1308
+ self.nextKey[previous] = nil
1309
+ else
1310
+ self.firstKey = nil
1311
+ self.lastKey = nil
1312
+ end
1313
+ self.nextKey[key] = nil
1314
+ self.previousKey[key] = nil
1315
+ end
1316
+ self.items[key] = nil
1317
+ return contains
1318
+ end
1319
+ function Map.prototype.forEach(self, callback)
1320
+ for ____, key in __TS__Iterator(self:keys()) do
1321
+ callback(nil, self.items[key], key, self)
1322
+ end
1323
+ end
1324
+ function Map.prototype.get(self, key)
1325
+ return self.items[key]
1326
+ end
1327
+ function Map.prototype.has(self, key)
1328
+ return self.nextKey[key] ~= nil or self.lastKey == key
1329
+ end
1330
+ function Map.prototype.set(self, key, value)
1331
+ local isNewValue = not self:has(key)
1332
+ if isNewValue then
1333
+ self.size = self.size + 1
1334
+ end
1335
+ self.items[key] = value
1336
+ if self.firstKey == nil then
1337
+ self.firstKey = key
1338
+ self.lastKey = key
1339
+ elseif isNewValue then
1340
+ self.nextKey[self.lastKey] = key
1341
+ self.previousKey[key] = self.lastKey
1342
+ self.lastKey = key
1343
+ end
1344
+ return self
1345
+ end
1346
+ Map.prototype[Symbol.iterator] = function(self)
1347
+ return self:entries()
1348
+ end
1349
+ function Map.prototype.entries(self)
1350
+ local items = self.items
1351
+ local nextKey = self.nextKey
1352
+ local key = self.firstKey
1353
+ return {
1354
+ [Symbol.iterator] = function(self)
1355
+ return self
1356
+ end,
1357
+ next = function(self)
1358
+ local result = {done = not key, value = {key, items[key]}}
1359
+ key = nextKey[key]
1360
+ return result
1361
+ end
1362
+ }
1363
+ end
1364
+ function Map.prototype.keys(self)
1365
+ local nextKey = self.nextKey
1366
+ local key = self.firstKey
1367
+ return {
1368
+ [Symbol.iterator] = function(self)
1369
+ return self
1370
+ end,
1371
+ next = function(self)
1372
+ local result = {done = not key, value = key}
1373
+ key = nextKey[key]
1374
+ return result
1375
+ end
1376
+ }
1377
+ end
1378
+ function Map.prototype.values(self)
1379
+ local items = self.items
1380
+ local nextKey = self.nextKey
1381
+ local key = self.firstKey
1382
+ return {
1383
+ [Symbol.iterator] = function(self)
1384
+ return self
1385
+ end,
1386
+ next = function(self)
1387
+ local result = {done = not key, value = items[key]}
1388
+ key = nextKey[key]
1389
+ return result
1390
+ end
1391
+ }
1392
+ end
1393
+ Map[Symbol.species] = Map
1394
+ end
1395
+
1396
+ local function __TS__StringSlice(self, start, ____end)
1397
+ if start == nil or start ~= start then
1398
+ start = 0
1399
+ end
1400
+ if ____end ~= ____end then
1401
+ ____end = 0
1402
+ end
1403
+ if start >= 0 then
1404
+ start = start + 1
1405
+ end
1406
+ if ____end ~= nil and ____end < 0 then
1407
+ ____end = ____end - 1
1408
+ end
1409
+ return string.sub(self, start, ____end)
1410
+ end
1411
+
1412
+ local function __TS__Match(s, pattern, init)
1413
+ local ____temp_0 = {string.find(s, pattern, init)}
1414
+ local start = ____temp_0[1]
1415
+ local ____end = ____temp_0[2]
1416
+ local captures = __TS__ArraySlice(____temp_0, 2)
1417
+ if start == nil or ____end == nil then
1418
+ return
1419
+ elseif table.getn(captures) <= 0 then
1420
+ return __TS__StringSlice(s, start - 1, ____end)
1421
+ else
1422
+ return unpack(captures)
1423
+ end
1424
+ end
1425
+
1426
+ local __TS__MathAtan2 = math.atan2 or math.atan
1427
+
1428
+ local function __TS__MathModf(x)
1429
+ local ____temp_0
1430
+ if x > 0 then
1431
+ ____temp_0 = math.floor(x)
1432
+ else
1433
+ ____temp_0 = math.ceil(x)
1434
+ end
1435
+ local integral = ____temp_0
1436
+ return integral, x - integral
1437
+ end
1438
+
1439
+ local function __TS__MathSign(val)
1440
+ if val > 0 then
1441
+ return 1
1442
+ elseif val < 0 then
1443
+ return -1
1444
+ end
1445
+ return 0
1446
+ end
1447
+
1448
+ local function __TS__Modulo50(a, b)
1449
+ return a - math.floor(a / b) * b
1450
+ end
1451
+
1452
+ local function __TS__Number(value)
1453
+ local valueType = type(value)
1454
+ if valueType == "number" then
1455
+ return value
1456
+ elseif valueType == "string" then
1457
+ local numberValue = tonumber(value)
1458
+ if numberValue then
1459
+ return numberValue
1460
+ end
1461
+ if value == "Infinity" then
1462
+ return 1 / 0
1463
+ end
1464
+ if value == "-Infinity" then
1465
+ return -(1 / 0)
1466
+ end
1467
+ local stringWithoutSpaces = string.gsub(value, "%s", "")
1468
+ if stringWithoutSpaces == "" then
1469
+ return 0
1470
+ end
1471
+ return 0 / 0
1472
+ elseif valueType == "boolean" then
1473
+ return value and 1 or 0
1474
+ else
1475
+ return 0 / 0
1476
+ end
1477
+ end
1478
+
1479
+ local function __TS__NumberIsFinite(value)
1480
+ return type(value) == "number" and value == value and value ~= 1 / 0 and value ~= -(1 / 0)
1481
+ end
1482
+
1483
+ local function __TS__NumberIsNaN(value)
1484
+ return value ~= value
1485
+ end
1486
+
1487
+ local __TS__NumberToString
1488
+ do
1489
+ local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
1490
+ function __TS__NumberToString(self, radix)
1491
+ if radix == nil or radix == 10 or self == 1 / 0 or self == -(1 / 0) or self ~= self then
1492
+ return tostring(self)
1493
+ end
1494
+ radix = math.floor(radix)
1495
+ if radix < 2 or radix > 36 then
1496
+ error("toString() radix argument must be between 2 and 36", 0)
1497
+ end
1498
+ local integer, fraction = __TS__MathModf(math.abs(self))
1499
+ local result = ""
1500
+ if radix == 8 then
1501
+ result = string.format("%o", integer)
1502
+ elseif radix == 16 then
1503
+ result = string.format("%x", integer)
1504
+ else
1505
+ repeat
1506
+ do
1507
+ result = __TS__StringAccess(
1508
+ radixChars,
1509
+ __TS__Modulo50(integer, radix)
1510
+ ) .. result
1511
+ integer = math.floor(integer / radix)
1512
+ end
1513
+ until not (integer ~= 0)
1514
+ end
1515
+ if fraction ~= 0 then
1516
+ result = result .. "."
1517
+ local delta = 1e-16
1518
+ repeat
1519
+ do
1520
+ fraction = fraction * radix
1521
+ delta = delta * radix
1522
+ local digit = math.floor(fraction)
1523
+ result = result .. __TS__StringAccess(radixChars, digit)
1524
+ fraction = fraction - digit
1525
+ end
1526
+ until not (fraction >= delta)
1527
+ end
1528
+ if self < 0 then
1529
+ result = "-" .. result
1530
+ end
1531
+ return result
1532
+ end
1533
+ end
1534
+
1535
+ local function __TS__ObjectDefineProperty(target, key, desc)
1536
+ local ____temp_0
1537
+ if type(key) == "number" then
1538
+ ____temp_0 = key + 1
1539
+ else
1540
+ ____temp_0 = key
1541
+ end
1542
+ local luaKey = ____temp_0
1543
+ local value = rawget(target, luaKey)
1544
+ local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
1545
+ local descriptor
1546
+ if hasGetterOrSetter then
1547
+ if value ~= nil then
1548
+ error(
1549
+ "Cannot redefine property: " .. tostring(key),
1550
+ 0
1551
+ )
1552
+ end
1553
+ descriptor = desc
1554
+ else
1555
+ local valueExists = value ~= nil
1556
+ local ____desc_set_5 = desc.set
1557
+ local ____desc_get_6 = desc.get
1558
+ local ____temp_1
1559
+ if desc.configurable ~= nil then
1560
+ ____temp_1 = desc.configurable
1561
+ else
1562
+ ____temp_1 = valueExists
1563
+ end
1564
+ local ____temp_2
1565
+ if desc.enumerable ~= nil then
1566
+ ____temp_2 = desc.enumerable
1567
+ else
1568
+ ____temp_2 = valueExists
1569
+ end
1570
+ local ____temp_3
1571
+ if desc.writable ~= nil then
1572
+ ____temp_3 = desc.writable
1573
+ else
1574
+ ____temp_3 = valueExists
1575
+ end
1576
+ local ____temp_4
1577
+ if desc.value ~= nil then
1578
+ ____temp_4 = desc.value
1579
+ else
1580
+ ____temp_4 = value
1581
+ end
1582
+ descriptor = {
1583
+ set = ____desc_set_5,
1584
+ get = ____desc_get_6,
1585
+ configurable = ____temp_1,
1586
+ enumerable = ____temp_2,
1587
+ writable = ____temp_3,
1588
+ value = ____temp_4
1589
+ }
1590
+ end
1591
+ __TS__SetDescriptor(target, luaKey, descriptor)
1592
+ return target
1593
+ end
1594
+
1595
+ local function __TS__ObjectEntries(obj)
1596
+ local result = {}
1597
+ local len = 0
1598
+ for key in pairs(obj) do
1599
+ len = len + 1
1600
+ result[len] = {key, obj[key]}
1601
+ end
1602
+ return result
1603
+ end
1604
+
1605
+ local function __TS__ObjectFromEntries(entries)
1606
+ local obj = {}
1607
+ local iterable = entries
1608
+ if iterable[Symbol.iterator] then
1609
+ local iterator = iterable[Symbol.iterator](iterable)
1610
+ while true do
1611
+ local result = iterator:next()
1612
+ if result.done then
1613
+ break
1614
+ end
1615
+ local value = result.value
1616
+ obj[value[1]] = value[2]
1617
+ end
1618
+ else
1619
+ for ____, entry in ipairs(entries) do
1620
+ obj[entry[1]] = entry[2]
1621
+ end
1622
+ end
1623
+ return obj
1624
+ end
1625
+
1626
+ local function __TS__ObjectKeys(obj)
1627
+ local result = {}
1628
+ local len = 0
1629
+ for key in pairs(obj) do
1630
+ len = len + 1
1631
+ result[len] = key
1632
+ end
1633
+ return result
1634
+ end
1635
+
1636
+ local function __TS__ObjectRest(target, usedProperties)
1637
+ local result = {}
1638
+ for property in pairs(target) do
1639
+ if not usedProperties[property] then
1640
+ result[property] = target[property]
1641
+ end
1642
+ end
1643
+ return result
1644
+ end
1645
+
1646
+ local function __TS__ObjectValues(obj)
1647
+ local result = {}
1648
+ local len = 0
1649
+ for key in pairs(obj) do
1650
+ len = len + 1
1651
+ result[len] = obj[key]
1652
+ end
1653
+ return result
1654
+ end
1655
+
1656
+ local function __TS__ParseFloat(numberString)
1657
+ local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
1658
+ if infinityMatch then
1659
+ local ____temp_0
1660
+ if __TS__StringAccess(infinityMatch, 0) == "-" then
1661
+ ____temp_0 = -(1 / 0)
1662
+ else
1663
+ ____temp_0 = 1 / 0
1664
+ end
1665
+ return ____temp_0
1666
+ end
1667
+ local number = tonumber(__TS__Match(numberString, "^%s*(-?%d+%.?%d*)"))
1668
+ local ____number_1 = number
1669
+ if ____number_1 == nil then
1670
+ ____number_1 = 0 / 0
1671
+ end
1672
+ return ____number_1
1673
+ end
1674
+
1675
+ local function __TS__StringSubstr(self, from, length)
1676
+ if from ~= from then
1677
+ from = 0
1678
+ end
1679
+ if length ~= nil then
1680
+ if length ~= length or length <= 0 then
1681
+ return ""
1682
+ end
1683
+ length = length + from
1684
+ end
1685
+ if from >= 0 then
1686
+ from = from + 1
1687
+ end
1688
+ return string.sub(self, from, length)
1689
+ end
1690
+
1691
+ local function __TS__StringSubstring(self, start, ____end)
1692
+ if ____end ~= ____end then
1693
+ ____end = 0
1694
+ end
1695
+ if ____end ~= nil and start > ____end then
1696
+ start, ____end = ____end, start
1697
+ end
1698
+ if start >= 0 then
1699
+ start = start + 1
1700
+ else
1701
+ start = 1
1702
+ end
1703
+ if ____end ~= nil and ____end < 0 then
1704
+ ____end = 0
1705
+ end
1706
+ return string.sub(self, start, ____end)
1707
+ end
1708
+
1709
+ local __TS__ParseInt
1710
+ do
1711
+ local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
1712
+ function __TS__ParseInt(numberString, base)
1713
+ if base == nil then
1714
+ base = 10
1715
+ local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
1716
+ if hexMatch then
1717
+ base = 16
1718
+ local ____TS__Match_result__0_0
1719
+ if __TS__Match(hexMatch, "-") then
1720
+ ____TS__Match_result__0_0 = "-" .. __TS__StringSubstr(
1721
+ numberString,
1722
+ string.len(hexMatch)
1723
+ )
1724
+ else
1725
+ ____TS__Match_result__0_0 = __TS__StringSubstr(
1726
+ numberString,
1727
+ string.len(hexMatch)
1728
+ )
1729
+ end
1730
+ numberString = ____TS__Match_result__0_0
1731
+ end
1732
+ end
1733
+ if base < 2 or base > 36 then
1734
+ return 0 / 0
1735
+ end
1736
+ local ____temp_1
1737
+ if base <= 10 then
1738
+ ____temp_1 = __TS__StringSubstring(parseIntBasePattern, 0, base)
1739
+ else
1740
+ ____temp_1 = __TS__StringSubstr(parseIntBasePattern, 0, 10 + 2 * (base - 10))
1741
+ end
1742
+ local allowedDigits = ____temp_1
1743
+ local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
1744
+ local number = tonumber(
1745
+ __TS__Match(numberString, pattern),
1746
+ base
1747
+ )
1748
+ if number == nil then
1749
+ return 0 / 0
1750
+ end
1751
+ if number >= 0 then
1752
+ return math.floor(number)
1753
+ else
1754
+ return math.ceil(number)
1755
+ end
1756
+ end
1757
+ end
1758
+
1759
+ local function __TS__PromiseAll(iterable)
1760
+ local results = {}
1761
+ local toResolve = {}
1762
+ local numToResolve = 0
1763
+ local i = 0
1764
+ for ____, item in __TS__Iterator(iterable) do
1765
+ if __TS__InstanceOf(item, __TS__Promise) then
1766
+ if item.state == 1 then
1767
+ results[i + 1] = item.value
1768
+ elseif item.state == 2 then
1769
+ return __TS__Promise.reject(item.rejectionReason)
1770
+ else
1771
+ numToResolve = numToResolve + 1
1772
+ toResolve[i] = item
1773
+ end
1774
+ else
1775
+ results[i + 1] = item
1776
+ end
1777
+ i = i + 1
1778
+ end
1779
+ if numToResolve == 0 then
1780
+ return __TS__Promise.resolve(results)
1781
+ end
1782
+ return __TS__New(
1783
+ __TS__Promise,
1784
+ function(____, resolve, reject)
1785
+ for index, promise in pairs(toResolve) do
1786
+ promise["then"](
1787
+ promise,
1788
+ function(____, data)
1789
+ results[index + 1] = data
1790
+ numToResolve = numToResolve - 1
1791
+ if numToResolve == 0 then
1792
+ resolve(nil, results)
1793
+ end
1794
+ end,
1795
+ function(____, reason)
1796
+ reject(nil, reason)
1797
+ end
1798
+ )
1799
+ end
1800
+ end
1801
+ )
1802
+ end
1803
+
1804
+ local function __TS__PromiseAllSettled(iterable)
1805
+ local results = {}
1806
+ local toResolve = {}
1807
+ local numToResolve = 0
1808
+ local i = 0
1809
+ for ____, item in __TS__Iterator(iterable) do
1810
+ if __TS__InstanceOf(item, __TS__Promise) then
1811
+ if item.state == 1 then
1812
+ results[i + 1] = {status = "fulfilled", value = item.value}
1813
+ elseif item.state == 2 then
1814
+ results[i + 1] = {status = "rejected", reason = item.rejectionReason}
1815
+ else
1816
+ numToResolve = numToResolve + 1
1817
+ toResolve[i] = item
1818
+ end
1819
+ else
1820
+ results[i + 1] = {status = "fulfilled", value = item}
1821
+ end
1822
+ i = i + 1
1823
+ end
1824
+ if numToResolve == 0 then
1825
+ return __TS__Promise.resolve(results)
1826
+ end
1827
+ return __TS__New(
1828
+ __TS__Promise,
1829
+ function(____, resolve)
1830
+ for index, promise in pairs(toResolve) do
1831
+ promise["then"](
1832
+ promise,
1833
+ function(____, data)
1834
+ results[index + 1] = {status = "fulfilled", value = data}
1835
+ numToResolve = numToResolve - 1
1836
+ if numToResolve == 0 then
1837
+ resolve(nil, results)
1838
+ end
1839
+ end,
1840
+ function(____, reason)
1841
+ results[index + 1] = {status = "rejected", reason = reason}
1842
+ numToResolve = numToResolve - 1
1843
+ if numToResolve == 0 then
1844
+ resolve(nil, results)
1845
+ end
1846
+ end
1847
+ )
1848
+ end
1849
+ end
1850
+ )
1851
+ end
1852
+
1853
+ local function __TS__PromiseAny(iterable)
1854
+ local rejections = {}
1855
+ local pending = {}
1856
+ for ____, item in __TS__Iterator(iterable) do
1857
+ if __TS__InstanceOf(item, __TS__Promise) then
1858
+ if item.state == 1 then
1859
+ return __TS__Promise.resolve(item.value)
1860
+ elseif item.state == 2 then
1861
+ rejections[table.getn(rejections) + 1] = item.rejectionReason
1862
+ else
1863
+ pending[table.getn(pending) + 1] = item
1864
+ end
1865
+ else
1866
+ return __TS__Promise.resolve(item)
1867
+ end
1868
+ end
1869
+ if table.getn(pending) == 0 then
1870
+ return __TS__Promise.reject("No promises to resolve with .any()")
1871
+ end
1872
+ local numResolved = 0
1873
+ return __TS__New(
1874
+ __TS__Promise,
1875
+ function(____, resolve, reject)
1876
+ for ____, promise in ipairs(pending) do
1877
+ promise["then"](
1878
+ promise,
1879
+ function(____, data)
1880
+ resolve(nil, data)
1881
+ end,
1882
+ function(____, reason)
1883
+ rejections[table.getn(rejections) + 1] = reason
1884
+ numResolved = numResolved + 1
1885
+ if numResolved == table.getn(pending) then
1886
+ reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
1887
+ end
1888
+ end
1889
+ )
1890
+ end
1891
+ end
1892
+ )
1893
+ end
1894
+
1895
+ local function __TS__PromiseRace(iterable)
1896
+ local pending = {}
1897
+ for ____, item in __TS__Iterator(iterable) do
1898
+ if __TS__InstanceOf(item, __TS__Promise) then
1899
+ if item.state == 1 then
1900
+ return __TS__Promise.resolve(item.value)
1901
+ elseif item.state == 2 then
1902
+ return __TS__Promise.reject(item.rejectionReason)
1903
+ else
1904
+ pending[table.getn(pending) + 1] = item
1905
+ end
1906
+ else
1907
+ return __TS__Promise.resolve(item)
1908
+ end
1909
+ end
1910
+ return __TS__New(
1911
+ __TS__Promise,
1912
+ function(____, resolve, reject)
1913
+ for ____, promise in ipairs(pending) do
1914
+ promise["then"](
1915
+ promise,
1916
+ function(____, value) return resolve(nil, value) end,
1917
+ function(____, reason) return reject(nil, reason) end
1918
+ )
1919
+ end
1920
+ end
1921
+ )
1922
+ end
1923
+
1924
+ local Set
1925
+ do
1926
+ Set = __TS__Class()
1927
+ Set.name = "Set"
1928
+ function Set.prototype.____constructor(self, values)
1929
+ self[Symbol.toStringTag] = "Set"
1930
+ self.size = 0
1931
+ self.nextKey = {}
1932
+ self.previousKey = {}
1933
+ if values == nil then
1934
+ return
1935
+ end
1936
+ local iterable = values
1937
+ if iterable[Symbol.iterator] then
1938
+ local iterator = iterable[Symbol.iterator](iterable)
1939
+ while true do
1940
+ local result = iterator:next()
1941
+ if result.done then
1942
+ break
1943
+ end
1944
+ self:add(result.value)
1945
+ end
1946
+ else
1947
+ local array = values
1948
+ for ____, value in ipairs(array) do
1949
+ self:add(value)
1950
+ end
1951
+ end
1952
+ end
1953
+ function Set.prototype.add(self, value)
1954
+ local isNewValue = not self:has(value)
1955
+ if isNewValue then
1956
+ self.size = self.size + 1
1957
+ end
1958
+ if self.firstKey == nil then
1959
+ self.firstKey = value
1960
+ self.lastKey = value
1961
+ elseif isNewValue then
1962
+ self.nextKey[self.lastKey] = value
1963
+ self.previousKey[value] = self.lastKey
1964
+ self.lastKey = value
1965
+ end
1966
+ return self
1967
+ end
1968
+ function Set.prototype.clear(self)
1969
+ self.nextKey = {}
1970
+ self.previousKey = {}
1971
+ self.firstKey = nil
1972
+ self.lastKey = nil
1973
+ self.size = 0
1974
+ end
1975
+ function Set.prototype.delete(self, value)
1976
+ local contains = self:has(value)
1977
+ if contains then
1978
+ self.size = self.size - 1
1979
+ local next = self.nextKey[value]
1980
+ local previous = self.previousKey[value]
1981
+ if next and previous then
1982
+ self.nextKey[previous] = next
1983
+ self.previousKey[next] = previous
1984
+ elseif next then
1985
+ self.firstKey = next
1986
+ self.previousKey[next] = nil
1987
+ elseif previous then
1988
+ self.lastKey = previous
1989
+ self.nextKey[previous] = nil
1990
+ else
1991
+ self.firstKey = nil
1992
+ self.lastKey = nil
1993
+ end
1994
+ self.nextKey[value] = nil
1995
+ self.previousKey[value] = nil
1996
+ end
1997
+ return contains
1998
+ end
1999
+ function Set.prototype.forEach(self, callback)
2000
+ for ____, key in __TS__Iterator(self:keys()) do
2001
+ callback(nil, key, key, self)
2002
+ end
2003
+ end
2004
+ function Set.prototype.has(self, value)
2005
+ return self.nextKey[value] ~= nil or self.lastKey == value
2006
+ end
2007
+ Set.prototype[Symbol.iterator] = function(self)
2008
+ return self:values()
2009
+ end
2010
+ function Set.prototype.entries(self)
2011
+ local nextKey = self.nextKey
2012
+ local key = self.firstKey
2013
+ return {
2014
+ [Symbol.iterator] = function(self)
2015
+ return self
2016
+ end,
2017
+ next = function(self)
2018
+ local result = {done = not key, value = {key, key}}
2019
+ key = nextKey[key]
2020
+ return result
2021
+ end
2022
+ }
2023
+ end
2024
+ function Set.prototype.keys(self)
2025
+ local nextKey = self.nextKey
2026
+ local key = self.firstKey
2027
+ return {
2028
+ [Symbol.iterator] = function(self)
2029
+ return self
2030
+ end,
2031
+ next = function(self)
2032
+ local result = {done = not key, value = key}
2033
+ key = nextKey[key]
2034
+ return result
2035
+ end
2036
+ }
2037
+ end
2038
+ function Set.prototype.values(self)
2039
+ local nextKey = self.nextKey
2040
+ local key = self.firstKey
2041
+ return {
2042
+ [Symbol.iterator] = function(self)
2043
+ return self
2044
+ end,
2045
+ next = function(self)
2046
+ local result = {done = not key, value = key}
2047
+ key = nextKey[key]
2048
+ return result
2049
+ end
2050
+ }
2051
+ end
2052
+ Set[Symbol.species] = Set
2053
+ end
2054
+
2055
+ local function __TS__SparseArrayNew(...)
2056
+ local sparseArray = {unpack(arg)}
2057
+ sparseArray.sparseLength = __TS__CountVarargs(unpack(arg))
2058
+ return sparseArray
2059
+ end
2060
+
2061
+ local function __TS__SparseArrayPush(sparseArray, ...)
2062
+ local args = arg
2063
+ local argsLen = __TS__CountVarargs(unpack(arg))
2064
+ local listLen = sparseArray.sparseLength
2065
+ for i = 1, argsLen do
2066
+ sparseArray[listLen + i] = args[i]
2067
+ end
2068
+ sparseArray.sparseLength = listLen + argsLen
2069
+ end
2070
+
2071
+ local function __TS__SparseArraySpread(sparseArray)
2072
+ return unpack(nil, sparseArray, 1, sparseArray.sparseLength)
2073
+ end
2074
+
2075
+ local WeakMap
2076
+ do
2077
+ WeakMap = __TS__Class()
2078
+ WeakMap.name = "WeakMap"
2079
+ function WeakMap.prototype.____constructor(self, entries)
2080
+ self[Symbol.toStringTag] = "WeakMap"
2081
+ self.items = {}
2082
+ setmetatable(self.items, {__mode = "k"})
2083
+ if entries == nil then
2084
+ return
2085
+ end
2086
+ local iterable = entries
2087
+ if iterable[Symbol.iterator] then
2088
+ local iterator = iterable[Symbol.iterator](iterable)
2089
+ while true do
2090
+ local result = iterator:next()
2091
+ if result.done then
2092
+ break
2093
+ end
2094
+ local value = result.value
2095
+ self.items[value[1]] = value[2]
2096
+ end
2097
+ else
2098
+ for ____, kvp in ipairs(entries) do
2099
+ self.items[kvp[1]] = kvp[2]
2100
+ end
2101
+ end
2102
+ end
2103
+ function WeakMap.prototype.delete(self, key)
2104
+ local contains = self:has(key)
2105
+ self.items[key] = nil
2106
+ return contains
2107
+ end
2108
+ function WeakMap.prototype.get(self, key)
2109
+ return self.items[key]
2110
+ end
2111
+ function WeakMap.prototype.has(self, key)
2112
+ return self.items[key] ~= nil
2113
+ end
2114
+ function WeakMap.prototype.set(self, key, value)
2115
+ self.items[key] = value
2116
+ return self
2117
+ end
2118
+ WeakMap[Symbol.species] = WeakMap
2119
+ end
2120
+
2121
+ local WeakSet
2122
+ do
2123
+ WeakSet = __TS__Class()
2124
+ WeakSet.name = "WeakSet"
2125
+ function WeakSet.prototype.____constructor(self, values)
2126
+ self[Symbol.toStringTag] = "WeakSet"
2127
+ self.items = {}
2128
+ setmetatable(self.items, {__mode = "k"})
2129
+ if values == nil then
2130
+ return
2131
+ end
2132
+ local iterable = values
2133
+ if iterable[Symbol.iterator] then
2134
+ local iterator = iterable[Symbol.iterator](iterable)
2135
+ while true do
2136
+ local result = iterator:next()
2137
+ if result.done then
2138
+ break
2139
+ end
2140
+ self.items[result.value] = true
2141
+ end
2142
+ else
2143
+ for ____, value in ipairs(values) do
2144
+ self.items[value] = true
2145
+ end
2146
+ end
2147
+ end
2148
+ function WeakSet.prototype.add(self, value)
2149
+ self.items[value] = true
2150
+ return self
2151
+ end
2152
+ function WeakSet.prototype.delete(self, value)
2153
+ local contains = self:has(value)
2154
+ self.items[value] = nil
2155
+ return contains
2156
+ end
2157
+ function WeakSet.prototype.has(self, value)
2158
+ return self.items[value] == true
2159
+ end
2160
+ WeakSet[Symbol.species] = WeakSet
2161
+ end
2162
+
2163
+ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2164
+ _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
2165
+ _G.__TS__sourcemap[fileName] = sourceMap
2166
+ if _G.__TS__originalTraceback == nil then
2167
+ local originalTraceback = debug.traceback
2168
+ _G.__TS__originalTraceback = originalTraceback
2169
+ debug.traceback = function(thread, message, level)
2170
+ local trace
2171
+ if thread == nil and message == nil and level == nil then
2172
+ trace = originalTraceback()
2173
+ elseif __TS__StringIncludes(_VERSION, "Lua 5.0") then
2174
+ trace = originalTraceback((("[Level " .. tostring(level)) .. "] ") .. tostring(message))
2175
+ else
2176
+ trace = originalTraceback(thread, message, level)
2177
+ end
2178
+ if type(trace) ~= "string" then
2179
+ return trace
2180
+ end
2181
+ local function replacer(____, file, srcFile, line)
2182
+ local fileSourceMap = _G.__TS__sourcemap[file]
2183
+ if fileSourceMap and fileSourceMap[line] then
2184
+ local data = fileSourceMap[line]
2185
+ if type(data) == "number" then
2186
+ return (srcFile .. ":") .. tostring(data)
2187
+ end
2188
+ return (tostring(data.file) .. ":") .. tostring(data.line)
2189
+ end
2190
+ return (file .. ":") .. line
2191
+ end
2192
+ local result = string.gsub(
2193
+ trace,
2194
+ "(%S+)%.lua:(%d+)",
2195
+ function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
2196
+ )
2197
+ local function stringReplacer(____, file, line)
2198
+ local fileSourceMap = _G.__TS__sourcemap[file]
2199
+ if fileSourceMap and fileSourceMap[line] then
2200
+ local chunkName = __TS__Match(file, "%[string \"([^\"]+)\"%]")
2201
+ local sourceName = string.gsub(chunkName, ".lua$", ".ts")
2202
+ local data = fileSourceMap[line]
2203
+ if type(data) == "number" then
2204
+ return (sourceName .. ":") .. tostring(data)
2205
+ end
2206
+ return (tostring(data.file) .. ":") .. tostring(data.line)
2207
+ end
2208
+ return (file .. ":") .. line
2209
+ end
2210
+ result = string.gsub(
2211
+ result,
2212
+ "(%[string \"[^\"]+\"%]):(%d+)",
2213
+ function(file, line) return stringReplacer(nil, file, line) end
2214
+ )
2215
+ return result
2216
+ end
2217
+ end
2218
+ end
2219
+
2220
+ local function __TS__StringCharAt(self, pos)
2221
+ if pos ~= pos then
2222
+ pos = 0
2223
+ end
2224
+ if pos < 0 then
2225
+ return ""
2226
+ end
2227
+ return string.sub(self, pos + 1, pos + 1)
2228
+ end
2229
+
2230
+ local function __TS__StringCharCodeAt(self, index)
2231
+ if index ~= index then
2232
+ index = 0
2233
+ end
2234
+ if index < 0 then
2235
+ return 0 / 0
2236
+ end
2237
+ local ____string_byte_result_0 = string.byte(self, index + 1)
2238
+ if ____string_byte_result_0 == nil then
2239
+ ____string_byte_result_0 = 0 / 0
2240
+ end
2241
+ return ____string_byte_result_0
2242
+ end
2243
+
2244
+ local function __TS__StringEndsWith(self, searchString, endPosition)
2245
+ if endPosition == nil or endPosition > string.len(self) then
2246
+ endPosition = string.len(self)
2247
+ end
2248
+ return string.sub(
2249
+ self,
2250
+ endPosition - string.len(searchString) + 1,
2251
+ endPosition
2252
+ ) == searchString
2253
+ end
2254
+
2255
+ local function __TS__StringPadEnd(self, maxLength, fillString)
2256
+ if fillString == nil then
2257
+ fillString = " "
2258
+ end
2259
+ if maxLength ~= maxLength then
2260
+ maxLength = 0
2261
+ end
2262
+ if maxLength == -(1 / 0) or maxLength == 1 / 0 then
2263
+ error("Invalid string length", 0)
2264
+ end
2265
+ if string.len(self) >= maxLength or string.len(fillString) == 0 then
2266
+ return self
2267
+ end
2268
+ maxLength = maxLength - string.len(self)
2269
+ if maxLength > string.len(fillString) then
2270
+ fillString = fillString .. string.rep(
2271
+ fillString,
2272
+ math.floor(maxLength / string.len(fillString))
2273
+ )
2274
+ end
2275
+ return self .. string.sub(
2276
+ fillString,
2277
+ 1,
2278
+ math.floor(maxLength)
2279
+ )
2280
+ end
2281
+
2282
+ local function __TS__StringPadStart(self, maxLength, fillString)
2283
+ if fillString == nil then
2284
+ fillString = " "
2285
+ end
2286
+ if maxLength ~= maxLength then
2287
+ maxLength = 0
2288
+ end
2289
+ if maxLength == -(1 / 0) or maxLength == 1 / 0 then
2290
+ error("Invalid string length", 0)
2291
+ end
2292
+ if string.len(self) >= maxLength or string.len(fillString) == 0 then
2293
+ return self
2294
+ end
2295
+ maxLength = maxLength - string.len(self)
2296
+ if maxLength > string.len(fillString) then
2297
+ fillString = fillString .. string.rep(
2298
+ fillString,
2299
+ math.floor(maxLength / string.len(fillString))
2300
+ )
2301
+ end
2302
+ return string.sub(
2303
+ fillString,
2304
+ 1,
2305
+ math.floor(maxLength)
2306
+ ) .. self
2307
+ end
2308
+
2309
+ local __TS__StringReplace
2310
+ do
2311
+ local sub = string.sub
2312
+ function __TS__StringReplace(source, searchValue, replaceValue)
2313
+ local startPos, endPos = string.find(source, searchValue, nil, true)
2314
+ if not startPos then
2315
+ return source
2316
+ end
2317
+ local before = sub(source, 1, startPos - 1)
2318
+ local ____temp_0
2319
+ if type(replaceValue) == "string" then
2320
+ ____temp_0 = replaceValue
2321
+ else
2322
+ ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
2323
+ end
2324
+ local replacement = ____temp_0
2325
+ local after = sub(source, endPos + 1)
2326
+ return (before .. replacement) .. after
2327
+ end
2328
+ end
2329
+
2330
+ local __TS__StringSplit
2331
+ do
2332
+ local sub = string.sub
2333
+ local find = string.find
2334
+ function __TS__StringSplit(source, separator, limit)
2335
+ if limit == nil then
2336
+ limit = 4294967295
2337
+ end
2338
+ if limit == 0 then
2339
+ return {}
2340
+ end
2341
+ local result = {}
2342
+ local resultIndex = 1
2343
+ if separator == nil or separator == "" then
2344
+ for i = 1, string.len(source) do
2345
+ result[resultIndex] = sub(source, i, i)
2346
+ resultIndex = resultIndex + 1
2347
+ end
2348
+ else
2349
+ local currentPos = 1
2350
+ while resultIndex <= limit do
2351
+ local startPos, endPos = find(source, separator, currentPos, true)
2352
+ if not startPos then
2353
+ break
2354
+ end
2355
+ result[resultIndex] = sub(source, currentPos, startPos - 1)
2356
+ resultIndex = resultIndex + 1
2357
+ currentPos = endPos + 1
2358
+ end
2359
+ if resultIndex <= limit then
2360
+ result[resultIndex] = sub(source, currentPos)
2361
+ end
2362
+ end
2363
+ return result
2364
+ end
2365
+ end
2366
+
2367
+ local __TS__StringReplaceAll
2368
+ do
2369
+ local sub = string.sub
2370
+ local find = string.find
2371
+ function __TS__StringReplaceAll(source, searchValue, replaceValue)
2372
+ if type(replaceValue) == "string" then
2373
+ local concat = table.concat(
2374
+ __TS__StringSplit(source, searchValue),
2375
+ replaceValue
2376
+ )
2377
+ if string.len(searchValue) == 0 then
2378
+ return (replaceValue .. concat) .. replaceValue
2379
+ end
2380
+ return concat
2381
+ end
2382
+ local parts = {}
2383
+ local partsIndex = 1
2384
+ if string.len(searchValue) == 0 then
2385
+ parts[1] = replaceValue(nil, "", 0, source)
2386
+ partsIndex = 2
2387
+ for i = 1, string.len(source) do
2388
+ parts[partsIndex] = sub(source, i, i)
2389
+ parts[partsIndex + 1] = replaceValue(nil, "", i, source)
2390
+ partsIndex = partsIndex + 2
2391
+ end
2392
+ else
2393
+ local currentPos = 1
2394
+ while true do
2395
+ local startPos, endPos = find(source, searchValue, currentPos, true)
2396
+ if not startPos then
2397
+ break
2398
+ end
2399
+ parts[partsIndex] = sub(source, currentPos, startPos - 1)
2400
+ parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source)
2401
+ partsIndex = partsIndex + 2
2402
+ currentPos = endPos + 1
2403
+ end
2404
+ parts[partsIndex] = sub(source, currentPos)
2405
+ end
2406
+ return table.concat(parts)
2407
+ end
2408
+ end
2409
+
2410
+ local function __TS__StringStartsWith(self, searchString, position)
2411
+ if position == nil or position < 0 then
2412
+ position = 0
2413
+ end
2414
+ return string.sub(
2415
+ self,
2416
+ position + 1,
2417
+ string.len(searchString) + position
2418
+ ) == searchString
2419
+ end
2420
+
2421
+ local function __TS__StringTrim(self)
2422
+ local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
2423
+ return result
2424
+ end
2425
+
2426
+ local function __TS__StringTrimEnd(self)
2427
+ local result = string.gsub(self, "[%s ]*$", "")
2428
+ return result
2429
+ end
2430
+
2431
+ local function __TS__StringTrimStart(self)
2432
+ local result = string.gsub(self, "^[%s ]*", "")
2433
+ return result
2434
+ end
2435
+
2436
+ local __TS__SymbolRegistryFor, __TS__SymbolRegistryKeyFor
2437
+ do
2438
+ local symbolRegistry = {}
2439
+ function __TS__SymbolRegistryFor(key)
2440
+ if not symbolRegistry[key] then
2441
+ symbolRegistry[key] = __TS__Symbol(key)
2442
+ end
2443
+ return symbolRegistry[key]
2444
+ end
2445
+ function __TS__SymbolRegistryKeyFor(sym)
2446
+ for key in pairs(symbolRegistry) do
2447
+ if symbolRegistry[key] == sym then
2448
+ return key
2449
+ end
2450
+ end
2451
+ end
2452
+ end
2453
+
2454
+ local function __TS__TypeOf(value)
2455
+ local luaType = type(value)
2456
+ if luaType == "table" then
2457
+ return "object"
2458
+ elseif luaType == "nil" then
2459
+ return "undefined"
2460
+ else
2461
+ return luaType
2462
+ end
2463
+ end
2464
+
2465
+ return {
2466
+ __TS__ArrayConcat = __TS__ArrayConcat,
2467
+ __TS__ArrayEntries = __TS__ArrayEntries,
2468
+ __TS__ArrayEvery = __TS__ArrayEvery,
2469
+ __TS__ArrayFilter = __TS__ArrayFilter,
2470
+ __TS__ArrayForEach = __TS__ArrayForEach,
2471
+ __TS__ArrayFind = __TS__ArrayFind,
2472
+ __TS__ArrayFindIndex = __TS__ArrayFindIndex,
2473
+ __TS__ArrayFrom = __TS__ArrayFrom,
2474
+ __TS__ArrayIncludes = __TS__ArrayIncludes,
2475
+ __TS__ArrayIndexOf = __TS__ArrayIndexOf,
2476
+ __TS__ArrayIsArray = __TS__ArrayIsArray,
2477
+ __TS__ArrayJoin = __TS__ArrayJoin,
2478
+ __TS__ArrayMap = __TS__ArrayMap,
2479
+ __TS__ArrayPush = __TS__ArrayPush,
2480
+ __TS__ArrayPushArray = __TS__ArrayPushArray,
2481
+ __TS__ArrayReduce = __TS__ArrayReduce,
2482
+ __TS__ArrayReduceRight = __TS__ArrayReduceRight,
2483
+ __TS__ArrayReverse = __TS__ArrayReverse,
2484
+ __TS__ArrayUnshift = __TS__ArrayUnshift,
2485
+ __TS__ArraySort = __TS__ArraySort,
2486
+ __TS__ArraySlice = __TS__ArraySlice,
2487
+ __TS__ArraySome = __TS__ArraySome,
2488
+ __TS__ArraySplice = __TS__ArraySplice,
2489
+ __TS__ArrayToObject = __TS__ArrayToObject,
2490
+ __TS__ArrayFlat = __TS__ArrayFlat,
2491
+ __TS__ArrayFlatMap = __TS__ArrayFlatMap,
2492
+ __TS__ArraySetLength = __TS__ArraySetLength,
2493
+ __TS__AsyncAwaiter = __TS__AsyncAwaiter,
2494
+ __TS__Await = __TS__Await,
2495
+ __TS__Class = __TS__Class,
2496
+ __TS__ClassExtends = __TS__ClassExtends,
2497
+ __TS__CloneDescriptor = __TS__CloneDescriptor,
2498
+ __TS__CountVarargs = __TS__CountVarargs,
2499
+ __TS__Decorate = __TS__Decorate,
2500
+ __TS__DecorateParam = __TS__DecorateParam,
2501
+ __TS__Delete = __TS__Delete,
2502
+ __TS__DelegatedYield = __TS__DelegatedYield,
2503
+ Error = Error,
2504
+ RangeError = RangeError,
2505
+ ReferenceError = ReferenceError,
2506
+ SyntaxError = SyntaxError,
2507
+ TypeError = TypeError,
2508
+ URIError = URIError,
2509
+ __TS__FunctionBind = __TS__FunctionBind,
2510
+ __TS__Generator = __TS__Generator,
2511
+ __TS__InstanceOf = __TS__InstanceOf,
2512
+ __TS__InstanceOfObject = __TS__InstanceOfObject,
2513
+ __TS__Iterator = __TS__Iterator,
2514
+ __TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
2515
+ Map = Map,
2516
+ __TS__Match = __TS__Match,
2517
+ __TS__MathAtan2 = __TS__MathAtan2,
2518
+ __TS__MathModf = __TS__MathModf,
2519
+ __TS__MathSign = __TS__MathSign,
2520
+ __TS__Modulo50 = __TS__Modulo50,
2521
+ __TS__New = __TS__New,
2522
+ __TS__Number = __TS__Number,
2523
+ __TS__NumberIsFinite = __TS__NumberIsFinite,
2524
+ __TS__NumberIsNaN = __TS__NumberIsNaN,
2525
+ __TS__NumberToString = __TS__NumberToString,
2526
+ __TS__ObjectAssign = __TS__ObjectAssign,
2527
+ __TS__ObjectDefineProperty = __TS__ObjectDefineProperty,
2528
+ __TS__ObjectEntries = __TS__ObjectEntries,
2529
+ __TS__ObjectFromEntries = __TS__ObjectFromEntries,
2530
+ __TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor,
2531
+ __TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors,
2532
+ __TS__ObjectKeys = __TS__ObjectKeys,
2533
+ __TS__ObjectRest = __TS__ObjectRest,
2534
+ __TS__ObjectValues = __TS__ObjectValues,
2535
+ __TS__ParseFloat = __TS__ParseFloat,
2536
+ __TS__ParseInt = __TS__ParseInt,
2537
+ __TS__Promise = __TS__Promise,
2538
+ __TS__PromiseAll = __TS__PromiseAll,
2539
+ __TS__PromiseAllSettled = __TS__PromiseAllSettled,
2540
+ __TS__PromiseAny = __TS__PromiseAny,
2541
+ __TS__PromiseRace = __TS__PromiseRace,
2542
+ Set = Set,
2543
+ __TS__SetDescriptor = __TS__SetDescriptor,
2544
+ __TS__SparseArrayNew = __TS__SparseArrayNew,
2545
+ __TS__SparseArrayPush = __TS__SparseArrayPush,
2546
+ __TS__SparseArraySpread = __TS__SparseArraySpread,
2547
+ WeakMap = WeakMap,
2548
+ WeakSet = WeakSet,
2549
+ __TS__SourceMapTraceBack = __TS__SourceMapTraceBack,
2550
+ __TS__Spread = __TS__Spread,
2551
+ __TS__StringAccess = __TS__StringAccess,
2552
+ __TS__StringCharAt = __TS__StringCharAt,
2553
+ __TS__StringCharCodeAt = __TS__StringCharCodeAt,
2554
+ __TS__StringEndsWith = __TS__StringEndsWith,
2555
+ __TS__StringIncludes = __TS__StringIncludes,
2556
+ __TS__StringPadEnd = __TS__StringPadEnd,
2557
+ __TS__StringPadStart = __TS__StringPadStart,
2558
+ __TS__StringReplace = __TS__StringReplace,
2559
+ __TS__StringReplaceAll = __TS__StringReplaceAll,
2560
+ __TS__StringSlice = __TS__StringSlice,
2561
+ __TS__StringSplit = __TS__StringSplit,
2562
+ __TS__StringStartsWith = __TS__StringStartsWith,
2563
+ __TS__StringSubstr = __TS__StringSubstr,
2564
+ __TS__StringSubstring = __TS__StringSubstring,
2565
+ __TS__StringTrim = __TS__StringTrim,
2566
+ __TS__StringTrimEnd = __TS__StringTrimEnd,
2567
+ __TS__StringTrimStart = __TS__StringTrimStart,
2568
+ __TS__Symbol = __TS__Symbol,
2569
+ Symbol = Symbol,
2570
+ __TS__SymbolRegistryFor = __TS__SymbolRegistryFor,
2571
+ __TS__SymbolRegistryKeyFor = __TS__SymbolRegistryKeyFor,
2572
+ __TS__TypeOf = __TS__TypeOf,
2573
+ __TS__Unpack = __TS__Unpack
2574
+ }