typescript-to-lua 1.3.3 → 1.4.1

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