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