typescript-to-lua 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/CompilerOptions.d.ts +4 -3
- package/dist/LuaAST.d.ts +1 -0
- package/dist/LuaAST.js +14 -6
- package/dist/LuaLib.d.ts +4 -3
- package/dist/LuaLib.js +5 -4
- package/dist/LuaPrinter.d.ts +15 -4
- package/dist/LuaPrinter.js +79 -27
- package/dist/cli/diagnostics.js +2 -2
- package/dist/cli/parse.d.ts +1 -1
- package/dist/cli/parse.js +14 -0
- package/dist/cli/report.js +1 -1
- package/dist/cli/tsconfig.js +4 -4
- package/dist/lualib/ArrayFlat.lua +1 -1
- package/dist/lualib/ArrayFlatMap.lua +1 -1
- package/dist/lualib/ArrayIsArray.lua +1 -1
- package/dist/lualib/ArrayReduce.lua +7 -1
- package/dist/lualib/ArrayReduceRight.lua +7 -1
- package/dist/lualib/ArraySetLength.lua +1 -1
- package/dist/lualib/ArraySplice.lua +5 -5
- package/dist/lualib/Await.lua +39 -19
- package/dist/lualib/CloneDescriptor.lua +8 -8
- package/dist/lualib/Decorate.lua +1 -1
- package/dist/lualib/DelegatedYield.lua +1 -3
- package/dist/lualib/Delete.lua +6 -6
- package/dist/lualib/Error.lua +47 -44
- package/dist/lualib/Generator.lua +1 -5
- package/dist/lualib/InstanceOf.lua +1 -1
- package/dist/lualib/InstanceOfObject.lua +1 -1
- package/dist/lualib/Map.lua +130 -134
- package/dist/lualib/Number.lua +1 -1
- package/dist/lualib/NumberIsFinite.lua +1 -1
- package/dist/lualib/NumberToString.lua +3 -5
- package/dist/lualib/ObjectDefineProperty.lua +40 -8
- package/dist/lualib/ParseFloat.lua +9 -5
- package/dist/lualib/ParseInt.lua +15 -3
- package/dist/lualib/Promise.lua +36 -26
- package/dist/lualib/Set.lua +119 -123
- package/dist/lualib/SetDescriptor.lua +7 -1
- package/dist/lualib/SourceMapTraceBack.lua +19 -9
- package/dist/lualib/SparseArrayNew.lua +5 -0
- package/dist/lualib/SparseArrayPush.lua +9 -0
- package/dist/lualib/SparseArraySpread.lua +4 -0
- package/dist/lualib/StringAccess.lua +1 -1
- package/dist/lualib/StringCharCodeAt.lua +1 -1
- package/dist/lualib/StringEndsWith.lua +2 -2
- package/dist/lualib/StringPadEnd.lua +2 -2
- package/dist/lualib/StringPadStart.lua +2 -2
- package/dist/lualib/StringReplace.lua +12 -11
- package/dist/lualib/StringReplaceAll.lua +35 -0
- package/dist/lualib/StringSlice.lua +2 -2
- package/dist/lualib/StringSplit.lua +3 -3
- package/dist/lualib/StringStartsWith.lua +1 -1
- package/dist/lualib/StringSubstr.lua +1 -1
- package/dist/lualib/StringSubstring.lua +2 -2
- package/dist/lualib/Symbol.lua +3 -5
- package/dist/lualib/WeakMap.lua +40 -42
- package/dist/lualib/WeakSet.lua +36 -38
- package/dist/lualib/lualib_bundle.lua +705 -586
- package/dist/transformation/builtins/array.js +29 -30
- package/dist/transformation/builtins/console.js +2 -2
- package/dist/transformation/builtins/function.js +9 -10
- package/dist/transformation/builtins/global.js +8 -8
- package/dist/transformation/builtins/index.d.ts +1 -1
- package/dist/transformation/builtins/index.js +69 -36
- package/dist/transformation/builtins/math.js +4 -4
- package/dist/transformation/builtins/number.js +7 -7
- package/dist/transformation/builtins/object.d.ts +2 -1
- package/dist/transformation/builtins/object.js +12 -13
- package/dist/transformation/builtins/promise.js +9 -9
- package/dist/transformation/builtins/string.js +32 -31
- package/dist/transformation/builtins/symbol.js +3 -3
- package/dist/transformation/context/context.d.ts +12 -0
- package/dist/transformation/context/context.js +105 -6
- package/dist/transformation/index.js +1 -1
- package/dist/transformation/utils/annotations.d.ts +1 -3
- package/dist/transformation/utils/annotations.js +0 -2
- package/dist/transformation/utils/assignment-validation.js +8 -7
- package/dist/transformation/utils/diagnostics.d.ts +6 -0
- package/dist/transformation/utils/diagnostics.js +7 -5
- package/dist/transformation/utils/export.d.ts +3 -2
- package/dist/transformation/utils/export.js +14 -7
- package/dist/transformation/utils/function-context.js +8 -8
- package/dist/transformation/utils/lua-ast.d.ts +0 -1
- package/dist/transformation/utils/lua-ast.js +25 -35
- package/dist/transformation/utils/lualib.js +1 -1
- package/dist/transformation/utils/preceding-statements.d.ts +3 -0
- package/dist/transformation/utils/preceding-statements.js +11 -0
- package/dist/transformation/utils/safe-names.js +5 -5
- package/dist/transformation/utils/scope.d.ts +7 -0
- package/dist/transformation/utils/scope.js +77 -40
- package/dist/transformation/utils/symbols.js +6 -6
- package/dist/transformation/utils/typescript/index.d.ts +1 -0
- package/dist/transformation/utils/typescript/index.js +16 -1
- package/dist/transformation/utils/typescript/nodes.d.ts +2 -0
- package/dist/transformation/utils/typescript/nodes.js +21 -1
- package/dist/transformation/visitors/access.d.ts +3 -0
- package/dist/transformation/visitors/access.js +74 -47
- package/dist/transformation/visitors/async-await.js +5 -4
- package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
- package/dist/transformation/visitors/binary-expression/assignments.js +86 -77
- package/dist/transformation/visitors/binary-expression/bit.js +4 -4
- package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
- package/dist/transformation/visitors/binary-expression/compound.js +69 -71
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
- package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +65 -36
- package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
- package/dist/transformation/visitors/binary-expression/index.js +84 -40
- package/dist/transformation/visitors/block.js +6 -6
- package/dist/transformation/visitors/break-continue.js +4 -9
- package/dist/transformation/visitors/call.d.ts +3 -2
- package/dist/transformation/visitors/call.js +130 -143
- package/dist/transformation/visitors/class/decorators.js +3 -3
- package/dist/transformation/visitors/class/index.js +43 -39
- package/dist/transformation/visitors/class/members/accessors.js +6 -6
- package/dist/transformation/visitors/class/members/constructor.js +7 -7
- package/dist/transformation/visitors/class/members/fields.js +6 -6
- package/dist/transformation/visitors/class/members/method.js +6 -6
- package/dist/transformation/visitors/class/new.js +14 -16
- package/dist/transformation/visitors/class/setup.js +11 -11
- package/dist/transformation/visitors/class/utils.js +2 -2
- package/dist/transformation/visitors/conditional.js +34 -20
- package/dist/transformation/visitors/delete.js +8 -4
- package/dist/transformation/visitors/enum.js +8 -8
- package/dist/transformation/visitors/errors.js +30 -30
- package/dist/transformation/visitors/expression-list.d.ts +7 -0
- package/dist/transformation/visitors/expression-list.js +120 -0
- package/dist/transformation/visitors/expression-statement.js +10 -6
- package/dist/transformation/visitors/function.js +30 -32
- package/dist/transformation/visitors/identifier.js +26 -22
- package/dist/transformation/visitors/index.js +2 -2
- package/dist/transformation/visitors/language-extensions/iterable.js +7 -7
- package/dist/transformation/visitors/language-extensions/multi.d.ts +1 -1
- package/dist/transformation/visitors/language-extensions/multi.js +3 -3
- package/dist/transformation/visitors/language-extensions/operators.js +6 -6
- package/dist/transformation/visitors/language-extensions/range.js +6 -6
- package/dist/transformation/visitors/language-extensions/table.js +5 -5
- package/dist/transformation/visitors/literal.d.ts +1 -2
- package/dist/transformation/visitors/literal.js +87 -57
- package/dist/transformation/visitors/loops/do-while.js +35 -9
- package/dist/transformation/visitors/loops/for-in.js +4 -4
- package/dist/transformation/visitors/loops/for-of.js +13 -13
- package/dist/transformation/visitors/loops/for.js +28 -8
- package/dist/transformation/visitors/loops/utils.d.ts +1 -0
- package/dist/transformation/visitors/loops/utils.js +21 -10
- package/dist/transformation/visitors/modules/export.js +14 -15
- package/dist/transformation/visitors/modules/import.js +10 -10
- package/dist/transformation/visitors/namespace.js +13 -13
- package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
- package/dist/transformation/visitors/optional-chaining.js +172 -0
- package/dist/transformation/visitors/return.d.ts +1 -0
- package/dist/transformation/visitors/return.js +40 -26
- package/dist/transformation/visitors/sourceFile.js +12 -9
- package/dist/transformation/visitors/spread.js +11 -11
- package/dist/transformation/visitors/switch.js +152 -30
- package/dist/transformation/visitors/template.js +10 -7
- package/dist/transformation/visitors/typeof.js +4 -2
- package/dist/transformation/visitors/typescript.js +1 -1
- package/dist/transformation/visitors/unary-expression.js +9 -9
- package/dist/transformation/visitors/variable-declaration.js +46 -32
- package/dist/transformation/visitors/void.d.ts +6 -0
- package/dist/transformation/visitors/void.js +20 -0
- package/dist/transpilation/bundle.d.ts +3 -0
- package/dist/transpilation/bundle.js +56 -13
- package/dist/transpilation/diagnostics.js +3 -3
- package/dist/transpilation/index.js +2 -2
- package/dist/transpilation/output-collector.js +2 -2
- package/dist/transpilation/plugins.js +1 -1
- package/dist/transpilation/resolve.js +26 -14
- package/dist/transpilation/transformers.js +45 -25
- package/dist/transpilation/transpile.js +6 -6
- package/dist/transpilation/transpiler.js +8 -8
- package/dist/transpilation/utils.js +5 -3
- package/dist/tstl.js +8 -8
- package/dist/utils.js +2 -2
- package/package.json +15 -12
- package/dist/lualib/OptionalChainAccess.lua +0 -6
- package/dist/lualib/OptionalFunctionCall.lua +0 -6
- package/dist/lualib/OptionalMethodCall.lua +0 -11
- package/dist/transformation/utils/transform.d.ts +0 -8
- package/dist/transformation/utils/transform.js +0 -14
- package/dist/transformation/visitors/jsx/jsx.d.ts +0 -9
- package/dist/transformation/visitors/jsx/jsx.js +0 -237
- package/dist/transformation/visitors/jsx/xhtml.d.ts +0 -3
- package/dist/transformation/visitors/jsx/xhtml.js +0 -260
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function __TS__ArrayIsArray(value)
|
|
2
|
-
return
|
|
2
|
+
return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
function __TS__ArrayConcat(arr1, ...)
|
|
@@ -199,7 +199,13 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
|
|
|
199
199
|
error("Reduce of empty array with no initial value", 0)
|
|
200
200
|
end
|
|
201
201
|
for i = k, len - 1 do
|
|
202
|
-
accumulator = callbackFn(
|
|
202
|
+
accumulator = callbackFn(
|
|
203
|
+
_G,
|
|
204
|
+
accumulator,
|
|
205
|
+
arr[i + 1],
|
|
206
|
+
i,
|
|
207
|
+
arr
|
|
208
|
+
)
|
|
203
209
|
end
|
|
204
210
|
return accumulator
|
|
205
211
|
end
|
|
@@ -217,7 +223,13 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
|
|
|
217
223
|
error("Reduce of empty array with no initial value", 0)
|
|
218
224
|
end
|
|
219
225
|
for i = k, 0, -1 do
|
|
220
|
-
accumulator = callbackFn(
|
|
226
|
+
accumulator = callbackFn(
|
|
227
|
+
_G,
|
|
228
|
+
accumulator,
|
|
229
|
+
arr[i + 1],
|
|
230
|
+
i,
|
|
231
|
+
arr
|
|
232
|
+
)
|
|
221
233
|
end
|
|
222
234
|
return accumulator
|
|
223
235
|
end
|
|
@@ -342,7 +354,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
342
354
|
if itemCount < actualDeleteCount then
|
|
343
355
|
do
|
|
344
356
|
local k = actualStart
|
|
345
|
-
while k <
|
|
357
|
+
while k < len - actualDeleteCount do
|
|
346
358
|
local from = k + actualDeleteCount
|
|
347
359
|
local to = k + itemCount
|
|
348
360
|
if list[from + 1] then
|
|
@@ -355,7 +367,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
355
367
|
end
|
|
356
368
|
do
|
|
357
369
|
local k = len
|
|
358
|
-
while k >
|
|
370
|
+
while k > len - actualDeleteCount + itemCount do
|
|
359
371
|
list[k] = nil
|
|
360
372
|
k = k - 1
|
|
361
373
|
end
|
|
@@ -364,8 +376,8 @@ function __TS__ArraySplice(list, ...)
|
|
|
364
376
|
do
|
|
365
377
|
local k = len - actualDeleteCount
|
|
366
378
|
while k > actualStart do
|
|
367
|
-
local from =
|
|
368
|
-
local to =
|
|
379
|
+
local from = k + actualDeleteCount - 1
|
|
380
|
+
local to = k + itemCount - 1
|
|
369
381
|
if list[from + 1] then
|
|
370
382
|
list[to + 1] = list[from + 1]
|
|
371
383
|
else
|
|
@@ -382,7 +394,7 @@ function __TS__ArraySplice(list, ...)
|
|
|
382
394
|
end
|
|
383
395
|
do
|
|
384
396
|
local k = #list - 1
|
|
385
|
-
while k >=
|
|
397
|
+
while k >= len - actualDeleteCount + itemCount do
|
|
386
398
|
list[k + 1] = nil
|
|
387
399
|
k = k - 1
|
|
388
400
|
end
|
|
@@ -408,7 +420,7 @@ function __TS__ArrayFlat(array, depth)
|
|
|
408
420
|
end
|
|
409
421
|
local result = {}
|
|
410
422
|
for ____, value in ipairs(array) do
|
|
411
|
-
if
|
|
423
|
+
if depth > 0 and __TS__ArrayIsArray(value) then
|
|
412
424
|
result = __TS__ArrayConcat(
|
|
413
425
|
result,
|
|
414
426
|
__TS__ArrayFlat(value, depth - 1)
|
|
@@ -426,7 +438,7 @@ function __TS__ArrayFlatMap(array, callback)
|
|
|
426
438
|
local i = 0
|
|
427
439
|
while i < #array do
|
|
428
440
|
local value = callback(_G, array[i + 1], i, array)
|
|
429
|
-
if
|
|
441
|
+
if type(value) == "table" and __TS__ArrayIsArray(value) then
|
|
430
442
|
result = __TS__ArrayConcat(result, value)
|
|
431
443
|
else
|
|
432
444
|
result[#result + 1] = value
|
|
@@ -438,7 +450,7 @@ function __TS__ArrayFlatMap(array, callback)
|
|
|
438
450
|
end
|
|
439
451
|
|
|
440
452
|
function __TS__ArraySetLength(arr, length)
|
|
441
|
-
if
|
|
453
|
+
if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
|
|
442
454
|
error(
|
|
443
455
|
"invalid array length: " .. tostring(length),
|
|
444
456
|
0
|
|
@@ -454,11 +466,9 @@ function __TS__ArraySetLength(arr, length)
|
|
|
454
466
|
return length
|
|
455
467
|
end
|
|
456
468
|
|
|
457
|
-
____symbolMetatable = {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
end
|
|
461
|
-
}
|
|
469
|
+
____symbolMetatable = {__tostring = function(self)
|
|
470
|
+
return ("Symbol(" .. (self.description or "")) .. ")"
|
|
471
|
+
end}
|
|
462
472
|
function __TS__Symbol(description)
|
|
463
473
|
return setmetatable({description = description}, ____symbolMetatable)
|
|
464
474
|
end
|
|
@@ -474,7 +484,7 @@ function __TS__InstanceOf(obj, classTbl)
|
|
|
474
484
|
error("Right-hand side of 'instanceof' is not an object", 0)
|
|
475
485
|
end
|
|
476
486
|
if classTbl[Symbol.hasInstance] ~= nil then
|
|
477
|
-
return not
|
|
487
|
+
return not not classTbl[Symbol.hasInstance](classTbl, obj)
|
|
478
488
|
end
|
|
479
489
|
if type(obj) == "table" then
|
|
480
490
|
local luaClass = obj.constructor
|
|
@@ -498,44 +508,64 @@ function __TS__AsyncAwaiter(generator)
|
|
|
498
508
|
return __TS__New(
|
|
499
509
|
__TS__Promise,
|
|
500
510
|
function(____, resolve, reject)
|
|
501
|
-
local
|
|
511
|
+
local adopt, fulfilled, rejected, step, asyncCoroutine
|
|
502
512
|
function adopt(self, value)
|
|
503
|
-
|
|
513
|
+
local ____temp_0
|
|
514
|
+
if __TS__InstanceOf(value, __TS__Promise) then
|
|
515
|
+
____temp_0 = value
|
|
516
|
+
else
|
|
517
|
+
____temp_0 = __TS__Promise.resolve(value)
|
|
518
|
+
end
|
|
519
|
+
return ____temp_0
|
|
504
520
|
end
|
|
505
521
|
function fulfilled(self, value)
|
|
506
|
-
local success, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
522
|
+
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine, value)
|
|
507
523
|
if success then
|
|
508
|
-
step(_G, resultOrError)
|
|
524
|
+
step(_G, resultOrError, errorOrErrorHandler)
|
|
525
|
+
else
|
|
526
|
+
reject(_G, errorOrErrorHandler)
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
function rejected(self, handler)
|
|
530
|
+
if handler then
|
|
531
|
+
return function(____, value)
|
|
532
|
+
local success, valueOrError = pcall(handler, value)
|
|
533
|
+
if success then
|
|
534
|
+
step(_G, valueOrError, handler)
|
|
535
|
+
else
|
|
536
|
+
reject(_G, valueOrError)
|
|
537
|
+
end
|
|
538
|
+
end
|
|
509
539
|
else
|
|
510
|
-
|
|
540
|
+
return function(____, value)
|
|
541
|
+
reject(_G, value)
|
|
542
|
+
end
|
|
511
543
|
end
|
|
512
544
|
end
|
|
513
|
-
function step(self, result)
|
|
545
|
+
function step(self, result, errorHandler)
|
|
514
546
|
if coroutine.status(asyncCoroutine) == "dead" then
|
|
515
547
|
resolve(_G, result)
|
|
516
548
|
else
|
|
517
|
-
(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
)
|
|
524
|
-
end)()
|
|
549
|
+
local ____self_1 = adopt(_G, result)
|
|
550
|
+
____self_1["then"](
|
|
551
|
+
____self_1,
|
|
552
|
+
fulfilled,
|
|
553
|
+
rejected(_G, errorHandler)
|
|
554
|
+
)
|
|
525
555
|
end
|
|
526
556
|
end
|
|
527
557
|
asyncCoroutine = coroutine.create(generator)
|
|
528
|
-
local success, resultOrError = coroutine.resume(asyncCoroutine)
|
|
558
|
+
local success, errorOrErrorHandler, resultOrError = coroutine.resume(asyncCoroutine)
|
|
529
559
|
if success then
|
|
530
|
-
step(_G, resultOrError)
|
|
560
|
+
step(_G, resultOrError, errorOrErrorHandler)
|
|
531
561
|
else
|
|
532
|
-
reject(_G,
|
|
562
|
+
reject(_G, errorOrErrorHandler)
|
|
533
563
|
end
|
|
534
564
|
end
|
|
535
565
|
)
|
|
536
566
|
end
|
|
537
|
-
function __TS__Await(thing)
|
|
538
|
-
return coroutine.yield(thing)
|
|
567
|
+
function __TS__Await(errorHandler, thing)
|
|
568
|
+
return coroutine.yield(errorHandler, thing)
|
|
539
569
|
end
|
|
540
570
|
|
|
541
571
|
function __TS__Class(self)
|
|
@@ -570,22 +600,22 @@ function __TS__ClassExtends(target, base)
|
|
|
570
600
|
end
|
|
571
601
|
end
|
|
572
602
|
|
|
603
|
+
local value
|
|
604
|
+
local writable
|
|
605
|
+
local set
|
|
606
|
+
local get
|
|
607
|
+
local configurable
|
|
608
|
+
local enumerable
|
|
573
609
|
function __TS__CloneDescriptor(____bindingPattern0)
|
|
574
|
-
local enumerable
|
|
575
610
|
enumerable = ____bindingPattern0.enumerable
|
|
576
|
-
local configurable
|
|
577
611
|
configurable = ____bindingPattern0.configurable
|
|
578
|
-
local get
|
|
579
612
|
get = ____bindingPattern0.get
|
|
580
|
-
local set
|
|
581
613
|
set = ____bindingPattern0.set
|
|
582
|
-
local writable
|
|
583
614
|
writable = ____bindingPattern0.writable
|
|
584
|
-
local value
|
|
585
615
|
value = ____bindingPattern0.value
|
|
586
616
|
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
587
|
-
local hasGetterOrSetter =
|
|
588
|
-
local hasValueOrWritableAttribute =
|
|
617
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
618
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
589
619
|
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
590
620
|
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
591
621
|
end
|
|
@@ -663,7 +693,13 @@ function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
|
663
693
|
if isPrototype == nil then
|
|
664
694
|
isPrototype = false
|
|
665
695
|
end
|
|
666
|
-
local
|
|
696
|
+
local ____isPrototype_0
|
|
697
|
+
if isPrototype then
|
|
698
|
+
____isPrototype_0 = target
|
|
699
|
+
else
|
|
700
|
+
____isPrototype_0 = getmetatable(target)
|
|
701
|
+
end
|
|
702
|
+
local metatable = ____isPrototype_0
|
|
667
703
|
if not metatable then
|
|
668
704
|
metatable = {}
|
|
669
705
|
setmetatable(target, metatable)
|
|
@@ -708,7 +744,7 @@ function __TS__Decorate(decorators, target, key, desc)
|
|
|
708
744
|
local value = rawget(target, key)
|
|
709
745
|
local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
|
|
710
746
|
local desc = decorator(_G, target, key, descriptor) or descriptor
|
|
711
|
-
local isSimpleValue =
|
|
747
|
+
local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
|
|
712
748
|
if isSimpleValue then
|
|
713
749
|
rawset(target, key, desc.value)
|
|
714
750
|
else
|
|
@@ -743,28 +779,107 @@ function __TS__ObjectGetOwnPropertyDescriptors(object)
|
|
|
743
779
|
return rawget(metatable, "_descriptors") or ({})
|
|
744
780
|
end
|
|
745
781
|
|
|
782
|
+
function __TS__GetErrorStack(self, constructor)
|
|
783
|
+
local level = 1
|
|
784
|
+
while true do
|
|
785
|
+
local info = debug.getinfo(level, "f")
|
|
786
|
+
level = level + 1
|
|
787
|
+
if not info then
|
|
788
|
+
level = 1
|
|
789
|
+
break
|
|
790
|
+
elseif info.func == constructor then
|
|
791
|
+
break
|
|
792
|
+
end
|
|
793
|
+
end
|
|
794
|
+
return debug.traceback(nil, level)
|
|
795
|
+
end
|
|
796
|
+
function __TS__WrapErrorToString(self, getDescription)
|
|
797
|
+
return function(self)
|
|
798
|
+
local description = getDescription(self)
|
|
799
|
+
local caller = debug.getinfo(3, "f")
|
|
800
|
+
if _VERSION == "Lua 5.1" or caller and caller.func ~= error then
|
|
801
|
+
return description
|
|
802
|
+
else
|
|
803
|
+
return (tostring(description) .. "\n") .. self.stack
|
|
804
|
+
end
|
|
805
|
+
end
|
|
806
|
+
end
|
|
807
|
+
function __TS__InitErrorClass(self, Type, name)
|
|
808
|
+
Type.name = name
|
|
809
|
+
return setmetatable(
|
|
810
|
+
Type,
|
|
811
|
+
{__call = function(____, _self, message) return __TS__New(Type, message) end}
|
|
812
|
+
)
|
|
813
|
+
end
|
|
814
|
+
local ____TS__InitErrorClass_3 = __TS__InitErrorClass
|
|
815
|
+
local ____G_2 = _G
|
|
816
|
+
____class_0 = __TS__Class()
|
|
817
|
+
____class_0.name = ""
|
|
818
|
+
function ____class_0.prototype.____constructor(self, message)
|
|
819
|
+
if message == nil then
|
|
820
|
+
message = ""
|
|
821
|
+
end
|
|
822
|
+
self.message = message
|
|
823
|
+
self.name = "Error"
|
|
824
|
+
self.stack = __TS__GetErrorStack(_G, self.constructor.new)
|
|
825
|
+
local metatable = getmetatable(self)
|
|
826
|
+
if not metatable.__errorToStringPatched then
|
|
827
|
+
metatable.__errorToStringPatched = true
|
|
828
|
+
metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
|
|
829
|
+
end
|
|
830
|
+
end
|
|
831
|
+
function ____class_0.prototype.__tostring(self)
|
|
832
|
+
local ____temp_1
|
|
833
|
+
if self.message ~= "" then
|
|
834
|
+
____temp_1 = (self.name .. ": ") .. self.message
|
|
835
|
+
else
|
|
836
|
+
____temp_1 = self.name
|
|
837
|
+
end
|
|
838
|
+
return ____temp_1
|
|
839
|
+
end
|
|
840
|
+
Error = ____TS__InitErrorClass_3(____G_2, ____class_0, "Error")
|
|
841
|
+
for ____, errorName in ipairs({
|
|
842
|
+
"RangeError",
|
|
843
|
+
"ReferenceError",
|
|
844
|
+
"SyntaxError",
|
|
845
|
+
"TypeError",
|
|
846
|
+
"URIError"
|
|
847
|
+
}) do
|
|
848
|
+
local ____G_7 = _G
|
|
849
|
+
local ____TS__InitErrorClass_6 = __TS__InitErrorClass
|
|
850
|
+
local ____G_5 = _G
|
|
851
|
+
local ____class_4 = __TS__Class()
|
|
852
|
+
____class_4.name = ____class_4.name
|
|
853
|
+
__TS__ClassExtends(____class_4, Error)
|
|
854
|
+
function ____class_4.prototype.____constructor(self, ...)
|
|
855
|
+
Error.prototype.____constructor(self, ...)
|
|
856
|
+
self.name = errorName
|
|
857
|
+
end
|
|
858
|
+
____G_7[errorName] = ____TS__InitErrorClass_6(____G_5, ____class_4, errorName)
|
|
859
|
+
end
|
|
860
|
+
|
|
746
861
|
function __TS__Delete(target, key)
|
|
747
862
|
local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
|
|
748
863
|
local descriptor = descriptors[key]
|
|
749
864
|
if descriptor then
|
|
750
865
|
if not descriptor.configurable then
|
|
751
866
|
error(
|
|
752
|
-
(
|
|
867
|
+
__TS__New(
|
|
868
|
+
TypeError,
|
|
869
|
+
((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
|
|
870
|
+
),
|
|
753
871
|
0
|
|
754
872
|
)
|
|
755
873
|
end
|
|
756
874
|
descriptors[key] = nil
|
|
757
875
|
return true
|
|
758
876
|
end
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return true
|
|
762
|
-
end
|
|
763
|
-
return false
|
|
877
|
+
target[key] = nil
|
|
878
|
+
return true
|
|
764
879
|
end
|
|
765
880
|
|
|
766
881
|
function __TS__StringAccess(self, index)
|
|
767
|
-
if
|
|
882
|
+
if index >= 0 and index < #self then
|
|
768
883
|
return string.sub(self, index + 1, index + 1)
|
|
769
884
|
end
|
|
770
885
|
end
|
|
@@ -772,9 +887,7 @@ end
|
|
|
772
887
|
function __TS__DelegatedYield(iterable)
|
|
773
888
|
if type(iterable) == "string" then
|
|
774
889
|
for index = 0, #iterable - 1 do
|
|
775
|
-
coroutine.yield(
|
|
776
|
-
__TS__StringAccess(iterable, index)
|
|
777
|
-
)
|
|
890
|
+
coroutine.yield(__TS__StringAccess(iterable, index))
|
|
778
891
|
end
|
|
779
892
|
elseif iterable.____coroutine ~= nil then
|
|
780
893
|
local co = iterable.____coroutine
|
|
@@ -806,82 +919,6 @@ function __TS__DelegatedYield(iterable)
|
|
|
806
919
|
end
|
|
807
920
|
end
|
|
808
921
|
|
|
809
|
-
function __TS__GetErrorStack(self, constructor)
|
|
810
|
-
local level = 1
|
|
811
|
-
while true do
|
|
812
|
-
local info = debug.getinfo(level, "f")
|
|
813
|
-
level = level + 1
|
|
814
|
-
if not info then
|
|
815
|
-
level = 1
|
|
816
|
-
break
|
|
817
|
-
elseif info.func == constructor then
|
|
818
|
-
break
|
|
819
|
-
end
|
|
820
|
-
end
|
|
821
|
-
return debug.traceback(nil, level)
|
|
822
|
-
end
|
|
823
|
-
function __TS__WrapErrorToString(self, getDescription)
|
|
824
|
-
return function(self)
|
|
825
|
-
local description = getDescription(self)
|
|
826
|
-
local caller = debug.getinfo(3, "f")
|
|
827
|
-
if (_VERSION == "Lua 5.1") or (caller and (caller.func ~= error)) then
|
|
828
|
-
return description
|
|
829
|
-
else
|
|
830
|
-
return (tostring(description) .. "\n") .. self.stack
|
|
831
|
-
end
|
|
832
|
-
end
|
|
833
|
-
end
|
|
834
|
-
function __TS__InitErrorClass(self, Type, name)
|
|
835
|
-
Type.name = name
|
|
836
|
-
return setmetatable(
|
|
837
|
-
Type,
|
|
838
|
-
{
|
|
839
|
-
__call = function(____, _self, message) return __TS__New(Type, message) end
|
|
840
|
-
}
|
|
841
|
-
)
|
|
842
|
-
end
|
|
843
|
-
Error = __TS__InitErrorClass(
|
|
844
|
-
_G,
|
|
845
|
-
(function()
|
|
846
|
-
local ____ = __TS__Class()
|
|
847
|
-
____.name = ""
|
|
848
|
-
function ____.prototype.____constructor(self, message)
|
|
849
|
-
if message == nil then
|
|
850
|
-
message = ""
|
|
851
|
-
end
|
|
852
|
-
self.message = message
|
|
853
|
-
self.name = "Error"
|
|
854
|
-
self.stack = __TS__GetErrorStack(_G, self.constructor.new)
|
|
855
|
-
local metatable = getmetatable(self)
|
|
856
|
-
if not metatable.__errorToStringPatched then
|
|
857
|
-
metatable.__errorToStringPatched = true
|
|
858
|
-
metatable.__tostring = __TS__WrapErrorToString(_G, metatable.__tostring)
|
|
859
|
-
end
|
|
860
|
-
end
|
|
861
|
-
function ____.prototype.__tostring(self)
|
|
862
|
-
return (((self.message ~= "") and (function() return (self.name .. ": ") .. self.message end)) or (function() return self.name end))()
|
|
863
|
-
end
|
|
864
|
-
return ____
|
|
865
|
-
end)(),
|
|
866
|
-
"Error"
|
|
867
|
-
)
|
|
868
|
-
for ____, errorName in ipairs({"RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"}) do
|
|
869
|
-
_G[errorName] = __TS__InitErrorClass(
|
|
870
|
-
_G,
|
|
871
|
-
(function()
|
|
872
|
-
local ____ = __TS__Class()
|
|
873
|
-
____.name = ____.name
|
|
874
|
-
__TS__ClassExtends(____, Error)
|
|
875
|
-
function ____.prototype.____constructor(self, ...)
|
|
876
|
-
Error.prototype.____constructor(self, ...)
|
|
877
|
-
self.name = errorName
|
|
878
|
-
end
|
|
879
|
-
return ____
|
|
880
|
-
end)(),
|
|
881
|
-
errorName
|
|
882
|
-
)
|
|
883
|
-
end
|
|
884
|
-
|
|
885
922
|
__TS__Unpack = table.unpack or unpack
|
|
886
923
|
|
|
887
924
|
function __TS__FunctionBind(fn, thisArg, ...)
|
|
@@ -924,11 +961,7 @@ function __TS__Generator(fn)
|
|
|
924
961
|
local args = {...}
|
|
925
962
|
local argsLength = select("#", ...)
|
|
926
963
|
return {
|
|
927
|
-
____coroutine = coroutine.create(
|
|
928
|
-
function() return fn(
|
|
929
|
-
(unpack or table.unpack)(args, 1, argsLength)
|
|
930
|
-
) end
|
|
931
|
-
),
|
|
964
|
+
____coroutine = coroutine.create(function() return fn((unpack or table.unpack)(args, 1, argsLength)) end),
|
|
932
965
|
[Symbol.iterator] = __TS__GeneratorIterator,
|
|
933
966
|
next = __TS__GeneratorNext
|
|
934
967
|
}
|
|
@@ -937,7 +970,7 @@ end
|
|
|
937
970
|
|
|
938
971
|
function __TS__InstanceOfObject(value)
|
|
939
972
|
local valueType = type(value)
|
|
940
|
-
return
|
|
973
|
+
return valueType == "table" or valueType == "function"
|
|
941
974
|
end
|
|
942
975
|
|
|
943
976
|
function __TS__IteratorGeneratorStep(self)
|
|
@@ -978,150 +1011,146 @@ function __TS__Iterator(iterable)
|
|
|
978
1011
|
end
|
|
979
1012
|
end
|
|
980
1013
|
|
|
981
|
-
Map = (
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
return
|
|
992
|
-
end
|
|
993
|
-
local iterable = entries
|
|
994
|
-
if iterable[Symbol.iterator] then
|
|
995
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
996
|
-
while true do
|
|
997
|
-
local result = iterator:next()
|
|
998
|
-
if result.done then
|
|
999
|
-
break
|
|
1000
|
-
end
|
|
1001
|
-
local value = result.value
|
|
1002
|
-
self:set(value[1], value[2])
|
|
1003
|
-
end
|
|
1004
|
-
else
|
|
1005
|
-
local array = entries
|
|
1006
|
-
for ____, kvp in ipairs(array) do
|
|
1007
|
-
self:set(kvp[1], kvp[2])
|
|
1008
|
-
end
|
|
1009
|
-
end
|
|
1014
|
+
Map = __TS__Class()
|
|
1015
|
+
Map.name = "Map"
|
|
1016
|
+
function Map.prototype.____constructor(self, entries)
|
|
1017
|
+
self[Symbol.toStringTag] = "Map"
|
|
1018
|
+
self.items = {}
|
|
1019
|
+
self.size = 0
|
|
1020
|
+
self.nextKey = {}
|
|
1021
|
+
self.previousKey = {}
|
|
1022
|
+
if entries == nil then
|
|
1023
|
+
return
|
|
1010
1024
|
end
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
end
|
|
1019
|
-
function Map.prototype.delete(self, key)
|
|
1020
|
-
local contains = self:has(key)
|
|
1021
|
-
if contains then
|
|
1022
|
-
self.size = self.size - 1
|
|
1023
|
-
local next = self.nextKey[key]
|
|
1024
|
-
local previous = self.previousKey[key]
|
|
1025
|
-
if next and previous then
|
|
1026
|
-
self.nextKey[previous] = next
|
|
1027
|
-
self.previousKey[next] = previous
|
|
1028
|
-
elseif next then
|
|
1029
|
-
self.firstKey = next
|
|
1030
|
-
self.previousKey[next] = nil
|
|
1031
|
-
elseif previous then
|
|
1032
|
-
self.lastKey = previous
|
|
1033
|
-
self.nextKey[previous] = nil
|
|
1034
|
-
else
|
|
1035
|
-
self.firstKey = nil
|
|
1036
|
-
self.lastKey = nil
|
|
1025
|
+
local iterable = entries
|
|
1026
|
+
if iterable[Symbol.iterator] then
|
|
1027
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1028
|
+
while true do
|
|
1029
|
+
local result = iterator:next()
|
|
1030
|
+
if result.done then
|
|
1031
|
+
break
|
|
1037
1032
|
end
|
|
1038
|
-
|
|
1039
|
-
self
|
|
1033
|
+
local value = result.value
|
|
1034
|
+
self:set(value[1], value[2])
|
|
1040
1035
|
end
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1036
|
+
else
|
|
1037
|
+
local array = entries
|
|
1038
|
+
for ____, kvp in ipairs(array) do
|
|
1039
|
+
self:set(kvp[1], kvp[2])
|
|
1040
|
+
end
|
|
1041
|
+
end
|
|
1042
|
+
end
|
|
1043
|
+
function Map.prototype.clear(self)
|
|
1044
|
+
self.items = {}
|
|
1045
|
+
self.nextKey = {}
|
|
1046
|
+
self.previousKey = {}
|
|
1047
|
+
self.firstKey = nil
|
|
1048
|
+
self.lastKey = nil
|
|
1049
|
+
self.size = 0
|
|
1050
|
+
end
|
|
1051
|
+
function Map.prototype.delete(self, key)
|
|
1052
|
+
local contains = self:has(key)
|
|
1053
|
+
if contains then
|
|
1054
|
+
self.size = self.size - 1
|
|
1055
|
+
local next = self.nextKey[key]
|
|
1056
|
+
local previous = self.previousKey[key]
|
|
1057
|
+
if next and previous then
|
|
1058
|
+
self.nextKey[previous] = next
|
|
1059
|
+
self.previousKey[next] = previous
|
|
1060
|
+
elseif next then
|
|
1061
|
+
self.firstKey = next
|
|
1062
|
+
self.previousKey[next] = nil
|
|
1063
|
+
elseif previous then
|
|
1064
|
+
self.lastKey = previous
|
|
1065
|
+
self.nextKey[previous] = nil
|
|
1066
|
+
else
|
|
1067
|
+
self.firstKey = nil
|
|
1068
|
+
self.lastKey = nil
|
|
1049
1069
|
end
|
|
1070
|
+
self.nextKey[key] = nil
|
|
1071
|
+
self.previousKey[key] = nil
|
|
1050
1072
|
end
|
|
1051
|
-
|
|
1052
|
-
|
|
1073
|
+
self.items[key] = nil
|
|
1074
|
+
return contains
|
|
1075
|
+
end
|
|
1076
|
+
function Map.prototype.forEach(self, callback)
|
|
1077
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
1078
|
+
callback(_G, self.items[key], key, self)
|
|
1053
1079
|
end
|
|
1054
|
-
|
|
1055
|
-
|
|
1080
|
+
end
|
|
1081
|
+
function Map.prototype.get(self, key)
|
|
1082
|
+
return self.items[key]
|
|
1083
|
+
end
|
|
1084
|
+
function Map.prototype.has(self, key)
|
|
1085
|
+
return self.nextKey[key] ~= nil or self.lastKey == key
|
|
1086
|
+
end
|
|
1087
|
+
function Map.prototype.set(self, key, value)
|
|
1088
|
+
local isNewValue = not self:has(key)
|
|
1089
|
+
if isNewValue then
|
|
1090
|
+
self.size = self.size + 1
|
|
1091
|
+
end
|
|
1092
|
+
self.items[key] = value
|
|
1093
|
+
if self.firstKey == nil then
|
|
1094
|
+
self.firstKey = key
|
|
1095
|
+
self.lastKey = key
|
|
1096
|
+
elseif isNewValue then
|
|
1097
|
+
self.nextKey[self.lastKey] = key
|
|
1098
|
+
self.previousKey[key] = self.lastKey
|
|
1099
|
+
self.lastKey = key
|
|
1056
1100
|
end
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1101
|
+
return self
|
|
1102
|
+
end
|
|
1103
|
+
Map.prototype[Symbol.iterator] = function(self)
|
|
1104
|
+
return self:entries()
|
|
1105
|
+
end
|
|
1106
|
+
function Map.prototype.entries(self)
|
|
1107
|
+
local ____temp_0 = self
|
|
1108
|
+
local items = ____temp_0.items
|
|
1109
|
+
local nextKey = ____temp_0.nextKey
|
|
1110
|
+
local key = self.firstKey
|
|
1111
|
+
return {
|
|
1112
|
+
[Symbol.iterator] = function(self)
|
|
1113
|
+
return self
|
|
1114
|
+
end,
|
|
1115
|
+
next = function(self)
|
|
1116
|
+
local result = {done = not key, value = {key, items[key]}}
|
|
1117
|
+
key = nextKey[key]
|
|
1118
|
+
return result
|
|
1119
|
+
end
|
|
1120
|
+
}
|
|
1121
|
+
end
|
|
1122
|
+
function Map.prototype.keys(self)
|
|
1123
|
+
local nextKey = self.nextKey
|
|
1124
|
+
local key = self.firstKey
|
|
1125
|
+
return {
|
|
1126
|
+
[Symbol.iterator] = function(self)
|
|
1127
|
+
return self
|
|
1128
|
+
end,
|
|
1129
|
+
next = function(self)
|
|
1130
|
+
local result = {done = not key, value = key}
|
|
1131
|
+
key = nextKey[key]
|
|
1132
|
+
return result
|
|
1061
1133
|
end
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1134
|
+
}
|
|
1135
|
+
end
|
|
1136
|
+
function Map.prototype.values(self)
|
|
1137
|
+
local ____temp_1 = self
|
|
1138
|
+
local items = ____temp_1.items
|
|
1139
|
+
local nextKey = ____temp_1.nextKey
|
|
1140
|
+
local key = self.firstKey
|
|
1141
|
+
return {
|
|
1142
|
+
[Symbol.iterator] = function(self)
|
|
1143
|
+
return self
|
|
1144
|
+
end,
|
|
1145
|
+
next = function(self)
|
|
1146
|
+
local result = {done = not key, value = items[key]}
|
|
1147
|
+
key = nextKey[key]
|
|
1148
|
+
return result
|
|
1070
1149
|
end
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
end
|
|
1076
|
-
function Map.prototype.entries(self)
|
|
1077
|
-
local ____ = self
|
|
1078
|
-
local items = ____.items
|
|
1079
|
-
local nextKey = ____.nextKey
|
|
1080
|
-
local key = self.firstKey
|
|
1081
|
-
return {
|
|
1082
|
-
[Symbol.iterator] = function(self)
|
|
1083
|
-
return self
|
|
1084
|
-
end,
|
|
1085
|
-
next = function(self)
|
|
1086
|
-
local result = {done = not key, value = {key, items[key]}}
|
|
1087
|
-
key = nextKey[key]
|
|
1088
|
-
return result
|
|
1089
|
-
end
|
|
1090
|
-
}
|
|
1091
|
-
end
|
|
1092
|
-
function Map.prototype.keys(self)
|
|
1093
|
-
local nextKey = self.nextKey
|
|
1094
|
-
local key = self.firstKey
|
|
1095
|
-
return {
|
|
1096
|
-
[Symbol.iterator] = function(self)
|
|
1097
|
-
return self
|
|
1098
|
-
end,
|
|
1099
|
-
next = function(self)
|
|
1100
|
-
local result = {done = not key, value = key}
|
|
1101
|
-
key = nextKey[key]
|
|
1102
|
-
return result
|
|
1103
|
-
end
|
|
1104
|
-
}
|
|
1105
|
-
end
|
|
1106
|
-
function Map.prototype.values(self)
|
|
1107
|
-
local ____ = self
|
|
1108
|
-
local items = ____.items
|
|
1109
|
-
local nextKey = ____.nextKey
|
|
1110
|
-
local key = self.firstKey
|
|
1111
|
-
return {
|
|
1112
|
-
[Symbol.iterator] = function(self)
|
|
1113
|
-
return self
|
|
1114
|
-
end,
|
|
1115
|
-
next = function(self)
|
|
1116
|
-
local result = {done = not key, value = items[key]}
|
|
1117
|
-
key = nextKey[key]
|
|
1118
|
-
return result
|
|
1119
|
-
end
|
|
1120
|
-
}
|
|
1121
|
-
end
|
|
1122
|
-
Map[Symbol.species] = Map
|
|
1123
|
-
return Map
|
|
1124
|
-
end)()
|
|
1150
|
+
}
|
|
1151
|
+
end
|
|
1152
|
+
Map[Symbol.species] = Map
|
|
1153
|
+
Map = Map
|
|
1125
1154
|
|
|
1126
1155
|
__TS__MathAtan2 = math.atan2 or math.atan
|
|
1127
1156
|
|
|
@@ -1146,14 +1175,14 @@ function __TS__Number(value)
|
|
|
1146
1175
|
end
|
|
1147
1176
|
return 0 / 0
|
|
1148
1177
|
elseif valueType == "boolean" then
|
|
1149
|
-
return
|
|
1178
|
+
return value and 1 or 0
|
|
1150
1179
|
else
|
|
1151
1180
|
return 0 / 0
|
|
1152
1181
|
end
|
|
1153
1182
|
end
|
|
1154
1183
|
|
|
1155
1184
|
function __TS__NumberIsFinite(value)
|
|
1156
|
-
return
|
|
1185
|
+
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
|
|
1157
1186
|
end
|
|
1158
1187
|
|
|
1159
1188
|
function __TS__NumberIsNaN(value)
|
|
@@ -1162,16 +1191,14 @@ end
|
|
|
1162
1191
|
|
|
1163
1192
|
____radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
1164
1193
|
function __TS__NumberToString(self, radix)
|
|
1165
|
-
if
|
|
1194
|
+
if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
|
|
1166
1195
|
return tostring(self)
|
|
1167
1196
|
end
|
|
1168
1197
|
radix = math.floor(radix)
|
|
1169
|
-
if
|
|
1198
|
+
if radix < 2 or radix > 36 then
|
|
1170
1199
|
error("toString() radix argument must be between 2 and 36", 0)
|
|
1171
1200
|
end
|
|
1172
|
-
local integer, fraction = math.modf(
|
|
1173
|
-
math.abs(self)
|
|
1174
|
-
)
|
|
1201
|
+
local integer, fraction = math.modf(math.abs(self))
|
|
1175
1202
|
local result = ""
|
|
1176
1203
|
if radix == 8 then
|
|
1177
1204
|
result = string.format("%o", integer)
|
|
@@ -1205,9 +1232,15 @@ function __TS__NumberToString(self, radix)
|
|
|
1205
1232
|
end
|
|
1206
1233
|
|
|
1207
1234
|
function __TS__ObjectDefineProperty(target, key, desc)
|
|
1208
|
-
local
|
|
1235
|
+
local ____temp_0
|
|
1236
|
+
if type(key) == "number" then
|
|
1237
|
+
____temp_0 = key + 1
|
|
1238
|
+
else
|
|
1239
|
+
____temp_0 = key
|
|
1240
|
+
end
|
|
1241
|
+
local luaKey = ____temp_0
|
|
1209
1242
|
local value = rawget(target, luaKey)
|
|
1210
|
-
local hasGetterOrSetter =
|
|
1243
|
+
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
|
|
1211
1244
|
local descriptor
|
|
1212
1245
|
if hasGetterOrSetter then
|
|
1213
1246
|
if value ~= nil then
|
|
@@ -1219,13 +1252,39 @@ function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1219
1252
|
descriptor = desc
|
|
1220
1253
|
else
|
|
1221
1254
|
local valueExists = value ~= nil
|
|
1255
|
+
local ____desc_set_5 = desc.set
|
|
1256
|
+
local ____desc_get_6 = desc.get
|
|
1257
|
+
local ____temp_1
|
|
1258
|
+
if desc.configurable ~= nil then
|
|
1259
|
+
____temp_1 = desc.configurable
|
|
1260
|
+
else
|
|
1261
|
+
____temp_1 = valueExists
|
|
1262
|
+
end
|
|
1263
|
+
local ____temp_2
|
|
1264
|
+
if desc.enumerable ~= nil then
|
|
1265
|
+
____temp_2 = desc.enumerable
|
|
1266
|
+
else
|
|
1267
|
+
____temp_2 = valueExists
|
|
1268
|
+
end
|
|
1269
|
+
local ____temp_3
|
|
1270
|
+
if desc.writable ~= nil then
|
|
1271
|
+
____temp_3 = desc.writable
|
|
1272
|
+
else
|
|
1273
|
+
____temp_3 = valueExists
|
|
1274
|
+
end
|
|
1275
|
+
local ____temp_4
|
|
1276
|
+
if desc.value ~= nil then
|
|
1277
|
+
____temp_4 = desc.value
|
|
1278
|
+
else
|
|
1279
|
+
____temp_4 = value
|
|
1280
|
+
end
|
|
1222
1281
|
descriptor = {
|
|
1223
|
-
set =
|
|
1224
|
-
get =
|
|
1225
|
-
configurable =
|
|
1226
|
-
enumerable =
|
|
1227
|
-
writable =
|
|
1228
|
-
value =
|
|
1282
|
+
set = ____desc_set_5,
|
|
1283
|
+
get = ____desc_get_6,
|
|
1284
|
+
configurable = ____temp_1,
|
|
1285
|
+
enumerable = ____temp_2,
|
|
1286
|
+
writable = ____temp_3,
|
|
1287
|
+
value = ____temp_4
|
|
1229
1288
|
}
|
|
1230
1289
|
end
|
|
1231
1290
|
__TS__SetDescriptor(target, luaKey, descriptor)
|
|
@@ -1287,41 +1346,19 @@ function __TS__ObjectValues(obj)
|
|
|
1287
1346
|
return result
|
|
1288
1347
|
end
|
|
1289
1348
|
|
|
1290
|
-
function __TS__OptionalChainAccess(____table, key)
|
|
1291
|
-
if ____table then
|
|
1292
|
-
return ____table[key]
|
|
1293
|
-
end
|
|
1294
|
-
return nil
|
|
1295
|
-
end
|
|
1296
|
-
|
|
1297
|
-
function __TS__OptionalFunctionCall(f, ...)
|
|
1298
|
-
if f then
|
|
1299
|
-
return f(...)
|
|
1300
|
-
end
|
|
1301
|
-
return nil
|
|
1302
|
-
end
|
|
1303
|
-
|
|
1304
|
-
function __TS__OptionalMethodCall(____table, methodName, isMethodOptional, ...)
|
|
1305
|
-
if ____table then
|
|
1306
|
-
local method = ____table[methodName]
|
|
1307
|
-
if method then
|
|
1308
|
-
return method(____table, ...)
|
|
1309
|
-
elseif not isMethodOptional then
|
|
1310
|
-
error(methodName .. " is not a function", 0)
|
|
1311
|
-
end
|
|
1312
|
-
end
|
|
1313
|
-
return nil
|
|
1314
|
-
end
|
|
1315
|
-
|
|
1316
1349
|
function __TS__ParseFloat(numberString)
|
|
1317
1350
|
local infinityMatch = string.match(numberString, "^%s*(-?Infinity)")
|
|
1318
1351
|
if infinityMatch then
|
|
1319
|
-
|
|
1352
|
+
local ____temp_0
|
|
1353
|
+
if __TS__StringAccess(infinityMatch, 0) == "-" then
|
|
1354
|
+
____temp_0 = -math.huge
|
|
1355
|
+
else
|
|
1356
|
+
____temp_0 = math.huge
|
|
1357
|
+
end
|
|
1358
|
+
return ____temp_0
|
|
1320
1359
|
end
|
|
1321
|
-
local number = tonumber(
|
|
1322
|
-
|
|
1323
|
-
)
|
|
1324
|
-
return number or (0 / 0)
|
|
1360
|
+
local number = tonumber(string.match(numberString, "^%s*(-?%d+%.?%d*)"))
|
|
1361
|
+
return number or 0 / 0
|
|
1325
1362
|
end
|
|
1326
1363
|
|
|
1327
1364
|
function __TS__StringSubstr(self, from, length)
|
|
@@ -1329,7 +1366,7 @@ function __TS__StringSubstr(self, from, length)
|
|
|
1329
1366
|
from = 0
|
|
1330
1367
|
end
|
|
1331
1368
|
if length ~= nil then
|
|
1332
|
-
if
|
|
1369
|
+
if length ~= length or length <= 0 then
|
|
1333
1370
|
return ""
|
|
1334
1371
|
end
|
|
1335
1372
|
length = length + from
|
|
@@ -1344,7 +1381,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
1344
1381
|
if ____end ~= ____end then
|
|
1345
1382
|
____end = 0
|
|
1346
1383
|
end
|
|
1347
|
-
if
|
|
1384
|
+
if ____end ~= nil and start > ____end then
|
|
1348
1385
|
start, ____end = ____end, start
|
|
1349
1386
|
end
|
|
1350
1387
|
if start >= 0 then
|
|
@@ -1352,7 +1389,7 @@ function __TS__StringSubstring(self, start, ____end)
|
|
|
1352
1389
|
else
|
|
1353
1390
|
start = 1
|
|
1354
1391
|
end
|
|
1355
|
-
if
|
|
1392
|
+
if ____end ~= nil and ____end < 0 then
|
|
1356
1393
|
____end = 0
|
|
1357
1394
|
end
|
|
1358
1395
|
return string.sub(self, start, ____end)
|
|
@@ -1365,13 +1402,25 @@ function __TS__ParseInt(numberString, base)
|
|
|
1365
1402
|
local hexMatch = string.match(numberString, "^%s*-?0[xX]")
|
|
1366
1403
|
if hexMatch then
|
|
1367
1404
|
base = 16
|
|
1368
|
-
|
|
1405
|
+
local ____string_match_result__0_0
|
|
1406
|
+
if string.match(hexMatch, "-") then
|
|
1407
|
+
____string_match_result__0_0 = "-" .. __TS__StringSubstr(numberString, #hexMatch)
|
|
1408
|
+
else
|
|
1409
|
+
____string_match_result__0_0 = __TS__StringSubstr(numberString, #hexMatch)
|
|
1410
|
+
end
|
|
1411
|
+
numberString = ____string_match_result__0_0
|
|
1369
1412
|
end
|
|
1370
1413
|
end
|
|
1371
|
-
if
|
|
1414
|
+
if base < 2 or base > 36 then
|
|
1372
1415
|
return 0 / 0
|
|
1373
1416
|
end
|
|
1374
|
-
local
|
|
1417
|
+
local ____temp_1
|
|
1418
|
+
if base <= 10 then
|
|
1419
|
+
____temp_1 = __TS__StringSubstring(__TS__parseInt_base_pattern, 0, base)
|
|
1420
|
+
else
|
|
1421
|
+
____temp_1 = __TS__StringSubstr(__TS__parseInt_base_pattern, 0, 10 + 2 * (base - 10))
|
|
1422
|
+
end
|
|
1423
|
+
local allowedDigits = ____temp_1
|
|
1375
1424
|
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
|
|
1376
1425
|
local number = tonumber(
|
|
1377
1426
|
string.match(numberString, pattern),
|
|
@@ -1417,18 +1466,19 @@ function __TS__Promise.prototype.____constructor(self, executor)
|
|
|
1417
1466
|
self.rejectedCallbacks = {}
|
|
1418
1467
|
self.finallyCallbacks = {}
|
|
1419
1468
|
do
|
|
1420
|
-
local
|
|
1421
|
-
function()
|
|
1422
|
-
executor(
|
|
1423
|
-
_G,
|
|
1424
|
-
__TS__FunctionBind(self.resolve, self),
|
|
1425
|
-
__TS__FunctionBind(self.reject, self)
|
|
1426
|
-
)
|
|
1427
|
-
end
|
|
1428
|
-
)
|
|
1429
|
-
if not ____try then
|
|
1469
|
+
local function ____catch(e)
|
|
1430
1470
|
self:reject(e)
|
|
1431
1471
|
end
|
|
1472
|
+
local ____try, ____hasReturned = pcall(function()
|
|
1473
|
+
executor(
|
|
1474
|
+
_G,
|
|
1475
|
+
__TS__FunctionBind(self.resolve, self),
|
|
1476
|
+
__TS__FunctionBind(self.reject, self)
|
|
1477
|
+
)
|
|
1478
|
+
end)
|
|
1479
|
+
if not ____try then
|
|
1480
|
+
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1481
|
+
end
|
|
1432
1482
|
end
|
|
1433
1483
|
end
|
|
1434
1484
|
function __TS__Promise.resolve(data)
|
|
@@ -1452,14 +1502,16 @@ function __TS__Promise.reject(reason)
|
|
|
1452
1502
|
return promise
|
|
1453
1503
|
end
|
|
1454
1504
|
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
1455
|
-
local
|
|
1456
|
-
local promise =
|
|
1457
|
-
local resolve =
|
|
1458
|
-
local reject =
|
|
1505
|
+
local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
|
|
1506
|
+
local promise = ____TS__PromiseDeferred_result_0.promise
|
|
1507
|
+
local resolve = ____TS__PromiseDeferred_result_0.resolve
|
|
1508
|
+
local reject = ____TS__PromiseDeferred_result_0.reject
|
|
1509
|
+
local isFulfilled = self.state == __TS__PromiseState.Fulfilled
|
|
1510
|
+
local isRejected = self.state == __TS__PromiseState.Rejected
|
|
1459
1511
|
if onFulfilled then
|
|
1460
1512
|
local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
|
|
1461
1513
|
__TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
|
|
1462
|
-
if
|
|
1514
|
+
if isFulfilled then
|
|
1463
1515
|
internalCallback(_G, self.value)
|
|
1464
1516
|
end
|
|
1465
1517
|
else
|
|
@@ -1471,10 +1523,16 @@ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
|
|
|
1471
1523
|
if onRejected then
|
|
1472
1524
|
local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
|
|
1473
1525
|
__TS__ArrayPush(self.rejectedCallbacks, internalCallback)
|
|
1474
|
-
if
|
|
1526
|
+
if isRejected then
|
|
1475
1527
|
internalCallback(_G, self.rejectionReason)
|
|
1476
1528
|
end
|
|
1477
1529
|
end
|
|
1530
|
+
if isFulfilled then
|
|
1531
|
+
resolve(_G, self.value)
|
|
1532
|
+
end
|
|
1533
|
+
if isRejected then
|
|
1534
|
+
reject(_G, self.rejectionReason)
|
|
1535
|
+
end
|
|
1478
1536
|
return promise
|
|
1479
1537
|
end
|
|
1480
1538
|
function __TS__Promise.prototype.catch(self, onRejected)
|
|
@@ -1516,18 +1574,19 @@ end
|
|
|
1516
1574
|
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
|
|
1517
1575
|
return function(____, value)
|
|
1518
1576
|
do
|
|
1519
|
-
local
|
|
1520
|
-
function()
|
|
1521
|
-
self:handleCallbackData(
|
|
1522
|
-
f(_G, value),
|
|
1523
|
-
resolve,
|
|
1524
|
-
reject
|
|
1525
|
-
)
|
|
1526
|
-
end
|
|
1527
|
-
)
|
|
1528
|
-
if not ____try then
|
|
1577
|
+
local function ____catch(e)
|
|
1529
1578
|
reject(_G, e)
|
|
1530
1579
|
end
|
|
1580
|
+
local ____try, ____hasReturned = pcall(function()
|
|
1581
|
+
self:handleCallbackData(
|
|
1582
|
+
f(_G, value),
|
|
1583
|
+
resolve,
|
|
1584
|
+
reject
|
|
1585
|
+
)
|
|
1586
|
+
end)
|
|
1587
|
+
if not ____try then
|
|
1588
|
+
____hasReturned, ____returnValue = ____catch(____hasReturned)
|
|
1589
|
+
end
|
|
1531
1590
|
end
|
|
1532
1591
|
end
|
|
1533
1592
|
end
|
|
@@ -1711,226 +1770,239 @@ function __TS__PromiseRace(iterable)
|
|
|
1711
1770
|
)
|
|
1712
1771
|
end
|
|
1713
1772
|
|
|
1714
|
-
Set = (
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
return
|
|
1724
|
-
end
|
|
1725
|
-
local iterable = values
|
|
1726
|
-
if iterable[Symbol.iterator] then
|
|
1727
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1728
|
-
while true do
|
|
1729
|
-
local result = iterator:next()
|
|
1730
|
-
if result.done then
|
|
1731
|
-
break
|
|
1732
|
-
end
|
|
1733
|
-
self:add(result.value)
|
|
1734
|
-
end
|
|
1735
|
-
else
|
|
1736
|
-
local array = values
|
|
1737
|
-
for ____, value in ipairs(array) do
|
|
1738
|
-
self:add(value)
|
|
1739
|
-
end
|
|
1740
|
-
end
|
|
1741
|
-
end
|
|
1742
|
-
function Set.prototype.add(self, value)
|
|
1743
|
-
local isNewValue = not self:has(value)
|
|
1744
|
-
if isNewValue then
|
|
1745
|
-
self.size = self.size + 1
|
|
1746
|
-
end
|
|
1747
|
-
if self.firstKey == nil then
|
|
1748
|
-
self.firstKey = value
|
|
1749
|
-
self.lastKey = value
|
|
1750
|
-
elseif isNewValue then
|
|
1751
|
-
self.nextKey[self.lastKey] = value
|
|
1752
|
-
self.previousKey[value] = self.lastKey
|
|
1753
|
-
self.lastKey = value
|
|
1754
|
-
end
|
|
1755
|
-
return self
|
|
1773
|
+
Set = __TS__Class()
|
|
1774
|
+
Set.name = "Set"
|
|
1775
|
+
function Set.prototype.____constructor(self, values)
|
|
1776
|
+
self[Symbol.toStringTag] = "Set"
|
|
1777
|
+
self.size = 0
|
|
1778
|
+
self.nextKey = {}
|
|
1779
|
+
self.previousKey = {}
|
|
1780
|
+
if values == nil then
|
|
1781
|
+
return
|
|
1756
1782
|
end
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
function Set.prototype.delete(self, value)
|
|
1765
|
-
local contains = self:has(value)
|
|
1766
|
-
if contains then
|
|
1767
|
-
self.size = self.size - 1
|
|
1768
|
-
local next = self.nextKey[value]
|
|
1769
|
-
local previous = self.previousKey[value]
|
|
1770
|
-
if next and previous then
|
|
1771
|
-
self.nextKey[previous] = next
|
|
1772
|
-
self.previousKey[next] = previous
|
|
1773
|
-
elseif next then
|
|
1774
|
-
self.firstKey = next
|
|
1775
|
-
self.previousKey[next] = nil
|
|
1776
|
-
elseif previous then
|
|
1777
|
-
self.lastKey = previous
|
|
1778
|
-
self.nextKey[previous] = nil
|
|
1779
|
-
else
|
|
1780
|
-
self.firstKey = nil
|
|
1781
|
-
self.lastKey = nil
|
|
1783
|
+
local iterable = values
|
|
1784
|
+
if iterable[Symbol.iterator] then
|
|
1785
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1786
|
+
while true do
|
|
1787
|
+
local result = iterator:next()
|
|
1788
|
+
if result.done then
|
|
1789
|
+
break
|
|
1782
1790
|
end
|
|
1783
|
-
self.
|
|
1784
|
-
self.previousKey[value] = nil
|
|
1791
|
+
self:add(result.value)
|
|
1785
1792
|
end
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
self:keys()
|
|
1791
|
-
) do
|
|
1792
|
-
callback(_G, key, key, self)
|
|
1793
|
+
else
|
|
1794
|
+
local array = values
|
|
1795
|
+
for ____, value in ipairs(array) do
|
|
1796
|
+
self:add(value)
|
|
1793
1797
|
end
|
|
1794
1798
|
end
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1799
|
+
end
|
|
1800
|
+
function Set.prototype.add(self, value)
|
|
1801
|
+
local isNewValue = not self:has(value)
|
|
1802
|
+
if isNewValue then
|
|
1803
|
+
self.size = self.size + 1
|
|
1800
1804
|
end
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
next = function(self)
|
|
1809
|
-
local result = {done = not key, value = {key, key}}
|
|
1810
|
-
key = nextKey[key]
|
|
1811
|
-
return result
|
|
1812
|
-
end
|
|
1813
|
-
}
|
|
1805
|
+
if self.firstKey == nil then
|
|
1806
|
+
self.firstKey = value
|
|
1807
|
+
self.lastKey = value
|
|
1808
|
+
elseif isNewValue then
|
|
1809
|
+
self.nextKey[self.lastKey] = value
|
|
1810
|
+
self.previousKey[value] = self.lastKey
|
|
1811
|
+
self.lastKey = value
|
|
1814
1812
|
end
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
return result
|
|
1840
|
-
end
|
|
1841
|
-
}
|
|
1842
|
-
end
|
|
1843
|
-
Set[Symbol.species] = Set
|
|
1844
|
-
return Set
|
|
1845
|
-
end)()
|
|
1846
|
-
|
|
1847
|
-
WeakMap = (function()
|
|
1848
|
-
local WeakMap = __TS__Class()
|
|
1849
|
-
WeakMap.name = "WeakMap"
|
|
1850
|
-
function WeakMap.prototype.____constructor(self, entries)
|
|
1851
|
-
self[Symbol.toStringTag] = "WeakMap"
|
|
1852
|
-
self.items = {}
|
|
1853
|
-
setmetatable(self.items, {__mode = "k"})
|
|
1854
|
-
if entries == nil then
|
|
1855
|
-
return
|
|
1856
|
-
end
|
|
1857
|
-
local iterable = entries
|
|
1858
|
-
if iterable[Symbol.iterator] then
|
|
1859
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1860
|
-
while true do
|
|
1861
|
-
local result = iterator:next()
|
|
1862
|
-
if result.done then
|
|
1863
|
-
break
|
|
1864
|
-
end
|
|
1865
|
-
local value = result.value
|
|
1866
|
-
self.items[value[1]] = value[2]
|
|
1867
|
-
end
|
|
1813
|
+
return self
|
|
1814
|
+
end
|
|
1815
|
+
function Set.prototype.clear(self)
|
|
1816
|
+
self.nextKey = {}
|
|
1817
|
+
self.previousKey = {}
|
|
1818
|
+
self.firstKey = nil
|
|
1819
|
+
self.lastKey = nil
|
|
1820
|
+
self.size = 0
|
|
1821
|
+
end
|
|
1822
|
+
function Set.prototype.delete(self, value)
|
|
1823
|
+
local contains = self:has(value)
|
|
1824
|
+
if contains then
|
|
1825
|
+
self.size = self.size - 1
|
|
1826
|
+
local next = self.nextKey[value]
|
|
1827
|
+
local previous = self.previousKey[value]
|
|
1828
|
+
if next and previous then
|
|
1829
|
+
self.nextKey[previous] = next
|
|
1830
|
+
self.previousKey[next] = previous
|
|
1831
|
+
elseif next then
|
|
1832
|
+
self.firstKey = next
|
|
1833
|
+
self.previousKey[next] = nil
|
|
1834
|
+
elseif previous then
|
|
1835
|
+
self.lastKey = previous
|
|
1836
|
+
self.nextKey[previous] = nil
|
|
1868
1837
|
else
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
end
|
|
1838
|
+
self.firstKey = nil
|
|
1839
|
+
self.lastKey = nil
|
|
1872
1840
|
end
|
|
1841
|
+
self.nextKey[value] = nil
|
|
1842
|
+
self.previousKey[value] = nil
|
|
1873
1843
|
end
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
function WeakMap.prototype.get(self, key)
|
|
1880
|
-
return self.items[key]
|
|
1844
|
+
return contains
|
|
1845
|
+
end
|
|
1846
|
+
function Set.prototype.forEach(self, callback)
|
|
1847
|
+
for ____, key in __TS__Iterator(self:keys()) do
|
|
1848
|
+
callback(_G, key, key, self)
|
|
1881
1849
|
end
|
|
1882
|
-
|
|
1883
|
-
|
|
1850
|
+
end
|
|
1851
|
+
function Set.prototype.has(self, value)
|
|
1852
|
+
return self.nextKey[value] ~= nil or self.lastKey == value
|
|
1853
|
+
end
|
|
1854
|
+
Set.prototype[Symbol.iterator] = function(self)
|
|
1855
|
+
return self:values()
|
|
1856
|
+
end
|
|
1857
|
+
function Set.prototype.entries(self)
|
|
1858
|
+
local nextKey = self.nextKey
|
|
1859
|
+
local key = self.firstKey
|
|
1860
|
+
return {
|
|
1861
|
+
[Symbol.iterator] = function(self)
|
|
1862
|
+
return self
|
|
1863
|
+
end,
|
|
1864
|
+
next = function(self)
|
|
1865
|
+
local result = {done = not key, value = {key, key}}
|
|
1866
|
+
key = nextKey[key]
|
|
1867
|
+
return result
|
|
1868
|
+
end
|
|
1869
|
+
}
|
|
1870
|
+
end
|
|
1871
|
+
function Set.prototype.keys(self)
|
|
1872
|
+
local nextKey = self.nextKey
|
|
1873
|
+
local key = self.firstKey
|
|
1874
|
+
return {
|
|
1875
|
+
[Symbol.iterator] = function(self)
|
|
1876
|
+
return self
|
|
1877
|
+
end,
|
|
1878
|
+
next = function(self)
|
|
1879
|
+
local result = {done = not key, value = key}
|
|
1880
|
+
key = nextKey[key]
|
|
1881
|
+
return result
|
|
1882
|
+
end
|
|
1883
|
+
}
|
|
1884
|
+
end
|
|
1885
|
+
function Set.prototype.values(self)
|
|
1886
|
+
local nextKey = self.nextKey
|
|
1887
|
+
local key = self.firstKey
|
|
1888
|
+
return {
|
|
1889
|
+
[Symbol.iterator] = function(self)
|
|
1890
|
+
return self
|
|
1891
|
+
end,
|
|
1892
|
+
next = function(self)
|
|
1893
|
+
local result = {done = not key, value = key}
|
|
1894
|
+
key = nextKey[key]
|
|
1895
|
+
return result
|
|
1896
|
+
end
|
|
1897
|
+
}
|
|
1898
|
+
end
|
|
1899
|
+
Set[Symbol.species] = Set
|
|
1900
|
+
Set = Set
|
|
1901
|
+
|
|
1902
|
+
function __TS__SparseArrayNew(...)
|
|
1903
|
+
local sparseArray = {...}
|
|
1904
|
+
sparseArray.sparseLength = select("#", ...)
|
|
1905
|
+
return sparseArray
|
|
1906
|
+
end
|
|
1907
|
+
|
|
1908
|
+
function __TS__SparseArrayPush(sparseArray, ...)
|
|
1909
|
+
local args = {...}
|
|
1910
|
+
local argsLen = select("#", ...)
|
|
1911
|
+
local listLen = sparseArray.sparseLength
|
|
1912
|
+
for i = 1, argsLen do
|
|
1913
|
+
sparseArray[listLen + i] = args[i]
|
|
1884
1914
|
end
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1915
|
+
sparseArray.sparseLength = listLen + argsLen
|
|
1916
|
+
end
|
|
1917
|
+
|
|
1918
|
+
function __TS__SparseArraySpread(sparseArray)
|
|
1919
|
+
local _unpack = unpack or table.unpack
|
|
1920
|
+
return _unpack(sparseArray, 1, sparseArray.sparseLength)
|
|
1921
|
+
end
|
|
1922
|
+
|
|
1923
|
+
WeakMap = __TS__Class()
|
|
1924
|
+
WeakMap.name = "WeakMap"
|
|
1925
|
+
function WeakMap.prototype.____constructor(self, entries)
|
|
1926
|
+
self[Symbol.toStringTag] = "WeakMap"
|
|
1927
|
+
self.items = {}
|
|
1928
|
+
setmetatable(self.items, {__mode = "k"})
|
|
1929
|
+
if entries == nil then
|
|
1930
|
+
return
|
|
1888
1931
|
end
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
function WeakSet.prototype.____constructor(self, values)
|
|
1897
|
-
self[Symbol.toStringTag] = "WeakSet"
|
|
1898
|
-
self.items = {}
|
|
1899
|
-
setmetatable(self.items, {__mode = "k"})
|
|
1900
|
-
if values == nil then
|
|
1901
|
-
return
|
|
1902
|
-
end
|
|
1903
|
-
local iterable = values
|
|
1904
|
-
if iterable[Symbol.iterator] then
|
|
1905
|
-
local iterator = iterable[Symbol.iterator](iterable)
|
|
1906
|
-
while true do
|
|
1907
|
-
local result = iterator:next()
|
|
1908
|
-
if result.done then
|
|
1909
|
-
break
|
|
1910
|
-
end
|
|
1911
|
-
self.items[result.value] = true
|
|
1912
|
-
end
|
|
1913
|
-
else
|
|
1914
|
-
for ____, value in ipairs(values) do
|
|
1915
|
-
self.items[value] = true
|
|
1932
|
+
local iterable = entries
|
|
1933
|
+
if iterable[Symbol.iterator] then
|
|
1934
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1935
|
+
while true do
|
|
1936
|
+
local result = iterator:next()
|
|
1937
|
+
if result.done then
|
|
1938
|
+
break
|
|
1916
1939
|
end
|
|
1940
|
+
local value = result.value
|
|
1941
|
+
self.items[value[1]] = value[2]
|
|
1942
|
+
end
|
|
1943
|
+
else
|
|
1944
|
+
for ____, kvp in ipairs(entries) do
|
|
1945
|
+
self.items[kvp[1]] = kvp[2]
|
|
1917
1946
|
end
|
|
1918
1947
|
end
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1948
|
+
end
|
|
1949
|
+
function WeakMap.prototype.delete(self, key)
|
|
1950
|
+
local contains = self:has(key)
|
|
1951
|
+
self.items[key] = nil
|
|
1952
|
+
return contains
|
|
1953
|
+
end
|
|
1954
|
+
function WeakMap.prototype.get(self, key)
|
|
1955
|
+
return self.items[key]
|
|
1956
|
+
end
|
|
1957
|
+
function WeakMap.prototype.has(self, key)
|
|
1958
|
+
return self.items[key] ~= nil
|
|
1959
|
+
end
|
|
1960
|
+
function WeakMap.prototype.set(self, key, value)
|
|
1961
|
+
self.items[key] = value
|
|
1962
|
+
return self
|
|
1963
|
+
end
|
|
1964
|
+
WeakMap[Symbol.species] = WeakMap
|
|
1965
|
+
WeakMap = WeakMap
|
|
1966
|
+
|
|
1967
|
+
WeakSet = __TS__Class()
|
|
1968
|
+
WeakSet.name = "WeakSet"
|
|
1969
|
+
function WeakSet.prototype.____constructor(self, values)
|
|
1970
|
+
self[Symbol.toStringTag] = "WeakSet"
|
|
1971
|
+
self.items = {}
|
|
1972
|
+
setmetatable(self.items, {__mode = "k"})
|
|
1973
|
+
if values == nil then
|
|
1974
|
+
return
|
|
1927
1975
|
end
|
|
1928
|
-
|
|
1929
|
-
|
|
1976
|
+
local iterable = values
|
|
1977
|
+
if iterable[Symbol.iterator] then
|
|
1978
|
+
local iterator = iterable[Symbol.iterator](iterable)
|
|
1979
|
+
while true do
|
|
1980
|
+
local result = iterator:next()
|
|
1981
|
+
if result.done then
|
|
1982
|
+
break
|
|
1983
|
+
end
|
|
1984
|
+
self.items[result.value] = true
|
|
1985
|
+
end
|
|
1986
|
+
else
|
|
1987
|
+
for ____, value in ipairs(values) do
|
|
1988
|
+
self.items[value] = true
|
|
1989
|
+
end
|
|
1930
1990
|
end
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1991
|
+
end
|
|
1992
|
+
function WeakSet.prototype.add(self, value)
|
|
1993
|
+
self.items[value] = true
|
|
1994
|
+
return self
|
|
1995
|
+
end
|
|
1996
|
+
function WeakSet.prototype.delete(self, value)
|
|
1997
|
+
local contains = self:has(value)
|
|
1998
|
+
self.items[value] = nil
|
|
1999
|
+
return contains
|
|
2000
|
+
end
|
|
2001
|
+
function WeakSet.prototype.has(self, value)
|
|
2002
|
+
return self.items[value] == true
|
|
2003
|
+
end
|
|
2004
|
+
WeakSet[Symbol.species] = WeakSet
|
|
2005
|
+
WeakSet = WeakSet
|
|
1934
2006
|
|
|
1935
2007
|
function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
1936
2008
|
_G.__TS__sourcemap = _G.__TS__sourcemap or ({})
|
|
@@ -1939,7 +2011,7 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
1939
2011
|
_G.__TS__originalTraceback = debug.traceback
|
|
1940
2012
|
debug.traceback = function(thread, message, level)
|
|
1941
2013
|
local trace
|
|
1942
|
-
if
|
|
2014
|
+
if thread == nil and message == nil and level == nil then
|
|
1943
2015
|
trace = _G.__TS__originalTraceback()
|
|
1944
2016
|
else
|
|
1945
2017
|
trace = _G.__TS__originalTraceback(thread, message, level)
|
|
@@ -1947,16 +2019,26 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
1947
2019
|
if type(trace) ~= "string" then
|
|
1948
2020
|
return trace
|
|
1949
2021
|
end
|
|
1950
|
-
local
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
return (file .. ".ts:") .. tostring(fileSourceMap[line])
|
|
2022
|
+
local function replacer(____, file, srcFile, line)
|
|
2023
|
+
local fileSourceMap = _G.__TS__sourcemap[file]
|
|
2024
|
+
if fileSourceMap and fileSourceMap[line] then
|
|
2025
|
+
local data = fileSourceMap[line]
|
|
2026
|
+
if type(data) == "number" then
|
|
2027
|
+
return (srcFile .. ":") .. tostring(data)
|
|
1957
2028
|
end
|
|
1958
|
-
return (file .. "
|
|
2029
|
+
return (tostring(data.file) .. ":") .. tostring(data.line)
|
|
1959
2030
|
end
|
|
2031
|
+
return (file .. ":") .. line
|
|
2032
|
+
end
|
|
2033
|
+
local result = string.gsub(
|
|
2034
|
+
trace,
|
|
2035
|
+
"(%S+)%.lua:(%d+)",
|
|
2036
|
+
function(file, line) return replacer(_G, file .. ".lua", file .. ".ts", line) end
|
|
2037
|
+
)
|
|
2038
|
+
result = string.gsub(
|
|
2039
|
+
result,
|
|
2040
|
+
"(%[string \"[^\"]+\"%]):(%d+)",
|
|
2041
|
+
function(file, line) return replacer(_G, file, "unknown", line) end
|
|
1960
2042
|
)
|
|
1961
2043
|
return result
|
|
1962
2044
|
end
|
|
@@ -1998,7 +2080,7 @@ function __TS__StringCharCodeAt(self, index)
|
|
|
1998
2080
|
if index < 0 then
|
|
1999
2081
|
return 0 / 0
|
|
2000
2082
|
end
|
|
2001
|
-
return string.byte(self, index + 1) or
|
|
2083
|
+
return string.byte(self, index + 1) or 0 / 0
|
|
2002
2084
|
end
|
|
2003
2085
|
|
|
2004
2086
|
function __TS__StringConcat(str1, ...)
|
|
@@ -2011,10 +2093,10 @@ function __TS__StringConcat(str1, ...)
|
|
|
2011
2093
|
end
|
|
2012
2094
|
|
|
2013
2095
|
function __TS__StringEndsWith(self, searchString, endPosition)
|
|
2014
|
-
if
|
|
2096
|
+
if endPosition == nil or endPosition > #self then
|
|
2015
2097
|
endPosition = #self
|
|
2016
2098
|
end
|
|
2017
|
-
return string.sub(self,
|
|
2099
|
+
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
|
|
2018
2100
|
end
|
|
2019
2101
|
|
|
2020
2102
|
function __TS__StringIncludes(self, searchString, position)
|
|
@@ -2034,10 +2116,10 @@ function __TS__StringPadEnd(self, maxLength, fillString)
|
|
|
2034
2116
|
if maxLength ~= maxLength then
|
|
2035
2117
|
maxLength = 0
|
|
2036
2118
|
end
|
|
2037
|
-
if
|
|
2119
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
2038
2120
|
error("Invalid string length", 0)
|
|
2039
2121
|
end
|
|
2040
|
-
if
|
|
2122
|
+
if #self >= maxLength or #fillString == 0 then
|
|
2041
2123
|
return self
|
|
2042
2124
|
end
|
|
2043
2125
|
maxLength = maxLength - #self
|
|
@@ -2061,10 +2143,10 @@ function __TS__StringPadStart(self, maxLength, fillString)
|
|
|
2061
2143
|
if maxLength ~= maxLength then
|
|
2062
2144
|
maxLength = 0
|
|
2063
2145
|
end
|
|
2064
|
-
if
|
|
2146
|
+
if maxLength == -math.huge or maxLength == math.huge then
|
|
2065
2147
|
error("Invalid string length", 0)
|
|
2066
2148
|
end
|
|
2067
|
-
if
|
|
2149
|
+
if #self >= maxLength or #fillString == 0 then
|
|
2068
2150
|
return self
|
|
2069
2151
|
end
|
|
2070
2152
|
maxLength = maxLength - #self
|
|
@@ -2082,24 +2164,61 @@ function __TS__StringPadStart(self, maxLength, fillString)
|
|
|
2082
2164
|
end
|
|
2083
2165
|
|
|
2084
2166
|
function __TS__StringReplace(source, searchValue, replaceValue)
|
|
2085
|
-
|
|
2167
|
+
local startPos, endPos = string.find(source, searchValue, nil, true)
|
|
2168
|
+
if not startPos then
|
|
2169
|
+
return source
|
|
2170
|
+
end
|
|
2171
|
+
local sub = string.sub
|
|
2172
|
+
local before = sub(source, 1, startPos - 1)
|
|
2173
|
+
local ____temp_0
|
|
2086
2174
|
if type(replaceValue) == "string" then
|
|
2087
|
-
|
|
2088
|
-
local result = string.gsub(source, searchValue, replaceValue, 1)
|
|
2089
|
-
return result
|
|
2175
|
+
____temp_0 = replaceValue
|
|
2090
2176
|
else
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2177
|
+
____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
|
|
2178
|
+
end
|
|
2179
|
+
local replacement = ____temp_0
|
|
2180
|
+
local after = sub(source, endPos + 1)
|
|
2181
|
+
return (before .. replacement) .. after
|
|
2182
|
+
end
|
|
2183
|
+
|
|
2184
|
+
function __TS__StringReplaceAll(source, searchValue, replaceValue)
|
|
2185
|
+
local replacer
|
|
2186
|
+
if type(replaceValue) == "string" then
|
|
2187
|
+
replacer = function() return replaceValue end
|
|
2188
|
+
else
|
|
2189
|
+
replacer = replaceValue
|
|
2190
|
+
end
|
|
2191
|
+
local parts = {}
|
|
2192
|
+
local partsIndex = 1
|
|
2193
|
+
local sub = string.sub
|
|
2194
|
+
if #searchValue == 0 then
|
|
2195
|
+
parts[1] = replacer(_G, "", 0, source)
|
|
2196
|
+
partsIndex = 2
|
|
2197
|
+
for i = 1, #source do
|
|
2198
|
+
parts[partsIndex] = sub(source, i, i)
|
|
2199
|
+
parts[partsIndex + 1] = replacer(_G, "", i, source)
|
|
2200
|
+
partsIndex = partsIndex + 2
|
|
2201
|
+
end
|
|
2202
|
+
else
|
|
2203
|
+
local find = string.find
|
|
2204
|
+
local currentPos = 1
|
|
2205
|
+
while true do
|
|
2206
|
+
local startPos, endPos = find(source, searchValue, currentPos, true)
|
|
2207
|
+
if not startPos then
|
|
2208
|
+
break
|
|
2209
|
+
end
|
|
2210
|
+
parts[partsIndex] = sub(source, currentPos, startPos - 1)
|
|
2211
|
+
parts[partsIndex + 1] = replacer(_G, searchValue, startPos - 1, source)
|
|
2212
|
+
partsIndex = partsIndex + 2
|
|
2213
|
+
currentPos = endPos + 1
|
|
2214
|
+
end
|
|
2215
|
+
parts[partsIndex] = sub(source, currentPos)
|
|
2098
2216
|
end
|
|
2217
|
+
return table.concat(parts)
|
|
2099
2218
|
end
|
|
2100
2219
|
|
|
2101
2220
|
function __TS__StringSlice(self, start, ____end)
|
|
2102
|
-
if
|
|
2221
|
+
if start == nil or start ~= start then
|
|
2103
2222
|
start = 0
|
|
2104
2223
|
end
|
|
2105
2224
|
if ____end ~= ____end then
|
|
@@ -2108,7 +2227,7 @@ function __TS__StringSlice(self, start, ____end)
|
|
|
2108
2227
|
if start >= 0 then
|
|
2109
2228
|
start = start + 1
|
|
2110
2229
|
end
|
|
2111
|
-
if
|
|
2230
|
+
if ____end ~= nil and ____end < 0 then
|
|
2112
2231
|
____end = ____end - 1
|
|
2113
2232
|
end
|
|
2114
2233
|
return string.sub(self, start, ____end)
|
|
@@ -2124,8 +2243,8 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2124
2243
|
local out = {}
|
|
2125
2244
|
local index = 0
|
|
2126
2245
|
local count = 0
|
|
2127
|
-
if
|
|
2128
|
-
while
|
|
2246
|
+
if separator == nil or separator == "" then
|
|
2247
|
+
while index < #source - 1 and count < limit do
|
|
2129
2248
|
out[count + 1] = __TS__StringAccess(source, index)
|
|
2130
2249
|
count = count + 1
|
|
2131
2250
|
index = index + 1
|
|
@@ -2133,7 +2252,7 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2133
2252
|
else
|
|
2134
2253
|
local separatorLength = #separator
|
|
2135
2254
|
local nextIndex = (string.find(source, separator, nil, true) or 0) - 1
|
|
2136
|
-
while
|
|
2255
|
+
while nextIndex >= 0 and count < limit do
|
|
2137
2256
|
out[count + 1] = __TS__StringSubstring(source, index, nextIndex)
|
|
2138
2257
|
count = count + 1
|
|
2139
2258
|
index = nextIndex + separatorLength
|
|
@@ -2152,7 +2271,7 @@ function __TS__StringSplit(source, separator, limit)
|
|
|
2152
2271
|
end
|
|
2153
2272
|
|
|
2154
2273
|
function __TS__StringStartsWith(self, searchString, position)
|
|
2155
|
-
if
|
|
2274
|
+
if position == nil or position < 0 then
|
|
2156
2275
|
position = 0
|
|
2157
2276
|
end
|
|
2158
2277
|
return string.sub(self, position + 1, #searchString + position) == searchString
|