Petrichor-PSTVL/lualib_bundle.lua
2025-04-16 21:38:42 +08:00

1552 lines
46 KiB
Lua

local function __TS__Class(self)
local c = {prototype = {}}
c.prototype.__index = c.prototype
c.prototype.constructor = c
return c
end
local function __TS__New(target, ...)
local instance = setmetatable({}, target.prototype)
instance:____constructor(...)
return instance
end
local function __TS__CountVarargs(...)
return select("#", ...)
end
local function __TS__ArraySplice(self, ...)
local args = {...}
local len = #self
local actualArgumentCount = __TS__CountVarargs(...)
local start = args[1]
local deleteCount = args[2]
if start < 0 then
start = len + start
if start < 0 then
start = 0
end
elseif start > len then
start = len
end
local itemCount = actualArgumentCount - 2
if itemCount < 0 then
itemCount = 0
end
local actualDeleteCount
if actualArgumentCount == 0 then
actualDeleteCount = 0
elseif actualArgumentCount == 1 then
actualDeleteCount = len - start
else
actualDeleteCount = deleteCount or 0
if actualDeleteCount < 0 then
actualDeleteCount = 0
end
if actualDeleteCount > len - start then
actualDeleteCount = len - start
end
end
local out = {}
for k = 1, actualDeleteCount do
local from = start + k
if self[from] ~= nil then
out[k] = self[from]
end
end
if itemCount < actualDeleteCount then
for k = start + 1, len - actualDeleteCount do
local from = k + actualDeleteCount
local to = k + itemCount
if self[from] then
self[to] = self[from]
else
self[to] = nil
end
end
for k = len - actualDeleteCount + itemCount + 1, len do
self[k] = nil
end
elseif itemCount > actualDeleteCount then
for k = len - actualDeleteCount, start + 1, -1 do
local from = k + actualDeleteCount
local to = k + itemCount
if self[from] then
self[to] = self[from]
else
self[to] = nil
end
end
end
local j = start + 1
for i = 3, actualArgumentCount do
self[j] = args[i]
j = j + 1
end
for k = #self, len - actualDeleteCount + itemCount + 1, -1 do
self[k] = nil
end
return out
end
local function __TS__ArrayIncludes(self, searchElement, fromIndex)
if fromIndex == nil then
fromIndex = 0
end
local len = #self
local k = fromIndex
if fromIndex < 0 then
k = len + fromIndex
end
if k < 0 then
k = 0
end
for i = k + 1, len do
if self[i] == searchElement then
return true
end
end
return false
end
local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
if fromIndex == nil then
fromIndex = 0
end
local len = #self
if len == 0 then
return -1
end
if fromIndex >= len then
return -1
end
if fromIndex < 0 then
fromIndex = len + fromIndex
if fromIndex < 0 then
fromIndex = 0
end
end
for i = fromIndex + 1, len do
if self[i] == searchElement then
return i - 1
end
end
return -1
end
local function __TS__ArrayMap(self, callbackfn, thisArg)
local result = {}
for i = 1, #self do
result[i] = callbackfn(thisArg, self[i], i - 1, self)
end
return result
end
local function __TS__CloneDescriptor(____bindingPattern0)
local value
local writable
local set
local get
local configurable
local enumerable
enumerable = ____bindingPattern0.enumerable
configurable = ____bindingPattern0.configurable
get = ____bindingPattern0.get
set = ____bindingPattern0.set
writable = ____bindingPattern0.writable
value = ____bindingPattern0.value
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
local hasGetterOrSetter = get ~= nil or set ~= nil
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
if hasGetterOrSetter and hasValueOrWritableAttribute then
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
end
if get or set then
descriptor.get = get
descriptor.set = set
else
descriptor.value = value
descriptor.writable = writable == true
end
return descriptor
end
local __TS__DescriptorGet
do
local getmetatable = _G.getmetatable
local ____rawget = _G.rawget
function __TS__DescriptorGet(self, metatable, key)
while metatable do
local rawResult = ____rawget(metatable, key)
if rawResult ~= nil then
return rawResult
end
local descriptors = ____rawget(metatable, "_descriptors")
if descriptors then
local descriptor = descriptors[key]
if descriptor ~= nil then
if descriptor.get then
return descriptor.get(self)
end
return descriptor.value
end
end
metatable = getmetatable(metatable)
end
end
end
local __TS__DescriptorSet
do
local getmetatable = _G.getmetatable
local ____rawget = _G.rawget
local rawset = _G.rawset
function __TS__DescriptorSet(self, metatable, key, value)
while metatable do
local descriptors = ____rawget(metatable, "_descriptors")
if descriptors then
local descriptor = descriptors[key]
if descriptor ~= nil then
if descriptor.set then
descriptor.set(self, value)
else
if descriptor.writable == false then
error(
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
0
)
end
descriptor.value = value
end
return
end
end
metatable = getmetatable(metatable)
end
rawset(self, key, value)
end
end
local __TS__SetDescriptor
do
local getmetatable = _G.getmetatable
local function descriptorIndex(self, key)
return __TS__DescriptorGet(
self,
getmetatable(self),
key
)
end
local function descriptorNewIndex(self, key, value)
return __TS__DescriptorSet(
self,
getmetatable(self),
key,
value
)
end
function __TS__SetDescriptor(target, key, desc, isPrototype)
if isPrototype == nil then
isPrototype = false
end
local ____isPrototype_0
if isPrototype then
____isPrototype_0 = target
else
____isPrototype_0 = getmetatable(target)
end
local metatable = ____isPrototype_0
if not metatable then
metatable = {}
setmetatable(target, metatable)
end
local value = rawget(target, key)
if value ~= nil then
rawset(target, key, nil)
end
if not rawget(metatable, "_descriptors") then
metatable._descriptors = {}
end
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
metatable.__index = descriptorIndex
metatable.__newindex = descriptorNewIndex
end
end
local function __TS__ArraySlice(self, first, last)
local len = #self
first = first or 0
if first < 0 then
first = len + first
if first < 0 then
first = 0
end
else
if first > len then
first = len
end
end
last = last or len
if last < 0 then
last = len + last
if last < 0 then
last = 0
end
else
if last > len then
last = len
end
end
local out = {}
first = first + 1
last = last + 1
local n = 1
while first < last do
out[n] = self[first]
first = first + 1
n = n + 1
end
return out
end
local function __TS__ArrayPushArray(self, items)
local len = #self
for i = 1, #items do
len = len + 1
self[len] = items[i]
end
return len
end
local function __TS__StringAccess(self, index)
if index >= 0 and index < #self then
return string.sub(self, index + 1, index + 1)
end
end
local __TS__Symbol, Symbol
do
local symbolMetatable = {__tostring = function(self)
return ("Symbol(" .. (self.description or "")) .. ")"
end}
function __TS__Symbol(description)
return setmetatable({description = description}, symbolMetatable)
end
Symbol = {
asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
dispose = __TS__Symbol("Symbol.dispose"),
iterator = __TS__Symbol("Symbol.iterator"),
hasInstance = __TS__Symbol("Symbol.hasInstance"),
species = __TS__Symbol("Symbol.species"),
toStringTag = __TS__Symbol("Symbol.toStringTag")
}
end
local function __TS__DelegatedYield(iterable)
if type(iterable) == "string" then
for index = 0, #iterable - 1 do
coroutine.yield(__TS__StringAccess(iterable, index))
end
elseif iterable.____coroutine ~= nil then
local co = iterable.____coroutine
while true do
local status, value = coroutine.resume(co)
if not status then
error(value, 0)
end
if coroutine.status(co) == "dead" then
return value
else
coroutine.yield(value)
end
end
elseif iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
return result.value
else
coroutine.yield(result.value)
end
end
else
for ____, value in ipairs(iterable) do
coroutine.yield(value)
end
end
end
local __TS__Unpack = table.unpack or unpack
local __TS__Generator
do
local function generatorIterator(self)
return self
end
local function generatorNext(self, ...)
local co = self.____coroutine
if coroutine.status(co) == "dead" then
return {done = true}
end
local status, value = coroutine.resume(co, ...)
if not status then
error(value, 0)
end
return {
value = value,
done = coroutine.status(co) == "dead"
}
end
function __TS__Generator(fn)
return function(...)
local args = {...}
local argsLength = __TS__CountVarargs(...)
return {
____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
[Symbol.iterator] = generatorIterator,
next = generatorNext
}
end
end
end
local function __TS__ArrayEntries(array)
local key = 0
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
local result = {done = array[key + 1] == nil, value = {key, array[key + 1]}}
key = key + 1
return result
end
}
end
local __TS__Iterator
do
local function iteratorGeneratorStep(self)
local co = self.____coroutine
local status, value = coroutine.resume(co)
if not status then
error(value, 0)
end
if coroutine.status(co) == "dead" then
return
end
return true, value
end
local function iteratorIteratorStep(self)
local result = self:next()
if result.done then
return
end
return true, result.value
end
local function iteratorStringStep(self, index)
index = index + 1
if index > #self then
return
end
return index, string.sub(self, index, index)
end
function __TS__Iterator(iterable)
if type(iterable) == "string" then
return iteratorStringStep, iterable, 0
elseif iterable.____coroutine ~= nil then
return iteratorGeneratorStep, iterable
elseif iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
return iteratorIteratorStep, iterator
else
return ipairs(iterable)
end
end
end
local function __TS__InstanceOf(obj, classTbl)
if type(classTbl) ~= "table" then
error("Right-hand side of 'instanceof' is not an object", 0)
end
if classTbl[Symbol.hasInstance] ~= nil then
return not not classTbl[Symbol.hasInstance](classTbl, obj)
end
if type(obj) == "table" then
local luaClass = obj.constructor
while luaClass ~= nil do
if luaClass == classTbl then
return true
end
luaClass = luaClass.____super
end
end
return false
end
local __TS__Promise
do
local function makeDeferredPromiseFactory()
local resolve
local reject
local function executor(____, res, rej)
resolve = res
reject = rej
end
return function()
local promise = __TS__New(__TS__Promise, executor)
return promise, resolve, reject
end
end
local makeDeferredPromise = makeDeferredPromiseFactory()
local function isPromiseLike(value)
return __TS__InstanceOf(value, __TS__Promise)
end
local function doNothing(self)
end
local ____pcall = _G.pcall
__TS__Promise = __TS__Class()
__TS__Promise.name = "__TS__Promise"
function __TS__Promise.prototype.____constructor(self, executor)
self.state = 0
self.fulfilledCallbacks = {}
self.rejectedCallbacks = {}
self.finallyCallbacks = {}
local success, ____error = ____pcall(
executor,
nil,
function(____, v) return self:resolve(v) end,
function(____, err) return self:reject(err) end
)
if not success then
self:reject(____error)
end
end
function __TS__Promise.resolve(value)
if __TS__InstanceOf(value, __TS__Promise) then
return value
end
local promise = __TS__New(__TS__Promise, doNothing)
promise.state = 1
promise.value = value
return promise
end
function __TS__Promise.reject(reason)
local promise = __TS__New(__TS__Promise, doNothing)
promise.state = 2
promise.rejectionReason = reason
return promise
end
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
local promise, resolve, reject = makeDeferredPromise()
self:addCallbacks(
onFulfilled and self:createPromiseResolvingCallback(onFulfilled, resolve, reject) or resolve,
onRejected and self:createPromiseResolvingCallback(onRejected, resolve, reject) or reject
)
return promise
end
function __TS__Promise.prototype.addCallbacks(self, fulfilledCallback, rejectedCallback)
if self.state == 1 then
return fulfilledCallback(nil, self.value)
end
if self.state == 2 then
return rejectedCallback(nil, self.rejectionReason)
end
local ____self_fulfilledCallbacks_0 = self.fulfilledCallbacks
____self_fulfilledCallbacks_0[#____self_fulfilledCallbacks_0 + 1] = fulfilledCallback
local ____self_rejectedCallbacks_1 = self.rejectedCallbacks
____self_rejectedCallbacks_1[#____self_rejectedCallbacks_1 + 1] = rejectedCallback
end
function __TS__Promise.prototype.catch(self, onRejected)
return self["then"](self, nil, onRejected)
end
function __TS__Promise.prototype.finally(self, onFinally)
if onFinally then
local ____self_finallyCallbacks_2 = self.finallyCallbacks
____self_finallyCallbacks_2[#____self_finallyCallbacks_2 + 1] = onFinally
if self.state ~= 0 then
onFinally(nil)
end
end
return self
end
function __TS__Promise.prototype.resolve(self, value)
if isPromiseLike(value) then
return value:addCallbacks(
function(____, v) return self:resolve(v) end,
function(____, err) return self:reject(err) end
)
end
if self.state == 0 then
self.state = 1
self.value = value
return self:invokeCallbacks(self.fulfilledCallbacks, value)
end
end
function __TS__Promise.prototype.reject(self, reason)
if self.state == 0 then
self.state = 2
self.rejectionReason = reason
return self:invokeCallbacks(self.rejectedCallbacks, reason)
end
end
function __TS__Promise.prototype.invokeCallbacks(self, callbacks, value)
local callbacksLength = #callbacks
local finallyCallbacks = self.finallyCallbacks
local finallyCallbacksLength = #finallyCallbacks
if callbacksLength ~= 0 then
for i = 1, callbacksLength - 1 do
callbacks[i](callbacks, value)
end
if finallyCallbacksLength == 0 then
return callbacks[callbacksLength](callbacks, value)
end
callbacks[callbacksLength](callbacks, value)
end
if finallyCallbacksLength ~= 0 then
for i = 1, finallyCallbacksLength - 1 do
finallyCallbacks[i](finallyCallbacks)
end
return finallyCallbacks[finallyCallbacksLength](finallyCallbacks)
end
end
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
return function(____, value)
local success, resultOrError = ____pcall(f, nil, value)
if not success then
return reject(nil, resultOrError)
end
return self:handleCallbackValue(resultOrError, resolve, reject)
end
end
function __TS__Promise.prototype.handleCallbackValue(self, value, resolve, reject)
if isPromiseLike(value) then
local nextpromise = value
if nextpromise.state == 1 then
return resolve(nil, nextpromise.value)
elseif nextpromise.state == 2 then
return reject(nil, nextpromise.rejectionReason)
else
return nextpromise:addCallbacks(resolve, reject)
end
else
return resolve(nil, value)
end
end
end
local __TS__AsyncAwaiter, __TS__Await
do
local ____coroutine = _G.coroutine or ({})
local cocreate = ____coroutine.create
local coresume = ____coroutine.resume
local costatus = ____coroutine.status
local coyield = ____coroutine.yield
function __TS__AsyncAwaiter(generator)
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
local fulfilled, step, resolved, asyncCoroutine
function fulfilled(self, value)
local success, resultOrError = coresume(asyncCoroutine, value)
if success then
return step(resultOrError)
end
return reject(nil, resultOrError)
end
function step(result)
if resolved then
return
end
if costatus(asyncCoroutine) == "dead" then
return resolve(nil, result)
end
return __TS__Promise.resolve(result):addCallbacks(fulfilled, reject)
end
resolved = false
asyncCoroutine = cocreate(generator)
local success, resultOrError = coresume(
asyncCoroutine,
function(____, v)
resolved = true
return __TS__Promise.resolve(v):addCallbacks(resolve, reject)
end
)
if success then
return step(resultOrError)
else
return reject(nil, resultOrError)
end
end
)
end
function __TS__Await(thing)
return coyield(thing)
end
end
local function __TS__StringSlice(self, start, ____end)
if start == nil or start ~= start then
start = 0
end
if ____end ~= ____end then
____end = 0
end
if start >= 0 then
start = start + 1
end
if ____end ~= nil and ____end < 0 then
____end = ____end - 1
end
return string.sub(self, start, ____end)
end
local __TS__StringSplit
do
local sub = string.sub
local find = string.find
function __TS__StringSplit(source, separator, limit)
if limit == nil then
limit = 4294967295
end
if limit == 0 then
return {}
end
local result = {}
local resultIndex = 1
if separator == nil or separator == "" then
for i = 1, #source do
result[resultIndex] = sub(source, i, i)
resultIndex = resultIndex + 1
end
else
local currentPos = 1
while resultIndex <= limit do
local startPos, endPos = find(source, separator, currentPos, true)
if not startPos then
break
end
result[resultIndex] = sub(source, currentPos, startPos - 1)
resultIndex = resultIndex + 1
currentPos = endPos + 1
end
if resultIndex <= limit then
result[resultIndex] = sub(source, currentPos)
end
end
return result
end
end
local function __TS__ArrayFilter(self, callbackfn, thisArg)
local result = {}
local len = 0
for i = 1, #self do
if callbackfn(thisArg, self[i], i - 1, self) then
len = len + 1
result[len] = self[i]
end
end
return result
end
local function __TS__ClassExtends(target, base)
target.____super = base
local staticMetatable = setmetatable({__index = base}, base)
setmetatable(target, staticMetatable)
local baseMetatable = getmetatable(base)
if baseMetatable then
if type(baseMetatable.__index) == "function" then
staticMetatable.__index = baseMetatable.__index
end
if type(baseMetatable.__newindex) == "function" then
staticMetatable.__newindex = baseMetatable.__newindex
end
end
setmetatable(target.prototype, base.prototype)
if type(base.prototype.__index) == "function" then
target.prototype.__index = base.prototype.__index
end
if type(base.prototype.__newindex) == "function" then
target.prototype.__newindex = base.prototype.__newindex
end
if type(base.prototype.__tostring) == "function" then
target.prototype.__tostring = base.prototype.__tostring
end
end
local function __TS__ObjectFromEntries(entries)
local obj = {}
local iterable = entries
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
local value = result.value
obj[value[1]] = value[2]
end
else
for ____, entry in ipairs(entries) do
obj[entry[1]] = entry[2]
end
end
return obj
end
local function __TS__ObjectDefineProperty(target, key, desc)
local luaKey = type(key) == "number" and key + 1 or key
local value = rawget(target, luaKey)
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
local descriptor
if hasGetterOrSetter then
if value ~= nil then
error(
"Cannot redefine property: " .. tostring(key),
0
)
end
descriptor = desc
else
local valueExists = value ~= nil
local ____desc_set_4 = desc.set
local ____desc_get_5 = desc.get
local ____temp_0
if desc.configurable ~= nil then
____temp_0 = desc.configurable
else
____temp_0 = valueExists
end
local ____temp_1
if desc.enumerable ~= nil then
____temp_1 = desc.enumerable
else
____temp_1 = valueExists
end
local ____temp_2
if desc.writable ~= nil then
____temp_2 = desc.writable
else
____temp_2 = valueExists
end
local ____temp_3
if desc.value ~= nil then
____temp_3 = desc.value
else
____temp_3 = value
end
descriptor = {
set = ____desc_set_4,
get = ____desc_get_5,
configurable = ____temp_0,
enumerable = ____temp_1,
writable = ____temp_2,
value = ____temp_3
}
end
__TS__SetDescriptor(target, luaKey, descriptor)
return target
end
local function __TS__ArrayUnshift(self, ...)
local items = {...}
local numItemsToInsert = #items
if numItemsToInsert == 0 then
return #self
end
for i = #self, 1, -1 do
self[i + numItemsToInsert] = self[i]
end
for i = 1, numItemsToInsert do
self[i] = items[i]
end
return #self
end
local function __TS__ArrayIsArray(value)
return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
end
local function __TS__ArrayFlatMap(self, callback, thisArg)
local result = {}
local len = 0
for i = 1, #self do
local value = callback(thisArg, self[i], i - 1, self)
if __TS__ArrayIsArray(value) then
for j = 1, #value do
len = len + 1
result[len] = value[j]
end
else
len = len + 1
result[len] = value
end
end
return result
end
local function __TS__SparseArrayNew(...)
local sparseArray = {...}
sparseArray.sparseLength = __TS__CountVarargs(...)
return sparseArray
end
local function __TS__SparseArrayPush(sparseArray, ...)
local args = {...}
local argsLen = __TS__CountVarargs(...)
local listLen = sparseArray.sparseLength
for i = 1, argsLen do
sparseArray[listLen + i] = args[i]
end
sparseArray.sparseLength = listLen + argsLen
end
local function __TS__SparseArraySpread(sparseArray)
local _unpack = unpack or table.unpack
return _unpack(sparseArray, 1, sparseArray.sparseLength)
end
local function __TS__ObjectAssign(target, ...)
local sources = {...}
for i = 1, #sources do
local source = sources[i]
for key in pairs(source) do
target[key] = source[key]
end
end
return target
end
local function __TS__ObjectValues(obj)
local result = {}
local len = 0
for key in pairs(obj) do
len = len + 1
result[len] = obj[key]
end
return result
end
local function __TS__StringIncludes(self, searchString, position)
if not position then
position = 1
else
position = position + 1
end
local index = string.find(self, searchString, position, true)
return index ~= nil
end
local function __TS__Spread(iterable)
local arr = {}
if type(iterable) == "string" then
for i = 0, #iterable - 1 do
arr[i + 1] = __TS__StringAccess(iterable, i)
end
else
local len = 0
for ____, item in __TS__Iterator(iterable) do
len = len + 1
arr[len] = item
end
end
return __TS__Unpack(arr)
end
local function __TS__ObjectKeys(obj)
local result = {}
local len = 0
for key in pairs(obj) do
len = len + 1
result[len] = key
end
return result
end
local __TS__StringReplaceAll
do
local sub = string.sub
local find = string.find
function __TS__StringReplaceAll(source, searchValue, replaceValue)
if type(replaceValue) == "string" then
local concat = table.concat(
__TS__StringSplit(source, searchValue),
replaceValue
)
if #searchValue == 0 then
return (replaceValue .. concat) .. replaceValue
end
return concat
end
local parts = {}
local partsIndex = 1
if #searchValue == 0 then
parts[1] = replaceValue(nil, "", 0, source)
partsIndex = 2
for i = 1, #source do
parts[partsIndex] = sub(source, i, i)
parts[partsIndex + 1] = replaceValue(nil, "", i, source)
partsIndex = partsIndex + 2
end
else
local currentPos = 1
while true do
local startPos, endPos = find(source, searchValue, currentPos, true)
if not startPos then
break
end
parts[partsIndex] = sub(source, currentPos, startPos - 1)
parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source)
partsIndex = partsIndex + 2
currentPos = endPos + 1
end
parts[partsIndex] = sub(source, currentPos)
end
return table.concat(parts)
end
end
local __TS__StringReplace
do
local sub = string.sub
function __TS__StringReplace(source, searchValue, replaceValue)
local startPos, endPos = string.find(source, searchValue, nil, true)
if not startPos then
return source
end
local before = sub(source, 1, startPos - 1)
local replacement = type(replaceValue) == "string" and replaceValue or replaceValue(nil, searchValue, startPos - 1, source)
local after = sub(source, endPos + 1)
return (before .. replacement) .. after
end
end
local function __TS__Number(value)
local valueType = type(value)
if valueType == "number" then
return value
elseif valueType == "string" then
local numberValue = tonumber(value)
if numberValue then
return numberValue
end
if value == "Infinity" then
return math.huge
end
if value == "-Infinity" then
return -math.huge
end
local stringWithoutSpaces = string.gsub(value, "%s", "")
if stringWithoutSpaces == "" then
return 0
end
return 0 / 0
elseif valueType == "boolean" then
return value and 1 or 0
else
return 0 / 0
end
end
local function __TS__NumberIsFinite(value)
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
end
local function __TS__NumberIsInteger(value)
return __TS__NumberIsFinite(value) and math.floor(value) == value
end
local function __TS__NumberIsNaN(value)
return value ~= value
end
local function __TS__StringStartsWith(self, searchString, position)
if position == nil or position < 0 then
position = 0
end
return string.sub(self, position + 1, #searchString + position) == searchString
end
local function __TS__StringEndsWith(self, searchString, endPosition)
if endPosition == nil or endPosition > #self then
endPosition = #self
end
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
end
local function __TS__PromiseAll(iterable)
local results = {}
local toResolve = {}
local numToResolve = 0
local i = 0
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
results[i + 1] = item.value
elseif item.state == 2 then
return __TS__Promise.reject(item.rejectionReason)
else
numToResolve = numToResolve + 1
toResolve[i] = item
end
else
results[i + 1] = item
end
i = i + 1
end
if numToResolve == 0 then
return __TS__Promise.resolve(results)
end
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
for index, promise in pairs(toResolve) do
promise["then"](
promise,
function(____, data)
results[index + 1] = data
numToResolve = numToResolve - 1
if numToResolve == 0 then
resolve(nil, results)
end
end,
function(____, reason)
reject(nil, reason)
end
)
end
end
)
end
local function __TS__ArrayJoin(self, separator)
if separator == nil then
separator = ","
end
local parts = {}
for i = 1, #self do
parts[i] = tostring(self[i])
end
return table.concat(parts, separator)
end
local function __TS__PromiseRace(iterable)
local pending = {}
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
return __TS__Promise.resolve(item.value)
elseif item.state == 2 then
return __TS__Promise.reject(item.rejectionReason)
else
pending[#pending + 1] = item
end
else
return __TS__Promise.resolve(item)
end
end
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
for ____, promise in ipairs(pending) do
promise["then"](
promise,
function(____, value) return resolve(nil, value) end,
function(____, reason) return reject(nil, reason) end
)
end
end
)
end
local function __TS__StringSubstring(self, start, ____end)
if ____end ~= ____end then
____end = 0
end
if ____end ~= nil and start > ____end then
start, ____end = ____end, start
end
if start >= 0 then
start = start + 1
else
start = 1
end
if ____end ~= nil and ____end < 0 then
____end = 0
end
return string.sub(self, start, ____end)
end
local __TS__Match = string.match
local __TS__ParseInt
do
local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
function __TS__ParseInt(numberString, base)
if base == nil then
base = 10
local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
if hexMatch ~= nil then
base = 16
numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch)
end
end
if base < 2 or base > 36 then
return 0 / 0
end
local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
local number = tonumber((__TS__Match(numberString, pattern)), base)
if number == nil then
return 0 / 0
end
if number >= 0 then
return math.floor(number)
else
return math.ceil(number)
end
end
end
local function __TS__ArrayPush(self, ...)
local items = {...}
local len = #self
for i = 1, #items do
len = len + 1
self[len] = items[i]
end
return len
end
local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
do
local function getErrorStack(self, constructor)
if debug == nil then
return nil
end
local level = 1
while true do
local info = debug.getinfo(level, "f")
level = level + 1
if not info then
level = 1
break
elseif info.func == constructor then
break
end
end
if __TS__StringIncludes(_VERSION, "Lua 5.0") then
return debug.traceback(("[Level " .. tostring(level)) .. "]")
else
return debug.traceback(nil, level)
end
end
local function wrapErrorToString(self, getDescription)
return function(self)
local description = getDescription(self)
local caller = debug.getinfo(3, "f")
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0") or _VERSION == "Lua 5.1"
if isClassicLua or caller and caller.func ~= error then
return description
else
return (description .. "\n") .. tostring(self.stack)
end
end
end
local function initErrorClass(self, Type, name)
Type.name = name
return setmetatable(
Type,
{__call = function(____, _self, message) return __TS__New(Type, message) end}
)
end
local ____initErrorClass_1 = initErrorClass
local ____class_0 = __TS__Class()
____class_0.name = ""
function ____class_0.prototype.____constructor(self, message)
if message == nil then
message = ""
end
self.message = message
self.name = "Error"
self.stack = getErrorStack(nil, self.constructor.new)
local metatable = getmetatable(self)
if metatable and not metatable.__errorToStringPatched then
metatable.__errorToStringPatched = true
metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
end
end
function ____class_0.prototype.__tostring(self)
return self.message ~= "" and (self.name .. ": ") .. self.message or self.name
end
Error = ____initErrorClass_1(nil, ____class_0, "Error")
local function createErrorClass(self, name)
local ____initErrorClass_3 = initErrorClass
local ____class_2 = __TS__Class()
____class_2.name = ____class_2.name
__TS__ClassExtends(____class_2, Error)
function ____class_2.prototype.____constructor(self, ...)
____class_2.____super.prototype.____constructor(self, ...)
self.name = name
end
return ____initErrorClass_3(nil, ____class_2, name)
end
RangeError = createErrorClass(nil, "RangeError")
ReferenceError = createErrorClass(nil, "ReferenceError")
SyntaxError = createErrorClass(nil, "SyntaxError")
TypeError = createErrorClass(nil, "TypeError")
URIError = createErrorClass(nil, "URIError")
end
local function __TS__ObjectGetOwnPropertyDescriptors(object)
local metatable = getmetatable(object)
if not metatable then
return {}
end
return rawget(metatable, "_descriptors") or ({})
end
local function __TS__Delete(target, key)
local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
local descriptor = descriptors[key]
if descriptor then
if not descriptor.configurable then
error(
__TS__New(
TypeError,
((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
),
0
)
end
descriptors[key] = nil
return true
end
target[key] = nil
return true
end
local function __TS__ArrayFlat(self, depth)
if depth == nil then
depth = 1
end
local result = {}
local len = 0
for i = 1, #self do
local value = self[i]
if depth > 0 and __TS__ArrayIsArray(value) then
local toAdd
if depth == 1 then
toAdd = value
else
toAdd = __TS__ArrayFlat(value, depth - 1)
end
for j = 1, #toAdd do
local val = toAdd[j]
len = len + 1
result[len] = val
end
else
len = len + 1
result[len] = value
end
end
return result
end
local Map
do
Map = __TS__Class()
Map.name = "Map"
function Map.prototype.____constructor(self, entries)
self[Symbol.toStringTag] = "Map"
self.items = {}
self.size = 0
self.nextKey = {}
self.previousKey = {}
if entries == nil then
return
end
local iterable = entries
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
local value = result.value
self:set(value[1], value[2])
end
else
local array = entries
for ____, kvp in ipairs(array) do
self:set(kvp[1], kvp[2])
end
end
end
function Map.prototype.clear(self)
self.items = {}
self.nextKey = {}
self.previousKey = {}
self.firstKey = nil
self.lastKey = nil
self.size = 0
end
function Map.prototype.delete(self, key)
local contains = self:has(key)
if contains then
self.size = self.size - 1
local next = self.nextKey[key]
local previous = self.previousKey[key]
if next ~= nil and previous ~= nil then
self.nextKey[previous] = next
self.previousKey[next] = previous
elseif next ~= nil then
self.firstKey = next
self.previousKey[next] = nil
elseif previous ~= nil then
self.lastKey = previous
self.nextKey[previous] = nil
else
self.firstKey = nil
self.lastKey = nil
end
self.nextKey[key] = nil
self.previousKey[key] = nil
end
self.items[key] = nil
return contains
end
function Map.prototype.forEach(self, callback)
for ____, key in __TS__Iterator(self:keys()) do
callback(nil, self.items[key], key, self)
end
end
function Map.prototype.get(self, key)
return self.items[key]
end
function Map.prototype.has(self, key)
return self.nextKey[key] ~= nil or self.lastKey == key
end
function Map.prototype.set(self, key, value)
local isNewValue = not self:has(key)
if isNewValue then
self.size = self.size + 1
end
self.items[key] = value
if self.firstKey == nil then
self.firstKey = key
self.lastKey = key
elseif isNewValue then
self.nextKey[self.lastKey] = key
self.previousKey[key] = self.lastKey
self.lastKey = key
end
return self
end
Map.prototype[Symbol.iterator] = function(self)
return self:entries()
end
function Map.prototype.entries(self)
local items = self.items
local nextKey = self.nextKey
local key = self.firstKey
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
local result = {done = not key, value = {key, items[key]}}
key = nextKey[key]
return result
end
}
end
function Map.prototype.keys(self)
local nextKey = self.nextKey
local key = self.firstKey
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
local result = {done = not key, value = key}
key = nextKey[key]
return result
end
}
end
function Map.prototype.values(self)
local items = self.items
local nextKey = self.nextKey
local key = self.firstKey
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
local result = {done = not key, value = items[key]}
key = nextKey[key]
return result
end
}
end
Map[Symbol.species] = Map
end
return {
__TS__Class = __TS__Class,
__TS__New = __TS__New,
__TS__ArraySplice = __TS__ArraySplice,
__TS__ArrayIncludes = __TS__ArrayIncludes,
__TS__ArrayIndexOf = __TS__ArrayIndexOf,
__TS__ArrayMap = __TS__ArrayMap,
__TS__SetDescriptor = __TS__SetDescriptor,
__TS__ArraySlice = __TS__ArraySlice,
__TS__ArrayPushArray = __TS__ArrayPushArray,
__TS__DelegatedYield = __TS__DelegatedYield,
__TS__Generator = __TS__Generator,
__TS__ArrayEntries = __TS__ArrayEntries,
__TS__Iterator = __TS__Iterator,
__TS__AsyncAwaiter = __TS__AsyncAwaiter,
__TS__Await = __TS__Await,
__TS__StringSlice = __TS__StringSlice,
__TS__StringSplit = __TS__StringSplit,
__TS__ArrayFilter = __TS__ArrayFilter,
__TS__StringAccess = __TS__StringAccess,
__TS__ClassExtends = __TS__ClassExtends,
__TS__ObjectFromEntries = __TS__ObjectFromEntries,
__TS__ObjectDefineProperty = __TS__ObjectDefineProperty,
__TS__ArrayUnshift = __TS__ArrayUnshift,
__TS__ArrayFlatMap = __TS__ArrayFlatMap,
__TS__SparseArrayNew = __TS__SparseArrayNew,
__TS__SparseArrayPush = __TS__SparseArrayPush,
__TS__SparseArraySpread = __TS__SparseArraySpread,
__TS__Promise = __TS__Promise,
__TS__ObjectAssign = __TS__ObjectAssign,
__TS__ObjectValues = __TS__ObjectValues,
__TS__StringIncludes = __TS__StringIncludes,
__TS__Spread = __TS__Spread,
__TS__ObjectKeys = __TS__ObjectKeys,
__TS__StringReplaceAll = __TS__StringReplaceAll,
__TS__StringReplace = __TS__StringReplace,
__TS__Number = __TS__Number,
__TS__NumberIsInteger = __TS__NumberIsInteger,
__TS__NumberIsNaN = __TS__NumberIsNaN,
__TS__StringStartsWith = __TS__StringStartsWith,
__TS__StringEndsWith = __TS__StringEndsWith,
__TS__PromiseAll = __TS__PromiseAll,
__TS__ArrayJoin = __TS__ArrayJoin,
__TS__PromiseRace = __TS__PromiseRace,
__TS__ParseInt = __TS__ParseInt,
__TS__InstanceOf = __TS__InstanceOf,
__TS__ArrayPush = __TS__ArrayPush,
__TS__Delete = __TS__Delete,
__TS__ArrayFlat = __TS__ArrayFlat,
Map = Map
}